From d7426630ea485b955e538993829903c7401861b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 13 Sep 2022 14:33:23 +0200 Subject: [PATCH 1/5] set stream precision to the max --- .../internal/Corefinement/face_graph_utils.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h index 1c6bdca4659..059edcdcdeb 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/face_graph_utils.h @@ -746,6 +746,7 @@ struct Patch_container{ Patch_description& patch=this->operator[](i); std::stringstream ss; + ss.precision(17); std::map vertexid; int id=0; for(vertex_descriptor vh : patch.interior_vertices) From 6f509a02ad65560570ef3033b311040a4cadca07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 13 Sep 2022 17:19:06 +0200 Subject: [PATCH 2/5] handle inconsistency of classification due to non-closed meshes --- .../Corefinement/Face_graph_output_builder.h | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h index 07268ec93ed..1ffffc8fd39 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h @@ -1038,6 +1038,54 @@ public: std::size_t patch_id_q1=tm2_patch_ids[ get(fids2, face(opposite(h2,tm2),tm2)) ]; std::size_t patch_id_q2=tm2_patch_ids[ get(fids2, face(h2,tm2)) ]; + // info on whether the patches were already classified + std::bitset<4> patch_status_was_not_already_set; + std::bitset<4> previous_bitvalue; + // info for tm1 + patch_status_was_not_already_set[0] = patch_status_not_set_tm1.test(patch_id_p1); + patch_status_was_not_already_set[1] = patch_status_not_set_tm1.test(patch_id_p2); + previous_bitvalue[0] = is_patch_inside_tm2.test(patch_id_p1); + previous_bitvalue[1] = is_patch_inside_tm2.test(patch_id_p2); + // info for tm2 + patch_status_was_not_already_set[2] = patch_status_not_set_tm2.test(patch_id_q1); + patch_status_was_not_already_set[3] = patch_status_not_set_tm2.test(patch_id_q2); + previous_bitvalue[2] = is_patch_inside_tm1.test(patch_id_q1); + previous_bitvalue[3] = is_patch_inside_tm1.test(patch_id_q2); + +#ifndef CGAL_NDEBUG + if (is_tm1_closed && is_tm2_closed) + { + if (!patch_status_was_not_already_set[0] && + !patch_status_was_not_already_set[1] && + !patch_status_was_not_already_set[2] && + !patch_status_was_not_already_set[3]) + continue; // all patches were already classified, no need to redo it + } +#endif + + // check incompatibility of patch classifications + auto inconsistent_classification = [&]() + { + if (!is_tm1_closed || !is_tm2_closed) + { + //make sure there is no ambiguity in tm1 + if( (patch_status_was_not_already_set[0] && previous_bitvalue[0]!=is_patch_inside_tm2[patch_id_p1] ) || + (patch_status_was_not_already_set[1] && previous_bitvalue[1]!=is_patch_inside_tm2[patch_id_p2] ) ) + { + impossible_operation.set(); + return true; + } + //make sure there is no ambiguity in tm2 + if( (patch_status_was_not_already_set[2] && previous_bitvalue[2]!=is_patch_inside_tm2[patch_id_q1] ) || + (patch_status_was_not_already_set[3] && previous_bitvalue[3]!=is_patch_inside_tm2[patch_id_q2] ) ) + { + impossible_operation.set(); + return true; + } + } + return false; + }; + //indicates that patch status will be updated patch_status_not_set_tm1.reset(patch_id_p1); patch_status_not_set_tm1.reset(patch_id_p2); @@ -1083,6 +1131,7 @@ public: if ( q2_is_between_p1p2 ) is_patch_inside_tm1.set(patch_id_q2); //case 1 else is_patch_inside_tm2.set(patch_id_p2); //case 2 + if (inconsistent_classification()) return; continue; } else{ @@ -1113,6 +1162,7 @@ public: is_patch_inside_tm1.set(patch_id_q1); is_patch_inside_tm2.set(patch_id_p2); } //else case 4 + if (inconsistent_classification()) return; continue; } else @@ -1143,6 +1193,7 @@ public: is_patch_inside_tm1.set(patch_id_q2); is_patch_inside_tm2.set(patch_id_p1); } // else case 6 + if (inconsistent_classification()) return; continue; } else{ @@ -1171,6 +1222,7 @@ public: if ( q1_is_between_p1p2 ) is_patch_inside_tm1.set(patch_id_q1); //case 7 else is_patch_inside_tm2.set(patch_id_p1); //case 8 + if (inconsistent_classification()) return; continue; } } @@ -1332,6 +1384,11 @@ public: } } } + if (inconsistent_classification()) return; + CGAL_assertion( patch_status_was_not_already_set[0] || previous_bitvalue[0]==is_patch_inside_tm2[patch_id_p1] ); + CGAL_assertion( patch_status_was_not_already_set[1] || previous_bitvalue[1]==is_patch_inside_tm2[patch_id_p2] ); + CGAL_assertion( patch_status_was_not_already_set[2] || previous_bitvalue[2]==is_patch_inside_tm1[patch_id_q1] ); + CGAL_assertion( patch_status_was_not_already_set[3] || previous_bitvalue[3]==is_patch_inside_tm1[patch_id_q2] ); } } From b3da3506d6790be95d9e9674a216c59f18ea2c51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 13 Sep 2022 17:55:02 +0200 Subject: [PATCH 3/5] add testcase that has an non-closed mesh and a close mesh incompatible for BO --- .../incompatible_with_open_cube.off | 96 +++++++++++++++++++ .../test_corefinement_bool_op.cmd | 1 + 2 files changed, 97 insertions(+) create mode 100644 Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/incompatible_with_open_cube.off diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/incompatible_with_open_cube.off b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/incompatible_with_open_cube.off new file mode 100644 index 00000000000..87267990f22 --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/data-coref/incompatible_with_open_cube.off @@ -0,0 +1,96 @@ +OFF +32 60 0 + +30 120 60 +30 120 30 +70 60 30 +60 120 60 +70 60 60 +60 120 30 +70 40 30 +130 60 30 +70 40 60 +30 -20 60 +60 -20 60 +30 -40 60 +30 -40 30 +130 60 60 +60 -20 30 +30 -20 30 +160 60 60 +160 -20 60 +60 -40 60 +60 -40 30 +130 -20 60 +130 -20 30 +160 -20 30 +130 40 60 +130 40 30 +160 -40 30 +160 40 30 +130 -40 30 +160 40 60 +130 -40 60 +160 -40 60 +160 60 30 +3 1 0 5 +3 0 9 3 +3 10 14 3 +3 5 0 3 +3 0 15 9 +3 3 14 5 +3 5 15 1 +3 14 15 5 +3 1 15 0 +3 3 9 10 +3 19 18 11 +3 9 18 10 +3 12 11 15 +3 12 19 11 +3 14 19 15 +3 19 12 15 +3 15 11 9 +3 11 18 9 +3 10 21 14 +3 19 29 18 +3 23 8 24 +3 19 27 29 +3 6 24 8 +3 18 29 10 +3 2 4 13 +3 29 20 10 +3 27 19 21 +3 14 21 19 +3 29 30 17 +3 22 25 21 +3 25 22 17 +3 21 25 27 +3 29 17 20 +3 30 25 17 +3 25 30 29 +3 27 25 29 +3 22 28 17 +3 4 2 8 +3 17 28 20 +3 20 23 24 +3 26 28 22 +3 21 24 22 +3 23 20 28 +3 24 26 22 +3 28 16 23 +3 31 26 7 +3 26 31 16 +3 24 7 26 +3 13 23 16 +3 31 7 16 +3 26 16 28 +3 7 13 16 +3 13 8 23 +3 24 2 7 +3 2 6 8 +3 24 6 2 +3 4 8 13 +3 7 2 13 +3 20 24 21 +3 21 10 20 + diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cmd b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cmd index d154ad0157d..99d70e20728 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cmd +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cmd @@ -1 +1,2 @@ ${CGAL_DATA_DIR}/meshes/elephant.off ${CGAL_DATA_DIR}/meshes/sphere.off ALL 1 1 1 1 +${CGAL_DATA_DIR}/meshes/open_cube.off data-coref/incompatible_with_open_cube.off ALL 0 0 0 0 From f5fb60ef66a83aab542eb43dfef1cd3df11f1f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 14 Sep 2022 10:18:16 +0200 Subject: [PATCH 4/5] handle cmd with several lines --- .../test_corefinement_bool_op.cpp | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cpp index 4822f03a76a..cc012385996 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cpp @@ -272,22 +272,43 @@ int main(int argc,char** argv) return 1; } - Result_checking rc; - - if (argc==8) + if (argc>8 && (argc-1)%7==0) { - rc.check=true; - rc.union_res = atoi(argv[4])!=0; - rc.inter_res = atoi(argv[5])!=0; - rc.P_minus_Q_res = atoi(argv[6])!=0; - rc.Q_minus_P_res = atoi(argv[7])!=0; + // cmd mode + for (int i=0;i(argv[i+1], argv[i+2], scenario, rc); + } } + else + { + Result_checking rc; - int scenario = -1; - if (argc>=5 && std::string(argv[3])!=std::string("ALL")) - scenario = atoi(argv[4]); + if (argc==8) + { + rc.check=true; + rc.union_res = atoi(argv[4])!=0; + rc.inter_res = atoi(argv[5])!=0; + rc.P_minus_Q_res = atoi(argv[6])!=0; + rc.Q_minus_P_res = atoi(argv[7])!=0; + } - run(argv[1], argv[2], scenario, rc); + int scenario = -1; + if (argc>=5 && std::string(argv[3])!=std::string("ALL")) + scenario = atoi(argv[3]); + + run(argv[1], argv[2], scenario, rc); + } return 0; } From d084d9396fbf75353faedd59ba74bea32bc7e6d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 14 Sep 2022 10:35:23 +0200 Subject: [PATCH 5/5] ignore new test for clipping --- .../internal/Corefinement/Face_graph_output_builder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h index 1ffffc8fd39..bb52550f111 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Corefinement/Face_graph_output_builder.h @@ -1066,7 +1066,7 @@ public: // check incompatibility of patch classifications auto inconsistent_classification = [&]() { - if (!is_tm1_closed || !is_tm2_closed) + if (!used_to_clip_a_surface && !used_to_classify_patches && (!is_tm1_closed || !is_tm2_closed)) { //make sure there is no ambiguity in tm1 if( (patch_status_was_not_already_set[0] && previous_bitvalue[0]!=is_patch_inside_tm2[patch_id_p1] ) ||