GeoTessCPP  2.1
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 
236  virtual void setRadius(int index, float radius)
237  { /* do nothing */ }
238 
242  virtual float getRadiusTop() const
243  { return NaN_FLOAT; };
244 
248  virtual const GeoTessData& getDataTop() const { return *data; };
249 
253  virtual GeoTessData* getDataTop() { return data; };
254 
258  virtual float getRadiusBottom() const
259  { return NaN_FLOAT; };
260 
264  virtual const GeoTessData& getDataBottom() const { return *data; };
265 
269  virtual GeoTessData* getDataBottom() { return data; };
270 
272 
277  data(NULL), pointIndex(-1)
278  { data = GeoTessData::getData(ifs, gtmd); };
279 
283  GeoTessProfileSurface(IFStreamAscii& ifs, GeoTessMetaData& gtmd) : GeoTessProfile(),
284  data(NULL), pointIndex(-1)
285  { data = GeoTessData::getData(ifs, gtmd); };
286 
291  virtual ~GeoTessProfileSurface() { if (data != NULL) delete data; };
292 
296  virtual void write(IFStreamBinary& ofs)
297  { ofs.writeByte((byte) GeoTessProfileType::SURFACE.ordinal());
298  data->write(ofs); };
299 
303  virtual void write(IFStreamAscii& ofs)
304  { ofs.writeInt(GeoTessProfileType::SURFACE.ordinal());
305  data->write(ofs);
306  ofs.writeNL(); };
307 
308  // *** TODO added 7/20/2012
317  virtual int findClosestRadiusIndex(double radius) const
318  { return -1; }
319 
320  // *** TODO added 7/20/2012
328  virtual void setPointIndex(int nodeIndex, int pntIndex)
329  { pointIndex = pntIndex; }
330 
331  // *** TODO added 10/14/2012
339  virtual void resetPointIndices() { pointIndex = -1; }
340 
341  // *** TODO added 7/20/2012
349  virtual int getPointIndex(int nodeIndex) const
350  { return pointIndex; }
351 
352  // *** TODO added 8/20/2012
356  virtual GeoTessProfile* copy()
357  {
358  return new GeoTessProfileSurface(data->copy());
359  }
360 
362 
363 }; // end class ProfileSurface
364 
365 } // end namespace geotess
366 
367 #endif // PROFILESURFACE_OBJECT_H