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

Loading...
Searching...
No Matches
GeoTessPolygon3D.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 POLYGON3D_H_
37#define POLYGON3D_H_
38
39// **** _SYSTEM INCLUDES_ ******************************************************
40
41#include <cstdio>
42#include <iostream>
43#include <iomanip>
44#include <vector>
45
46// use standard library objects
47 using namespace std;
48
49// **** _LOCAL INCLUDES_ *******************************************************
50
51#include "CPPUtils.h"
52#include "GeoTessUtils.h"
53#include "GeoTessGreatCircle.h"
54#include "IFStreamAscii.h"
55#include "GeoTessPolygon.h"
56#include "GeoTessHorizon.h"
57
58// **** _BEGIN GEOTESS NAMESPACE_ **********************************************
59
60 namespace geotess {
61
62// **** _FORWARD REFERENCES_ ***************************************************
63
64 class GeoTessPosition;
65
66// **** _CLASS DEFINITION_ *****************************************************
67
114 class GEOTESS_EXP_IMP GeoTessPolygon3D : public GeoTessPolygon
115{
116 private:
117
118 GeoTessHorizon* bottom;
119
120 GeoTessHorizon* top;
121
122 public:
123
124 ~GeoTessPolygon3D();
125
126 GeoTessPolygon3D() : GeoTessPolygon(), bottom(NULL), top(NULL)
127 {};
128
139 GeoTessPolygon3D(vector<double*> points, GeoTessHorizon* h_bottom, GeoTessHorizon* h_top)
140 : GeoTessPolygon(points), bottom(h_bottom), top(h_top)
141 {}
142
154 GeoTessPolygon3D(double* center, double radius, int nEdges, GeoTessHorizon* h_bottom, GeoTessHorizon* h_top)
155 : GeoTessPolygon(center, radius, nEdges), bottom(h_bottom), top(h_top)
156 {}
157
166 GeoTessPolygon3D(string filename);
167
171 virtual string class_name() { return "Polygon3D"; };
172
176 GeoTessHorizon* getTop()
177 {
178 return top;
179 }
180
184 GeoTessHorizon* getBottom()
185 {
186 return bottom;
187 }
188
202 bool contains(const double* x, const double& radius, const int& layer, GeoTessProfile** profiles)
203 {
204 return (bottom->getLayerIndex() < 0 || layer >= bottom->getLayerIndex())
205 && (top->getLayerIndex() < 0 || layer <= top->getLayerIndex())
206 && radius > bottom->getRadius(x, profiles) - 1e-4
207 && radius < top->getRadius(x, profiles) + 1e-4
208 && GeoTessPolygon::contains(x);
209 }
210
218 bool contains(const double* x, const int& layer)
219 {
220 return ( bottom->getLayerIndex() < 0 || layer >= bottom->getLayerIndex())
221 && ( top->getLayerIndex() < 0 || layer <= top->getLayerIndex())
222 && GeoTessPolygon::contains(x);
223 }
224
231 bool contains(GeoTessPosition& position);
232
244 bool containsAll(vector<double*>& points, vector<double>& radii, vector<int>& layers, vector<GeoTessProfile**>& profiles)
245 {
246 for (int i=0; i<(int)points.size(); ++i)
247 if (!contains(points[i], radii[i], layers[i], profiles[i]))
248 return false;
249 return true;
250 }
251
263 bool containsAny(vector<double*>& points, vector<double>& radii, vector<int>& layers, vector<GeoTessProfile**>& profiles)
264 {
265 for (int i=0; i<(int)points.size(); ++i)
266 if (contains(points[i], radii[i], layers[i], profiles[i]))
267 return true;
268 return false;
269 }
270
271 virtual void write(const string& outputFileName);
272
274
275 virtual void loadAscii(vector<string>& records);
276
278
279}; // end class Polygon
280
281} // end namespace geotess
282
283#endif /* POLYGON3D_H_ */
GEOTESS_EXP_IMP
#define GEOTESS_EXP_IMP
Definition CPPGlobals.h:71
CPPUtils.h
GeoTessGreatCircle.h
GeoTessHorizon.h
GeoTessPolygon.h
GeoTessUtils.h
IFStreamAscii.h
geotess::GeoTessHorizon
An abstract class that represents a single "surface" within a model.
Definition GeoTessHorizon.h:80
geotess::GeoTessPolygon3D::containsAll
bool containsAll(vector< double * > &points, vector< double > &radii, vector< int > &layers, vector< GeoTessProfile ** > &profiles)
Definition GeoTessPolygon3D.h:244
geotess::GeoTessPolygon3D::GeoTessPolygon3D
GeoTessPolygon3D(vector< double * > points, GeoTessHorizon *h_bottom, GeoTessHorizon *h_top)
Definition GeoTessPolygon3D.h:139
geotess::GeoTessPolygon3D::class_name
virtual string class_name()
Definition GeoTessPolygon3D.h:171
geotess::GeoTessPolygon3D::contains
bool contains(const double *x, const double &radius, const int &layer, GeoTessProfile **profiles)
Definition GeoTessPolygon3D.h:202
geotess::GeoTessPolygon3D::~GeoTessPolygon3D
~GeoTessPolygon3D()
geotess::GeoTessPolygon3D::getTop
GeoTessHorizon * getTop()
Definition GeoTessPolygon3D.h:176
geotess::GeoTessPolygon3D::contains
bool contains(const double *x, const int &layer)
Definition GeoTessPolygon3D.h:218
geotess::GeoTessPolygon3D::GeoTessPolygon3D
GeoTessPolygon3D()
Definition GeoTessPolygon3D.h:126
geotess::GeoTessPolygon3D::getBottom
GeoTessHorizon * getBottom()
Definition GeoTessPolygon3D.h:184
geotess::GeoTessPolygon3D::write
virtual void write(const string &outputFileName)
geotess::GeoTessPolygon3D::contains
bool contains(GeoTessPosition &position)
geotess::GeoTessPolygon3D::GeoTessPolygon3D
GeoTessPolygon3D(string filename)
geotess::GeoTessPolygon3D::containsAny
bool containsAny(vector< double * > &points, vector< double > &radii, vector< int > &layers, vector< GeoTessProfile ** > &profiles)
Definition GeoTessPolygon3D.h:263
geotess::GeoTessPolygon3D::GeoTessPolygon3D
GeoTessPolygon3D(double *center, double radius, int nEdges, GeoTessHorizon *h_bottom, GeoTessHorizon *h_top)
Definition GeoTessPolygon3D.h:154
geotess::GeoTessPolygon::GeoTessPolygon
GeoTessPolygon()
geotess::GeoTessPolygon::contains
bool contains(const double *x)
Definition GeoTessPolygon.h:380
geotess::GeoTessPosition
Information about an interpolated point at an arbitrary position in a model.
Definition GeoTessPosition.h:102
geotess::GeoTessProfile
Abstract class that manages the radii and data values that span a single layer associated with a sing...
Definition GeoTessProfile.h:97
geotess
Definition ArrayReuse.h:55