Template Class PMPMesh
Defined in File PMPMesh.hpp
Inheritance Relationships
Base Type
public lvr2::BaseMesh< BaseVecT >(Template Class BaseMesh)
Class Documentation
-
template<typename BaseVecT>
class PMPMesh : public lvr2::BaseMesh<BaseVecT> Wrapper around the pmp::SurfaceMesh class to provide a lvr2::BaseMesh interface.
Public Types
Public Functions
-
inline PMPMesh()
-
PMPMesh(MeshBufferPtr ptr)
-
PMPMesh(const HighFive::Group &group)
-
virtual ~PMPMesh() = default
-
void read(const HighFive::Group &group)
Reads the mesh from a group. group must be written to with write(group)
-
inline void write(HighFive::Group &group)
Writes the mesh into the given group.
-
void write_const(HighFive::Group &group) const
const version of write(group). Requires that the mesh has no garbage (see collectGarbage())
-
inline MeshBufferPtr toMeshBuffer()
Creates a MeshBuffer from the Mesh.
-
MeshBufferPtr toMeshBuffer_const() const
const version of toMeshBuffer(). Requires that the mesh has no garbage (see collectGarbage())
-
inline virtual VertexHandle addVertex(BaseVecT pos) override
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.
-
inline virtual FaceHandle addFace(VertexHandle v1H, VertexHandle v2H, VertexHandle v3H) override
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.
-
inline virtual void removeFace(FaceHandle handle) override
Removes the given face and all (if not connected to any other face/edge/vertex) connected edges and vertices.
-
virtual EdgeCollapseResult collapseEdge(EdgeHandle edgeH) override
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
-
inline virtual void flipEdge(EdgeHandle edgeH) override
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.
-
inline virtual size_t numVertices() const override
Returns the number of vertices in the mesh.
-
inline virtual size_t numFaces() const override
Returns the number of faces in the mesh.
-
inline virtual size_t numEdges() const override
Returns the number of edges in the mesh.
-
inline virtual bool containsVertex(VertexHandle vH) const override
Checks if the given vertex is part of this mesh.
-
inline virtual bool containsFace(FaceHandle fH) const override
Checks if the given face is part of this mesh.
-
inline virtual bool containsEdge(EdgeHandle eH) const override
Checks if the given edge is part of this mesh.
-
inline virtual bool isBorderEdge(EdgeHandle handle) const override
Determines wheter the given edge is an border edge, i.e., if it is connected to two faces or not.
-
inline virtual bool isFlippable(EdgeHandle handle) const override
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.
-
inline virtual Index nextVertexIndex() const override
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.
-
inline virtual Index nextFaceIndex() const override
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.
-
inline virtual Index nextEdgeIndex() const override
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.
-
inline virtual BaseVecT getVertexPosition(VertexHandle handle) const override
- #include “List.tcc”e given vertex.
@brief Get the position of th
-
inline virtual BaseVecT &getVertexPosition(VertexHandle handle) override
Get a ref to the position of the given vertex.
-
virtual array<VertexHandle, 3> getVerticesOfFace(FaceHandle handle) const override
Get the three vertices surrounding the given face.
- Returns:
The vertex-handles in counter-clockwise order.
-
virtual array<EdgeHandle, 3> getEdgesOfFace(FaceHandle handle) const override
Get the three edges surrounding the given face.
- Returns:
The edge-handles in counter-clockwise order.
-
void getNeighboursOfFace(FaceHandle handle, vector<FaceHandle> &facesOut) const override
-
virtual array<VertexHandle, 2> getVerticesOfEdge(EdgeHandle edgeH) const override
Get the two vertices of an edge.
The order of the vertices is not specified
-
virtual array<OptionalFaceHandle, 2> getFacesOfEdge(EdgeHandle edgeH) const override
Get the two faces of an edge.
The order of the faces is not specified
-
void getFacesOfVertex(VertexHandle handle, vector<FaceHandle> &facesOut) const override
-
void getEdgesOfVertex(VertexHandle handle, vector<EdgeHandle> &edgesOut) const override
-
void getNeighboursOfVertex(VertexHandle handle, vector<VertexHandle> &verticesOut) const override
-
virtual OptionalFaceHandle getOppositeFace(FaceHandle faceH, VertexHandle vertexH) const override
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 override
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 override
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 override
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 override
Returns an iterator to the element following the last vertex of this mesh.
-
virtual MeshHandleIteratorPtr<FaceHandle> facesBegin() const override
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 override
Returns an iterator to the element following the last face of this mesh.
-
virtual MeshHandleIteratorPtr<EdgeHandle> edgesBegin() const override
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 override
Returns an iterator to the element following the last edge of this mesh.
-
VertexSplitResult splitVertex(VertexHandle vertexToBeSplitH)
-
EdgeSplitResult splitEdge(EdgeHandle edgeH)
-
void fillHoles(size_t maxSize, bool simple = true)
Fill holes smaller than maxSize.
- Parameters:
maxSize – the maximum number of vertices around a hole. Bigger holes are ignored
simple – true: simple but fast algorithm, false: more complex but slower algorithm
-
void laplacianSmoothing(float smoothFactor = 0.5, int numSmooths = 1, bool useUniformLaplace = true)
Performs Laplacian Smoothing.
- Parameters:
smoothFactor – value between [0..1]. Used to determine the strength of each smoothing step. (usually 0.5)
numSmooths – number of smoothing steps to perform.
useUniformLaplace – true: use uniform weights (faster), false: use cotan weights (better quality)
-
vector<VertexHandle> findCommonNeigbours(VertexHandle vH1, VertexHandle vH2)
-
void splitVertex(EdgeHandle eH, VertexHandle vH, pmp::Point pos1, pmp::Point pos2)
-
std::pair<BaseVecT, float> triCircumCenter(FaceHandle faceH)
-
void simplify(size_t targetNumVertices)
Decimates the Mesh with repeated Edge Collapses until the target number of vertices is reached.
- Parameters:
targetNumVertices – the target number of vertices
-
inline void collectGarbage()
Gets rid of deleted vertices, edges and faces.
The remaining vertices, edges and faces might have their indices changed, so any external structures that use those indices must be updated manually.
Does nothing if there are no deleted vertices, edges or faces.
-
inline bool hasGarbage() const
-
inline pmp::SurfaceMesh &getSurfaceMesh()
-
inline const pmp::SurfaceMesh &getSurfaceMesh() const
-
void getFacesOfVertex(VertexHandle handle, std::vector<FaceHandle> &facesOut) const = 0
Get a list of faces the given vertex belongs to.
The face handles are written into the
facesOutvector. This is done to reduce the number of heap allocations if this method is called in a loop. If you are not calling it in a loop or can’t, for some reason, take advantages of this method’s signature, you can call the other overload of this method which just returns the vector. Such convinient.Note: you probably should remember to
clear()the vector before passing it into this method.- Parameters:
facesOut – The handles of the faces around
handlewill be written into this vector in clockwise order.
-
std::vector<FaceHandle> getFacesOfVertex(VertexHandle handle) const
Get a list of faces the given vertex belongs to.
This method is implemented using the pure virtual method
getFacesOfVertex(VertexHandle, vector<FaceHandle>&). If you are calling this method in a loop, you should probably call the more manual method (with the out vector) to avoid useless heap allocations.- Returns:
The face-handles in counter-clockwise order.
-
void getEdgesOfVertex(VertexHandle handle, std::vector<EdgeHandle> &edgesOut) const = 0
Get a list of edges around the given vertex.
The face handles are written into the
edgesOutvector. This is done to reduce the number of heap allocations if this method is called in a loop. If you are not calling it in a loop or can’t, for some reason, take advantages of this method’s signature, you can call the other overload of this method which just returns the vector. Such convenient.Note: you probably should remember to
clear()the vector before passing it into this method.- Parameters:
edgesOut – The handles of the edges around
handlewill be written into this vector in clockwise order.
-
std::vector<EdgeHandle> getEdgesOfVertex(VertexHandle handle) const
Get a list of edges around the given vertex.
This method is implemented using the pure virtual method
getEdgesOfVertex(VertexHandle, vector<EdgeHandle>&). If you are calling this method in a loop, you should probably call the more manual method (with the out vector) to avoid useless heap allocations.- Returns:
The edge-handles in counter-clockwise order.
-
void getNeighboursOfVertex(VertexHandle handle, std::vector<VertexHandle> &verticesOut) const = 0
Get vertex handles of the neighbours of the requested vertex.
The vertex handles are written into the
verticesOutvector. This is done to reduce the number of heap allocations if this method is called in a loop. If you are not calling it in a loop or can’t, for some reason, take advantages of this method’s signature, you can call the other overload of this method which just returns the vector. Such convenient.Note: you probably should remember to
clear()the vector before passing it into this method.- Parameters:
verticesOut – The vertex-handles of the neighbours of
handlewill be written into this vector in clockwise order.
-
std::vector<VertexHandle> getNeighboursOfVertex(VertexHandle handle) const
Get a list of vertices around the given vertex.
This method is implemented using the pure virtual method
getNeighboursOfVertex(VertexHandle, vector<EdgeHandle>&). If you are calling this method in a loop, you should probably call the more manual method (with the out vector) to avoid useless heap allocations.- Returns:
The vertex-handles in clockwise order.
-
inline PMPMesh()