G+Smo
24.08.0
Geometry + Simulation Modules
|
gsHalfEdgeMesh is a gsMesh implementation that handles Halfedges
According to Floater's algorithm the N points of the triangle mesh are given by x1, ..., xN where x1, ..., xn are inner points and x(n+1), ..., xN are boundary points. In MeshInfo the points are stored without special order and then two vectors containing indices are constructed for easily accessing point xi s. t. xi is inner vertex for i<=n and boundary vertex for i > n.
In the following the 'vertexIndex' is used for the indices of the ordered vertices 1, ..., N and by 'internVertexIndex' the indices 0,...,N-1 of the unordered m_vertices vector is meant, s. t. *m_vertices[internVertexIndex] = x(vertexIndex).
There are getter functions for the number of vertices (N), triangles, halfedges, inner vertices (n) and boundary vertices plus one can get a vertex with particular vertex index or the index from a particular vertex. The vertices of the triangle mesh get ordered, s. t. the first n vertex indices have correspondent inner vertices and the last N-n vertex indices correspond to the boundary vertices ordered counter-clockwise.
Classes | |
class | Boundary |
Class that maintains boundary of triangle mesh. More... | |
class | Chain |
Class that maintains chain of halfedges. More... | |
class | Halfedge |
Class that maintains directed halfedges in any dimension. More... | |
Public Member Functions | |
void | addLine (gsMatrix< T > const &points) |
void | addLine (VertexHandle v0, VertexHandle v1, int midPts=0) |
gsMesh & | cleanMesh () |
reorders the vertices of all faces of an .stl mesh, such that only 1 vertex is used instead of #(adjacent triangles) vertices | |
size_t | findVertex (const typename gsMesh< T >::gsVertexHandle &vertex) const |
Finds the vertex that has the same coordinates (up to a tolerance) as vertex. | |
size_t | findVertex (T x, T y, T z, bool sorted=false, real_t tol=1e-6) const |
Finds the vertex that has the coordinates x, by and z (up to a tolerance tol). | |
const std::vector< T > | getBoundaryChordLengths () const |
Get chord lengths of boundary A vector storing the lengths of the halfedges of the boundary is returned. The lengths are ordered in the same way they occur in the boundary, meaning returnVector[i] and returnVector[i+1] hold lengths of consecutive halfedges for all i. More... | |
T | getBoundaryLength () const |
Get length of the boundary of the triangle mesh. The length of the boundary of the triangle mesh is returned. More... | |
std::list< size_t > | getBoundaryVertexIndices () const |
Returns the vertex indices of the boundary. | |
std::vector< T > | getCornerLengths (std::vector< index_t > &corners) const |
Get boundary part lengths between corners A vector containing the numbers of the boundary corners serves as input like [3,10,34,59] for the 3., 10., 34. and 59. boundary vertex being the corners. The lengths of the parts between the corners, e. g. between 3. and 10. boundary vertex as first part length and so on, are returned in a vector of doubles. In case one of the corner entries is > number of boundary vertices, an error message is printed. Mostly there will be 4 corners, as the parameter domain usually is [0,1]x[0,1], but the input can have more than 4 corners too. More... | |
size_t | getGlobalVertexIndex (const size_t localVertexIndex, const size_t triangleIndex) const |
Get vertex index for firts, second or third vertex of triangle Returns the vertex index of a vertex with local vertex index 1,2 or 3 of the triangle with number 'triangleIndex'. More... | |
T | getHalfedgeLength (const size_t originVertexIndex, const size_t endVertexIndex) const |
Get halfedge length The length of the halfedge with origin and end vertex is returned. In case one of the input vertex indices is greater than the number of vertices, a error message is printed. Nothing is returned then. More... | |
size_t | getInternVertexIndex (const typename gsMesh< T >::gsVertexHandle &vertex) const |
Get intern index of the vertex stored in disordered vertex vector The index i of the intern vector of vertices, s. t. vertices[i] = vertex, is returned. In case the vertex is not stored in the vector, -1 is returned. More... | |
size_t | getNumberOfBoundaryVertices () const |
Get number of boundary vertices The number of boundary vertices of the triangle mesh is returned. More... | |
size_t | getNumberOfInnerVertices () const |
Get number of inner vertices The number of inner vertices of the triangle mesh is returned. More... | |
size_t | getNumberOfTriangles () const |
Get number of triangles The number of triangles of the triangle mesh is returned. More... | |
size_t | getNumberOfVertices () const |
Get number of vertices The number of vertices of the triangle mesh is returned. More... | |
const std::queue< Halfedge > | getOppositeHalfedges (const size_t vertexIndex, const bool innerVertex=1) const |
Returns queue of all opposite halfedges of vertex The opposite halfedge of a point in a triangle is meant to be the halfedge lying opposite of the point, e. g. the halfedge in the triangle not containing the point. Therefore all halfedges of triangles containing the vertex are stored in the return queue. Usually the function is used for inner points. By using the second optional input bool value to 0 it can be used for boundary points too. A warning is printed if the vertex is a boundary vertex although the optional bool value was not set to 0. An error message is printed if the vertex index > number of vertices. More... | |
T | getShortestBoundaryDistanceBetween (size_t i, size_t j) const |
Get distance between vertices The distance between i-th and j-th boundary vertex is returned. In is checked wheter the distance in a clockwise or counterclockwise direction is shorter, and this one is returned. More... | |
const gsMesh< T >::gsVertexHandle & | getVertex (const size_t vertexIndex) const |
Get vertex The vertex with index 'vertexIndex' is returned. More... | |
const gsMesh< T >::gsVertexHandle & | getVertexUnsorted (const size_t globIndex) const |
Returns the handle to the vertex with index globIndex. | |
gsHalfEdgeMesh (size_t nv=0) | |
Default constructor. | |
gsHalfEdgeMesh (const gsMesh< T > &mesh, T precision=1e-8, bool periodic=false) | |
Constructor This constructor uses a gsMesh and sortest its vertices. More... | |
short_t | isTriangleVertex (size_t vertexIndex, size_t triangleIndex) const |
Returns the index of a vertex contained in triangle The integers 0 for not contained 1 for being vertex1 2 for being vertex2 3 for being vertex3 in triangle are returned. If vertex index > number of vertices a warning is printed and 0 is returned. If number of triangle > number of all triangles a warning is printed and 0 is returned. More... | |
Private Member Functions | |
const Halfedge | getInternHalfedge (const typename gsMesh< T >::gsFaceHandle &triangle, size_t numberOfHalfedge) const |
Returns halfedge of triangle For a given triangle the first, second or third halfedge are constructed and returned. The first halfedge is meant to be the halfedge from vertex2 to vertex1, the second one is meant to be the one from vertex3 to vertex2 and the third one is meant to be the one from vertex1 to vertex3. The halfedges are constructed in the opposite direction because the boundary is supposed to have counterclockwise direction, if the triangles are given in clockwise direction. In case the number of the halfedge is not 1, 2 or 3 a warning is printed and the first halfedge is returned. More... | |
bool | isBoundaryVertex (const size_t internVertexIndex) const |
Tells whether a vertex is a boundary vertex or not. The boundary is constructed and it is tested whether the point with index 'internVertexIndex' stored in m_vertices is a boundary vertex. In case the internVertexIndex > N-1 a warning is printed, because that is not supposed to happen. More... | |
void | sortVertices () |
Creates ordering for vertices The vertices in m_vertices are not ordered. Therefore two index vectors m_sorting and m_inverseSorting are created. These vectors are supposed to be used like xi = *(vertices[m_sorting[i-1]) vertexIndex(vertex) = m_inverseSorting[internVertexIndex] For construction of the index vectors all vertices stored in m_vertices are passed through. The intern vertex indices of the non-boundary vertices are stored in the first n m_sorting entries. The other way round the vertex indices 1,...,n are stored in the corresponding m_inverseSorting entries. At last the boundary is traversed and for every vertex the intern vertex index is stored in the last N-n m_sorting entries as well as the vertex index is stored in the corresponding m_inverseSorting entry. More... | |
Private Attributes | |
Boundary | m_boundary |
boundary of the mesh | |
std::vector< Halfedge > | m_halfedges |
vector of halfedges | |
std::vector< index_t > | m_inverseSorting |
vector of indices s. t. m_inverseSorting[internVertexIndex] = vertexIndex | |
size_t | m_n |
number of inner vertices in the mesh | |
std::vector< index_t > | m_sorting |
vector that stores the internVertexIndices s. t. m_sorting[vertexIndex-1] = internVertexIndex | |
|
explicit |
|
inherited |
Add to the mesh a list of vertices connected with edges One edges are added between two successive vertices in the input. Vertices of the edges are assumed to be inexistent vertices.
points | matrix containing in the columns a list of points |
|
inherited |
Inserts a straight line in the mesh, between v0 and v1, with midPts intermediate vertices distributed linearly between v0 and v1 (used for plotting).
const std::vector< T > getBoundaryChordLengths | ( | ) | const |
Get chord lengths of boundary A vector storing the lengths of the halfedges of the boundary is returned. The lengths are ordered in the same way they occur in the boundary, meaning returnVector[i] and returnVector[i+1] hold lengths of consecutive halfedges for all i.
T getBoundaryLength | ( | ) | const |
Get length of the boundary of the triangle mesh. The length of the boundary of the triangle mesh is returned.
std::vector< T > getCornerLengths | ( | std::vector< index_t > & | corners | ) | const |
Get boundary part lengths between corners A vector containing the numbers of the boundary corners serves as input like [3,10,34,59] for the 3., 10., 34. and 59. boundary vertex being the corners. The lengths of the parts between the corners, e. g. between 3. and 10. boundary vertex as first part length and so on, are returned in a vector of doubles. In case one of the corner entries is > number of boundary vertices, an error message is printed. Mostly there will be 4 corners, as the parameter domain usually is [0,1]x[0,1], but the input can have more than 4 corners too.
[in] | corners | std::vector<size_t >& - vector of boundary point numbers for corners, [1,2,3,4] stands for 1., 2., 3., 4. boundary vertex serve as corners |
size_t getGlobalVertexIndex | ( | const size_t | localVertexIndex, |
const size_t | triangleIndex | ||
) | const |
Get vertex index for firts, second or third vertex of triangle Returns the vertex index of a vertex with local vertex index 1,2 or 3 of the triangle with number 'triangleIndex'.
[in] | localVertexIndex | const int - local vertex index (1,2,3) of the vertex |
[in] | triangleIndex | const int - number of the triangle |
T getHalfedgeLength | ( | const size_t | originVertexIndex, |
const size_t | endVertexIndex | ||
) | const |
Get halfedge length The length of the halfedge with origin and end vertex is returned. In case one of the input vertex indices is greater than the number of vertices, a error message is printed. Nothing is returned then.
[in] | originVertexIndex | const int - vertex index of origin vertex |
[in] | endVertexIndex | const int - vertex index of origin vertex |
|
private |
Returns halfedge of triangle For a given triangle the first, second or third halfedge are constructed and returned. The first halfedge is meant to be the halfedge from vertex2 to vertex1, the second one is meant to be the one from vertex3 to vertex2 and the third one is meant to be the one from vertex1 to vertex3. The halfedges are constructed in the opposite direction because the boundary is supposed to have counterclockwise direction, if the triangles are given in clockwise direction. In case the number of the halfedge is not 1, 2 or 3 a warning is printed and the first halfedge is returned.
[in] | triangle | const ESS_IO::IO_Triangle& - triangle |
[in] | numberOfHalfedge | int - number of the desired halfedge |
size_t getInternVertexIndex | ( | const typename gsMesh< T >::gsVertexHandle & | vertex | ) | const |
Get intern index of the vertex stored in disordered vertex vector The index i of the intern vector of vertices, s. t. vertices[i] = vertex, is returned. In case the vertex is not stored in the vector, -1 is returned.
[in] | vertex | const ESS_IO::IO_Vertex& - vertex that one wants to know the index of |
size_t getNumberOfBoundaryVertices | ( | ) | const |
Get number of boundary vertices The number of boundary vertices of the triangle mesh is returned.
size_t getNumberOfInnerVertices | ( | ) | const |
Get number of inner vertices The number of inner vertices of the triangle mesh is returned.
size_t getNumberOfTriangles | ( | ) | const |
Get number of triangles The number of triangles of the triangle mesh is returned.
size_t getNumberOfVertices | ( | ) | const |
Get number of vertices The number of vertices of the triangle mesh is returned.
const std::queue< typename gsHalfEdgeMesh< T >::Halfedge > getOppositeHalfedges | ( | const size_t | vertexIndex, |
const bool | innerVertex = 1 |
||
) | const |
Returns queue of all opposite halfedges of vertex The opposite halfedge of a point in a triangle is meant to be the halfedge lying opposite of the point, e. g. the halfedge in the triangle not containing the point. Therefore all halfedges of triangles containing the vertex are stored in the return queue. Usually the function is used for inner points. By using the second optional input bool value to 0 it can be used for boundary points too. A warning is printed if the vertex is a boundary vertex although the optional bool value was not set to 0. An error message is printed if the vertex index > number of vertices.
[in] | vertexIndex | const int - vertex index |
[in] | innerVertex | bool - optional bool value, should be set to 0 if vertex is boundary vertex |
T getShortestBoundaryDistanceBetween | ( | size_t | i, |
size_t | j | ||
) | const |
Get distance between vertices The distance between i-th and j-th boundary vertex is returned. In is checked wheter the distance in a clockwise or counterclockwise direction is shorter, and this one is returned.
[in] | i | number of the first boundary vertex |
[in] | j | number of the second boundary vertex |
const gsMesh< T >::gsVertexHandle & getVertex | ( | const size_t | vertexIndex | ) | const |
Get vertex The vertex with index 'vertexIndex' is returned.
[in] | vertexIndex | const int - index of the vertex that should be returned |
|
private |
Tells whether a vertex is a boundary vertex or not. The boundary is constructed and it is tested whether the point with index 'internVertexIndex' stored in m_vertices is a boundary vertex. In case the internVertexIndex > N-1 a warning is printed, because that is not supposed to happen.
[in] | internVertexIndex | const int - intern vertex index |
short_t isTriangleVertex | ( | size_t | vertexIndex, |
size_t | triangleIndex | ||
) | const |
Returns the index of a vertex contained in triangle The integers 0 for not contained 1 for being vertex1 2 for being vertex2 3 for being vertex3 in triangle are returned. If vertex index > number of vertices a warning is printed and 0 is returned. If number of triangle > number of all triangles a warning is printed and 0 is returned.
[in] | vertexIndex | int - vertex index |
[in] | triangleIndex | int - number of triangle |
|
private |
Creates ordering for vertices The vertices in m_vertices are not ordered. Therefore two index vectors m_sorting and m_inverseSorting are created. These vectors are supposed to be used like xi = *(vertices[m_sorting[i-1]) vertexIndex(vertex) = m_inverseSorting[internVertexIndex] For construction of the index vectors all vertices stored in m_vertices are passed through. The intern vertex indices of the non-boundary vertices are stored in the first n m_sorting entries. The other way round the vertex indices 1,...,n are stored in the corresponding m_inverseSorting entries. At last the boundary is traversed and for every vertex the intern vertex index is stored in the last N-n m_sorting entries as well as the vertex index is stored in the corresponding m_inverseSorting entry.