OpenGP  1.1
Open Geometry Processing Library
Classes | List of all members
OpenGP::SurfaceMesh Class Reference

A halfedge data structure for polygonal meshes. More...

#include <SurfaceMesh.h>

Inheritance diagram for OpenGP::SurfaceMesh:
OpenGP::Global_properties

Classes

class  Base_handle
 
struct  Edge
 
class  Edge_container
 
class  Edge_iterator
 
class  Edge_property
 
struct  Face
 
class  Face_around_vertex_circulator
 
struct  Face_connectivity
 
class  Face_container
 
class  Face_iterator
 
class  Face_property
 
struct  Halfedge
 
class  Halfedge_around_face_circulator
 
class  Halfedge_around_vertex_circulator
 
struct  Halfedge_connectivity
 
class  Halfedge_container
 
class  Halfedge_iterator
 
class  Halfedge_property
 
struct  Vertex
 
class  Vertex_around_face_circulator
 
class  Vertex_around_vertex_circulator
 
struct  Vertex_connectivity
 
class  Vertex_container
 
class  Vertex_iterator
 
class  Vertex_property
 

Public Member Functions

Construct, destruct, assignment
HEADERONLY_INLINE SurfaceMesh ()
 default constructor
 
virtual HEADERONLY_INLINE ~SurfaceMesh ()
 
 SurfaceMesh (const SurfaceMesh &rhs)
 copy constructor: copies rhs to *this. performs a deep copy of all properties.
 
HEADERONLY_INLINE SurfaceMeshoperator= (const SurfaceMesh &rhs)
 assign rhs to *this. performs a deep copy of all properties.
 
HEADERONLY_INLINE SurfaceMeshassign (const SurfaceMesh &rhs)
 assign rhs to *this. does not copy custom properties.
 
File IO
HEADERONLY_INLINE bool read (const std::string &filename)
 
HEADERONLY_INLINE bool write (const std::string &filename) const
 
Add new elements by hand
HEADERONLY_INLINE Vertex add_vertex (const Vec3 &p)
 add a new vertex with position p
 
HEADERONLY_INLINE Face add_face (const std::vector< Vertex > &vertices)
 
HEADERONLY_INLINE Face add_triangle (Vertex v1, Vertex v2, Vertex v3)
 
HEADERONLY_INLINE 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
 
unsigned int empty () const
 returns true iff the mesh is empty, i.e., has no vertices
 
HEADERONLY_INLINE void clear ()
 clear mesh: remove all vertices, edges, faces
 
HEADERONLY_INLINE void free_memory ()
 remove unused memory from vectors
 
HEADERONLY_INLINE void reserve (unsigned int nvertices, unsigned int nedges, unsigned int nfaces)
 reserve memory (mainly used in file readers)
 
HEADERONLY_INLINE void garbage_collection ()
 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 halfedge (Vertex v) const
 
void set_halfedge (Vertex v, Halfedge h)
 set the outgoing halfedge of vertex v to h
 
bool is_boundary (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)
 
Vertex to_vertex (Halfedge h) const
 returns the vertex the halfedge h points to
 
Vertex from_vertex (Halfedge h) const
 returns the vertex the halfedge h emanates from
 
void set_vertex (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 (Halfedge h) const
 returns the next halfedge within the incident face
 
void set_next_halfedge (Halfedge h, Halfedge nh)
 sets the next halfedge of h within the face to nh
 
Halfedge prev_halfedge (Halfedge h) const
 returns the previous halfedge within the incident face
 
Halfedge opposite_halfedge (Halfedge h) const
 returns the opposite halfedge of h
 
Halfedge ccw_rotated_halfedge (Halfedge h) const
 
Halfedge cw_rotated_halfedge (Halfedge h) const
 
Edge edge (Halfedge h) const
 return the edge that contains halfedge h as one of its two halfedges.
 
bool is_boundary (Halfedge h) const
 returns whether h is a boundary halfege, 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_boundary (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_boundary (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 >
Vertex_property< T > add_vertex_property (const std::string &name, const T t=T())
 
template<class T >
Halfedge_property< T > add_halfedge_property (const std::string &name, const T t=T())
 
template<class T >
Edge_property< T > add_edge_property (const std::string &name, const T t=T())
 
template<class T >
Face_property< T > add_face_property (const std::string &name, const T t=T())
 
template<class T >
Vertex_property< T > get_vertex_property (const std::string &name) const
 
template<class T >
Halfedge_property< T > get_halfedge_property (const std::string &name) const
 
template<class T >
Edge_property< T > get_edge_property (const std::string &name) const
 
template<class T >
Face_property< T > get_face_property (const std::string &name) const
 
template<class T >
Vertex_property< T > vertex_property (const std::string &name, const T t=T())
 
template<class T >
Halfedge_property< T > halfedge_property (const std::string &name, const T t=T())
 
template<class T >
Edge_property< T > edge_property (const std::string &name, const T t=T())
 
template<class T >
Face_property< T > face_property (const std::string &name, const T t=T())
 
template<class T >
void remove_vertex_property (Vertex_property< T > &p)
 remove the vertex property p
 
template<class T >
void remove_halfedge_property (Halfedge_property< T > &p)
 remove the halfedge property p
 
template<class T >
void remove_edge_property (Edge_property< T > &p)
 remove the edge property p
 
template<class T >
void remove_face_property (Face_property< T > &p)
 remove the face property p
 
const std::type_info & get_vertex_property_type (const std::string &name)
 
const std::type_info & get_halfedge_property_type (const std::string &name)
 
const std::type_info & get_edge_property_type (const std::string &name)
 
const std::type_info & get_face_property_type (const std::string &name)
 
std::vector< std::string > vertex_properties () const
 returns the names of all vertex properties
 
std::vector< std::string > halfedge_properties () const
 returns the names of all halfedge properties
 
std::vector< std::string > edge_properties () const
 returns the names of all edge properties
 
std::vector< std::string > face_properties () const
 returns the names of all face properties
 
HEADERONLY_INLINE void property_stats () const
 prints the names of all properties
 
Iterators & Circulators
Vertex_iterator vertices_begin () const
 returns start iterator for vertices
 
Vertex_iterator vertices_end () const
 returns end iterator for vertices
 
Vertex_container vertices () const
 returns vertex container for C++11 range-based for-loops
 
Halfedge_iterator halfedges_begin () const
 returns start iterator for halfedges
 
Halfedge_iterator halfedges_end () const
 returns end iterator for halfedges
 
Halfedge_container halfedges () const
 returns halfedge container for C++11 range-based for-loops
 
Edge_iterator edges_begin () const
 returns start iterator for edges
 
Edge_iterator edges_end () const
 returns end iterator for edges
 
Edge_container edges () const
 returns edge container for C++11 range-based for-loops
 
Face_iterator faces_begin () const
 returns start iterator for faces
 
Face_iterator faces_end () const
 returns end iterator for faces
 
Face_container faces () const
 returns face container for C++11 range-based for-loops
 
Vertex_around_vertex_circulator vertices (Vertex v) const
 returns circulator for vertices around vertex v
 
Halfedge_around_vertex_circulator halfedges (Vertex v) const
 returns circulator for outgoing halfedges around vertex v
 
Face_around_vertex_circulator faces (Vertex v) const
 returns circulator for faces around vertex v
 
Vertex_around_face_circulator vertices (Face f) const
 returns circulator for vertices of face f
 
Halfedge_around_face_circulator halfedges (Face f) const
 returns circulator for halfedges of face f
 
Higher-level Topological Operations
HEADERONLY_INLINE bool is_triangle_mesh () const
 
HEADERONLY_INLINE bool is_quad_mesh () const
 
HEADERONLY_INLINE void triangulate ()
 
HEADERONLY_INLINE void triangulate (Face f)
 
HEADERONLY_INLINE bool is_collapse_ok (Halfedge h)
 
HEADERONLY_INLINE void collapse (Halfedge h)
 
HEADERONLY_INLINE Vertex split (Face f, const Vec3 &p)
 
HEADERONLY_INLINE void split (Face f, Vertex v)
 
HEADERONLY_INLINE Vertex split (Edge e, const Vec3 &p)
 
HEADERONLY_INLINE void split (Edge e, Vertex v)
 
Halfedge insert_vertex (Edge e, const Vec3 &p)
 
Halfedge insert_vertex (Edge e, Vertex v)
 
HEADERONLY_INLINE Halfedge insert_vertex (Halfedge h, Vertex v)
 
HEADERONLY_INLINE Halfedge insert_edge (Halfedge h0, Halfedge h1)
 
HEADERONLY_INLINE bool is_flip_ok (Edge e) const
 
HEADERONLY_INLINE void flip (Edge e)
 
HEADERONLY_INLINE unsigned int valence (Vertex v) const
 
HEADERONLY_INLINE unsigned int valence (Face f) const
 returns the valence of face f (its number of vertices)
 
HEADERONLY_INLINE Halfedge find_halfedge (Vertex start, Vertex end) const
 find the halfedge from start to end
 
HEADERONLY_INLINE Edge find_edge (Vertex a, Vertex b) const
 find the edge (a,b)
 
HEADERONLY_INLINE void delete_vertex (Vertex v)
 deletes the vertex v from the mesh
 
HEADERONLY_INLINE void delete_edge (Edge e)
 deletes the edge e from the mesh
 
HEADERONLY_INLINE void delete_face (Face f)
 deletes the face f from the mesh
 
Geometry-related Functions
const Vec3 & position (Vertex v) const
 position of a vertex (read only)
 
Vec3 & position (Vertex v)
 position of a vertex
 
std::vector< Vec3 > & points ()
 vector of vertex positions
 
HEADERONLY_INLINE void update_face_normals ()
 compute face normals by calling compute_face_normal(Face) for each face.
 
HEADERONLY_INLINE Vec3 compute_face_normal (Face f) const
 compute normal vector of face f.
 
HEADERONLY_INLINE void update_vertex_normals ()
 compute vertex normals by calling compute_vertex_normal(Vertex) for each vertex.
 
HEADERONLY_INLINE Vec3 compute_vertex_normal (Vertex v) const
 compute normal vector of vertex v.
 
HEADERONLY_INLINE Scalar edge_length (Edge e) const
 compute the length of edge e.
 
- Public Member Functions inherited from OpenGP::Global_properties
template<class T >
T & add_property (const std::string &name)
 Generic. More...
 
template<class T >
T & add_property (const std::string &name, const T &initval)
 Generic with immediate initialization.
 
template<class T >
T & get_property (const std::string &name)
 

Detailed Description

A halfedge data structure for polygonal meshes.

Member Function Documentation

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

add a edge property of type T with name name and default value t. fails if a property named name exists already, since the name has to be unique. in this case it returns an invalid property

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

add a new face with vertex list vertices

See also
add_triangle, add_quad
template<class T >
Face_property<T> OpenGP::SurfaceMesh::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. fails if a property named name exists already, since the name has to be unique. in this case it returns an invalid property

template<class T >
Halfedge_property<T> OpenGP::SurfaceMesh::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. fails if a property named name exists already, since the name has to be unique. in this case it returns an invalid property

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

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

See also
add_triangle, add_face
SurfaceMesh::Face OpenGP::SurfaceMesh::add_triangle ( Vertex  v1,
Vertex  v2,
Vertex  v3 
)

add a new triangle connecting vertices v1, v2, v3

See also
add_face, add_quad
template<class T >
Vertex_property<T> OpenGP::SurfaceMesh::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. fails if a property named name exists already, since the name has to be unique. in this case it returns an invalid property

Halfedge OpenGP::SurfaceMesh::ccw_rotated_halfedge ( 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.

void OpenGP::SurfaceMesh::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 garbage_collection() to finally remove them.
Halfedge OpenGP::SurfaceMesh::cw_rotated_halfedge ( 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.

template<class T >
Edge_property<T> OpenGP::SurfaceMesh::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)

template<class T >
Face_property<T> OpenGP::SurfaceMesh::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)

void OpenGP::SurfaceMesh::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)
template<class T >
Edge_property<T> OpenGP::SurfaceMesh::get_edge_property ( const std::string &  name) const
inline

get the edge property named name of type T. returns an invalid Vertex_property if the property does not exist or if the type does not match.

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

get the type_info T of edge property named . returns an typeid(void) if the property does not exist or if the type does not match.

template<class T >
Face_property<T> OpenGP::SurfaceMesh::get_face_property ( const std::string &  name) const
inline

get the face property named name of type T. returns an invalid Vertex_property if the property does not exist or if the type does not match.

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

get the type_info T of face property named . returns an typeid(void) if the property does not exist or if the type does not match.

template<class T >
Halfedge_property<T> OpenGP::SurfaceMesh::get_halfedge_property ( const std::string &  name) const
inline

get the halfedge property named name of type T. returns an invalid Vertex_property if the property does not exist or if the type does not match.

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

get the type_info T of halfedge property named . returns an typeid(void) if the property does not exist or if the type does not match.

template<class T >
Vertex_property<T> OpenGP::SurfaceMesh::get_vertex_property ( const std::string &  name) const
inline

get the vertex property named name of type T. returns an invalid Vertex_property if the property does not exist or if the type does not match.

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

get the type_info T of vertex property named . returns an typeid(void) if the property does not exist or if the type does not match.

Halfedge OpenGP::SurfaceMesh::halfedge ( Vertex  v) const
inline

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

template<class T >
Halfedge_property<T> OpenGP::SurfaceMesh::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)

SurfaceMesh::Halfedge OpenGP::SurfaceMesh::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
Halfedge OpenGP::SurfaceMesh::insert_vertex ( Edge  e,
const Vec3 &  p 
)
inline

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)
Halfedge OpenGP::SurfaceMesh::insert_vertex ( Edge  e,
Vertex  v 
)
inline

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

See also
insert_vertex(Edge, Vec3)
insert_vertex(Halfedge, Vertex)
SurfaceMesh::Halfedge OpenGP::SurfaceMesh::insert_vertex ( Halfedge  h,
Vertex  v 
)

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

See also
insert_vertex(Edge, Vec3)
insert_vertex(Edge, Vertex)
bool OpenGP::SurfaceMesh::is_boundary ( Edge  e) const
inline

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

bool OpenGP::SurfaceMesh::is_collapse_ok ( Halfedge  h)

returns whether collapsing the halfedge h is topologically legal.

Attention
This function is only valid for triangle meshes.
bool OpenGP::SurfaceMesh::is_deleted ( Vertex  v) const
inline

returns whether vertex v is deleted

See also
garbage_collection()
bool OpenGP::SurfaceMesh::is_deleted ( Halfedge  h) const
inline

returns whether halfedge h is deleted

See also
garbage_collection()
bool OpenGP::SurfaceMesh::is_deleted ( Edge  e) const
inline

returns whether edge e is deleted

See also
garbage_collection()
bool OpenGP::SurfaceMesh::is_deleted ( Face  f) const
inline

returns whether face f is deleted

See also
garbage_collection()
bool OpenGP::SurfaceMesh::is_flip_ok ( Edge  e) const

Check whether flipping edge e is topologically

Attention
This function is only valid for triangle meshes.
See also
flip(Edge)
bool OpenGP::SurfaceMesh::is_quad_mesh ( ) const

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

bool OpenGP::SurfaceMesh::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
trianglate(), triangulate(Face)
bool OpenGP::SurfaceMesh::read ( const std::string &  filename)

read mesh from file filename. file extension determines file type.

See also
write(const std::string& filename)
HEADERONLY_INLINE Vertex OpenGP::SurfaceMesh::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)
void OpenGP::SurfaceMesh::split ( Face  f,
Vertex  v 
)

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

See also
split(Face, const Vec3&)
HEADERONLY_INLINE Vertex OpenGP::SurfaceMesh::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.

Attention
This function is only valid for triangle meshes.
See also
split(Edge, Vertex)
void OpenGP::SurfaceMesh::split ( Edge  e,
Vertex  v 
)

Split the edge e by connecting vertex v it to the two vertices of the adjacent triangles that are opposite to edge e.

Attention
This function is only valid for triangle meshes.
See also
split(Edge, Vec3)
void OpenGP::SurfaceMesh::triangulate ( )

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

See also
trianglate(Face)
void OpenGP::SurfaceMesh::triangulate ( Face  f)

triangulate the face f

See also
trianglate()
unsigned int OpenGP::SurfaceMesh::valence ( Vertex  v) const

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

template<class T >
Vertex_property<T> OpenGP::SurfaceMesh::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)

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

write mesh to file filename. file extensions determines file type.

See also
read(const std::string& filename)

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