GeoTessCPP  2.2
Software to facilitate storage and retrieval of 3D information about the Earth.
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 
142  virtual LONG_INT getMemory() { return (LONG_INT)(sizeof(GeoTessProfileEmpty)); };
143 
149  virtual const GeoTessProfileType& getType() const
150  { return GeoTessProfileType::EMPTY; };
151 
155  virtual bool operator == (const GeoTessProfile& p) const
156  { return (GeoTessProfile::operator==(p) &&
157  (radiusBottom == p.getRadiusBottom()) &&
158  (radiusTop == p.getRadiusTop()));
159  }
160 
165  virtual double getValue(const GeoTessInterpolatorType& rInterpType,
166  int attributeIndex, double radius,
167  bool allowRadiusOutOfRange) const;
168 
177  virtual double getValue(int attributeIndex, int nodeIndex) const
178  { return NaN_DOUBLE; }
179 
190  virtual bool isNaN(int nodeIndex, int attributeIndex)
191  {
192  return true;
193  }
194 
195  // *** TODO added 7/20/2012
202  virtual double getValueTop(int attributeIndex) const
203  {
204  return NaN_DOUBLE;
205  }
206 
207  // *** TODO added 7/20/2012
214  virtual double getValueBottom(int attributeIndex) const
215  {
216  return NaN_DOUBLE;
217  }
218 
223  virtual float getRadius(int i) const
224  { return i == 0 ? radiusBottom : radiusTop; };
225 
229  virtual int getNRadii() const { return 2; };
230 
234  virtual int getNData() const { return 0; };
235 
239  virtual float* getRadii()
240  { float* fa = new float [2]; fa[0] = radiusBottom; fa[1] = radiusTop; return fa; };
241 
246  virtual GeoTessData** getData();
247 
251  virtual GeoTessData* getData(int i);
252 
256  virtual const GeoTessData& getData(int i) const;
257 
261  virtual void setData(const vector<GeoTessData*>& inData)
262  {/* do nothing*/ };
263 
264  // TODO: added by sb 9/27/2012
268  virtual void setRadii(const vector<float>& newRadii)
269  { radiusBottom = newRadii[0]; radiusTop = newRadii[1]; }
270 
271  virtual void setRadius(int index, float radius)
272  {
273  switch (index)
274  {
275  case 0:
276  radiusBottom = radius;
277  break;
278  case 1:
279  radiusTop = radius;
280  break;
281  }
282  }
283  // *** TODO added 7/19/2012
287  virtual void setData(int index, GeoTessData* inData)
288  { /* do nothing*/ };
289 
293  virtual float getRadiusTop() const { return radiusTop; };
294 
298  virtual const GeoTessData& getDataTop() const;
299 
303  virtual GeoTessData* getDataTop() { return NULL; }
304 
308  virtual float getRadiusBottom() const { return radiusBottom; };
309 
313  virtual const GeoTessData& getDataBottom() const;
314 
318  virtual GeoTessData* getDataBottom() { return NULL; }
319 
323  virtual void write(IFStreamBinary& ofs)
324  { ofs.writeByte((byte) GeoTessProfileType::EMPTY.ordinal());
325  ofs.writeFloat(radiusBottom);
326  ofs.writeFloat(radiusTop); };
327 
331  virtual void write(IFStreamAscii& ofs)
332  { ofs.writeInt(GeoTessProfileType::EMPTY.ordinal());
333  ofs.writeString(" ");
334  ofs.writeFloat(radiusBottom);
335  ofs.writeString(" ");
336  ofs.writeFloatNL(radiusTop); };
337 
338  // *** TODO added 7/20/2012
347  virtual int findClosestRadiusIndex(double radius) const
348  { return abs(radiusTop - radius) < abs(radiusBottom - radius) ? 1 : 0; }
349 
350  // *** TODO added 7/20/2012
358  virtual void setPointIndex(int nodeIndex, int pointIndex)
359  {
360  // do nothing. empty profiles have no data, hence pointIndex is always -1.
361  }
362 
363  // *** TODO added 10/14/2012
371  virtual void resetPointIndices() { /* empty profiles have no data, hence pointIndex is always -1. */ }
372 
373  // *** TODO added 7/20/2012
381  virtual int getPointIndex(int nodeIndex) const
382  { return -1; }
383 
384  // *** TODO added 7/20/2012
391  virtual void getWeights(map<int, double>& weights,
392  double dkm, double radius, double hcoefficient) const
393  {
394  // do nothing.
395  }
396 
397  // *** TODO added 7/26/2012
401  virtual void getCoefficients(map<int, double>& coefficients, double radius,
402  double horizontalCoefficient) const
403  {
404  // do nothing.
405  }
406 
408  vector<int>& nodeIndexes, vector<double>& coefficients,
409  double& radius, bool& allowOutOfRange)
410  {
411  // POISON!
412  nodeIndexes.push_back(0);
413  coefficients.push_back(NaN_DOUBLE);
414  }
415 
416  // *** TODO added 8/20/2012
420  virtual GeoTessProfile* copy()
421  {
422  return new GeoTessProfileEmpty(radiusBottom, radiusTop);
423  }
424 
426 
428 
429 }; // end class ProfileEmpty
430 
431 } // end namespace geotess
432 
433 #endif // PROFILEEMPTY_OBJECT_H
virtual double getValue(int attributeIndex, int nodeIndex) const
Retrieve the value of the specified attribute interpolated from this profile at the specified radius ...
Definition: GeoTessProfileEmpty.h:177
virtual float getRadiusBottom() const
Get the radius at the bottom of the profile, in km.
Definition: GeoTessProfileEmpty.h:308
virtual float getRadiusTop() const
Get the radius at the top of the profile, in km.
Definition: GeoTessProfileEmpty.h:293
void writeFloat(float f)
Write float data.
Definition: IFStreamBinary.h:1716
virtual float getRadius(int i) const
Get the i'th radius value in this profile in km.
Definition: GeoTessProfileEmpty.h:223
GeoTessProfileEmpty(IFStreamAscii &ifs)
Standard constructor.
Definition: GeoTessProfileEmpty.h:113
static string class_name()
Returns the class name.
Definition: GeoTessProfileEmpty.h:134
void writeByte(byte b)
Write byte data.
Definition: IFStreamBinary.h:1408
virtual void setInterpolationCoefficients(const GeoTessInterpolatorType &interpType, vector< int > &nodeIndexes, vector< double > &coefficients, double &radius, bool &allowOutOfRange)
Definition: GeoTessProfileEmpty.h:407
Definition: ArrayReuse.h:55
virtual int getNRadii() const
Get the number of radii that comprise this profile.
Definition: GeoTessProfileEmpty.h:229
virtual bool isNaN(int nodeIndex, int attributeIndex)
Return true if the specified Data value is NaN.
Definition: GeoTessProfileEmpty.h:190
virtual const GeoTessProfileType & getType() const
Returns ProfileType (EMPTY).
Definition: GeoTessProfileEmpty.h:149
virtual void write(IFStreamAscii &ofs)
Write the radii and data values to binary file.
Definition: GeoTessProfileEmpty.h:331
virtual GeoTessProfile * copy()
Returns a deep copy of this profile.
Definition: GeoTessProfileEmpty.h:420
Opens a file for binary read and write access.
Definition: IFStreamBinary.h:79
GeoTessProfileEmpty(float radBot, float radTop)
Default constructor.
Definition: GeoTessProfileEmpty.h:98
virtual GeoTessData * getDataTop()
Get the Data object at the top of the profile.
Definition: GeoTessProfileEmpty.h:303
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
Get the pointIndex that corresponds to the supplied nodeIndex.
Definition: GeoTessProfileEmpty.h:381
virtual LONG_INT getMemory()
Definition: GeoTessProfileEmpty.h:142
Enumeration of the valid Profile types, including EMPTY, THIN, CONSTANT, NPOINT and SURFACE...
Definition: GeoTessProfileType.h:69
virtual ~GeoTessProfileEmpty()
Default destructor.
Definition: GeoTessProfileEmpty.h:129
virtual double getValueBottom(int attributeIndex) const
Retrieve the value of the specified attribute at the bottom of the layer.
Definition: GeoTessProfileEmpty.h:214
void writeFloatNL(float f)
Definition: IFStreamAscii.h:509
virtual void setPointIndex(int nodeIndex, int pointIndex)
Set the pointIndex that corresponds to the supplied nodeIndex.
Definition: GeoTessProfileEmpty.h:358
virtual double getValueTop(int attributeIndex) const
Retrieve the value of the specified attribute at the top of the layer.
Definition: GeoTessProfileEmpty.h:202
void writeInt(int i)
Definition: IFStreamAscii.h:500
virtual void setRadii(const vector< float > &newRadii)
Replace the radii currently associated with this Profile with new values.
Definition: GeoTessProfileEmpty.h:268
virtual float getRadiusTop() const
Get the radius at the top of the profile, in km.
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
Find the index of the node in this Profile that has radius closest to the supplied radius...
Definition: GeoTessProfileEmpty.h:347
virtual void write(IFStreamBinary &ofs)
Write the radii and data values to binary file.
Definition: GeoTessProfileEmpty.h:323
float readFloat()
Read and return the next float.
Definition: IFStreamAscii.h:741
float readFloat()
Read float data.
Definition: IFStreamBinary.h:1117
#define LONG_INT
Definition: CPPGlobals.h:111
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
Get the number of Data objects that comprise this profile.
Definition: GeoTessProfileEmpty.h:234
virtual void setRadius(int index, float radius)
Replace the radius at the specified nodeIndex.
Definition: GeoTessProfileEmpty.h:271
virtual void setData(int index, GeoTessData *inData)
Resets the data object at index to the new input data.
Definition: GeoTessProfileEmpty.h:287
virtual GeoTessData * getDataBottom()
Get the Data object at the bottom of the profile.
Definition: GeoTessProfileEmpty.h:318
virtual void getCoefficients(map< int, double > &coefficients, double radius, double horizontalCoefficient) const
Definition: GeoTessProfileEmpty.h:401
virtual int class_size() const
Returns the class size.
Definition: GeoTessProfileEmpty.h:139
virtual float * getRadii()
Retrieve a deeep copy of the radii values in km.
Definition: GeoTessProfileEmpty.h:239
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
GeoTessProfileEmpty(IFStreamBinary &ifs)
Standard constructor.
Definition: GeoTessProfileEmpty.h:105
void writeString(const string &s)
Definition: IFStreamAscii.h:484
GeoTessProfileEmpty(float radii[], int &rIndex)
Standard constructor creates references into the supplied array of radii.
Definition: GeoTessProfileEmpty.h:121
virtual void setData(const vector< GeoTessData * > &inData)
Resets the data object to the new input data.
Definition: GeoTessProfileEmpty.h:261
virtual void resetPointIndices()
Reset all the pointIndex values to -1.
Definition: GeoTessProfileEmpty.h:371
virtual float getRadiusBottom() const
Get the radius at the bottom of the profile, in km.
virtual void getWeights(map< int, double > &weights, double dkm, double radius, double hcoefficient) const
Add dkm * hcoefficient to the weight of this point index into the input map.
Definition: GeoTessProfileEmpty.h:391