GeoTessCPP  2.6.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 
135 
140  bool operator==(const GeoTessPointMap& other);
141 
145  bool operator!=(const GeoTessPointMap& other) { return !(*this == other); }
146 
151 
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 
166 
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  sprintf(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
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
#define LONG_INT
Definition: CPPGlobals.h:111
Abstract base class that manages the data values attached to a single grid point.
Definition: GeoTessData.h:76
virtual GeoTessData & setValue(int attributeIndex, double v)
virtual byte getByte(int attributeIndex) const
virtual float getFloat(int attributeIndex) const
virtual double getDouble(int attributeIndex) const
virtual LONG_INT getLong(int attributeIndex) const
virtual int getInt(int attributeIndex) const
virtual short getShort(int attributeIndex) const
Manages the geometry and topology of one or more multi-level triangular tessellations of a unit spher...
Definition: GeoTessGrid.h:167
const double * getVertex(int vertex) const
Definition: GeoTessGrid.h:630
Basic metadata information about a GeoTessModel.
int getTessellation(int layer) const
Top level class that manages the GeoTessMetaData, GeoTessGrid and GeoTessData that comprise a 3D Eart...
Definition: GeoTessModel.h:120
Relationships between vertices (2D positions in a tessellation), nodes (1D positions along a radial P...
GeoTessData * getPointData(int pointIndex)
void getPointNeighbors(set< int > &pointNeighbors, int pointIndex)
void getPointVector(int pointIndex, double *v)
int getNodeIndex(int pointIndex)
float getPointValueFloat(int pointIndex, int attributeIndex)
double getPointValue(int pointIndex, int attributeIndex)
void setPointData(int pointIndex, GeoTessData *data)
GeoTessPointMap(GeoTessPointMap &other)
const double * getPointUnitVector(int pointIndex) const
double getPointRadius(int pointIndex)
double getPointDepth(int pointIndex)
byte getPointValueByte(int pointIndex, int attributeIndex)
double getPointValueDouble(int pointIndex, int attributeIndex)
int getTessId(int pointIndex)
void setActiveRegion(GeoTessPolygon *polygon)
short getPointValueShort(int pointIndex, int attributeIndex)
int getLayerIndex(int pointIndex)
int getPointValueInt(int pointIndex, int attributeIndex)
int getVertexIndex(int pointIndex)
LONG_INT getPointValueLong(int pointIndex, int attributeIndex)
const vector< int > & getPointIndices(int pointIndex)
bool operator!=(const GeoTessPointMap &other)
string getPointLatLonString(int pointIndex)
bool operator==(const GeoTessPointMap &other)
void setPointValue(int pointIndex, int attributeIndex, T value)
int getPointIndexLast(int vertex, int layer)
bool isNaN(int pointIndex, int attributeIndex)
void setActiveRegion(const string &polygonFileName)
double getDistance3D(int pointIndex1, int pointIndex2)
int getPointIndexFirst(int vertex, int layer)
GeoTessPolygon * getPolygon()
GeoTessPointMap(GeoTessModel &m)
string toString(int pointIndex)
int getPointIndex(int vertex, int layer, int node)
GeoTessPointMap & operator=(const GeoTessPointMap &other)
An ordered list of points on the surface of a unit sphere that define a closed polygon.
Abstract class that manages the radii and data values that span a single layer associated with a sing...
virtual float getRadius(int i) const
virtual bool isNaN(int nodeIndex, int attributeIndex)
virtual void setData(int index, GeoTessData *data)
virtual GeoTessData ** getData()
virtual int getPointIndex(int nodeIndex) const
virtual double getValue(const GeoTessInterpolatorType &rInterpType, int attributeIndex, double radius, bool allowRadiusOutOfRange) const