GeoTessCPP  2.1
Software to facilitate storage and retrieval of 3D information about the Earth.
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
GeoTessProfileEmpty.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 "GeoTessProfile.h"
51 #include "GeoTessProfileType.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 GeoTessData;
62 
63 // **** _CLASS DEFINITION_ *****************************************************
64 
75 {
76  private:
77 
81  float radiusTop;
82 
86  float radiusBottom;
87 
91  GeoTessProfileEmpty() : GeoTessProfile(), radiusTop(0.0), radiusBottom(0.0) {};
92 
93  public:
94 
98  GeoTessProfileEmpty(float radBot, float radTop) : GeoTessProfile(),
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  GeoTessProfileEmpty(float radii[], int &rIndex) : GeoTessProfile()
122  { radiusBottom = radii[rIndex++];
123  radiusTop = radii[rIndex++];
124  }
125 
129  virtual ~GeoTessProfileEmpty() {};
130 
134  static string class_name() { return "ProfileEmpty"; };
135 
139  virtual int class_size() const
140  { return (int) sizeof(GeoTessProfileEmpty); };
141 
147  virtual const GeoTessProfileType& getType() const
148  { return GeoTessProfileType::EMPTY; };
149 
153  virtual bool operator == (const GeoTessProfile& p) const
154  { return (GeoTessProfile::operator==(p) &&
155  (radiusBottom == p.getRadiusBottom()) &&
156  (radiusTop == p.getRadiusTop()));
157  }
158 
163  virtual double getValue(const GeoTessInterpolatorType& 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 GeoTessData** getData();
245 
249  virtual GeoTessData* getData(int i);
250 
254  virtual const GeoTessData& getData(int i) const;
255 
259  virtual void setData(const vector<GeoTessData*>& 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  virtual void setRadius(int index, float radius)
270  {
271  switch (index)
272  {
273  case 0:
274  radiusBottom = radius;
275  break;
276  case 1:
277  radiusTop = radius;
278  break;
279  }
280  }
281  // *** TODO added 7/19/2012
285  virtual void setData(int index, GeoTessData* inData)
286  { /* do nothing*/ };
287 
291  virtual float getRadiusTop() const { return radiusTop; };
292 
296  virtual const GeoTessData& getDataTop() const;
297 
301  virtual GeoTessData* getDataTop() { return NULL; }
302 
306  virtual float getRadiusBottom() const { return radiusBottom; };
307 
311  virtual const GeoTessData& getDataBottom() const;
312 
316  virtual GeoTessData* getDataBottom() { return NULL; }
317 
321  virtual void write(IFStreamBinary& ofs)
322  { ofs.writeByte((byte) GeoTessProfileType::EMPTY.ordinal());
323  ofs.writeFloat(radiusBottom);
324  ofs.writeFloat(radiusTop); };
325 
329  virtual void write(IFStreamAscii& ofs)
330  { ofs.writeInt(GeoTessProfileType::EMPTY.ordinal());
331  ofs.writeString(" ");
332  ofs.writeFloat(radiusBottom);
333  ofs.writeString(" ");
334  ofs.writeFloatNL(radiusTop); };
335 
336  // *** TODO added 7/20/2012
345  virtual int findClosestRadiusIndex(double radius) const
346  { return abs(radiusTop - radius) < abs(radiusBottom - radius) ? 1 : 0; }
347 
348  // *** TODO added 7/20/2012
356  virtual void setPointIndex(int nodeIndex, int pointIndex)
357  {
358  // do nothing. empty profiles have no data, hence pointIndex is always -1.
359  }
360 
361  // *** TODO added 10/14/2012
369  virtual void resetPointIndices() { /* empty profiles have no data, hence pointIndex is always -1. */ }
370 
371  // *** TODO added 7/20/2012
379  virtual int getPointIndex(int nodeIndex) const
380  { return -1; }
381 
382  // *** TODO added 7/20/2012
389  virtual void getWeights(map<int, double>& weights,
390  double dkm, double radius, double hcoefficient) const
391  {
392  // do nothing.
393  }
394 
395  // *** TODO added 7/26/2012
399  virtual void getCoefficients(map<int, double>& coefficients, double radius,
400  double horizontalCoefficient) const
401  {
402  // do nothing.
403  }
404 
406  vector<int>& nodeIndexes, vector<double>& coefficients,
407  double& radius, bool& allowOutOfRange)
408  {
409  // POISON!
410  nodeIndexes.push_back(0);
411  coefficients.push_back(NaN_DOUBLE);
412  }
413 
414  // *** TODO added 8/20/2012
418  virtual GeoTessProfile* copy()
419  {
420  return new GeoTessProfileEmpty(radiusBottom, radiusTop);
421  }
422 
424 
426 
427 }; // end class ProfileEmpty
428 
429 } // end namespace geotess
430 
431 #endif // PROFILEEMPTY_OBJECT_H
virtual double getValue(int attributeIndex, int nodeIndex) const
Definition: GeoTessProfileEmpty.h:175
virtual float getRadiusBottom() const
Definition: GeoTessProfileEmpty.h:306
virtual float getRadiusTop() const
Definition: GeoTessProfileEmpty.h:291
void writeFloat(float f)
Definition: IFStreamBinary.h:1716
virtual float getRadius(int i) const
Definition: GeoTessProfileEmpty.h:221
GeoTessProfileEmpty(IFStreamAscii &ifs)
Definition: GeoTessProfileEmpty.h:113
static string class_name()
Definition: GeoTessProfileEmpty.h:134
void writeByte(byte b)
Definition: IFStreamBinary.h:1408
virtual void setInterpolationCoefficients(const GeoTessInterpolatorType &interpType, vector< int > &nodeIndexes, vector< double > &coefficients, double &radius, bool &allowOutOfRange)
Definition: GeoTessProfileEmpty.h:405
virtual int getNRadii() const
Definition: GeoTessProfileEmpty.h:227
virtual bool isNaN(int nodeIndex, int attributeIndex)
Definition: GeoTessProfileEmpty.h:188
virtual const GeoTessProfileType & getType() const
Definition: GeoTessProfileEmpty.h:147
virtual void write(IFStreamAscii &ofs)
Definition: GeoTessProfileEmpty.h:329
virtual GeoTessProfile * copy()
Definition: GeoTessProfileEmpty.h:418
Opens a file for binary read and write access.
Definition: IFStreamBinary.h:79
GeoTessProfileEmpty(float radBot, float radTop)
Definition: GeoTessProfileEmpty.h:98
virtual GeoTessData * getDataTop()
Definition: GeoTessProfileEmpty.h:301
Enumeration of the interpolation algorithms supported by GeoTess including LINEAR, NATURAL_NEIGHBOR and CUBIC_SPLINE.
Definition: GeoTessInterpolatorType.h:71
virtual int getPointIndex(int nodeIndex) const
Definition: GeoTessProfileEmpty.h:379
Enumeration of the valid Profile types, including EMPTY, THIN, CONSTANT, NPOINT and SURFACE...
Definition: GeoTessProfileType.h:69
virtual ~GeoTessProfileEmpty()
Definition: GeoTessProfileEmpty.h:129
virtual double getValueBottom(int attributeIndex) const
Definition: GeoTessProfileEmpty.h:212
void writeFloatNL(float f)
Definition: IFStreamAscii.h:509
virtual void setPointIndex(int nodeIndex, int pointIndex)
Definition: GeoTessProfileEmpty.h:356
virtual double getValueTop(int attributeIndex) const
Definition: GeoTessProfileEmpty.h:200
void writeInt(int i)
Definition: IFStreamAscii.h:500
virtual void setRadii(const vector< float > &newRadii)
Definition: GeoTessProfileEmpty.h:266
virtual float getRadiusTop() const
A Profile object that defines two radii at the bottom and top of the associated layer, and no Data.
Definition: GeoTessProfileEmpty.h:74
#define byte
signed-byte typedef
Definition: CPPGlobals.h:94
Opens ascii file for read and write access.
Definition: IFStreamAscii.h:80
virtual int findClosestRadiusIndex(double radius) const
Definition: GeoTessProfileEmpty.h:345
virtual void write(IFStreamBinary &ofs)
Definition: GeoTessProfileEmpty.h:321
float readFloat()
Definition: IFStreamAscii.h:741
float readFloat()
Definition: IFStreamBinary.h:1117
Abstract class that manages the radii and data values that span a single layer associated with a sing...
Definition: GeoTessProfile.h:96
Abstract base class that manages the data values attached to a single grid point. ...
Definition: GeoTessData.h:75
void writeFloat(float f)
Definition: IFStreamAscii.h:508
virtual int getNData() const
Definition: GeoTessProfileEmpty.h:232
virtual void setRadius(int index, float radius)
Definition: GeoTessProfileEmpty.h:269
virtual void setData(int index, GeoTessData *inData)
Definition: GeoTessProfileEmpty.h:285
virtual GeoTessData * getDataBottom()
Definition: GeoTessProfileEmpty.h:316
virtual void getCoefficients(map< int, double > &coefficients, double radius, double horizontalCoefficient) const
Definition: GeoTessProfileEmpty.h:399
virtual int class_size() const
Definition: GeoTessProfileEmpty.h:139
virtual float * getRadii()
Definition: GeoTessProfileEmpty.h:237
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
GeoTessProfileEmpty(IFStreamBinary &ifs)
Definition: GeoTessProfileEmpty.h:105
void writeString(const string &s)
Definition: IFStreamAscii.h:484
GeoTessProfileEmpty(float radii[], int &rIndex)
Definition: GeoTessProfileEmpty.h:121
virtual void setData(const vector< GeoTessData * > &inData)
Definition: GeoTessProfileEmpty.h:259
virtual void resetPointIndices()
Definition: GeoTessProfileEmpty.h:369
virtual float getRadiusBottom() const
virtual void getWeights(map< int, double > &weights, double dkm, double radius, double hcoefficient) const
Definition: GeoTessProfileEmpty.h:389