From 1a54b648a4718e9d6f3192acc2be63a52742deeb Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Wed, 24 Apr 2024 17:44:14 +0200 Subject: [PATCH 1/4] turn off spamming --- .../test/Kinetic_space_partition/kinetic_3d_test_all.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kinetic_space_partition/test/Kinetic_space_partition/kinetic_3d_test_all.cpp b/Kinetic_space_partition/test/Kinetic_space_partition/kinetic_3d_test_all.cpp index cd433bd4087..77531de7cc0 100644 --- a/Kinetic_space_partition/test/Kinetic_space_partition/kinetic_3d_test_all.cpp +++ b/Kinetic_space_partition/test/Kinetic_space_partition/kinetic_3d_test_all.cpp @@ -39,7 +39,7 @@ bool run_test( std::cout << input_filename << std::endl; for (std::size_t i = 0; i < ks.size(); i++) { - KSP ksp(CGAL::parameters::verbose(true).debug(true)); + KSP ksp(CGAL::parameters::verbose(false).debug(false)); ksp.insert(input_vertices, input_faces); From 436a53e4b1f47a40799187027d14c5d630eb0667 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 25 Apr 2024 10:45:20 +0200 Subject: [PATCH 2/4] remove debug code less verbose output --- .../include/CGAL/KSP_2/Data_structure.h | 2 +- .../include/CGAL/KSP_3/Data_structure.h | 66 +------------------ .../include/CGAL/KSP_3/Propagation.h | 1 - .../include/CGAL/KSP_3/Support_plane.h | 12 ---- .../include/CGAL/Kinetic_space_partition_3.h | 16 +++-- 5 files changed, 13 insertions(+), 84 deletions(-) diff --git a/Kinetic_space_partition/include/CGAL/KSP_2/Data_structure.h b/Kinetic_space_partition/include/CGAL/KSP_2/Data_structure.h index 5ec82ee8cee..f6a2c9f78d6 100644 --- a/Kinetic_space_partition/include/CGAL/KSP_2/Data_structure.h +++ b/Kinetic_space_partition/include/CGAL/KSP_2/Data_structure.h @@ -38,7 +38,7 @@ public: typedef typename Kernel::Line_2 Line_2; typedef typename Kernel::Segment_2 Segment_2; - typedef Support_line_2 Support_line_DS; + typedef Support_line Support_line_DS; typedef CGAL::KSP_2::internal::Vertex Vertex; typedef CGAL::KSP_2::internal::Segment Segment; diff --git a/Kinetic_space_partition/include/CGAL/KSP_3/Data_structure.h b/Kinetic_space_partition/include/CGAL/KSP_3/Data_structure.h index 50b22231736..db2dc5892a0 100644 --- a/Kinetic_space_partition/include/CGAL/KSP_3/Data_structure.h +++ b/Kinetic_space_partition/include/CGAL/KSP_3/Data_structure.h @@ -211,7 +211,6 @@ public: pfaces.clear(); } }; - std::ofstream eventlog; private: std::vector m_support_planes; @@ -220,7 +219,6 @@ private: std::vector > m_input_polygons; - To_exact to_exact; From_exact from_exact; @@ -245,7 +243,6 @@ private: public: Data_structure(const Parameters& parameters, const std::string &prefix) : to_exact(), from_exact(), m_parameters(parameters), m_prefix(prefix) { - eventlog << std::setprecision(17); } template @@ -376,15 +373,11 @@ public: if (m_intersection_graph.iedge_is_on_bbox(edge)) return 0; - bool verbose = false; - // Count faces std::size_t numfaces = 0; for (std::size_t i = 0; i < m_support_planes.size(); i++) numfaces += m_support_planes[i].data().mesh.number_of_faces(); - eventlog << "#faces: " << numfaces << std::endl; - Support_plane& sp = m_support_planes[sp_idx]; To_exact to_exact; @@ -394,12 +387,6 @@ public: typename Intersection_graph::Kinetic_interval& kinetic_interval = m_intersection_graph.kinetic_interval(edge, sp_idx); -/* - if (kinetic_interval.size() != 0) { - int a; - a = 3; - }*/ - Point_2 s = sp.to_2d(from_exact(point_3(m_intersection_graph.source(edge)))); IkPoint_2 s2 = sp.to_2d(point_3(m_intersection_graph.source(edge))); Point_2 t = sp.to_2d(from_exact(point_3(m_intersection_graph.target(edge)))); @@ -431,20 +418,6 @@ public: else event.face = faces.first; - if (event.face == 403 && m_intersection_graph.source(edge) == 393 && m_intersection_graph.target(edge) == 382) { - verbose = true; - eventlog << "triggered" << std::flush; - } - - if (verbose) { - eventlog << "s: " << s.x() << " " << s.y() << std::endl; - eventlog << "t: " << t.x() << " " << t.y() << std::endl; - eventlog << "segment: " << segment << std::endl; - eventlog << "segment_length: " << segment_length << std::endl; - eventlog << "to_source: " << to_source << std::endl; - eventlog << "to_target: " << to_target << std::endl; - } - for (std::size_t i = 0; i < sp.data().original_directions.size(); i++) { if (source_idx == uninitialized && sp.data().original_directions[i] > to_source) source_idx = i; @@ -462,13 +435,6 @@ public: IkVector_2 tt2 = to_target2.vector(), ts2 = to_source2.vector(); bool ccw = (tt2.x() * ts2.y() - tt2.y() * ts2.x()) < 0; - if (verbose) { - eventlog << "source_idx: " << source_idx << std::endl; - eventlog << "target_idx: " << target_idx << std::endl; - eventlog << "tt2: " << from_exact(tt2) << std::endl; - eventlog << "ccw: " << ccw << std::endl; - } - // Check whether the segment is cw or ccw oriented. if (!ccw) { std::size_t tmp = source_idx; @@ -484,11 +450,6 @@ public: t2 = tmp_p2; } - if (verbose) { - eventlog << "s2: " << from_exact(s2) << std::endl; - eventlog << "t2: " << from_exact(t2) << std::endl; - } - if (source_idx <= target_idx) num = target_idx - source_idx; else @@ -498,10 +459,6 @@ public: std::vector intersections(num); std::vector intersections_bary(num); - if (verbose) { - eventlog << "num: " << num << std::endl; - } - // Shooting rays to find intersection with line of IEdge typename Intersection_kernel::Line_3 l3 = m_intersection_graph.line_3(edge); const typename Intersection_kernel::Line_2 l = sp.to_2d(l3); @@ -514,8 +471,6 @@ public: } IkPoint_2 p; FT diff = sp.data().original_vectors[idx].squared_length() - from_exact(sp.data().original_rays[idx].to_vector().squared_length()); - if (CGAL::abs(diff) > 0.001) - eventlog << "diff: " << diff << std::endl; if (CGAL::assign(p, result)) { IkFT l = CGAL::approximate_sqrt(sp.data().original_vectors[idx].squared_length()); @@ -533,18 +488,6 @@ public: // If the intersection is a segment, it can be safely ignored as there are also two intersections with the adjacent edges. } - if (verbose) { - eventlog << "intersections_bary:"; - for (IkFT bary : intersections_bary) - eventlog << " " << from_exact(bary); - eventlog << std::endl; - - eventlog << "intersections:"; - for (IkPoint_2 p : intersections) - eventlog << " " << from_exact(p); - eventlog << std::endl; - } - // Calculate pedge vs ivertex collision IkFT edge_time[2]; @@ -613,17 +556,16 @@ public: event.intersection_bary = 1; } -/* + if (kinetic_interval.size() > 4) { if (kinetic_interval[2].first > kinetic_interval[1].first) { int a; a = 2; } - }*/ + } CGAL_assertion(0 <= event.intersection_bary && event.intersection_bary <= 1); - eventlog.flush(); return event.time; } @@ -634,8 +576,6 @@ public: for (std::size_t i = 0; i < m_support_planes.size(); i++) faces += m_support_planes[i].data().mesh.number_of_faces(); - eventlog << "#faces: " << faces << std::endl; - for (std::size_t sp_idx = 6; sp_idx < m_support_planes.size(); sp_idx++) { std::vector border; m_support_planes[sp_idx].get_border(m_intersection_graph, border); @@ -647,8 +587,6 @@ public: Face_event fe; IkFT t = calculate_edge_intersection_time(sp_idx, edge, fe); if (t > 0) { - eventlog << CGAL::to_double(fe.time) << ": " << fe.support_plane << " " << fe.face << " " << fe.crossed_edge << " " << CGAL::to_double(fe.intersection_bary) << std::endl; - eventlog.flush(); queue.push(fe); } } diff --git a/Kinetic_space_partition/include/CGAL/KSP_3/Propagation.h b/Kinetic_space_partition/include/CGAL/KSP_3/Propagation.h index 59033902abf..26e9e228a8a 100644 --- a/Kinetic_space_partition/include/CGAL/KSP_3/Propagation.h +++ b/Kinetic_space_partition/include/CGAL/KSP_3/Propagation.h @@ -140,7 +140,6 @@ private: ********************************/ void apply(const Face_event& event) { - m_data.eventlog << "."; if (m_data.igraph().face(event.face).part_of_partition) { return; } diff --git a/Kinetic_space_partition/include/CGAL/KSP_3/Support_plane.h b/Kinetic_space_partition/include/CGAL/KSP_3/Support_plane.h index 085eedd65d2..d719f56307a 100644 --- a/Kinetic_space_partition/include/CGAL/KSP_3/Support_plane.h +++ b/Kinetic_space_partition/include/CGAL/KSP_3/Support_plane.h @@ -729,18 +729,6 @@ public: const Vertex_index add_vertex(const Point_2& point) { return m_data->mesh.add_vertex(point); } -/* - - const Vertex_index duplicate_vertex(const Vertex_index& v) { - // TODO: We cannot take it by reference because it fails for EPECK - // when called from front_and_back_34() in Data_structure. - const auto pp = m_data->mesh.point(v); - const auto vi = m_data->mesh.add_vertex(pp); - m_data->direction[vi] = m_data->direction[v]; - m_data->v_ivertex_map[vi] = m_data->v_ivertex_map[v]; - m_data->v_iedge_map[vi] = m_data->v_iedge_map[v]; - return vi; - }*/ void remove_vertex(const Vertex_index& vi) { m_data->mesh.remove_vertex(vi); diff --git a/Kinetic_space_partition/include/CGAL/Kinetic_space_partition_3.h b/Kinetic_space_partition/include/CGAL/Kinetic_space_partition_3.h index 431c063dcf2..e2bd11335c7 100644 --- a/Kinetic_space_partition/include/CGAL/Kinetic_space_partition_3.h +++ b/Kinetic_space_partition/include/CGAL/Kinetic_space_partition_3.h @@ -984,10 +984,12 @@ public: if (!added_volumes[i]) std::cout << "volume " << i << " has not been added" << std::endl; - std::cout << "lcc #volumes: " << lcc.template one_dart_per_cell<3>().size() << " ksp #volumes: " << number_of_volumes() << std::endl; - std::cout << "lcc #faces: " << lcc.template one_dart_per_cell<2>().size() << " ksp #faces: " << num_faces << std::endl; - std::cout << "lcc #n-edges: " << lcc.template one_dart_per_cell<1>().size() << std::endl; - std::cout << "lcc #vtx: " << lcc.template one_dart_per_cell<0>().size() << " ksp #vtx: " << vtx.size() << std::endl; + if (m_parameters.verbose) { + std::cout << "lcc #volumes: " << lcc.template one_dart_per_cell<3>().size() << " ksp #volumes: " << number_of_volumes() << std::endl; + std::cout << "lcc #faces: " << lcc.template one_dart_per_cell<2>().size() << " ksp #faces: " << num_faces << std::endl; + std::cout << "lcc #n-edges: " << lcc.template one_dart_per_cell<1>().size() << std::endl; + std::cout << "lcc #vtx: " << lcc.template one_dart_per_cell<0>().size() << " ksp #vtx: " << vtx.size() << std::endl; + } // Verification // Check attributes in each dart @@ -1012,7 +1014,8 @@ public: } } - lcc.display_characteristics(std::cout) << std::endl; + if (m_parameters.verbose) + lcc.display_characteristics(std::cout) << std::endl; if (!lcc.is_valid()) std::cout << "LCC is not valid" << std::endl; @@ -2391,7 +2394,8 @@ private: idx++; } - std::cout << "input split into " << m_partition_nodes.size() << " partitions" << std::endl; + if (m_parameters.verbose) + std::cout << "input split into " << m_partition_nodes.size() << " partitions" << std::endl; } }; From f60278e1661caea6567780664e8ab3bbbcb28b03 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 25 Apr 2024 16:23:52 +0200 Subject: [PATCH 3/4] making find_adjacent_faces exact --- .../include/CGAL/KSP_3/Finalizer.h | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/Kinetic_space_partition/include/CGAL/KSP_3/Finalizer.h b/Kinetic_space_partition/include/CGAL/KSP_3/Finalizer.h index 9b3afefa141..0926616f831 100644 --- a/Kinetic_space_partition/include/CGAL/KSP_3/Finalizer.h +++ b/Kinetic_space_partition/include/CGAL/KSP_3/Finalizer.h @@ -50,6 +50,7 @@ private: using Tetrahedron_3 = typename Kernel::Tetrahedron_3; using From_exact = CGAL::Cartesian_converter; + using To_exact = CGAL::Cartesian_converter; using Data_structure = CGAL::KSP_3::internal::Data_structure; @@ -421,16 +422,23 @@ private: // take 2d directions orthogonal to edge // sort and take neighbors to current face - const Segment_3 segment = m_data.segment_3(pedge); - Vector_3 norm(segment.source(), segment.target()); - norm = KSP::internal::normalize(norm); - const Plane_3 plane(segment.source(), norm); - Point_2 source2d = plane.to_2d(segment.source()); + To_exact to_exact; + + const Segment_3 segment = m_data.segment_3(pedge); + IEdge ie = m_data.iedge(pedge); + typename Intersection_kernel::Point_3 source = m_data.point_3(m_data.igraph().source(ie)); + typename Intersection_kernel::Vector_3 norm(source, m_data.point_3(m_data.igraph().target(ie))); + + norm = KSP::internal::normalize(norm); + + const typename Intersection_kernel::Plane_3 plane(source, norm); + typename Intersection_kernel::Point_2 source2d = plane.to_2d(source); + + std::vector< std::pair > dir_edges; - std::vector< std::pair > dir_edges; // Get orientation towards edge of current face - Point_2 v2d = plane.to_2d(m_data.centroid_of_pface(pface)); - dir_edges.push_back(std::make_pair(Direction_2(source2d - v2d), pface)); + typename Intersection_kernel::Point_2 v2d = plane.to_2d(to_exact(m_data.centroid_of_pface(pface))); + dir_edges.push_back(std::make_pair(typename Intersection_kernel::Direction_2(source2d - v2d), pface)); // Get orientation towards edge of other faces for (const PFace& face : neighbor_faces) { @@ -443,13 +451,14 @@ private: auto h = mesh.halfedge(face.second); auto first = h; - Point_3 point; - FT dist = 0; + typename Intersection_kernel::Point_3 point; + typename Intersection_kernel::FT dist = 0; do { - Point_3 p = sp.to_3d(mesh.point(mesh.target(h))); - Vector_3 dist_in_plane = (p - segment.source()); + typename Intersection_kernel::Point_3 p = m_data.point_3(m_data.ivertex(PVertex(face.first, mesh.target(h)))); + typename Intersection_kernel::Vector_3 dist_in_plane = (p - source); dist_in_plane -= norm * (dist_in_plane * norm); - FT d = dist_in_plane.squared_length(); + typename Intersection_kernel::FT d = dist_in_plane.squared_length(); + if (d > dist) { dist = d; point = p; @@ -457,17 +466,15 @@ private: h = mesh.next(h); } while (first != h); - Point_2 p = plane.to_2d(point); - - dir_edges.push_back(std::make_pair(Direction_2(source2d - p), face)); + dir_edges.push_back(std::make_pair(typename Intersection_kernel::Direction_2(source2d - plane.to_2d(point)), face)); } CGAL_assertion(dir_edges.size() == neighbor_faces.size()); // Sort directions std::sort(dir_edges.begin(), dir_edges.end(), [&]( - const std::pair& p, - const std::pair& q) -> bool { + const std::pair& p, + const std::pair& q) -> bool { return p.first < q.first; } ); From 0bead91431dd776785ada8028fcb6772cf2cd4ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 29 Apr 2024 09:57:29 +0200 Subject: [PATCH 4/4] fix link error --- .../examples/Kinetic_space_partition/kinetic_partition.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Kinetic_space_partition/examples/Kinetic_space_partition/kinetic_partition.cpp b/Kinetic_space_partition/examples/Kinetic_space_partition/kinetic_partition.cpp index cd943605715..2eaaf47bbe0 100644 --- a/Kinetic_space_partition/examples/Kinetic_space_partition/kinetic_partition.cpp +++ b/Kinetic_space_partition/examples/Kinetic_space_partition/kinetic_partition.cpp @@ -15,7 +15,8 @@ using Surface_mesh = CGAL::Surface_mesh; using KSP = CGAL::Kinetic_space_partition_3; using Timer = CGAL::Real_timer; -int main(const int argc, const char** argv) { +int main(int argc, char** argv) +{ // Reading polygons from file std::string input_filename = (argc > 1 ? argv[1] : "data/test-4-rnd-polygons-4-6.off"); std::ifstream input_file(input_filename);