Easy3D 2.6.1
Loading...
Searching...
No Matches
surface_mesh_components.h
1/********************************************************************
2 * Copyright (C) 2015-2021 by Liangliang Nan <liangliang.nan@gmail.com>
3 * Copyright (C) 2000-2005 INRIA - Project ALICE
4 *
5 * The code in this file is partly from OGF/Graphite (2.0 alpha-4) with
6 * modifications and enhancement:
7 * https://gforge.inria.fr/forum/forum.php?forum_id=11459
8 * The original code was distributed under the GNU GPL license.
9 ********************************************************************/
10
11#ifndef EASY3D_ALGO_SURFACE_MESH_COMPONENTS_H
12#define EASY3D_ALGO_SURFACE_MESH_COMPONENTS_H
13
14#include <vector>
15
16#include <easy3d/core/surface_mesh.h>
17
18
19namespace easy3d {
20
28 public:
29 // convenient type definitions
34
35 public:
41
48 static std::vector<SurfaceMeshComponent> extract(SurfaceMesh *mesh, bool descending = true);
49
57
65
70 const std::vector<Face> &faces() const { return faces_; }
71
76 const std::vector<Vertex> &vertices() const { return vertices_; }
77
82 const std::vector<Edge> &edges() const { return edges_; }
83
88 const std::vector<Halfedge> &halfedges() const { return halfedges_; }
89
94 std::size_t n_faces() const { return faces_.size(); }
95
100 std::size_t n_vertices() const { return vertices_.size(); }
101
106 std::size_t n_edges() const { return edges_.size(); }
107
112 std::size_t n_halfedges() const { return halfedges_.size(); }
113
118 SurfaceMesh *mesh() const { return mesh_; }
119
125 float area() const;
126
131 float border_length() const;
132
137 Box3 bbox() const;
138
143 void translate(const vec3 &offset);
144
149 SurfaceMesh *to_mesh() const;
150
151 private:
152 SurfaceMesh *mesh_;
153 std::vector<Face> faces_;
154 std::vector<Vertex> vertices_;
155 std::vector<Halfedge> halfedges_;
156 std::vector<Edge> edges_;
157 };
158
159}
160
161#endif // EASY3D_ALGO_SURFACE_MESH_COMPONENTS_H
162
A connected component of a SurfaceMesh.
Definition surface_mesh_components.h:27
const std::vector< Edge > & edges() const
Returns the list of edges in this component.
Definition surface_mesh_components.h:82
SurfaceMesh::Vertex Vertex
Vertex type.
Definition surface_mesh_components.h:31
const std::vector< Vertex > & vertices() const
Returns the list of vertices in this component.
Definition surface_mesh_components.h:76
SurfaceMesh * to_mesh() const
Constructs a surface mesh from this component.
Definition surface_mesh_components.cpp:53
SurfaceMesh::Face Face
Face type.
Definition surface_mesh_components.h:30
void translate(const vec3 &offset)
Translates this component by an offset vector.
Definition surface_mesh_components.cpp:180
static std::vector< SurfaceMeshComponent > extract(SurfaceMesh *mesh, bool descending=true)
Extracts connected components from the given mesh.
Definition surface_mesh_components.cpp:187
float area() const
Returns the surface area of this component.
Definition surface_mesh_components.cpp:119
std::size_t n_faces() const
Returns the number of faces in this component.
Definition surface_mesh_components.h:94
const std::vector< Halfedge > & halfedges() const
Returns the list of halfedges in this component.
Definition surface_mesh_components.h:88
SurfaceMesh::Halfedge Halfedge
Halfedge type.
Definition surface_mesh_components.h:33
std::size_t n_vertices() const
Returns the number of vertices in this component.
Definition surface_mesh_components.h:100
Box3 bbox() const
Returns the bounding box of this component.
Definition surface_mesh_components.cpp:171
SurfaceMesh::Edge Edge
Edge type.
Definition surface_mesh_components.h:32
const std::vector< Face > & faces() const
Returns the list of faces in this component.
Definition surface_mesh_components.h:70
std::size_t n_edges() const
Returns the number of edges in this component.
Definition surface_mesh_components.h:106
SurfaceMesh * mesh() const
Returns the surface mesh to which this component belongs.
Definition surface_mesh_components.h:118
SurfaceMeshComponent(SurfaceMesh *mesh)
Constructor that initializes the component with a given mesh.
Definition surface_mesh_components.h:40
float border_length() const
Returns the total border length of this component.
Definition surface_mesh_components.cpp:155
std::size_t n_halfedges() const
Returns the number of halfedges in this component.
Definition surface_mesh_components.h:112
A halfedge data structure for polygonal meshes of 2-manifold.
Definition surface_mesh.h:51
Definition collider.cpp:182
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
GenericBox< 3, float > Box3
A 3D axis-aligned bounding box of float type.
Definition types.h:108
Definition surface_mesh.h:173
Definition surface_mesh.h:191
This type represents a halfedge (internally it is basically an index).
Definition surface_mesh.h:155
This type represents a vertex (internally it is basically an index).
Definition surface_mesh.h:135