GeoTessCPP: include/GeoTessProfileSurface.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
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
76 class GEOTESS_EXP_IMP GeoTessProfileSurface: virtual public GeoTessProfile
77 {
78 private:
79
83 GeoTessData* data;
84
88 int pointIndex;
89
93 GeoTessProfileSurface() : GeoTessProfile(), data(NULL),
94 pointIndex(-1) {};
95
96 public:
97
101 GeoTessProfileSurface(GeoTessData* dat) : GeoTessProfile(), data(dat),
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
279 GeoTessProfileSurface(IFStreamBinary& ifs, GeoTessMetaData& gtmd) : GeoTessProfile(),
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