GeoTessCPP  2.2
Software to facilitate storage and retrieval of 3D information about the Earth.
GeoTessProfileSurface.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 PROFILESURFACE_OBJECT_H
37 #define PROFILESURFACE_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 "GeoTessUtils.h"
51 #include "GeoTessData.h"
52 #include "GeoTessProfile.h"
53 #include "GeoTessProfileType.h"
54 #include "IFStreamAscii.h"
55 #include "IFStreamBinary.h"
56 
57 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
58 
59 namespace geotess {
60 
61 // **** _FORWARD REFERENCES_ ***************************************************
62 
63 class GeoTessMetaData;
64 
65 // **** _CLASS DEFINITION_ *****************************************************
66 
77 {
78  private:
79 
83  GeoTessData* data;
84 
88  int pointIndex;
89 
93  GeoTessProfileSurface() : GeoTessProfile(), data(NULL),
94  pointIndex(-1) {};
95 
96  public:
97 
102  pointIndex(-1) {};
103 
107  static string class_name() { return "ProfileSurface"; };
108 
112  virtual int class_size() const
113  { return (int) sizeof(GeoTessProfileSurface); };
114 
115  virtual LONG_INT getMemory()
116  { return (LONG_INT)(sizeof(GeoTessProfileSurface) + data->getMemory()); }
117 
123  virtual const GeoTessProfileType& getType() const
124  { return GeoTessProfileType::SURFACE; };
125 
129  virtual bool operator == (const GeoTessProfile& p) const
130  { return (GeoTessProfile::operator==(p) &&
131  (*data == p.getData(0)));
132  }
133 
142  virtual double getValue(int attributeIndex, int nodeIndex) const
143  {
144  return nodeIndex == 0 ? data->getDouble(attributeIndex) : NaN_DOUBLE;
145  }
146 
153  virtual double getValueTop(int attributeIndex) const
154  { return data->getDouble(attributeIndex); }
155 
166  virtual bool isNaN(int nodeIndex, int attributeIndex)
167  {
168  return nodeIndex != 0 || data->isNaN(attributeIndex);
169  }
170 
175  virtual double getValue(const GeoTessInterpolatorType& rInterpType,
176  int attributeIndex, double radius,
177  bool allowRadiusOutOfRange) const
178  {
179  return getData(0).getDouble(attributeIndex);
180  }
181 
186  virtual float getRadius(int i) const
187  { return NaN_FLOAT; };
188 
192  virtual int getNRadii() const { return 0; };
193 
197  virtual int getNData() const { return 1; };
198 
202  virtual float* getRadii() { return NULL; };
203 
207  virtual GeoTessData** getData()
208  { GeoTessData** da = new GeoTessData* [1]; da[0] = data; return da; };
209 
213  virtual GeoTessData* getData(int i) { return data; };
214 
218  virtual const GeoTessData& getData(int i) const { return *data; };
219 
223  virtual void setData(const vector<GeoTessData*>& inData)
224  { delete data; data = inData[0]; }
225 
229  virtual void setData(int index, GeoTessData* inData)
230  { delete data; data = inData; }
231 
232  // TODO: added by sb 9/27/2012
236  virtual void setRadii(const vector<float>& newRadii)
237  { /* do nothing */ };
238 
239  virtual void setRadius(int index, float radius)
240  { /* do nothing */ }
241 
245  virtual float getRadiusTop() const
246  { return NaN_FLOAT; };
247 
251  virtual const GeoTessData& getDataTop() const { return *data; };
252 
256  virtual GeoTessData* getDataTop() { return data; };
257 
261  virtual float getRadiusBottom() const
262  { return NaN_FLOAT; };
263 
267  virtual const GeoTessData& getDataBottom() const { return *data; };
268 
272  virtual GeoTessData* getDataBottom() { return data; };
273 
275 
280  data(NULL), pointIndex(-1)
281  { data = GeoTessData::getData(ifs, gtmd); };
282 
286  GeoTessProfileSurface(IFStreamAscii& ifs, GeoTessMetaData& gtmd) : GeoTessProfile(),
287  data(NULL), pointIndex(-1)
288  { data = GeoTessData::getData(ifs, gtmd); };
289 
294  virtual ~GeoTessProfileSurface() { if (data != NULL) delete data; };
295 
299  virtual void write(IFStreamBinary& ofs)
300  { ofs.writeByte((byte) GeoTessProfileType::SURFACE.ordinal());
301  data->write(ofs); };
302 
306  virtual void write(IFStreamAscii& ofs)
307  { ofs.writeInt(GeoTessProfileType::SURFACE.ordinal());
308  data->write(ofs);
309  ofs.writeNL(); };
310 
311  // *** TODO added 7/20/2012
320  virtual int findClosestRadiusIndex(double radius) const
321  { return -1; }
322 
323  // *** TODO added 7/20/2012
331  virtual void setPointIndex(int nodeIndex, int pntIndex)
332  { pointIndex = pntIndex; }
333 
334  // *** TODO added 10/14/2012
342  virtual void resetPointIndices() { pointIndex = -1; }
343 
344  // *** TODO added 7/20/2012
352  virtual int getPointIndex(int nodeIndex) const
353  { return pointIndex; }
354 
355  // *** TODO added 8/20/2012
359  virtual GeoTessProfile* copy()
360  {
361  return new GeoTessProfileSurface(data->copy());
362  }
363 
365 
366 }; // end class ProfileSurface
367 
368 } // end namespace geotess
369 
370 #endif // PROFILESURFACE_OBJECT_H
virtual GeoTessData * getData(int i)
Retrieve a reference the i'th Data object.
Definition: GeoTessProfileSurface.h:213
virtual float * getRadii()
Returns NULL.
Definition: GeoTessProfileSurface.h:202
virtual double getDouble(int attributeIndex) const
Retrieve the value of the attribute at the specified attribute index as a double value.
virtual int getNData() const
Get the number of Data objects that comprise this profile.
Definition: GeoTessProfileSurface.h:197
virtual LONG_INT getMemory()
virtual float getRadiusBottom() const
Get the radius at the bottom of the profile, in km.
Definition: GeoTessProfileSurface.h:261
A Profile object that defines a single Data object and no radius value.
Definition: GeoTessProfileSurface.h:76
virtual const GeoTessData & getData(int i) const
Retrieve a reference the i'th Data object.
Definition: GeoTessProfileSurface.h:218
Definition: ArrayReuse.h:55
Opens a file for binary read and write access.
Definition: IFStreamBinary.h:79
virtual const GeoTessData & getDataBottom() const
Get the Data object at the bottom of the profile.
Definition: GeoTessProfileSurface.h:267
virtual LONG_INT getMemory()
Definition: GeoTessProfileSurface.h:115
Enumeration of the interpolation algorithms supported by GeoTess including LINEAR, NATURAL_NEIGHBOR and CUBIC_SPLINE.
Definition: GeoTessInterpolatorType.h:71
virtual GeoTessData * getDataBottom()
Get the Data object at the bottom of the profile.
Definition: GeoTessProfileSurface.h:272
GeoTessProfileSurface(GeoTessData *dat)
Default constructor.
Definition: GeoTessProfileSurface.h:101
Enumeration of the valid Profile types, including EMPTY, THIN, CONSTANT, NPOINT and SURFACE...
Definition: GeoTessProfileType.h:69
virtual const GeoTessProfileType & getType() const
Returns ProfileType (SURFACE).
Definition: GeoTessProfileSurface.h:123
virtual GeoTessData ** getData()
Retrieve a shallow copy of the array of Data objects associated with this Profile.
virtual const GeoTessData & getDataTop() const
Get the Data object at the top of the profile.
Definition: GeoTessProfileSurface.h:251
virtual double getValue(int attributeIndex, int nodeIndex) const
Retrieve the value of the specified attribute from this profile at the specified node index...
Definition: GeoTessProfileSurface.h:142
virtual double getValue(const GeoTessInterpolatorType &rInterpType, int attributeIndex, double radius, bool allowRadiusOutOfRange) const
Retrieve the value of the specified attribute interpolated at the specified radius.
Definition: GeoTessProfileSurface.h:175
virtual bool isNaN(int attributeIndex) const
Returns true if the specified attribute is NaN.
#define byte
signed-byte typedef
Definition: CPPGlobals.h:94
virtual bool isNaN(int nodeIndex, int attributeIndex)
Return true if the specified Data value is NaN.
Definition: GeoTessProfileSurface.h:166
#define LONG_INT
Definition: CPPGlobals.h:111
virtual float getRadiusTop() const
Get the radius at the top of the profile, in km.
Definition: GeoTessProfileSurface.h:245
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
static string class_name()
Returns the class name.
Definition: GeoTessProfileSurface.h:107
virtual int class_size() const
Returns the class size.
Definition: GeoTessProfileSurface.h:112
virtual double getValueTop(int attributeIndex) const
Retrieve the value of the specified attribute at the top of the layer.
Definition: GeoTessProfileSurface.h:153
Basic metadata information about a GeoTessModel.
Definition: GeoTessMetaData.h:95
virtual void setData(const vector< GeoTessData * > &inData)
Resets the data object to the new input data.
Definition: GeoTessProfileSurface.h:223
virtual GeoTessData ** getData()
Retrieve a shallow copy of all of the Data objects associated with thisProfile.
Definition: GeoTessProfileSurface.h:207
virtual GeoTessData * getDataTop()
Get the Data object at the top of the profile.
Definition: GeoTessProfileSurface.h:256
virtual void setData(int index, GeoTessData *inData)
Resets the data object at index to the new input data.
Definition: GeoTessProfileSurface.h:229
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
virtual float getRadius(int i) const
Get the i'th radius value in this profile in km.
Definition: GeoTessProfileSurface.h:186
virtual void setRadii(const vector< float > &newRadii)
Replace the radii currently associated with this Profile with new values.
Definition: GeoTessProfileSurface.h:236
virtual int getNRadii() const
Get the number of radii that comprise this profile.
Definition: GeoTessProfileSurface.h:192
virtual void setRadius(int index, float radius)
Replace the radius at the specified nodeIndex.
Definition: GeoTessProfileSurface.h:239