Easy3D 2.5.3
surface_mesh_remeshing.h
1/********************************************************************
2 * Copyright (C) 2020-2021 by Liangliang Nan <liangliang.nan@gmail.com>
3 * Copyright (C) 2011-2020 the Polygon Mesh Processing Library developers.
4 *
5 * The code in this file is adapted from the PMP (Polygon Mesh Processing
6 * Library) with modifications.
7 * https://github.com/pmp-library/pmp-library
8 * The original code was distributed under a MIT-style license, see
9 * https://github.com/pmp-library/pmp-library/blob/master/LICENSE.txt
10 ********************************************************************/
11
12#ifndef EASY3D_ALGO_SURFACE_MESH_REMESHING_H
13#define EASY3D_ALGO_SURFACE_MESH_REMESHING_H
14
15#include <easy3d/core/surface_mesh.h>
16
17namespace easy3d {
18
19 class TriangleMeshKdTree;
20
32 public:
33 explicit SurfaceMeshRemeshing(SurfaceMesh *mesh);
34
36
41 void uniform_remeshing(float edge_length, unsigned int iterations = 10,
42 bool use_projection = true);
43
50 void adaptive_remeshing(float min_edge_length, float max_edge_length,
51 float approx_error, unsigned int iterations = 10,
52 bool use_projection = true);
53
54 private:
55 void preprocessing();
56 void postprocessing();
57 void split_long_edges();
58 void collapse_short_edges();
59 void flip_edges();
60 void tangential_smoothing(unsigned int iterations);
61 void remove_caps();
62 vec3 minimize_squared_areas(SurfaceMesh::Vertex v);
63 vec3 weighted_centroid(SurfaceMesh::Vertex v);
64 void project_to_reference(SurfaceMesh::Vertex v);
65 bool is_too_long(SurfaceMesh::Vertex v0, SurfaceMesh::Vertex v1) const {
66 return distance(points_[v0], points_[v1]) >
67 4.0 / 3.0 * std::min(vsizing_[v0], vsizing_[v1]);
68 }
69
70 bool is_too_short(SurfaceMesh::Vertex v0, SurfaceMesh::Vertex v1) const {
71 return distance(points_[v0], points_[v1]) <
72 4.0 / 5.0 * std::min(vsizing_[v0], vsizing_[v1]);
73 }
74
75 private:
76 SurfaceMesh *mesh_;
77 SurfaceMesh *refmesh_;
78
79 bool use_projection_;
80 TriangleMeshKdTree *kd_tree_;
81
82 bool uniform_;
83 float target_edge_length_;
84 float min_edge_length_;
85 float max_edge_length_;
86 float approx_error_;
87
95
99 };
100
101} // namespace easy3d
102
103#endif // EASY3D_ALGO_SURFACE_MESH_REMESHING_H
Definition: surface_mesh.h:233
Definition: surface_mesh.h:185
A halfedge data structure for polygonal meshes of 2-manifold.
Definition: surface_mesh.h:52
A class for uniform and adaptive surface remeshing.
Definition: surface_mesh_remeshing.h:31
void adaptive_remeshing(float min_edge_length, float max_edge_length, float approx_error, unsigned int iterations=10, bool use_projection=true)
Perform adaptive remeshing.
Definition: surface_mesh_remeshing.cpp:70
void uniform_remeshing(float edge_length, unsigned int iterations=10, bool use_projection=true)
Perform uniform remeshing.
Definition: surface_mesh_remeshing.cpp:37
A k-d tree for triangular surface meshes.
Definition: triangle_mesh_kdtree.h:24
Definition: collider.cpp:182
T distance(const Vec< N, T > &v1, const Vec< N, T > &v2)
Computes the distance between two vectors/points.
Definition: vec.h:295
Definition: surface_mesh.h:104