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 4dda920a5f0..b1d30735608 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Data_structure.h +++ b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Data_structure.h @@ -1459,6 +1459,8 @@ public: CGAL_assertion(pvertices[idx] == null_pvertex()); pvertices[idx] = propagated; + CGAL_assertion(is_correctly_oriented( + propagated.first, future_direction, ivertex, iedge)); // CGAL_assertion_msg(false, "TODO: CREATE NEW PVERTEX!"); } @@ -2349,8 +2351,16 @@ public: ** CHECKING PROPERTIES ** ********************************/ - bool belongs_to_iedge(const PVertex& /*pvertex*/, const IEdge& /*iedge*/) const { - return true; // TODO: finish this using dot products and orientations! + bool is_correctly_oriented( + const std::size_t sp_idx, const Vector_2& direction, + const IVertex& ivertex, const IEdge& iedge) const { + + CGAL_assertion(direction.squared_length() != FT(0)); + const auto overtex = opposite(iedge, ivertex); + const Vector_2 ref_direction( + point_2(sp_idx, ivertex), point_2(sp_idx, overtex)); + const FT vec_dot = direction * ref_direction; + return (vec_dot >= FT(0)); } template diff --git a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Propagation.h b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Propagation.h index 3bac50bba02..bb263e2ac16 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Propagation.h +++ b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Propagation.h @@ -1716,7 +1716,8 @@ private: m_data.direction(cropped) = future_direction; if (m_verbose) std::cout << "- cropped: " << m_data.str(cropped) << ", " << m_data.point_3(cropped) << std::endl; - // CGAL_assertion(m_data.belongs_to_iedge(cropped, iedge_0)); // Can we do it more precise? + CGAL_assertion(m_data.is_correctly_oriented( + cropped.first, future_direction, ivertex, iedge_0)); } // Create new pfaces if any. @@ -1921,6 +1922,8 @@ private: m_data.direction(cropped) = future_direction; if (m_verbose) std::cout << "- cropped: " << m_data.str(cropped) << ", " << m_data.point_3(cropped) << std::endl; + CGAL_assertion(m_data.is_correctly_oriented( + cropped.first, future_direction, ivertex, iedge_0)); } // Create new pfaces if any. @@ -2266,6 +2269,8 @@ private: m_data.direction(cropped) = future_directions.front(); if (m_verbose) std::cout << "- cropped 1: " << m_data.str(cropped) << ", " << m_data.point_3(cropped) << std::endl; + CGAL_assertion(m_data.is_correctly_oriented( + cropped.first, future_directions.front(), ivertex, crossed_iedges.front().first)); } { // second crop @@ -2299,6 +2304,8 @@ private: m_data.direction(cropped) = future_directions.back(); if (m_verbose) std::cout << "- cropped 2: " << m_data.str(cropped) << ", " << m_data.point_3(cropped) << std::endl; + CGAL_assertion(m_data.is_correctly_oriented( + cropped.first, future_directions.back(), ivertex, crossed_iedges.back().first)); } // Create new pfaces if any.