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
ProfileEmpty.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 PROFILEEMPTY_OBJECT_H
37 #define PROFILEEMPTY_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 "Profile.h"
51 #include "ProfileType.h"
52 #include "IFStreamAscii.h"
53 #include "IFStreamBinary.h"
54 
55 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
56 
57 namespace geotess {
58 
59 // **** _FORWARD REFERENCES_ ***************************************************
60 
61 class Data;
62 
63 // **** _CLASS DEFINITION_ *****************************************************
64 
74 class GEOTESS_EXP_IMP ProfileEmpty : virtual public Profile
75 {
76  private:
77 
81  float radiusTop;
82 
86  float radiusBottom;
87 
91  ProfileEmpty() : Profile(), radiusTop(0.0), radiusBottom(0.0) {};
92 
93  public:
94 
98  ProfileEmpty(float radBot, float radTop) : Profile(),
99  radiusTop(radTop), radiusBottom(radBot)
100  {}
101 
106  { radiusBottom = ifs.readFloat();
107  radiusTop = ifs.readFloat();
108  }
109 
114  { radiusBottom = ifs.readFloat();
115  radiusTop = ifs.readFloat();
116  }
117 
121  ProfileEmpty(float radii[], int &rIndex) : Profile()
122  { radiusBottom = radii[rIndex++];
123  radiusTop = radii[rIndex++];
124  }
125 
129  virtual ~ProfileEmpty() {};
130 
134  static string class_name() { return "ProfileEmpty"; };
135 
139  virtual int class_size() const
140  { return (int) sizeof(ProfileEmpty); };
141 
147  virtual const ProfileType& getType() const
148  { return ProfileType::EMPTY; };
149 
153  virtual bool operator == (const Profile& p) const
154  { return (Profile::operator==(p) &&
155  (radiusBottom == p.getRadiusBottom()) &&
156  (radiusTop == p.getRadiusTop()));
157  }
158 
163  virtual double getValue(const InterpolatorType& rInterpType,
164  int attributeIndex, double radius,
165  bool allowRadiusOutOfRange) const;
166 
175  virtual double getValue(int attributeIndex, int nodeIndex) const
176  { return NaN_DOUBLE; }
177 
188  virtual bool isNaN(int nodeIndex, int attributeIndex)
189  {
190  return true;
191  }
192 
193  // *** TODO added 7/20/2012
200  virtual double getValueTop(int attributeIndex) const
201  {
202  return NaN_DOUBLE;
203  }
204 
205  // *** TODO added 7/20/2012
212  virtual double getValueBottom(int attributeIndex) const
213  {
214  return NaN_DOUBLE;
215  }
216 
221  virtual float getRadius(int i) const
222  { return i == 0 ? radiusBottom : radiusTop; };
223 
228  virtual Data** getData();
229 
233  virtual Data* getData(int i);
234 
238  virtual const Data& getData(int i) const;
239 
243  virtual void setData(const vector<Data*>& inData)
244  {/* do nothing*/ };
245 
246  // TODO: added by sb 9/27/2012
250  virtual void setRadii(const vector<float>& newRadii)
251  { radiusBottom = newRadii[0]; radiusTop = newRadii[1]; }
252 
253  // *** TODO added 7/19/2012
257  virtual void setData(int index, Data* inData)
258  { /* do nothing*/ };
259 
263  virtual float getRadiusTop() const { return radiusTop; };
264 
268  virtual const Data& getDataTop() const;
269 
273  virtual Data* getDataTop() { return NULL; }
274 
278  virtual float getRadiusBottom() const { return radiusBottom; };
279 
283  virtual const Data& getDataBottom() const;
284 
288  virtual Data* getDataBottom() { return NULL; }
289 
293  virtual int getNRadii() const { return 2; };
294 
298  virtual int getNData() const { return 0; };
299 
303  virtual float* getRadii()
304  { float* fa = new float [2]; fa[0] = radiusBottom;
305  fa[1] = radiusTop; return fa; };
306 
310  virtual void write(IFStreamBinary& ofs)
311  { ofs.writeByte((byte) ProfileType::EMPTY.ordinal());
312  ofs.writeFloat(radiusBottom);
313  ofs.writeFloat(radiusTop); };
314 
318  virtual void write(IFStreamAscii& ofs)
319  { ofs.writeInt(ProfileType::EMPTY.ordinal());
320  ofs.writeString(" ");
321  ofs.writeFloat(radiusBottom);
322  ofs.writeString(" ");
323  ofs.writeFloatNL(radiusTop);
324  ofs.writeNL(); };
325 
326  // *** TODO added 7/20/2012
335  virtual int findClosestRadiusIndex(double radius) const
336  { return abs(radiusTop - radius) < abs(radiusBottom - radius) ? 1 : 0; }
337 
338  // *** TODO added 7/20/2012
346  virtual void setPointIndex(int nodeIndex, int pointIndex)
347  {
348  // do nothing. empty profiles have no data, hence pointIndex is always -1.
349  }
350 
351  // *** TODO added 10/14/2012
359  virtual void resetPointIndices() { /* empty profiles have no data, hence pointIndex is always -1. */ }
360 
361  // *** TODO added 7/20/2012
369  virtual int getPointIndex(int nodeIndex) const
370  { return -1; }
371 
372  // *** TODO added 7/20/2012
379  virtual void getWeights(map<int, double>& weights,
380  double dkm, double radius, double hcoefficient) const
381  {
382  // do nothing.
383  }
384 
385  // *** TODO added 7/26/2012
389  virtual void getCoefficients(map<int, double>& coefficients, double radius,
390  double horizontalCoefficient) const
391  {
392  // do nothing.
393  }
394 
395  virtual void setInterpolationCoefficients(const InterpolatorType& interpType,
396  vector<int>& nodeIndexes, vector<double>& coefficients,
397  double& radius, bool& allowOutOfRange)
398  {
399  // POISON!
400  nodeIndexes.push_back(0);
401  coefficients.push_back(NaN_DOUBLE);
402  }
403 
404  // *** TODO added 8/20/2012
408  virtual Profile* copy()
409  {
410  return new ProfileEmpty(radiusBottom, radiusTop);
411  }
412 
414 
416 
417 }; // end class ProfileEmpty
418 
419 } // end namespace geotess
420 
421 #endif // PROFILEEMPTY_OBJECT_H