GeoTessCPP: include/GeoTessProfileEmpty.h Source File

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

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Friends Macros
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
74 class GEOTESS_EXP_IMP GeoTessProfileEmpty : virtual public GeoTessProfile
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
105 GeoTessProfileEmpty(IFStreamBinary& ifs) : GeoTessProfile()
106 { radiusBottom = ifs.readFloat();
107 radiusTop = ifs.readFloat();
108 }
109
113 GeoTessProfileEmpty(IFStreamAscii& ifs) : GeoTessProfile()
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
407 virtual void setInterpolationCoefficients(const GeoTessInterpolatorType& interpType,
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