GeoTessCPP  2.0.0
Software to facilitate storage and retrieval of 3D information about the Earth.
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
ProfileEmpty.h
Go to the documentation of this file.
1 //- ****************************************************************************
2 //-
3 //- Copyright 2009 Sandia Corporation. Under the terms of Contract
4 //- DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
5 //- retains certain rights in this software.
6 //-
7 //- BSD Open Source License.
8 //- All rights reserved.
9 //-
10 //- Redistribution and use in source and binary forms, with or without
11 //- modification, are permitted provided that the following conditions are met:
12 //-
13 //- * Redistributions of source code must retain the above copyright notice,
14 //- this list of conditions and the following disclaimer.
15 //- * Redistributions in binary form must reproduce the above copyright
16 //- notice, this list of conditions and the following disclaimer in the
17 //- documentation and/or other materials provided with the distribution.
18 //- * Neither the name of Sandia National Laboratories nor the names of its
19 //- contributors may be used to endorse or promote products derived from
20 //- this software without specific prior written permission.
21 //-
22 //- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 //- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 //- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 //- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26 //- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 //- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 //- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 //- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 //- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 //- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 //- POSSIBILITY OF SUCH DAMAGE.
33 //-
34 //- ****************************************************************************
35 
36 #ifndef PROFILEEMPTY_OBJECT_H
37 #define PROFILEEMPTY_OBJECT_H
38 
39 // **** _SYSTEM INCLUDES_ ******************************************************
40 
41 #include <iostream>
42 #include <string>
43 #include <fstream>
44 
45 // use standard library objects
46 using namespace std;
47 
48 // **** _LOCAL INCLUDES_ *******************************************************
49 
50 #include "Profile.h"
51 #include "ProfileType.h"
52 #include "IFStreamAscii.h"
53 #include "IFStreamBinary.h"
54 
55 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
56 
57 namespace geotess {
58 
59 // **** _FORWARD REFERENCES_ ***************************************************
60 
61 class Data;
62 
63 // **** _CLASS DEFINITION_ *****************************************************
64 
74 class GEOTESS_EXP_IMP ProfileEmpty : virtual public Profile
75 {
76  private:
77 
81  float radiusTop;
82 
86  float radiusBottom;
87 
91  ProfileEmpty() : Profile(), radiusTop(0.0), radiusBottom(0.0) {};
92 
93  public:
94 
98  ProfileEmpty(float radBot, float radTop) : Profile(),
99  radiusTop(radTop), radiusBottom(radBot)
100  {}
101 
106  { radiusBottom = ifs.readFloat();
107  radiusTop = ifs.readFloat();
108  }
109 
114  { radiusBottom = ifs.readFloat();
115  radiusTop = ifs.readFloat();
116  }
117 
121  ProfileEmpty(float radii[], int &rIndex) : Profile()
122  { radiusBottom = radii[rIndex++];
123  radiusTop = radii[rIndex++];
124  }
125 
129  virtual ~ProfileEmpty() {};
130 
134  static string class_name() { return "ProfileEmpty"; };
135 
139  virtual int class_size() const
140  { return (int) sizeof(ProfileEmpty); };
141 
147  virtual const ProfileType& getType() const
148  { return ProfileType::EMPTY; };
149 
153  virtual bool operator == (const Profile& p) const
154  { return (Profile::operator==(p) &&
155  (radiusBottom == p.getRadiusBottom()) &&
156  (radiusTop == p.getRadiusTop()));
157  }
158 
163  virtual double getValue(const InterpolatorType& rInterpType,
164  int attributeIndex, double radius,
165  bool allowRadiusOutOfRange) const;
166 
175  virtual double getValue(int attributeIndex, int nodeIndex) const
176  { return NaN_DOUBLE; }
177 
188  virtual bool isNaN(int nodeIndex, int attributeIndex)
189  {
190  return true;
191  }
192 
193  // *** TODO added 7/20/2012
200  virtual double getValueTop(int attributeIndex) const
201  {
202  return NaN_DOUBLE;
203  }
204 
205  // *** TODO added 7/20/2012
212  virtual double getValueBottom(int attributeIndex) const
213  {
214  return NaN_DOUBLE;
215  }
216 
221  virtual float getRadius(int i) const
222  { return i == 0 ? radiusBottom : radiusTop; };
223 
227  virtual int getNRadii() const { return 2; };
228 
232  virtual int getNData() const { return 0; };
233 
237  virtual float* getRadii()
238  { float* fa = new float [2]; fa[0] = radiusBottom; fa[1] = radiusTop; return fa; };
239 
244  virtual Data** getData();
245 
249  virtual Data* getData(int i);
250 
254  virtual const Data& getData(int i) const;
255 
259  virtual void setData(const vector<Data*>& inData)
260  {/* do nothing*/ };
261 
262  // TODO: added by sb 9/27/2012
266  virtual void setRadii(const vector<float>& newRadii)
267  { radiusBottom = newRadii[0]; radiusTop = newRadii[1]; }
268 
269  // *** TODO added 7/19/2012
273  virtual void setData(int index, Data* inData)
274  { /* do nothing*/ };
275 
279  virtual float getRadiusTop() const { return radiusTop; };
280 
284  virtual const Data& getDataTop() const;
285 
289  virtual Data* getDataTop() { return NULL; }
290 
294  virtual float getRadiusBottom() const { return radiusBottom; };
295 
299  virtual const Data& getDataBottom() const;
300 
304  virtual Data* getDataBottom() { return NULL; }
305 
309  virtual void write(IFStreamBinary& ofs)
310  { ofs.writeByte((byte) ProfileType::EMPTY.ordinal());
311  ofs.writeFloat(radiusBottom);
312  ofs.writeFloat(radiusTop); };
313 
317  virtual void write(IFStreamAscii& ofs)
318  { ofs.writeInt(ProfileType::EMPTY.ordinal());
319  ofs.writeString(" ");
320  ofs.writeFloat(radiusBottom);
321  ofs.writeString(" ");
322  ofs.writeFloatNL(radiusTop); };
323 
324  // *** TODO added 7/20/2012
333  virtual int findClosestRadiusIndex(double radius) const
334  { return abs(radiusTop - radius) < abs(radiusBottom - radius) ? 1 : 0; }
335 
336  // *** TODO added 7/20/2012
344  virtual void setPointIndex(int nodeIndex, int pointIndex)
345  {
346  // do nothing. empty profiles have no data, hence pointIndex is always -1.
347  }
348 
349  // *** TODO added 10/14/2012
357  virtual void resetPointIndices() { /* empty profiles have no data, hence pointIndex is always -1. */ }
358 
359  // *** TODO added 7/20/2012
367  virtual int getPointIndex(int nodeIndex) const
368  { return -1; }
369 
370  // *** TODO added 7/20/2012
377  virtual void getWeights(map<int, double>& weights,
378  double dkm, double radius, double hcoefficient) const
379  {
380  // do nothing.
381  }
382 
383  // *** TODO added 7/26/2012
387  virtual void getCoefficients(map<int, double>& coefficients, double radius,
388  double horizontalCoefficient) const
389  {
390  // do nothing.
391  }
392 
393  virtual void setInterpolationCoefficients(const InterpolatorType& interpType,
394  vector<int>& nodeIndexes, vector<double>& coefficients,
395  double& radius, bool& allowOutOfRange)
396  {
397  // POISON!
398  nodeIndexes.push_back(0);
399  coefficients.push_back(NaN_DOUBLE);
400  }
401 
402  // *** TODO added 8/20/2012
406  virtual Profile* copy()
407  {
408  return new ProfileEmpty(radiusBottom, radiusTop);
409  }
410 
412 
414 
415 }; // end class ProfileEmpty
416 
417 } // end namespace geotess
418 
419 #endif // PROFILEEMPTY_OBJECT_H