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
ProfileSurface.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 "Data.h"
52 #include "Profile.h"
53 #include "ProfileType.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 ProfileSurface: virtual public Profile
77 {
78  private:
79 
83  Data* data;
84 
88  int pointIndex;
89 
93  ProfileSurface() : Profile(), data(NULL),
94  pointIndex(-1) {};
95 
96  public:
97 
101  ProfileSurface(Data* dat) : Profile(), data(dat),
102  pointIndex(-1) {};
103 
107  static string class_name() { return "ProfileSurface"; };
108 
112  virtual int class_size() const
113  { return (int) sizeof(ProfileSurface); };
114 
120  virtual const ProfileType& getType() const
121  { return ProfileType::SURFACE; };
122 
126  virtual bool operator == (const Profile& p) const
127  { return (Profile::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 InterpolatorType& 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 
190  virtual Data** getData()
191  { Data** da = new Data* [1]; da[0] = data; return da; };
192 
196  virtual Data* getData(int i) { return data; };
197 
201  virtual const Data& getData(int i) const { return *data; };
202 
206  virtual void setData(const vector<Data*>& inData)
207  { delete data; data = inData[0]; }
208 
212  virtual void setData(int index, Data* inData)
213  { delete data; data = inData; }
214 
215  // TODO: added by sb 9/27/2012
219  virtual void setRadii(const vector<float>& newRadii)
220  { /* do nothing */ };
221 
225  virtual float getRadiusTop() const
226  { return NaN_FLOAT; };
227 
231  virtual const Data& getDataTop() const { return *data; };
232 
236  virtual Data* getDataTop() { return data; };
237 
241  virtual float getRadiusBottom() const
242  { return NaN_FLOAT; };
243 
247  virtual const Data& getDataBottom() const { return *data; };
248 
252  virtual Data* getDataBottom() { return data; };
253 
257  virtual int getNRadii() const { return 0; };
258 
262  virtual int getNData() const { return 1; };
263 
267  virtual float* getRadii() { return NULL; };
268 
270 
275  data(NULL), pointIndex(-1)
276  { data = Data::getData(ifs, gtmd); };
277 
281  ProfileSurface(IFStreamAscii& ifs, GeoTessMetaData& gtmd) : Profile(),
282  data(NULL), pointIndex(-1)
283  { data = Data::getData(ifs, gtmd); };
284 
289  virtual ~ProfileSurface() { if (data != NULL) delete data; };
290 
294  virtual void write(IFStreamBinary& ofs)
295  { ofs.writeByte((byte) ProfileType::SURFACE.ordinal());
296  data->write(ofs); };
297 
301  virtual void write(IFStreamAscii& ofs)
302  { ofs.writeInt(ProfileType::SURFACE.ordinal());
303  data->write(ofs);
304  ofs.writeNL(); };
305 
306  // *** TODO added 7/20/2012
315  virtual int findClosestRadiusIndex(double radius) const
316  { return -1; }
317 
318  // *** TODO added 7/20/2012
326  virtual void setPointIndex(int nodeIndex, int pntIndex)
327  { pointIndex = pntIndex; }
328 
329  // *** TODO added 10/14/2012
337  virtual void resetPointIndices() { pointIndex = -1; }
338 
339  // *** TODO added 7/20/2012
347  virtual int getPointIndex(int nodeIndex) const
348  { return pointIndex; }
349 
350  // *** TODO added 8/20/2012
354  virtual Profile* copy()
355  {
356  return new ProfileSurface(data->copy());
357  }
358 
360 
361 }; // end class ProfileSurface
362 
363 } // end namespace geotess
364 
365 #endif // PROFILESURFACE_OBJECT_H