diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/Cartesian_kinetic_kernel.h b/Kinetic_data_structures/include/CGAL/Kinetic/Cartesian_kinetic_kernel.h deleted file mode 100644 index ea8c7e89915..00000000000 --- a/Kinetic_data_structures/include/CGAL/Kinetic/Cartesian_kinetic_kernel.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2005 Stanford University (USA). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org); you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; version 2.1 of the License. -// See the file LICENSE.LGPL distributed with CGAL. -// -// Licensees holding a valid commercial license may use this file in -// accordance with the commercial license agreement provided with the software. -// -// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// $URL$ -// $Id$ -// -// -// Author(s) : Daniel Russel - -#ifndef CGAL_KINETIC_KINETIC_KERNEL_H -#define CGAL_KINETIC_KINETIC_KERNEL_H -#include -#include - -CGAL_KINETIC_BEGIN_NAMESPACE - -//! A kinetic kernel using cartesian coordinates -/*! It takes a PolynomialKernel as a template parameter. The - PolynomialKernel is used to define the Motion_function and the - Certificate_function. -*/ -template -class Cartesian_kinetic_kernel: - public internal::Cartesian_kinetic_kernel_base > -{ - typedef internal::Cartesian_kinetic_kernel_base > P; -public: - typedef Function_kernel_k Function_kernel; - Cartesian_kinetic_kernel(Function_kernel_k pk): P(pk){} - Cartesian_kinetic_kernel(){} -}; - -CGAL_KINETIC_END_NAMESPACE - -//#include -#endif 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 3362a0f2bb3..1def55d3371 100644 --- a/Kinetic_data_structures/include/CGAL/Kinetic/Delaunay_triangulation_2.h +++ b/Kinetic_data_structures/include/CGAL/Kinetic/Delaunay_triangulation_2.h @@ -36,11 +36,11 @@ #include CGAL_KINETIC_BEGIN_NAMESPACE -#ifdef NDEBUG +//#ifdef NDEBUG #define CGAL_DELAUNAY_2_DEBUG(x) -#else +/*#else #define CGAL_DELAUNAY_2_DEBUG(x) x -#endif +//#endif*/ template struct Delaunay_edge_failure_event: public Event_base { diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/Exact_simulation_traits.h b/Kinetic_data_structures/include/CGAL/Kinetic/Exact_simulation_traits.h index 1b244146e21..07773a0b6ec 100644 --- a/Kinetic_data_structures/include/CGAL/Kinetic/Exact_simulation_traits.h +++ b/Kinetic_data_structures/include/CGAL/Kinetic/Exact_simulation_traits.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -49,7 +49,7 @@ struct Exact_simulation_traits { typedef CGAL::Kinetic::Handle_degeneracy_function_kernel Simulator_function_kernel_base; struct Simulator_function_kernel: public Simulator_function_kernel_base{}; - typedef Cartesian_kinetic_kernel Kinetic_kernel; + typedef Cartesian Kinetic_kernel; typedef Two_list_pointer_event_queue Event_queue; typedef Default_simulator Simulator; diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/Inexact_simulation_traits.h b/Kinetic_data_structures/include/CGAL/Kinetic/Inexact_simulation_traits.h index fe45f61f5ba..485f300e976 100644 --- a/Kinetic_data_structures/include/CGAL/Kinetic/Inexact_simulation_traits.h +++ b/Kinetic_data_structures/include/CGAL/Kinetic/Inexact_simulation_traits.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -47,7 +47,7 @@ struct Inexact_simulation_traits { typedef CGAL::Kinetic::Derivitive_filter_function_kernel Simulator_function_kernel_base; struct Simulator_function_kernel: public Simulator_function_kernel_base{}; - typedef Cartesian_kinetic_kernel Kinetic_kernel; + typedef Cartesian Kinetic_kernel; typedef Heap_pointer_event_queue Event_queue; typedef Default_simulator Simulator; diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/Regular_triangulation_exact_simulation_traits.h b/Kinetic_data_structures/include/CGAL/Kinetic/Regular_triangulation_exact_simulation_traits.h new file mode 100644 index 00000000000..cbe5546c9f0 --- /dev/null +++ b/Kinetic_data_structures/include/CGAL/Kinetic/Regular_triangulation_exact_simulation_traits.h @@ -0,0 +1,100 @@ +// Copyright (c) 2005 Stanford University (USA). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; version 2.1 of the License. +// See the file LICENSE.LGPL distributed with CGAL. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// +// Author(s) : Daniel Russel + +#ifndef CGAL_KINETIC_REGULAR_EXACT_SIMULATION_H +#define CGAL_KINETIC_REGULAR_EXACT_SIMULATION_H +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +//#include + +CGAL_KINETIC_BEGIN_NAMESPACE + +struct Regular_triangulation_exact_simulation_traits { + typedef Regular_triangulation_exact_simulation_traits This; + + typedef CGAL::Exact_predicates_exact_constructions_kernel Static_kernel_base; + typedef CGAL::Regular_triangulation_euclidean_traits_3 Static_kernel; + typedef CGAL::POLYNOMIAL::Polynomial Function; + typedef CGAL::POLYNOMIAL::Sturm_root_stack_traits Root_stack_traits; + typedef CGAL::POLYNOMIAL::Sturm_root_stack Root_stack; + typedef CGAL::POLYNOMIAL::Kernel Function_kernel; + + typedef CGAL::Kinetic::Handle_degeneracy_function_kernel Simulator_function_kernel_base; + struct Simulator_function_kernel: public Simulator_function_kernel_base{}; + + typedef Cartesian Kinetic_kernel; + typedef Two_list_pointer_event_queue Event_queue; + typedef Default_simulator Simulator; + + typedef Active_objects_vector Active_points_1_table; + typedef Active_objects_vector Active_points_2_table; + typedef Active_objects_vector Active_points_3_table; + //typedef Active_objects_vector Active_weighted_points_3_table; + + typedef Regular_triangulation_instantaneous_kernel Instantaneous_kernel; + + Active_points_1_table* active_points_1_table_handle() const { return ap1_.get();} + Active_points_2_table* active_points_2_table_handle() const {return ap2_.get();} + Active_points_3_table* active_points_3_table_handle() const {return ap3_.get();} + //Active_weighted_points_3_table* active_weighted_points_3_table_handle() const {return awp3_.get();} + + Simulator* simulator_handle() const { return sim_.get();} + const Static_kernel& static_kernel_object() const {return k_;} + const Kinetic_kernel& kinetic_kernel_object() const {return kk_;} + + Instantaneous_kernel instantaneous_kernel_object() const { + return Instantaneous_kernel(*this); + } + + Regular_triangulation_exact_simulation_traits(const Simulator::Time &lb, + const Simulator::Time &ub): sim_(new Simulator(lb, ub)), + ap1_(new Active_points_1_table()), + ap2_(new Active_points_2_table()), + ap3_(new Active_points_3_table()) + //awp3_(new Active_weighted_points_3_table()) +{} + + + bool is_exact() const { + return true; + } +protected: + Simulator::Handle sim_; + Active_points_1_table::Handle ap1_; + Active_points_2_table::Handle ap2_; + Active_points_3_table::Handle ap3_; + //Active_weighted_points_3_table::Handle awp3_; + Static_kernel k_; + Kinetic_kernel kk_; + Function_kernel fk_; +}; +CGAL_KINETIC_END_NAMESPACE +#endif diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/Regular_triangulation_inexact_simulation_traits.h b/Kinetic_data_structures/include/CGAL/Kinetic/Regular_triangulation_inexact_simulation_traits.h index 22241fb6782..6ba509499b5 100644 --- a/Kinetic_data_structures/include/CGAL/Kinetic/Regular_triangulation_inexact_simulation_traits.h +++ b/Kinetic_data_structures/include/CGAL/Kinetic/Regular_triangulation_inexact_simulation_traits.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -48,7 +48,7 @@ struct Regular_triangulation_inexact_simulation_traits { struct Simulator_function_kernel: public Simulator_function_kernel_base{}; - typedef Cartesian_kinetic_kernel Kinetic_kernel; + typedef Cartesian Kinetic_kernel; typedef Two_list_pointer_event_queue Event_queue; typedef Default_simulator Simulator; diff --git a/Kinetic_data_structures/include/CGAL/Kinetic/Regular_triangulation_instantaneous_kernel.h b/Kinetic_data_structures/include/CGAL/Kinetic/Regular_triangulation_instantaneous_kernel.h new file mode 100644 index 00000000000..036a3d3874a --- /dev/null +++ b/Kinetic_data_structures/include/CGAL/Kinetic/Regular_triangulation_instantaneous_kernel.h @@ -0,0 +1,258 @@ +// Copyright (c) 2005 Stanford University (USA). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; version 2.1 of the License. +// See the file LICENSE.LGPL distributed with CGAL. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// +// Author(s) : Daniel Russel + +#ifndef CGAL_CARTESIAN_REGULAR_INSTANTANEOUS_KERNEL_H +#define CGAL_CARTESIAN_REGULAR_INSTANTANEOUS_KERNEL_H +#include +#include +#include +#include +#include +#include +#include +#include +//#include + +#define CGAL_MSA(Pred, pred, Arg, d) typedef Instantaneous_adaptor Pred##_##d; \ + Pred##_##d pred##_##d##_object() const \ + { \ + typename Static_kernel::Pred##_##d sp= rep_->static_kernel().pred##_##d##_object(); \ + return Pred##_##d(current_coordinates_object(), sp); \ + } + +#define CGAL_TSO(name) typedef typename Static_kernel::name name + +CGAL_KINETIC_BEGIN_NAMESPACE + +template +class Regular_instantaneous_kernel_rep: public Ref_counted > +{ +public: + typedef typename CIK::Traits::Static_kernel Static_kernel; + typedef typename CIK::Traits::Kinetic_kernel Kinetic_kernel; + + typedef typename Kinetic_kernel::Point_1::template Static_traits Static_traits_point_1; + typedef typename Kinetic_kernel::Point_2::template Static_traits Static_traits_point_2; + typedef typename Kinetic_kernel::Point_3::template Static_traits Static_traits_point_3; + //typedef typename Kinetic_kernel::Weighted_point_3::template Static_traits Static_traits_weighted_point_3; + + typedef typename Static_kernel::FT Time; + + Regular_instantaneous_kernel_rep(typename CIK::Traits tr): tr_(tr) { + initialized_=false; + } + + void set_time(const Time &t) + { + if (t != time_ || !initialized_) { + time_=t; + cache_1_.clear(); + cache_2_.clear(); + cache_w3_.clear(); + //cache_w3_.clear(); + initialized_=true; + } + } + const Time & time() const + { + return time_; + } + + void check_static_object() const { +#ifndef NDEBUG + if (!initialized_) { + std::cerr << "The InstantaneousKernel (or one of its predicates) was\n"; + std::cerr << "used without the time being set. This probably is the sign\n"; + std::cerr << "of misusing it--specifically make sure you store a copy\n"; + std::cerr << "from the SimulatorTraits and get predicates from it.\n"; + } +#endif + } + + const typename Static_kernel::FT& + static_object(typename CIK::Point_1 k) const { + check_static_object(); + if (cache_1_.find(k) == cache_1_.end()) { + cache_1_[k]= tr_.active_points_1_table_handle()->at(k).x()(time_); + } + return cache_1_[k]; + } + + const typename Static_kernel::Point_2& + static_object(typename CIK::Point_2 k) const { + check_static_object(); + if (cache_2_.find(k) == cache_2_.end()) { + cache_2_[k]= typename Static_kernel::Point_2(tr_.active_points_2_table_handle()->at(k).x()(time_), + tr_.active_points_2_table_handle()->at(k).y()(time_)); + } + return cache_2_[k]; + } + + /*const typename Static_kernel::Point_3& + static_object(typename CIK::Point_3 k) const { + check_static_object(); + if (cache_3_.find(k) == cache_3_.end()) { + cache_3_[k]= typename Static_kernel::Point_3(tr_.active_weighted_points_3_table_handle()->at(k).point().x()(time_), + tr_.active_weighted_points_3_table_handle()->at(k).point().y()(time_), + tr_.active_weighted_points_3_table_handle()->at(k).point().z()(time_)); + } + return cache_3_[k]; + }*/ + + + const typename Static_kernel::Weighted_point_3& + static_object(typename CIK::Point_3 k) const { + check_static_object(); + if (cache_w3_.find(k) == cache_w3_.end()) { + const typename Kinetic_kernel::Weighted_point_3 &wp= tr_.active_points_3_table_handle()->at(k); + cache_w3_[k]= typename Static_kernel::Point_3(typename Static_kernel::Bare_point(wp.point().x()(time_), + wp.point().y()(time_), + wp.point().z()(time_)), + wp.weight()(time_)); + } + return cache_w3_[k]; + } + + + const Static_kernel& static_kernel() const + { + return tr_.static_kernel_object(); + } +protected: + mutable bool initialized_; + typename CIK::Traits tr_; + mutable std::map cache_1_; + mutable std::map cache_2_; + mutable std::map cache_w3_; + /*mutable std::map cache_w3_;*/ + Time time_; +}; + + +template +class Regular_triangulation_instantaneous_kernel +{ + typedef Regular_triangulation_instantaneous_kernel This; +public: + typedef Traitst Traits; + typedef Regular_instantaneous_kernel_rep< This> Rep; + typedef typename Traits::Static_kernel Static_kernel; + typedef typename Static_kernel::FT Time; + + Regular_triangulation_instantaneous_kernel(const Traits &tr): + rep_(new Rep(tr)) { + } + + void set_time(const Time &cur_time) const + { + rep_->set_time(cur_time); + } + + const Time &time() const + { + return rep_->time(); + } + + + typedef typename Static_kernel::RT RT; + typedef typename Static_kernel::FT FT; + + typedef typename Traits::Active_points_1_table::Key Point_1; + typedef typename Traits::Active_points_2_table::Key Point_2; + //typedef typename Traits::Active_weighted_points_3_table::Key Point_3; + typedef typename Traits::Active_points_3_table::Key Bare_point; + typedef typename Traits::Active_points_3_table::Key Point_3; + typedef Point_3 Weighted_point_3; + //typedef typename Traits::Active_weighted_points_3_table::Key Weighted_point_3; + + struct Current_coordinates { + Current_coordinates(typename Rep::Handle rep): rep_(rep){} + + const FT & operator()(Point_1 k) const { + return rep_->static_object(k); + } + const typename Static_kernel::Point_2 & operator()(Point_2 k) const { + return rep_->static_object(k); + } + const typename Static_kernel::Point_3 & operator()(Point_3 k) const { + return rep_->static_object(k); + } + /*const typename Static_kernel::Weighted_point_3 & operator()(Weighted_point_3 k) const { + return rep_->static_object(k); + }*/ + typename Rep::Handle rep_; + }; + + Current_coordinates current_coordinates_object() const { + return Current_coordinates(rep_); + } + + + typedef Instantaneous_adaptor, Current_coordinates, Point_1> Less_x_1; + Less_x_1 less_x_1_object() const + { + typename std::less sp; + return Less_x_1(current_coordinates_object(), sp); + } + + CGAL_MSA(Side_of_oriented_circle,side_of_oriented_circle, Point_2, 2); + CGAL_MSA(Orientation,orientation, Point_2, 2); + CGAL_MSA(Compare_x, compare_x, Point_2, 2); + CGAL_MSA(Compare_y,compare_y, Point_2, 2); + CGAL_MSA(Less_x, less_x, Point_2, 2); + CGAL_MSA(Less_y, less_y, Point_2, 2); + CGAL_MSA(Compare_distance, compare_distance, Point_2, 2); + CGAL_MSA(Compare_distance, compare_distance, Point_3, 3); + CGAL_TSO(Segment_2); + CGAL_TSO(Triangle_2); + + CGAL_MSA(Side_of_oriented_sphere,side_of_oriented_sphere, Point_3, 3); + CGAL_MSA(Orientation,orientation, Point_3, 3); + CGAL_MSA(Compare_x,compare_x, Point_3, 3); + CGAL_MSA(Compare_y,compare_y, Point_3, 3); + CGAL_MSA(Compare_z,compare_z, Point_3, 3); + CGAL_MSA(Compare_xyz,compare_xyz, Point_3, 3); + CGAL_MSA(Less_x, less_x, Point_3, 3); + CGAL_MSA(Less_y, less_y, Point_3, 3); + CGAL_MSA(Less_z, less_z, Point_3, 3); + CGAL_MSA(Coplanar_orientation, coplanar_orientation, Point_3, 3); + CGAL_MSA(Coplanar_side_of_bounded_circle, coplanar_side_of_bounded_circle, Point_3, 3); + CGAL_MSA(Power_test,power_test, Point_3, 3); + + + + CGAL_TSO(Segment_3); + CGAL_TSO(Triangle_3); + CGAL_TSO(Tetrahedron_3); + CGAL_TSO(Line_3); + CGAL_TSO(Ray_3); + CGAL_TSO(Object_3); + CGAL_TSO(Plane_3); +protected: + typename Rep::Handle rep_; +}; +#undef CGAL_MSA +#undef CGAL_TSO +CGAL_KINETIC_END_NAMESPACE +#endif