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

Loading...
Searching...
No Matches
GeoTessProfileThin.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 PROFILETHIN_OBJECT_H
37#define PROFILETHIN_OBJECT_H
38
39// **** _SYSTEM INCLUDES_ ******************************************************
40
41#include <iostream>
42#include <fstream>
43#include <string>
44
45// use standard library objects
46 using namespace std;
47
48// **** _LOCAL INCLUDES_ *******************************************************
49
50#include "GeoTessData.h"
51#include "GeoTessProfile.h"
52#include "GeoTessProfileType.h"
53#include "IFStreamAscii.h"
54#include "IFStreamBinary.h"
55
56// **** _BEGIN GEOTESS NAMESPACE_ **********************************************
57
58 namespace geotess {
59
60// **** _FORWARD REFERENCES_ ***************************************************
61
62 class GeoTessMetaData;
63
64// **** _CLASS DEFINITION_ *****************************************************
65
73 class GEOTESS_EXP_IMP GeoTessProfileThin : virtual public GeoTessProfile
74{
75 private:
76
80 float radius;
81
85 GeoTessData* data;
86
90 int pointIndex;
91
95 GeoTessProfileThin() : GeoTessProfile(), radius(0.0), data(NULL),
96 pointIndex(-1) {};
97
98 public:
99
103 GeoTessProfileThin(float rad, GeoTessData* dat) :
104 GeoTessProfile(), radius(rad), data(dat),
105 pointIndex(-1) {};
106
110 static string class_name() { return "ProfileThin"; };
111
115 virtual int class_size() const
116 { return (int) sizeof(GeoTessProfileThin); };
117
118 virtual LONG_INT getMemory() { return (LONG_INT)sizeof(GeoTessProfileThin) + data->getMemory(); }
119
125 virtual const GeoTessProfileType& getType() const
126 { return GeoTessProfileType::THIN; };
127
131 virtual bool operator == (const GeoTessProfile& p) const
132 { return (GeoTessProfile::operator==(p) && (radius == p.getRadius(0)) && (*data == p.getData(0))); }
133
142 virtual double getValue(int attributeIndex, int nodeIndex) const
143 { return nodeIndex == 0 ? data->getDouble(attributeIndex) : NaN_DOUBLE; }
144
154 virtual double getValue(const GeoTessInterpolatorType& rInterpType,
155 int attributeIndex, double r, bool allowRadiusOutOfRange) const
156 {
157 if (!allowRadiusOutOfRange &&
158 ((r < getRadiusBottom()) || (r > getRadiusTop())))
159 return NaN_DOUBLE;
160
161 // default behavior is to simply return the data value for the first
162 // data object. This works for all the Profile classes that only support
163 // a single Data object like ProfileConstant, ProfileSurface, and
164 // ProfileThin. Profile classes for which the number of supported
165 // Data objects is not equal to 1 must override this method.
166
167 return getValue(attributeIndex, 0);
168 };
169
176 virtual double getValueTop(int attributeIndex) const
177 { return data->getDouble(attributeIndex); }
178
189 virtual bool isNaN(int nodeIndex, int attributeIndex)
190 {
191 return nodeIndex != 0 || data->isNaN(attributeIndex);
192 }
193
198 virtual float getRadius(int i) const { return radius; };
199
203 virtual int getNRadii() const { return 1; };
204
208 virtual int getNData() const { return 1; };
209
213 virtual float* getRadii()
214 { float* fa = new float [1]; fa[0] = radius; return fa; };
215
219 virtual GeoTessData** getData()
220 { GeoTessData** da = new GeoTessData* [1]; da[0] = data; return da; };
221
225 virtual GeoTessData* getData(int i) { return data; };
226
230 virtual const GeoTessData& getData(int i) const { return *data; };
231
235 virtual void setData(const vector<GeoTessData*>& inData)
236 { delete data; data = inData[0]; }
237
241 virtual void setRadii(const vector<float>& newRadii)
242 { radius = newRadii[0]; }
243
244 virtual void setRadius(int index, float newRadius)
245 { if (index == 0) radius = newRadius; }
246
250 virtual void setData(int index, GeoTessData* inData)
251 { delete data; data = inData; }
252
256 virtual float getRadiusTop() const { return radius; };
257
261 virtual const GeoTessData& getDataTop() const { return *data; };
262
266 virtual GeoTessData* getDataTop() { return data; };
267
271 virtual float getRadiusBottom() const { return radius; };
272
276 virtual const GeoTessData& getDataBottom() const { return *data; };
277
281 virtual GeoTessData* getDataBottom() { return data; };
282
284
288 GeoTessProfileThin(IFStreamBinary& ifs, GeoTessMetaData& gtmd) : GeoTessProfile(),
289 radius(-1.0), data(NULL), pointIndex(-1)
290 { radius = ifs.readFloat(); data = GeoTessData::getData(ifs, gtmd); };
291
295 GeoTessProfileThin(IFStreamAscii& ifs, GeoTessMetaData& gtmd) : GeoTessProfile(),
296 radius(-1.0), data(NULL), pointIndex(-1)
297 { radius = ifs.readFloat(); data = GeoTessData::getData(ifs, gtmd); };
298
303 virtual ~GeoTessProfileThin() { if (data != NULL) delete data; };
304
308 virtual void write(IFStreamBinary& ofs)
309 { ofs.writeByte((byte) GeoTessProfileType::THIN.ordinal());
310 ofs.writeFloat(radius); data->write(ofs); };
311
315 virtual void write(IFStreamAscii& ofs)
316 { ofs.writeInt(GeoTessProfileType::THIN.ordinal());
317 ofs.writeString(" ");
318 ofs.writeFloat(radius);
319 data->write(ofs);
320 ofs.writeNL(); };
321
330 virtual int findClosestRadiusIndex(double r) const
331 { return 0; }
332
340 virtual void setPointIndex(int nodeIndex, int pntIndex)
341 { pointIndex = pntIndex; }
342
350 virtual void resetPointIndices() { pointIndex = -1; }
351
359 virtual int getPointIndex(int nodeIndex) const
360 { return pointIndex; }
361
365 virtual GeoTessProfile* copy()
366 {
367 return new GeoTessProfileThin(radius, data->copy());
368 }
369
371
372}; // end class ProfileThin
373
374} // end namespace geotess
375
376#endif // PROFILETHIN_OBJECT_H
GEOTESS_EXP_IMP
#define GEOTESS_EXP_IMP
Definition CPPGlobals.h:71
LONG_INT
#define LONG_INT
Definition CPPGlobals.h:111
GeoTessData.h
GeoTessProfile.h
GeoTessProfileType.h
IFStreamAscii.h
IFStreamBinary.h
geotess::GeoTessData
Abstract base class that manages the data values attached to a single grid point.
Definition GeoTessData.h:76
geotess::GeoTessData::getData
static GeoTessData * getData(const GeoTessDataType &dataType, int nAttributes)
geotess::GeoTessInterpolatorType
Enumeration of the interpolation algorithms supported by GeoTess including LINEAR,...
Definition GeoTessInterpolatorType.h:72
geotess::GeoTessMetaData
Basic metadata information about a GeoTessModel.
Definition GeoTessMetaData.h:97
geotess::GeoTessProfile
Abstract class that manages the radii and data values that span a single layer associated with a sing...
Definition GeoTessProfile.h:97
geotess::GeoTessProfile::getData
virtual GeoTessData ** getData()
geotess::GeoTessProfile::getRadius
virtual float getRadius(int i) const
geotess::GeoTessProfileThin
A Profile object consiting of a single radius value and a single Data object. It represents a profile...
Definition GeoTessProfileThin.h:74
geotess::GeoTessProfileThin::setRadii
virtual void setRadii(const vector< float > &newRadii)
Definition GeoTessProfileThin.h:241
geotess::GeoTessProfileThin::getRadiusTop
virtual float getRadiusTop() const
Definition GeoTessProfileThin.h:256
geotess::GeoTessProfileThin::getDataBottom
virtual GeoTessData * getDataBottom()
Definition GeoTessProfileThin.h:281
geotess::GeoTessProfileThin::getDataTop
virtual const GeoTessData & getDataTop() const
Definition GeoTessProfileThin.h:261
geotess::GeoTessProfileThin::getDataBottom
virtual const GeoTessData & getDataBottom() const
Definition GeoTessProfileThin.h:276
geotess::GeoTessProfileThin::getNRadii
virtual int getNRadii() const
Definition GeoTessProfileThin.h:203
geotess::GeoTessProfileThin::getValue
virtual double getValue(const GeoTessInterpolatorType &rInterpType, int attributeIndex, double r, bool allowRadiusOutOfRange) const
Definition GeoTessProfileThin.h:154
geotess::GeoTessProfileThin::getMemory
virtual LONG_INT getMemory()
Definition GeoTessProfileThin.h:118
geotess::GeoTessProfileThin::getRadiusBottom
virtual float getRadiusBottom() const
Definition GeoTessProfileThin.h:271
geotess::GeoTessProfileThin::getNData
virtual int getNData() const
Definition GeoTessProfileThin.h:208
geotess::GeoTessProfileThin::class_size
virtual int class_size() const
Definition GeoTessProfileThin.h:115
geotess::GeoTessProfileThin::isNaN
virtual bool isNaN(int nodeIndex, int attributeIndex)
Definition GeoTessProfileThin.h:189
geotess::GeoTessProfileThin::getData
virtual GeoTessData ** getData()
Definition GeoTessProfileThin.h:219
geotess::GeoTessProfileThin::setData
virtual void setData(const vector< GeoTessData * > &inData)
Definition GeoTessProfileThin.h:235
geotess::GeoTessProfileThin::GeoTessProfileThin
GeoTessProfileThin(float rad, GeoTessData *dat)
Definition GeoTessProfileThin.h:103
geotess::GeoTessProfileThin::getValueTop
virtual double getValueTop(int attributeIndex) const
Definition GeoTessProfileThin.h:176
geotess::GeoTessProfileThin::getValue
virtual double getValue(int attributeIndex, int nodeIndex) const
Definition GeoTessProfileThin.h:142
geotess::GeoTessProfileThin::setRadius
virtual void setRadius(int index, float newRadius)
Definition GeoTessProfileThin.h:244
geotess::GeoTessProfileThin::getDataTop
virtual GeoTessData * getDataTop()
Definition GeoTessProfileThin.h:266
geotess::GeoTessProfileThin::getRadii
virtual float * getRadii()
Definition GeoTessProfileThin.h:213
geotess::GeoTessProfileThin::setData
virtual void setData(int index, GeoTessData *inData)
Definition GeoTessProfileThin.h:250
geotess::GeoTessProfileThin::class_name
static string class_name()
Definition GeoTessProfileThin.h:110
geotess::GeoTessProfileThin::getData
virtual const GeoTessData & getData(int i) const
Definition GeoTessProfileThin.h:230
geotess::GeoTessProfileThin::getData
virtual GeoTessData * getData(int i)
Definition GeoTessProfileThin.h:225
geotess::GeoTessProfileThin::getType
virtual const GeoTessProfileType & getType() const
Definition GeoTessProfileThin.h:125
geotess::GeoTessProfileThin::getRadius
virtual float getRadius(int i) const
Definition GeoTessProfileThin.h:198
geotess::GeoTessProfileType
Enumeration of the valid Profile types, including EMPTY, THIN, CONSTANT, NPOINT and SURFACE.
Definition GeoTessProfileType.h:70
geotess::GeoTessProfileType::THIN
static const GeoTessProfileType THIN
Definition GeoTessProfileType.h:116
geotess::IFStreamBinary
Opens a file for binary read and write access.
Definition IFStreamBinary.h:80
geotess::IFStreamBinary::readFloat
float readFloat()
Definition IFStreamBinary.h:1117
geotess
Definition ArrayReuse.h:55