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 3e9c542edb7..6b87e0d6bc9 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Data_structure.h +++ b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Data_structure.h @@ -478,7 +478,7 @@ public: } const FT last_event_time(const PVertex& pvertex) { - return support_plane(pvertex).last_event_time(pvertex.second); + return support_plane(pvertex).last_event_time(pvertex.second, current_time()); } std::vector& volumes() { return m_volumes; } @@ -1315,8 +1315,8 @@ public: std::cout << "- num added pfaces: " << num_added_pfaces << std::endl; std::cout << "- k intersections after: " << this->k(pvertex.first) << std::endl; } - CGAL_assertion_msg(num_added_pfaces <= 3, - "TODO: CHECK CASES WHERE WE HAVE MORE THAN 3 NEW PFACES!"); + CGAL_assertion_msg(num_added_pfaces <= 1, + "TODO: CHECK CASES WHERE WE HAVE MORE THAN N NEW PFACES!"); // CGAL_assertion_msg(false, "TODO: TRAVERSE IEDGES GLOBAL!"); } diff --git a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Event.h b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Event.h index 6402073980f..6b2bae44335 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Event.h +++ b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Event.h @@ -57,6 +57,34 @@ public: using Queue = Event_queue; friend Queue; + struct ETime { + ETime(const NT event_time, const PVertex& pother, const IVertex& ivertex) : + time(static_cast(CGAL::to_double(event_time))), + m_pother(pother), m_ivertex(ivertex) + { } + + const FT time; + const PVertex& m_pother; + const IVertex& m_ivertex; + const bool operator<(const ETime& e) const { + + const FT tol = KSR::tolerance(); + const FT time_diff = CGAL::abs(time - e.time); + if (time_diff < tol) { + const std::size_t la = is_pvertex_to_ivertex() ? 1 : 0; + const std::size_t lb = e.is_pvertex_to_ivertex() ? 1 : 0; + return la < lb; + } + return time < e.time; + } + + const bool is_pvertex_to_ivertex() const { + return ( + m_pother == Data_structure::null_pvertex() && + m_ivertex != Data_structure::null_ivertex()); + } + }; + // Event types. // Empty event. @@ -66,7 +94,7 @@ public: m_pother(Data_structure::null_pvertex()), m_ivertex(Data_structure::null_ivertex()), m_iedge(Data_structure::null_iedge()), - m_time(FT(0)), + m_time(ETime(0, m_pother, m_ivertex)), m_support_plane_idx(m_pvertex.first) { } @@ -81,7 +109,7 @@ public: m_pother(pother), m_ivertex(Data_structure::null_ivertex()), m_iedge(Data_structure::null_iedge()), - m_time(static_cast(CGAL::to_double(time))), + m_time(ETime(time, m_pother, m_ivertex)), m_support_plane_idx(m_pvertex.first) { CGAL_assertion_msg(is_constrained, @@ -99,7 +127,7 @@ public: m_pother(Data_structure::null_pvertex()), m_ivertex(Data_structure::null_ivertex()), m_iedge(iedge), - m_time(static_cast(CGAL::to_double(time))), + m_time(ETime(time, m_pother, m_ivertex)), m_support_plane_idx(m_pvertex.first) { CGAL_assertion_msg(!is_constrained, @@ -117,7 +145,7 @@ public: m_pother(Data_structure::null_pvertex()), m_ivertex(ivertex), m_iedge(Data_structure::null_iedge()), - m_time(static_cast(CGAL::to_double(time))), + m_time(ETime(time, m_pother, m_ivertex)), m_support_plane_idx(m_pvertex.first) { } @@ -133,7 +161,7 @@ public: m_pother(pother), m_ivertex(ivertex), m_iedge(Data_structure::null_iedge()), - m_time(static_cast(CGAL::to_double(time))), + m_time(ETime(time, m_pother, m_ivertex)), m_support_plane_idx(m_pvertex.first) { CGAL_assertion_msg(is_constrained, @@ -145,7 +173,7 @@ public: const PVertex& pother() const { return m_pother; } const IVertex& ivertex() const { return m_ivertex; } const IEdge& iedge() const { return m_iedge; } - const NT time() const { return static_cast(m_time); } + const NT time() const { return static_cast(m_time.time); } const std::size_t support_plane() const { return m_support_plane_idx; } // Predicates. @@ -166,24 +194,24 @@ public: const std::string constr_type = ( event.m_is_constrained ? "constrained " : "unconstrained " ); if (event.is_pvertices_to_ivertex()) { - os << constr_type << "event at t = " << event.m_time << " between PVertex(" + os << constr_type << "event at t = " << event.time() << " between PVertex(" << event.m_pvertex.first << ":" << event.m_pvertex.second << "), PVertex(" << event.m_pother.first << ":" << event.m_pother.second << "), and IVertex(" << event.m_ivertex << ")"; } else if (event.is_pvertex_to_pvertex()) { - os << constr_type << "event at t = " << event.m_time << " between PVertex(" + os << constr_type << "event at t = " << event.time() << " between PVertex(" << event.m_pvertex.first << ":" << event.m_pvertex.second << ") and PVertex(" << event.m_pother.first << ":" << event.m_pother.second << ")"; } else if (event.is_pvertex_to_iedge()) { - os << constr_type << "event at t = " << event.m_time << " between PVertex(" + os << constr_type << "event at t = " << event.time() << " between PVertex(" << event.m_pvertex.first << ":" << event.m_pvertex.second << ") and IEdge" << event.m_iedge; } else if (event.is_pvertex_to_ivertex()) { - os << constr_type << "event at t = " << event.m_time << " between PVertex(" + os << constr_type << "event at t = " << event.time() << " between PVertex(" << event.m_pvertex.first << ":" << event.m_pvertex.second << ") and IVertex(" << event.m_ivertex << ")"; } else { - os << "ERROR: INVALID EVENT at t = " << event.m_time; + os << "ERROR: INVALID EVENT at t = " << event.time(); } return os; } @@ -194,7 +222,7 @@ private: PVertex m_pother; IVertex m_ivertex; IEdge m_iedge; - FT m_time; + ETime m_time; std::size_t m_support_plane_idx; }; diff --git a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Event_queue.h b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Event_queue.h index 46fa485da43..22227620487 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Event_queue.h +++ b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Event_queue.h @@ -42,6 +42,7 @@ class Event_queue { public: // Data structure types. + using FT = typename Data_structure::Kernel::FT; using PVertex = typename Data_structure::PVertex; using PEdge = typename Data_structure::PEdge; using PFace = typename Data_structure::PFace; @@ -50,13 +51,13 @@ public: // Event types. using Event = KSR_3::Event; - using FT = typename Event::FT; + using ETime = typename Event::ETime; // Boost queue. using Queue = boost::multi_index_container< Event, boost::multi_index::indexed_by< boost::multi_index::ordered_non_unique< - boost::multi_index::member >, + boost::multi_index::member >, boost::multi_index::ordered_non_unique< boost::multi_index::member >, boost::multi_index::ordered_non_unique< @@ -94,13 +95,11 @@ public: const Event event = *event_iterator; m_queue.erase(event_iterator); - if (queue_by_time().begin()->m_time == event.m_time) { + const FT tol = KSR::tolerance(); + const FT time_diff = CGAL::abs(queue_by_time().begin()->time() - event.time()); + if (time_diff < tol) { if (m_verbose) { - std::cerr << "WARNING: NEXT EVENT IS HAPPENING AT THE SAME TIME!" << std::endl; - } - } else if (CGAL::abs(queue_by_time().begin()->m_time - event.m_time) < 1e-15) { - if (m_verbose) { - std::cerr << "WARNING: NEXT EVENT IS HAPPENING AT ALMOST THE SAME TIME!" << std::endl; + std::cout << "WARNING: NEXT EVENT IS HAPPENNING AT THE SAME TIME!" << std::endl; } } return event; diff --git a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Propagation.h b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Propagation.h index 238d9d68788..7f9c0ccb3a4 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Propagation.h +++ b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Propagation.h @@ -468,9 +468,9 @@ private: } ++iteration; - // if (iteration == 80) { - // exit(EXIT_FAILURE); - // } + if (iteration == 35) { + exit(EXIT_FAILURE); + } apply(event); CGAL_assertion(m_data.check_integrity()); @@ -1445,23 +1445,41 @@ private: } // We use this modification in order to avoid collinear directions. + const FT tol = KSR::tolerance(); CGAL_assertion(m_data.has_iedge(pvertex)); const std::size_t other_side_limit = m_data.line_idx(pvertex); const FT prev_time = m_data.last_event_time(prev); - CGAL_assertion(prev_time < m_data.current_time()); - CGAL_assertion(prev_time >= FT(0)); + const FT curr_time = m_data.current_time(); - if (prev_time == m_data.current_time()) { - std::cout << "TODO: BACK, EVENTS ARE HAPPENNING AT THE SAME TIME!" << std::endl; - exit(EXIT_FAILURE); - } + // std::cout << "min time: " << min_time << std::endl; + // std::cout << "max time: " << max_time << std::endl; // std::cout << "prev time: " << prev_time << std::endl; - // std::cout << "curr time: " << m_data.current_time() << std::endl; + // std::cout << "curr time: " << curr_time << std::endl; - const auto pp_last = m_data.point_2(prev, prev_time); - const auto pp_curr = m_data.point_2(prev, m_data.current_time()); - const auto dirp = Vector_2(pp_last, pp_curr); - const auto shifted_prev = pp_curr - dirp / FT(10); + CGAL_assertion(prev_time >= FT(0)); + const FT prev_diff = CGAL::abs(curr_time - prev_time); + + // CGAL_assertion(prev_time >= FT(0)); + // CGAL_assertion(prev_diff >= tol); + // if (prev_diff < tol) { + // std::cout << "TODO: BACK, EVENTS ARE HAPPENNING AT THE SAME TIME!" << std::endl; + // exit(EXIT_FAILURE); + // } + + Point_2 shifted_prev; + const auto pp_curr = m_data.point_2(prev, curr_time); + if (prev_diff < tol) { + if (m_verbose) std::cout << "- back, same time events, prev" << std::endl; + CGAL_assertion(CGAL::abs(max_time - curr_time) >= tol); + const auto pp_futr = m_data.point_2(prev, max_time); + const auto dirp = Vector_2(pp_curr, pp_futr); + shifted_prev = pp_curr + dirp / FT(10); + // CGAL_assertion_msg(false, "TODO: BACK, ADD SHIFTED_PREV FOR SAME TIME EVENTS!"); + } else { + const auto pp_last = m_data.point_2(prev, prev_time); + const auto dirp = Vector_2(pp_last, pp_curr); + shifted_prev = pp_curr - dirp / FT(10); + } if (m_verbose) { std::cout << "- shifting prev: " << m_data.to_3d(pvertex.first, shifted_prev) << std::endl; @@ -1596,23 +1614,41 @@ private: } // We use this modification in order to avoid collinear directions. + const FT tol = KSR::tolerance(); CGAL_assertion(m_data.has_iedge(pvertex)); const std::size_t other_side_limit = m_data.line_idx(pvertex); const FT next_time = m_data.last_event_time(next); - CGAL_assertion(next_time < m_data.current_time()); - CGAL_assertion(next_time >= FT(0)); + const FT curr_time = m_data.current_time(); - if (next_time == m_data.current_time()) { - std::cout << "TODO: FRONT, EVENTS ARE HAPPENNING AT THE SAME TIME!" << std::endl; - exit(EXIT_FAILURE); - } - // std::cout << "curr time: " << m_data.current_time() << std::endl; + // std::cout << "min time: " << min_time << std::endl; + // std::cout << "max time: " << max_time << std::endl; // std::cout << "next time: " << next_time << std::endl; + // std::cout << "curr time: " << curr_time << std::endl; - const auto pn_last = m_data.point_2(next, next_time); - const auto pn_curr = m_data.point_2(next, m_data.current_time()); - const auto dirn = Vector_2(pn_last, pn_curr); - const auto shifted_next = pn_curr - dirn / FT(10); + CGAL_assertion(next_time >= FT(0)); + const FT next_diff = CGAL::abs(curr_time - next_time); + + // CGAL_assertion(next_time >= FT(0)); + // CGAL_assertion(next_diff >= tol); + // if (next_diff < tol) { + // std::cout << "TODO: FRONT, EVENTS ARE HAPPENNING AT THE SAME TIME!" << std::endl; + // exit(EXIT_FAILURE); + // } + + Point_2 shifted_next; + const auto pn_curr = m_data.point_2(next, curr_time); + if (next_diff < tol) { + if (m_verbose) std::cout << "- front, same time events, next" << std::endl; + CGAL_assertion(CGAL::abs(max_time - curr_time) >= tol); + const auto pn_futr = m_data.point_2(next, max_time); + const auto dirn = Vector_2(pn_curr, pn_futr); + shifted_next = pn_curr + dirn / FT(10); + // CGAL_assertion_msg(false, "TODO: FRONT, ADD SHIFTED_NEXT FOR SAME TIME EVENTS!"); + } else { + const auto pn_last = m_data.point_2(next, next_time); + const auto dirn = Vector_2(pn_last, pn_curr); + shifted_next = pn_curr - dirn / FT(10); + } if (m_verbose) { std::cout << "- shifting next: " << m_data.to_3d(pvertex.first, shifted_next) << std::endl; @@ -1749,29 +1785,57 @@ private: // We use this modification in order to avoid collinear directions. const FT prev_time = m_data.last_event_time(prev); + const FT curr_time = m_data.current_time(); const FT next_time = m_data.last_event_time(next); - CGAL_assertion(prev_time < m_data.current_time()); - CGAL_assertion(next_time < m_data.current_time()); - CGAL_assertion(prev_time >= FT(0)); - CGAL_assertion(next_time >= FT(0)); - if (prev_time == m_data.current_time() || next_time == m_data.current_time()) { - std::cout << "TODO: OPEN, EVENTS ARE HAPPENNING AT THE SAME TIME!" << std::endl; - exit(EXIT_FAILURE); - } + // std::cout << "min time: " << min_time << std::endl; + // std::cout << "max time: " << max_time << std::endl; // std::cout << "prev time: " << prev_time << std::endl; - // std::cout << "curr time: " << m_data.current_time() << std::endl; + // std::cout << "curr time: " << curr_time << std::endl; // std::cout << "next time: " << next_time << std::endl; - const auto pp_last = m_data.point_2(prev, prev_time); - const auto pp_curr = m_data.point_2(prev, m_data.current_time()); - const auto dirp = Vector_2(pp_last, pp_curr); - const auto shifted_prev = pp_curr - dirp / FT(10); + const FT tol = KSR::tolerance(); + CGAL_assertion(prev_time >= FT(0)); + CGAL_assertion(next_time >= FT(0)); + const FT prev_diff = CGAL::abs(curr_time - prev_time); + const FT next_diff = CGAL::abs(curr_time - next_time); - const auto pn_last = m_data.point_2(next, next_time); - const auto pn_curr = m_data.point_2(next, m_data.current_time()); - const auto dirn = Vector_2(pn_last, pn_curr); - const auto shifted_next = pn_curr - dirn / FT(10); + // CGAL_assertion(prev_diff >= tol); + // CGAL_assertion(next_diff >= tol); + // if (prev_diff < tol || next_diff < tol) { + // std::cout << "TODO: OPEN, EVENTS ARE HAPPENNING AT THE SAME TIME!" << std::endl; + // exit(EXIT_FAILURE); + // } + + Point_2 shifted_prev; + const auto pp_curr = m_data.point_2(prev, curr_time); + if (prev_diff < tol) { + if (m_verbose) std::cout << "- open, same time events, prev" << std::endl; + CGAL_assertion(CGAL::abs(max_time - curr_time) >= tol); + const auto pp_futr = m_data.point_2(prev, max_time); + const auto dirp = Vector_2(pp_curr, pp_futr); + shifted_prev = pp_curr + dirp / FT(10); + // CGAL_assertion_msg(false, "TODO: OPEN, ADD SHIFTED_PREV FOR SAME TIME EVENTS!"); + } else { + const auto pp_last = m_data.point_2(prev, prev_time); + const auto dirp = Vector_2(pp_last, pp_curr); + shifted_prev = pp_curr - dirp / FT(10); + } + + Point_2 shifted_next; + const auto pn_curr = m_data.point_2(next, curr_time); + if (next_diff < tol) { + if (m_verbose) std::cout << "- open, same time events, next" << std::endl; + CGAL_assertion(CGAL::abs(max_time - curr_time) >= tol); + const auto pn_futr = m_data.point_2(next, max_time); + const auto dirn = Vector_2(pn_curr, pn_futr); + shifted_next = pn_curr + dirn / FT(10); + // CGAL_assertion_msg(false, "TODO: OPEN, ADD SHIFTED_NEXT FOR SAME TIME EVENTS!"); + } else { + const auto pn_last = m_data.point_2(next, next_time); + const auto dirn = Vector_2(pn_last, pn_curr); + shifted_next = pn_curr - dirn / FT(10); + } if (m_verbose) { std::cout << "- shifting prev: " << m_data.to_3d(pvertex.first, shifted_prev) << std::endl; @@ -1834,18 +1898,77 @@ private: } } + if (crossed_iedges.size() == 1) { + + CGAL_assertion_msg( + m_data.point_2(pvertex.first, m_data.source(crossed_iedges[0].first)) != + m_data.point_2(pvertex.first, m_data.target(crossed_iedges[0].first)), + "TODO: OPEN, 1 EDGE CASE, HANDLE ZERO-LENGTH IEDGE!"); + + Point_2 future_point; + Vector_2 future_direction; + const bool is_parallel = m_data.compute_future_point_and_direction( + pvertex, prev, next, crossed_iedges[0].first, future_point, future_direction); + CGAL_assertion_msg(!is_parallel, + "TODO: OPEN, 1 EDGE CASE, CAN WE HAVE PARALLEL LINES HERE?"); + + new_pvertices.clear(); + new_pvertices.resize(crossed_iedges.size(), m_data.null_pvertex()); + + if (m_verbose) std::cout << "- open, 1 edge case" << std::endl; + + const auto vi = pvertex.second; + const auto ei = m_data.mesh(pvertex).edge( + CGAL::Euler::split_vertex( + m_data.mesh(pvertex).halfedge(vi), + m_data.mesh(pvertex).opposite(m_data.mesh(pvertex).next(m_data.mesh(pvertex).halfedge(vi))), + m_data.mesh(pvertex))); + const PEdge pedge(pvertex.first, ei); + const auto pother = m_data.opposite(pedge, pvertex); + m_data.support_plane(pother).set_point(pother.second, ipoint); + m_data.direction(pother) = CGAL::NULL_VECTOR; + const auto cropped = pvertex; + + + // const auto cropped1 = PVertex(pvertex.first, m_data.support_plane(pvertex).split_edge(pvertex.second, next.second)); + // const auto cropped2 = PVertex(pvertex.first, m_data.support_plane(pvertex).split_edge(pvertex.second, prev.second)); + // m_data.add_pface(std::array{pvertex, cropped1, cropped2}); + // const auto he = m_data.mesh(pvertex).halfedge(cropped1.second, cropped2.second); + // CGAL::Euler::join_vertex(he, m_data.mesh(pvertex)); + // const auto cropped = cropped2; + CGAL_assertion(cropped != m_data.null_pvertex()); + + // const PEdge pedge(pvertex.first, m_data.support_plane(pvertex).edge(pvertex.second, cropped.second)); + // CGAL_assertion(cropped != pvertex); + new_pvertices[0] = cropped; + + m_data.connect(pedge, crossed_iedges[0].first); + m_data.connect(cropped, crossed_iedges[0].first); + + CGAL_assertion(future_direction != Vector_2()); + m_data.support_plane(cropped).set_point(cropped.second, future_point); + 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_msg(false, "TODO: OPEN, HANDLE 1 EDGE CASE!"); + return; + } + // Compute future points and directions. + CGAL_assertion(crossed_iedges.size() >= 2); std::vector future_points(2); std::vector future_directions(2); IEdge prev_iedge = m_data.null_iedge(); IEdge next_iedge = m_data.null_iedge(); - CGAL_assertion_msg( - m_data.point_2(pvertex.first, m_data.source(crossed_iedges.front().first)) != - m_data.point_2(pvertex.first, m_data.target(crossed_iedges.front().first)), - "TODO: OPEN, FRONT, HANDLE ZERO-LENGTH IEDGE!"); - { // first future point and direction + CGAL_assertion_msg( + m_data.point_2(pvertex.first, m_data.source(crossed_iedges.front().first)) != + m_data.point_2(pvertex.first, m_data.target(crossed_iedges.front().first)), + "TODO: OPEN, FRONT, HANDLE ZERO-LENGTH IEDGE!"); + + if (m_verbose) std::cout << "- getting future point and direction, front" << std::endl; const bool is_parallel = m_data.compute_future_point_and_direction( pvertex, prev, next, crossed_iedges.front().first, future_points.front(), future_directions.front()); if (is_parallel) { @@ -1858,12 +1981,14 @@ private: } } - CGAL_assertion_msg( - m_data.point_2(pvertex.first, m_data.source(crossed_iedges.back().first)) != - m_data.point_2(pvertex.first, m_data.target(crossed_iedges.back().first)), - "TODO: OPEN, BACK, HANDLE ZERO-LENGTH IEDGE!"); + // second future point and direction + { + CGAL_assertion_msg( + m_data.point_2(pvertex.first, m_data.source(crossed_iedges.back().first)) != + m_data.point_2(pvertex.first, m_data.target(crossed_iedges.back().first)), + "TODO: OPEN, BACK, HANDLE ZERO-LENGTH IEDGE!"); - { // second future point and direction + if (m_verbose) std::cout << "- getting future point and direction, back" << std::endl; const bool is_parallel = m_data.compute_future_point_and_direction( pvertex, prev, next, crossed_iedges.back().first, future_points.back(), future_directions.back()); if (is_parallel) { diff --git a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Support_plane.h b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Support_plane.h index bd4fb9b3613..59176172351 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Support_plane.h +++ b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Support_plane.h @@ -70,7 +70,7 @@ public: using F_index_map = typename Mesh::template Property_map >; using F_uint_map = typename Mesh::template Property_map; using V_original_map = typename Mesh::template Property_map; - using V_time_map = typename Mesh::template Property_map; + using V_time_map = typename Mesh::template Property_map >; private: struct Data { @@ -159,8 +159,11 @@ public: m_data->v_original_map = m_data->mesh.template add_property_map( "v:original", false).first; - m_data->v_time_map = m_data->mesh.template add_property_map( - "v:time", FT(0)).first; + // TODO: I can have a similar vector to push all ivertices/events of the polygon vertex + // to keep track of the path it traversed. Later, we can return this path. + std::vector time_vector(1, FT(0)); + m_data->v_time_map = m_data->mesh.template add_property_map >( + "v:time", time_vector).first; } template @@ -272,7 +275,15 @@ public: sp.data().v_original_map[vi] = m_data->v_original_map[vertex]; // sp.data().v_time_map[vi] = converter(m_data->v_time_map[vertex]); - sp.data().v_time_map[vi] = static_cast(CGAL::to_double(m_data->v_time_map[vertex])); + // sp.data().v_time_map[vi] = static_cast(CGAL::to_double(m_data->v_time_map[vertex])); + + sp.data().v_time_map[vi].clear(); + sp.data().v_time_map[vi].reserve(m_data->v_time_map[vertex].size()); + for (const auto vtime : m_data->v_time_map[vertex]) { + sp.data().v_time_map[vi].push_back(static_cast(CGAL::to_double(vtime))); + } + CGAL_assertion( + sp.data().v_time_map[vi].size() == m_data->v_time_map[vertex].size()); } for (const auto& edge : m_data->mesh.edges()) { @@ -433,11 +444,27 @@ public: } void set_last_event_time(const Vertex_index& vi, const FT time) { - m_data->v_time_map[vi] = time; + // TODO: If we do not need the full vector, remove it. + m_data->v_time_map[vi].push_back(time); } - const FT last_event_time(const Vertex_index& vi) const { - return m_data->v_time_map[vi]; + const FT last_event_time(const Vertex_index& vi, const FT /* curr_time */) const { + + // FT last_time = FT(-1); + // const FT tol = KSR::tolerance(); + // CGAL_assertion(m_data->v_time_map[vi].size() > 0); + + // // std::cout << "----" << std::endl; + // for (const FT vtime : m_data->v_time_map[vi]) { + // // std::cout << "vtime: " << vtime << std::endl; + // const FT time_diff = CGAL::abs(curr_time - vtime); + // if (time_diff < tol) continue; + // last_time = vtime; + // } + // CGAL_assertion(last_time >= FT(0)); + // return last_time; + + return m_data->v_time_map[vi].back(); } const Vertex_index prev(const Vertex_index& vi) const { 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 083fa22d1a7..2b6d2160d15 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/Kinetic_shape_reconstruction_3.h +++ b/Kinetic_shape_reconstruction/include/CGAL/Kinetic_shape_reconstruction_3.h @@ -82,7 +82,7 @@ public: const bool verbose = true, const bool debug = false) : m_verbose(verbose), - m_export(false), + m_export(true), m_debug(debug), m_data(m_debug), m_num_events(0)