GeoTessCPP: rstt/GeoTessCPP/include/GeoTessPolygon3D.h Source File

GeoTessCPP 2.2.3 Software to facilitate storage and retrieval of 3D information about the Earth.

GeoTessPolygon3D.h
Go to the documentation of this file.
1 //- ****************************************************************************
2 //-
3 //- Copyright 2009 National Technology & Engineering Solutions of Sandia, LLC
4 //- (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S.
5 //- Government 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 //- 1. Redistributions of source code must retain the above copyright notice,
14 //- this list of conditions and the following disclaimer.
15 //-
16 //- 2. Redistributions in binary form must reproduce the above copyright
17 //- notice, this list of conditions and the following disclaimer in the
18 //- documentation and/or other materials provided with the distribution.
19 //-
20 //- 3. Neither the name of the copyright holder nor the names of its
21 //- contributors may be used to endorse or promote products derived from
22 //- this software without specific prior written permission.
23 //-
24 //- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 //- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 //- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 //- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
28 //- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 //- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 //- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 //- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 //- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 //- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 //- POSSIBILITY OF SUCH DAMAGE.
35 //-
36 //- ****************************************************************************
37
38 #ifndef POLYGON3D_H_
39 #define POLYGON3D_H_
40
41 // **** _SYSTEM INCLUDES_ ******************************************************
42
43 #include <cstdio>
44 #include <iostream>
45 #include <iomanip>
46 #include <vector>
47
48 // use standard library objects
49 using namespace std;
50
51 // **** _LOCAL INCLUDES_ *******************************************************
52
53 #include "CPPUtils.h"
54 #include "GeoTessUtils.h"
55 #include "GeoTessGreatCircle.h"
56 #include "IFStreamAscii.h"
57 #include "GeoTessPolygon.h"
58 #include "GeoTessHorizon.h"
59
60 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
61
62 namespace geotess {
63
64 // **** _FORWARD REFERENCES_ ***************************************************
65
66 class GeoTessPosition;
67
68 // **** _CLASS DEFINITION_ *****************************************************
69
116 class GEOTESS_EXP_IMP GeoTessPolygon3D : public GeoTessPolygon
117 {
118 private:
119
120 GeoTessHorizon* bottom;
121
122 GeoTessHorizon* top;
123
124 public:
125
126 ~GeoTessPolygon3D();
127
128 GeoTessPolygon3D() : GeoTessPolygon(), bottom(NULL), top(NULL)
129 {};
130
141 GeoTessPolygon3D(vector<double*> points, GeoTessHorizon* h_bottom, GeoTessHorizon* h_top)
142 : GeoTessPolygon(points), bottom(h_bottom), top(h_top)
143 {}
144
156 GeoTessPolygon3D(double* center, double radius, int nEdges, GeoTessHorizon* h_bottom, GeoTessHorizon* h_top)
157 : GeoTessPolygon(center, radius, nEdges), bottom(h_bottom), top(h_top)
158 {}
159
168 GeoTessPolygon3D(string filename);
169
173 virtual string class_name() { return "Polygon3D"; };
174
178 GeoTessHorizon* getTop()
179 {
180 return top;
181 }
182
186 GeoTessHorizon* getBottom()
187 {
188 return bottom;
189 }
190
204 bool contains(const double* x, const double& radius, const int& layer, GeoTessProfile** profiles)
205 {
206 return (bottom->getLayerIndex() < 0 || layer >= bottom->getLayerIndex())
207 && (top->getLayerIndex() < 0 || layer <= top->getLayerIndex())
208 && radius > bottom->getRadius(x, profiles) - 1e-4
209 && radius < top->getRadius(x, profiles) + 1e-4
210 && GeoTessPolygon::contains(x);
211 }
212
220 bool contains(const double* x, const int& layer)
221 {
222 return ( bottom->getLayerIndex() < 0 || layer >= bottom->getLayerIndex())
223 && ( top->getLayerIndex() < 0 || layer <= top->getLayerIndex())
224 && GeoTessPolygon::contains(x);
225 }
226
233 bool contains(GeoTessPosition& position);
234
246 bool containsAll(vector<double*>& points, vector<double>& radii, vector<int>& layers, vector<GeoTessProfile**>& profiles)
247 {
248 for (int i=0; i<(int)points.size(); ++i)
249 if (!contains(points[i], radii[i], layers[i], profiles[i]))
250 return false;
251 return true;
252 }
253
265 bool containsAny(vector<double*>& points, vector<double>& radii, vector<int>& layers, vector<GeoTessProfile**>& profiles)
266 {
267 for (int i=0; i<(int)points.size(); ++i)
268 if (contains(points[i], radii[i], layers[i], profiles[i]))
269 return true;
270 return false;
271 }
272
273 virtual void write(const string& outputFileName);
274
276
277 virtual void loadAscii(vector<string>& records);
278
280
281 }; // end class Polygon
282
283 } // end namespace geotess
284
285 #endif /* POLYGON3D_H_ */
geotess
Definition: ArrayReuse.h:57
geotess::GeoTessProfile
Abstract class that manages the radii and data values that span a single layer associated with a sing...
Definition: GeoTessProfile.h:99
geotess::GeoTessPolygon3D::containsAny
bool containsAny(vector< double * > &points, vector< double > &radii, vector< int > &layers, vector< GeoTessProfile ** > &profiles)
Definition: GeoTessPolygon3D.h:265
geotess::GeoTessPolygon3D::write
virtual void write(const string &outputFileName)
GeoTessPolygon.h
geotess::GeoTessPolygon3D::~GeoTessPolygon3D
~GeoTessPolygon3D()
geotess::GeoTessPolygon3D::contains
bool contains(const double *x, const double &radius, const int &layer, GeoTessProfile **profiles)
Definition: GeoTessPolygon3D.h:204
geotess::GeoTessPolygon3D::class_name
virtual string class_name()
Definition: GeoTessPolygon3D.h:173
geotess::GeoTessPolygon3D::getBottom
GeoTessHorizon * getBottom()
Definition: GeoTessPolygon3D.h:186
geotess::GeoTessPolygon3D::containsAll
bool containsAll(vector< double * > &points, vector< double > &radii, vector< int > &layers, vector< GeoTessProfile ** > &profiles)
Definition: GeoTessPolygon3D.h:246
geotess::GeoTessPolygon3D::GeoTessPolygon3D
GeoTessPolygon3D(string filename)
geotess::GeoTessPolygon3D::contains
bool contains(const double *x, const int &layer)
Definition: GeoTessPolygon3D.h:220
GeoTessUtils.h
geotess::GeoTessHorizon
An abstract class that represents a single "surface" within a model.
Definition: GeoTessHorizon.h:82
geotess::GeoTessPolygon
An ordered list of points on the surface of a unit sphere that define a closed polygon.
Definition: GeoTessPolygon.h:114
geotess::GeoTessPolygon3D::GeoTessPolygon3D
GeoTessPolygon3D(vector< double * > points, GeoTessHorizon *h_bottom, GeoTessHorizon *h_top)
Definition: GeoTessPolygon3D.h:141
geotess::GeoTessPolygon3D::contains
bool contains(GeoTessPosition &position)
geotess::GeoTessPolygon3D::getTop
GeoTessHorizon * getTop()
Definition: GeoTessPolygon3D.h:178
geotess::GeoTessPolygon3D::GeoTessPolygon3D
GeoTessPolygon3D()
Definition: GeoTessPolygon3D.h:128
GEOTESS_EXP_IMP
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:73
IFStreamAscii.h
geotess::GeoTessHorizon::getLayerIndex
virtual int getLayerIndex()
Definition: GeoTessHorizon.h:148
geotess::GeoTessPolygon3D::GeoTessPolygon3D
GeoTessPolygon3D(double *center, double radius, int nEdges, GeoTessHorizon *h_bottom, GeoTessHorizon *h_top)
Definition: GeoTessPolygon3D.h:156
geotess::GeoTessPosition
Information about an interpolated point at an arbitrary position in a model.
Definition: GeoTessPosition.h:104
GeoTessHorizon.h
GeoTessGreatCircle.h
geotess::GeoTessHorizon::getRadius
virtual double getRadius(const double *position, GeoTessProfile **profiles)
CPPUtils.h
geotess::GeoTessPolygon3D
Extends Polygon by including information and constraints about the radial dimension.
Definition: GeoTessPolygon3D.h:117