diff --git a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Initializer.h b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Initializer.h index 4ba8d1e17b1..fc8bc113f2f 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Initializer.h +++ b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Initializer.h @@ -393,9 +393,9 @@ private: for (KSR::size_t i = 0; i < m_data.number_of_support_planes(); ++i) { Polygon_splitter splitter(m_data); splitter.split_support_plane(i); - if (i >= 6 && m_debug) { - KSR_3::dump(m_data, "intersected-iter-" + std::to_string(i)); - } + // if (i >= 6 && m_debug) { + // KSR_3::dump(m_data, "intersected-iter-" + std::to_string(i)); + // } } } diff --git a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Polygon_splitter.h b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Polygon_splitter.h index c9ea30277f3..b4cc26ff52f 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Polygon_splitter.h +++ b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Polygon_splitter.h @@ -167,7 +167,7 @@ private: std::vector points; collect_pface_points(support_plane_idx, points); std::vector merged; - create_merged_pface(points, merged); + create_merged_pface(support_plane_idx, points, merged); if (is_debug) { std::cout << "merged pface: " << std::endl; @@ -206,6 +206,7 @@ private: } void create_merged_pface( + const KSR::size_t support_plane_idx, const std::vector& points, std::vector& merged) const { @@ -225,6 +226,35 @@ private: } } CGAL_assertion(merged.size() >= 3); + CGAL_assertion(check_merged_pface(support_plane_idx, merged)); + } + + // Check if the newly created pface goes beyond the bbox. + const bool check_merged_pface( + const KSR::size_t support_plane_idx, + const std::vector& merged) const { + + std::vector wps; + add_weighted_bbox(support_plane_idx, wps); + CGAL_assertion(wps.size() == 4); + + for (std::size_t i = 0; i < 4; ++i) { + const std::size_t ip = (i + 1) % 4; + const auto& pi = wps[i].point(); + const auto& qi = wps[ip].point(); + const Segment_2 edge(pi, qi); + + for (std::size_t j = 0; j < merged.size(); ++j) { + const std::size_t jp = (j + 1) % merged.size(); + const auto& pj = merged[j]; + const auto& qj = merged[jp]; + const Segment_2 segment(pj, qj); + Point_2 inter; + const bool is_intersected = KSR::intersection(segment, edge, inter); + if (is_intersected) return false; + } + } + return true; } void add_merged_pface( diff --git a/Kinetic_shape_reconstruction/include/CGAL/Kinetic_shape_reconstruction_3.h b/Kinetic_shape_reconstruction/include/CGAL/Kinetic_shape_reconstruction_3.h index faac2dfbd54..d36aad50395 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/Kinetic_shape_reconstruction_3.h +++ b/Kinetic_shape_reconstruction/include/CGAL/Kinetic_shape_reconstruction_3.h @@ -118,11 +118,11 @@ public: input_range, polygon_map, k, enlarge_bbox_ratio, reorient)); m_initializer.convert(m_data); - // if (m_verbose) { - // std::cout << std::endl << "POLYGON SPLITTER SUCCESS!" << std::endl << std::endl; - // } + if (m_verbose) { + std::cout << std::endl << "POLYGON SPLITTER SUCCESS!" << std::endl << std::endl; + } // return true; - // exit(EXIT_SUCCESS); + exit(EXIT_SUCCESS); if (m_verbose) { std::cout << std::endl << "--- RUNNING THE QUEUE:" << std::endl;