GeoTessCPP  2.1
Software to facilitate storage and retrieval of 3D information about the Earth.
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
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 
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 
125 
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 
158  void setActiveRegion();
159 
169  void setActiveRegion(GeoTessPolygon* polygon);
170 
180  void setActiveRegion(const string& polygonFileName)
181  {
182  GeoTessPolygon* plgn = GeoTessPolygonFactory::getPolygon(polygonFileName);
183  setActiveRegion(plgn);
184  }
185 
193  GeoTessPolygon* getPolygon() { return polygon; }
194 
202  void clear();
203 
208  bool isPopulated() { return populated; }
209 
215  int size()
216  {
217  return pointMap.size();
218  }
219 
228  int getVertexIndex(int pointIndex)
229  {
230  return pointMap[pointIndex][0];
231  }
232 
241  int getTessId(int pointIndex)
242  {
243  return metaData.getTessellation(pointMap[pointIndex][1]);
244  }
245 
254  int getLayerIndex(int pointIndex)
255  {
256  return pointMap[pointIndex][1];
257  }
258 
267  int getNodeIndex(int pointIndex)
268  {
269  return pointMap[pointIndex][2];
270  }
271 
280  const vector<int>& getPointIndices(int pointIndex)
281  {
282  return pointMap[pointIndex];
283  }
284 
295  int getPointIndex(int vertex, int layer, int node)
296  {
297  return profiles[vertex][layer]->getPointIndex(node);
298  }
299 
310  int getPointIndexLast(int vertex, int layer)
311  {
312  return profiles[vertex][layer]->getPointIndex(profiles[vertex][layer]->getNData()-1);
313  }
314 
325  int getPointIndexFirst(int vertex, int layer)
326  {
327  return profiles[vertex][layer]->getPointIndex(0);
328  }
329 
333  void setPointData(int pointIndex, GeoTessData* data)
334  {
335  vector<int>& map = pointMap[pointIndex];
336  profiles[map[0]][map[1]]->setData(map[2], data);
337  }
338 
344  GeoTessData* getPointData(int pointIndex)
345  {
346  vector<int>& map = pointMap[pointIndex];
347  return profiles[map[0]][map[1]]->getData(map[2]);
348  }
349 
358  template <typename T>
359  void setPointValue(int pointIndex, int attributeIndex, T value)
360  {
361  vector<int>& map = pointMap[pointIndex];
362  profiles[map[0]][map[1]]->getData(map[2])->setValue(attributeIndex,
363  value);
364  }
365 
373  double getPointValue(int pointIndex, int attributeIndex)
374  {
375  vector<int>& map = pointMap[pointIndex];
376  return profiles[map[0]][map[1]]->getValue(attributeIndex, map[2]);
377  }
378 
388  double getPointValueDouble(int pointIndex, int attributeIndex)
389  {
390  vector<int>& map = pointMap[pointIndex];
391  return profiles[map[0]][map[1]]->getData(map[2])->getDouble(attributeIndex);
392  }
393 
403  float getPointValueFloat(int pointIndex, int attributeIndex)
404  {
405  vector<int>& map = pointMap[pointIndex];
406  return profiles[map[0]][map[1]]->getData(map[2])->getFloat(attributeIndex);
407  }
408 
418  LONG_INT getPointValueLong(int pointIndex, int attributeIndex)
419  {
420  vector<int>& map = pointMap[pointIndex];
421  return profiles[map[0]][map[1]]->getData(map[2])->getLong(attributeIndex);
422  }
423 
433  int getPointValueInt(int pointIndex, int attributeIndex)
434  {
435  vector<int>& map = pointMap[pointIndex];
436  return profiles[map[0]][map[1]]->getData(map[2])->getInt(attributeIndex);
437  }
438 
448  short getPointValueShort(int pointIndex, int attributeIndex)
449  {
450  vector<int>& map = pointMap[pointIndex];
451  return profiles[map[0]][map[1]]->getData(map[2])->getShort(attributeIndex);
452  }
453 
463  byte getPointValueByte(int pointIndex, int attributeIndex)
464  {
465  vector<int>& map = pointMap[pointIndex];
466  return profiles[map[0]][map[1]]->getData(map[2])->getByte(attributeIndex);
467  }
468 
478  bool isNaN(int pointIndex, int attributeIndex)
479  {
480  vector<int>& map = pointMap[pointIndex];
481  return profiles[map[0]][map[1]]->isNaN(map[2], attributeIndex);
482  }
483 
492  void getPointVector(int pointIndex, double* v)
493  {
494  vector<int>& map = pointMap[pointIndex];
495  const double* vv = grid.getVertex(map[0]);
496  double r = profiles[map[0]][map[1]]->getRadius(map[2]);
497  v[0] = vv[0] * r;
498  v[1] = vv[1] * r;
499  v[2] = vv[2] * r;
500  }
501 
508  const double* getPointUnitVector(int pointIndex) const
509  {
510  return grid.getVertex(pointMap[pointIndex][0]);
511  }
512 
519  double getPointRadius(int pointIndex)
520  {
521  vector<int>& map = pointMap[pointIndex];
522  return profiles[map[0]][map[1]]->getRadius(map[2]);
523  }
524 
531  double getPointDepth(int pointIndex)
532  {
533  vector<int>& map = pointMap[pointIndex];
534  return GeoTessUtils::getEarthRadius(
535  grid.getVertex(pointMap[pointIndex][0]))
536  - profiles[map[0]][map[1]]->getRadius(map[2]);
537  }
538 
546  double getDistance3D(int pointIndex1, int pointIndex2)
547  {
548  vector<int>& m1 = pointMap[pointIndex1];
549  vector<int>& m2 = pointMap[pointIndex2];
550  return GeoTessUtils::getDistance3D(grid.getVertex(m1[0]),
551  profiles[m1[0]][m1[1]]->getRadius(m1[2]), grid.getVertex(m2[0]),
552  profiles[m2[0]][m2[1]]->getRadius(m2[2]));
553  }
554 
555 // /**
556 // * Append the input new values array to the profile at pointIndex
557 // */
558 // template<typename T>
559 // void appendData(int pointIndex, T* newValues, int n)
560 // {
561 // vector<int>& map = pointMap[pointIndex];
562 // profiles[map[0]][map[1]]->appendData<T>(map[2], newValues, n);
563 // }
564 
565 
589  void getPointNeighbors(set<int>& pointNeighbors, int pointIndex);
590 
596  string getPointLatLonString(int pointIndex)
597  {
598  return GeoTessUtils::getLatLonString(getPointUnitVector(pointIndex));
599  }
600 
606  string toString(int pointIndex)
607  {
608  char s[100];
609  string frmt = "%8.3f";
610  sprintf(s, frmt.c_str(), getPointDepth(pointIndex));
611  return GeoTessUtils::getLatLonString(getPointUnitVector(pointIndex))
612  + " " + s;
613  }
614 
615 };
616 // end class PointMap
617 
618 }// end namespace geotess
619 
620 #endif // POINTMAP_OBJECT_H
string toString(int pointIndex)
Definition: GeoTessPointMap.h:606
An ordered list of points on the surface of a unit sphere that define a closed polygon.
Definition: GeoTessPolygon.h:111
Relationships between vertices (2D positions in a tessellation), nodes (1D positions along a radial P...
Definition: GeoTessPointMap.h:74
bool isNaN(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:478
void setPointData(int pointIndex, GeoTessData *data)
Definition: GeoTessPointMap.h:333
float getPointValueFloat(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:403
int getLayerIndex(int pointIndex)
Definition: GeoTessPointMap.h:254
void getPointVector(int pointIndex, double *v)
Definition: GeoTessPointMap.h:492
string getPointLatLonString(int pointIndex)
Definition: GeoTessPointMap.h:596
bool isPopulated()
Definition: GeoTessPointMap.h:208
double getPointRadius(int pointIndex)
Definition: GeoTessPointMap.h:519
Manages the geometry and topology of one or more multi-level triangular tessellations of a unit spher...
Definition: GeoTessGrid.h:163
int getPointIndexFirst(int vertex, int layer)
Definition: GeoTessPointMap.h:325
int getTessId(int pointIndex)
Definition: GeoTessPointMap.h:241
static GeoTessData * getData(const GeoTessDataType &dataType, int nAttributes)
int getPointValueInt(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:433
GeoTessData * getPointData(int pointIndex)
Definition: GeoTessPointMap.h:344
void setPointValue(int pointIndex, int attributeIndex, T value)
Definition: GeoTessPointMap.h:359
int getVertexIndex(int pointIndex)
Definition: GeoTessPointMap.h:228
GeoTessPolygon * getPolygon()
Definition: GeoTessPointMap.h:193
void setActiveRegion(const string &polygonFileName)
Definition: GeoTessPointMap.h:180
short getPointValueShort(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:448
LONG_INT getPointValueLong(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:418
int getPointIndex(int vertex, int layer, int node)
Definition: GeoTessPointMap.h:295
const vector< int > & getPointIndices(int pointIndex)
Definition: GeoTessPointMap.h:280
byte getPointValueByte(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:463
#define byte
signed-byte typedef
Definition: CPPGlobals.h:94
bool operator!=(const GeoTessPointMap &other)
Definition: GeoTessPointMap.h:145
double getDistance3D(int pointIndex1, int pointIndex2)
Definition: GeoTessPointMap.h:546
#define LONG_INT
Definition: CPPGlobals.h:111
Abstract class that manages the radii and data values that span a single layer associated with a sing...
Definition: GeoTessProfile.h:96
Abstract base class that manages the data values attached to a single grid point. ...
Definition: GeoTessData.h:75
Top level class that manages the GeoTessMetaData, GeoTessGrid and Data that comprise a 3D Earth model...
Definition: GeoTessModel.h:119
double getPointValueDouble(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:388
int getPointIndexLast(int vertex, int layer)
Definition: GeoTessPointMap.h:310
Basic metadata information about a GeoTessModel.
Definition: GeoTessMetaData.h:96
int size()
Definition: GeoTessPointMap.h:215
double getPointDepth(int pointIndex)
Definition: GeoTessPointMap.h:531
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
const double * getPointUnitVector(int pointIndex) const
Definition: GeoTessPointMap.h:508
double getPointValue(int pointIndex, int attributeIndex)
Definition: GeoTessPointMap.h:373
int getNodeIndex(int pointIndex)
Definition: GeoTessPointMap.h:267