Easy3D 2.5.3
surface_mesh_polygonization.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_SURFACE_MESH_POLYGONIZATION_H
28#define EASY3D_ALGO_SURFACE_MESH_POLYGONIZATION_H
29
30#include <easy3d/core/surface_mesh.h>
31
32
33namespace easy3d {
34
41 public:
42
51 void apply(SurfaceMesh *mesh, float angle_threshold = 1.0f);
52
61 void merge_colinear_edges(SurfaceMesh *mesh, float angle_threshold = 1.0f);
62
63 private:
64 void internal_apply(SurfaceMesh *mesh, float angle_threshold);
65
66 typedef std::vector<SurfaceMesh::Halfedge> Loop;
67 std::vector<Loop> extract_boundary_loop(const SurfaceMesh *mesh, int comp_id, std::set<SurfaceMesh::Halfedge>& boundary_edges);
68
69 // classify the loops of a planar region into an "outer" loop and several "holes".
70 void classify(const SurfaceMesh *mesh, const std::vector<Loop>& loops, Loop& outer, std::vector<Loop>& holes);
71
72 // split a complex polygon (with duplicate vertices and possibly hole) into a set of convex polygons
73 typedef std::vector<SurfaceMesh::Vertex> Contour;
74 std::vector<Contour> split_complex_contour(
75 const Contour &outer_poly, // the outer polygon represented by a list of SurfaceMesh::Vertex
76 const std::vector<Contour> &hole_polys, // the holes each represented by a list of SurfaceMesh::Vertex
77 const vec3 &normal, // the normal of the polygon
78 const SurfaceMesh *mesh
79 ) const;
80
81 private:
82 SurfaceMesh::FaceProperty<int> planar_segments_;
83 };
84
85}
86
87#endif // EASY3D_ALGO_SURFACE_MESH_POLYGONIZATION_H
A halfedge data structure for polygonal meshes of 2-manifold.
Definition: surface_mesh.h:52
Merge connected coplanar faces into a general polygon face.
Definition: surface_mesh_polygonization.h:40
void merge_colinear_edges(SurfaceMesh *mesh, float angle_threshold=1.0f)
Removes 2-degree vertices.
Definition: surface_mesh_polygonization.cpp:357
void apply(SurfaceMesh *mesh, float angle_threshold=1.0f)
Merges connected coplanar faces into a general polygon face.
Definition: surface_mesh_polygonization.cpp:39
Definition: collider.cpp:182