From 36bceb08999f46ea2a033a7aa1edd1ab82360f01 Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Wed, 4 Nov 2020 11:05:32 +0100 Subject: [PATCH] fix bug with handling k for k > 1 --- .../include/CGAL/KSR_3/Data_structure.h | 17 +++---- .../CGAL/Kinetic_shape_reconstruction_3.h | 49 +++++++++++++------ 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Data_structure.h b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Data_structure.h index f760d6b8d09..0902d33695c 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Data_structure.h +++ b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Data_structure.h @@ -1697,9 +1697,8 @@ public: const auto pface = pface_of_pvertex(pvertex); std::cout << "k intersections: " << this->k(pface) << std::endl; if (bbox_reached) { - this->k(pface) = 1; break; - } - if (is_occupied_edge && this->k(pface) == 1) { + /* this->k(pface) = 1; */ break; + } else if (is_occupied_edge && this->k(pface) == 1) { break; } @@ -1877,9 +1876,8 @@ public: const auto pface = pface_of_pvertex(pvertex); std::cout << "k intersections: " << this->k(pface) << std::endl; if (bbox_reached) { - this->k(pface) = 1; break; - } - if (is_occupied_edge && this->k(pface) == 1) { + /* this->k(pface) = 1; */ break; + } else if (is_occupied_edge && this->k(pface) == 1) { break; } @@ -2089,7 +2087,7 @@ public: std::cout << "k intersections: " << this->k(pface) << std::endl; if (bbox_reached_back || bbox_reached_front) { // stop - this->k(pface) = 1; + /* this->k(pface) = 1; */ } else if ((is_occupied_edge_back && is_occupied_edge_front) && this->k(pface) == 1) { // stop @@ -2107,6 +2105,7 @@ public: PFace new_pface = add_pface(std::array{new_vertices[i], new_vertices[i + 1], pvertex}); this->k(new_pface) = k; } + } else if ((!is_occupied_edge_back && !is_occupied_edge_front) && new_vertices.size() >= 2) { // add a triangle face for (std::size_t i = 0; i < new_vertices.size() - 1; ++i) { @@ -2116,7 +2115,7 @@ public: } // CGAL_assertion_msg(false, "TODO: ADD A TRIANGLE FACE!"); - } else if((is_occupied_edge_back || is_occupied_edge_front) && this->k(pface) == 1) { // add a triangle face + } else if ((is_occupied_edge_back || is_occupied_edge_front) && this->k(pface) == 1) { // add a triangle face for (std::size_t i = 0; i < new_vertices.size() - 1; ++i) { std::cout << "adding a new face" << std::endl; @@ -2132,7 +2131,7 @@ public: // PFace new_pface = add_pface(std::array{new_vertices[i], new_vertices[i + 1], pvertex}); // this->k(new_pface) = k; // } - CGAL_assertion_msg(false, "TODO: ADD NEW OPEN CASE!"); + CGAL_assertion_msg(false, "TODO: ADD NEW OPEN CASE! DO NOT FORGET TO UPDATE K!"); } for (std::size_t i = 1; i < crossed.size() - 1; ++i) { 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 0376ddc7cd9..9988cd91dd7 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/Kinetic_shape_reconstruction_3.h +++ b/Kinetic_shape_reconstruction/include/CGAL/Kinetic_shape_reconstruction_3.h @@ -136,6 +136,11 @@ public: KSR_3::dump (m_data, "intersected"); + for (KSR::size_t i = 0; i < m_data.number_of_support_planes(); ++i) { + for (const auto pface : m_data.pfaces(i)) + m_data.k(pface) = k; + } + std::size_t iter = 0; m_min_time = 0; m_max_time = time_step; @@ -585,7 +590,7 @@ private: ++ iter; - // if (iter == 3) { + // if (iter == 10) { // exit(0); // } @@ -687,21 +692,27 @@ private: bool collision_other, bbox_reached_other; // collision_other = m_data.collision_occured(pother, iedge).first; - std::tie(collision_other, bbox_reached_other) = m_data.is_occupied(pvertex, iedge); + std::tie(collision_other, bbox_reached_other) = m_data.is_occupied(pother, iedge); std::cout << "other/bbox: " << collision_other << "/" << bbox_reached_other << std::endl; - if ((collision || collision_other) && m_data.k(pface) > 1) - m_data.k(pface) --; - + std::cout << "k intersections: " << m_data.k(pface) << std::endl; bool stop = false; if (bbox_reached) { - m_data.k(pface) = 1; stop = true; - } - if ((collision || collision_other) && m_data.k(pface) == 1) { + + std::cout << "pv po k bbox" << std::endl; + /* m_data.k(pface) = 1; */ stop = true; + + } else if ((collision || collision_other) && m_data.k(pface) == 1) { + + std::cout << "pv po k stop" << std::endl; stop = true; - } - if ((collision || collision_other) && m_data.k(pface) > 1) + + } else if ((collision || collision_other) && m_data.k(pface) > 1) { + + std::cout << "pv po k continue" << std::endl; m_data.k(pface)--; + + } CGAL_assertion(m_data.k(pface) >= 1); if (stop) // polygon stops @@ -732,15 +743,23 @@ private: std::tie(collision, bbox_reached) = m_data.is_occupied(pvertex, iedge); std::cout << "collision/bbox: " << collision << "/" << bbox_reached << std::endl; + std::cout << "k intersections: " << m_data.k(pface) << std::endl; bool stop = false; if (bbox_reached) { - m_data.k(pface) = 1; stop = true; - } - if (collision && m_data.k(pface) == 1) { + + std::cout << "pv k bbox" << std::endl; + /* m_data.k(pface) = 1; */ stop = true; + + } else if (collision && m_data.k(pface) == 1) { + + std::cout << "pv k stop" << std::endl; stop = true; - } - if (collision && m_data.k(pface) > 1) + + } else if (collision && m_data.k(pface) > 1) { + + std::cout << "pv k continue" << std::endl; m_data.k(pface)--; + } CGAL_assertion(m_data.k(pface) >= 1); if (stop) // polygon stops