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); diff --git a/Kinetic_space_partition/include/CGAL/KSP_3/Finalizer.h b/Kinetic_space_partition/include/CGAL/KSP_3/Finalizer.h index 44afa6ab175..3727d82f1fd 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; @@ -422,16 +423,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) { @@ -444,13 +452,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; @@ -458,17 +467,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; } ); 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 4de442bd399..ab53a84a6d9 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; } };