GeoTessCPP  2.0.0
Software to facilitate storage and retrieval of 3D information about the Earth.
 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 
77 {
78  private:
79 
83  GeoTessData* data;
84 
88  int pointIndex;
89 
93  GeoTessProfileSurface() : GeoTessProfile(), data(NULL),
94  pointIndex(-1) {};
95 
96  public:
97 
102  pointIndex(-1) {};
103 
107  static string class_name() { return "ProfileSurface"; };
108 
112  virtual int class_size() const
113  { return (int) sizeof(GeoTessProfileSurface); };
114 
120  virtual const GeoTessProfileType& getType() const
121  { return GeoTessProfileType::SURFACE; };
122 
126  virtual bool operator == (const GeoTessProfile& p) const
127  { return (GeoTessProfile::operator==(p) &&
128  (*data == p.getData(0)));
129  }
130 
139  virtual double getValue(int attributeIndex, int nodeIndex) const
140  {
141  return nodeIndex == 0 ? data->getDouble(attributeIndex) : NaN_DOUBLE;
142  }
143 
150  virtual double getValueTop(int attributeIndex) const
151  { return data->getDouble(attributeIndex); }
152 
163  virtual bool isNaN(int nodeIndex, int attributeIndex)
164  {
165  return nodeIndex != 0 || data->isNaN(attributeIndex);
166  }
167 
172  virtual double getValue(const GeoTessInterpolatorType& rInterpType,
173  int attributeIndex, double radius,
174  bool allowRadiusOutOfRange) const
175  {
176  return getData(0).getDouble(attributeIndex);
177  }
178 
183  virtual float getRadius(int i) const
184  { return NaN_FLOAT; };
185 
189  virtual int getNRadii() const { return 0; };
190 
194  virtual int getNData() const { return 1; };
195 
199  virtual float* getRadii() { return NULL; };
200 
204  virtual GeoTessData** getData()
205  { GeoTessData** da = new GeoTessData* [1]; da[0] = data; return da; };
206 
210  virtual GeoTessData* getData(int i) { return data; };
211 
215  virtual const GeoTessData& getData(int i) const { return *data; };
216 
220  virtual void setData(const vector<GeoTessData*>& inData)
221  { delete data; data = inData[0]; }
222 
226  virtual void setData(int index, GeoTessData* inData)
227  { delete data; data = inData; }
228 
229  // TODO: added by sb 9/27/2012
233  virtual void setRadii(const vector<float>& newRadii)
234  { /* do nothing */ };
235 
239  virtual float getRadiusTop() const
240  { return NaN_FLOAT; };
241 
245  virtual const GeoTessData& getDataTop() const { return *data; };
246 
250  virtual GeoTessData* getDataTop() { return data; };
251 
255  virtual float getRadiusBottom() const
256  { return NaN_FLOAT; };
257 
261  virtual const GeoTessData& getDataBottom() const { return *data; };
262 
266  virtual GeoTessData* getDataBottom() { return data; };
267 
269 
274  data(NULL), pointIndex(-1)
275  { data = GeoTessData::getData(ifs, gtmd); };
276 
280  GeoTessProfileSurface(IFStreamAscii& ifs, GeoTessMetaData& gtmd) : GeoTessProfile(),
281  data(NULL), pointIndex(-1)
282  { data = GeoTessData::getData(ifs, gtmd); };
283 
288  virtual ~GeoTessProfileSurface() { if (data != NULL) delete data; };
289 
293  virtual void write(IFStreamBinary& ofs)
294  { ofs.writeByte((byte) GeoTessProfileType::SURFACE.ordinal());
295  data->write(ofs); };
296 
300  virtual void write(IFStreamAscii& ofs)
301  { ofs.writeInt(GeoTessProfileType::SURFACE.ordinal());
302  data->write(ofs);
303  ofs.writeNL(); };
304 
305  // *** TODO added 7/20/2012
314  virtual int findClosestRadiusIndex(double radius) const
315  { return -1; }
316 
317  // *** TODO added 7/20/2012
325  virtual void setPointIndex(int nodeIndex, int pntIndex)
326  { pointIndex = pntIndex; }
327 
328  // *** TODO added 10/14/2012
336  virtual void resetPointIndices() { pointIndex = -1; }
337 
338  // *** TODO added 7/20/2012
346  virtual int getPointIndex(int nodeIndex) const
347  { return pointIndex; }
348 
349  // *** TODO added 8/20/2012
353  virtual GeoTessProfile* copy()
354  {
355  return new GeoTessProfileSurface(data->copy());
356  }
357 
359 
360 }; // end class ProfileSurface
361 
362 } // end namespace geotess
363 
364 #endif // PROFILESURFACE_OBJECT_H