Easy3D 2.5.3
surfacer.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
27#ifndef EASY3D_ALGO_SURFACER_H
28#define EASY3D_ALGO_SURFACER_H
29
30
31#include <vector>
32
33#include <easy3d/core/surface_mesh.h>
34
35
36namespace easy3d {
37
38
39 class SurfaceMesh;
40
52 class Surfacer {
53 public:
55 typedef std::vector<int> Polygon;
56
59 typedef std::vector<vec3> Polyline;
60
61 public:
62
64
65
77 static int stitch_borders(SurfaceMesh *mesh);
78
90
98
104 static void orient_closed_triangle_mesh(SurfaceMesh *mesh);
105
120 static bool orient_and_stitch_polygon_soup(std::vector<vec3> &points, std::vector<Polygon> &polygons);
121
135 static void repair_polygon_soup(std::vector<vec3> &points, std::vector<Polygon> &polygons);
136
152 static void repair_polygon_soup(SurfaceMesh *mesh);
153
155
156
158
159
167 static unsigned int remove_degenerate_faces(SurfaceMesh *mesh, float length_threshold = 1e-5);
168
179 static void detect_overlapping_faces(
180 SurfaceMesh *mesh,
181 std::vector<std::pair<SurfaceMesh::Face, SurfaceMesh::Face> > &duplicate_faces,
182 std::vector<std::pair<SurfaceMesh::Face, SurfaceMesh::Face> > &folding_faces,
183 double dist_threshold = 1e-6
184 );
185
195 static unsigned int remove_overlapping_faces(
196 SurfaceMesh *mesh,
197 bool folding_faces = false,
198 double dist_threshold = 1e-6
199 );
201
202
204
205
214 static std::vector<std::pair<SurfaceMesh::Face, SurfaceMesh::Face> >
216
225 static bool remesh_self_intersections(SurfaceMesh *mesh, bool stitch = true);
227
228
229
231
232
245 static bool clip(SurfaceMesh *mesh, const Plane3 &plane, bool clip_volume = false);
246
254 static void split(SurfaceMesh *mesh, const Plane3 &plane);
255
270 static std::vector<Polyline> slice(SurfaceMesh *mesh, const Plane3 &plane);
271
287 static std::vector< std::vector<Polyline> > slice(SurfaceMesh *mesh, const std::vector<Plane3> &planes);
289 };
290}
291
292
293#endif // EASY3D_ALGO_SURFACER_H
294
A halfedge data structure for polygonal meshes of 2-manifold.
Definition: surface_mesh.h:52
A collection of mesh (and polygon soup) processing functions.
Definition: surfacer.h:52
static bool remesh_self_intersections(SurfaceMesh *mesh, bool stitch=true)
Detects and remesh the intersecting faces.
Definition: surfacer.cpp:597
std::vector< int > Polygon
A polygon represented by a list of vertex indices.
Definition: surfacer.h:55
static void detect_overlapping_faces(SurfaceMesh *mesh, std::vector< std::pair< SurfaceMesh::Face, SurfaceMesh::Face > > &duplicate_faces, std::vector< std::pair< SurfaceMesh::Face, SurfaceMesh::Face > > &folding_faces, double dist_threshold=1e-6)
Detects duplicate faces and folding faces.
Definition: surfacer.cpp:538
static bool orient_and_stitch_polygon_soup(SurfaceMesh *mesh)
Tries to consistently orient and stitch a mesh (treated as a polygon soup).
Definition: surfacer.cpp:239
static unsigned int remove_overlapping_faces(SurfaceMesh *mesh, bool folding_faces=false, double dist_threshold=1e-6)
Removes duplicate faces and and folding faces.
Definition: surfacer.cpp:549
static int stitch_borders(SurfaceMesh *mesh)
Stitches together border halfedges in a polygon mesh.
Definition: surfacer.cpp:230
static void repair_polygon_soup(std::vector< vec3 > &points, std::vector< Polygon > &polygons)
Repairs a given polygon soup through various repairing operations.
Definition: surfacer.cpp:329
static unsigned int remove_degenerate_faces(SurfaceMesh *mesh, float length_threshold=1e-5)
Remove degenerate faces.
Definition: surfacer.cpp:471
static std::vector< std::pair< SurfaceMesh::Face, SurfaceMesh::Face > > detect_self_intersections(SurfaceMesh *mesh)
Collects all pairs of intersecting faces of a triangulated surface mesh.
Definition: surfacer.cpp:556
std::vector< vec3 > Polyline
Definition: surfacer.h:59
static bool clip(SurfaceMesh *mesh, const Plane3 &plane, bool clip_volume=false)
Clips a triangle mesh by keeping the part on the negative side of a plane (side opposite to its norma...
Definition: surfacer.cpp:382
static void merge_reversible_connected_components(SurfaceMesh *mesh)
Reverses the connected components having incompatible boundary cycles that could be merged if their o...
Definition: surfacer.cpp:254
static void split(SurfaceMesh *mesh, const Plane3 &plane)
Split a triangle mesh by a plane.
Definition: surfacer.cpp:403
static void orient_closed_triangle_mesh(SurfaceMesh *mesh)
Makes each connected component of a closed triangle surface mesh inward or outward oriented.
Definition: surfacer.cpp:278
static std::vector< Polyline > slice(SurfaceMesh *mesh, const Plane3 &plane)
Computes the intersection of a plane with a triangle surface mesh.
Definition: surfacer.cpp:419
Definition: collider.cpp:182