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

A connected component of a SurfaceMesh. More...

#include <easy3d/algo/surface_mesh_components.h>

Public Types

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

Public Member Functions

 SurfaceMeshComponent (SurfaceMesh *mesh)
 Constructor that initializes the component with a given mesh.
 
const std::vector< Face > & faces () const
 Returns the list of faces in this component.
 
const std::vector< Vertex > & vertices () const
 Returns the list of vertices in this component.
 
const std::vector< Edge > & edges () const
 Returns the list of edges in this component.
 
const std::vector< Halfedge > & halfedges () const
 Returns the list of halfedges in this component.
 
std::size_t n_faces () const
 Returns the number of faces in this component.
 
std::size_t n_vertices () const
 Returns the number of vertices in this component.
 
std::size_t n_edges () const
 Returns the number of edges in this component.
 
std::size_t n_halfedges () const
 Returns the number of halfedges in this component.
 
SurfaceMeshmesh () const
 Returns the surface mesh to which this component belongs.
 
float area () const
 Returns the surface area of this component.
 
float border_length () const
 Returns the total border length of this component.
 
Box3 bbox () const
 Returns the bounding box of this component.
 
void translate (const vec3 &offset)
 Translates this component by an offset vector.
 
SurfaceMeshto_mesh () const
 Constructs a surface mesh from this component.
 

Static Public Member Functions

static std::vector< SurfaceMeshComponentextract (SurfaceMesh *mesh, bool descending=true)
 Extracts connected components from the given mesh.
 
static SurfaceMeshComponent extract (SurfaceMesh *mesh, SurfaceMesh::Face seed)
 Extracts a single connected component from the given seed face.
 
static SurfaceMeshComponent extract (SurfaceMesh *mesh, SurfaceMesh::Vertex seed)
 Extracts a single connected component from the given seed vertex.
 

Detailed Description

A connected component of a SurfaceMesh.

Internally, A connected component of a SurfaceMesh stores four lists of SurfaceMesh elements, i.e., vertices, faces, edges, and halfedges.

Constructor & Destructor Documentation

◆ SurfaceMeshComponent()

SurfaceMeshComponent ( SurfaceMesh * mesh)
inlineexplicit

Constructor that initializes the component with a given mesh.

Parameters
meshThe surface mesh to which this component belongs.

Member Function Documentation

◆ area()

float area ( ) const

Returns the surface area of this component.

Internally it triangulates the face using the tessellator. So this method also works for concave faces.

Returns
The surface area.

◆ bbox()

Box3 bbox ( ) const

Returns the bounding box of this component.

Returns
The bounding box.

◆ border_length()

float border_length ( ) const

Returns the total border length of this component.

Returns
The total border length.

◆ edges()

const std::vector< Edge > & edges ( ) const
inline

Returns the list of edges in this component.

Returns
A constant reference to the vector of edges.

◆ extract() [1/3]

std::vector< SurfaceMeshComponent > extract ( SurfaceMesh * mesh,
bool descending = true )
static

Extracts connected components from the given mesh.

Parameters
meshThe surface mesh from which to extract components.
descendingIf true, the components are sorted in descending order by the number of faces.
Returns
A vector of extracted SurfaceMeshComponent objects.
Examples
Tutorial_204_Viewer_Qt/main.cpp.

◆ extract() [2/3]

SurfaceMeshComponent extract ( SurfaceMesh * mesh,
SurfaceMesh::Face seed )
static

Extracts a single connected component from the given seed face.

Parameters
meshThe surface mesh from which to extract the component.
seedThe seed face to start the extraction.
Returns
The extracted SurfaceMeshComponent object.

◆ extract() [3/3]

SurfaceMeshComponent extract ( SurfaceMesh * mesh,
SurfaceMesh::Vertex seed )
static

Extracts a single connected component from the given seed vertex.

Parameters
meshThe surface mesh from which to extract the component.
seedThe seed vertex to start the extraction.
Returns
The extracted SurfaceMeshComponent object.

◆ faces()

const std::vector< Face > & faces ( ) const
inline

Returns the list of faces in this component.

Returns
A constant reference to the vector of faces.

◆ halfedges()

const std::vector< Halfedge > & halfedges ( ) const
inline

Returns the list of halfedges in this component.

Returns
A constant reference to the vector of halfedges.

◆ mesh()

SurfaceMesh * mesh ( ) const
inline

Returns the surface mesh to which this component belongs.

Returns
A pointer to the surface mesh.

◆ n_edges()

std::size_t n_edges ( ) const
inline

Returns the number of edges in this component.

Returns
The number of edges.

◆ n_faces()

std::size_t n_faces ( ) const
inline

Returns the number of faces in this component.

Returns
The number of faces.

◆ n_halfedges()

std::size_t n_halfedges ( ) const
inline

Returns the number of halfedges in this component.

Returns
The number of halfedges.

◆ n_vertices()

std::size_t n_vertices ( ) const
inline

Returns the number of vertices in this component.

Returns
The number of vertices.

◆ to_mesh()

SurfaceMesh * to_mesh ( ) const

Constructs a surface mesh from this component.

Returns
A pointer to the constructed surface mesh.

◆ translate()

void translate ( const vec3 & offset)

Translates this component by an offset vector.

Parameters
offsetThe offset vector.

◆ vertices()

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

Returns the list of vertices in this component.

Returns
A constant reference to the vector of vertices.

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