From 22813e7ce856b3dc9a24e13d1417b5ddb76b05f7 Mon Sep 17 00:00:00 2001 From: Daniel Russel Date: Fri, 14 Jul 2006 09:33:05 +0000 Subject: [PATCH] removed time from process --- Kinetic_data_structures/changes.txt | 4 ++++ .../doc_tex/Kinetic_framework_ref/Event.tex | 7 +++++++ .../doc_tex/Kinetic_framework_ref/Simulator.tex | 8 ++++++++ .../CGAL/Kinetic/Delaunay_triangulation_2.h | 2 +- .../include/CGAL/Kinetic/Erase_event.h | 5 +++-- .../CGAL/Kinetic/Heap_pointer_event_queue.h | 10 +++++----- .../include/CGAL/Kinetic/Insert_event.h | 4 ++-- .../CGAL/Kinetic/Regular_triangulation_3.h | 6 +++--- .../include/CGAL/Kinetic/Sort.h | 2 +- .../CGAL/Kinetic/Two_list_pointer_event_queue.h | 10 +++++----- .../internal/Delaunay_triangulation_base_3.h | 6 +++--- .../test/Kinetic_data_structures/simulator.cpp | 16 +++++++++++----- 12 files changed, 53 insertions(+), 27 deletions(-) diff --git a/Kinetic_data_structures/changes.txt b/Kinetic_data_structures/changes.txt index 1be5fb4d214..f97ef17e77e 100644 --- a/Kinetic_data_structures/changes.txt +++ b/Kinetic_data_structures/changes.txt @@ -4,6 +4,10 @@ 9 March 2006 Andreas Fabri - Made heading of user and reference manual to be the same +July 2006 Daniel Russel +- removed time in process function calls +- changed Simulator to Default_simulator + 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 d1ca9da6a19..105d4248e1b 100644 --- a/Kinetic_data_structures/doc_tex/Kinetic_framework_ref/Event.tex +++ b/Kinetic_data_structures/doc_tex/Kinetic_framework_ref/Event.tex @@ -32,6 +32,13 @@ scheduling events which will in turn pass them to the scheduled and the event will be removed from the queue immediately afterwards.} +\ccMethod{void* kds();}{Return a \ccc{void *} which represents the KDS + which this event belongs to. The pointer is used solely to tell if + two events come from the same KDS for the purposes of handling + degeneracy.} + +%\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 diff --git a/Kinetic_data_structures/doc_tex/Kinetic_framework_ref/Simulator.tex b/Kinetic_data_structures/doc_tex/Kinetic_framework_ref/Simulator.tex index fd162940850..b5286bd2079 100644 --- a/Kinetic_data_structures/doc_tex/Kinetic_framework_ref/Simulator.tex +++ b/Kinetic_data_structures/doc_tex/Kinetic_framework_ref/Simulator.tex @@ -40,6 +40,12 @@ then verify that their structure is correct. Typically, the simulator is created by the Kinetic:SimulationTraits class and kinetic data structures request a handle to it from there. +Events that occur at or after \ccc{Kinetic::Simulator::end_time()} +will may not be processed. The exception are events which are +scheduled using the \ccc{new_final_event(Event)} call which are +guaranteed to occur after all other events (but have no particular +order amongst themselves). + \ccTypes @@ -89,6 +95,8 @@ Returns true if the current time is a rational number and there are no events at \ccMethod{ template Event_key new_event(Time t, const Event event);}{Schedule a new event at time \ccc{t}. The object \ccc{event} must implement the concept \ccc{Event}. The \ccc{Event_key} returned can be used to access or deschedule the event.} +\ccMethod{ template Event_key new_final_event(const Event event);}{Schedule a new event that will occur at the end of the simulation. This type of event is useful if, for example, you want to run for a while, change all motions, and then run some more.} + \ccMethod{Event_key null_event() const;}{This method returns an \ccc{Event_key} which is guaranteed never to be assigned to any real event.} \ccMethod{void delete_event(const Event_key k);}{Remove the event referenced by \ccc{k} from the event queue.} diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/Delaunay_triangulation_2.h b/Kinetic_data_structures/include/CGAL/Kinetic/Delaunay_triangulation_2.h index 7fc355eeb51..599b7732bf7 100644 --- a/Kinetic_data_structures/include/CGAL/Kinetic/Delaunay_triangulation_2.h +++ b/Kinetic_data_structures/include/CGAL/Kinetic/Delaunay_triangulation_2.h @@ -53,7 +53,7 @@ struct Delaunay_2_event_base { KDel* kdel() { return d_; } - void process(const typename KDel::Time&) { + void process() { d_->flip(e_, c_); } typename KDel::Certificate c_; diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/Erase_event.h b/Kinetic_data_structures/include/CGAL/Kinetic/Erase_event.h index 894cf894136..0fd41159d34 100644 --- a/Kinetic_data_structures/include/CGAL/Kinetic/Erase_event.h +++ b/Kinetic_data_structures/include/CGAL/Kinetic/Erase_event.h @@ -37,11 +37,12 @@ public: Erase_event(Key k, Handle mot):mot_(mot), k_(k){} - template - void process(const T&) { + void process() { CGAL_KINETIC_LOG(LOG_SOME,"Deleting object.\n"); mot_->erase(k_); } + + void* kds() const {return NULL;} void write(std::ostream &out) const { out << "E" << k_; diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/Heap_pointer_event_queue.h b/Kinetic_data_structures/include/CGAL/Kinetic/Heap_pointer_event_queue.h index 0e03598fccd..d9e8d9d3f6a 100644 --- a/Kinetic_data_structures/include/CGAL/Kinetic/Heap_pointer_event_queue.h +++ b/Kinetic_data_structures/include/CGAL/Kinetic/Heap_pointer_event_queue.h @@ -43,7 +43,7 @@ public: virtual void write(std::ostream &out) const =0; const Priority& time() const {return time_;}; - virtual void process(const Priority &t) =0; + virtual void process() =0; void set_bin(int bin) const { bin_=bin;} int bin() const {return bin_;}; virtual ~Heap_pointer_event_queue_item(){} @@ -70,7 +70,7 @@ class Heap_pointer_event_queue_dummy_item: public Heap_pointer_event_queue_item< { public: Heap_pointer_event_queue_dummy_item(): Heap_pointer_event_queue_item(-2, internal::infinity_or_max(Priority())){} - virtual void process(const Priority &) { + virtual void process() { } virtual void write(std::ostream &out) const { @@ -96,8 +96,8 @@ public: Heap_pointer_event_queue_item_rep(const Priority &t, const Event &e, unsigned int bin): internal::Heap_pointer_event_queue_item(bin, t), event_(e){} - virtual void process(const Priority &t) { - event_.process(t); + virtual void process() { + event_.process(); } virtual void write(std::ostream &out) const { @@ -325,7 +325,7 @@ public: Item_handle ih= queue_.front(); pop_front(); //std::pop_heap(queue_.begin(), queue_.end()); - ih->process(ih->time()); + ih->process(); CGAL_expensive_postcondition(is_valid()); /*} else { diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/Insert_event.h b/Kinetic_data_structures/include/CGAL/Kinetic/Insert_event.h index 58f26312894..af11df69d80 100644 --- a/Kinetic_data_structures/include/CGAL/Kinetic/Insert_event.h +++ b/Kinetic_data_structures/include/CGAL/Kinetic/Insert_event.h @@ -37,11 +37,11 @@ public: Insert_event(const Object &obj, Pointer mot):mot_(mot), obj_(obj){} - template - void process(const T&) { + void process() { CGAL_KINETIC_LOG(LOG_SOME, "Inserting object.\n"); mot_->insert(obj_); } + void* kds() const {return NULL;} void write(std::ostream &out) const { diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/Regular_triangulation_3.h b/Kinetic_data_structures/include/CGAL/Kinetic/Regular_triangulation_3.h index e86bc3eb9d2..f6b8eeaa474 100644 --- a/Kinetic_data_structures/include/CGAL/Kinetic/Regular_triangulation_3.h +++ b/Kinetic_data_structures/include/CGAL/Kinetic/Regular_triangulation_3.h @@ -46,7 +46,7 @@ public: KD *kd): P(s, kd), vh_(vh) { } - void process(const typename KD::Simulator::Time&) { + void process() { P::kdel_->pop(vh_); } @@ -130,7 +130,7 @@ public: KD *kd): P(s,k, c, kd), dir_(dir) { } - void process(const typename KD::Simulator::Time&) { + void process() { P::kdel_->move(P::k_, P::cell_, dir_); } @@ -172,7 +172,7 @@ public: KD *kd): P(s,k, c, kd) { } - void process(const typename KD::Simulator::Time&) { + void process() { P::kdel_->push(P::k_, P::cell_); } diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/Sort.h b/Kinetic_data_structures/include/CGAL/Kinetic/Sort.h index 79ef030aa96..61e6c70abd9 100644 --- a/Kinetic_data_structures/include/CGAL/Kinetic/Sort.h +++ b/Kinetic_data_structures/include/CGAL/Kinetic/Sort.h @@ -314,7 +314,7 @@ class Swap_event public: Swap_event(Id o, Sort* sorter, const Solver &s): left_object_(o), sorter_(sorter), s_(s){} - void process(const typename Solver::Time &) { + void process() { sorter_->swap(left_object_, s_); } Id left_object_; Sort* sorter_; Solver s_; diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/Two_list_pointer_event_queue.h b/Kinetic_data_structures/include/CGAL/Kinetic/Two_list_pointer_event_queue.h index d274bdd7cb3..b9a8cc91ed5 100644 --- a/Kinetic_data_structures/include/CGAL/Kinetic/Two_list_pointer_event_queue.h +++ b/Kinetic_data_structures/include/CGAL/Kinetic/Two_list_pointer_event_queue.h @@ -72,7 +72,7 @@ public: } virtual void write(std::ostream &out) const =0; - virtual void process(const Priority &t) =0; + virtual void process() =0; bool operator<(const This &o) const { @@ -111,7 +111,7 @@ public: Two_list_event_queue_dummy_item(){} Two_list_event_queue_dummy_item(const Two_list_event_queue_dummy_item &): Two_list_event_queue_item(){} - virtual void process(const Priority &) { + virtual void process() { std::cerr << "Trying to process a NULL event.\n"; CGAL_assertion(0); } @@ -142,8 +142,8 @@ public: { out << event_ << " at " << P::time(); } - virtual void process(const Priority &t) { - event_.process(t); + virtual void process() { + event_.process(); } // Access the actual event const Event &event() const @@ -505,7 +505,7 @@ public: front_.pop_front(); CGAL_expensive_postcondition(audit()); if (front_.empty() && !back_.empty()) grow_front(); - i->process(i->time()); + i->process(); if (!front_.empty() && i->time() == front_.front().time()) { CGAL_KINETIC_LOG(LOG_SOME, "Degeneracy at time " diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/internal/Delaunay_triangulation_base_3.h b/Kinetic_data_structures/include/CGAL/Kinetic/internal/Delaunay_triangulation_base_3.h index 9957d0fd388..d28b7debf50 100644 --- a/Kinetic_data_structures/include/CGAL/Kinetic/internal/Delaunay_triangulation_base_3.h +++ b/Kinetic_data_structures/include/CGAL/Kinetic/internal/Delaunay_triangulation_base_3.h @@ -53,7 +53,7 @@ public: Delaunay_event_base_3() { } - void process(const typename Root_stack::Time&) { + void process() { // for some reason VC insists that this be there CGAL_assertion(0 && "Process called in Delaunay_event_base_3"); } @@ -91,7 +91,7 @@ public: d_= edge_point(e_,1); #endif } - void process(const typename Root_stack::Time&) { + void process() { P::kdel_->flip(e_); } @@ -142,7 +142,7 @@ public: c_= vertex_of_facet(e_,2)->point(); #endif } - void process(const typename Root_stack::Time&) { + void process() { P::kdel_->flip(e_); } void write(std::ostream &out) const diff --git a/Kinetic_data_structures/test/Kinetic_data_structures/simulator.cpp b/Kinetic_data_structures/test/Kinetic_data_structures/simulator.cpp index 598cb3cdbd4..97756060733 100644 --- a/Kinetic_data_structures/test/Kinetic_data_structures/simulator.cpp +++ b/Kinetic_data_structures/test/Kinetic_data_structures/simulator.cpp @@ -25,13 +25,13 @@ struct Test_event Test_event(){} - void process(const Time& t) { - if (tt_->expected_next_event_time() != t) { + void process() { + if (tt_->expected_next_event_time() != tt_->current_time()) { std::cerr << "ERROR Wrong event occurred. Expecting time " << tt_->expected_next_event_time() - << " got time " << t << std::endl; + << " got time " << tt_->current_time() << std::endl; } - if (t != t_) { - std::cerr << "ERROR Event occured at wrong time. Expecting time " << t_ << " got time " << t << std::endl; + if (tt_->current_time() != t_) { + std::cerr << "ERROR Event occured at wrong time. Expecting time " << t_ << " got time " << tt_->current_time() << std::endl; } tt_->process_one_event(); } @@ -75,6 +75,12 @@ struct Test } } + + Time current_time() const + { + return sim->current_time(); + } + void process_one_event() { if (!time_map.empty()) { event_map.erase(time_map.begin()->second);