Easy3D 2.6.1
Loading...
Searching...
No Matches
PolyMesh Class Reference

Data structure representing a polyhedral mesh. More...

#include <easy3d/core/poly_mesh.h>

Inheritance diagram for PolyMesh:
Model

Classes

class  BaseHandle
 Base class for all topology types (internally it is basically an index). More...
 
struct  Cell
 
struct  CellConnectivity
 
class  CellContainer
 This helper class is a container for iterating through all cells using C++11 range-based for-loops. More...
 
class  CellIterator
 Cell iterator for PolyMesh. This class iterates linearly over all cells. More...
 
class  CellProperty
 Cell property of type T. More...
 
struct  Edge
 
struct  EdgeConnectivity
 
class  EdgeContainer
 This helper class is a container for iterating through all edges using C++11 range-based for-loops. More...
 
class  EdgeIterator
 Edge iterator for PolyMesh. This class iterates linearly over all edges. More...
 
class  EdgeProperty
 Edge property of type T. More...
 
struct  Face
 
class  FaceContainer
 This helper class is a container for iterating through all faces using C++11 range-based for-loops. More...
 
class  FaceIterator
 Face iterator for PolyMesh. This class iterates linearly over all faces. More...
 
class  FaceProperty
 Face property of type T. More...
 
struct  HalfFace
 
struct  HalfFaceConnectivity
 
class  HalffaceContainer
 This helper class is a container for iterating through all halffaces using C++11 range-based for-loops. More...
 
class  HalfFaceIterator
 HalfFace iterator for PolyMesh. This class iterates linearly over all halffaces. More...
 
class  HalfFaceProperty
 HalfFace property of type T. More...
 
class  ModelProperty
 Model property of type T. More...
 
struct  Vertex
 
struct  VertexConnectivity
 
class  VertexContainer
 This helper class is a container for iterating through all vertices using C++11 range-based for-loops. More...
 
class  VertexIterator
 Vertex iterator for PolyMesh. This class iterates linearly over all vertices. More...
 
class  VertexProperty
 Vertex property of type T. More...
 

Public Member Functions

Construct, destruct, assignment
 PolyMesh ()
 Default constructor.
 
 ~PolyMesh () override=default
 Destructor.
 
 PolyMesh (const PolyMesh &rhs)
 Copy constructor: copies rhs to *this. Performs a deep copy of all properties.
 
PolyMeshoperator= (const PolyMesh &rhs)
 Assign rhs to *this. Performs a deep copy of all properties.
 
PolyMeshassign (const PolyMesh &rhs)
 Assign rhs to *this. Does not copy custom properties.
 
File IO
bool read (const std::string &filename)
 Read mesh from a PM file filename.
 
bool write (const std::string &filename) const
 Write mesh to a PM file filename.
 
Add new elements by hand
Vertex add_vertex (const vec3 &p)
 Add a new vertex.
 
Cell add_cell (const std::vector< HalfFace > &faces)
 Add a new cell defined by faces.
 
Cell add_tetra (HalfFace f0, HalfFace f1, HalfFace f2, HalfFace f3)
 Add a new tetrahedron defined by its faces.
 
Cell add_tetra (Vertex v0, Vertex v1, Vertex v2, Vertex v3)
 Add a new tetrahedron connecting vertices v0, v1, v2, v3.
 
Cell add_hexa (Vertex v0, Vertex v1, Vertex v2, Vertex v3, Vertex v4, Vertex v5, Vertex v6, Vertex v7)
 Add a new hexahedron connecting vertices v0, v1, v2, v3, v4, v5, v6, v7.
 
HalfFace add_face (const std::vector< Vertex > &vertices)
 Add a new face connecting vertices.
 
HalfFace add_triangle (Vertex v0, Vertex v1, Vertex v2)
 Add a new triangle face connecting vertices v0, v1, v2.
 
HalfFace add_quad (Vertex v0, Vertex v1, Vertex v2, Vertex v3)
 Add a new quad face connecting vertices v0, v1, v2, v3.
 
Memory Management
unsigned int n_vertices () const
 Returns number of vertices in the mesh.
 
unsigned int n_edges () const
 Returns number of edges in the mesh.
 
unsigned int n_halffaces () const
 Returns number of halffaces in the mesh.
 
unsigned int n_faces () const
 Returns number of faces in the mesh.
 
unsigned int n_cells () const
 Returns number of cells in the mesh.
 
void clear ()
 Removes all vertices, edges, halffaces, faces, cells and properties.
 
void resize (unsigned int nv, unsigned int ne, unsigned int nf, unsigned int nc)
 Resizes space for vertices, edges, halffaces, and their currently associated properties.
 
bool is_valid (Vertex v) const
 Return whether vertex v is valid, i.e. the index is stored within the array bounds.
 
bool is_valid (Edge e) const
 Return whether edge e is valid, i.e. the index is stored within the array bounds.
 
bool is_valid (HalfFace h) const
 Return whether halfface h is valid, i.e. the index is stored within the array bounds.
 
bool is_valid (Face f) const
 Return whether face f is valid, i.e. the index is stored within the array bounds.
 
bool is_valid (Cell c) const
 Return whether cell c is valid, i.e. the index is stored within the array bounds.
 
Property handling
template<class T>
VertexProperty< T > add_vertex_property (const std::string &name, const T t=T())
 Add a vertex property of type T with name name and default value t.
 
template<class T>
EdgeProperty< T > add_edge_property (const std::string &name, const T t=T())
 Add an edge property of type T with name name and default value t.
 
template<class T>
HalfFaceProperty< T > add_halfface_property (const std::string &name, const T t=T())
 Add a halfface property of type T with name name and default value t.
 
template<class T>
FaceProperty< T > add_face_property (const std::string &name, const T t=T())
 Add a face property of type T with name name and default value t.
 
template<class T>
CellProperty< T > add_cell_property (const std::string &name, const T t=T())
 Add a cell property of type T with name name and default value t.
 
template<class T>
ModelProperty< T > add_model_property (const std::string &name, const T t=T())
 Adds a model property of type T with name name and default value t.
 
template<class T>
VertexProperty< T > get_vertex_property (const std::string &name) const
 Get the vertex property with name name of type T.
 
template<class T>
EdgeProperty< T > get_edge_property (const std::string &name) const
 Get the edge property with name name of type T.
 
template<class T>
HalfFaceProperty< T > get_halfface_property (const std::string &name) const
 Get the halfface property with name name of type T.
 
template<class T>
FaceProperty< T > get_face_property (const std::string &name) const
 Get the face property with name name of type T.
 
template<class T>
CellProperty< T > get_cell_property (const std::string &name) const
 Get the cell property with name name of type T.
 
template<class T>
ModelProperty< T > get_model_property (const std::string &name) const
 Gets the model property named name of type T.
 
template<class T>
VertexProperty< T > vertex_property (const std::string &name, const T t=T())
 If a vertex property of type T with name name exists, it is returned. Otherwise, this property is added with default value t.
 
template<class T>
EdgeProperty< T > edge_property (const std::string &name, const T t=T())
 If an edge property of type T with name name exists, it is returned. Otherwise, this property is added with default value t.
 
template<class T>
HalfFaceProperty< T > halfface_property (const std::string &name, const T t=T())
 If a halfface property of type T with name name exists, it is returned. Otherwise, this property is added with default value t.
 
template<class T>
FaceProperty< T > face_property (const std::string &name, const T t=T())
 If a face property of type T with name name exists, it is returned. Otherwise, this property is added with default value t.
 
template<class T>
CellProperty< T > cell_property (const std::string &name, const T t=T())
 If a cell property of type T with name name exists, it is returned. Otherwise, this property is added with default value t.
 
template<class T>
ModelProperty< T > model_property (const std::string &name, const T t=T())
 If a model property of type T with name name exists, it is returned. Otherwise, this property is added with default value t.
 
template<class T>
bool remove_vertex_property (VertexProperty< T > &p)
 Remove the vertex property p.
 
bool remove_vertex_property (const std::string &n)
 Remove the vertex property named n.
 
template<class T>
bool remove_edge_property (EdgeProperty< T > &p)
 Remove the edge property p.
 
bool remove_edge_property (const std::string &n)
 Remove the edge property named n.
 
template<class T>
bool remove_halfface_property (HalfFaceProperty< T > &p)
 Remove the halfface property p.
 
bool remove_halfface_property (const std::string &n)
 Remove the halfface property named n.
 
template<class T>
bool remove_face_property (FaceProperty< T > &p)
 Remove the face property p.
 
bool remove_face_property (const std::string &n)
 Remove the face property named n.
 
template<class T>
bool remove_cell_property (CellProperty< T > &p)
 Remove the cell property p.
 
bool remove_cell_property (const std::string &n)
 Remove the cell property named n.
 
template<class T>
bool remove_model_property (ModelProperty< T > &p)
 Remove the model property p.
 
bool remove_model_property (const std::string &n)
 Remove the model property named n.
 
bool rename_vertex_property (const std::string &old_name, const std::string &new_name)
 Rename a vertex property given its name.
 
bool rename_halfface_property (const std::string &old_name, const std::string &new_name)
 Rename a halfface property given its name.
 
bool rename_face_property (const std::string &old_name, const std::string &new_name)
 Rename a face property given its name.
 
bool rename_edge_property (const std::string &old_name, const std::string &new_name)
 Rename an edge property given its name.
 
bool rename_cell_property (const std::string &old_name, const std::string &new_name)
 Rename a cell property given its name.
 
bool rename_model_property (const std::string &old_name, const std::string &new_name)
 Rename a model property given its name.
 
const std::type_info & get_vertex_property_type (const std::string &name) const
 Get the type information of the vertex property name.
 
const std::type_info & get_edge_property_type (const std::string &name) const
 Get the type information of the edge property name.
 
const std::type_info & get_halfface_property_type (const std::string &name) const
 Get the type information of the halfface property name.
 
const std::type_info & get_face_property_type (const std::string &name) const
 Get the type information of the face property name.
 
const std::type_info & get_cell_property_type (const std::string &name) const
 Get the type information of the cell property name.
 
const std::type_info & get_model_property_type (const std::string &name) const
 Get the type information of the model property name.
 
std::vector< std::string > vertex_properties () const
 Get the names of all vertex properties.
 
std::vector< std::string > edge_properties () const
 Get the names of all edge properties.
 
std::vector< std::string > halfface_properties () const
 Get the names of all halfface properties.
 
std::vector< std::string > face_properties () const
 Get the names of all face properties.
 
std::vector< std::string > cell_properties () const
 Get the names of all cell properties.
 
std::vector< std::string > model_properties () const
 Get the names of all model properties.
 
void property_stats (std::ostream &output) const override
 Prints the names of all properties to an output stream (e.g., std::cout).
 
Iterators & Circulators
VertexIterator vertices_begin () const
 Returns an iterator to the beginning of the vertices.
 
VertexIterator vertices_end () const
 Returns an iterator to the end of the vertices.
 
VertexContainer vertices () const
 Returns a container for range-based iteration over vertices.
 
EdgeIterator edges_begin () const
 Returns an iterator to the beginning of the edges.
 
EdgeIterator edges_end () const
 Returns an iterator to the end of the edges.
 
EdgeContainer edges () const
 Returns a container for range-based iteration over edges.
 
HalfFaceIterator halffaces_begin () const
 Returns an iterator to the beginning of the halffaces.
 
HalfFaceIterator halffaces_end () const
 Returns an iterator to the end of the halffaces.
 
HalffaceContainer halffaces () const
 Returns a container for range-based iteration over halffaces.
 
FaceIterator faces_begin () const
 Returns an iterator to the beginning of the faces.
 
FaceIterator faces_end () const
 Returns an iterator to the end of the faces.
 
FaceContainer faces () const
 Returns a container for range-based iteration over faces.
 
CellIterator cells_begin () const
 Returns an iterator to the beginning of the cells.
 
CellIterator cells_end () const
 Returns an iterator to the end of the cells.
 
CellContainer cells () const
 Returns a container for range-based iteration over cells.
 
Adjacency access
const std::set< Vertex > & vertices (Vertex v) const
 Returns the vertices around vertex v.
 
HalfFace halfface (Face f, unsigned int i) const
 Returns the i'th halfface of face f. i has to be 0 or 1.
 
Face face (HalfFace h) const
 Returns the face of HalfFace h.
 
HalfFace opposite (HalfFace h) const
 Returns the twin halfface of halfface h.
 
Vertex vertex (Edge e, unsigned int i) const
 Returns the i'th vertex of edge e. i has to be 0 or 1.
 
const std::vector< Vertex > & vertices (HalfFace h) const
 Returns the set of vertices around halfface h. The vertices are ordered in a way such that its normal points outside of the cell associated with h.
 
const std::vector< Vertex > & vertices (Face f) const
 Returns the set of vertices around face f.
 
const std::set< Vertex > & vertices (Cell c) const
 Returns the set of vertices around cell c.
 
const std::set< Edge > & edges (Vertex v) const
 Returns the set of edges around vertex v.
 
const std::set< Edge > & edges (HalfFace h) const
 Returns the set of edges around halfface h.
 
const std::set< Edge > & edges (Cell c) const
 Returns the set of edges around cell c.
 
const std::set< HalfFace > & halffaces (Vertex v) const
 Returns the set of halffaces around vertex v.
 
const std::set< HalfFace > & halffaces (Edge e) const
 Returns the set of halffaces around edge e.
 
const std::vector< HalfFace > & halffaces (Cell c) const
 Returns the set of halffaces around cell c.
 
const std::set< Cell > & cells (Vertex v) const
 Returns the set of cells around vertex v.
 
const std::set< Cell > & cells (Edge e) const
 Returns the set of cells around edge e.
 
Cell cell (HalfFace h) const
 Returns the cell associated with halfface h.
 
Higher-level Topological Operations
bool is_tetraheral_mesh () const
 Returns whether the mesh is a tetrahedral mesh, i.e., every cell is a tetrahedron.
 
bool is_border (Vertex v) const
 Returns whether v is a boundary vertex, i.e., at least one of its incident halffaces is not associated with a cell.
 
bool is_border (Edge e) const
 Returns whether e is a boundary edge, i.e., at least one of its incident halffaces is not associated with a cell.
 
bool is_border (HalfFace h) const
 Returns whether h is a boundary halfface, i.e., it is not associated with a cell.
 
bool is_border (Face f) const
 Returns whether f is a boundary face, i.e., it is incident to only one cell.
 
Edge find_edge (Vertex a, Vertex b) const
 
HalfFace find_half_face (const std::vector< Vertex > &vertices) const
 
bool is_degenerate (Face f) const
 Returns whether face f is degenerate, i.e., if it has collinear or coincident vertices.
 
void extract_boundary (std::vector< std::vector< Vertex > > &faces) const
 
- Public Member Functions inherited from Model
 Model (const std::string &name="unknown")
 Default constructor. The parameter name is optional, but it is useful for handling multiple models with the same viewer.
 
void set_name (const std::string &n)
 Sets/Changes the name of a model. Assigning a name to a model is optional, but it is useful for handling multiple models with the same viewer.
 
const std::string & name () const
 The name of a model.
 
const Box3bounding_box (bool recompute=false) const
 The bounding box of the model.
 
void invalidate_bounding_box ()
 Invalidates the bounding box of the model. So when bounding_box() is called, the bounding box will be re-computed. This function is typically called when the geometry of a model is changed.
 
bool empty () const
 Tests if the model is empty.
 
void set_renderer (std::shared_ptr< Renderer > r)
 Sets the renderer of this model.
 
Rendererrenderer ()
 Gets the renderer of this model.
 
const Rendererrenderer () const
 Gets the constant renderer of this model.
 
void set_manipulator (std::shared_ptr< Manipulator > manip)
 Attaches a manipulator to this model.
 
Manipulatormanipulator ()
 Gets the manipulator attached to this model.
 
const Manipulatormanipulator () const
 Gets the manipulator attached to this model.
 

Geometry-related Functions

const vec3position (Vertex v) const
 Returns the position of a vertex.
 
const std::vector< vec3 > & points () const override
 Returns a read-only vector of all vertex positions.
 
std::vector< vec3 > & points () override
 Returns a modifiable vector of all vertex positions.
 
void update_face_normals ()
 Computes face normals by calling compute_face_normal(HalfFace) for each face.
 
vec3 compute_face_normal (Face f) const
 Computes the normal vector of face f.
 
void update_vertex_normals ()
 Computes vertex normals for each vertex.
 
float edge_length (Edge e) const
 Computes the length of edge e.
 

Detailed Description

Data structure representing a polyhedral mesh.

Note
PolyMesh assumes the half-face normals pointing outside the cells.

This implementation is inspired by Surface_mesh https://opensource.cit-ec.de/projects/surface_mesh

Examples
Tutorial_112_PolyMesh/main.cpp, Tutorial_113_PolyMesh_Connectivity/main.cpp, Tutorial_114_PolyMesh_Property/main.cpp, and Tutorial_115_PolyMesh_IO/main.cpp.

Constructor & Destructor Documentation

◆ PolyMesh()

PolyMesh ( const PolyMesh & rhs)
inline

Copy constructor: copies rhs to *this. Performs a deep copy of all properties.

Parameters
rhsThe PolyMesh to copy from.

Member Function Documentation

◆ add_cell()

PolyMesh::Cell add_cell ( const std::vector< HalfFace > & faces)

Add a new cell defined by faces.

Parameters
facesThe input faces created by add_face(), add_triangle(), or add_quad().
Returns
The new cell.
See also
add_face(), add_triangle(), add_quad(), add_tetra(), add_hexa()

◆ add_cell_property()

template<class T>
CellProperty< T > add_cell_property ( const std::string & name,
const T t = T() )
inline

Add a cell property of type T with name name and default value t.

Parameters
nameThe name of the property.
tThe default value of the property.
Returns
The new cell property.

Fails if a property named name exists already, since the name has to be unique. In this case, it returns an invalid property.

◆ add_edge_property()

template<class T>
EdgeProperty< T > add_edge_property ( const std::string & name,
const T t = T() )
inline

Add an edge property of type T with name name and default value t.

Parameters
nameThe name of the property.
tThe default value of the property.
Returns
The new edge property.

Fails if a property named name exists already, since the name has to be unique. In this case, it returns an invalid property.

◆ add_face()

PolyMesh::HalfFace add_face ( const std::vector< Vertex > & vertices)

Add a new face connecting vertices.

Parameters
verticesThe input vertices created by add_vertex().
Returns
The new halfface.
See also
add_triangle(), add_quad()

◆ add_face_property()

template<class T>
FaceProperty< T > add_face_property ( const std::string & name,
const T t = T() )
inline

Add a face property of type T with name name and default value t.

Parameters
nameThe name of the property.
tThe default value of the property.
Returns
The new face property.

Fails if a property named name exists already, since the name has to be unique. In this case, it returns an invalid property.

◆ add_halfface_property()

template<class T>
HalfFaceProperty< T > add_halfface_property ( const std::string & name,
const T t = T() )
inline

Add a halfface property of type T with name name and default value t.

Parameters
nameThe name of the property.
tThe default value of the property.
Returns
The new halfface property.

Fails if a property named name exists already, since the name has to be unique. In this case, it returns an invalid property.

◆ add_hexa()

PolyMesh::Cell add_hexa ( Vertex v0,
Vertex v1,
Vertex v2,
Vertex v3,
Vertex v4,
Vertex v5,
Vertex v6,
Vertex v7 )

Add a new hexahedron connecting vertices v0, v1, v2, v3, v4, v5, v6, v7.

Parameters
v0The first vertex created by add_vertex().
v1The second vertex created by add_vertex().
v2The third vertex created by add_vertex().
v3The fourth vertex created by add_vertex().
v4The fifth vertex created by add_vertex().
v5The sixth vertex created by add_vertex().
v6The seventh vertex created by add_vertex().
v7The eighth vertex created by add_vertex().
Returns
The new cell.

This function creates all the faces and the cell, and adds them to the mesh. The vertices must be ordered as below: 3-----------------—2 |\ |\ | \ | \ | \ | \ | 7-------------—+—6 | | | | 0—+-------------—1 | \ | \ | \ | \ | | | 4-----------------—5

See also
add_vertex()

◆ add_model_property()

template<class T>
ModelProperty< T > add_model_property ( const std::string & name,
const T t = T() )
inline

Adds a model property of type T with name name and default value t.

Parameters
nameThe name of the property.
tThe default value of the property.

Fails if a property named name exists already, since the name has to be unique. In this case it returns an invalid property. Example:

auto trans = cloud->add_model_property<mat4>("transformation", mat4::identity());
trans[0] = mat4::translation(-x0, -y0, -z0);
static Mat4< float > translation(const Vec< 3, float > &t)
static Mat< N, M, T > identity()
Returns an identity matrix.
Definition mat.h:697
Mat4< float > mat4
A 4 by 4 matrix of float type.
Definition types.h:67

◆ add_quad()

HalfFace add_quad ( Vertex v0,
Vertex v1,
Vertex v2,
Vertex v3 )
inline

Add a new quad face connecting vertices v0, v1, v2, v3.

Parameters
v0The first vertex created by add_vertex().
v1The second vertex created by add_vertex().
v2The third vertex created by add_vertex().
v3The fourth vertex created by add_vertex().
Returns
The new halfface.
See also
add_face(), add_triangle()

◆ add_tetra() [1/2]

Cell add_tetra ( HalfFace f0,
HalfFace f1,
HalfFace f2,
HalfFace f3 )
inline

Add a new tetrahedron defined by its faces.

Parameters
f0The first face created by add_face() or add_triangle().
f1The second face created by add_face() or add_triangle().
f2The third face created by add_face() or add_triangle().
f3The fourth face created by add_face() or add_triangle().
Returns
The new cell.
See also
add_cell(), add_tetra(), add_face(), add_triangle().

◆ add_tetra() [2/2]

PolyMesh::Cell add_tetra ( Vertex v0,
Vertex v1,
Vertex v2,
Vertex v3 )

Add a new tetrahedron connecting vertices v0, v1, v2, v3.

Parameters
v0The first vertex created by add_vertex().
v1The second vertex created by add_vertex().
v2The third vertex created by add_vertex().
v3The fourth vertex created by add_vertex().
Returns
The new cell.

It creates all the faces and the cell, and adds them to the mesh.

See also
add_vertex()

◆ add_triangle()

HalfFace add_triangle ( Vertex v0,
Vertex v1,
Vertex v2 )
inline

Add a new triangle face connecting vertices v0, v1, v2.

Parameters
v0The first vertex created by add_vertex().
v1The second vertex created by add_vertex().
v2The third vertex created by add_vertex().
Returns
The new halfface.
See also
add_face(), add_quad()

◆ add_vertex()

Vertex add_vertex ( const vec3 & p)
inline

Add a new vertex.

Parameters
pThe position of the new vertex
Returns
The new vertex

◆ add_vertex_property()

template<class T>
VertexProperty< T > add_vertex_property ( const std::string & name,
const T t = T() )
inline

Add a vertex property of type T with name name and default value t.

Parameters
nameThe name of the property.
tThe default value of the property.
Returns
The new vertex property.

Fails if a property named name exists already, since the name has to be unique. In this case, it returns an invalid property.

◆ assign()

PolyMesh & assign ( const PolyMesh & rhs)

Assign rhs to *this. Does not copy custom properties.

Parameters
rhsThe PolyMesh to assign from.
Returns
Reference to the assigned PolyMesh.

◆ cell()

Cell cell ( HalfFace h) const
inline

Returns the cell associated with halfface h.

Parameters
hThe HalfFace.
Returns
The associated Cell.

◆ cell_properties()

std::vector< std::string > cell_properties ( ) const
inline

Get the names of all cell properties.

Returns
A vector containing the names of all cell properties.

◆ cell_property()

template<class T>
CellProperty< T > cell_property ( const std::string & name,
const T t = T() )
inline

If a cell property of type T with name name exists, it is returned. Otherwise, this property is added with default value t.

Parameters
nameThe name of the property to get.
tThe default value of the property.
Returns
The cell property. If the property does not exist, it is added with the default value t and returned.

◆ cells() [1/3]

CellContainer cells ( ) const
inline

Returns a container for range-based iteration over cells.

Returns
CellContainer containing all cells.

◆ cells() [2/3]

const std::set< Cell > & cells ( Edge e) const
inline

Returns the set of cells around edge e.

Parameters
eThe Edge.
Returns
A set of cells.

◆ cells() [3/3]

const std::set< Cell > & cells ( Vertex v) const
inline

Returns the set of cells around vertex v.

Parameters
vThe Vertex.
Returns
A set of cells.

◆ cells_begin()

CellIterator cells_begin ( ) const
inline

Returns an iterator to the beginning of the cells.

Returns
CellIterator pointing to the first cell.

◆ cells_end()

CellIterator cells_end ( ) const
inline

Returns an iterator to the end of the cells.

Returns
CellIterator pointing past the last cell.

◆ clear()

void clear ( )

Removes all vertices, edges, halffaces, faces, cells and properties.

After calling this method, the mesh is the same as newly constructed. The additional properties (such as normal vectors) are also removed and must thus be re-added if needed.

◆ compute_face_normal()

vec3 compute_face_normal ( Face f) const

Computes the normal vector of face f.

Parameters
fThe Face.
Returns
The normal vector of the face.

◆ edge_length()

float edge_length ( Edge e) const

Computes the length of edge e.

Parameters
eThe Edge.
Returns
The length of the edge.

◆ edge_properties()

std::vector< std::string > edge_properties ( ) const
inline

Get the names of all edge properties.

Returns
A vector containing the names of all edge properties.

◆ edge_property()

template<class T>
EdgeProperty< T > edge_property ( const std::string & name,
const T t = T() )
inline

If an edge property of type T with name name exists, it is returned. Otherwise, this property is added with default value t.

Parameters
nameThe name of the property to get.
tThe default value of the property.
Returns
The edge property. If the property does not exist, it is added with the default value t and returned.

◆ edges() [1/4]

EdgeContainer edges ( ) const
inline

Returns a container for range-based iteration over edges.

Returns
EdgeContainer containing all edges.

◆ edges() [2/4]

const std::set< Edge > & edges ( Cell c) const
inline

Returns the set of edges around cell c.

Parameters
cThe Cell.
Returns
A set of edges.

◆ edges() [3/4]

const std::set< Edge > & edges ( HalfFace h) const
inline

Returns the set of edges around halfface h.

Parameters
hThe HalfFace.
Returns
A set of edges.

◆ edges() [4/4]

const std::set< Edge > & edges ( Vertex v) const
inline

Returns the set of edges around vertex v.

Parameters
vThe Vertex.
Returns
A set of edges.

◆ edges_begin()

EdgeIterator edges_begin ( ) const
inline

Returns an iterator to the beginning of the edges.

Returns
EdgeIterator pointing to the first edge.

◆ edges_end()

EdgeIterator edges_end ( ) const
inline

Returns an iterator to the end of the edges.

Returns
EdgeIterator pointing past the last edge.

◆ extract_boundary()

void extract_boundary ( std::vector< std::vector< Vertex > > & faces) const

Extracts the boundary surface and returns its faces.

Parameters
facesA reference to a vector of vertex sequences, each defining a boundary face.

◆ face()

Face face ( HalfFace h) const
inline

Returns the face of HalfFace h.

Parameters
hThe HalfFace.
Returns
The corresponding Face.

◆ face_properties()

std::vector< std::string > face_properties ( ) const
inline

Get the names of all face properties.

Returns
A vector containing the names of all face properties.

◆ face_property()

template<class T>
FaceProperty< T > face_property ( const std::string & name,
const T t = T() )
inline

If a face property of type T with name name exists, it is returned. Otherwise, this property is added with default value t.

Parameters
nameThe name of the property to get.
tThe default value of the property.
Returns
The face property. If the property does not exist, it is added with the default value t and returned.

◆ faces()

FaceContainer faces ( ) const
inline

Returns a container for range-based iteration over faces.

Returns
FaceContainer containing all faces.

◆ faces_begin()

FaceIterator faces_begin ( ) const
inline

Returns an iterator to the beginning of the faces.

Returns
FaceIterator pointing to the first face.

◆ faces_end()

FaceIterator faces_end ( ) const
inline

Returns an iterator to the end of the faces.

Returns
FaceIterator pointing past the last face.

◆ find_edge()

PolyMesh::Edge find_edge ( Vertex a,
Vertex b ) const

Finds the edge connecting vertices a and b.

Parameters
aThe first vertex.
bThe second vertex.
Returns
The edge (a, b), if it exists.

◆ find_half_face()

PolyMesh::HalfFace find_half_face ( const std::vector< Vertex > & vertices) const

Finds the halfface defined by a sequence of vertices (orientation sensitive).

Parameters
verticesThe ordered sequence of vertices defining the halfface.
Returns
The corresponding HalfFace, if it exists.

◆ get_cell_property()

template<class T>
CellProperty< T > get_cell_property ( const std::string & name) const
inline

Get the cell property with name name of type T.

Parameters
nameThe name of the property to get.
Returns
The cell property. An invalid CellProperty will be returned if the property does not exist or if the type does not match.

◆ get_cell_property_type()

const std::type_info & get_cell_property_type ( const std::string & name) const
inline

Get the type information of the cell property name.

Parameters
nameThe name of the property.
Returns
The type information of the property. Returns typeid(void) if the property does not exist.

◆ get_edge_property()

template<class T>
EdgeProperty< T > get_edge_property ( const std::string & name) const
inline

Get the edge property with name name of type T.

Parameters
nameThe name of the property to get.
Returns
The edge property. An invalid EdgeProperty will be returned if the property does not exist or if the type does not match.

◆ get_edge_property_type()

const std::type_info & get_edge_property_type ( const std::string & name) const
inline

Get the type information of the edge property name.

Parameters
nameThe name of the property.
Returns
The type information of the property. Returns typeid(void) if the property does not exist.

◆ get_face_property()

template<class T>
FaceProperty< T > get_face_property ( const std::string & name) const
inline

Get the face property with name name of type T.

Parameters
nameThe name of the property to get.
Returns
The face property. An invalid FaceProperty will be returned if the property does not exist or if the type does not match.

◆ get_face_property_type()

const std::type_info & get_face_property_type ( const std::string & name) const
inline

Get the type information of the face property name.

Parameters
nameThe name of the property.
Returns
The type information of the property. Returns typeid(void) if the property does not exist.

◆ get_halfface_property()

template<class T>
HalfFaceProperty< T > get_halfface_property ( const std::string & name) const
inline

Get the halfface property with name name of type T.

Parameters
nameThe name of the property to get.
Returns
The halfface property. An invalid HalfFaceProperty will be returned if the property does not exist or if the type does not match.

◆ get_halfface_property_type()

const std::type_info & get_halfface_property_type ( const std::string & name) const
inline

Get the type information of the halfface property name.

Parameters
nameThe name of the property.
Returns
The type information of the property. Returns typeid(void) if the property does not exist.

◆ get_model_property()

template<class T>
ModelProperty< T > get_model_property ( const std::string & name) const
inline

Gets the model property named name of type T.

Parameters
nameThe name of the property to get.
Returns
The model property. An invalid ModelProperty will be returned if the property does not exist or if the type does not match. Example:
auto T = cloud->get_model_property<mat4>("transformation");
T[0] = mat4::translation(-x0, -y0, -z0);

◆ get_model_property_type()

const std::type_info & get_model_property_type ( const std::string & name) const
inline

Get the type information of the model property name.

Parameters
nameThe name of the property.
Returns
The type information of the property. Returns typeid(void) if the property does not exist.

◆ get_vertex_property()

template<class T>
VertexProperty< T > get_vertex_property ( const std::string & name) const
inline

Get the vertex property with name name of type T.

Parameters
nameThe name of the property to get.
Returns
The vertex property. An invalid VertexProperty will be returned if the property does not exist or if the type does not match.

◆ get_vertex_property_type()

const std::type_info & get_vertex_property_type ( const std::string & name) const
inline

Get the type information of the vertex property name.

Parameters
nameThe name of the property.
Returns
The type information of the property. Returns typeid(void) if the property does not exist.

◆ halfface()

HalfFace halfface ( Face f,
unsigned int i ) const
inline

Returns the i'th halfface of face f. i has to be 0 or 1.

Parameters
fThe face.
iThe index (0 or 1).
Returns
The corresponding HalfFace.

◆ halfface_properties()

std::vector< std::string > halfface_properties ( ) const
inline

Get the names of all halfface properties.

Returns
A vector containing the names of all halfface properties.

◆ halfface_property()

template<class T>
HalfFaceProperty< T > halfface_property ( const std::string & name,
const T t = T() )
inline

If a halfface property of type T with name name exists, it is returned. Otherwise, this property is added with default value t.

Parameters
nameThe name of the property to get.
tThe default value of the property.
Returns
The halfface property. If the property does not exist, it is added with the default value t and returned.

◆ halffaces() [1/4]

HalffaceContainer halffaces ( ) const
inline

Returns a container for range-based iteration over halffaces.

Returns
HalffaceContainer containing all halffaces.

◆ halffaces() [2/4]

const std::vector< HalfFace > & halffaces ( Cell c) const
inline

Returns the set of halffaces around cell c.

Parameters
cThe Cell.
Returns
A vector of halffaces.

◆ halffaces() [3/4]

const std::set< HalfFace > & halffaces ( Edge e) const
inline

Returns the set of halffaces around edge e.

Parameters
eThe Edge.
Returns
A set of halffaces.

◆ halffaces() [4/4]

const std::set< HalfFace > & halffaces ( Vertex v) const
inline

Returns the set of halffaces around vertex v.

Parameters
vThe Vertex.
Returns
A set of halffaces.

◆ halffaces_begin()

HalfFaceIterator halffaces_begin ( ) const
inline

Returns an iterator to the beginning of the halffaces.

Returns
HalfFaceIterator pointing to the first halfface.

◆ halffaces_end()

HalfFaceIterator halffaces_end ( ) const
inline

Returns an iterator to the end of the halffaces.

Returns
HalfFaceIterator pointing past the last halfface.

◆ is_border() [1/4]

bool is_border ( Edge e) const
inline

Returns whether e is a boundary edge, i.e., at least one of its incident halffaces is not associated with a cell.

Parameters
eThe edge.
Returns
True if e is a boundary edge, false otherwise.

◆ is_border() [2/4]

bool is_border ( Face f) const
inline

Returns whether f is a boundary face, i.e., it is incident to only one cell.

Parameters
fThe Face.
Returns
True if f is a boundary face, false otherwise.

◆ is_border() [3/4]

bool is_border ( HalfFace h) const
inline

Returns whether h is a boundary halfface, i.e., it is not associated with a cell.

Parameters
hThe HalfFace.
Returns
True if h is a boundary halfface, false otherwise.

◆ is_border() [4/4]

bool is_border ( Vertex v) const
inline

Returns whether v is a boundary vertex, i.e., at least one of its incident halffaces is not associated with a cell.

Parameters
vThe vertex.
Returns
True if v is a boundary vertex, false otherwise.

◆ is_degenerate()

bool is_degenerate ( Face f) const

Returns whether face f is degenerate, i.e., if it has collinear or coincident vertices.

Parameters
fThe Face.
Returns
True if the face is degenerate, false otherwise.

◆ is_tetraheral_mesh()

bool is_tetraheral_mesh ( ) const

Returns whether the mesh is a tetrahedral mesh, i.e., every cell is a tetrahedron.

Returns
True if the mesh consists only of tetrahedral cells, false otherwise.

◆ is_valid() [1/5]

bool is_valid ( Cell c) const
inline

Return whether cell c is valid, i.e. the index is stored within the array bounds.

Parameters
cThe cell to check.
Returns
True if the cell is valid, false otherwise.

◆ is_valid() [2/5]

bool is_valid ( Edge e) const
inline

Return whether edge e is valid, i.e. the index is stored within the array bounds.

Parameters
eThe edge to check.
Returns
True if the edge is valid, false otherwise.

◆ is_valid() [3/5]

bool is_valid ( Face f) const
inline

Return whether face f is valid, i.e. the index is stored within the array bounds.

Parameters
fThe face to check.
Returns
True if the face is valid, false otherwise.

◆ is_valid() [4/5]

bool is_valid ( HalfFace h) const
inline

Return whether halfface h is valid, i.e. the index is stored within the array bounds.

Parameters
hThe halfface to check.
Returns
True if the halfface is valid, false otherwise.

◆ is_valid() [5/5]

bool is_valid ( Vertex v) const
inline

Return whether vertex v is valid, i.e. the index is stored within the array bounds.

Parameters
vThe vertex to check.
Returns
True if the vertex is valid, false otherwise.

◆ model_properties()

std::vector< std::string > model_properties ( ) const
inline

Get the names of all model properties.

Returns
A vector containing the names of all model properties.

◆ model_property()

template<class T>
ModelProperty< T > model_property ( const std::string & name,
const T t = T() )
inline

If a model property of type T with name name exists, it is returned. Otherwise, this property is added with default value t.

Parameters
nameThe name of the property to get.
tThe default value of the property.
Returns
The model property. If the property does not exist, it is added with the default value t and returned.

◆ n_cells()

unsigned int n_cells ( ) const
inline

Returns number of cells in the mesh.

Returns
The number of cells.

◆ n_edges()

unsigned int n_edges ( ) const
inline

Returns number of edges in the mesh.

Returns
The number of edges.

◆ n_faces()

unsigned int n_faces ( ) const
inline

Returns number of faces in the mesh.

Returns
The number of faces.

◆ n_halffaces()

unsigned int n_halffaces ( ) const
inline

Returns number of halffaces in the mesh.

Returns
The number of halffaces.

◆ n_vertices()

unsigned int n_vertices ( ) const
inline

Returns number of vertices in the mesh.

Returns
The number of vertices.

◆ operator=()

PolyMesh & operator= ( const PolyMesh & rhs)

Assign rhs to *this. Performs a deep copy of all properties.

Parameters
rhsThe PolyMesh to assign from.
Returns
Reference to the assigned PolyMesh.

◆ opposite()

HalfFace opposite ( HalfFace h) const
inline

Returns the twin halfface of halfface h.

Parameters
hThe HalfFace.
Returns
The opposite HalfFace.

◆ points() [1/2]

const std::vector< vec3 > & points ( ) const
inlineoverridevirtual

Returns a read-only vector of all vertex positions.

Returns
A constant reference to the vector of vertex positions.

Implements Model.

◆ points() [2/2]

std::vector< vec3 > & points ( )
inlineoverridevirtual

Returns a modifiable vector of all vertex positions.

Returns
A reference to the vector of vertex positions.

Implements Model.

◆ position()

const vec3 & position ( Vertex v) const
inline

Returns the position of a vertex.

Parameters
vThe vertex.
Returns
A reference to the 3D position vector.

◆ property_stats()

void property_stats ( std::ostream & output) const
overridevirtual

Prints the names of all properties to an output stream (e.g., std::cout).

Parameters
outputThe output stream.

Reimplemented from Model.

◆ read()

bool read ( const std::string & filename)

Read mesh from a PM file filename.

Mainly for quick debug purposes. Client code should use PolyMeshIO.

Parameters
filenameThe name of the file to read from.
Returns
True if the read was successful, false otherwise.
See also
PolyMeshIO.

◆ remove_cell_property() [1/2]

template<class T>
bool remove_cell_property ( CellProperty< T > & p)
inline

Remove the cell property p.

Parameters
pThe property to remove.
Returns
True if the property was removed, false otherwise.

◆ remove_cell_property() [2/2]

bool remove_cell_property ( const std::string & n)
inline

Remove the cell property named n.

Parameters
nThe name of the property to remove.
Returns
True if the property was removed, false otherwise.

◆ remove_edge_property() [1/2]

bool remove_edge_property ( const std::string & n)
inline

Remove the edge property named n.

Parameters
nThe name of the property to remove.
Returns
True if the property was removed, false otherwise.

◆ remove_edge_property() [2/2]

template<class T>
bool remove_edge_property ( EdgeProperty< T > & p)
inline

Remove the edge property p.

Parameters
pThe property to remove.
Returns
True if the property was removed, false otherwise.

◆ remove_face_property() [1/2]

bool remove_face_property ( const std::string & n)
inline

Remove the face property named n.

Parameters
nThe name of the property to remove.
Returns
True if the property was removed, false otherwise.

◆ remove_face_property() [2/2]

template<class T>
bool remove_face_property ( FaceProperty< T > & p)
inline

Remove the face property p.

Parameters
pThe property to remove.
Returns
True if the property was removed, false otherwise.

◆ remove_halfface_property() [1/2]

bool remove_halfface_property ( const std::string & n)
inline

Remove the halfface property named n.

Parameters
nThe name of the property to remove.
Returns
True if the property was removed, false otherwise.

◆ remove_halfface_property() [2/2]

template<class T>
bool remove_halfface_property ( HalfFaceProperty< T > & p)
inline

Remove the halfface property p.

Parameters
pThe property to remove.
Returns
True if the property was removed, false otherwise.

◆ remove_model_property() [1/2]

bool remove_model_property ( const std::string & n)
inline

Remove the model property named n.

Parameters
nThe name of the property to remove.
Returns
True if the property was removed, false otherwise.

◆ remove_model_property() [2/2]

template<class T>
bool remove_model_property ( ModelProperty< T > & p)
inline

Remove the model property p.

Parameters
pThe property to remove.
Returns
True if the property was removed, false otherwise.

◆ remove_vertex_property() [1/2]

bool remove_vertex_property ( const std::string & n)
inline

Remove the vertex property named n.

Parameters
nThe name of the property to remove.
Returns
True if the property was removed, false otherwise.

◆ remove_vertex_property() [2/2]

template<class T>
bool remove_vertex_property ( VertexProperty< T > & p)
inline

Remove the vertex property p.

Parameters
pThe property to remove.
Returns
True if the property was removed, false otherwise.

◆ rename_cell_property()

bool rename_cell_property ( const std::string & old_name,
const std::string & new_name )
inline

Rename a cell property given its name.

Parameters
old_nameThe old name of the property.
new_nameThe new name of the property.
Returns
True if the property was renamed, false otherwise.

◆ rename_edge_property()

bool rename_edge_property ( const std::string & old_name,
const std::string & new_name )
inline

Rename an edge property given its name.

Parameters
old_nameThe old name of the property.
new_nameThe new name of the property.
Returns
True if the property was renamed, false otherwise.

◆ rename_face_property()

bool rename_face_property ( const std::string & old_name,
const std::string & new_name )
inline

Rename a face property given its name.

Parameters
old_nameThe old name of the property.
new_nameThe new name of the property.
Returns
True if the property was renamed, false otherwise.

◆ rename_halfface_property()

bool rename_halfface_property ( const std::string & old_name,
const std::string & new_name )
inline

Rename a halfface property given its name.

Parameters
old_nameThe old name of the property.
new_nameThe new name of the property.
Returns
True if the property was renamed, false otherwise.

◆ rename_model_property()

bool rename_model_property ( const std::string & old_name,
const std::string & new_name )
inline

Rename a model property given its name.

Parameters
old_nameThe old name of the property.
new_nameThe new name of the property.
Returns
True if the property was renamed, false otherwise.

◆ rename_vertex_property()

bool rename_vertex_property ( const std::string & old_name,
const std::string & new_name )
inline

Rename a vertex property given its name.

Parameters
old_nameThe old name of the property.
new_nameThe new name of the property.
Returns
True if the property was renamed, false otherwise.

◆ resize()

void resize ( unsigned int nv,
unsigned int ne,
unsigned int nf,
unsigned int nc )
inline

Resizes space for vertices, edges, halffaces, and their currently associated properties.

Parameters
nvNumber of vertices.
neNumber of edges.
nfNumber of faces.
ncNumber of cells.

nf is the number of faces. For halffaces, nh = 2 * nf.

◆ update_vertex_normals()

void update_vertex_normals ( )

Computes vertex normals for each vertex.

Attention
For vertices on the border of the polyhedral mesh, the normals point outward. Interior vertices do not have well-defined normals. This method may be unstable for concave vertices or vertices with spanning angles close to 0 or 180 degrees.

◆ vertex()

Vertex vertex ( Edge e,
unsigned int i ) const
inline

Returns the i'th vertex of edge e. i has to be 0 or 1.

Parameters
eThe Edge.
iThe index (0 or 1).
Returns
The corresponding Vertex.

◆ vertex_properties()

std::vector< std::string > vertex_properties ( ) const
inline

Get the names of all vertex properties.

Returns
A vector containing the names of all vertex properties.

◆ vertex_property()

template<class T>
VertexProperty< T > vertex_property ( const std::string & name,
const T t = T() )
inline

If a vertex property of type T with name name exists, it is returned. Otherwise, this property is added with default value t.

Parameters
nameThe name of the property to get.
tThe default value of the property.
Returns
The vertex property. If the property does not exist, it is added with the default value t and returned.

◆ vertices() [1/5]

VertexContainer vertices ( ) const
inline

Returns a container for range-based iteration over vertices.

Returns
VertexContainer containing all vertices.

◆ vertices() [2/5]

const std::set< Vertex > & vertices ( Cell c) const
inline

Returns the set of vertices around cell c.

Parameters
cThe Cell.
Returns
A set of vertices.

◆ vertices() [3/5]

const std::vector< Vertex > & vertices ( Face f) const
inline

Returns the set of vertices around face f.

Parameters
fThe Face.
Returns
A vector of ordered vertices.

◆ vertices() [4/5]

const std::vector< Vertex > & vertices ( HalfFace h) const
inline

Returns the set of vertices around halfface h. The vertices are ordered in a way such that its normal points outside of the cell associated with h.

Parameters
hThe HalfFace.
Returns
A vector of ordered vertices.

◆ vertices() [5/5]

const std::set< Vertex > & vertices ( Vertex v) const
inline

Returns the vertices around vertex v.

Parameters
vThe vertex.
Returns
A set of adjacent vertices.

◆ vertices_begin()

VertexIterator vertices_begin ( ) const
inline

Returns an iterator to the beginning of the vertices.

Returns
VertexIterator pointing to the first vertex.

◆ vertices_end()

VertexIterator vertices_end ( ) const
inline

Returns an iterator to the end of the vertices.

Returns
VertexIterator pointing past the last vertex.

◆ write()

bool write ( const std::string & filename) const

Write mesh to a PM file filename.

Mainly for quick debug purposes. Client code should use PolyMeshIO.

Parameters
filenameThe name of the file to write to.
Returns
True if the write was successful, false otherwise.
See also
PolyMeshIO.

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