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

Loading...
Searching...
No Matches
GeoTessPointMap.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 POINTMAP_OBJECT_H
37#define POINTMAP_OBJECT_H
38
39// **** _SYSTEM INCLUDES_ ******************************************************
40
41#include <cstdio>
42
43// use standard library objects
44 using namespace std;
45
46// **** _LOCAL INCLUDES_ *******************************************************
47
48#include "CPPUtils.h"
49#include "GeoTessGrid.h"
50#include "GeoTessProfile.h"
51#include "GeoTessMetaData.h"
52#include "GeoTessPolygon.h"
53#include "GeoTessPolygon3D.h"
54#include "GeoTessPolygonFactory.h"
55
56// **** _BEGIN GEOTESS NAMESPACE_ **********************************************
57
58 namespace geotess
59{
60
61// **** _FORWARD REFERENCES_ ***************************************************
62
63 class GeoTessModel;
64
65// **** _CLASS DEFINITION_ *****************************************************
66
74 class GEOTESS_EXP_IMP GeoTessPointMap
75{
76 private:
77
81 GeoTessGrid& grid;
82
87 GeoTessProfile *** profiles;
88
105 GeoTessMetaData& metaData;
106
107 GeoTessPolygon* polygon;
108
114 vector<vector<int> > pointMap;
115
116 bool populated;
117
118 public:
119
124 GeoTessPointMap(GeoTessModel& m);
125
129 GeoTessPointMap(GeoTessPointMap& other);
130
134 GeoTessPointMap& operator=(const GeoTessPointMap& other);
135
140 bool operator==(const GeoTessPointMap& other);
141
145 bool operator!=(const GeoTessPointMap& other) { return !(*this == other); }
146
150 ~GeoTessPointMap();
151
152 LONG_INT getMemory()
153 {
154 return (LONG_INT) sizeof(GeoTessPointMap)
155 + (LONG_INT)(pointMap.capacity() * sizeof(vector<int>)
156 + pointMap.size() * 3 * (LONG_INT)sizeof(int));
157 }
158
165 void setActiveRegion();
166
176 void setActiveRegion(GeoTessPolygon* polygon);
177
187 void setActiveRegion(const string& polygonFileName)
188 {
189 GeoTessPolygon* plgn = GeoTessPolygonFactory::getPolygon(polygonFileName);
190 setActiveRegion(plgn);
191 }
192
200 GeoTessPolygon* getPolygon() { return polygon; }
201
209 void clear();
210
215 bool isPopulated() { return populated; }
216
222 int size()
223 {
224 return pointMap.size();
225 }
226
235 int getVertexIndex(int pointIndex)
236 {
237 return pointMap[pointIndex][0];
238 }
239
248 int getTessId(int pointIndex)
249 {
250 return metaData.getTessellation(pointMap[pointIndex][1]);
251 }
252
261 int getLayerIndex(int pointIndex)
262 {
263 return pointMap[pointIndex][1];
264 }
265
274 int getNodeIndex(int pointIndex)
275 {
276 return pointMap[pointIndex][2];
277 }
278
287 const vector<int>& getPointIndices(int pointIndex)
288 {
289 return pointMap[pointIndex];
290 }
291
302 int getPointIndex(int vertex, int layer, int node)
303 {
304 return profiles[vertex][layer]->getPointIndex(node);
305 }
306
317 int getPointIndexLast(int vertex, int layer)
318 {
319 return profiles[vertex][layer]->getPointIndex(profiles[vertex][layer]->getNData()-1);
320 }
321
332 int getPointIndexFirst(int vertex, int layer)
333 {
334 return profiles[vertex][layer]->getPointIndex(0);
335 }
336
340 void setPointData(int pointIndex, GeoTessData* data)
341 {
342 vector<int>& map = pointMap[pointIndex];
343 profiles[map[0]][map[1]]->setData(map[2], data);
344 }
345
351 GeoTessData* getPointData(int pointIndex)
352 {
353 vector<int>& map = pointMap[pointIndex];
354 return profiles[map[0]][map[1]]->getData(map[2]);
355 }
356
365 template <typename T>
366 void setPointValue(int pointIndex, int attributeIndex, T value)
367 {
368 vector<int>& map = pointMap[pointIndex];
369 profiles[map[0]][map[1]]->getData(map[2])->setValue(attributeIndex,
370 value);
371 }
372
380 double getPointValue(int pointIndex, int attributeIndex)
381 {
382 vector<int>& map = pointMap[pointIndex];
383 return profiles[map[0]][map[1]]->getValue(attributeIndex, map[2]);
384 }
385
395 double getPointValueDouble(int pointIndex, int attributeIndex)
396 {
397 vector<int>& map = pointMap[pointIndex];
398 return profiles[map[0]][map[1]]->getData(map[2])->getDouble(attributeIndex);
399 }
400
410 float getPointValueFloat(int pointIndex, int attributeIndex)
411 {
412 vector<int>& map = pointMap[pointIndex];
413 return profiles[map[0]][map[1]]->getData(map[2])->getFloat(attributeIndex);
414 }
415
425 LONG_INT getPointValueLong(int pointIndex, int attributeIndex)
426 {
427 vector<int>& map = pointMap[pointIndex];
428 return profiles[map[0]][map[1]]->getData(map[2])->getLong(attributeIndex);
429 }
430
440 int getPointValueInt(int pointIndex, int attributeIndex)
441 {
442 vector<int>& map = pointMap[pointIndex];
443 return profiles[map[0]][map[1]]->getData(map[2])->getInt(attributeIndex);
444 }
445
455 short getPointValueShort(int pointIndex, int attributeIndex)
456 {
457 vector<int>& map = pointMap[pointIndex];
458 return profiles[map[0]][map[1]]->getData(map[2])->getShort(attributeIndex);
459 }
460
470 byte getPointValueByte(int pointIndex, int attributeIndex)
471 {
472 vector<int>& map = pointMap[pointIndex];
473 return profiles[map[0]][map[1]]->getData(map[2])->getByte(attributeIndex);
474 }
475
485 bool isNaN(int pointIndex, int attributeIndex)
486 {
487 vector<int>& map = pointMap[pointIndex];
488 return profiles[map[0]][map[1]]->isNaN(map[2], attributeIndex);
489 }
490
499 void getPointVector(int pointIndex, double* v)
500 {
501 vector<int>& map = pointMap[pointIndex];
502 const double* vv = grid.getVertex(map[0]);
503 double r = profiles[map[0]][map[1]]->getRadius(map[2]);
504 v[0] = vv[0] * r;
505 v[1] = vv[1] * r;
506 v[2] = vv[2] * r;
507 }
508
515 const double* getPointUnitVector(int pointIndex) const
516 {
517 return grid.getVertex(pointMap[pointIndex][0]);
518 }
519
526 double getPointRadius(int pointIndex)
527 {
528 vector<int>& map = pointMap[pointIndex];
529 return profiles[map[0]][map[1]]->getRadius(map[2]);
530 }
531
538 double getPointDepth(int pointIndex)
539 {
540 vector<int>& map = pointMap[pointIndex];
541 return GeoTessUtils::getEarthRadius(
542 grid.getVertex(pointMap[pointIndex][0]))
543 - profiles[map[0]][map[1]]->getRadius(map[2]);
544 }
545
553 double getDistance3D(int pointIndex1, int pointIndex2)
554 {
555 vector<int>& m1 = pointMap[pointIndex1];
556 vector<int>& m2 = pointMap[pointIndex2];
557 return GeoTessUtils::getDistance3D(grid.getVertex(m1[0]),
558 profiles[m1[0]][m1[1]]->getRadius(m1[2]), grid.getVertex(m2[0]),
559 profiles[m2[0]][m2[1]]->getRadius(m2[2]));
560 }
561
562// /**
563// * Append the input new values array to the profile at pointIndex
564// */
565// template<typename T>
566// void appendData(int pointIndex, T* newValues, int n)
567// {
568// vector<int>& map = pointMap[pointIndex];
569// profiles[map[0]][map[1]]->appendData<T>(map[2], newValues, n);
570// }
571
572
596 void getPointNeighbors(set<int>& pointNeighbors, int pointIndex);
597
603 string getPointLatLonString(int pointIndex)
604 {
605 return GeoTessUtils::getLatLonString(getPointUnitVector(pointIndex));
606 }
607
613 string toString(int pointIndex)
614 {
615 char s[100];
616 string frmt = "%8.3f";
617 snprintf(s, sizeof(s), frmt.c_str(), getPointDepth(pointIndex));
618 return GeoTessUtils::getLatLonString(getPointUnitVector(pointIndex))
619 + " " + s;
620 }
621
622};
623// end class PointMap
624
625}// end namespace geotess
626
627#endif // POINTMAP_OBJECT_H
GEOTESS_EXP_IMP
#define GEOTESS_EXP_IMP
Definition CPPGlobals.h:71
LONG_INT
#define LONG_INT
Definition CPPGlobals.h:111
CPPUtils.h
GeoTessGrid.h
GeoTessMetaData.h
GeoTessPolygon3D.h
GeoTessPolygon.h
GeoTessPolygonFactory.h
GeoTessProfile.h
geotess::GeoTessData
Abstract base class that manages the data values attached to a single grid point.
Definition GeoTessData.h:76
geotess::GeoTessData::getData
static GeoTessData * getData(const GeoTessDataType &dataType, int nAttributes)
geotess::GeoTessGrid
Manages the geometry and topology of one or more multi-level triangular tessellations of a unit spher...
Definition GeoTessGrid.h:167
geotess::GeoTessMetaData
Basic metadata information about a GeoTessModel.
Definition GeoTessMetaData.h:97
geotess::GeoTessModel
Top level class that manages the GeoTessMetaData, GeoTessGrid and GeoTessData that comprise a 3D Eart...
Definition GeoTessModel.h:120
geotess::GeoTessPointMap::getMemory
LONG_INT getMemory()
Definition GeoTessPointMap.h:152
geotess::GeoTessPointMap::getPointUnitVector
const double * getPointUnitVector(int pointIndex) const
Definition GeoTessPointMap.h:515
geotess::GeoTessPointMap::isPopulated
bool isPopulated()
Definition GeoTessPointMap.h:215
geotess::GeoTessPointMap::getPointNeighbors
void getPointNeighbors(set< int > &pointNeighbors, int pointIndex)
geotess::GeoTessPointMap::getPointVector
void getPointVector(int pointIndex, double *v)
Definition GeoTessPointMap.h:499
geotess::GeoTessPointMap::getPointIndices
const vector< int > & getPointIndices(int pointIndex)
Definition GeoTessPointMap.h:287
geotess::GeoTessPointMap::getNodeIndex
int getNodeIndex(int pointIndex)
Definition GeoTessPointMap.h:274
geotess::GeoTessPointMap::getPointValueFloat
float getPointValueFloat(int pointIndex, int attributeIndex)
Definition GeoTessPointMap.h:410
geotess::GeoTessPointMap::getPointValue
double getPointValue(int pointIndex, int attributeIndex)
Definition GeoTessPointMap.h:380
geotess::GeoTessPointMap::setPointData
void setPointData(int pointIndex, GeoTessData *data)
Definition GeoTessPointMap.h:340
geotess::GeoTessPointMap::setActiveRegion
void setActiveRegion()
geotess::GeoTessPointMap::GeoTessPointMap
GeoTessPointMap(GeoTessPointMap &other)
geotess::GeoTessPointMap::getPointRadius
double getPointRadius(int pointIndex)
Definition GeoTessPointMap.h:526
geotess::GeoTessPointMap::getPointDepth
double getPointDepth(int pointIndex)
Definition GeoTessPointMap.h:538
geotess::GeoTessPointMap::getPointValueByte
byte getPointValueByte(int pointIndex, int attributeIndex)
Definition GeoTessPointMap.h:470
geotess::GeoTessPointMap::getPointValueDouble
double getPointValueDouble(int pointIndex, int attributeIndex)
Definition GeoTessPointMap.h:395
geotess::GeoTessPointMap::getTessId
int getTessId(int pointIndex)
Definition GeoTessPointMap.h:248
geotess::GeoTessPointMap::setActiveRegion
void setActiveRegion(GeoTessPolygon *polygon)
geotess::GeoTessPointMap::getPointValueShort
short getPointValueShort(int pointIndex, int attributeIndex)
Definition GeoTessPointMap.h:455
geotess::GeoTessPointMap::getLayerIndex
int getLayerIndex(int pointIndex)
Definition GeoTessPointMap.h:261
geotess::GeoTessPointMap::getPointData
GeoTessData * getPointData(int pointIndex)
Definition GeoTessPointMap.h:351
geotess::GeoTessPointMap::operator=
GeoTessPointMap & operator=(const GeoTessPointMap &other)
geotess::GeoTessPointMap::getPointValueInt
int getPointValueInt(int pointIndex, int attributeIndex)
Definition GeoTessPointMap.h:440
geotess::GeoTessPointMap::getVertexIndex
int getVertexIndex(int pointIndex)
Definition GeoTessPointMap.h:235
geotess::GeoTessPointMap::~GeoTessPointMap
~GeoTessPointMap()
geotess::GeoTessPointMap::clear
void clear()
geotess::GeoTessPointMap::getPointValueLong
LONG_INT getPointValueLong(int pointIndex, int attributeIndex)
Definition GeoTessPointMap.h:425
geotess::GeoTessPointMap::operator!=
bool operator!=(const GeoTessPointMap &other)
Definition GeoTessPointMap.h:145
geotess::GeoTessPointMap::getPointLatLonString
string getPointLatLonString(int pointIndex)
Definition GeoTessPointMap.h:603
geotess::GeoTessPointMap::operator==
bool operator==(const GeoTessPointMap &other)
geotess::GeoTessPointMap::setPointValue
void setPointValue(int pointIndex, int attributeIndex, T value)
Definition GeoTessPointMap.h:366
geotess::GeoTessPointMap::getPointIndexLast
int getPointIndexLast(int vertex, int layer)
Definition GeoTessPointMap.h:317
geotess::GeoTessPointMap::isNaN
bool isNaN(int pointIndex, int attributeIndex)
Definition GeoTessPointMap.h:485
geotess::GeoTessPointMap::setActiveRegion
void setActiveRegion(const string &polygonFileName)
Definition GeoTessPointMap.h:187
geotess::GeoTessPointMap::getDistance3D
double getDistance3D(int pointIndex1, int pointIndex2)
Definition GeoTessPointMap.h:553
geotess::GeoTessPointMap::getPointIndexFirst
int getPointIndexFirst(int vertex, int layer)
Definition GeoTessPointMap.h:332
geotess::GeoTessPointMap::size
int size()
Definition GeoTessPointMap.h:222
geotess::GeoTessPointMap::getPolygon
GeoTessPolygon * getPolygon()
Definition GeoTessPointMap.h:200
geotess::GeoTessPointMap::GeoTessPointMap
GeoTessPointMap(GeoTessModel &m)
geotess::GeoTessPointMap::toString
string toString(int pointIndex)
Definition GeoTessPointMap.h:613
geotess::GeoTessPointMap::getPointIndex
int getPointIndex(int vertex, int layer, int node)
Definition GeoTessPointMap.h:302
geotess::GeoTessPolygonFactory::getPolygon
static GeoTessPolygon * getPolygon(string inputFileName)
Definition GeoTessPolygonFactory.h:76
geotess::GeoTessPolygon
An ordered list of points on the surface of a unit sphere that define a closed polygon.
Definition GeoTessPolygon.h:112
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::GeoTessUtils::getEarthRadius
static double getEarthRadius(const double *const v)
Definition GeoTessUtils.h:553
geotess::GeoTessUtils::getLatLonString
static string getLatLonString(const double *const v)
geotess::GeoTessUtils::getDistance3D
static double getDistance3D(const double *const v0, double r0, const double *const v1, double r1)
Definition GeoTessUtils.h:537
geotess
Definition ArrayReuse.h:55