Easy3D 2.6.1
Loading...
Searching...
No Matches
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
44 public:
50
54 virtual ~SurfaceMeshStitching();
55
60 void apply(float dist_threshold = 1e-6);
61
62 private:
63
64 // given a border halfedge h (its face is nullptr), return the matched border halfedge.
65 // - if multiple edges match, return the closest one;
66 // - if could not found, return an invalid halfedge.
67 SurfaceMesh::Halfedge matched_border(SurfaceMesh::Halfedge h, float squared_dist_threshold) const;
68
69 // given a border halfedge, return all border halfedges that are within a distance threshold.
70 void borders_in_range(
71 SurfaceMesh::Halfedge h, float squared_dist_threshold,
72 std::vector<SurfaceMesh::Halfedge> &neighbors
73 ) const;
74
75 // the coordinates of a halfedge: represented by its two end points going from the xyz-lexicographically
76 // smaller endpoint toward the xyz-lexicographically larger end point.
77 void assign_edge_coordinate(float* coords, SurfaceMesh::Halfedge) const;
78
79 bool lexicographically_smaller(const vec3 &p0, const vec3 &p1) const;
80
81 float squared_distance(SurfaceMesh::Halfedge h1, SurfaceMesh::Halfedge h2) const;
82
83 protected:
84 SurfaceMesh *mesh_;
85
86 std::vector<SurfaceMesh::Halfedge> border_edges_;
87
88 // the coordinates of all the border edges. Each halfedge is represented by its two end points going from the
89 // xyz-lexicographically smaller endpoint toward the xyz-lexicographically larger end point.
90 float **coordinates_;
91
92 void *tree_;
93 int k_for_radius_search_;
94 };
95
96} // namespace easy3d
97
98
99#endif // EASY3D_ALGO_SURFACE_MESH_STITCHING_H
A halfedge data structure for polygonal meshes of 2-manifold.
Definition surface_mesh.h:51
SurfaceMeshStitching(SurfaceMesh *mesh)
Construct with mesh to be stitched.
Definition surface_mesh_stitching.cpp:44
virtual ~SurfaceMeshStitching()
Destructor.
Definition surface_mesh_stitching.cpp:62
void apply(float dist_threshold=1e-6)
Apply stitching to the surface mesh.
Definition surface_mesh_stitching.cpp:169
Definition collider.cpp:182
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
This type represents a halfedge (internally it is basically an index).
Definition surface_mesh.h:155