From d3ae3b4fdae3cf1e9b9b7cb94316335fd457577c Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Thu, 14 Nov 2024 10:39:24 +0100 Subject: [PATCH 1/6] documented Eigen3 version requirement of Ceres documented use of OSQP in Shape Regularization package --- Documentation/doc/Documentation/Third_party.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/doc/Documentation/Third_party.txt b/Documentation/doc/Documentation/Third_party.txt index 2d6382b3c17..c42fbd91a9a 100644 --- a/Documentation/doc/Documentation/Third_party.txt +++ b/Documentation/doc/Documentation/Third_party.txt @@ -289,6 +289,8 @@ requires solving complex non-linear least squares problems. Visit the official website of the library at `ceres-solver.org` for more information. +\attention \ceres requires to be compiled with the exact same version of \eigen that is used for \cgal. + \attention \ceres indicates that `glog` is a recommended dependency. `glog` has `libunwind` as a recommended dependency. On some platforms, linking with `libunwind` was responsible for an increase of the runtime of the final application. If you experience such an issue, we recommend to compile \ceres without `glog` support. @@ -315,7 +317,7 @@ The \scip web site is `https://www.scipopt.or \osqp (Operator Splitting Quadratic Program) is currently one of the fastest open source solvers for convex Quadratic Programs (QP). -In \cgal, \osqp provides an optional solver for the QP problems often arising in various computational geometry algorithms. +In \cgal, \osqp provides an optional solver for the quadratic programming used in the \ref PkgShapeRegularization package. In order to use \osqp in \cgal programs, the executables should be linked with the CMake imported target `CGAL::OSQP_support` provided in `CGAL_OSQP_support.cmake`. The \osqp web site is `https://osqp.org`. From 51bfe99ff1d53ce0fc1470c4c0cac38e41f202f0 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Fri, 15 Nov 2024 14:14:10 +0100 Subject: [PATCH 2/6] bugfix initial intervals --- .../include/CGAL/KSP_3/Intersection_graph.h | 8 +++----- .../include/CGAL/Kinetic_space_partition_3.h | 2 +- .../Kinetic_surface_reconstruction/ksr_parameters.cpp | 2 ++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Kinetic_space_partition/include/CGAL/KSP_3/Intersection_graph.h b/Kinetic_space_partition/include/CGAL/KSP_3/Intersection_graph.h index 3dffb18c35f..e500e1a9653 100644 --- a/Kinetic_space_partition/include/CGAL/KSP_3/Intersection_graph.h +++ b/Kinetic_space_partition/include/CGAL/KSP_3/Intersection_graph.h @@ -289,9 +289,8 @@ public: m_initial_intervals.resize(e.size()); std::size_t idx = 0; - for (const auto& edge : e) { + for (const auto& edge : e) m_initial_intervals[idx++] = m_graph[edge].intervals; - } m_initial_part_of_partition.resize(m_ifaces.size()); for (idx = 0; idx < m_ifaces.size(); idx++) @@ -303,9 +302,8 @@ public: CGAL_assertion(e.size() == m_initial_intervals.size()); std::size_t idx = 0; - for (auto edge : e) { - m_graph[edge].intervals = m_initial_intervals[idx]; - } + for (auto edge : e) + m_graph[edge].intervals = m_initial_intervals[idx++]; CGAL_assertion(m_ifaces.size() == m_initial_part_of_partition.size()); for (idx = 0; idx < m_ifaces.size(); idx++) 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 a0f5c66e7e6..e76a9b26cf1 100644 --- a/Kinetic_space_partition/include/CGAL/Kinetic_space_partition_3.h +++ b/Kinetic_space_partition/include/CGAL/Kinetic_space_partition_3.h @@ -731,7 +731,7 @@ public: } if (m_parameters.verbose) - std::cout << "ksp v: " << m_partition_nodes[0].m_data->vertices().size() << " f: " << m_partition_nodes[0].face2vertices.size() << " vol: " << m_volumes.size() << std::endl; + std::cout << "ksp v: " << m_partition_nodes[0].m_data->vertices().size() << " f: " << m_partition_nodes[0].face2vertices.size() << " vol: " << m_volumes.size() << std::endl; return; } diff --git a/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/ksr_parameters.cpp b/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/ksr_parameters.cpp index 9e624e3cc66..d411451b0d5 100644 --- a/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/ksr_parameters.cpp +++ b/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/ksr_parameters.cpp @@ -198,6 +198,8 @@ int main(const int argc, const char** argv) { FT after_reconstruction = timer.time(); + std::cout << polylist.size() << " polygons, " << vtx.size() << " vertices" << std::endl; + if (polylist.size() > 0) CGAL::IO::write_polygon_soup("polylist_" + std::to_string(parameters.graphcut_lambda) + (parameters.use_ground ? "_g" : "_") + ".off", vtx, polylist); From e680f83e8b1701e1369db281bf5be3d5b6c7fa32 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Fri, 15 Nov 2024 18:17:54 +0100 Subject: [PATCH 3/6] doc fix --- .../Kinetic_surface_reconstruction.txt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Kinetic_surface_reconstruction/doc/Kinetic_surface_reconstruction/Kinetic_surface_reconstruction.txt b/Kinetic_surface_reconstruction/doc/Kinetic_surface_reconstruction/Kinetic_surface_reconstruction.txt index 08cb4000e2f..99ee3553995 100644 --- a/Kinetic_surface_reconstruction/doc/Kinetic_surface_reconstruction/Kinetic_surface_reconstruction.txt +++ b/Kinetic_surface_reconstruction/doc/Kinetic_surface_reconstruction/Kinetic_surface_reconstruction.txt @@ -284,9 +284,9 @@ Building_C 3.432 -370 +369 -1.466 +1.457 40,1 @@ -376,10 +376,10 @@ Meeting Room 15 -0,03 - 10 +0,03 + 3 0,5 @@ -396,10 +396,10 @@ Full Thing 12 -0,05 - 3 +0,05 + 1 0,5 @@ -416,10 +416,10 @@ Hilbert cube 12 -0,03 - 5 +0,03 + 4 0,5 @@ -456,10 +456,10 @@ Building_C 15 -0,5 - 3 +0,5 + 2 0,77 From 5e554b234982627c2335c7e641adc55d5a139454 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Fri, 15 Nov 2024 18:29:43 +0100 Subject: [PATCH 4/6] removed unnecessary computations --- .../CGAL/Kinetic_surface_reconstruction_3.h | 65 ++----------------- 1 file changed, 5 insertions(+), 60 deletions(-) diff --git a/Kinetic_surface_reconstruction/include/CGAL/Kinetic_surface_reconstruction_3.h b/Kinetic_surface_reconstruction/include/CGAL/Kinetic_surface_reconstruction_3.h index bdc4687b6d4..761470cfc83 100644 --- a/Kinetic_surface_reconstruction/include/CGAL/Kinetic_surface_reconstruction_3.h +++ b/Kinetic_surface_reconstruction/include/CGAL/Kinetic_surface_reconstruction_3.h @@ -627,7 +627,6 @@ private: std::vector > m_volume_votes; // pair votes std::vector m_volume_below_ground; std::vector > m_cost_matrix; - std::vector m_volumes; // normalized volume of each kinetic volume std::vector m_labels; std::size_t m_total_inliers; @@ -747,9 +746,9 @@ private: std::cout << "* computing data term ... "; std::size_t max_inside = 0, max_outside = 0; - for (std::size_t i = 0; i < m_volumes.size(); i++) { - max_inside = (std::max)(static_cast(m_cost_matrix[0][i + 6]), max_inside); - max_outside = (std::max)(static_cast(m_cost_matrix[1][i + 6]), max_outside); + for (std::size_t i = 6; i < m_cost_matrix[0].size(); i++) { + max_inside = (std::max)(static_cast(m_cost_matrix[0][i]), max_inside); + max_outside = (std::max)(static_cast(m_cost_matrix[1][i]), max_outside); } // Dump volumes colored by votes @@ -1743,55 +1742,14 @@ private: return face_area; } - FT volume(typename LCC::Dart_descriptor volume_dart) { - FT x = 0, y = 0, z = 0; - std::size_t count = 0; - From_exact from_exact; - - // Collect vertices to obtain point on the inside. - for (auto& fd : m_lcc.template one_dart_per_incident_cell<2, 3>(volume_dart)) { - typename LCC::Dart_descriptor fdh = m_lcc.dart_descriptor(fd); - - for (const auto& vd : m_lcc.template one_dart_per_incident_cell<0, 2>(fdh)) { - const auto &p = from_exact(m_lcc.point(m_lcc.dart_descriptor(vd))); - x += p.x(); - y += p.y(); - z += p.z(); - count++; - } - } - - Point_3 center(x / count, y / count, z / count); - - FT vol = 0; - // Second iteration for computing the area of each face and the volume spanned with the center point. - for (auto& fd : m_lcc.template one_dart_per_incident_cell<2, 3>(volume_dart)) { - typename LCC::Dart_descriptor fdh = m_lcc.dart_descriptor(fd); - - Plane_3 plane; - FT a = area(fdh, plane); - Vector_3 n = plane.orthogonal_vector(); - - FT distance = CGAL::abs((plane.point() - center) * n); - vol += distance * a / 3.0; - } - - return vol; - } - void count_volume_votes_lcc() { // const int debug_volume = -1; - FT total_volume = 0; std::size_t num_volumes = m_kinetic_partition.number_of_volumes(); m_volume_votes.clear(); m_volume_votes.resize(num_volumes, std::make_pair(0, 0)); - m_volumes.resize(num_volumes, 0); - - for (std::size_t i = 6; i < num_volumes; i++) { + for (std::size_t i = 6; i < num_volumes; i++) m_cost_matrix[0][i] = m_cost_matrix[1][i] = 0; - m_volumes[i] = 0; - } From_exact from_exact; @@ -1829,28 +1787,15 @@ private: m_cost_matrix[1][v[j] + 6] += static_cast(out[j]); } } - - for (auto& d : m_lcc.template one_dart_per_cell<3>()) { - typename LCC::Dart_descriptor dh = m_lcc.dart_descriptor(d); - - std::size_t volume_index = m_lcc.template info<3>(dh).volume_id; - m_volumes[volume_index] = volume(dh); - - total_volume += m_volumes[volume_index]; - } - - // Normalize volumes - for (FT& v : m_volumes) - v /= total_volume; } template void create_planar_shapes(const NamedParameters& np) { - if (m_points.size() < 3) { if (m_verbose) std::cout << "* no points found, skipping" << std::endl; return; } + if (m_verbose) std::cout << "* getting planar shapes using region growing" << std::endl; FT xmin, ymin, zmin, xmax, ymax, zmax; From b64a868ff0e05e44dfa6770422b73186990a5655 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Fri, 15 Nov 2024 18:40:03 +0100 Subject: [PATCH 5/6] removing redundant initialization reformatting output --- .../ksr_parameters.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/ksr_parameters.cpp b/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/ksr_parameters.cpp index d411451b0d5..8575827b5a6 100644 --- a/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/ksr_parameters.cpp +++ b/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/ksr_parameters.cpp @@ -171,15 +171,10 @@ int main(const int argc, const char** argv) { timer.start(); std::size_t num_shapes = ksr.detect_planar_shapes(param); - std::cout << num_shapes << " detected planar shapes" << std::endl; FT after_shape_detection = timer.time(); - ksr.initialize_partition(param); - - FT after_init = timer.time(); - ksr.partition(parameters.k_intersections); FT after_partition = timer.time(); @@ -222,19 +217,16 @@ int main(const int argc, const char** argv) { else ksr.reconstruct(l, external_nodes, std::back_inserter(vtx), std::back_inserter(polylist)); - if (polylist.size() > 0) { non_empty = true; CGAL::IO::write_polygon_soup("polylist_" + std::to_string(l) + (parameters.use_ground ? "_g" : "_") + ".off", vtx, polylist); } } - std::cout << "Shape detection: " << after_shape_detection << " seconds!" << std::endl; - std::cout << "Kinetic partition: " << (after_partition - after_shape_detection) << " seconds!" << std::endl; - std::cout << " initialization: " << (after_init - after_shape_detection) << " seconds!" << std::endl; - std::cout << " partition: " << (after_partition - after_init) << " seconds!" << std::endl; - std::cout << "Kinetic reconstruction: " << (after_reconstruction - after_partition) << " seconds!" << std::endl; - std::cout << "Total time: " << time << " seconds!" << std::endl << std::endl; + std::cout << "Shape detection and initialization\nof kinetic partition: " << after_shape_detection << " seconds!" << std::endl; + std::cout << "Kinetic partition: " << (after_partition - after_shape_detection) << " seconds!" << std::endl; + std::cout << "Kinetic reconstruction: " << (after_reconstruction - after_partition) << " seconds!" << std::endl; + std::cout << "Total time: " << time << " seconds!" << std::endl << std::endl; return (non_empty) ? EXIT_SUCCESS : EXIT_FAILURE; } From c71488fcaf0621c60165253737407d05cdef222d Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Mon, 18 Nov 2024 11:39:56 +0100 Subject: [PATCH 6/6] more appropriate console output --- .../examples/Kinetic_surface_reconstruction/ksr_parameters.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/ksr_parameters.cpp b/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/ksr_parameters.cpp index 8575827b5a6..b7593484504 100644 --- a/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/ksr_parameters.cpp +++ b/Kinetic_surface_reconstruction/examples/Kinetic_surface_reconstruction/ksr_parameters.cpp @@ -171,7 +171,7 @@ int main(const int argc, const char** argv) { timer.start(); std::size_t num_shapes = ksr.detect_planar_shapes(param); - std::cout << num_shapes << " detected planar shapes" << std::endl; + std::cout << num_shapes << " regularized detected planar shapes" << std::endl; FT after_shape_detection = timer.time();