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

A helper class for constructing manifold surface mesh models. More...

#include <easy3d/core/surface_mesh_builder.h>

Public Types

typedef SurfaceMesh::Vertex Vertex
 Vertex type.
 
typedef SurfaceMesh::Halfedge Halfedge
 Halfedge type.
 
typedef SurfaceMesh::Face Face
 Face type.
 

Public Member Functions

 SurfaceMeshBuilder (SurfaceMesh *mesh)
 Constructor that initializes the builder with a given surface mesh.
 
 ~SurfaceMeshBuilder ()
 Destructor.
 
void begin_surface ()
 Begin surface construction.
 
Vertex add_vertex (const vec3 &p)
 Add a vertex to the mesh.
 
Face add_face (const std::vector< Vertex > &vertices)
 Add a face to the mesh.
 
Face add_triangle (Vertex v1, Vertex v2, Vertex v3)
 Add a new triangle face connecting vertices v1, v2, and v3.
 
Face add_quad (Vertex v1, Vertex v2, Vertex v3, Vertex v4)
 Add a new quad face connecting vertices v1, v2, v3, and v4.
 
void end_surface (bool log_issues=true)
 Finalize surface construction.
 
const std::vector< Vertex > & face_vertices () const
 Get the actual vertices of the previously added face.
 

Detailed Description

A helper class for constructing manifold surface mesh models.

SurfaceMeshBuilder resolves non-manifoldness while building a surface mesh. It is typically used to load a model from a file (because you don't know if the mesh is manifold or not). For meshes guaranteed to be manifold, you can also use the built-in add_vertex() and add_[face/triangle/quad]() functions of SurfaceMesh for their construction. Example use:

SurfaceMeshBuilder builder(mesh);
builder.begin_surface();
for_each_vertex:
builder.add_vertex(p);
for_each_face:
builder.add_face(ids); // ids: the vertices of the face
builder.end_surface();
SurfaceMeshBuilder(SurfaceMesh *mesh)
Constructor that initializes the builder with a given surface mesh.
Definition surface_mesh_builder.cpp:44
Examples
Tutorial_104_SurfaceMesh/main.cpp.

Constructor & Destructor Documentation

◆ SurfaceMeshBuilder()

SurfaceMeshBuilder ( SurfaceMesh * mesh)
explicit

Constructor that initializes the builder with a given surface mesh.

Parameters
meshThe surface mesh to build.

Member Function Documentation

◆ add_face()

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

Add a face to the mesh.

Parameters
verticesThe vertices of the face.
Returns
The added face on success.
See also
add_triangle(), add_quad().

◆ add_quad()

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

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

Parameters
v1The first vertex of the quad.
v2The second vertex of the quad.
v3The third vertex of the quad.
v4The fourth vertex of the quad.
Returns
The added face on success.
See also
add_face(), add_triangle().

◆ add_triangle()

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

Add a new triangle face connecting vertices v1, v2, and v3.

Parameters
v1The first vertex of the triangle.
v2The second vertex of the triangle.
v3The third vertex of the triangle.
Returns
The added face on success.
See also
add_face(), add_quad().
Examples
Tutorial_104_SurfaceMesh/main.cpp.

◆ add_vertex()

SurfaceMesh::Vertex add_vertex ( const vec3 & p)

Add a vertex to the mesh.

Parameters
pThe 3D coordinates of the vertex.
Returns
The added vertex on success.
Examples
Tutorial_104_SurfaceMesh/main.cpp.

◆ begin_surface()

void begin_surface ( )

Begin surface construction.

Must be called at the beginning of the surface construction and used in pair with end_surface() at the end of surface mesh construction.

See also
end_surface().
Examples
Tutorial_104_SurfaceMesh/main.cpp.

◆ end_surface()

void end_surface ( bool log_issues = true)

Finalize surface construction.

Must be called at the end of the surface construction and used in pair with begin_surface() at the beginning of surface mesh construction.

Parameters
log_issuesTrue to log the issues detected and a report on the process of the issues to the log file.
See also
begin_surface().
Examples
Tutorial_104_SurfaceMesh/main.cpp.

◆ face_vertices()

const std::vector< Vertex > & face_vertices ( ) const
inline

Get the actual vertices of the previously added face.

The order of the vertices are the same as those provided to add_[face/triangle/quad]() for the construction of the face.

Attention
The result is valid if the face was successfully added, and it will remain valid until the next call to add_[face/triangle/quad]() and end_surface().
Returns
A vector containing the vertices of the face.

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