diff --git a/Kinetic_data_structures/changes.txt b/Kinetic_data_structures/changes.txt index f97ef17e77e..e06d3df0bad 100644 --- a/Kinetic_data_structures/changes.txt +++ b/Kinetic_data_structures/changes.txt @@ -8,6 +8,11 @@ July 2006 Daniel Russel - removed time in process function calls - changed Simulator to Default_simulator +August 2006 Daniel Russel +- added set_has_certificates to Delaunay_2 +- added degeneracy handling to Event +- infinity is not needed for roots any more + Future Daniel Russel - change non-failing root to be NaN or Root() rather than infinity? - when using numeric solvers, evaluate the static predicates first before solving? diff --git a/Kinetic_data_structures/doc_tex/Kinetic_framework_ref/Event.tex b/Kinetic_data_structures/doc_tex/Kinetic_framework_ref/Event.tex index 105d4248e1b..c399e47412d 100644 --- a/Kinetic_data_structures/doc_tex/Kinetic_framework_ref/Event.tex +++ b/Kinetic_data_structures/doc_tex/Kinetic_framework_ref/Event.tex @@ -37,13 +37,18 @@ scheduling events which will in turn pass them to the two events come from the same KDS for the purposes of handling degeneracy.} + +\ccMethod{CGAL::Comparison_result perturb_concurrent(Key a, Key b) const;}{The two events \ccc{a} and \ccc{b} occur at the same time (\ccc{this} has key \ccc{a}). This method returns a \ccc{CGAL::Comparison_result} which is used to order the two equal events. If \ccc{CGAL::EQUAL} is returned then \ccc{merge} will be called.} + +\ccMethod{bool merge_concurrent(Key a, Key b);}{ The two events \ccc{a} and \ccc{b} occur at the same time (\ccc{this} has key \ccc{a}) and cannot be perturbed to be unequal. This event allows the KDS to merge event \ccc{b} with \ccc{a}. If it returns \ccc{true} then \ccc{b} is dropped from the event queue.} + %\ccMethod{void degenerate_events(Event_key this_event, Event_key other_event);}{This event and the event referenced by \ccc{k} belong to the same KDS and occur simultaneously. This function call gives the KDS a chance to handle } \ccGlobalFunction{std::ostream& operator<<(std::ostream&, Event);}{Write a text description of the event to a standard stream.} \ccHasModels -All over the place. +All over the place. \ccc{Kinetic::Event_base}. \ccSeeAlso @@ -53,21 +58,33 @@ All over the place. All of the kinetic data structures provided have models of \ccRefName. Here is the code implementing a swap event from the -sorting kinetic data structure. +sorting kinetic data structure. Events occuring at equal times are +perturbed so that the one that occurs first in the list is processed +first (just to illustrate the idea). \begin{ccExampleCode} template class Swap_event { + typedef Swap_event This; public: - Swap_event(Id o, typename Sort::Handle sorter, + Swap_event(Id o, Sort* sorter, const Certificate &s): left_object_(o), sorter_(sorter), s_(s){} void process(){ sorter_->swap(left_object_, s_); } + void *kds() const {return sorter_;} + CGAL::Comparison_result perturb_comparison(typename Sort::Event_key a, typename Sort::Event_key b) const { + return CGAL::compare(std::distance(sorter_->objects_begin(), left_object_), + std::distance(sorter_->objects_begin(), + sorter_->simulator_handle()->get_event(b).left_object_)); + } + bool merge(typename Sort::Event_key a, typename Sort::Event_key b) { + return false; + } Id left_object_; - typename Sort::Handle sorter_; + Sort* sorter_; Certificate s_; }; \end{ccExampleCode} diff --git a/Kinetic_data_structures/doc_tex/Kinetic_framework_ref/Event_base.tex b/Kinetic_data_structures/doc_tex/Kinetic_framework_ref/Event_base.tex new file mode 100644 index 00000000000..990e956810f --- /dev/null +++ b/Kinetic_data_structures/doc_tex/Kinetic_framework_ref/Event_base.tex @@ -0,0 +1,80 @@ +% +------------------------------------------------------------------------+ +% | Reference manual page: Event.tex +% +------------------------------------------------------------------------+ +% | 20.03.2005 Author +% | Package: Kinetic_data_structures +% | +\RCSdef{\RCSEventRev}{$Id$} +\RCSdefDate{\RCSEventDate}{$Date$} +% | +%%RefPage: end of header, begin of main body +% +------------------------------------------------------------------------+ + +\ccDefGlobalScope{CGAL::} +\begin{ccRefClass}[Kinetic::]{Event_base} + +%% \ccHtmlCrossLink{} %% add further rules for cross referencing links +%% \ccHtmlIndexC[concept]{} %% add further index entries + +\ccDefinition + +This class provides a base to use for implementing events. The base provides default implementations of several methods and stores a pointer to the KDS. + +\ccCreationVariable{a} %% choose variable name + +\ccConstructor{Event_base(KDS *kds)}{Construct the object and store the pointer to the KDS.} + +\ccConstructor{Event_base()}{Use a \ccc{NULL} pointer as the KDS pointer.} + +\ccOperations + +\ccMethod{KDS* kds();}{Returns the stored pointer to the KDS.} + + +\ccMethod{CGAL::Comparison_result perturb_comparison(Key a, Key b) const;}{This returns \ccc{CGAL::compare(a,b)}.} + +\ccMethod{bool merge(Key a, Key b);}{ This returns false.} + +%\ccMethod{void degenerate_events(Event_key this_event, Event_key other_event);}{This event and the event referenced by \ccc{k} belong to the same KDS and occur simultaneously. This function call gives the KDS a chance to handle } + +\ccGlobalFunction{std::ostream& operator<<(std::ostream&, Event);}{Write a text description of the event to a standard stream.} + +\ccIsModel + +\ccc{Kinetic::Event}. + +\ccSeeAlso + +\ccc{Kinetic::EventQueue} + +\ccExample + +All of the kinetic data structures provided have models of +\ccRefName. Here is the code implementing a swap event from the +sorting kinetic data structure. + +\begin{ccExampleCode} +template +class Swap_event: CGAL::Kinetic::Event_base { + typedef CGAL::Kinetic::Event_base P; +public: + Swap_event(Id o, Sort* sorter, + const Certificate &s): P(sorter), + left_object_(o), + s_(s){} + void process(){ + P::kds()->swap(left_object_, s_); + } + Id left_object_; + Certificate s_; +}; +\end{ccExampleCode} + + +\end{ccRefConcept} + +% +------------------------------------------------------------------------+ +%%RefPage: end of main body, begin of footer +% EOF +% +------------------------------------------------------------------------+ + diff --git a/Kinetic_data_structures/examples/Kinetic_data_structures/Delaunay_triangulation_2.cpp b/Kinetic_data_structures/examples/Kinetic_data_structures/Delaunay_triangulation_2.cpp index 142b6125373..fb9686e01e4 100644 --- a/Kinetic_data_structures/examples/Kinetic_data_structures/Delaunay_triangulation_2.cpp +++ b/Kinetic_data_structures/examples/Kinetic_data_structures/Delaunay_triangulation_2.cpp @@ -14,9 +14,13 @@ int main(int, char *[]) KDel kdel(tr); + kdel.set_has_certificates(false); std::ifstream in("data/points_2"); in >> *tr.active_points_2_table_handle(); + kdel.set_has_certificates(true); + + std::cout << "Starting to run" << std::endl; while (sp->next_event_time() < sp->end_time()) { sp->set_current_event_number(sp->current_event_number()+10); diff --git a/Kinetic_data_structures/examples/Kinetic_framework/pointer_queue.cpp b/Kinetic_data_structures/examples/Kinetic_framework/pointer_queue.cpp index ad690e4c14c..42974c06c51 100644 --- a/Kinetic_data_structures/examples/Kinetic_framework/pointer_queue.cpp +++ b/Kinetic_data_structures/examples/Kinetic_framework/pointer_queue.cpp @@ -7,6 +7,7 @@ typedef double Time; Time proc_time_=-1; + class Event { public: @@ -16,15 +17,14 @@ public: { return Time(i_); }; - void process(double t) const - { + void process(){ //std::cout << "Event at " << i_ << "\n"; proc_time_=i_; - if (t != i_) { - std::cerr << "ERROR: Times do not match. Got " << t + /*if (sim_->current_time() != i_) { + std::cerr << "ERROR: Times do not match. Got " << sim_->current_time() << " expected " << i_ <current_time()==i_);*/ } protected: Time i_; diff --git a/Kinetic_data_structures/examples/Kinetic_framework/trivial_kds.cpp b/Kinetic_data_structures/examples/Kinetic_framework/trivial_kds.cpp index 9ced9f6eb97..ca3635d2152 100644 --- a/Kinetic_data_structures/examples/Kinetic_framework/trivial_kds.cpp +++ b/Kinetic_data_structures/examples/Kinetic_framework/trivial_kds.cpp @@ -17,10 +17,9 @@ struct Trivial_event objects_.push_back(m[*beg]); } } - void process(Time t) const + void process() const { - std::cout << "At time " << t - << " the following objects are in the table: "; + std::cout << "The following objects are in the table: "; for (typename std::vector::const_iterator cit= objects_.begin(); cit != objects_.end(); ++cit) { diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/Cartesian_instantaneous_kernel.h b/Kinetic_data_structures/include/CGAL/Kinetic/Cartesian_instantaneous_kernel.h index cb98f7db4db..c51e38918a1 100644 --- a/Kinetic_data_structures/include/CGAL/Kinetic/Cartesian_instantaneous_kernel.h +++ b/Kinetic_data_structures/include/CGAL/Kinetic/Cartesian_instantaneous_kernel.h @@ -187,6 +187,8 @@ public: CGAL_MSA(Compare_y,compare_y, 2); CGAL_MSA(Less_x, less_x, 2); CGAL_MSA(Less_y, less_y, 2); + CGAL_MSA(Compare_distance, compare_distance, 2); + CGAL_MSA(Compare_distance, compare_distance, 3); CGAL_TSO(Segment_2); CGAL_TSO(Triangle_2); @@ -202,6 +204,7 @@ public: CGAL_MSA(Less_z, less_z, 3); CGAL_MSA(Coplanar_orientation, coplanar_orientation, 3); CGAL_MSA(Coplanar_side_of_bounded_circle, coplanar_side_of_bounded_circle, 3); + CGAL_TSO(Segment_3); CGAL_TSO(Triangle_3); CGAL_TSO(Tetrahedron_3); diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/Default_simulator.h b/Kinetic_data_structures/include/CGAL/Kinetic/Default_simulator.h index 4a8b310a982..e1a81bdec5e 100644 --- a/Kinetic_data_structures/include/CGAL/Kinetic/Default_simulator.h +++ b/Kinetic_data_structures/include/CGAL/Kinetic/Default_simulator.h @@ -141,10 +141,10 @@ public: //! Create a simulator passing the start time and the end time. Default_simulator(const Time &start_time=Time(0.0), - const Time &end_time= internal::infinity_or_max(Time()), - Function_kernel fk=Function_kernel()):queue_(start_time, end_time, fk, 100), + const Time &end_time= internal::infinity_or_max(Time()), + Function_kernel fk=Function_kernel()):queue_(start_time, end_time, fk, 100), cur_time_(start_time), - last_event_time_(-internal::infinity_or_max(Time())), + last_event_time_(start_time), mp_(fk.rational_between_roots_object()), ir_(fk.is_rational_object()), tr_(fk.to_rational_object()), @@ -154,7 +154,7 @@ public: // make it less than the current time. //std::pair ival= to_interval(cur_time_); //audit_time_=NT(ival.first-10.0); - audit_time_= -internal::infinity_or_max(NT()); + audit_time_= to_interval(start_time).first-1; #endif }; @@ -210,7 +210,7 @@ public: //CGAL_exactness_precondition_code(CGAL::Interval_nt_advanced ub= CGAL::to_interval(next_event_time())); //CGAL_exactness_precondition(ub.inf() > lb.sup()); // NT ret; - if (ir_(cur_time_) && cur_time_ != std::numeric_limits