GEL  2
GEL is a library for Geometry and Linear Algebra
Public Member Functions
HMesh::Manifold Class Reference

List of all members.

Public Member Functions

 Manifold ()
 Default constructor.
void build (size_t no_vertices, const float *vertvec, size_t no_faces, const int *facevec, const int *indices)
 Build a manifold. The arguments are the number of vertices, no_vertices, the vector of vertices, vertvec, the number of faces, no_faces. facevecis an array where each entry indicates the number of vertices in that face. The array indices contains all the corresponding vertex indices in one concatenated list.
void build (const Geometry::TriMesh &mesh)
 Build a manifold from a TriMesh.
std::vector< HalfEdgeIDbridge_faces (FaceID f0, FaceID f1, const std::vector< std::pair< VertexID, VertexID > > &pairs)
 Bridge f0 and f1 by connecting the vertex pairs given in pairs. This function creates a cylindrical connection between f0 and f1. f0 and f1 are removed and the vertices given in pairs are connected by edges. The result is a cylindrical connection that changes the genus of the object.
void collapse_edge (HalfEdgeID h, bool avg_vertices=false)
 Collapse the halfedge h. The argument h is the halfedge being removed. The vertex v=h->opp->vert is the one being removed while h->vert survives. The final argument indicates whether the surviving vertex should have the average position of the former vertices. By default false meaning that the surviving vertex retains it position. This function is not guaranteed to keep the mesh sane unless, precond_collapse_edge has returned true !!
FaceID split_face_by_edge (FaceID f, VertexID v0, VertexID v1)
 Split a face. The face, f, is split by creating an edge with endpoints v0 and v1 (the next two arguments). The vertices of the old face between v0 and v1 (in counter clockwise order) continue to belong to f. The vertices between v1 and v0 belong to the new face. A handle to the new face is returned.
VertexID split_face_by_vertex (FaceID f)
 Split a polygon, f, by inserting a vertex at the barycenter. This function is less likely to create flipped triangles than the split_face_triangulate function. On the other hand, it introduces more vertices and probably makes the triangles more acute. A handle to the inserted vertex is returned.
VertexID split_edge (HalfEdgeID h)
 Insert a new vertex on halfedge h. The new halfedge is insterted as the previous edge to h. A handle to the inserted vertex is returned.
bool merge_faces (FaceID f, HalfEdgeID h)
 Merges two faces into a single polygon. The first face is f. The second face is adjacent to f along the halfedge h. This function returns true if the merging was possible and false otherwise. Currently merge only fails if the mesh is already illegal. Thus it should, in fact, never fail.
FaceID merge_one_ring (VertexID v, float max_loop_length=FLT_MAX)
 Merge all faces in the one ring of a vertex into a single polygon. The vertex is given by v.
void close_hole (HalfEdgeID h)
 Close hole given by the invalid face of halfedgehandle h.
void flip_edge (HalfEdgeID h)
 Flip an edge h.
size_t active_vertices () const
 Get number of vertices.
size_t active_halfedges () const
 Get number of halfedges.
size_t active_faces () const
 Get number of faces.
size_t total_vertices () const
 Get number of vertices.
size_t total_halfedges () const
 Get number of halfedges.
size_t total_faces () const
 Get number of faces.
bool in_use (VertexID id) const
bool in_use (FaceID id) const
bool in_use (HalfEdgeID id) const
VertexIDIterator vertices_begin (bool skip=true) const
 Iterator to first VertexID, optional argument defines if unused items should be skipped.
FaceIDIterator faces_begin (bool skip=true) const
 Iterator to first FaceID, optional argument defines if unused items should be skipped.
HalfEdgeIDIterator halfedges_begin (bool skip=true) const
 Iterator to first HalfEdgeID, optional argument defines if unused items should be skipped.
VertexIDIterator vertices_end () const
 Iterator to past the end VertexID.
FaceIDIterator faces_end () const
 Iterator topast the end FaceID.
HalfEdgeIDIterator halfedges_end () const
 Iterator to past the end HalfEdgeID.
HalfEdgeWalker halfedgewalker (VertexID id) const
 Returns a HalfEdgeWalker to the out halfedge of vertex given by VertexID.
HalfEdgeWalker halfedgewalker (FaceID id) const
 Returns a HalfEdgeWalker to the last halfedge of face given by FaceID.
HalfEdgeWalker halfedgewalker (HalfEdgeID id) const
 Returns a HalfEdgeWalker to the halfedge given by HalfEdgeID.
CGLA::Vec3fpos (VertexID id)
 Return reference to position given by VertexID.
const CGLA::Vec3fpos (VertexID id) const
 Return const reference to position given by VertexID.
void clear ()
 Clear the mesh.
void cleanup (IDRemap &map)
 Remove unused items from Mesh, map argument is to be used for attribute vector cleanups in order to maintain sync.
void cleanup ()
 Remove unused items from Mesh.

Member Function Documentation

vector< HalfEdgeID > HMesh::Manifold::bridge_faces ( FaceID  f0,
FaceID  f1,
const std::vector< std::pair< VertexID, VertexID > > &  pairs 
)

Bridge f0 and f1 by connecting the vertex pairs given in pairs. This function creates a cylindrical connection between f0 and f1. f0 and f1 are removed and the vertices given in pairs are connected by edges. The result is a cylindrical connection that changes the genus of the object.

This function leaves all error checking in the hands of the user (for now). The faces clearly should not have any vertices or edges in common as this will create a non-manifold situation. Also the faces should face towards or away from each other and be in a position where it is reasonable to make the bridge. The connections should also make sense from a geometric point of view and should be in a counter clockwise loop on f0 and a clockwise loop on f1. No need to connect all vertices.

The function returns a vector of HalfEdgeIDs. Those are, of course, the connecting halfedges - also the opposite edges.

FaceID HMesh::Manifold::merge_one_ring ( VertexID  v,
float  max_loop_length = FLT_MAX 
)

Merge all faces in the one ring of a vertex into a single polygon. The vertex is given by v.

The return value is the FaceID of the resulting polygonal face. InvalidFaceID is returned if

  • the input vertex is not in use or
  • the input vertex has valence less than two which is a degenerate case.
  • the input vertex is a boundary vertex of valence two - i.e. adjacent to just one face.
  • the same halfedge appears in two faces of the one ring of the input vertex: I.e. the input vertex is twice adjacent to the same face!

Note that this function can create some unusual and arguably degenerate meshes. For instance, two triangles which share all vertices is collapsed to a single pair of vertices connected by a pair of halfedges bounding the same face.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations