Easy3D 2.5.3
surface_mesh_stitching.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_STITCHING_H
28#define EASY3D_ALGO_SURFACE_MESH_STITCHING_H
29
30
31#include <vector>
32#include <easy3d/core/surface_mesh.h>
33
34namespace easy3d {
35
36
48 public:
50
51 virtual ~SurfaceMeshStitching();
52
53 void apply(float dist_threshold = 1e-6);
54
55 private:
56
57 // given a border halfedge h (its face is nullptr), return the matched border halfedge.
58 // - if multiple edges match, return the closest one;
59 // - if could not found, return an invalid halfedge.
60 SurfaceMesh::Halfedge matched_border(SurfaceMesh::Halfedge h, float squared_dist_threshold) const;
61
62 // given a border halfedge, return all border halfedges that are within a distance threshold.
63 void borders_in_range(
64 SurfaceMesh::Halfedge h, float squared_dist_threshold,
65 std::vector<SurfaceMesh::Halfedge> &neighbors
66 ) const;
67
68 // the coordinates of a halfedge: represented by its two end points going from the xyz-lexicographically
69 // smaller endpoint toward the xyz-lexicographically larger end point.
70 void assign_edge_coordinate(float* coords, SurfaceMesh::Halfedge) const;
71
72 bool lexicographically_smaller(const vec3 &p0, const vec3 &p1) const;
73
74 float squared_distance(SurfaceMesh::Halfedge h1, SurfaceMesh::Halfedge h2) const;
75
76 protected:
77 SurfaceMesh *mesh_;
78
79 std::vector<SurfaceMesh::Halfedge> border_edges_;
80
81 // the coordinates of all the border edges. Each halfedge is represented by its two end points going from the
82 // xyz-lexicographically smaller endpoint toward the xyz-lexicographically larger end point.
83 float **coordinates_;
84
85 void *tree_;
86 int k_for_radius_search_;
87 };
88
89} // namespace easy3d
90
91
92#endif // EASY3D_ALGO_SURFACE_MESH_STITCHING_H
A halfedge data structure for polygonal meshes of 2-manifold.
Definition: surface_mesh.h:52
Stitch coincident border edges of a surface mesh.
Definition: surface_mesh_stitching.h:47
Definition: collider.cpp:182
Definition: surface_mesh.h:114