GeoTessCPP  2.2
Software to facilitate storage and retrieval of 3D information about the Earth.
GeoTessGrid.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 GEOTESSGRID_OBJECT_H
37 #define GEOTESSGRID_OBJECT_H
38 
39 // **** _SYSTEM INCLUDES_ ******************************************************
40 
41 #include <iostream>
42 #include <string>
43 #include <fstream>
44 #include <vector>
45 #include <set>
46 #include <list>
47 #include <set>
48 #include <sstream>
49 
50 // use standard library objects
51 using namespace std;
52 
53 // **** _LOCAL INCLUDES_ *******************************************************
54 
55 #include "CPPUtils.h"
56 #include "GeoTessUtils.h"
57 #include "ArrayReuse.h"
58 #include "GeoTessException.h"
60 
61 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
62 
63 namespace geotess
64 {
65 
66 // **** _FORWARD REFERENCES_ ***************************************************
67 
68 class IFStreamAscii;
69 class IFStreamBinary;
70 
71 // **** _CLASS DEFINITION_ *****************************************************
72 
101 struct Edge
102 {
106  int vj;
107 
111  int vk;
112 
113  int cornerj;
114 
118  int tLeft;
119 
123  int tRight;
124 
128  double normal[3]; //
129 
134  Edge* next; //
135 };
136 
167 {
168 protected:
169 
177  double** vertices;
178 
183 
189  int** triangles;
190 
195 
207  int** levels;
208 
212  int nLevels;
213 
228 
233 
239  void initialize();
240 
244  GeoTessGrid(const string& gid) :
245  vertices(NULL), nVertices(0),
246  triangles(NULL), nTriangles(0),
247  levels(NULL), nLevels(0),
248  tessellations(NULL), nTessellations(0),
249  descendants(NULL), gridID(gid),
250  gridInputFile("null"), gridOutputFile("null"), gridSoftwareVersion(""),
251  gridGenerationDate(""), refCount(0)
252  {
253  }
254 
255 private:
256 
264  int* descendants;
265 
283  vector<vector<Edge*> > edgeList;
284 
297  mutable vector<vector<Edge*> > spokeList;
298 
305  mutable vector<double*> circumCenters;
306 
315  string gridID;
316 
320  string gridInputFile;
321 
325  string gridOutputFile;
326 
330  string gridSoftwareVersion;
331 
336  string gridGenerationDate;
337 
341  int refCount;
342 
347  vector< vector< vector<int> > > vtxTriangles;
348 
354  mutable vector< set<int> > connectedVertices;
355 
359  GeoTessGrid* loadGridAscii(const string& inputFile);
360 
365  GeoTessGrid* loadGridAscii(IFStreamAscii& input);
366 
370  GeoTessGrid* loadGridBinary(const string& inputFile);
371 
375  virtual GeoTessGrid* loadGridBinary(IFStreamBinary& ifs);
376 
377  static void loadGridAsciiFront(IFStreamAscii& input, int& gridFileFormat,
378  string& gridSWVersion, string& fileCreationDate,
379  string& gridid, const string& grdInptFile);
380 
381  static void loadGridBinaryFront(IFStreamBinary& ifs, int& gridFileFormat,
382  string& gridSWVersion, string& fileCreationDate,
383  string& gridid, const string& grdInptFile);
384 
399  const set<int>& getVertexIndices(const int& level);
400 
401  void computeSpokeLists(const int& level) const;
402 
403 public:
404 
411  vertices(NULL), nVertices(0),
412  triangles(NULL), nTriangles(0),
413  levels(NULL), nLevels(0),
414  tessellations(NULL), nTessellations(0),
415  descendants(NULL), gridID(""),
416  gridInputFile("null"), gridOutputFile("null"), gridSoftwareVersion(""),
417  gridGenerationDate(""), refCount(0)
418  { }
419 
424  vertices(NULL), triangles(NULL), levels(NULL), tessellations(NULL),
425  descendants(NULL), gridID(""),
426  gridInputFile("null"), gridOutputFile("null"), gridSoftwareVersion(""),
427  gridGenerationDate(""), refCount(0)
428  { loadGridAscii(input); }
429 
434  vertices(NULL), triangles(NULL), levels(NULL), tessellations(NULL),
435  descendants(NULL), gridID(""),
436  gridInputFile("null"), gridOutputFile("null"), gridSoftwareVersion(""),
437  gridGenerationDate(""), refCount(0)
438  { loadGridBinary(input); }
439 
444  GeoTessGrid(GeoTessGrid &other);
445 
451  GeoTessGrid& operator= (const GeoTessGrid& other);
452 
458  {
459  LONG_INT memory = (LONG_INT)sizeof(GeoTessGrid);
460 
461  // double** vertices
462  memory += nVertices * (LONG_INT)sizeof(double*) + nVertices * 3 * (LONG_INT)sizeof(double);
463 
464  // int** triangles
465  memory += nTriangles * (LONG_INT)sizeof(int*) + nTriangles * 3 * (LONG_INT)sizeof(int);
466 
467  // int** levels
468  memory += nLevels * (LONG_INT)sizeof(int*) + nLevels * 2 * (LONG_INT)sizeof(int);
469 
470  // int** tessellations
471  memory += nTessellations * (LONG_INT)sizeof(int*) + nTessellations * 2 * (LONG_INT)sizeof(int);
472 
473  // int* descendants
474  memory += nTriangles * (LONG_INT)sizeof(int);
475 
476  // vector<vector<Edge*> > edgeList : nTriangles x 3 array of Edges
477  memory += (LONG_INT) (edgeList.capacity() * sizeof(vector<Edge*>)
478  + edgeList.size() * 3 * (sizeof(Edge*) + sizeof(Edge)));
479 
480  // vector<vector<Edge*> > spokeList;
481  memory += (LONG_INT) (spokeList.capacity() * sizeof(vector<Edge*>)
482  + spokeList.size() * 3 * sizeof(Edge*));
483 
484  // vector<double*> circumCenters is nTriangles x 3 array of doubles
485  memory += (LONG_INT) (circumCenters.capacity() * sizeof(double*));
486  for (int i=0; i<(int)circumCenters.size(); ++i)
487  if (circumCenters[i]) memory += 3 * (LONG_INT)sizeof(double);
488 
489  // An nLevels x nVertices x n array that stores the indices of the n
490  // triangles of which each vertex is a member.
491  // vector< vector< vector<int> > > vtxTriangles;
492  memory += (LONG_INT) (vtxTriangles.capacity() * sizeof(vector< vector<int> >));
493  for (int i=0; i<(int)vtxTriangles.size(); ++i)
494  {
495  memory += (LONG_INT) (vtxTriangles[i].capacity() * sizeof(vector<int>));
496  for (int j=0; j<(int)vtxTriangles[i].size(); ++j)
497  memory += (LONG_INT) (vtxTriangles[i][j].capacity() * sizeof(int));
498  }
499 
500  // An nLevels x n array that stores the indexes of the n vertices
501  // that are connected together by triangles on the corresponding
502  // level. Lazy evaluation is used to construct this array of sets.
503  // vector< set<int> > connectedVertices;
504  memory += (LONG_INT) (connectedVertices.capacity() * sizeof(set<int>));
505  for (int i=0; i<(int)connectedVertices.size(); ++i)
506  memory += (LONG_INT) (connectedVertices[i].size() * sizeof(int));
507 
508  // add memory requirements for all the string variables.
509  memory += (LONG_INT) (gridID.length() + gridInputFile.length() + gridOutputFile.length()
510  + gridSoftwareVersion.length() + gridGenerationDate.length());
511 
512  return memory;
513  }
514 
520  GeoTessGrid* loadGrid(const string& inputFile);
521 
528  static string getGridID(const string& fileName);
529 
536  static bool isGeoTessGrid(const string& inputFile);
537 
543  bool operator == (const GeoTessGrid& g) const
544  { return (gridID == g.gridID); }
545 
551  bool operator != (const GeoTessGrid& g) const
552  { return !(*this == g); }
553 
564  const string& getGridID() const
565  {
566  return gridID;
567  }
568 
575  void setGridSoftwareVersion(const string& swVersion) {gridSoftwareVersion = swVersion; };
576 
583  const string& getGridSoftwareVersion() const {return gridSoftwareVersion; };
584 
591  void setGridGenerationDate(const string& gridDate) {gridGenerationDate = gridDate; };
592 
599  const string& getGridGenerationDate() const {return gridGenerationDate; };
600 
605  void setGridInputFile(const string& gridFile) { gridInputFile = gridFile; }
606 
614  const string& getGridInputFile() const {return gridInputFile; }
615 
623  const string& getGridOutputFile() const { return gridOutputFile; }
624 
630  const double* getVertex(int vertex) const
631  {
632  return vertices[vertex];
633  }
634 
643  int findClosestVertex(double* unit_vector, int tessId)
644  {
645  int* t = triangles[getTriangle(getFirstTriangle(tessId, 0), unit_vector)];
646 
647  int index = 0;
648  double dot = GeoTessUtils::dot(unit_vector, vertices[t[0]]);
649 
650  double doti = GeoTessUtils::dot(unit_vector, vertices[t[1]]);
651  if (doti > dot)
652  {
653  index = 1;
654  dot = doti;
655  }
656 
657  doti = GeoTessUtils::dot(unit_vector, vertices[t[2]]);
658  if (doti > dot)
659  {
660  index = 2;
661  dot = doti;
662  }
663 
664  return t[index];
665  }
666 
675  int getVertexIndex(int triangle, int corner) const
676  { return triangles[triangle][corner]; }
677 
693  int getVertexIndex(int tessId, int level, int triangle, int corner) const
694  {
695  return triangles[levels[tessellations[tessId][0] + level][0] + triangle][corner];
696  }
697 
704  int getVertexIndex(const double* u)
705  {
706  for (int i=nTessellations-1; i>=0; --i)
707  {
708  int vid = getVertexIndex(u, i);
709  if (vid >= 0)
710  return vid;
711  }
712  return -1;
713  }
714 
723  int getVertexIndex(const double* u, int tessId)
724  {
725  int* t = triangles[getTriangle(getFirstTriangle(tessId, 0), u)];
726 
727  if (GeoTessUtils::dot(u, vertices[t[0]]) > cos(1e-7))
728  return t[0];
729  if (GeoTessUtils::dot(u, vertices[t[1]]) > cos(1e-7))
730  return t[1];
731  if (GeoTessUtils::dot(u, vertices[t[2]]) > cos(1e-7))
732  return t[2];
733  return -1;
734  }
735 
747  double* getVertex(int tessId, int level, int triangle, int corner)
748  {
749  return vertices[triangles[levels[tessellations[tessId][0] + level][0] + triangle][corner]];
750  }
751 
761  double const* const* getVertices() const { return vertices; }
762 
771  void getVerticesTopLevel(const int& tessellation, set<const double*>& vectors)
772  {
773  getVertices(tessellation, getNLevels(tessellation)-1, vectors);
774  }
775 
785  void getVertices(const int& tessellation, const int& level, set<const double*>& vectors);
786 
799  const set<int>& getVertexIndices(const int& tessId, const int& level)
800  { return getVertexIndices(getLevel(tessId, level)); }
801 
813  const set<int>& getVertexIndicesTopLevel(const int& tessId)
814  { return getVertexIndices(tessellations[tessId][1] - 1); }
815 
820  int getNVertices() const { return nVertices; }
821 
826  int getNTessellations() const { return nTessellations; }
827 
835  int getNLevels(int tessellation) const
836  { return tessellations[tessellation][1] - tessellations[tessellation][0]; }
837 
846  int getLevel(int tessellation, int i) const
847  { return tessellations[tessellation][0] + i; }
848 
864  int getLastLevel(int tessellation) const
865  { return tessellations[tessellation][1] - 1; }
866 
881  int getTopLevel(int tessellation) const
882  { return tessellations[tessellation][1] - tessellations[tessellation][0] - 1; }
883 
893  int getNTriangles(int tessellation, int level) const
894  {
895  return levels[tessellations[tessellation][0] + level][1]
896  - levels[tessellations[tessellation][0] + level][0];
897  }
898 
910  int getTriangle(int tessellation, int level, int i) const
911  { return levels[tessellations[tessellation][0] + level][0] + i; }
912 
922  int getFirstTriangle(int tessellation, int level) const
923  { return levels[tessellations[tessellation][0] + level][0]; }
924 
934  int getLastTriangle(int tessellation, int level) const
935  { return levels[tessellations[tessellation][0] + level][1]-1; }
936 
946  int const* const* getTriangles() const { return triangles; }
947 
959  const int* getTriangleVertexIndexes(int triangleIndex) const
960  { return triangles[triangleIndex]; }
961 
973  int getTriangleVertexIndex(int triangleIndex, int cornerIndex) const
974  { return triangles[triangleIndex][cornerIndex]; }
975 
987  const double* getTriangleVertex(int triangleIndex, int cornerIndex) const
988  { return vertices[triangles[triangleIndex][cornerIndex]]; }
989 
990 
999  void getTriangleVertices(int triangle, double** triVrt)
1000  {
1001  int* corners = triangles[triangle];
1002  triVrt[0][0] = vertices[corners[0]][0];
1003  triVrt[0][1] = vertices[corners[0]][1];
1004  triVrt[0][2] = vertices[corners[0]][2];
1005  triVrt[1][0] = vertices[corners[1]][0];
1006  triVrt[1][1] = vertices[corners[1]][1];
1007  triVrt[1][2] = vertices[corners[1]][2];
1008  triVrt[2][0] = vertices[corners[2]][0];
1009  triVrt[2][1] = vertices[corners[2]][1];
1010  triVrt[2][2] = vertices[corners[2]][2];
1011  }
1012 
1018  {
1019  if (circumCenters.empty()) circumCenters.resize(nTriangles, NULL);
1020 
1021  for (int triangle=0; triangle<nTriangles; ++triangle)
1022  if (circumCenters[triangle] == NULL)
1023  {
1024  int* corners = triangles[triangle];
1025  circumCenters[triangle] = GeoTessUtils::circumCenterPlus(vertices[corners[0]],
1026  vertices[corners[1]], vertices[corners[2]]);
1027  }
1028  }
1029 
1034  const void computeCircumCenters(const int& level)
1035  {
1036  if (circumCenters.empty()) circumCenters.resize(nTriangles);
1037 
1038  if (circumCenters[levels[level][0]] == NULL)
1039  {
1040  for (int triangle=levels[level][0]; triangle<levels[level][1]; ++triangle)
1041  {
1042  int* corners = triangles[triangle];
1043  circumCenters[triangle] = GeoTessUtils::circumCenterPlus(vertices[corners[0]],
1044  vertices[corners[1]], vertices[corners[2]]);
1045  }
1046  }
1047  }
1048 
1064  const double* getCircumCenter(const int& triangle) const { return circumCenters[triangle]; }
1065 
1083  void getCircumCenter(const int& triangle, double* cc) const
1084  { cc[0]=circumCenters[triangle][0]; cc[1]=circumCenters[triangle][1]; cc[2]=circumCenters[triangle][2]; }
1085 
1100  int getNeighbor(const int& triangleIndex, const int& neighborIndex) const
1101  { return neighborIndex == 3 ? descendants[triangleIndex] : edgeList[triangleIndex][neighborIndex]->tLeft; }
1102 
1127  int getNeighbor(const int& tessellation, const int& level, const int& triangle, const int& side)
1128  { return getNeighbor(getTriangle(tessellation, level, triangle), side); }
1129 
1144  void getNeighbors(int triangleIndex, vector<int>& neighbors)
1145  {
1146  neighbors.clear();
1147  vector<Edge*> edges = edgeList[triangleIndex];
1148  neighbors.push_back(edges[0]->tLeft);
1149  neighbors.push_back(edges[1]->tLeft);
1150  neighbors.push_back(edges[2]->tLeft);
1151  neighbors.push_back(descendants[triangleIndex]);
1152  }
1153 
1176  void getNeighbors(const int& tessellation, const int& level, const int& triangle, vector<int>& neighbors)
1177  { getNeighbors(getTriangle(tessellation, level, triangle), neighbors); }
1178 
1192  int getNeighborIndex(const int& tid, const int& nid)
1193  {
1194  if (edgeList[tid][0]->tLeft == nid)
1195  return 0;
1196  if (edgeList[tid][1]->tLeft == nid)
1197  return 1;
1198  if (edgeList[tid][2]->tLeft == nid)
1199  return 2;
1200  return -1;
1201  }
1202 
1203  int const* getDescendants() const { return descendants; }
1204 
1205  int getDescendant(const int& triangle) const { return descendants[triangle]; }
1206 
1207  int getDescendant(const int& tessId, const int& level, const int& triangle) const
1208  { return descendants[getTriangle(tessId, level, triangle)]; }
1209 
1213  string toString();
1214 
1222  int getTriangle(int triangleIndex, const double* vector);
1223 
1231  const vector<vector<int> >& getVertexTriangles(const int& level) const { return vtxTriangles[level]; }
1232 
1245  const vector<int>& getVertexTriangles(const int& tessId, const int& level, const int& vertex) const
1246  { return vtxTriangles[tessellations[tessId][0] + level][vertex]; }
1247 
1261  const vector<int>& getVertexTriangles(int tessId, int vertex) const
1262  { return getVertexTriangles(tessId, getNLevels(tessId)-1, vertex); }
1263 
1270  //void clearVertexTriangles();
1271 
1281  void getVertexNeighborsOrdered(const int& tessId, const int& level, const int& vertex, vector<int>& v);
1282 
1294  void getVertexNeighbors(const int& tessId, const int& level, const int& vertex, set<int>& nbrs)
1295  { getVertexNeighbors(tessId, level, vertex, 1, nbrs); }
1296 
1314  void getVertexNeighbors(const int& tessId, const int& level, const int& vertex,
1315  const int& order, set<int>& nbrs);
1316 
1317  // All methods below this point are public but are not documented in the doxygen documentation.
1318  // These are methods that typical applications will never need to call. They have to be
1319  // public because other classes in the GeoTess namespace need to access them.
1320  //
1322 
1328  GeoTessGrid(const GeoTessOptimizationType* opttype) :
1329  vertices(NULL), nVertices(0),
1330  triangles(NULL), nTriangles(0),
1331  levels(NULL), nLevels(0),
1332  tessellations(NULL), nTessellations(0),
1333  descendants(NULL), gridID(""),
1334  gridInputFile("null"), gridOutputFile("null"), gridSoftwareVersion(""),
1335  gridGenerationDate(""), refCount(0)
1336  { }
1337 
1342  GeoTessGrid(IFStreamAscii& input, const GeoTessOptimizationType* opttype) :
1343  vertices(NULL), triangles(NULL), levels(NULL), tessellations(NULL),
1344  descendants(NULL), gridID(""),
1345  gridInputFile("null"), gridOutputFile("null"), gridSoftwareVersion(""),
1346  gridGenerationDate(""), refCount(0)
1347  { loadGridAscii(input); }
1348 
1353  GeoTessGrid(IFStreamBinary& input, const GeoTessOptimizationType* opttype) :
1354  vertices(NULL), triangles(NULL), levels(NULL), tessellations(NULL),
1355  descendants(NULL), gridID(""),
1356  gridInputFile("null"), gridOutputFile("null"), gridSoftwareVersion(""),
1357  gridGenerationDate(""), refCount(0)
1358  { loadGridBinary(input); }
1359 
1364  GeoTessGrid(double** _vertices, int& _nVertices,
1365  int** _triangles, int& _nTriangles,
1366  int** _levels, int& _nLevels,
1367  int** _tessellations, int& _nTessellations,
1368  string& _gridID,
1369  string& _gridInputFile,
1370  string& _gridOutputFile,
1371  string& _gridSoftwareVersion,
1372  string& _gridGenerationDate) :
1373  vertices(_vertices), nVertices(_nVertices),
1374  triangles(_triangles), nTriangles(_nTriangles),
1375  levels(_levels), nLevels(_nLevels),
1376  tessellations(_tessellations), nTessellations(_nTessellations),
1377  descendants(NULL),
1378  gridID(_gridID),
1379  gridInputFile(_gridInputFile),
1380  gridOutputFile(_gridOutputFile),
1381  gridSoftwareVersion(_gridSoftwareVersion),
1382  gridGenerationDate(_gridGenerationDate),
1383  refCount(0)
1384  { initialize(); }
1385 
1389  virtual ~GeoTessGrid();
1390 
1394  int getReferenceCount() { return refCount; }
1395 
1399  void addReference() { ++refCount; }
1400 
1404  void removeReference()
1405  {
1406  if (isNotReferenced())
1407  {
1408  ostringstream os;
1409  os << endl << "ERROR in GeoTessGrid::removeReference" << endl
1410  << "Reference count (" << refCount << ") is already zero." << endl;
1411  throw GeoTessException(os, __FILE__, __LINE__, 2001);
1412  }
1413 
1414  --refCount;
1415  }
1416 
1420  bool isNotReferenced() { return (refCount == 0); }
1421 
1427  void writeGrid(const string& fileName);
1428 
1432  void writeGridAscii(const string& fileName);
1433 
1437  void writeGridAscii(IFStreamAscii& output);
1438 
1442  void writeGridBinary(const string& fileName);
1443 
1447  void writeGridBinary(IFStreamBinary& output);
1448 
1454  bool isSupportedFormatVersion(int frmtVrsn)
1455  { return (frmtVrsn == 2); }
1456 
1457  // deprecated. GeoTessOptimizationType is no longer used. Always optimized for speed.
1458  const GeoTessOptimizationType& getOptimizationType() const { return GeoTessOptimizationType::SPEED; }
1459 
1461 
1470  void testGrid();
1471 
1477  int getNLevels() const { return nLevels; }
1478 
1490  int const* const* getLevels() const { return levels; }
1491 
1506  int const* const* getTessellations() const { return tessellations; }
1507 
1515  int getNTriangles() const { return nTriangles; }
1516 
1517  vector<Edge*>& getSpokeList(const int& level) const
1518  { computeSpokeLists(level); return spokeList[level]; }
1519 
1520  const vector<vector<Edge*> >& getEdgeList() const { return edgeList; }
1521 
1522  const vector<Edge*>& getEdgeList(const int& triangle) const { return edgeList[triangle]; }
1523 
1530  void getCenter(const int& triangle, double* center)
1531  {
1532  vector<double*> corners;
1533  corners.push_back(vertices[triangles[triangle][0]]);
1534  corners.push_back(vertices[triangles[triangle][1]]);
1535  corners.push_back(vertices[triangles[triangle][2]]);
1536  GeoTessUtils::center(corners, center);
1537  }
1538 
1544  int delaunay();
1545 
1546 };
1547 // end class GeoTessGrid
1548 
1549 }// end namespace geotess
1550 
1551 #endif // GEOTESSGRID_OBJECT_H
const string & getGridID() const
A String ID that uniquely identifies this GeoTessGrid.
Definition: GeoTessGrid.h:564
void getVertexNeighbors(const int &tessId, const int &level, const int &vertex, set< int > &nbrs)
Retrieve a list of the indexes of all the vertexes that are connected to the specified vertex by a si...
Definition: GeoTessGrid.h:1294
void getCircumCenter(const int &triangle, double *cc) const
Copy the circumCenter of the specified triangle.
Definition: GeoTessGrid.h:1083
int getNLevels(int tessellation) const
Retrieve number of tessellation levels that define the specified multi-level tessellation of the mode...
Definition: GeoTessGrid.h:835
int tLeft
lndex of triangle to the left of edge from vj to vk
Definition: GeoTessGrid.h:118
const string & getGridGenerationDate() const
Retrieve the date when the contents of this grid was generated.
Definition: GeoTessGrid.h:599
GeoTessGrid(const string &gid)
Standard constructor.
Definition: GeoTessGrid.h:244
int getLevel(int tessellation, int i) const
Retrieve the index of one of the levels on the specified tessellation.
Definition: GeoTessGrid.h:846
const vector< Edge * > & getEdgeList(const int &triangle) const
Definition: GeoTessGrid.h:1522
const double * getVertex(int vertex) const
Retrieve the unit vector that corresponds to the specified vertex.
Definition: GeoTessGrid.h:630
vector< Edge * > & getSpokeList(const int &level) const
Definition: GeoTessGrid.h:1517
int getVertexIndex(const double *u)
Retrieve the index of the vertex that is colocated with the supplied unit vector. ...
Definition: GeoTessGrid.h:704
double ** vertices
An nVertices x 3 array of tessellation vertices.
Definition: GeoTessGrid.h:177
Definition: ArrayReuse.h:55
int const * getDescendants() const
Definition: GeoTessGrid.h:1203
int ** triangles
An nTriangles x 3 array of integers.
Definition: GeoTessGrid.h:189
Opens a file for binary read and write access.
Definition: IFStreamBinary.h:79
GeoTessGrid()
Default constructor.
Definition: GeoTessGrid.h:410
int vj
vertex index j
Definition: GeoTessGrid.h:106
int vk
vertex index k
Definition: GeoTessGrid.h:111
const vector< int > & getVertexTriangles(int tessId, int vertex) const
Retrieve a list of the triangles a particular vertex is a member of, considering only triangles in th...
Definition: GeoTessGrid.h:1261
const string & getGridInputFile() const
Retrieve the name of the file from which the grid was loaded.
Definition: GeoTessGrid.h:614
Manages the geometry and topology of one or more multi-level triangular tessellations of a unit spher...
Definition: GeoTessGrid.h:166
const vector< int > & getVertexTriangles(const int &tessId, const int &level, const int &vertex) const
Retrieve a list of the triangles a particular vertex is a member of, considering only triangles in th...
Definition: GeoTessGrid.h:1245
int getNVertices() const
Returns the number of vertices in the vectices array.
Definition: GeoTessGrid.h:820
const vector< vector< int > > & getVertexTriangles(const int &level) const
Retrieve a list of the triangles a particular vertex is a member of, considering only triangles in th...
Definition: GeoTessGrid.h:1231
int getNeighbor(const int &triangleIndex, const int &neighborIndex) const
Retrieve the index of one of the triangles that is a neighbor of the specified triangle.
Definition: GeoTessGrid.h:1100
void getVerticesTopLevel(const int &tessellation, set< const double * > &vectors)
Retrieve a set containing the unit vectors of all the vertices that are connected together by triangl...
Definition: GeoTessGrid.h:771
int getFirstTriangle(int tessellation, int level) const
Retrieve the index of the first triangle on the specified level of the specified tessellation of the ...
Definition: GeoTessGrid.h:922
GeoTessGrid(IFStreamAscii &input)
Standard constructor.
Definition: GeoTessGrid.h:423
int ** tessellations
tessellations is a n x 2 int array where n is the number of tessellations in the topology of the mode...
Definition: GeoTessGrid.h:227
void setGridGenerationDate(const string &gridDate)
Set the date when this grid was generated.
Definition: GeoTessGrid.h:591
int getNeighbor(const int &tessellation, const int &level, const int &triangle, const int &side)
Retrieve the index of the triangle that is the i'th neighbor of the specified triangle.
Definition: GeoTessGrid.h:1127
LONG_INT getMemory()
Retrieve the amount of memory required by this GeoTessGrid object in bytes.
Definition: GeoTessGrid.h:457
double const *const * getVertices() const
Retrieve a reference to all of the vertices.
Definition: GeoTessGrid.h:761
const string & getGridOutputFile() const
Retrieve the name of the file to which this grid was most recently written, or the string "null" if i...
Definition: GeoTessGrid.h:623
void setGridSoftwareVersion(const string &swVersion)
Set the name and version number of the software that generated the contents of this grid...
Definition: GeoTessGrid.h:575
int getNTessellations() const
Returns the number of tessellations in the tessellations array.
Definition: GeoTessGrid.h:826
int nLevels
Number of levels.
Definition: GeoTessGrid.h:212
int getVertexIndex(const double *u, int tessId)
Retrieve the index of the vertex that is colocated with the supplied unit vector. ...
Definition: GeoTessGrid.h:723
int const *const * getTessellations() const
Retrieve a reference to all of the tessellations of this grid.
Definition: GeoTessGrid.h:1506
Enumeration of the optimization strategies supported by GeoTess including OptimizationType::SPEED and...
Definition: GeoTessOptimizationType.h:66
int getVertexIndex(int triangle, int corner) const
Get the index of the vertex that occupies the specified position in the hierarchy.
Definition: GeoTessGrid.h:675
int nTessellations
Number of tessellations.
Definition: GeoTessGrid.h:232
void setGridInputFile(const string &gridFile)
Set the grid input file name.
Definition: GeoTessGrid.h:605
Opens ascii file for read and write access.
Definition: IFStreamAscii.h:80
const vector< vector< Edge * > > & getEdgeList() const
Definition: GeoTessGrid.h:1520
const double * getCircumCenter(const int &triangle) const
Retrieve the circumCenter of the specified triangle.
Definition: GeoTessGrid.h:1064
int getLastTriangle(int tessellation, int level) const
Retrieve the index of the last triangle on the specified level of the specified tessellation of the m...
Definition: GeoTessGrid.h:934
int getVertexIndex(int tessId, int level, int triangle, int corner) const
Get the index of the vertex that occupies the specified position in the hierarchy.
Definition: GeoTessGrid.h:693
const int * getTriangleVertexIndexes(int triangleIndex) const
Retrieve an int[3] array containing the indexes of the vertices that form the corners of the triangle...
Definition: GeoTessGrid.h:959
int nTriangles
Number of triangles.
Definition: GeoTessGrid.h:194
int cornerj
Definition: GeoTessGrid.h:113
#define LONG_INT
Definition: CPPGlobals.h:111
GeoTessGrid(IFStreamBinary &input)
Standard constructor.
Definition: GeoTessGrid.h:433
int const *const * getTriangles() const
Retrieve a reference to the nTriangles x 3 array of int that specifies the indexes of the 3 vertices ...
Definition: GeoTessGrid.h:946
int const *const * getLevels() const
Retrieve a reference to all of the tessellation levels.
Definition: GeoTessGrid.h:1490
int getLastLevel(int tessellation) const
Retrieve the index of the last level on the specified tessellation, relative to all levels in all tes...
Definition: GeoTessGrid.h:864
int getTriangleVertexIndex(int triangleIndex, int cornerIndex) const
Retrieve the index of the i'th vertex (0..2) that represents one of the corners of the specified tria...
Definition: GeoTessGrid.h:973
int nVertices
Number of vertices.
Definition: GeoTessGrid.h:182
Stores information about the connection between two adjacent vertices which separates two neighboring...
Definition: GeoTessGrid.h:101
int getTriangle(int tessellation, int level, int i) const
Retrieve the index of the i'th triangle on the specified level of the specified tessellation of the m...
Definition: GeoTessGrid.h:910
int ** levels
An n x 2 array where n is the number of tessellation levels in all the tessellations that constitute ...
Definition: GeoTessGrid.h:207
int getNLevels() const
Returns the number of tessellation levels defined for this grid.
Definition: GeoTessGrid.h:1477
int getNeighborIndex(const int &tid, const int &nid)
If triangle with index tid has a neighbor with index nid, then return the index of neighbor in triang...
Definition: GeoTessGrid.h:1192
Edge * next
pointer to next edge in circular list of edges emanating from vertex vj.
Definition: GeoTessGrid.h:134
const set< int > & getVertexIndicesTopLevel(const int &tessId)
Retrieve a set containing the indices of all the vertices that are connected together by triangles on...
Definition: GeoTessGrid.h:813
const string & getGridSoftwareVersion() const
Get the name and version number of the software that generated the contents of this grid...
Definition: GeoTessGrid.h:583
int tRight
index of triangle to the right of edge from vj to vk
Definition: GeoTessGrid.h:123
void getCenter(const int &triangle, double *center)
Compute the unit vector that resides at the center of the specified triangle.
Definition: GeoTessGrid.h:1530
void getTriangleVertices(int triangle, double **triVrt)
Get the 3 vertices that form the corners of the specified triangle, in clockwise order.
Definition: GeoTessGrid.h:999
void getNeighbors(const int &tessellation, const int &level, const int &triangle, vector< int > &neighbors)
Retrieve the indexes of the triangles that are neighbors of the specified triangle.
Definition: GeoTessGrid.h:1176
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:71
const set< int > & getVertexIndices(const int &tessId, const int &level)
Retrieve a set containing the indices of all the vertices that are connected together by triangles on...
Definition: GeoTessGrid.h:799
const double * getTriangleVertex(int triangleIndex, int cornerIndex) const
Retrieve the unit vector of the vertex located at one of the corners of the specified triangle...
Definition: GeoTessGrid.h:987
int getNTriangles() const
Retrieve the total number of triangles including those on all levels of all tessellations.
Definition: GeoTessGrid.h:1515
double * getVertex(int tessId, int level, int triangle, int corner)
Get the unit vector of the vertex that occupies the specified position in the hierarchy.
Definition: GeoTessGrid.h:747
int getDescendant(const int &tessId, const int &level, const int &triangle) const
Definition: GeoTessGrid.h:1207
const void computeCircumCenters(const int &level)
Compute the circumcenters of all triangles on the specified level if they have not already been compu...
Definition: GeoTessGrid.h:1034
int getTopLevel(int tessellation) const
Retrieve the index of the last level on the specified tessellation, relative to first level of the sp...
Definition: GeoTessGrid.h:881
int findClosestVertex(double *unit_vector, int tessId)
Retrieve the index of the vertex that is closest to the supplied unit vector.
Definition: GeoTessGrid.h:643
void getNeighbors(int triangleIndex, vector< int > &neighbors)
Retrieve the indexes of the triangles that are neighbors of the specified triangle.
Definition: GeoTessGrid.h:1144
int getDescendant(const int &triangle) const
Definition: GeoTessGrid.h:1205
int getNTriangles(int tessellation, int level) const
Retrieve the number of triangles that define the specified level of the specified multi-level tessell...
Definition: GeoTessGrid.h:893
const void computeCircumCenters()
Compute the circumcenters of all triangles if they have not already been computed.
Definition: GeoTessGrid.h:1017