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

GeoTessCPP 2.2.3 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 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 PROFILEEMPTY_OBJECT_H
39 #define PROFILEEMPTY_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 "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 GeoTessData;
64
65 // **** _CLASS DEFINITION_ *****************************************************
66
76 class GEOTESS_EXP_IMP GeoTessProfileEmpty : virtual public GeoTessProfile
77 {
78 private:
79
83 float radiusTop;
84
88 float radiusBottom;
89
93 GeoTessProfileEmpty() : GeoTessProfile(), radiusTop(0.0), radiusBottom(0.0) {};
94
95 public:
96
100 GeoTessProfileEmpty(float radBot, float radTop) : GeoTessProfile(),
101 radiusTop(radTop), radiusBottom(radBot)
102 {}
103
107 GeoTessProfileEmpty(IFStreamBinary& ifs) : GeoTessProfile()
108 { radiusBottom = ifs.readFloat();
109 radiusTop = ifs.readFloat();
110 }
111
115 GeoTessProfileEmpty(IFStreamAscii& ifs) : GeoTessProfile()
116 { radiusBottom = ifs.readFloat();
117 radiusTop = ifs.readFloat();
118 }
119
123 GeoTessProfileEmpty(float radii[], int &rIndex) : GeoTessProfile()
124 { radiusBottom = radii[rIndex++];
125 radiusTop = radii[rIndex++];
126 }
127
131 virtual ~GeoTessProfileEmpty() {};
132
136 static string class_name() { return "ProfileEmpty"; };
137
141 virtual int class_size() const
142 { return (int) sizeof(GeoTessProfileEmpty); };
143
144 virtual LONG_INT getMemory() { return (LONG_INT)(sizeof(GeoTessProfileEmpty)); };
145
151 virtual const GeoTessProfileType& getType() const
152 { return GeoTessProfileType::EMPTY; };
153
157 virtual bool operator == (const GeoTessProfile& p) const
158 { return (GeoTessProfile::operator==(p) &&
159 (radiusBottom == p.getRadiusBottom()) &&
160 (radiusTop == p.getRadiusTop()));
161 }
162
167 virtual double getValue(const GeoTessInterpolatorType& rInterpType,
168 int attributeIndex, double radius,
169 bool allowRadiusOutOfRange) const;
170
179 virtual double getValue(int attributeIndex, int nodeIndex) const
180 { return NaN_DOUBLE; }
181
192 virtual bool isNaN(int nodeIndex, int attributeIndex)
193 {
194 return true;
195 }
196
197 // *** TODO added 7/20/2012
204 virtual double getValueTop(int attributeIndex) const
205 {
206 return NaN_DOUBLE;
207 }
208
209 // *** TODO added 7/20/2012
216 virtual double getValueBottom(int attributeIndex) const
217 {
218 return NaN_DOUBLE;
219 }
220
225 virtual float getRadius(int i) const
226 { return i == 0 ? radiusBottom : radiusTop; };
227
231 virtual int getNRadii() const { return 2; };
232
236 virtual int getNData() const { return 0; };
237
241 virtual float* getRadii()
242 { float* fa = new float [2]; fa[0] = radiusBottom; fa[1] = radiusTop; return fa; };
243
248 virtual GeoTessData** getData();
249
253 virtual GeoTessData* getData(int i);
254
258 virtual const GeoTessData& getData(int i) const;
259
263 virtual void setData(const vector<GeoTessData*>& inData)
264 {/* do nothing*/ };
265
266 // TODO: added by sb 9/27/2012
270 virtual void setRadii(const vector<float>& newRadii)
271 { radiusBottom = newRadii[0]; radiusTop = newRadii[1]; }
272
273 virtual void setRadius(int index, float radius)
274 {
275 switch (index)
276 {
277 case 0:
278 radiusBottom = radius;
279 break;
280 case 1:
281 radiusTop = radius;
282 break;
283 }
284 }
285 // *** TODO added 7/19/2012
289 virtual void setData(int index, GeoTessData* inData)
290 { /* do nothing*/ };
291
295 virtual float getRadiusTop() const { return radiusTop; };
296
300 virtual const GeoTessData& getDataTop() const;
301
305 virtual GeoTessData* getDataTop() { return NULL; }
306
310 virtual float getRadiusBottom() const { return radiusBottom; };
311
315 virtual const GeoTessData& getDataBottom() const;
316
320 virtual GeoTessData* getDataBottom() { return NULL; }
321
325 virtual void write(IFStreamBinary& ofs)
326 { ofs.writeByte((byte) GeoTessProfileType::EMPTY.ordinal());
327 ofs.writeFloat(radiusBottom);
328 ofs.writeFloat(radiusTop); };
329
333 virtual void write(IFStreamAscii& ofs)
334 { ofs.writeInt(GeoTessProfileType::EMPTY.ordinal());
335 ofs.writeString(" ");
336 ofs.writeFloat(radiusBottom);
337 ofs.writeString(" ");
338 ofs.writeFloatNL(radiusTop); };
339
340 // *** TODO added 7/20/2012
349 virtual int findClosestRadiusIndex(double radius) const
350 { return abs(radiusTop - radius) < abs(radiusBottom - radius) ? 1 : 0; }
351
352 // *** TODO added 7/20/2012
360 virtual void setPointIndex(int nodeIndex, int pointIndex)
361 {
362 // do nothing. empty profiles have no data, hence pointIndex is always -1.
363 }
364
365 // *** TODO added 10/14/2012
373 virtual void resetPointIndices() { /* empty profiles have no data, hence pointIndex is always -1. */ }
374
375 // *** TODO added 7/20/2012
383 virtual int getPointIndex(int nodeIndex) const
384 { return -1; }
385
386 // *** TODO added 7/20/2012
393 virtual void getWeights(map<int, double>& weights,
394 double dkm, double radius, double hcoefficient) const
395 {
396 // do nothing.
397 }
398
399 // *** TODO added 7/26/2012
403 virtual void getCoefficients(map<int, double>& coefficients, double radius,
404 double horizontalCoefficient) const
405 {
406 // do nothing.
407 }
408
409 virtual void setInterpolationCoefficients(const GeoTessInterpolatorType& interpType,
410 vector<int>& nodeIndexes, vector<double>& coefficients,
411 double& radius, bool& allowOutOfRange)
412 {
413 // POISON!
414 nodeIndexes.push_back(0);
415 coefficients.push_back(NaN_DOUBLE);
416 }
417
418 // *** TODO added 8/20/2012
422 virtual GeoTessProfile* copy()
423 {
424 return new GeoTessProfileEmpty(radiusBottom, radiusTop);
425 }
426
428
430
431 }; // end class ProfileEmpty
432
433 } // end namespace geotess
434
435 #endif // PROFILEEMPTY_OBJECT_H
geotess::GeoTessProfileEmpty::getRadii
virtual float * getRadii()
Definition: GeoTessProfileEmpty.h:241
geotess::IFStreamAscii::readFloat
float readFloat()
Definition: IFStreamAscii.h:792
geotess::GeoTessProfileEmpty::getMemory
virtual LONG_INT getMemory()
Definition: GeoTessProfileEmpty.h:144
geotess::GeoTessProfileEmpty::class_name
static string class_name()
Definition: GeoTessProfileEmpty.h:136
geotess::GeoTessProfileEmpty::getValue
virtual double getValue(int attributeIndex, int nodeIndex) const
Definition: GeoTessProfileEmpty.h:179
geotess::GeoTessProfileEmpty::GeoTessProfileEmpty
GeoTessProfileEmpty(float radBot, float radTop)
Definition: GeoTessProfileEmpty.h:100
geotess::GeoTessProfileEmpty::getNRadii
virtual int getNRadii() const
Definition: GeoTessProfileEmpty.h:231
geotess::IFStreamBinary::writeByte
void writeByte(byte b)
Definition: IFStreamBinary.h:1446
geotess
Definition: ArrayReuse.h:57
geotess::GeoTessProfileEmpty::getCoefficients
virtual void getCoefficients(map< int, double > &coefficients, double radius, double horizontalCoefficient) const
Definition: GeoTessProfileEmpty.h:403
IFStreamBinary.h
geotess::GeoTessProfileEmpty::GeoTessProfileEmpty
GeoTessProfileEmpty(IFStreamAscii &ifs)
Definition: GeoTessProfileEmpty.h:115
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
geotess::GeoTessProfile::getRadiusTop
virtual float getRadiusTop() const
geotess::GeoTessProfileEmpty::resetPointIndices
virtual void resetPointIndices()
Definition: GeoTessProfileEmpty.h:373
geotess::GeoTessProfileEmpty::getValueTop
virtual double getValueTop(int attributeIndex) const
Definition: GeoTessProfileEmpty.h:204
GeoTessProfile.h
geotess::GeoTessProfileType
Enumeration of the valid Profile types, including EMPTY, THIN, CONSTANT, NPOINT and SURFACE.
Definition: GeoTessProfileType.h:72
geotess::IFStreamAscii::writeFloatNL
void writeFloatNL(float f)
Definition: IFStreamAscii.h:560
geotess::GeoTessProfileEmpty::copy
virtual GeoTessProfile * copy()
Definition: GeoTessProfileEmpty.h:422
geotess::IFStreamAscii::writeString
void writeString(const string &s)
Definition: IFStreamAscii.h:535
geotess::IFStreamAscii::writeFloat
void writeFloat(float f)
Definition: IFStreamAscii.h:559
geotess::GeoTessProfileEmpty::setInterpolationCoefficients
virtual void setInterpolationCoefficients(const GeoTessInterpolatorType &interpType, vector< int > &nodeIndexes, vector< double > &coefficients, double &radius, bool &allowOutOfRange)
Definition: GeoTessProfileEmpty.h:409
geotess::GeoTessProfileEmpty::isNaN
virtual bool isNaN(int nodeIndex, int attributeIndex)
Definition: GeoTessProfileEmpty.h:192
geotess::GeoTessProfileEmpty::getRadius
virtual float getRadius(int i) const
Definition: GeoTessProfileEmpty.h:225
geotess::GeoTessProfileEmpty::write
virtual void write(IFStreamAscii &ofs)
Definition: GeoTessProfileEmpty.h:333
geotess::GeoTessProfileEmpty::getValue
virtual double getValue(const GeoTessInterpolatorType &rInterpType, int attributeIndex, double radius, bool allowRadiusOutOfRange) const
geotess::GeoTessProfileEmpty::getData
virtual GeoTessData ** getData()
geotess::GeoTessProfileEmpty::findClosestRadiusIndex
virtual int findClosestRadiusIndex(double radius) const
Definition: GeoTessProfileEmpty.h:349
geotess::GeoTessProfileEmpty::getRadiusTop
virtual float getRadiusTop() const
Definition: GeoTessProfileEmpty.h:295
geotess::GeoTessProfileEmpty::getData
virtual const GeoTessData & getData(int i) const
geotess::GeoTessProfileEmpty::write
virtual void write(IFStreamBinary &ofs)
Definition: GeoTessProfileEmpty.h:325
geotess::GeoTessProfileEmpty::getType
virtual const GeoTessProfileType & getType() const
Definition: GeoTessProfileEmpty.h:151
geotess::GeoTessProfileEmpty::getData
virtual GeoTessData * getData(int i)
geotess::GeoTessProfileEmpty::getValueBottom
virtual double getValueBottom(int attributeIndex) const
Definition: GeoTessProfileEmpty.h:216
geotess::GeoTessProfileEmpty::getDataTop
virtual GeoTessData * getDataTop()
Definition: GeoTessProfileEmpty.h:305
geotess::GeoTessProfileEmpty
A Profile object that defines two radii at the bottom and top of the associated layer,...
Definition: GeoTessProfileEmpty.h:77
geotess::GeoTessProfileEmpty::getDataTop
virtual const GeoTessData & getDataTop() const
geotess::GeoTessProfileEmpty::getDataBottom
virtual GeoTessData * getDataBottom()
Definition: GeoTessProfileEmpty.h:320
geotess::GeoTessProfile::getRadiusBottom
virtual float getRadiusBottom() const
geotess::GeoTessProfileEmpty::setRadii
virtual void setRadii(const vector< float > &newRadii)
Definition: GeoTessProfileEmpty.h:270
geotess::IFStreamAscii
Opens ascii file for read and write access.
Definition: IFStreamAscii.h:83
LONG_INT
#define LONG_INT
Definition: CPPGlobals.h:113
geotess::GeoTessProfileEmpty::class_size
virtual int class_size() const
Definition: GeoTessProfileEmpty.h:141
geotess::GeoTessProfileEmpty::setPointIndex
virtual void setPointIndex(int nodeIndex, int pointIndex)
Definition: GeoTessProfileEmpty.h:360
geotess::IFStreamBinary::readFloat
float readFloat()
Definition: IFStreamBinary.h:1155
geotess::GeoTessProfileEmpty::~GeoTessProfileEmpty
virtual ~GeoTessProfileEmpty()
Definition: GeoTessProfileEmpty.h:131
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
IFStreamAscii.h
geotess::GeoTessProfileEmpty::getPointIndex
virtual int getPointIndex(int nodeIndex) const
Definition: GeoTessProfileEmpty.h:383
geotess::GeoTessProfileEmpty::GeoTessProfileEmpty
GeoTessProfileEmpty(IFStreamBinary &ifs)
Definition: GeoTessProfileEmpty.h:107
geotess::IFStreamBinary
Opens a file for binary read and write access.
Definition: IFStreamBinary.h:82
geotess::GeoTessProfileEmpty::getDataBottom
virtual const GeoTessData & getDataBottom() const
geotess::GeoTessProfileEmpty::getNData
virtual int getNData() const
Definition: GeoTessProfileEmpty.h:236
geotess::GeoTessProfileEmpty::setRadius
virtual void setRadius(int index, float radius)
Definition: GeoTessProfileEmpty.h:273
geotess::GeoTessProfileEmpty::setData
virtual void setData(int index, GeoTessData *inData)
Definition: GeoTessProfileEmpty.h:289
geotess::IFStreamAscii::writeInt
void writeInt(int i)
Definition: IFStreamAscii.h:551
geotess::IFStreamBinary::writeFloat
void writeFloat(float f)
Definition: IFStreamBinary.h:1754
geotess::GeoTessProfileEmpty::getRadiusBottom
virtual float getRadiusBottom() const
Definition: GeoTessProfileEmpty.h:310
geotess::GeoTessProfileEmpty::GeoTessProfileEmpty
GeoTessProfileEmpty(float radii[], int &rIndex)
Definition: GeoTessProfileEmpty.h:123
geotess::GeoTessProfileEmpty::getWeights
virtual void getWeights(map< int, double > &weights, double dkm, double radius, double hcoefficient) const
Definition: GeoTessProfileEmpty.h:393
geotess::GeoTessProfileEmpty::setData
virtual void setData(const vector< GeoTessData * > &inData)
Definition: GeoTessProfileEmpty.h:263
geotess::GeoTessInterpolatorType
Enumeration of the interpolation algorithms supported by GeoTess including LINEAR,...
Definition: GeoTessInterpolatorType.h:74