GeoTessCPP: rstt/GeoTessCPP/include/GeoTessProfileThin.h Source File

GeoTessCPP 2.2.3 Software to facilitate storage and retrieval of 3D information about the Earth.

GeoTessProfileThin.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 PROFILETHIN_OBJECT_H
39 #define PROFILETHIN_OBJECT_H
40
41 // **** _SYSTEM INCLUDES_ ******************************************************
42
43 #include <iostream>
44 #include <fstream>
45 #include <string>
46
47 // use standard library objects
48 using namespace std;
49
50 // **** _LOCAL INCLUDES_ *******************************************************
51
52 #include "GeoTessData.h"
53 #include "GeoTessProfile.h"
54 #include "GeoTessProfileType.h"
55 #include "IFStreamAscii.h"
56 #include "IFStreamBinary.h"
57
58 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
59
60 namespace geotess {
61
62 // **** _FORWARD REFERENCES_ ***************************************************
63
64 class GeoTessMetaData;
65
66 // **** _CLASS DEFINITION_ *****************************************************
67
75 class GEOTESS_EXP_IMP GeoTessProfileThin : virtual public GeoTessProfile
76 {
77 private:
78
82 float radius;
83
87 GeoTessData* data;
88
92 int pointIndex;
93
97 GeoTessProfileThin() : GeoTessProfile(), radius(0.0), data(NULL),
98 pointIndex(-1) {};
99
100 public:
101
105 GeoTessProfileThin(float rad, GeoTessData* dat) :
106 GeoTessProfile(), radius(rad), data(dat),
107 pointIndex(-1) {};
108
112 static string class_name() { return "ProfileThin"; };
113
117 virtual int class_size() const
118 { return (int) sizeof(GeoTessProfileThin); };
119
120 virtual LONG_INT getMemory() { return (LONG_INT)sizeof(GeoTessProfileThin) + data->getMemory(); }
121
127 virtual const GeoTessProfileType& getType() const
128 { return GeoTessProfileType::THIN; };
129
133 virtual bool operator == (const GeoTessProfile& p) const
134 { return (GeoTessProfile::operator==(p) && (radius == p.getRadius(0)) && (*data == p.getData(0))); }
135
144 virtual double getValue(int attributeIndex, int nodeIndex) const
145 { return nodeIndex == 0 ? data->getDouble(attributeIndex) : NaN_DOUBLE; }
146
156 virtual double getValue(const GeoTessInterpolatorType& rInterpType,
157 int attributeIndex, double r, bool allowRadiusOutOfRange) const
158 {
159 if (!allowRadiusOutOfRange &&
160 ((r < getRadiusBottom()) || (r > getRadiusTop())))
161 return NaN_DOUBLE;
162
163 // default behavior is to simply return the data value for the first
164 // data object. This works for all the Profile classes that only support
165 // a single Data object like ProfileConstant, ProfileSurface, and
166 // ProfileThin. Profile classes for which the number of supported
167 // Data objects is not equal to 1 must override this method.
168
169 return getValue(attributeIndex, 0);
170 };
171
178 virtual double getValueTop(int attributeIndex) const
179 { return data->getDouble(attributeIndex); }
180
191 virtual bool isNaN(int nodeIndex, int attributeIndex)
192 {
193 return nodeIndex != 0 || data->isNaN(attributeIndex);
194 }
195
200 virtual float getRadius(int i) const { return radius; };
201
205 virtual int getNRadii() const { return 1; };
206
210 virtual int getNData() const { return 1; };
211
215 virtual float* getRadii()
216 { float* fa = new float [1]; fa[0] = radius; return fa; };
217
221 virtual GeoTessData** getData()
222 { GeoTessData** da = new GeoTessData* [1]; da[0] = data; return da; };
223
227 virtual GeoTessData* getData(int i) { return data; };
228
232 virtual const GeoTessData& getData(int i) const { return *data; };
233
237 virtual void setData(const vector<GeoTessData*>& inData)
238 { delete data; data = inData[0]; }
239
243 virtual void setRadii(const vector<float>& newRadii)
244 { radius = newRadii[0]; }
245
246 virtual void setRadius(int index, float newRadius)
247 { if (index == 0) radius = newRadius; }
248
252 virtual void setData(int index, GeoTessData* inData)
253 { delete data; data = inData; }
254
258 virtual float getRadiusTop() const { return radius; };
259
263 virtual const GeoTessData& getDataTop() const { return *data; };
264
268 virtual GeoTessData* getDataTop() { return data; };
269
273 virtual float getRadiusBottom() const { return radius; };
274
278 virtual const GeoTessData& getDataBottom() const { return *data; };
279
283 virtual GeoTessData* getDataBottom() { return data; };
284
286
290 GeoTessProfileThin(IFStreamBinary& ifs, GeoTessMetaData& gtmd) : GeoTessProfile(),
291 radius(-1.0), data(NULL), pointIndex(-1)
292 { radius = ifs.readFloat(); data = GeoTessData::getData(ifs, gtmd); };
293
297 GeoTessProfileThin(IFStreamAscii& ifs, GeoTessMetaData& gtmd) : GeoTessProfile(),
298 radius(-1.0), data(NULL), pointIndex(-1)
299 { radius = ifs.readFloat(); data = GeoTessData::getData(ifs, gtmd); };
300
305 virtual ~GeoTessProfileThin() { if (data != NULL) delete data; };
306
310 virtual void write(IFStreamBinary& ofs)
311 { ofs.writeByte((byte) GeoTessProfileType::THIN.ordinal());
312 ofs.writeFloat(radius); data->write(ofs); };
313
317 virtual void write(IFStreamAscii& ofs)
318 { ofs.writeInt(GeoTessProfileType::THIN.ordinal());
319 ofs.writeString(" ");
320 ofs.writeFloat(radius);
321 data->write(ofs);
322 ofs.writeNL(); };
323
332 virtual int findClosestRadiusIndex(double r) const
333 { return 0; }
334
342 virtual void setPointIndex(int nodeIndex, int pntIndex)
343 { pointIndex = pntIndex; }
344
352 virtual void resetPointIndices() { pointIndex = -1; }
353
361 virtual int getPointIndex(int nodeIndex) const
362 { return pointIndex; }
363
367 virtual GeoTessProfile* copy()
368 {
369 return new GeoTessProfileThin(radius, data->copy());
370 }
371
373
374 }; // end class ProfileThin
375
376 } // end namespace geotess
377
378 #endif // PROFILETHIN_OBJECT_H
geotess::GeoTessProfileThin::getValue
virtual double getValue(const GeoTessInterpolatorType &rInterpType, int attributeIndex, double r, bool allowRadiusOutOfRange) const
Definition: GeoTessProfileThin.h:156
geotess::GeoTessProfileThin::setData
virtual void setData(int index, GeoTessData *inData)
Definition: GeoTessProfileThin.h:252
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::GeoTessData::getMemory
virtual LONG_INT getMemory()
GeoTessProfile.h
geotess::GeoTessProfileType
Enumeration of the valid Profile types, including EMPTY, THIN, CONSTANT, NPOINT and SURFACE.
Definition: GeoTessProfileType.h:72
geotess::GeoTessProfileThin::getDataBottom
virtual const GeoTessData & getDataBottom() const
Definition: GeoTessProfileThin.h:278
geotess::GeoTessProfileThin::getRadiusTop
virtual float getRadiusTop() const
Definition: GeoTessProfileThin.h:258
geotess::GeoTessProfileThin::getData
virtual const GeoTessData & getData(int i) const
Definition: GeoTessProfileThin.h:232
geotess::GeoTessProfileThin::getValue
virtual double getValue(int attributeIndex, int nodeIndex) const
Definition: GeoTessProfileThin.h:144
geotess::GeoTessProfileThin::getMemory
virtual LONG_INT getMemory()
Definition: GeoTessProfileThin.h:120
geotess::GeoTessProfileThin::getNRadii
virtual int getNRadii() const
Definition: GeoTessProfileThin.h:205
geotess::GeoTessProfileThin::getDataTop
virtual const GeoTessData & getDataTop() const
Definition: GeoTessProfileThin.h:263
geotess::GeoTessProfileThin::getDataTop
virtual GeoTessData * getDataTop()
Definition: GeoTessProfileThin.h:268
geotess::GeoTessProfileThin::class_size
virtual int class_size() const
Definition: GeoTessProfileThin.h:117
geotess::GeoTessProfile::getRadius
virtual float getRadius(int i) const
geotess::GeoTessProfileThin::getRadiusBottom
virtual float getRadiusBottom() const
Definition: GeoTessProfileThin.h:273
geotess::GeoTessProfileThin::GeoTessProfileThin
GeoTessProfileThin(float rad, GeoTessData *dat)
Definition: GeoTessProfileThin.h:105
geotess::GeoTessProfileThin::getValueTop
virtual double getValueTop(int attributeIndex) const
Definition: GeoTessProfileThin.h:178
geotess::GeoTessProfileThin::setRadius
virtual void setRadius(int index, float newRadius)
Definition: GeoTessProfileThin.h:246
geotess::GeoTessProfileThin::getData
virtual GeoTessData * getData(int i)
Definition: GeoTessProfileThin.h:227
geotess::GeoTessProfileThin::getType
virtual const GeoTessProfileType & getType() const
Definition: GeoTessProfileThin.h:127
geotess::GeoTessProfileThin::getDataBottom
virtual GeoTessData * getDataBottom()
Definition: GeoTessProfileThin.h:283
geotess::GeoTessProfileThin::setRadii
virtual void setRadii(const vector< float > &newRadii)
Definition: GeoTessProfileThin.h:243
LONG_INT
#define LONG_INT
Definition: CPPGlobals.h:113
geotess::GeoTessProfileThin::class_name
static string class_name()
Definition: GeoTessProfileThin.h:112
geotess::IFStreamBinary::readFloat
float readFloat()
Definition: IFStreamBinary.h:1155
geotess::GeoTessProfileThin::getRadius
virtual float getRadius(int i) const
Definition: GeoTessProfileThin.h:200
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::GeoTessProfileThin::setData
virtual void setData(const vector< GeoTessData * > &inData)
Definition: GeoTessProfileThin.h:237
IFStreamAscii.h
geotess::GeoTessProfileThin::getData
virtual GeoTessData ** getData()
Definition: GeoTessProfileThin.h:221
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::GeoTessProfileThin
A Profile object consiting of a single radius value and a single Data object. It represents a profile...
Definition: GeoTessProfileThin.h:76
geotess::GeoTessProfileThin::isNaN
virtual bool isNaN(int nodeIndex, int attributeIndex)
Definition: GeoTessProfileThin.h:191
geotess::GeoTessProfile::getData
virtual GeoTessData ** getData()
geotess::GeoTessProfileThin::getNData
virtual int getNData() const
Definition: GeoTessProfileThin.h:210
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::GeoTessProfileThin::getRadii
virtual float * getRadii()
Definition: GeoTessProfileThin.h:215