GeoTessCPP: geotess::GeoTessGrid Class Reference

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

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
geotess::GeoTessGrid Class Reference

`#include <GeoTessGrid.h>`

List of all members.

## Public Member Functions
| GeoTessGrid ()
| GeoTessGrid (const OptimizationType *opttype)
| GeoTessGrid (GeoTessGrid &other)
GeoTessGrid & | operator= (const GeoTessGrid &other)
GeoTessGrid * | loadGrid (const string &inputFile)
bool | operator== (const GeoTessGrid &g) const
bool | operator!= (const GeoTessGrid &g) const
const string & | getGridID () const
const OptimizationType * | getOptimizationType () const
void | setGridSoftwareVersion (const string &swVersion)
const string & | getGridSoftwareVersion () const
void | setGridGenerationDate (const string &gridDate)
const string & | getGridGenerationDate () const
void | setGridInputFile (const string &gridFile)
const string & | getGridInputFile () const
const string & | getGridOutputFile () const
const double * | getVertex (int vertex) const
int | getVertexIndex (int tessId, int level, int triangle, int corner) const
double * | getVertex (int tessId, int level, int triangle, int corner)
double const *const * | getVertices () const
void | getVerticesTopLevel (const int &tessellation, set< const double * > &vectors)
void | getVertices (const int &tessellation, const int &level, set< const double * > &vectors)
const set< int > & | getVertexIndices (const int &level)
const set< int > & | getVertexIndices (const int &tessId, const int &level)
const set< int > & | getVertexIndicesTopLevel (const int &tessId)
void | clearVertexIndices ()
int | getNVertices () const
int | getNTessellations () const
int | getNLevels () const
int | getNLevels (int tessellation) const
int | getLevel (int tessellation, int i) const
int | getLastLevel (int tessellation) const
int | getNTriangles () const
int | getNTriangles (int tessellation, int level) const
int | getTriangle (int tessellation, int level, int i) const
int | getFirstTriangle (int tessellation, int level) const
int | getLastTriangle (int tessellation, int level) const
int const *const * | getTriangles () const
const int * | getTriangleVertexIndexes (int triangleIndex) const
int | getTriangleVertexIndex (int triangleIndex, int cornerIndex) const
const double * | getTriangleVertex (int triangleIndex, int cornerIndex) const
void | getTriangleVertices (int triangle, double **triVrt)
const double * | getCircumCenter (int triangle, double *const pA) const
int | getNeighbor (int triangleIndex, int neighborIndex) const
const int * | getNeighbors (int triangleIndex) const
const int * | getNeighbors (const int &tessellation, const int &level, const int &triangle)
int | getNeighbor (const int &tessellation, const int &level, const int &triangle, const int &side)
int const *const * | getNeighbors () const
int | getNeighborIndex (const int &tid, const int &nid)
string | toString ()
int | getTriangle (int triangleIndex, double *vector)
const vector< int > & | getVertexTriangles (const int &tessId, const int &level, const int &vertex) const
const vector< int > & | getVertexTriangles (int tessId, int vertex) const
void | clearVertexTriangles (const int &level)
void | clearVertexTriangles ()
void | getVertexNeighborsOrdered (const int &tessId, const int &level, const int &vertex, vector< int > &v)
void | getVertexNeighbors (const int &tessId, const int &level, const int &vertex, set< int > &nbrs)
void | getVertexNeighbors (const int &tessId, const int &level, const int &vertex, const int &order, set< int > &nbrs)
bool | isSupportedFormatVersion (int frmtVrsn)
void | testGrid ()

## Static Public Member Functions
static string | getGridID (const string &fileName)
static bool | isGeoTessGrid (const string &inputFile)

## Protected Member Functions
GeoTessGrid * | loadGridAscii (const string &inputFile)
GeoTessGrid * | loadGridAscii (IFStreamAscii &input)
GeoTessGrid * | loadGridBinary (const string &inputFile)
void | findEdges ()
virtual GeoTessGrid * | loadGridBinary (IFStreamBinary &ifs)
int ** | findNeighbors ()
| GeoTessGrid (const string &gid, const OptimizationType *opttype)

## Static Protected Member Functions
static void | loadGridAsciiFront (IFStreamAscii &input, int &gridFileFormat, string &gridSWVersion, string &fileCreationDate, string &gridid, const string &grdInptFile)
static void | loadGridBinaryFront (IFStreamBinary &ifs, int &gridFileFormat, string &gridSWVersion, string &fileCreationDate, string &gridid, const string &grdInptFile)

## Protected Attributes
double ** | vertices
int | nVertices
int ** | triangles
int | nTriangles
int ** | levels
int | nLevels
int ** | tessellations
int | nTessellations
int ** | neighbors
double *** | edges
double ** | circumCenters
string | gridID
string | gridInputFile
string | gridOutputFile
string | gridSoftwareVersion
string | gridGenerationDate
int | refCount
vector< vector< vector< int > > > | vtxTriangles
vector< set< int > > | connectedVertices
const OptimizationType * | optimization

## Detailed Description

Manages the geometry and topology of one or more multi-level triangular tessellations of a unit sphere. It knows:

- the positions of all the vertices,
- the connectivity information that defines how vertices are connected to form triangles,
- for each triangle it knows the indexes of the 3 neighboring triangles,
- for each triangle it knows the index of the triangle which is a descendant at the next higher tessellation level, if there is one.
- information about which triangles reside on which tessellation level

GeoTessGrid is thread-safe in that its internal state is not modified after its data has been loaded into memory. The design intention is that single instances of a GeoTessGrid object and GeoTessData object can be shared among all the threads in a multi-threaded application and each thread will have it's own instance of a GeoTessPosition object that references the common GeoTessGrid + GeoTessData combination.

References Ballard, S., J. R. Hipp and C. J. Young, 2009, Efficient and Accurate Calculation of Ray Theory Seismic Travel Time Through Variable Resolution 3D Earth Models, Seismological Research Letters, v.80, n. 6 p. 989-999.

Author:
  Sandy Ballard

## Constructor & Destructor Documentation

geotess::GeoTessGrid::GeoTessGrid | ( | const string & | gid,
|  | const OptimizationType * | opttype
| ) |  |
| inlineprotected

Standard constructor. Builds this grid from the input file name.

geotess::GeoTessGrid::GeoTessGrid | ( |  | ) |
| inline

Default constructor. Optimization defaults to OptimizationType::SPEED. All grid information initialized to NULL. Applications need to call

geotess::GeoTessGrid::GeoTessGrid | ( | const OptimizationType * | opttype | ) |
| inline

Standard constructor. Sets optimiztion.

geotess::GeoTessGrid::GeoTessGrid | ( | GeoTessGrid & | other | ) |

Copy constructor.

## Member Function Documentation

void geotess::GeoTessGrid::clearVertexIndices | ( |  | ) |
| inline

Clear all the sets generated by getVertexIndices(level) and getVertexIndicesTopLevel(tessId)

For parallel application where thread safety of the GeoTessGrid object is important, this method will need to be synchronized.

void geotess::GeoTessGrid::clearVertexTriangles | ( | const int & | level | ) |

GeoTessGrid maintains a list of the triangles that each vertex is a member of. there is a separate list for every tessellation level in the grid. Lazy evaluation is used to build this list.

This method clears the list only for the specified tessellation level.

void geotess::GeoTessGrid::clearVertexTriangles | ( |  | ) |

GeoTessGrid maintains a list of the triangles that each vertex is a member of. there is a separate list for every tessellation level in the grid. Lazy evaluation is used to build this list.

This method clears the list for all tessellation levels.

void geotess::GeoTessGrid::findEdges | ( |  | ) |
| protected

For every edge of every triangle, compute the inward pointing normal to the edge, i.e., in a triangle formed by nodes ni, nj and nk, set edge[i] = nk cross nj.

This variable can be large and hence it is optional. If it is computed then the triangle walking algorithm will be much faster because it will only have to compute dot products instead of scalar triple products. If it remains null (is never computed) then the walking triangle algorithm will be slower.

Whether or not edges are computed is determined by the setting of variable optimization. If set to SPEED, the edges are computed, otherwise they are not.

int** geotess::GeoTessGrid::findNeighbors | ( |  | ) |
| protected

Identify the neighbors and descendants of each triangle. This method is called during construction of a GeoTessGrid object (i.e., when it is loaded from a file). Applications should not call this method.

If optimization is set to SPEED, then for each edge of a triangle the unit vector normal to the plane of the great circle containing the edge will be computed during input of the grid from file and stored in memory. With this information, the walking triangle algorithm can use dot products instead of scalar triple products when determining if a point resides inside a triangle. While much more computationally efficient, it requires alot of memory to store all those unit vectors.

const double* geotess::GeoTessGrid::getCircumCenter | ( | int | triangle,
|  | double *const | pA
| ) |  | const
| inline

Retrieve the circumCenter of the specified triangle. The circumCenter of a triangle is the center of the circle that has all three corners of the triangle on its circumference.

For parallel application where thread safety of the GeoTessGrid object is important, this method will need to be synchronized.

Parameters:

  triangle | Triangle for which the circumcenter will be returned.
  pA | The array list of circumcenter pointers created by this method that are not stored in the Grid circumCenters array. This list is empty when SPEED optimization is used.

Returns:
  unit vector that defines circumCenter.

int geotess::GeoTessGrid::getFirstTriangle | ( | int | tessellation,
|  | int | level
| ) |  | const
| inline

Retrieve the index of the first triangle on the specified level of the specified tessellation of the model.

Parameters:

  tessellation |
  level |

Returns:
  a triangle index

Since:
  2.0

const string& geotess::GeoTessGrid::getGridGenerationDate | ( |  | ) | const
| inline

Retrieve the date when the contents of this grid was generated. This is not necessarily the same as the date when the file was copied or translated.

Returns:
  the date when the contents of this grid was generated.

static string geotess::GeoTessGrid::getGridID | ( | const string & | fileName | ) |
| static

Open the specified file using the appropriate format, and read only enough of the file to retrieve the gridID.

const string& geotess::GeoTessGrid::getGridID | ( |  | ) | const
| inline

A String ID that uniquely identifies this GeoTessGrid. It must be true that two GeoTessGrid objects that have different geometry or topology also have different uniqueID values. An MD5 hash of the primary data structures (tessellations, levels, triangles and vertices) would be an excellent choice for the uniqueId, but the uniqueId can be any String that uniquely identifies the grid.

Returns:
  String gridID

const string& geotess::GeoTessGrid::getGridInputFile | ( |  | ) | const
| inline

Retrieve the name of the file from which the grid was loaded. This will be the name of a GeoTessModel file if the grid was stored in the same file as the model.

Returns:
  the name of the file from which the grid was loaded.

const string& geotess::GeoTessGrid::getGridOutputFile | ( |  | ) | const
| inline

Retrieve the name of the file to which this grid was most recently written, or the string "null" if it has not been written.

Returns:
  the name of the file to which this grid was most recently written, or the string "null" if it has not been written.

const string& geotess::GeoTessGrid::getGridSoftwareVersion | ( |  | ) | const
| inline

Get the name and version number of the software that generated the contents of this grid.

Returns:
  the name and version number of the software that generated the contents of this grid.

int geotess::GeoTessGrid::getLastLevel | ( | int | tessellation | ) | const
| inline

Retrieve the index of the last level on the specified tessellation

Parameters:

  tessellation |

Returns:
  The index of the last level on the specified tessellation.

int geotess::GeoTessGrid::getLastTriangle | ( | int | tessellation,
|  | int | level
| ) |  | const
| inline

Retrieve the index of the last triangle on the specified level of the specified tessellation of the model.

Parameters:

  tessellation |
  level |

Returns:
  a triangle index

Since:
  2.0

int geotess::GeoTessGrid::getLevel | ( | int | tessellation,
|  | int | i
| ) |  | const
| inline

Retrieve the index of one of the levels on the specified tessellation

Parameters:

  tessellation |
  i | the index of the desired level (zero would return the index of the first level on tessellation.

Returns:
  the index of the i'th level on the specified tessellation.

int geotess::GeoTessGrid::getNeighbor | ( | int | triangleIndex,
|  | int | neighborIndex
| ) |  | const
| inline

Retrieve the index of one of the triangles that is a neighbor of the specified triangle. A triangle has at least 3 neighbors and usually has 4. For triangle T, neighbors 0, 1, and 2 reside on the same tessellation level as T and refer to the triangles that share an edge with T. If T has a fourth neighbor it is a descendent of T and resides on the next higher tessellation level relative to T. In other words, neighbor(3) is one of the triangles into which T was subdivided when the tessellation was constructed. If T does not have a descendant, then getNeighbor(3) will return -1. getNeighbor(i) will always return a valid triangle index for i=[0,1,2] but may or may not return a valid triangle index for i=3.

Parameters:

  triangleIndex | index of the triangle whose neighbor is desired.
  neighborIndex | (0..3)

Returns:
  int index of the triangle that is a neighbor of triangle.

int geotess::GeoTessGrid::getNeighbor | ( | const int & | tessellation,
|  | const int & | level,
|  | const int & | triangle,
|  | const int & | side
| ) |  |
| inline

Retrieve the index of the triangle that is the i'th neighbor of the specified triangle. A triangle has at least 3 neighbors and usually has

1. For triangle T, neighbors 0, 1, and 2 reside on the same tessellation level as T and refer to the triangles that share an edge with T. If T has a fourth neighbor it is a descendent of T and resides on the next higher tessellation level relative to T. In other words, neighbor(3) is one of the triangles into which T was subdivided when the tessellation was constructed. If T does not have a descendant, then getNeighbor(3) will return -1. getNeighbor(i) will always return a valid triangle index for i=[0,1,2] but may or may not return a valid triangle index for i=3.

Parameters:

  tessellation | tessellation index
  level | index of a level relative to the first level of the specified tessellation
  triangle | the i'th triangle in the specified tessellation/level
  side | the index of the triangle side (0..2)

Returns:
  the index of the triangle that is the i'th neighbor of the specified triangle.

int geotess::GeoTessGrid::getNeighborIndex | ( | const int & | tid,
|  | const int & | nid
| ) |  |
| inline

If triangle with index tid has a neighbor with index nid, then return the index of neighbor in triangle's neighbor array.

In other words, if triangle nid is a neighbor of triangle tid, i.e., neighbors[tid][i] == nid, then this method returns i.

Parameters:

  tid | the index of a triangle
  nid | the index of another triangle

Returns:
  the index of neighbor in triangle's array of neighbors.

const int* geotess::GeoTessGrid::getNeighbors | ( | int | triangleIndex | ) | const
| inline

Retrieve the indexes of the triangles that are neighbors of the specified triangle. A triangle has at least 3 neighbors and usually has 4. For triangle T, neighbors 0, 1, and 2 reside on the same tessellation level as T and refer to the triangles that share an edge with T. If T has a fourth neighbor it is a descendent of T and resides on the next higher tessellation level relative to T. In other words, neighbor(3) is one of the triangles into which T was subdivided when the tessellation was constructed. If T does not have a descendant, then getNeighbor(3) will return -1. getNeighbor(i) will always return a valid triangle index for i=[0,1,2] but may or may not return a valid triangle index for i=3.

Parameters:

  triangleIndex | index of the triangle whose neighbors are desired.

Returns:
  int[] indexes of the triangles that are neighbors of triangle.

const int* geotess::GeoTessGrid::getNeighbors | ( | const int & | tessellation,
|  | const int & | level,
|  | const int & | triangle
| ) |  |
| inline

Retrieve the indexes of the triangles that are neighbors of the specified triangle. A triangle has at least 3 neighbors and usually has 4. For triangle T, neighbors 0, 1, and 2 reside on the same tessellation level as T and refer to the triangles that share an edge with T. If T has a fourth neighbor it is a descendent of T and resides on the next higher tessellation level relative to T. In other words, neighbor(3) is one of the triangles into which T was subdivided when the tessellation was constructed. If T does not have a descendant, then getNeighbor(3) will return -1. getNeighbor(i) will always return a valid triangle index for i=[0,1,2] but may or may not return a valid triangle index for i=3.

Parameters:

  tessellation | tessellation index
  level | index of a level relative to the first level of the specified tessellation
  triangle | the i'th triangle in the specified tessellation/level

Returns:
  the indexes of the triangles that are neighbors of the specified triangle.

int const* const* geotess::GeoTessGrid::getNeighbors | ( |  | ) | const
| inline

Returns:
  a reference to the neighbors array.

int geotess::GeoTessGrid::getNLevels | ( |  | ) | const
| inline

Returns the number of levels in the level array.

int geotess::GeoTessGrid::getNLevels | ( | int | tessellation | ) | const
| inline

Retrieve number of tessellation levels that define the specified multi-level tessellation of the model.

Parameters:

  tessellation |

Returns:
  number of levels

Since:
  2.0

int geotess::GeoTessGrid::getNTessellations | ( |  | ) | const
| inline

Returns the number of tessellations in the tessellations array.

int geotess::GeoTessGrid::getNTriangles | ( |  | ) | const
| inline

Returns the number of Triangles in the Triangle array.

int geotess::GeoTessGrid::getNTriangles | ( | int | tessellation,
|  | int | level
| ) |  | const
| inline

Retrieve the number of triangles that define the specified level of the specified multi-level tessellation of the model.

Parameters:

  tessellation |
  level |

Returns:
  number of triangles on specified tessellation and level.

Since:
  2.0

int geotess::GeoTessGrid::getNVertices | ( |  | ) | const
| inline

Returns the number of vertices in the vectices array.

const OptimizationType* geotess::GeoTessGrid::getOptimizationType | ( |  | ) | const
| inline

Returns the optimization type setting.

int geotess::GeoTessGrid::getTriangle | ( | int | tessellation,
|  | int | level,
|  | int | i
| ) |  | const
| inline

Retrieve the index of the i'th triangle on the specified level of the specified tessellation of the model.

Parameters:

  tessellation |
  level |
  i |

Returns:
  a triangle index

Since:
  2.0

int geotess::GeoTessGrid::getTriangle | ( | int | triangleIndex,
|  | double * | vector
| ) |  |

Perform walking triangle search to find the index of the triangle that contains position defined by vector and which has no descendant.

Parameters:

  triangleIndex | the triangle from which to start the search
  vector | the unit vector of the point that is to be searched for.

Returns:
  the index of the triangle that contains vector

int const* const* geotess::GeoTessGrid::getTriangles | ( |  | ) | const
| inline

Retrieve a reference to the nTriangles x 3 array of int that specifies the indexes of the 3 vertices that define each triangle of the tessellation.

Users should not modify the contents of the array.

Returns:
  a reference to the triangles.

const double* geotess::GeoTessGrid::getTriangleVertex | ( | int | triangleIndex,
|  | int | cornerIndex
| ) |  | const
| inline

Retrieve the unit vector of the vertex located at one of the corners of the specified triangle.

Parameters:

  triangleIndex | triangleIndex
  cornerIndex | 0..2

Returns:
  the unit vector of the vertex at the specified corner of the specified triangle

int geotess::GeoTessGrid::getTriangleVertexIndex | ( | int | triangleIndex,
|  | int | cornerIndex
| ) |  | const
| inline

Retrieve the index of the i'th vertex (0..2) that represents one of the corners of the specified triangle.

Parameters:

  triangleIndex | triangleIndex
  cornerIndex | 0..2

Returns:
  the index of the vertex at the specified corner of the specified triangle

const int* geotess::GeoTessGrid::getTriangleVertexIndexes | ( | int | triangleIndex | ) | const
| inline

Retrieve an int[3] array containing the indexes of the vertices that form the corners of the triangle with index triangleIndex.

Users should not modify the contents of the array.

Parameters:

  triangleIndex | triangleIndex

Returns:
  an int[3] array containing the indexes of the vertices that form the corners of the specified triangle.

void geotess::GeoTessGrid::getTriangleVertices | ( | int | triangle,
|  | double ** | triVrt
| ) |  |
| inline

Get the 3 vertices that form the corners of the specified triangle, in clockwise order.

Parameters:

  triangle | index of the desired triangle
  triVrt | the 3 vertices (unit vectors).

Returns:
  3 x 3 array of doubles with the unit vectors that define the 3 corners of the specified triangle.

const double* geotess::GeoTessGrid::getVertex | ( | int | vertex | ) | const
| inline

Retrieve the unit vector that corresponds to the specified vertex.

double* geotess::GeoTessGrid::getVertex | ( | int | tessId,
|  | int | level,
|  | int | triangle,
|  | int | corner
| ) |  |
| inline

Get the unit vector of the vertex that occupies the specified position in the hierarchy.

Parameters:

  tessId | tessellation index
  level | index of a level relative to the first level of the specified tessellation
  triangle | the i'th triangle in the specified tessellation/level
  corner | the i'th corner of the specified tessellation/level/triangle

Returns:
  unit vector of a vertex

int geotess::GeoTessGrid::getVertexIndex | ( | int | tessId,
|  | int | level,
|  | int | triangle,
|  | int | corner
| ) |  | const
| inline

Get the index of the vertex that occupies the specified position in the hierarchy.

Parameters:

  tessId | tessellation index
  level | index of a level relative to the first level of the specified tessellation
  triangle | the i'th triangle in the specified tessellation/level
  corner | the i'th corner of the specified tessellation/level/triangle

Returns:
  index of a vertex

const set<int>& geotess::GeoTessGrid::getVertexIndices | ( | const int & | level | ) |

Retrieve a set containing the indices of all the vertices that are connected together by triangles on the specified level. The index of the level is relative to all the levels in all tessellations.

Lazy evaluation is used to generate and store these sets.

For parallel application where thread safety of the GeoTessGrid object is important, this method will need to be synchronized.

Parameters:

  level | index of the level is relative to all the levels in all tessellations.

Returns:
  a set containing the indices of all the vertices that are connected together by triangles on the specified level.

const set<int>& geotess::GeoTessGrid::getVertexIndices | ( | const int & | tessId,
|  | const int & | level
| ) |  |
| inline

Retrieve a set containing the indices of all the vertices that are connected together by triangles on the specified level. The index of the level is relative to the first level of the specified tessellation.

Lazy evaluation is used to generate and store these sets.

Parameters:

  tessId | index of the tessellation.
  level | index of the level relative to the first level of the specified tessellation.

Returns:
  a set containing the indices of all the vertices that are connected together by triangles on the specified level.

const set<int>& geotess::GeoTessGrid::getVertexIndicesTopLevel | ( | const int & | tessId | ) |
| inline

Retrieve a set containing the indices of all the vertices that are connected together by triangles on the top level of the specified tessellation.

Lazy evaluation is used to generate and store these sets.

Parameters:

  tessId | index of the tessellation.

Returns:
  a set containing the indices of all the vertices that are connected together by triangles on the top level of the specified tessellation.

void geotess::GeoTessGrid::getVertexNeighbors | ( | const int & | tessId,
|  | const int & | level,
|  | const int & | vertex,
|  | set< int > & | nbrs
| ) |  |
| inline

Retrieve a list of the indexes of all the vertexes that are connected to the specified vertex by a single edge, considering only triangles in the specified tessellation and level.

Equivalent to calling this function with extra parameter "order" = 1.

Parameters:

  tessId | tessellation index
  level | index of a level relative to the first level of the specified tessellation
  vertex | index of a vertex
  nbrs | indexes of vertices

void geotess::GeoTessGrid::getVertexNeighbors | ( | const int & | tessId,
|  | const int & | level,
|  | const int & | vertex,
|  | const int & | order,
|  | set< int > & | nbrs
| ) |  |

Retrieve a list of the indexes of all the vertexes that are within a neighborhood of the specified vertex. The neighborhood is defined by the argument "order". If order is 1, then all the vertices that are connected by a single edge to vertex are included. If order is 2, then take the order 1 neighborhood and add all the vertices that are connected to any vertex in the order-1 neighborhood by a single edge. Keep doing that to as high order as desired. Only triangles in the specified tessellation and level are considered.

Supplied set nbrs is cleared at the beginning of this method and it will not contain starting vertex upon return.

Parameters:

  tessId | tessellation index
  level | index of a level relative to the first level of the specified tessellation
  vertex |
  order |
  nbrs | list of vertex indices

void geotess::GeoTessGrid::getVertexNeighborsOrdered | ( | const int & | tessId,
|  | const int & | level,
|  | const int & | vertex,
|  | vector< int > & | v
| ) |  |

Retrieve a list of the indexes of all the vertexes that are connected to the specified vertex by a single edge, considering only triangles in the specified tessellation and level. The vertices will be arranged in clockwise order when viewed from outside the unit sphere.

Parameters:

  tessId | the tessellation index
  level | index of a level relative to the first level of the specified tessellation
  vertex | index of central vertex
  v | vector of vertex indexes

const vector<int>& geotess::GeoTessGrid::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 the specified tessellation/level.

Lazy evaluation is used here. The list of indexes is initially empty and is computed and stored on demand. Once computed the indexes remain in memory for the next time they might be called.

Parameters:

  tessId | the tessellation index
  level | index of a level relative to the first level of the specified tessellation
  vertex | the index of the vertex

Returns:
  vector of vertex indexes

const vector<int>& geotess::GeoTessGrid::getVertexTriangles | ( | int | tessId,
|  | int | vertex
| ) |  | const
| inline

Retrieve a list of the triangles a particular vertex is a member of, considering only triangles in the top level of the specified tessellation.

Lazy evaluation is used here. The list of indexes is initially empty and is computed and stored on demand. Once computed the indexes remain in memory for the next time they might be called.

Parameters:

  tessId | tessellation index
  vertex |

Returns:
  list of triangle indeces

double const* const* geotess::GeoTessGrid::getVertices | ( |  | ) | const
| inline

Retrieve a reference to all of the vertices. Vertices consists of an nVertices x 3 array of doubles. The double[3] array associated with each vertex is the 3 component unit vector that defines the position of the vertex.

Users should not modify the contents of the array.

void geotess::GeoTessGrid::getVertices | ( | const int & | tessellation,
|  | const int & | level,
|  | set< const double * > & | vectors
| ) |  |

Return a set containing the unit vectors of all the vertices that are connected together by triangles on the specified tessellation and level.

Parameters:

  tessellation |
  level | the level relative to the first level of the specified tessellation
  vectors | (output) a set containing the unit vectors of all the vertices that are connected together by triangles on the specified tessellation and level.

void geotess::GeoTessGrid::getVerticesTopLevel | ( | const int & | tessellation,
|  | set< const double * > & | vectors
| ) |  |
| inline

Retrieve a set containing the unit vectors of all the vertices that are connected together by triangles on the top level of the specified tessellation.

Parameters:

  tessellation |
  vectors | (output) a set containing the unit vectors of all the vertices that are connected together by triangles on the top level of the specified tessellation.

static bool geotess::GeoTessGrid::isGeoTessGrid | ( | const string & | inputFile | ) |
| static

Test a file to see if it is a GeoTessGrid file.

Parameters:

  inputFile |

Returns:
  true if inputFile is a GeoTessGrid file.

bool geotess::GeoTessGrid::isSupportedFormatVersion | ( | int | frmtVrsn | ) |
| inline

Returns true if the input format version is supported.

GeoTessGrid* geotess::GeoTessGrid::loadGrid | ( | const string & | inputFile | ) |

Load GeoTessGrid object from a File.

GeoTessGrid* geotess::GeoTessGrid::loadGridAscii | ( | const string & | inputFile | ) |
| protected

Builds this grid from the contents of the input ascii file stream.

GeoTessGrid* geotess::GeoTessGrid::loadGridAscii | ( | IFStreamAscii & | input | ) |
| protected

Read grid from a Scanner in ascii format. Scanner is not closed by this method.

static void geotess::GeoTessGrid::loadGridAsciiFront | ( | IFStreamAscii & | input,
|  | int & | gridFileFormat,
|  | string & | gridSWVersion,
|  | string & | fileCreationDate,
|  | string & | gridid,
|  | const string & | grdInptFile
| ) |  |
| staticprotected

GeoTessGrid* geotess::GeoTessGrid::loadGridBinary | ( | const string & | inputFile | ) |
| protected

Load the 2D grid from a File.

virtual GeoTessGrid* geotess::GeoTessGrid::loadGridBinary | ( | IFStreamBinary & | ifs | ) |
| protectedvirtual

Builds this grid from the contents of the input binary file stream.

static void geotess::GeoTessGrid::loadGridBinaryFront | ( | IFStreamBinary & | ifs,
|  | int & | gridFileFormat,
|  | string & | gridSWVersion,
|  | string & | fileCreationDate,
|  | string & | gridid,
|  | const string & | grdInptFile
| ) |  |
| staticprotected

bool geotess::GeoTessGrid::operator!= | ( | const GeoTessGrid & | g | ) | const
| inline

Return true if the input Grid object (g) gridID is not equal to this Grid objects gridID.

GeoTessGrid& geotess::GeoTessGrid::operator= | ( | const GeoTessGrid & | other | ) |

Equal operator.

bool geotess::GeoTessGrid::operator== | ( | const GeoTessGrid & | g | ) | const
| inline

Return true if the input Grid object (g) gridID equals this Grid objects gridID.

void geotess::GeoTessGrid::setGridGenerationDate | ( | const string & | gridDate | ) |
| inline

Set the date when this grid was generated. This is not necessarily the same as the date when the file was copied or translated.

Parameters:

  gridDate |

void geotess::GeoTessGrid::setGridInputFile | ( | const string & | gridFile | ) |
| inline

Set the grid input file.

void geotess::GeoTessGrid::setGridSoftwareVersion | ( | const string & | swVersion | ) |
| inline

Set the name and version number of the software that generated the contents of this grid.

Parameters:

  swVersion | the name and version number of the software that generated the contents of this grid.

void geotess::GeoTessGrid::testGrid | ( |  | ) |

Tests the integrity of the grid. Visits every triangle T, and (1) checks to ensure that every neighbor of T includes T in its list of neighbors, and (2) checks that every neighbor of T shares exactly two nodes with T.

Exceptions:

  GeoTessException | if anything is amiss.

string geotess::GeoTessGrid::toString | ( |  | ) |

Returns:
  summary information about this GeoTessGrid object.

## Member Data Documentation

double** geotess::GeoTessGrid::circumCenters
| mutableprotected

An nTriangles x 3 array that stores the circumCenters of each triangle in the grid. Lazy evaluation is used.

vector< set<int> > geotess::GeoTessGrid::connectedVertices
| mutableprotected

An nLevels x n array that stores the indexes of the n vertices that are connected together by triangles on the corresponding level. Lazy evaluation is used to constuct this array of sets.

double*** geotess::GeoTessGrid::edges
| protected

an nTriangles x 3 x 3 array of doubles. For every edge of every triangle, store the inward pointing normal to the edge, i.e., in a triangle formed by nodes ni, nj and nk, set edge[i] = nk cross nj.

This variable can be large and hence it is optional. If it is computed then the triangle walking algorithm will be much faster because it will only have to compute dot products instead of scalar triple products. If it remains null (is never computed) then the walking triangle algorithm will be slower.

Whether or not edges are computed is determined by the setting of variable optimization. If set to SPEED, the edges are computed, otherwise they are not.

string geotess::GeoTessGrid::gridGenerationDate
| protected

The date when this grid was generated. Not necessarily the same as the date that the grid file was copied or translated.

string geotess::GeoTessGrid::gridID
| protected

A String ID that uniquely identifies this GeoTessGrid. It must be true that two GeoTessGrid objects that have different geometry or topology also have different uniqueID values. An MD5 hash of the primary data structures (tessellations, levels, triangles and vertices) would be an excellent choice for the uniqueId, but the uniqueId can be any String that uniquely identifies the grid.

string geotess::GeoTessGrid::gridInputFile
| protected

The name of the file from which the grid was loaded.

string geotess::GeoTessGrid::gridOutputFile
| protected

The name of the file from which the grid was loaded.

string geotess::GeoTessGrid::gridSoftwareVersion
| protected

Name and version number of the software that generated this grid.

int** geotess::GeoTessGrid::levels
| protected

An n x 2 array where n is the number of tessellation levels in all the tessellations that constitute this model. For each tessellation level, the first element of the int[2] specifies the index of the first triangle in the tess level and the second element specifies the index of the last triangle on the tess level + 1.

A level is a single-level tessellation of a unit sphere, which is to say that it is a set of triangles that completely spans the surface of a unit sphere without gaps or overlaps.

int** geotess::GeoTessGrid::neighbors
| protected

An nTriangles x 4 array of integers. Neighbors[n][0..2] are the indexes of the triangles that reside on the other side of one of the edges of triangle[n]. If edge(i) is the edge that connects vertex[n][j] and vertex[n][k], i.e., edge(i) is the edge that does not contain vertex[n][i] then neighbor[n][i] is the triangle that resides on the other side of edge(i). The last element, neighbor[n][3] is the index of the descendant of triangle[n], if it has one. If triangle[n] has no descendants, then neighbor[n][3] = -1.

int geotess::GeoTessGrid::nLevels
| protected

Number of levels.

int geotess::GeoTessGrid::nTessellations
| protected

Number of tessellations.

int geotess::GeoTessGrid::nTriangles
| protected

Number of triangles.

int geotess::GeoTessGrid::nVertices
| protected

Number of vertices.

const OptimizationType* geotess::GeoTessGrid::optimization
| protected

Execution can be optimized either for speed or memory. If optimization is set to SPEED, then for each edge of a triangle the unit vector normal to the plane of the great circle containing the edge will be computed during input of the grid from file and stored in memory. With this information, the walking triangle algorithm can use dot products instead of scalar triple products when determining if a point resides inside a triangle. While much more computationally efficient, it requires a lot of memory to store all those unit vectors.

int geotess::GeoTessGrid::refCount
| protected

Reference count.

int** geotess::GeoTessGrid::tessellations
| protected

tessellations is a n x 2 int array where n is the number of tessellations in the topology of the model. Each element specifies [0] the index of the first level and [1] last level + 1 that make up the tessellation.

A tessellation is a multi-level tessellation of a unit sphere, which is to say that it is a hierarchical set of single-level tessellations (see 'levels' above).

To loop over the triangles of tessellation tessid, level levelid:
for (int i=getFirtTriangle(tessid, levelid); i < getLastTriangle(tessid, levelid); ++i)
{ // do something with triangles[i] }

int** geotess::GeoTessGrid::triangles
| protected

An nTriangles x 3 array of integers. Each triangle is represented by the indexes of the 3 vertices that form the corners of the triangle, listed in clockwise order when viewed from outside the tessellation.

double** geotess::GeoTessGrid::vertices
| protected

An nVertices x 3 array of tessellation vertices. Each vertex is represented by a 3-component unit vector with it's origin at the center of the earth. The x-component points toward lat,lon = 0, 0. The y-component points toward lat,lon = 0, 90. The z-component points toward north pole.

vector< vector< vector<int> > > geotess::GeoTessGrid::vtxTriangles
| mutableprotected

An nLevels x nVertices x n array that stores the indices of the n triangles of which each vertex is a member.

The documentation for this class was generated from the following file:

- include/GeoTessGrid.h