GeoTessCPP  2.2.3
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 National Technology & Engineering Solutions of Sandia, LLC
4 //- (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S.
5 //- Government 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 //- 1. Redistributions of source code must retain the above copyright notice,
14 //- this list of conditions and the following disclaimer.
15 //-
16 //- 2. Redistributions in binary form must reproduce the above copyright
17 //- notice, this list of conditions and the following disclaimer in the
18 //- documentation and/or other materials provided with the distribution.
19 //-
20 //- 3. Neither the name of the copyright holder nor the names of its
21 //- contributors may be used to endorse or promote products derived from
22 //- this software without specific prior written permission.
23 //-
24 //- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 //- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 //- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 //- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
28 //- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 //- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 //- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 //- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 //- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 //- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 //- POSSIBILITY OF SUCH DAMAGE.
35 //-
36 //- ****************************************************************************
37 
38 #ifndef PROFILESURFACE_OBJECT_H
39 #define PROFILESURFACE_OBJECT_H
40 
41 // **** _SYSTEM INCLUDES_ ******************************************************
42 
43 #include <iostream>
44 #include <string>
45 #include <fstream>
46 
47 // use standard library objects
48 using namespace std;
49 
50 // **** _LOCAL INCLUDES_ *******************************************************
51 
52 #include "GeoTessUtils.h"
53 #include "GeoTessData.h"
54 #include "GeoTessProfile.h"
55 #include "GeoTessProfileType.h"
56 #include "IFStreamAscii.h"
57 #include "IFStreamBinary.h"
58 
59 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
60 
61 namespace geotess {
62 
63 // **** _FORWARD REFERENCES_ ***************************************************
64 
65 class GeoTessMetaData;
66 
67 // **** _CLASS DEFINITION_ *****************************************************
68 
79 {
80  private:
81 
85  GeoTessData* data;
86 
90  int pointIndex;
91 
95  GeoTessProfileSurface() : GeoTessProfile(), data(NULL),
96  pointIndex(-1) {};
97 
98  public:
99 
104  pointIndex(-1) {};
105 
109  static string class_name() { return "ProfileSurface"; };
110 
114  virtual int class_size() const
115  { return (int) sizeof(GeoTessProfileSurface); };
116 
117  virtual LONG_INT getMemory()
118  { return (LONG_INT)(sizeof(GeoTessProfileSurface) + data->getMemory()); }
119 
125  virtual const GeoTessProfileType& getType() const
126  { return GeoTessProfileType::SURFACE; };
127 
131  virtual bool operator == (const GeoTessProfile& p) const
132  { return (GeoTessProfile::operator==(p) &&
133  (*data == p.getData(0)));
134  }
135 
144  virtual double getValue(int attributeIndex, int nodeIndex) const
145  {
146  return nodeIndex == 0 ? data->getDouble(attributeIndex) : NaN_DOUBLE;
147  }
148 
155  virtual double getValueTop(int attributeIndex) const
156  { return data->getDouble(attributeIndex); }
157 
168  virtual bool isNaN(int nodeIndex, int attributeIndex)
169  {
170  return nodeIndex != 0 || data->isNaN(attributeIndex);
171  }
172 
177  virtual double getValue(const GeoTessInterpolatorType& rInterpType,
178  int attributeIndex, double radius,
179  bool allowRadiusOutOfRange) const
180  {
181  return getData(0).getDouble(attributeIndex);
182  }
183 
188  virtual float getRadius(int i) const
189  { return NaN_FLOAT; };
190 
194  virtual int getNRadii() const { return 0; };
195 
199  virtual int getNData() const { return 1; };
200 
204  virtual float* getRadii() { return NULL; };
205 
209  virtual GeoTessData** getData()
210  { GeoTessData** da = new GeoTessData* [1]; da[0] = data; return da; };
211 
215  virtual GeoTessData* getData(int i) { return data; };
216 
220  virtual const GeoTessData& getData(int i) const { return *data; };
221 
225  virtual void setData(const vector<GeoTessData*>& inData)
226  { delete data; data = inData[0]; }
227 
231  virtual void setData(int index, GeoTessData* inData)
232  { delete data; data = inData; }
233 
234  // TODO: added by sb 9/27/2012
238  virtual void setRadii(const vector<float>& newRadii)
239  { /* do nothing */ };
240 
241  virtual void setRadius(int index, float radius)
242  { /* do nothing */ }
243 
247  virtual float getRadiusTop() const
248  { return NaN_FLOAT; };
249 
253  virtual const GeoTessData& getDataTop() const { return *data; };
254 
258  virtual GeoTessData* getDataTop() { return data; };
259 
263  virtual float getRadiusBottom() const
264  { return NaN_FLOAT; };
265 
269  virtual const GeoTessData& getDataBottom() const { return *data; };
270 
274  virtual GeoTessData* getDataBottom() { return data; };
275 
277 
282  data(NULL), pointIndex(-1)
283  { data = GeoTessData::getData(ifs, gtmd); };
284 
288  GeoTessProfileSurface(IFStreamAscii& ifs, GeoTessMetaData& gtmd) : GeoTessProfile(),
289  data(NULL), pointIndex(-1)
290  { data = GeoTessData::getData(ifs, gtmd); };
291 
296  virtual ~GeoTessProfileSurface() { if (data != NULL) delete data; };
297 
301  virtual void write(IFStreamBinary& ofs)
302  { ofs.writeByte((byte) GeoTessProfileType::SURFACE.ordinal());
303  data->write(ofs); };
304 
308  virtual void write(IFStreamAscii& ofs)
309  { ofs.writeInt(GeoTessProfileType::SURFACE.ordinal());
310  data->write(ofs);
311  ofs.writeNL(); };
312 
313  // *** TODO added 7/20/2012
322  virtual int findClosestRadiusIndex(double radius) const
323  { return -1; }
324 
325  // *** TODO added 7/20/2012
333  virtual void setPointIndex(int nodeIndex, int pntIndex)
334  { pointIndex = pntIndex; }
335 
336  // *** TODO added 10/14/2012
344  virtual void resetPointIndices() { pointIndex = -1; }
345 
346  // *** TODO added 7/20/2012
354  virtual int getPointIndex(int nodeIndex) const
355  { return pointIndex; }
356 
357  // *** TODO added 8/20/2012
361  virtual GeoTessProfile* copy()
362  {
363  return new GeoTessProfileSurface(data->copy());
364  }
365 
367 
368 }; // end class ProfileSurface
369 
370 } // end namespace geotess
371 
372 #endif // PROFILESURFACE_OBJECT_H
geotess::GeoTessProfileSurface::getData
virtual GeoTessData ** getData()
Definition: GeoTessProfileSurface.h:209
geotess::GeoTessProfileSurface::getNRadii
virtual int getNRadii() const
Definition: GeoTessProfileSurface.h:194
geotess::GeoTessProfileSurface::getMemory
virtual LONG_INT getMemory()
Definition: GeoTessProfileSurface.h:117
geotess::GeoTessProfileSurface::setData
virtual void setData(const vector< GeoTessData * > &inData)
Definition: GeoTessProfileSurface.h:225
geotess::GeoTessProfileSurface::isNaN
virtual bool isNaN(int nodeIndex, int attributeIndex)
Definition: GeoTessProfileSurface.h:168
geotess
Definition: ArrayReuse.h:57
IFStreamBinary.h
geotess::GeoTessProfile
Abstract class that manages the radii and data values that span a single layer associated with a sing...
Definition: GeoTessProfile.h:99
GeoTessProfileType.h
GeoTessData.h
geotess::GeoTessProfileSurface::getDataTop
virtual GeoTessData * getDataTop()
Definition: GeoTessProfileSurface.h:258
geotess::GeoTessData::getMemory
virtual LONG_INT getMemory()
GeoTessProfile.h
geotess::GeoTessProfileSurface::getRadiusTop
virtual float getRadiusTop() const
Definition: GeoTessProfileSurface.h:247
geotess::GeoTessProfileType
Enumeration of the valid Profile types, including EMPTY, THIN, CONSTANT, NPOINT and SURFACE.
Definition: GeoTessProfileType.h:72
geotess::GeoTessProfileSurface::getRadius
virtual float getRadius(int i) const
Definition: GeoTessProfileSurface.h:188
geotess::GeoTessProfileSurface::class_size
virtual int class_size() const
Definition: GeoTessProfileSurface.h:114
geotess::GeoTessProfileSurface::GeoTessProfileSurface
GeoTessProfileSurface(GeoTessData *dat)
Definition: GeoTessProfileSurface.h:103
geotess::GeoTessProfileSurface::setRadius
virtual void setRadius(int index, float radius)
Definition: GeoTessProfileSurface.h:241
geotess::GeoTessProfileSurface::class_name
static string class_name()
Definition: GeoTessProfileSurface.h:109
geotess::GeoTessProfileSurface::getValue
virtual double getValue(int attributeIndex, int nodeIndex) const
Definition: GeoTessProfileSurface.h:144
GeoTessUtils.h
geotess::GeoTessProfileSurface::getNData
virtual int getNData() const
Definition: GeoTessProfileSurface.h:199
geotess::GeoTessProfileSurface::getValueTop
virtual double getValueTop(int attributeIndex) const
Definition: GeoTessProfileSurface.h:155
geotess::GeoTessProfileSurface::getDataBottom
virtual GeoTessData * getDataBottom()
Definition: GeoTessProfileSurface.h:274
LONG_INT
#define LONG_INT
Definition: CPPGlobals.h:113
geotess::GeoTessProfileSurface::getRadii
virtual float * getRadii()
Definition: GeoTessProfileSurface.h:204
geotess::GeoTessProfileSurface
A Profile object that defines a single Data object and no radius value.
Definition: GeoTessProfileSurface.h:79
geotess::GeoTessData
Abstract base class that manages the data values attached to a single grid point.
Definition: GeoTessData.h:78
GEOTESS_EXP_IMP
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:73
geotess::GeoTessProfileSurface::setRadii
virtual void setRadii(const vector< float > &newRadii)
Definition: GeoTessProfileSurface.h:238
IFStreamAscii.h
geotess::IFStreamBinary
Opens a file for binary read and write access.
Definition: IFStreamBinary.h:82
geotess::GeoTessData::getDouble
virtual double getDouble(int attributeIndex) const
geotess::GeoTessMetaData
Basic metadata information about a GeoTessModel.
Definition: GeoTessMetaData.h:98
geotess::GeoTessProfileSurface::getRadiusBottom
virtual float getRadiusBottom() const
Definition: GeoTessProfileSurface.h:263
geotess::GeoTessProfileSurface::getDataBottom
virtual const GeoTessData & getDataBottom() const
Definition: GeoTessProfileSurface.h:269
geotess::GeoTessProfileSurface::getDataTop
virtual const GeoTessData & getDataTop() const
Definition: GeoTessProfileSurface.h:253
geotess::GeoTessProfileSurface::getData
virtual const GeoTessData & getData(int i) const
Definition: GeoTessProfileSurface.h:220
geotess::GeoTessProfileSurface::getData
virtual GeoTessData * getData(int i)
Definition: GeoTessProfileSurface.h:215
geotess::GeoTessProfileSurface::getType
virtual const GeoTessProfileType & getType() const
Definition: GeoTessProfileSurface.h:125
geotess::GeoTessProfileSurface::getValue
virtual double getValue(const GeoTessInterpolatorType &rInterpType, int attributeIndex, double radius, bool allowRadiusOutOfRange) const
Definition: GeoTessProfileSurface.h:177
geotess::GeoTessProfile::getData
virtual GeoTessData ** getData()
geotess::GeoTessInterpolatorType
Enumeration of the interpolation algorithms supported by GeoTess including LINEAR,...
Definition: GeoTessInterpolatorType.h:74
geotess::GeoTessData::isNaN
virtual bool isNaN(int attributeIndex) const
geotess::GeoTessProfileSurface::setData
virtual void setData(int index, GeoTessData *inData)
Definition: GeoTessProfileSurface.h:231