GeoTessCPP  2.2
Software to facilitate storage and retrieval of 3D information about the Earth.
GeoTessHorizonLayer.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 HORIZONLAYER_H_
37 #define HORIZONLAYER_H_
38 
39 // **** _SYSTEM INCLUDES_ ******************************************************
40 
41 #include <iostream>
42 #include <fstream>
43 #include <string>
44 #include <climits>
45 
46 // use standard library objects
47 using namespace std;
48 
49 // **** _LOCAL INCLUDES_ *******************************************************
50 
51 #include "GeoTessHorizon.h"
52 #include "GeoTessProfile.h"
53 #include "GeoTessPosition.h"
54 
55 // **** _BEGIN GEOTESS NAMESPACE_ *********************************************
56 
57 namespace geotess {
58 
59 // **** _FORWARD REFERENCES_ ***************************************************
60 
61 // **** _CLASS DEFINITION_ *****************************************************
62 
74 {
75 
76 private:
77 
82  double fraction;
83 
84 public:
85 
96  GeoTessHorizonLayer(const double& fractionalPosition, const int& lyrIndex)
97  : GeoTessHorizon(lyrIndex), fraction(fractionalPosition)
98  {};
99 
103  GeoTessHorizonLayer(GeoTessHorizonLayer& other) : GeoTessHorizon(other.getLayerIndex()), fraction(other.fraction)
104  {
105  }
106 
111  {
112  layerIndex = other.layerIndex;
113  fraction = other.fraction;
114  return *this;
115  }
116 
120  virtual ~GeoTessHorizonLayer() {};
121 
122  virtual double getValue() { return fraction; };
123 
124  virtual double getRadius(const double* position, GeoTessProfile** profiles)
125  {
126  double bottom = profiles[layerIndex]->getRadiusBottom();
127  if (fraction <= 0. )
128  return bottom;
129  double top = profiles[layerIndex]->getRadiusTop();
130  if (fraction >= 1.)
131  return top;
132  return bottom + fraction*(top-bottom);
133  }
134 
135  virtual string class_name() { return "HorizonLayer"; };
136 
137  virtual double getRadius(GeoTessPosition& position)
138  {
139  double bottom = position.getRadiusBottom(layerIndex);
140  if (fraction <= 0. )
141  return bottom;
142  double top = position.getRadiusTop(layerIndex);
143  if (fraction >= 1.)
144  return top;
145  return bottom + fraction*(top-bottom);
146  }
147 
148  virtual string str()
149  {
150  string s = "layer " + CPPUtils::dtos(fraction) + " " + CPPUtils::itos(layerIndex);
151  return s;
152  }
153 
154 }; // end class DataValue
155 
156 } // end namespace geotess
157 
158 #endif /* HORIZONLAYER_H_ */
virtual double getRadius(const double *position, GeoTessProfile **profiles)
Return the radius of the Horizon at the specified geographic position and constrained by the specifie...
Definition: GeoTessHorizonLayer.h:124
Information about an interpolated point at an arbitrary position in a model.
Definition: GeoTessPosition.h:101
virtual double getRadius(GeoTessPosition &position)
Return the radius of the Horizon at the position of the specified GeoTessPosition object...
Definition: GeoTessHorizonLayer.h:137
virtual string str()
Definition: GeoTessHorizonLayer.h:148
Definition: ArrayReuse.h:55
virtual ~GeoTessHorizonLayer()
Destructor.
Definition: GeoTessHorizonLayer.h:120
An abstract class that represents a single "surface" within a model.
Definition: GeoTessHorizon.h:79
GeoTessHorizonLayer & operator=(const GeoTessHorizonLayer &other)
Overloaded assignment operator.
Definition: GeoTessHorizonLayer.h:110
Defines a "surface" in a model that resides at a constant fractional radius within a specified layer...
Definition: GeoTessHorizonLayer.h:73
virtual float getRadiusTop() const
Get the radius at the top of the profile, in km.
GeoTessHorizonLayer(const double &fractionalPosition, const int &lyrIndex)
Constructor for a Horizon object that represents a constant fractional radius within a layer...
Definition: GeoTessHorizonLayer.h:96
Abstract class that manages the radii and data values that span a single layer associated with a sing...
Definition: GeoTessProfile.h:96
virtual string class_name()
Definition: GeoTessHorizonLayer.h:135
double getRadiusTop(int layid)
Retrieve an interpolated value of the radius of the top of the specified layer, in km...
GeoTessHorizonLayer(GeoTessHorizonLayer &other)
Copy constructor.
Definition: GeoTessHorizonLayer.h:103
double getRadiusBottom(int layid)
Retrieve an interpolated value of the radius of the bottom of the specified layer, in km.
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
int layerIndex
If layerIndex is >= 0 and < the number of layers represented in a model, then the returned radius wil...
Definition: GeoTessHorizon.h:92
virtual double getValue()
HorizonDepth objects return depth, HorizonRadius object return radius, and HorizonLayer object return...
Definition: GeoTessHorizonLayer.h:122
virtual float getRadiusBottom() const
Get the radius at the bottom of the profile, in km.