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

A halfedge data structure for polygonal meshes of 2-manifold. More...

#include <easy3d/core/surface_mesh.h>

Inheritance diagram for SurfaceMesh:
Model

Classes

class  BaseHandle
 Base class for all topology types (internally it is basically an index). More...
 
struct  Edge
 
class  EdgeContainer
 This helper class is a container for iterating through all edges using C++11 range-based for-loops. More...
 
class  EdgeIterator
 This class iterates linearly over all edges. More...
 
class  EdgeProperty
 Edge property of type T. More...
 
struct  Face
 
class  FaceAroundVertexCirculator
 
struct  FaceConnectivity
 This type stores the face connectivity. More...
 
class  FaceContainer
 This helper class is a container for iterating through all faces using C++11 range-based for-loops. More...
 
class  FaceIterator
 This class iterates linearly over all faces. More...
 
class  FaceProperty
 Face property of type T. More...
 
struct  Halfedge
 This type represents a halfedge (internally it is basically an index). More...
 
class  HalfedgeAroundFaceCirculator
 
class  HalfedgeAroundVertexCirculator
 
struct  HalfedgeConnectivity
 This type stores the halfedge connectivity. More...
 
class  HalfedgeContainer
 This helper class is a container for iterating through all halfedges using C++11 range-based for-loops. More...
 
class  HalfedgeIterator
 This class iterates linearly over all halfedges. More...
 
class  HalfedgeProperty
 Halfedge property of type T. More...
 
class  ModelProperty
 Mesh property of type T. More...
 
struct  Vertex
 This type represents a vertex (internally it is basically an index). More...
 
class  VertexAroundFaceCirculator
 
class  VertexAroundVertexCirculator
 
struct  VertexConnectivity
 This type stores the vertex connectivity. More...
 
class  VertexContainer
 This helper class is a container for iterating through all vertices using C++11 range-based for-loops. More...
 
class  VertexIterator
 This class iterates linearly over all vertices. More...
 
class  VertexProperty
 Vertex property of type T. More...
 

Public Member Functions

Construct, destruct, assignment
 SurfaceMesh ()
 Default constructor. Initializes an empty surface mesh.
 
 ~SurfaceMesh () override=default
 destructor (is virtual, since we inherit from Geometry_representation)
 
 SurfaceMesh (const SurfaceMesh &rhs)
 copy constructor: copies rhs to *this. performs a deep copy of all properties.
 
SurfaceMeshoperator= (const SurfaceMesh &rhs)
 assign rhs to *this. performs a deep copy of all properties.
 
SurfaceMeshoperator+= (const SurfaceMesh &other)
 Merges another surface mesh into the current one. Shifts the indices of vertices of the other mesh by number_of_vertices() + number_of_removed_vertices() and analogously for halfedges, edges, and faces. Copies entries of all property maps which have the same name in both meshes. That is, properties maps which are only in other are ignored. Also copies elements which are marked as removed, and concatenates the freelists of both meshes.
 
SurfaceMeshjoin (const SurfaceMesh &other)
 Merges another surface mesh into the current one. Shifts the indices of vertices of the other mesh by number_of_vertices() + number_of_removed_vertices() and analogously for halfedges, edges, and faces. Copies entries of all property maps which have the same name in both meshes. That is, properties maps which are only in other are ignored. Also copies elements which are marked as removed, and concatenates the freelists of both meshes.
 
SurfaceMeshassign (const SurfaceMesh &rhs)
 assign rhs to *this. does not copy custom properties.
 
File IO
bool read (const std::string &filename)
 Read mesh from a SM file filename. Mainly for quick debug purposes. Client code should use SurfaceMeshIO.
 
bool write (const std::string &filename) const
 Write mesh to a SM file filename. Mainly for quick debug purposes. Client code should use SurfaceMeshIO.
 
Add new elements by hand
Vertex add_vertex (const vec3 &p)
 Adds a new vertex to the mesh.
 
Face add_face (const std::vector< Vertex > &vertices)
 Adds a new face to the mesh.
 
Face add_triangle (Vertex v1, Vertex v2, Vertex v3)
 
Face add_quad (Vertex v1, Vertex v2, Vertex v3, Vertex v4)
 
Memory Management
unsigned int vertices_size () const
 returns number of (deleted and valid) vertices in the mesh
 
unsigned int halfedges_size () const
 returns number of (deleted and valid)halfedge in the mesh
 
unsigned int edges_size () const
 returns number of (deleted and valid)edges in the mesh
 
unsigned int faces_size () const
 returns number of (deleted and valid)faces in the mesh
 
unsigned int n_vertices () const
 returns number of vertices in the mesh
 
unsigned int n_halfedges () const
 returns number of halfedge in the mesh
 
unsigned int n_edges () const
 returns number of edges in the mesh
 
unsigned int n_faces () const
 returns number of faces in the mesh
 
void clear ()
 Clears the mesh, removing all vertices, edges, faces, and properties (and resets garbage state).
 
void reserve (unsigned int n_vertices, unsigned int n_edges, unsigned int n_faces)
 Reserves memory for the given number of vertices, edges, and faces.
 
void resize (unsigned int nv, unsigned int ne, unsigned int nf)
 
bool has_garbage () const
 are there deleted vertices, edges or faces?
 
void collect_garbage ()
 remove deleted vertices/edges/faces
 
bool is_deleted (Vertex v) const
 
bool is_deleted (Halfedge h) const
 
bool is_deleted (Edge e) const
 
bool is_deleted (Face f) const
 
bool is_valid (Vertex v) const
 return whether vertex v is valid, i.e. the index is stores it within the array bounds.
 
bool is_valid (Halfedge h) const
 return whether halfedge h is valid, i.e. the index is stores it within the array bounds.
 
bool is_valid (Edge e) const
 return whether edge e is valid, i.e. the index is stores it within the array bounds.
 
bool is_valid (Face f) const
 return whether face f is valid, i.e. the index is stores it within the array bounds.
 
Low-level connectivity
Halfedge out_halfedge (Vertex v) const
 
void set_out_halfedge (Vertex v, Halfedge h)
 set the outgoing halfedge of vertex v to h
 
bool is_border (Vertex v) const
 returns whether v is a boundary vertex
 
bool is_isolated (Vertex v) const
 returns whether v is isolated, i.e., not incident to any face
 
bool is_manifold (Vertex v) const
 returns whether v is a manifold vertex (not incident to several patches)
 
bool is_degenerate (Face f) const
 returns whether f is degenerate
 
Vertex target (Halfedge h) const
 returns the vertex the halfedge h points to
 
Vertex source (Halfedge h) const
 returns the vertex the halfedge h emanates from
 
void set_target (Halfedge h, Vertex v)
 sets the vertex the halfedge h points to to v
 
Face face (Halfedge h) const
 returns the face incident to halfedge h
 
void set_face (Halfedge h, Face f)
 sets the incident face to halfedge h to f
 
Halfedge next (Halfedge h) const
 returns the next halfedge within the incident face
 
void set_next (Halfedge h, Halfedge nh)
 sets the next halfedge of h within the face to nh
 
Halfedge prev (Halfedge h) const
 returns the previous halfedge within the incident face
 
Halfedge opposite (Halfedge h) const
 returns the opposite halfedge of h
 
Halfedge prev_around_source (Halfedge h) const
 
Halfedge next_around_source (Halfedge h) const
 
Halfedge prev_around_target (Halfedge h) const
 
Halfedge next_around_target (Halfedge h) const
 
Edge edge (Halfedge h) const
 return the edge that contains halfedge h as one of its two halfedges.
 
bool is_border (Halfedge h) const
 returns whether h is a boundary halfedge, i.e., if its face does not exist.
 
Halfedge halfedge (Edge e, unsigned int i) const
 returns the i'th halfedge of edge e. i has to be 0 or 1.
 
Vertex vertex (Edge e, unsigned int i) const
 returns the i'th vertex of edge e. i has to be 0 or 1.
 
Face face (Edge e, unsigned int i) const
 returns the face incident to the i'th halfedge of edge e. i has to be 0 or 1.
 
bool is_border (Edge e) const
 
Halfedge halfedge (Face f) const
 returns a halfedge of face f
 
void set_halfedge (Face f, Halfedge h)
 sets the halfedge of face f to h
 
bool is_border (Face f) const
 returns whether f is a boundary face, i.e., it one of its edges is a boundary edge.
 
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>
HalfedgeProperty< T > add_halfedge_property (const std::string &name, const T t=T())
 Add a halfedge 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>
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>
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>
HalfedgeProperty< T > get_halfedge_property (const std::string &name) const
 Get the halfedge 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>
FaceProperty< T > get_face_property (const std::string &name) const
 Get the face 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>
HalfedgeProperty< T > halfedge_property (const std::string &name, const T t=T())
 If a halfedge 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>
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>
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_halfedge_property (HalfedgeProperty< T > &p)
 Remove the halfedge property p.
 
bool remove_halfedge_property (const std::string &n)
 Remove the halfedge 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_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_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_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_halfedge_property (const std::string &old_name, const std::string &new_name)
 Rename a halfedge 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_halfedge_property_type (const std::string &name) const
 Get the type information of the halfedge 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_face_property_type (const std::string &name) const
 Get the type information of the face 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 > halfedge_properties () const
 Get the names of all halfedge properties.
 
std::vector< std::string > edge_properties () const
 Get the names of all edge properties.
 
std::vector< std::string > face_properties () const
 Get the names of all face 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.
 
HalfedgeIterator halfedges_begin () const
 Returns an iterator to the beginning of the halfedges.
 
HalfedgeIterator halfedges_end () const
 Returns an iterator to the end of the halfedges.
 
HalfedgeContainer halfedges () const
 Returns a container for range-based iteration over halfedges.
 
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.
 
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.
 
VertexAroundVertexCirculator vertices (Vertex v) const
 Returns circulator for the vertices around vertex v.
 
HalfedgeAroundVertexCirculator halfedges (Vertex v) const
 Returns circulator for outgoing halfedges around vertex v.
 
FaceAroundVertexCirculator faces (Vertex v) const
 Returns circulator for faces around vertex v.
 
VertexAroundFaceCirculator vertices (Face f) const
 Returns circulator for vertices of face f.
 
HalfedgeAroundFaceCirculator halfedges (Face f) const
 Returns circulator for halfedges of face f.
 
- 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

class SurfaceMeshBuilder
 
const vec3position (Vertex v) const
 Returns the position of a vertex.
 
vec3position (Vertex v)
 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 ()
 compute face normals by calling compute_face_normal(Face) for each face.
 
vec3 compute_face_normal (Face f) const
 Computes the normal vector of face f. This method is robust for concave and general polygonal faces.
 
void update_vertex_normals ()
 compute vertex normals by calling compute_vertex_normal(Vertex) for each vertex.
 
vec3 compute_vertex_normal (Vertex v) const
 
float edge_length (Edge e) const
 compute the length of edge e.
 
float edge_length (Halfedge h) const
 compute the length of an edge denoted by one of its halfedge h.
 

Higher-level Topological Operations

bool is_closed () const
 returns whether the mesh closed (i.e., no boundary edges)
 
bool is_triangle_mesh () const
 
bool is_quad_mesh () const
 
void triangulate ()
 
void triangulate (Face f)
 
void reverse_orientation ()
 Reverses the orientation of the entire mesh.
 
bool is_collapse_ok (Halfedge h) const
 
void collapse (Halfedge h)
 
Vertex split (Face f, const vec3 &p)
 
void split (Face f, Vertex v)
 
Halfedge split (Edge e, const vec3 &p)
 
Halfedge split (Edge e, Vertex v)
 
bool join_edges (Vertex v)
 
bool can_join_edges (Vertex v) const
 
Halfedge insert_edge (Halfedge h0, Halfedge h1)
 
bool is_flip_ok (Edge e) const
 
void flip (Edge e)
 
bool is_stitch_ok (Halfedge h0, Halfedge h1)
 
void stitch (Halfedge h0, Halfedge h1)
 Stitch two halfedges h0 and h1. Precondition: h0 and h1 are both on the border and point in reversed directions.
 
unsigned int valence (Vertex v) const
 
unsigned int valence (Face f) const
 returns the valence of face f (its number of vertices)
 
Halfedge find_halfedge (Vertex start, Vertex end) const
 find the halfedge from start to end
 
Edge find_edge (Vertex a, Vertex b) const
 find the edge (a, b)
 
void delete_vertex (Vertex v)
 
void delete_edge (Edge e)
 
void delete_face (Face f)
 
Halfedge insert_vertex (Edge e, const vec3 &p)
 
Halfedge insert_vertex (Edge e, Vertex v)
 
Halfedge insert_vertex (Halfedge h, Vertex v)
 

Detailed Description

A halfedge data structure for polygonal meshes of 2-manifold.

A surface mesh is a consistent and orientable polygonal mesh that may have one or more boundaries. The faces are simple polygons and the edges are line segments. Each edge connects two vertices, and is shared by two faces (including the null face for boundary edges). A surface mesh can have any number of connected components and also some self-intersections.

Note
The construction of a manifold surface mesh can be done by iteratively calling add_vertex() and add_face(). These two methods can ONLY be used when you're sure that the mesh is manifold. Otherwise, SurfaceMeshBuilder should be used for the construction, which guarantees you end up with a polygonal mesh of a 2-manifold topology. In any case, client code is highly recommended to use SurfaceMeshBuilder.
See also
SurfaceMeshBuilder.
Examples
Tutorial_104_SurfaceMesh/main.cpp, Tutorial_105_SurfaceMesh_Connectivity/main.cpp, Tutorial_106_SurfaceMesh_Property/main.cpp, Tutorial_107_SurfaceMesh_IO/main.cpp, Tutorial_302_Imposters/main.cpp, Tutorial_303_ScalarField/main.cpp, Tutorial_304_VectorField/main.cpp, Tutorial_305_Texture/main.cpp, Tutorial_310_TextMesher/main.cpp, Tutorial_402_FacePicker/main.cpp, Tutorial_406_CollisionDetection/main.cpp, Tutorial_601_Tessellator/main.cpp, and Tutorial_602_ConvexPartition/main.cpp.

Member Function Documentation

◆ 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()

SurfaceMesh::Face add_face ( const std::vector< Vertex > & vertices)

Adds a new face to the mesh.

Parameters
verticesThe vertices of the new face. Each vertex was created by add_vertex().
Returns
The handle to the new face.
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_halfedge_property()

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

Add a halfedge 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 halfedge 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_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()

SurfaceMesh::Face add_quad ( Vertex v1,
Vertex v2,
Vertex v3,
Vertex v4 )

add a new quad connecting vertices v1, v2, v3, v4

Parameters
{v1,v2,v3,v4}The input vertices created by add_vertex().
See also
add_triangle, add_face

◆ add_triangle()

SurfaceMesh::Face add_triangle ( Vertex v1,
Vertex v2,
Vertex v3 )

add a new triangle connecting vertices v1, v2, v3

Parameters
{v1,v2,v3}The input vertices created by add_vertex().
See also
add_face, add_quad

◆ add_vertex()

Vertex add_vertex ( const vec3 & p)
inline

Adds a new vertex to the mesh.

Parameters
pThe position of the new vertex.
Returns
The handle to 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.

◆ can_join_edges()

bool can_join_edges ( Vertex v) const

Check whether the two incident edges of a vertex can be joined. It only allows for vertices of valence two.

See also
join_edges(Vertex)

◆ clear()

void clear ( )

Clears the mesh, removing all vertices, edges, faces, and properties (and resets garbage state).

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.

◆ collapse()

void collapse ( Halfedge h)

Collapse the halfedge h by moving its start vertex into its target vertex. For non-boundary halfedges this function removes one vertex, three edges, and two faces. For boundary halfedges it removes one vertex, two edges and one face.

Attention
This function is only valid for triangle meshes.
Halfedge collapses might lead to invalid faces. Call is_collapse_ok(Halfedge) to be sure the collapse is legal.
The removed items are only marked as deleted. You have to call collect_garbage() to finally remove them.

◆ compute_face_normal()

vec3 compute_face_normal ( Face f) const

Computes the normal vector of face f. This method is robust for concave and general polygonal faces.

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

◆ compute_vertex_normal()

vec3 compute_vertex_normal ( Vertex v) const

compute normal vector of vertex v. This is the angle-weighted average of incident face normals.

Note
The per-face normals much have been computed.

◆ delete_edge()

void delete_edge ( Edge e)

deletes the edge e from the mesh. Its incident faces will also be deleted.

Attention
This function only marks the edge and its incident faces as deleted, and you have to call collect_garbage() to finally remove them.

◆ delete_face()

void delete_face ( Face f)

deletes the face f from the mesh. Its incident edges (if on boundary) will also be deleted.

Attention
This function only marks the face and its incident edges (if on boundary) as deleted, and you have to call collect_garbage() to finally remove them.

◆ delete_vertex()

void delete_vertex ( Vertex v)

deletes the vertex v from the mesh. Its incident edges and faces will also be deleted.

Attention
This function only marks the vertex and its incident edges and faces as deleted, and you have to call collect_garbage() to finally remove them.

◆ 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()

EdgeContainer edges ( ) const
inline

Returns a container for range-based iteration over edges.

Returns
EdgeContainer containing all 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.

◆ 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() [1/2]

FaceContainer faces ( ) const
inline

Returns a container for range-based iteration over faces.

Returns
FaceContainer containing all faces.

◆ faces() [2/2]

FaceAroundVertexCirculator faces ( Vertex v) const
inline

Returns circulator for faces around vertex v.

Parameters
vThe vertex.
Returns
The face circulator.

◆ 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.

◆ flip()

void flip ( Edge e)

Flip edge e: Remove edge e and add an edge between the two vertices opposite to edge e of the two incident triangles.

Attention
This function is only valid for triangle meshes.
See also
is_flip_ok(Edge)

◆ 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.
Examples
Tutorial_406_CollisionDetection/main.cpp.

◆ 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_halfedge_property()

template<class T>
HalfedgeProperty< T > get_halfedge_property ( const std::string & name) const
inline

Get the halfedge property with name name of type T.

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

◆ get_halfedge_property_type()

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

Get the type information of the halfedge 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.

◆ halfedge_properties()

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

Get the names of all halfedge properties.

Returns
A vector containing the names of all edge properties.

◆ halfedge_property()

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

If a halfedge 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 halfedge property. If the property does not exist, it is added with the default value t and returned.

◆ halfedges() [1/3]

HalfedgeContainer halfedges ( ) const
inline

Returns a container for range-based iteration over halfedges.

Returns
EdgeContainer containing all halfedges.

◆ halfedges() [2/3]

HalfedgeAroundFaceCirculator halfedges ( Face f) const
inline

Returns circulator for halfedges of face f.

Parameters
fThe face.
Returns
The halfedge circulator.

◆ halfedges() [3/3]

HalfedgeAroundVertexCirculator halfedges ( Vertex v) const
inline

Returns circulator for outgoing halfedges around vertex v.

Parameters
vThe vertex.
Returns
The outgoing halfedge circulator.

◆ halfedges_begin()

HalfedgeIterator halfedges_begin ( ) const
inline

Returns an iterator to the beginning of the halfedges.

Returns
EdgeIterator pointing to the first halfedge.

◆ halfedges_end()

HalfedgeIterator halfedges_end ( ) const
inline

Returns an iterator to the end of the halfedges.

Returns
EdgeIterator pointing past the last halfedges.

◆ insert_edge()

SurfaceMesh::Halfedge insert_edge ( Halfedge h0,
Halfedge h1 )

insert edge between the to-vertices v0 of h0 and v1 of h1. returns the new halfedge from v0 to v1.

Attention
h0 and h1 have to belong to the same face

◆ is_border()

bool is_border ( Edge e) const
inline

returns whether e is a boundary edge, i.e., if one of its halfedges is a boundary halfedge.

◆ is_collapse_ok()

bool is_collapse_ok ( Halfedge h) const

returns whether collapsing the halfedge h is topologically legal.

Attention
This function is only valid for triangle meshes.

◆ is_deleted() [1/4]

bool is_deleted ( Edge e) const
inline

returns whether edge e is deleted

See also
collect_garbage()

◆ is_deleted() [2/4]

bool is_deleted ( Face f) const
inline

returns whether face f is deleted

See also
collect_garbage()

◆ is_deleted() [3/4]

bool is_deleted ( Halfedge h) const
inline

returns whether halfedge h is deleted

See also
collect_garbage()

◆ is_deleted() [4/4]

bool is_deleted ( Vertex v) const
inline

returns whether vertex v is deleted

See also
collect_garbage()

◆ is_flip_ok()

bool is_flip_ok ( Edge e) const

Check whether flipping edge e is topologically allowed.

Attention
This function is only valid for triangle meshes.
See also
flip(Edge)

◆ is_quad_mesh()

bool is_quad_mesh ( ) const

returns whether the mesh a quad mesh. this function simply tests each face, and therefore is not very efficient.

◆ is_stitch_ok()

bool is_stitch_ok ( Halfedge h0,
Halfedge h1 )

Check whether stitching two halfedges h0 an h1 is topologically allowed. Two halfedges can be stitched if they are both on on the border and point in reverse directions.

◆ is_triangle_mesh()

bool is_triangle_mesh ( ) const

returns whether the mesh a triangle mesh. this function simply tests each face, and therefore is not very efficient.

See also
triangulate(), triangulate(Face)

◆ join_edges()

bool join_edges ( Vertex v)

Merges the two incident edges of a 2-degree vertex. This is the reverse operation of insert_vertex().

Precondition
valence(v) == 2.
See also
insert_vertex(Edge, vec3)
insert_vertex(Edge, Vertex)
insert_vertex(Halfedge, Vertex)

◆ 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.

◆ next_around_source()

Halfedge next_around_source ( Halfedge h) const
inline

returns the halfedge that is rotated clockwise around the start vertex of h. it is the next halfedge of the opposite halfedge of h.

◆ next_around_target()

Halfedge next_around_target ( Halfedge h) const
inline

returns the halfedge that is rotated clockwise around the end vertex of h. it is the opposite halfedge of the next halfedge of h.

◆ out_halfedge()

Halfedge out_halfedge ( Vertex v) const
inline

returns an outgoing halfedge of vertex v. if v is a boundary vertex this will be a boundary halfedge.

◆ 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() [1/2]

vec3 & position ( Vertex v)
inline

Returns the position of a vertex.

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

◆ position() [2/2]

const vec3 & position ( Vertex v) const
inline

Returns the position of a vertex.

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

◆ prev_around_source()

Halfedge prev_around_source ( Halfedge h) const
inline

returns the halfedge that is rotated counter-clockwise around the start vertex of h. it is the opposite halfedge of the previous halfedge of h.

◆ prev_around_target()

Halfedge prev_around_target ( Halfedge h) const
inline

returns the halfedge that is rotated counter-clockwise around the end vertex of h. it is the prev halfedge of the opposite halfedge of h.

◆ 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 SM file filename. Mainly for quick debug purposes. Client code should use SurfaceMeshIO.

See also
SurfaceMeshIO.

◆ 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_halfedge_property() [1/2]

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

Remove the halfedge property named n.

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

◆ remove_halfedge_property() [2/2]

template<class T>
bool remove_halfedge_property ( HalfedgeProperty< T > & p)
inline

Remove the halfedge 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_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_halfedge_property()

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

Rename a halfedge 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.

◆ reserve()

void reserve ( unsigned int n_vertices,
unsigned int n_edges,
unsigned int n_faces )

Reserves memory for the given number of vertices, edges, and faces.

Parameters
n_verticesThe number of vertices to reserve.
n_edgesThe number of edges to reserve.
n_facesThe number of faces to reserve.

◆ resize()

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

resizes space for vertices, halfedges, edges, faces, and their currently associated properties. Note: ne is the number of edges. for halfedges, nh = 2 * ne. *‍/

◆ reverse_orientation()

void reverse_orientation ( )

Reverses the orientation of the entire mesh.

This function reverses for each face the order of the vertices along the face boundary. As a consequence, the normal computed for each face using compute_face_normal() is also reversed.

◆ split() [1/4]

Halfedge split ( Edge e,
const vec3 & p )
inline

Split the edge e by first adding point p to the mesh and then connecting it to the two vertices of the adjacent triangles that are opposite to edge e. Returns the halfedge pointing to p that is created by splitting the existing edge e.

Attention
This function is only valid for triangle meshes.
See also
split(Edge, Vertex)

◆ split() [2/4]

Split the edge e by connecting vertex v it to the two vertices of the adjacent triangles that are opposite to edge e. Returns the halfedge pointing to p that is created by splitting the existing edge e.

Attention
This function is only valid for triangle meshes.
See also
split(Edge, vec3)

◆ split() [3/4]

Vertex split ( Face f,
const vec3 & p )
inline

Split the face f by first adding point p to the mesh and then inserting edges between p and the vertices of f. For a triangle this is a standard one-to-three split.

See also
split(Face, Vertex)

◆ split() [4/4]

void split ( Face f,
Vertex v )

Split the face f by inserting edges between v and the vertices of f. For a triangle this is a standard one-to-three split.

See also
split(Face, const vec3&)

◆ stitch()

void stitch ( Halfedge h0,
Halfedge h1 )

Stitch two halfedges h0 and h1. Precondition: h0 and h1 are both on the border and point in reversed directions.

Attention
Stitching two halfedges changes the topology and geometry significantly, thus it may result in a non-manifold mesh, client code must check if this operation can be executed.
See also
is_stitch_ok().

◆ triangulate() [1/2]

void triangulate ( )

triangulate the entire mesh, by calling triangulate(Face) for each face.

See also
triangulate(Face)

◆ triangulate() [2/2]

void triangulate ( Face f)

triangulate the face f

See also
triangulate()

◆ valence()

unsigned int valence ( Vertex v) const

returns the valence (number of incident edges or neighboring vertices) of vertex v.

◆ 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/3]

VertexContainer vertices ( ) const
inline

Returns a container for range-based iteration over vertices.

Returns
VertexContainer containing all vertices.

◆ vertices() [2/3]

VertexAroundFaceCirculator vertices ( Face f) const
inline

Returns circulator for vertices of face f.

Parameters
fThe face.
Returns
The vertex circulator.

◆ vertices() [3/3]

VertexAroundVertexCirculator vertices ( Vertex v) const
inline

Returns circulator for the vertices around vertex v.

Parameters
vThe vertex.
Returns
The vertex circulator.

◆ 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 SM file filename. Mainly for quick debug purposes. Client code should use SurfaceMeshIO.

See also
SurfaceMeshIO.

Friends And Related Symbol Documentation

◆ insert_vertex() [1/3]

Halfedge insert_vertex ( Edge e,
const vec3 & p )
related

Subdivide the edge e = (v0,v1) by splitting it into the two edge (v0,p) and (p,v1). Note that this function does not introduce any other edge or faces. It simply splits the edge. Returns halfedge that points to p.

See also
insert_vertex(Edge, Vertex)
insert_vertex(Halfedge, Vertex) (Vertex)

◆ insert_vertex() [2/3]

Halfedge insert_vertex ( Edge e,
Vertex v )
related

Subdivide the edge e = (v0,v1) by splitting it into the two edge (v0,v) and (v,v1). Note that this function does not introduce any other edge or faces. It simply splits the edge. Returns halfedge that points to v.

See also
insert_vertex(Edge, vec3)
insert_vertex(Halfedge, Vertex) (Vertex)

◆ insert_vertex() [3/3]

SurfaceMesh::Halfedge insert_vertex ( Halfedge h,
Vertex v )
related

Subdivide the edge e = (v0,v1) by splitting it into the two edge (v0,v) and (v,v1). Note that this function does not introduce any other edge or faces. It simply splits the edge. Returns halfedge that points to v.

See also
insert_vertex(Edge, vec3)
insert_vertex(Edge, Vertex) (Vertex)

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