Easy3D 2.6.1
Loading...
Searching...
No Matches
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
76 static int stitch_borders(SurfaceMesh *mesh);
77
88
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
137 static void repair_polygon_soup(std::vector<vec3> &points, std::vector<Polygon> &polygons);
138
155 static void repair_polygon_soup(SurfaceMesh *mesh);
156
158
159
161
162
171 static unsigned int remove_degenerate_faces(SurfaceMesh *mesh, float length_threshold = 1e-5);
172
184 static void detect_overlapping_faces(
185 SurfaceMesh *mesh,
186 std::vector<std::pair<SurfaceMesh::Face, SurfaceMesh::Face> > &duplicate_faces,
187 std::vector<std::pair<SurfaceMesh::Face, SurfaceMesh::Face> > &folding_faces,
188 double dist_threshold = 1e-6
189 );
190
202 static unsigned int remove_overlapping_faces(
203 SurfaceMesh *mesh,
204 bool folding_faces = false,
205 double dist_threshold = 1e-6
206 );
208
209
211
212
221 static std::vector<std::pair<SurfaceMesh::Face, SurfaceMesh::Face> >
223
232 static bool remesh_self_intersections(SurfaceMesh *mesh, bool stitch = true);
234
235
237
238
251 static bool clip(SurfaceMesh *mesh, const Plane3 &plane, bool clip_volume = false);
252
260 static void split(SurfaceMesh *mesh, const Plane3 &plane);
261
276 static std::vector<Polyline> slice(SurfaceMesh *mesh, const Plane3 &plane);
277
293 static std::vector< std::vector<Polyline> > slice(SurfaceMesh *mesh, const std::vector<Plane3> &planes);
295 };
296}
297
298
299#endif // EASY3D_ALGO_SURFACER_H
300
A halfedge data structure for polygonal meshes of 2-manifold.
Definition surface_mesh.h:51
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 remeshes 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 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)
Splits 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
GenericPlane< float > Plane3
A 3D plane of float type.
Definition types.h:103