DelaunayTriangulation
A C++ Object Oriented data structure with algorithms that could be used to generate a Delaunay triangulation
Public Member Functions | Private Attributes | Friends | List of all members
Mesh Class Reference

Parent class of all objects, contains full triangulation and its constituent parts. More...

#include <Mesh.hpp>

Inheritance diagram for Mesh:
Inheritance graph
Collaboration diagram for Mesh:
Collaboration graph

Public Member Functions

 Mesh ()
 Default contructor.
 
 ~Mesh ()
 Default destructor.
 
std::vector< VecresolvePoints (std::vector< vertInd > vertInds)
 Implementation of IMesh::resolvePoints Resolves vector of vertex indices to vector of vertex pointers. More...
 
bool isDelaunay ()
 Checks whether mesh is Delauney. More...
 
std::vector< edgenewEdges (triInd triInd, const std::vector< vertInd > &vert)
 Implementation of IMesh::newEdges Adds triangle's new edges to map. More...
 
void removeEdges (triInd triInd, const std::vector< edge > &rEdge)
 Implementation of IMesh::removeEdges Remove triangle's old edges from map. More...
 
int containingTriangle (double x, double y)
 Find the triangle which contains the point \((x,y)\). More...
 
std::vector< int > adjacentTriangles (triInd triInd)
 Find all triangles that share an edge with triangle represented by triInd. More...
 
void recalcCircum (vertInd vertInd)
 Implementation of IMesh::recalcCircum Recalculate the Triangle::circumcircle of all Triangles using vertex represented by vertInd. More...
 
void updateVertTri (triInd triInd, std::vector< vertInd > vertInds)
 Implementation of IMesh::updateVertTri Add Triangle represented by triInd to vertTri. More...
 
void removeVertTri (triInd triInd, std::vector< vertInd > rVertInds)
 Implementation of IMesh::removeVertTri Remove triangle index from vertTri. More...
 
template<typename T >
double integrate (T func, double(*interp)(T, const Triangle &))
 Estimate the integral of the function func over the mesh. More...
 
const std::map< int, Vertex > & getVertices () const
 Accessor to private member vertices. More...
 
void setVertices (const std::map< int, Vertex > &vertices)
 Mutator for private member vertices. More...
 
const std::map< int, Triangle > & getTriangles () const
 Accessor to private member vertices. More...
 
void setTriangles (const std::map< int, Triangle > &triangles)
 Mutator for private member triangles. More...
 
int getVertexAttributes () const
 Accessor for private member vertexAttributes. More...
 
void setVertexAttributes (int verAttr)
 Mutator for private member vertexAttributes. More...
 
int getTriangleAttributes () const
 Accessor for private member triangleAttributes. More...
 
void setTriangleAttributes (int triAttr)
 Mutator for private member triangleAttributes. More...
 
int getDimensions () const
 Accessor for private member dimensions. More...
 
const std::map< std::pair< int, int >, std::vector< int > > & getEdges () const
 Accessor for private member edges. More...
 
bool operator== (const Mesh &rhs) const
 Equality operator. More...
 
bool operator!= (const Mesh &rhs) const
 Not-equality operator. More...
 
- Public Member Functions inherited from IMesh
virtual ~IMesh ()
 Virtual destructor.
 

Private Attributes

int vertexAttributes
 Number of attributes in a vertex object.
 
int triangleAttributes
 Number of attributes in a triangle object.
 
int dimensions
 Number of dimensions of the mesh.
 
std::map< triInd, Triangletriangles
 Map of triangle indices to triangles they refer to.
 
std::map< vertInd, Vertexvertices
 Map of vertex indices to vertices they refer to.
 
std::map< edge, std::vector< triInd > > edges
 Map of pairs of vertex indices (representing an edge) to a vector of triangles using them. More...
 
std::map< vertInd, std::vector< triInd > > vertTri
 Map of a vertex index to a vector of triangles using them. More...
 

Friends

std::ifstream & operator>> (std::ifstream &ifs, Mesh &mesh)
 Input filestream operator. More...
 
std::ofstream & operator<< (std::ofstream &ofs, Mesh &mesh)
 Output filestream operator. More...
 

Additional Inherited Members

- Public Types inherited from IMesh
typedef std::pair< int, int > edge
 Type representing an edge, two vertex indices.
 
typedef int vertInd
 Type representing an index of a vertex.
 
typedef int triInd
 Type representing an index of a triangle.
 

Detailed Description

Parent class of all objects, contains full triangulation and its constituent parts.

Member Function Documentation

◆ adjacentTriangles()

std::vector< int > Mesh::adjacentTriangles ( triInd  triInd)

Find all triangles that share an edge with triangle represented by triInd.

Parameters
triIndIndex of querying triangle
Returns
Vector of indices of adjacent triangles

◆ containingTriangle()

int Mesh::containingTriangle ( double  x,
double  y 
)

Find the triangle which contains the point \((x,y)\).

Parameters
x
y
Returns
Index of containing triangle, or -1 if not inside

◆ getDimensions()

int Mesh::getDimensions ( ) const

Accessor for private member dimensions.

Returns
number of dimensions

◆ getEdges()

const std::map< Mesh::edge, std::vector< int > > & Mesh::getEdges ( ) const

Accessor for private member edges.

Returns
Map of pairs of vertex indices (edges) to a std::vector of triangle indices that use that side

◆ getTriangleAttributes()

int Mesh::getTriangleAttributes ( ) const

Accessor for private member triangleAttributes.

Returns
number of Triangle attributes

◆ getTriangles()

const std::map< int, Triangle > & Mesh::getTriangles ( ) const

Accessor to private member vertices.

Returns
Map of indices to Triangle instances

◆ getVertexAttributes()

int Mesh::getVertexAttributes ( ) const

Accessor for private member vertexAttributes.

Returns
number of Vertex attributes

◆ getVertices()

const std::map< int, Vertex > & Mesh::getVertices ( ) const

Accessor to private member vertices.

Returns
Map of indices to Vertex instances

◆ integrate()

template<typename T >
double Mesh::integrate ( func,
double(*)(T, const Triangle &)  interp 
)
inline

Estimate the integral of the function func over the mesh.

Template Parameters
Tfunction with signature double (double, double)
Parameters
funcMathematical function to be integrated
interpFunction with signature double(T, const Triangle&) which will integrate the function over a triangle Examples are Utils::constantValueApprox and Utils::linearInterpolationApprox
Returns
Estimation of the integral

◆ isDelaunay()

bool Mesh::isDelaunay ( )

Checks whether mesh is Delauney.

Returns
bool representing whether or not mesh is Delauney
Exceptions
std::runtime_errorif mesh has no triangles

◆ newEdges()

std::vector< std::pair< int, int > > Mesh::newEdges ( triInd  triInd,
const std::vector< vertInd > &  vert 
)
virtual

Implementation of IMesh::newEdges Adds triangle's new edges to map.

Parameters
triIndindex of the triangle using the vertices
vertVector of vertex indices being used by the triangle
Returns
Vector of pairs of vectors representing an edge

Implements IMesh.

◆ operator!=()

bool Mesh::operator!= ( const Mesh rhs) const

Not-equality operator.

Parameters
rhs
Returns

◆ operator==()

bool Mesh::operator== ( const Mesh rhs) const

Equality operator.

Note
Copy operator is generated by the compiler
Parameters
rhs
Returns

◆ recalcCircum()

void Mesh::recalcCircum ( vertInd  vertInd)
virtual

Implementation of IMesh::recalcCircum Recalculate the Triangle::circumcircle of all Triangles using vertex represented by vertInd.

  • called after coordinates of a Vertex changed using mutator
    Parameters
    vertIndIndex of changed Vector

Implements IMesh.

◆ removeEdges()

void Mesh::removeEdges ( triInd  triInd,
const std::vector< edge > &  rEdge 
)
virtual

Implementation of IMesh::removeEdges Remove triangle's old edges from map.

Parameters
triIndindex of triangle using the vertices
rEdgeVector of edges that are no longer in use by the triangle

Implements IMesh.

◆ removeVertTri()

void Mesh::removeVertTri ( triInd  triInd,
std::vector< vertInd rVertInds 
)
virtual

Implementation of IMesh::removeVertTri Remove triangle index from vertTri.

Parameters
triIndIndex of triangle to be removed
rVertIndsOld indices used by Triangle

Implements IMesh.

◆ resolvePoints()

std::vector< Vec > Mesh::resolvePoints ( std::vector< vertInd vertInds)
virtual

Implementation of IMesh::resolvePoints Resolves vector of vertex indices to vector of vertex pointers.

Parameters
vertIndsVector of indices of vertexes
Returns
Vector of coordinates matching the indices given by pointIndices
Exceptions
std::runtime_errorif index is out of range of valid vertices

Implements IMesh.

◆ setTriangleAttributes()

void Mesh::setTriangleAttributes ( int  triAttr)

Mutator for private member triangleAttributes.

Parameters
triAttrnumber of Triangle attributes

◆ setTriangles()

void Mesh::setTriangles ( const std::map< int, Triangle > &  triangles)

Mutator for private member triangles.

Parameters
trianglesMap of indices to Triangle instances

◆ setVertexAttributes()

void Mesh::setVertexAttributes ( int  verAttr)

Mutator for private member vertexAttributes.

Parameters
verAttrnumber of Vertex attributes

◆ setVertices()

void Mesh::setVertices ( const std::map< int, Vertex > &  vertices)

Mutator for private member vertices.

Parameters
verticesMap of indices to Vertex instances

◆ updateVertTri()

void Mesh::updateVertTri ( triInd  triInd,
std::vector< vertInd vertInds 
)
virtual

Implementation of IMesh::updateVertTri Add Triangle represented by triInd to vertTri.

Implements IMesh.

Friends And Related Function Documentation

◆ operator<<

std::ofstream & operator<< ( std::ofstream &  ofs,
Mesh mesh 
)
friend

Output filestream operator.

Parameters
ofs
mesh
Returns

◆ operator>>

std::ifstream & operator>> ( std::ifstream &  ifs,
Mesh mesh 
)
friend

Input filestream operator.

Parameters
ifs
mesh
Returns

Member Data Documentation

◆ edges

std::map<edge, std::vector<triInd> > Mesh::edges
private

Map of pairs of vertex indices (representing an edge) to a vector of triangles using them.

  • Used to find adjacent triangles

◆ vertTri

std::map<vertInd, std::vector<triInd> > Mesh::vertTri
private

Map of a vertex index to a vector of triangles using them.

  • Used to find circumcentres that must be updated when vector values change

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