GeoTessCPP: rstt/GeoTessCPP/include/GeoTessGrid.h Source File

GeoTessCPP 2.2.3 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 National Technology & Engineering Solutions of Sandia, LLC
4 //- (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S.
5 //- Government 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 //- 1. Redistributions of source code must retain the above copyright notice,
14 //- this list of conditions and the following disclaimer.
15 //-
16 //- 2. Redistributions in binary form must reproduce the above copyright
17 //- notice, this list of conditions and the following disclaimer in the
18 //- documentation and/or other materials provided with the distribution.
19 //-
20 //- 3. Neither the name of the copyright holder nor the names of its
21 //- contributors may be used to endorse or promote products derived from
22 //- this software without specific prior written permission.
23 //-
24 //- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 //- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 //- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 //- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
28 //- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 //- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 //- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 //- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 //- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 //- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 //- POSSIBILITY OF SUCH DAMAGE.
35 //-
36 //- ****************************************************************************
37
38 #ifndef GEOTESSGRID_OBJECT_H
39 #define GEOTESSGRID_OBJECT_H
40
41 // **** _SYSTEM INCLUDES_ ******************************************************
42
43 #include <iostream>
44 #include <string>
45 #include <fstream>
46 #include <vector>
47 #include <set>
48 #include <list>
49 #include <set>
50 #include <sstream>
51
52 // use standard library objects
53 using namespace std;
54
55 // **** _LOCAL INCLUDES_ *******************************************************
56
57 #include "CPPUtils.h"
58 #include "GeoTessUtils.h"
59 #include "ArrayReuse.h"
60 #include "GeoTessException.h"
61 #include "GeoTessOptimizationType.h"
62
63 // **** _BEGIN GEOTESS NAMESPACE_ **********************************************
64
65 namespace geotess
66 {
67
68 // **** _FORWARD REFERENCES_ ***************************************************
69
70 class IFStreamAscii;
71 class IFStreamBinary;
72
73 // **** _CLASS DEFINITION_ *****************************************************
74
103 struct Edge
104 {
108 int vj;
109
113 int vk;
114
115 int cornerj;
116
120 int tLeft;
121
125 int tRight;
126
130 double normal[3]; //
131
136 Edge* next; //
137 };
138
168 class GEOTESS_EXP_IMP GeoTessGrid
169 {
170 protected:
171
179 double** vertices;
180
184 int nVertices;
185
191 int** triangles;
192
196 int nTriangles;
197
209 int** levels;
210
214 int nLevels;
215
229 int** tessellations;
230
234 int nTessellations;
235
241 void initialize();
242
246 GeoTessGrid(const string& gid) :
247 vertices(NULL), nVertices(0),
248 triangles(NULL), nTriangles(0),
249 levels(NULL), nLevels(0),
250 tessellations(NULL), nTessellations(0),
251 descendants(NULL), gridID(gid),
252 gridInputFile("null"), gridOutputFile("null"), gridSoftwareVersion(""),
253 gridGenerationDate(""), refCount(0)
254 {
255 }
256
257 private:
258
266 int* descendants;
267
285 vector<vector<Edge*> > edgeList;
286
299 mutable vector<vector<Edge*> > spokeList;
300
307 mutable vector<double*> circumCenters;
308
317 string gridID;
318
322 string gridInputFile;
323
327 string gridOutputFile;
328
332 string gridSoftwareVersion;
333
338 string gridGenerationDate;
339
343 int refCount;
344
349 vector< vector< vector<int> > > vtxTriangles;
350
356 mutable vector< set<int> > connectedVertices;
357
361 GeoTessGrid* loadGridAscii(const string& inputFile);
362
367 GeoTessGrid* loadGridAscii(IFStreamAscii& input);
368
372 GeoTessGrid* loadGridBinary(const string& inputFile);
373
377 virtual GeoTessGrid* loadGridBinary(IFStreamBinary& ifs);
378
379 static void loadGridAsciiFront(IFStreamAscii& input, int& gridFileFormat,
380 string& gridSWVersion, string& fileCreationDate,
381 string& gridid, const string& grdInptFile);
382
383 static void loadGridBinaryFront(IFStreamBinary& ifs, int& gridFileFormat,
384 string& gridSWVersion, string& fileCreationDate,
385 string& gridid, const string& grdInptFile);
386
401 const set<int>& getVertexIndices(const int& level);
402
403 void computeSpokeLists(const int& level) const;
404
405 public:
406
412 GeoTessGrid() :
413 vertices(NULL), nVertices(0),
414 triangles(NULL), nTriangles(0),
415 levels(NULL), nLevels(0),
416 tessellations(NULL), nTessellations(0),
417 descendants(NULL), gridID(""),
418 gridInputFile("null"), gridOutputFile("null"), gridSoftwareVersion(""),
419 gridGenerationDate(""), refCount(0)
420 { }
421
425 GeoTessGrid(IFStreamAscii& input) :
426 vertices(NULL), triangles(NULL), levels(NULL), tessellations(NULL),
427 descendants(NULL), gridID(""),
428 gridInputFile("null"), gridOutputFile("null"), gridSoftwareVersion(""),
429 gridGenerationDate(""), refCount(0)
430 { loadGridAscii(input); }
431
435 GeoTessGrid(IFStreamBinary& input) :
436 vertices(NULL), triangles(NULL), levels(NULL), tessellations(NULL),
437 descendants(NULL), gridID(""),
438 gridInputFile("null"), gridOutputFile("null"), gridSoftwareVersion(""),
439 gridGenerationDate(""), refCount(0)
440 { loadGridBinary(input); }
441
446 GeoTessGrid(GeoTessGrid &other);
447
453 GeoTessGrid& operator= (const GeoTessGrid& other);
454
459 LONG_INT getMemory()
460 {
461 LONG_INT memory = (LONG_INT)sizeof(GeoTessGrid);
462
463 // double** vertices
464 memory += nVertices * (LONG_INT)sizeof(double*) + nVertices * 3 * (LONG_INT)sizeof(double);
465
466 // int** triangles
467 memory += nTriangles * (LONG_INT)sizeof(int*) + nTriangles * 3 * (LONG_INT)sizeof(int);
468
469 // int** levels
470 memory += nLevels * (LONG_INT)sizeof(int*) + nLevels * 2 * (LONG_INT)sizeof(int);
471
472 // int** tessellations
473 memory += nTessellations * (LONG_INT)sizeof(int*) + nTessellations * 2 * (LONG_INT)sizeof(int);
474
475 // int* descendants
476 memory += nTriangles * (LONG_INT)sizeof(int);
477
478 // vector<vector<Edge*> > edgeList : nTriangles x 3 array of Edges
479 memory += (LONG_INT) (edgeList.capacity() * sizeof(vector<Edge*>)
480 + edgeList.size() * 3 * (sizeof(Edge*) + sizeof(Edge)));
481
482 // vector<vector<Edge*> > spokeList;
483 memory += (LONG_INT) (spokeList.capacity() * sizeof(vector<Edge*>)
484 + spokeList.size() * 3 * sizeof(Edge*));
485
486 // vector<double*> circumCenters is nTriangles x 3 array of doubles
487 memory += (LONG_INT) (circumCenters.capacity() * sizeof(double*));
488 for (int i=0; i<(int)circumCenters.size(); ++i)
489 if (circumCenters[i]) memory += 3 * (LONG_INT)sizeof(double);
490
491 // An nLevels x nVertices x n array that stores the indices of the n
492 // triangles of which each vertex is a member.
493 // vector< vector< vector<int> > > vtxTriangles;
494 memory += (LONG_INT) (vtxTriangles.capacity() * sizeof(vector< vector<int> >));
495 for (int i=0; i<(int)vtxTriangles.size(); ++i)
496 {
497 memory += (LONG_INT) (vtxTriangles[i].capacity() * sizeof(vector<int>));
498 for (int j=0; j<(int)vtxTriangles[i].size(); ++j)
499 memory += (LONG_INT) (vtxTriangles[i][j].capacity() * sizeof(int));
500 }
501
502 // An nLevels x n array that stores the indexes of the n vertices
503 // that are connected together by triangles on the corresponding
504 // level. Lazy evaluation is used to construct this array of sets.
505 // vector< set<int> > connectedVertices;
506 memory += (LONG_INT) (connectedVertices.capacity() * sizeof(set<int>));
507 for (int i=0; i<(int)connectedVertices.size(); ++i)
508 memory += (LONG_INT) (connectedVertices[i].size() * sizeof(int));
509
510 // add memory requirements for all the string variables.
511 memory += (LONG_INT) (gridID.length() + gridInputFile.length() + gridOutputFile.length()
512 + gridSoftwareVersion.length() + gridGenerationDate.length());
513
514 return memory;
515 }
516
522 GeoTessGrid* loadGrid(const string& inputFile);
523
530 static string getGridID(const string& fileName);
531
538 static bool isGeoTessGrid(const string& inputFile);
539
545 bool operator == (const GeoTessGrid& g) const
546 { return (gridID == g.gridID); }
547
553 bool operator != (const GeoTessGrid& g) const
554 { return !(*this == g); }
555
566 const string& getGridID() const
567 {
568 return gridID;
569 }
570
577 void setGridSoftwareVersion(const string& swVersion) {gridSoftwareVersion = swVersion; };
578
585 const string& getGridSoftwareVersion() const {return gridSoftwareVersion; };
586
593 void setGridGenerationDate(const string& gridDate) {gridGenerationDate = gridDate; };
594
601 const string& getGridGenerationDate() const {return gridGenerationDate; };
602
607 void setGridInputFile(const string& gridFile) { gridInputFile = gridFile; }
608
616 const string& getGridInputFile() const {return gridInputFile; }
617
625 const string& getGridOutputFile() const { return gridOutputFile; }
626
632 const double* getVertex(int vertex) const
633 {
634 return vertices[vertex];
635 }
636
645 int findClosestVertex(double* unit_vector, int tessId)
646 {
647 int* t = triangles[getTriangle(getFirstTriangle(tessId, 0), unit_vector)];
648
649 int index = 0;
650 double dot = GeoTessUtils::dot(unit_vector, vertices[t[0]]);
651
652 double doti = GeoTessUtils::dot(unit_vector, vertices[t[1]]);
653 if (doti > dot)
654 {
655 index = 1;
656 dot = doti;
657 }
658
659 doti = GeoTessUtils::dot(unit_vector, vertices[t[2]]);
660 if (doti > dot)
661 {
662 index = 2;
663 dot = doti;
664 }
665
666 return t[index];
667 }
668
677 int getVertexIndex(int triangle, int corner) const
678 { return triangles[triangle][corner]; }
679
695 int getVertexIndex(int tessId, int level, int triangle, int corner) const
696 {
697 return triangles[levels[tessellations[tessId][0] + level][0] + triangle][corner];
698 }
699
706 int getVertexIndex(const double* u)
707 {
708 for (int i=nTessellations-1; i>=0; --i)
709 {
710 int vid = getVertexIndex(u, i);
711 if (vid >= 0)
712 return vid;
713 }
714 return -1;
715 }
716
725 int getVertexIndex(const double* u, int tessId)
726 {
727 int* t = triangles[getTriangle(getFirstTriangle(tessId, 0), u)];
728
729 if (GeoTessUtils::dot(u, vertices[t[0]]) > cos(1e-7))
730 return t[0];
731 if (GeoTessUtils::dot(u, vertices[t[1]]) > cos(1e-7))
732 return t[1];
733 if (GeoTessUtils::dot(u, vertices[t[2]]) > cos(1e-7))
734 return t[2];
735 return -1;
736 }
737
749 double* getVertex(int tessId, int level, int triangle, int corner)
750 {
751 return vertices[triangles[levels[tessellations[tessId][0] + level][0] + triangle][corner]];
752 }
753
763 double const* const* getVertices() const { return vertices; }
764
773 void getVerticesTopLevel(const int& tessellation, set<const double*>& vectors)
774 {
775 getVertices(tessellation, getNLevels(tessellation)-1, vectors);
776 }
777
787 void getVertices(const int& tessellation, const int& level, set<const double*>& vectors);
788
801 const set<int>& getVertexIndices(const int& tessId, const int& level)
802 { return getVertexIndices(getLevel(tessId, level)); }
803
815 const set<int>& getVertexIndicesTopLevel(const int& tessId)
816 { return getVertexIndices(tessellations[tessId][1] - 1); }
817
822 int getNVertices() const { return nVertices; }
823
828 int getNTessellations() const { return nTessellations; }
829
837 int getNLevels(int tessellation) const
838 { return tessellations[tessellation][1] - tessellations[tessellation][0]; }
839
848 int getLevel(int tessellation, int i) const
849 { return tessellations[tessellation][0] + i; }
850
866 int getLastLevel(int tessellation) const
867 { return tessellations[tessellation][1] - 1; }
868
883 int getTopLevel(int tessellation) const
884 { return tessellations[tessellation][1] - tessellations[tessellation][0] - 1; }
885
895 int getNTriangles(int tessellation, int level) const
896 {
897 return levels[tessellations[tessellation][0] + level][1]
898 - levels[tessellations[tessellation][0] + level][0];
899 }
900
912 int getTriangle(int tessellation, int level, int i) const
913 { return levels[tessellations[tessellation][0] + level][0] + i; }
914
924 int getFirstTriangle(int tessellation, int level) const
925 { return levels[tessellations[tessellation][0] + level][0]; }
926
936 int getLastTriangle(int tessellation, int level) const
937 { return levels[tessellations[tessellation][0] + level][1]-1; }
938
948 int const* const* getTriangles() const { return triangles; }
949
961 const int* getTriangleVertexIndexes(int triangleIndex) const
962 { return triangles[triangleIndex]; }
963
975 int getTriangleVertexIndex(int triangleIndex, int cornerIndex) const
976 { return triangles[triangleIndex][cornerIndex]; }
977
989 const double* getTriangleVertex(int triangleIndex, int cornerIndex) const
990 { return vertices[triangles[triangleIndex][cornerIndex]]; }
991
992
1001 void getTriangleVertices(int triangle, double** triVrt)
1002 {
1003 int* corners = triangles[triangle];
1004 triVrt[0][0] = vertices[corners[0]][0];
1005 triVrt[0][1] = vertices[corners[0]][1];
1006 triVrt[0][2] = vertices[corners[0]][2];
1007 triVrt[1][0] = vertices[corners[1]][0];
1008 triVrt[1][1] = vertices[corners[1]][1];
1009 triVrt[1][2] = vertices[corners[1]][2];
1010 triVrt[2][0] = vertices[corners[2]][0];
1011 triVrt[2][1] = vertices[corners[2]][1];
1012 triVrt[2][2] = vertices[corners[2]][2];
1013 }
1014
1019 const void computeCircumCenters()
1020 {
1021 if (circumCenters.empty()) circumCenters.resize(nTriangles, NULL);
1022
1023 for (int triangle=0; triangle<nTriangles; ++triangle)
1024 if (circumCenters[triangle] == NULL)
1025 {
1026 int* corners = triangles[triangle];
1027 circumCenters[triangle] = GeoTessUtils::circumCenterPlus(vertices[corners[0]],
1028 vertices[corners[1]], vertices[corners[2]]);
1029 }
1030 }
1031
1036 const void computeCircumCenters(const int& level)
1037 {
1038 if (circumCenters.empty()) circumCenters.resize(nTriangles);
1039
1040 if (circumCenters[levels[level][0]] == NULL)
1041 {
1042 for (int triangle=levels[level][0]; triangle<levels[level][1]; ++triangle)
1043 {
1044 int* corners = triangles[triangle];
1045 circumCenters[triangle] = GeoTessUtils::circumCenterPlus(vertices[corners[0]],
1046 vertices[corners[1]], vertices[corners[2]]);
1047 }
1048 }
1049 }
1050
1066 const double* getCircumCenter(const int& triangle) const { return circumCenters[triangle]; }
1067
1085 void getCircumCenter(const int& triangle, double* cc) const
1086 { cc[0]=circumCenters[triangle][0]; cc[1]=circumCenters[triangle][1]; cc[2]=circumCenters[triangle][2]; }
1087
1102 int getNeighbor(const int& triangleIndex, const int& neighborIndex) const
1103 { return neighborIndex == 3 ? descendants[triangleIndex] : edgeList[triangleIndex][neighborIndex]->tLeft; }
1104
1129 int getNeighbor(const int& tessellation, const int& level, const int& triangle, const int& side)
1130 { return getNeighbor(getTriangle(tessellation, level, triangle), side); }
1131
1146 void getNeighbors(int triangleIndex, vector<int>& neighbors)
1147 {
1148 neighbors.clear();
1149 vector<Edge*> edges = edgeList[triangleIndex];
1150 neighbors.push_back(edges[0]->tLeft);
1151 neighbors.push_back(edges[1]->tLeft);
1152 neighbors.push_back(edges[2]->tLeft);
1153 neighbors.push_back(descendants[triangleIndex]);
1154 }
1155
1178 void getNeighbors(const int& tessellation, const int& level, const int& triangle, vector<int>& neighbors)
1179 { getNeighbors(getTriangle(tessellation, level, triangle), neighbors); }
1180
1194 int getNeighborIndex(const int& tid, const int& nid)
1195 {
1196 if (edgeList[tid][0]->tLeft == nid)
1197 return 0;
1198 if (edgeList[tid][1]->tLeft == nid)
1199 return 1;
1200 if (edgeList[tid][2]->tLeft == nid)
1201 return 2;
1202 return -1;
1203 }
1204
1205 int const* getDescendants() const { return descendants; }
1206
1207 int getDescendant(const int& triangle) const { return descendants[triangle]; }
1208
1209 int getDescendant(const int& tessId, const int& level, const int& triangle) const
1210 { return descendants[getTriangle(tessId, level, triangle)]; }
1211
1215 string toString();
1216
1224 int getTriangle(int triangleIndex, const double* vector);
1225
1233 const vector<vector<int> >& getVertexTriangles(const int& level) const { return vtxTriangles[level]; }
1234
1247 const vector<int>& getVertexTriangles(const int& tessId, const int& level, const int& vertex) const
1248 { return vtxTriangles[tessellations[tessId][0] + level][vertex]; }
1249
1263 const vector<int>& getVertexTriangles(int tessId, int vertex) const
1264 { return getVertexTriangles(tessId, getNLevels(tessId)-1, vertex); }
1265
1272 //void clearVertexTriangles();
1273
1283 void getVertexNeighborsOrdered(const int& tessId, const int& level, const int& vertex, vector<int>& v);
1284
1296 void getVertexNeighbors(const int& tessId, const int& level, const int& vertex, set<int>& nbrs)
1297 { getVertexNeighbors(tessId, level, vertex, 1, nbrs); }
1298
1316 void getVertexNeighbors(const int& tessId, const int& level, const int& vertex,
1317 const int& order, set<int>& nbrs);
1318
1319 // All methods below this point are public but are not documented in the doxygen documentation.
1320 // These are methods that typical applications will never need to call. They have to be
1321 // public because other classes in the GeoTess namespace need to access them.
1322 //
1324
1330 GeoTessGrid(const GeoTessOptimizationType* opttype) :
1331 vertices(NULL), nVertices(0),
1332 triangles(NULL), nTriangles(0),
1333 levels(NULL), nLevels(0),
1334 tessellations(NULL), nTessellations(0),
1335 descendants(NULL), gridID(""),
1336 gridInputFile("null"), gridOutputFile("null"), gridSoftwareVersion(""),
1337 gridGenerationDate(""), refCount(0)
1338 { }
1339
1344 GeoTessGrid(IFStreamAscii& input, const GeoTessOptimizationType* opttype) :
1345 vertices(NULL), triangles(NULL), levels(NULL), tessellations(NULL),
1346 descendants(NULL), gridID(""),
1347 gridInputFile("null"), gridOutputFile("null"), gridSoftwareVersion(""),
1348 gridGenerationDate(""), refCount(0)
1349 { loadGridAscii(input); }
1350
1355 GeoTessGrid(IFStreamBinary& input, const GeoTessOptimizationType* opttype) :
1356 vertices(NULL), triangles(NULL), levels(NULL), tessellations(NULL),
1357 descendants(NULL), gridID(""),
1358 gridInputFile("null"), gridOutputFile("null"), gridSoftwareVersion(""),
1359 gridGenerationDate(""), refCount(0)
1360 { loadGridBinary(input); }
1361
1366 GeoTessGrid(double** _vertices, int& _nVertices,
1367 int** _triangles, int& _nTriangles,
1368 int** _levels, int& _nLevels,
1369 int** _tessellations, int& _nTessellations,
1370 string& _gridID,
1371 string& _gridInputFile,
1372 string& _gridOutputFile,
1373 string& _gridSoftwareVersion,
1374 string& _gridGenerationDate) :
1375 vertices(_vertices), nVertices(_nVertices),
1376 triangles(_triangles), nTriangles(_nTriangles),
1377 levels(_levels), nLevels(_nLevels),
1378 tessellations(_tessellations), nTessellations(_nTessellations),
1379 descendants(NULL),
1380 gridID(_gridID),
1381 gridInputFile(_gridInputFile),
1382 gridOutputFile(_gridOutputFile),
1383 gridSoftwareVersion(_gridSoftwareVersion),
1384 gridGenerationDate(_gridGenerationDate),
1385 refCount(0)
1386 { initialize(); }
1387
1391 virtual ~GeoTessGrid();
1392
1396 int getReferenceCount() { return refCount; }
1397
1401 void addReference() { ++refCount; }
1402
1406 void removeReference()
1407 {
1408 if (isNotReferenced())
1409 {
1410 ostringstream os;
1411 os << endl << "ERROR in GeoTessGrid::removeReference" << endl
1412 << "Reference count (" << refCount << ") is already zero." << endl;
1413 throw GeoTessException(os, __FILE__, __LINE__, 2001);
1414 }
1415
1416 --refCount;
1417 }
1418
1422 bool isNotReferenced() { return (refCount == 0); }
1423
1429 void writeGrid(const string& fileName);
1430
1434 void writeGridAscii(const string& fileName);
1435
1439 void writeGridAscii(IFStreamAscii& output);
1440
1444 void writeGridBinary(const string& fileName);
1445
1449 void writeGridBinary(IFStreamBinary& output);
1450
1456 bool isSupportedFormatVersion(int frmtVrsn)
1457 { return (frmtVrsn == 2); }
1458
1459 // deprecated. GeoTessOptimizationType is no longer used. Always optimized for speed.
1460 const GeoTessOptimizationType& getOptimizationType() const { return GeoTessOptimizationType::SPEED; }
1461
1463
1472 void testGrid();
1473
1479 int getNLevels() const { return nLevels; }
1480
1492 int const* const* getLevels() const { return levels; }
1493
1508 int const* const* getTessellations() const { return tessellations; }
1509
1517 int getNTriangles() const { return nTriangles; }
1518
1519 vector<Edge*>& getSpokeList(const int& level) const
1520 { computeSpokeLists(level); return spokeList[level]; }
1521
1522 const vector<vector<Edge*> >& getEdgeList() const { return edgeList; }
1523
1524 const vector<Edge*>& getEdgeList(const int& triangle) const { return edgeList[triangle]; }
1525
1532 void getCenter(const int& triangle, double* center)
1533 {
1534 vector<double*> corners;
1535 corners.push_back(vertices[triangles[triangle][0]]);
1536 corners.push_back(vertices[triangles[triangle][1]]);
1537 corners.push_back(vertices[triangles[triangle][2]]);
1538 GeoTessUtils::center(corners, center);
1539 }
1540
1546 int delaunay();
1547
1548 };
1549 // end class GeoTessGrid
1550
1551 }// end namespace geotess
1552
1553 #endif // GEOTESSGRID_OBJECT_H
geotess::GeoTessGrid::getLastLevel
int getLastLevel(int tessellation) const
Definition: GeoTessGrid.h:866
geotess::GeoTessGrid::getSpokeList
vector< Edge * > & getSpokeList(const int &level) const
Definition: GeoTessGrid.h:1519
geotess::GeoTessGrid::testGrid
void testGrid()
geotess::GeoTessGrid::getGridSoftwareVersion
const string & getGridSoftwareVersion() const
Definition: GeoTessGrid.h:585
geotess::GeoTessGrid::GeoTessGrid
GeoTessGrid(IFStreamBinary &input)
Definition: GeoTessGrid.h:435
geotess
Definition: ArrayReuse.h:57
geotess::GeoTessGrid::getNTriangles
int getNTriangles() const
Definition: GeoTessGrid.h:1517
geotess::GeoTessGrid::getDescendant
int getDescendant(const int &triangle) const
Definition: GeoTessGrid.h:1207
geotess::Edge
Stores information about the connection between two adjacent vertices which separates two neighboring...
Definition: GeoTessGrid.h:104
GeoTessException.h
geotess::GeoTessGrid::triangles
int ** triangles
Definition: GeoTessGrid.h:191
geotess::GeoTessGrid::getNeighbor
int getNeighbor(const int &tessellation, const int &level, const int &triangle, const int &side)
Definition: GeoTessGrid.h:1129
geotess::GeoTessGrid::toString
string toString()
geotess::GeoTessGrid::getGridID
const string & getGridID() const
Definition: GeoTessGrid.h:566
geotess::GeoTessGrid::getNTriangles
int getNTriangles(int tessellation, int level) const
Definition: GeoTessGrid.h:895
geotess::GeoTessGrid::getVertexIndex
int getVertexIndex(int tessId, int level, int triangle, int corner) const
Definition: GeoTessGrid.h:695
geotess::GeoTessGrid::getDescendant
int getDescendant(const int &tessId, const int &level, const int &triangle) const
Definition: GeoTessGrid.h:1209
geotess::GeoTessGrid::getVertices
double const *const * getVertices() const
Definition: GeoTessGrid.h:763
geotess::GeoTessGrid::getVertex
double * getVertex(int tessId, int level, int triangle, int corner)
Definition: GeoTessGrid.h:749
geotess::Edge::vk
int vk
Definition: GeoTessGrid.h:113
geotess::GeoTessGrid::getNeighbors
void getNeighbors(const int &tessellation, const int &level, const int &triangle, vector< int > &neighbors)
Definition: GeoTessGrid.h:1178
geotess::GeoTessGrid::getTriangleVertex
const double * getTriangleVertex(int triangleIndex, int cornerIndex) const
Definition: GeoTessGrid.h:989
geotess::GeoTessGrid::GeoTessGrid
GeoTessGrid(const string &gid)
Definition: GeoTessGrid.h:246
geotess::GeoTessGrid::getGridID
static string getGridID(const string &fileName)
geotess::GeoTessGrid::getVertexNeighbors
void getVertexNeighbors(const int &tessId, const int &level, const int &vertex, const int &order, set< int > &nbrs)
geotess::GeoTessGrid::getVertexIndex
int getVertexIndex(const double *u)
Definition: GeoTessGrid.h:706
geotess::GeoTessGrid::getNLevels
int getNLevels() const
Definition: GeoTessGrid.h:1479
geotess::GeoTessGrid::getNTessellations
int getNTessellations() const
Definition: GeoTessGrid.h:828
geotess::GeoTessGrid::vertices
double ** vertices
Definition: GeoTessGrid.h:179
geotess::GeoTessGrid::setGridGenerationDate
void setGridGenerationDate(const string &gridDate)
Definition: GeoTessGrid.h:593
geotess::GeoTessGrid::getTriangleVertexIndexes
const int * getTriangleVertexIndexes(int triangleIndex) const
Definition: GeoTessGrid.h:961
geotess::GeoTessGrid::GeoTessGrid
GeoTessGrid()
Definition: GeoTessGrid.h:412
GeoTessOptimizationType.h
geotess::GeoTessGrid::nTessellations
int nTessellations
Definition: GeoTessGrid.h:234
geotess::GeoTessGrid::setGridInputFile
void setGridInputFile(const string &gridFile)
Definition: GeoTessGrid.h:607
geotess::GeoTessGrid::getEdgeList
const vector< vector< Edge * > > & getEdgeList() const
Definition: GeoTessGrid.h:1522
geotess::GeoTessGrid::getVertexNeighbors
void getVertexNeighbors(const int &tessId, const int &level, const int &vertex, set< int > &nbrs)
Definition: GeoTessGrid.h:1296
geotess::GeoTessGrid::getDescendants
int const * getDescendants() const
Definition: GeoTessGrid.h:1205
geotess::GeoTessGrid::getFirstTriangle
int getFirstTriangle(int tessellation, int level) const
Definition: GeoTessGrid.h:924
geotess::GeoTessGrid::getTriangleVertices
void getTriangleVertices(int triangle, double **triVrt)
Definition: GeoTessGrid.h:1001
geotess::Edge::vj
int vj
Definition: GeoTessGrid.h:108
geotess::GeoTessGrid::getVertexTriangles
const vector< vector< int > > & getVertexTriangles(const int &level) const
Definition: GeoTessGrid.h:1233
geotess::GeoTessGrid::nLevels
int nLevels
Definition: GeoTessGrid.h:214
geotess::GeoTessGrid::getNeighbor
int getNeighbor(const int &triangleIndex, const int &neighborIndex) const
Definition: GeoTessGrid.h:1102
geotess::GeoTessGrid::getVerticesTopLevel
void getVerticesTopLevel(const int &tessellation, set< const double * > &vectors)
Definition: GeoTessGrid.h:773
GeoTessUtils.h
geotess::GeoTessGrid::getNeighborIndex
int getNeighborIndex(const int &tid, const int &nid)
Definition: GeoTessGrid.h:1194
geotess::GeoTessGrid::getVertexTriangles
const vector< int > & getVertexTriangles(int tessId, int vertex) const
Definition: GeoTessGrid.h:1263
geotess::GeoTessGrid::getCircumCenter
void getCircumCenter(const int &triangle, double *cc) const
Definition: GeoTessGrid.h:1085
geotess::GeoTessGrid::findClosestVertex
int findClosestVertex(double *unit_vector, int tessId)
Definition: GeoTessGrid.h:645
geotess::GeoTessGrid::getLastTriangle
int getLastTriangle(int tessellation, int level) const
Definition: GeoTessGrid.h:936
geotess::GeoTessGrid::nVertices
int nVertices
Definition: GeoTessGrid.h:184
geotess::GeoTessGrid
Manages the geometry and topology of one or more multi-level triangular tessellations of a unit spher...
Definition: GeoTessGrid.h:169
geotess::IFStreamAscii
Opens ascii file for read and write access.
Definition: IFStreamAscii.h:83
geotess::GeoTessGrid::getTriangle
int getTriangle(int triangleIndex, const double *vector)
LONG_INT
#define LONG_INT
Definition: CPPGlobals.h:113
geotess::GeoTessGrid::tessellations
int ** tessellations
Definition: GeoTessGrid.h:229
geotess::GeoTessGrid::getVertexIndex
int getVertexIndex(int triangle, int corner) const
Definition: GeoTessGrid.h:677
geotess::GeoTessGrid::getLevel
int getLevel(int tessellation, int i) const
Definition: GeoTessGrid.h:848
geotess::GeoTessGrid::getGridInputFile
const string & getGridInputFile() const
Definition: GeoTessGrid.h:616
geotess::GeoTessGrid::delaunay
int delaunay()
geotess::GeoTessGrid::getVertex
const double * getVertex(int vertex) const
Definition: GeoTessGrid.h:632
geotess::GeoTessGrid::GeoTessGrid
GeoTessGrid(GeoTessGrid &other)
geotess::GeoTessGrid::nTriangles
int nTriangles
Definition: GeoTessGrid.h:196
geotess::GeoTessGrid::getVertices
void getVertices(const int &tessellation, const int &level, set< const double * > &vectors)
geotess::GeoTessGrid::setGridSoftwareVersion
void setGridSoftwareVersion(const string &swVersion)
Definition: GeoTessGrid.h:577
geotess::GeoTessGrid::getGridOutputFile
const string & getGridOutputFile() const
Definition: GeoTessGrid.h:625
geotess::GeoTessGrid::getTriangles
int const *const * getTriangles() const
Definition: GeoTessGrid.h:948
geotess::GeoTessGrid::getNLevels
int getNLevels(int tessellation) const
Definition: GeoTessGrid.h:837
geotess::GeoTessGrid::getLevels
int const *const * getLevels() const
Definition: GeoTessGrid.h:1492
geotess::GeoTessGrid::getTriangleVertexIndex
int getTriangleVertexIndex(int triangleIndex, int cornerIndex) const
Definition: GeoTessGrid.h:975
GEOTESS_EXP_IMP
#define GEOTESS_EXP_IMP
Definition: CPPGlobals.h:73
geotess::GeoTessGrid::getVertexTriangles
const vector< int > & getVertexTriangles(const int &tessId, const int &level, const int &vertex) const
Definition: GeoTessGrid.h:1247
geotess::GeoTessGrid::getVertexNeighborsOrdered
void getVertexNeighborsOrdered(const int &tessId, const int &level, const int &vertex, vector< int > &v)
geotess::Edge::cornerj
int cornerj
Definition: GeoTessGrid.h:115
geotess::GeoTessGrid::getNeighbors
void getNeighbors(int triangleIndex, vector< int > &neighbors)
Definition: GeoTessGrid.h:1146
geotess::IFStreamBinary
Opens a file for binary read and write access.
Definition: IFStreamBinary.h:82
geotess::GeoTessGrid::getCircumCenter
const double * getCircumCenter(const int &triangle) const
Definition: GeoTessGrid.h:1066
geotess::GeoTessGrid::computeCircumCenters
const void computeCircumCenters(const int &level)
Definition: GeoTessGrid.h:1036
geotess::GeoTessGrid::getEdgeList
const vector< Edge * > & getEdgeList(const int &triangle) const
Definition: GeoTessGrid.h:1524
geotess::GeoTessGrid::getTessellations
int const *const * getTessellations() const
Definition: GeoTessGrid.h:1508
geotess::GeoTessGrid::getVertexIndex
int getVertexIndex(const double *u, int tessId)
Definition: GeoTessGrid.h:725
geotess::GeoTessGrid::initialize
void initialize()
geotess::GeoTessGrid::loadGrid
GeoTessGrid * loadGrid(const string &inputFile)
geotess::Edge::next
Edge * next
Definition: GeoTessGrid.h:136
geotess::GeoTessGrid::getVertexIndicesTopLevel
const set< int > & getVertexIndicesTopLevel(const int &tessId)
Definition: GeoTessGrid.h:815
ArrayReuse.h
geotess::GeoTessGrid::computeCircumCenters
const void computeCircumCenters()
Definition: GeoTessGrid.h:1019
geotess::GeoTessGrid::isGeoTessGrid
static bool isGeoTessGrid(const string &inputFile)
geotess::Edge::tRight
int tRight
Definition: GeoTessGrid.h:125
geotess::GeoTessGrid::GeoTessGrid
GeoTessGrid(IFStreamAscii &input)
Definition: GeoTessGrid.h:425
geotess::GeoTessGrid::getNVertices
int getNVertices() const
Definition: GeoTessGrid.h:822
geotess::GeoTessOptimizationType
Enumeration of the optimization strategies supported by GeoTess including OptimizationType::SPEED and...
Definition: GeoTessOptimizationType.h:69
geotess::Edge::tLeft
int tLeft
Definition: GeoTessGrid.h:120
geotess::GeoTessGrid::getMemory
LONG_INT getMemory()
Definition: GeoTessGrid.h:459
geotess::GeoTessGrid::levels
int ** levels
Definition: GeoTessGrid.h:209
CPPUtils.h
geotess::GeoTessGrid::getVertexIndices
const set< int > & getVertexIndices(const int &tessId, const int &level)
Definition: GeoTessGrid.h:801
geotess::GeoTessGrid::getTopLevel
int getTopLevel(int tessellation) const
Definition: GeoTessGrid.h:883
geotess::GeoTessGrid::getGridGenerationDate
const string & getGridGenerationDate() const
Definition: GeoTessGrid.h:601
geotess::GeoTessGrid::getTriangle
int getTriangle(int tessellation, int level, int i) const
Definition: GeoTessGrid.h:912
geotess::GeoTessGrid::getCenter
void getCenter(const int &triangle, double *center)
Definition: GeoTessGrid.h:1532