Skip to content

Commit 3654f78

Browse files
authored
Initialize the lower bound face in traversal of the AABB-tree for Hausdorff distance (#9041)
## Summary of Changes Solve issue_7164 ## Release Management * Affected package(s): Polygon_mesh_processing * Issue(s) solved (if any): fix #7164 * Feature/Small Feature (if any): * Link to compiled documentation (obligatory for small feature) [*wrong link name to be changed*](httpssss://wrong_URL_to_be_changed/Manual/Pkg) * License and copyright ownership: GF
2 parents dc2b48b + 24f70c8 commit 3654f78

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1687,8 +1687,9 @@ bounded_error_squared_Hausdorff_distance_impl(const TriangleMesh1& tm1,
16871687
// Thus, subdivision can only decrease the min, and the upper bound.
16881688
Local_bounds<Kernel, Face_handle_1, Face_handle_2> bounds(triangle_bounds.upper);
16891689

1690-
// Ensure 'uface' is initialized in case the upper bound is not changed by the subdivision
1690+
// Ensure 'lface' and 'uface' are initialized in case the bounds are not changed by the subdivision
16911691
bounds.tm2_uface = triangle_bounds.tm2_uface;
1692+
bounds.tm2_lface = triangle_bounds.tm2_lface;
16921693

16931694
TM2_hd_traits traversal_traits_tm2(sub_t1_bbox, tm2, vpm2, bounds, global_bounds, infinity_value);
16941695
tm2_tree.traversal_with_priority(sub_triangles[i], traversal_traits_tm2);

Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ create_single_source_cgal_program("test_pmp_np_function.cpp")
6767
create_single_source_cgal_program("test_degenerate_pmp_clip_split_corefine.cpp")
6868
create_single_source_cgal_program("test_corefinement_cavities.cpp")
6969
create_single_source_cgal_program("issue_8730.cpp")
70+
create_single_source_cgal_program("issue_7164.cpp")
7071
# create_single_source_cgal_program("test_pmp_repair_self_intersections.cpp")
7172

7273
find_package(Eigen3 3.2.0 QUIET) #(requires 3.2.0 or greater)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#include <CGAL/Surface_mesh.h>
2+
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
3+
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>
4+
#include <CGAL/Polygon_mesh_processing/distance.h>
5+
#include <CGAL/Random.h>
6+
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
7+
using Point_3 = Kernel::Point_3;
8+
using Mesh = CGAL::Surface_mesh<Point_3>;
9+
namespace PMP = CGAL::Polygon_mesh_processing;
10+
11+
int main(/*int argc, char** argv*/)
12+
{
13+
// A simple triangle
14+
std::vector<Point_3> pts_A;
15+
std::vector<std::vector<size_t>> trs_A;
16+
pts_A.emplace_back( 0.26641936088212415, 0.2664193608821242, 0.73358063911787585);
17+
pts_A.emplace_back(-0.14011519816541251, 0.6017979969632727, 1.1810107045967466);
18+
pts_A.emplace_back(-0.14011519816541279,-0.1810107045967464, 0.39820200303672726);
19+
trs_A.emplace_back(std::vector<size_t>{0,1,2});
20+
Mesh A;
21+
PMP::polygon_soup_to_polygon_mesh(pts_A, trs_A, A);
22+
23+
// An open tetrahedron
24+
std::vector<Point_3> pts_B;
25+
std::vector<std::vector<size_t>> trs_B;
26+
pts_B.emplace_back(0,0,0);
27+
pts_B.emplace_back(1,1,0);
28+
pts_B.emplace_back(1,0,1);
29+
pts_B.emplace_back(0,1,1);
30+
trs_B.emplace_back(std::vector<size_t>{0,1,2});
31+
trs_B.emplace_back(std::vector<size_t>{3,1,0});
32+
trs_B.emplace_back(std::vector<size_t>{3,2,1});
33+
Mesh B;
34+
PMP::polygon_soup_to_polygon_mesh(pts_B, trs_B, B);
35+
36+
double bound = 0.01 * 0.42149467833714593;
37+
PMP::bounded_error_Hausdorff_distance<CGAL::Sequential_tag>(A, B, bound);
38+
PMP::bounded_error_Hausdorff_distance<CGAL::Sequential_tag>(B, A, bound);
39+
40+
// The bug was possible with closed models
41+
std::vector<Point_3> pts_C;
42+
std::vector<std::vector<size_t>> trs_C;
43+
pts_C.emplace_back(0,0,0);
44+
pts_C.emplace_back(1,1,0);
45+
pts_C.emplace_back(1,0,1);
46+
pts_C.emplace_back(0,1,1);
47+
pts_C.emplace_back(0.75,0.75,0);
48+
trs_C.emplace_back(std::vector<size_t>{0,1,2});
49+
trs_C.emplace_back(std::vector<size_t>{3,1,0});
50+
trs_C.emplace_back(std::vector<size_t>{3,2,1});
51+
trs_C.emplace_back(std::vector<size_t>{0,2,4});
52+
trs_C.emplace_back(std::vector<size_t>{3,0,4});
53+
trs_C.emplace_back(std::vector<size_t>{3,4,2});
54+
Mesh C;
55+
PMP::polygon_soup_to_polygon_mesh(pts_C, trs_C, C);
56+
57+
PMP::bounded_error_Hausdorff_distance<CGAL::Sequential_tag>(A, C, bound);
58+
PMP::bounded_error_Hausdorff_distance<CGAL::Sequential_tag>(C, A, bound);
59+
60+
return EXIT_SUCCESS;
61+
}

0 commit comments

Comments
 (0)