Template Class HalfEdgeMesh
Defined in File HalfEdgeMesh.hpp
Inheritance Relationships
Base Type
public lvr2::BaseMesh< BaseVecT >(Template Class BaseMesh)
Class Documentation
-
template<typename BaseVecT>
class HalfEdgeMesh : public lvr2::BaseMesh<BaseVecT> Half-edge data structure implementing the
BaseMeshinterface.This implementation uses a half-edge structure. This encodes many connectivity details explicitly, enabling fast lookup. However, HEMs are primarily intended for non-triangle meshes (variable number of edges per face). Using it for triangle meshes might be overkill and results in a memory overhead.
Public Functions
-
HalfEdgeMesh()
-
HalfEdgeMesh(MeshBufferPtr ptr)
-
virtual VertexHandle addVertex(BaseVecT pos) final
Adds a vertex with the given position to the mesh.
The vertex is not connected to anything after calling this method. To add this vertex to a face, use
addFace().- Returns:
A handle to access the inserted vertex later.
-
virtual FaceHandle addFace(VertexHandle v1H, VertexHandle v2H, VertexHandle v3H) final
Creates a face connecting the three given vertices.
Important: The face’s vertices have to be given in front-face counter- clockwise order. This means that, when looking at the face’s front, the vertices would appear in counter-clockwise order. Or in more mathy terms: the face’s normal is equal to (v1 - v2) x (v1 - v3) in the right-handed coordinate system (where
xis cross-product).This method panics if an insertion is not possible. You can check whether or not an insertion is valid by using
isFaceInsertionValid().- Returns:
A handle to access the inserted face later.
-
virtual void removeFace(FaceHandle handle) final
Removes the given face and all (if not connected to any other face/edge/vertex) connected edges and vertices.
-
virtual EdgeCollapseResult collapseEdge(EdgeHandle edgeH) final
Merges the two vertices connected by the given edge.
If existing, the two neighboring faces or triangles without faces and their edges are removed and replaced by two new edges The vertices at the start and end of the given edge are removed and replaced by a new vertex at the center of the previous vertex positions
- Returns:
An EdgeCollapseResult that contains handles of the removed faces and edges and the new vertex and the new edges
-
VertexSplitResult splitVertex(VertexHandle vertexToBeSplitH)
-
EdgeSplitResult splitEdge(EdgeHandle edgeH)
-
void fillHoles(size_t maxSize)
-
void laplacianSmoothing(float smoothFactor, int numSmooths = 1)
-
vector<VertexHandle> findCommonNeigbours(VertexHandle vH1, VertexHandle vH2)
-
virtual void flipEdge(EdgeHandle edgeH) final
Performs the edge flip operation.
This operation turns an edge and the two adjacent faces within a four vertex region by 90°. The edge is now connected to two new vertices; the new edge would cross the old one.
Important: the given edge needs to be flippable. You can check that property with
isFlippable(). If that property is not satisfied, this method will panic.Note that while this method modifies connectivity information, it does not add or remove any elements. This implies that it doesn’t invalidate any handles.
The user of this method has to pay attention to what edges to flip. It’s easily possible to create unrealistic meshes with this method (things like zero volume and stuff like that). However, it doesn’t destroy the mesh in itself or create non-manifold meshes.
-
void splitVertex(EdgeHandle eH, VertexHandle vH, BaseVecT pos1, BaseVecT pos2)
-
std::pair<BaseVecT, float> triCircumCenter(FaceHandle faceH)
-
virtual size_t numVertices() const final
Returns the number of vertices in the mesh.
-
virtual size_t numFaces() const final
Returns the number of faces in the mesh.
-
virtual size_t numEdges() const final
Returns the number of edges in the mesh.
-
virtual bool containsVertex(VertexHandle vH) const
Checks if the given vertex is part of this mesh.
-
virtual bool containsFace(FaceHandle fH) const
Checks if the given face is part of this mesh.
-
virtual bool containsEdge(EdgeHandle eH) const
Checks if the given edge is part of this mesh.
-
virtual bool isBorderEdge(EdgeHandle handle) const
Determines wheter the given edge is an border edge, i.e., if it is connected to two faces or not.
-
virtual bool isFlippable(EdgeHandle handle) const
Determines whether or not the given edge can be flipped without destroying the mesh.
The mesh could be destroyed by invalidating mesh connectivity information or by making it non-manifold.
-
virtual Index nextVertexIndex() const
Returns the handle index which would be assigned to the next vertex that is created. This method is mainly useful for manually iterating over all possible handles. As handles are strictly increasing, all vertices currently in this mesh have a handle index smaller than what this method returns.
-
virtual Index nextFaceIndex() const
Returns the handle index which would be assigned to the next face that is created. This method is mainly useful for manually iterating over all possible handles. As handles are strictly increasing, all faces currently in this mesh have a handle index smaller than what this method returns.
-
virtual Index nextEdgeIndex() const
Returns the handle index which would be assigned to the next edge that is created. This method is mainly useful for manually iterating over all possible handles. As handles are strictly increasing, all edges currently in this mesh have a handle index smaller than what this method returns.
-
virtual BaseVecT getVertexPosition(VertexHandle handle) const final
- #include “List.tcc”e given vertex.
@brief Get the position of th
-
virtual BaseVecT &getVertexPosition(VertexHandle handle) final
Get a ref to the position of the given vertex.
-
virtual array<VertexHandle, 3> getVerticesOfFace(FaceHandle handle) const final
Get the three vertices surrounding the given face.
- Returns:
The vertex-handles in counter-clockwise order.
-
virtual array<EdgeHandle, 3> getEdgesOfFace(FaceHandle handle) const final
Get the three edges surrounding the given face.
- Returns:
The edge-handles in counter-clockwise order.
-
void getNeighboursOfFace(FaceHandle handle, vector<FaceHandle> &facesOut) const final
-
virtual array<VertexHandle, 2> getVerticesOfEdge(EdgeHandle edgeH) const final
Get the two vertices of an edge.
The order of the vertices is not specified
-
virtual array<OptionalFaceHandle, 2> getFacesOfEdge(EdgeHandle edgeH) const final
Get the two faces of an edge.
The order of the faces is not specified
-
void getFacesOfVertex(VertexHandle handle, vector<FaceHandle> &facesOut) const final
-
void getEdgesOfVertex(VertexHandle handle, vector<EdgeHandle> &edgesOut) const final
-
void getNeighboursOfVertex(VertexHandle handle, vector<VertexHandle> &verticesOut) const final
-
virtual OptionalFaceHandle getOppositeFace(FaceHandle faceH, VertexHandle vertexH) const
Get the optional face handle of the neighboring face lying on the vertex’s opposite site.
- Parameters:
faceH – The corresponding face handle
vertexH – The corresponding vertex handle
- Returns:
optional face handle of the
faceHneighboring face lying on the opposite side of thevertexHvertex.
-
virtual OptionalEdgeHandle getOppositeEdge(FaceHandle faceH, VertexHandle vertexH) const
Get the optional edge handle of the edge lying on the vertex’s opposite site.
- Parameters:
faceH – The corresponding face handle
vertexH – The corresponding vertex handle
- Returns:
optional edge handle which lies on the
faceHface on the opposite side of thevertexHvertex.
-
virtual OptionalVertexHandle getOppositeVertex(FaceHandle faceH, EdgeHandle edgeH) const
Get the optional vertex handle of the vertex lying on the edge’s opposite site.
- Parameters:
faceH – The corresponding face handle
edgeH – The corresponding edge handle
- Returns:
optional vertex handle which lies on the
faceHface on the opposite side of theedgeHedge.
-
virtual MeshHandleIteratorPtr<VertexHandle> verticesBegin() const final
Returns an iterator to the first vertex of this mesh.
- Returns:
When dereferenced, this iterator returns a handle to the current vertex.
-
virtual MeshHandleIteratorPtr<VertexHandle> verticesEnd() const final
Returns an iterator to the element following the last vertex of this mesh.
-
virtual MeshHandleIteratorPtr<FaceHandle> facesBegin() const final
Returns an iterator to the first face of this mesh.
- Returns:
When dereferenced, this iterator returns a handle to the current face.
-
virtual MeshHandleIteratorPtr<FaceHandle> facesEnd() const final
Returns an iterator to the element following the last face of this mesh.
-
virtual MeshHandleIteratorPtr<EdgeHandle> edgesBegin() const final
Returns an iterator to the first edge of this mesh.
- Returns:
When dereferenced, this iterator returns a handle to the current edge.
-
virtual MeshHandleIteratorPtr<EdgeHandle> edgesEnd() const final
Returns an iterator to the element following the last edge of this mesh.
-
bool debugCheckMeshIntegrity() const
-
HalfEdgeMesh()