diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h index 7cb44d5ab76..604b4d9ee92 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h @@ -71,8 +71,6 @@ public: Vector_3 to_vector() const; Vector_3 vector() const { return to_vector(); } - Direction_3 operator-() const; - const FT & delta(int i) const; const FT & dx() const { @@ -131,14 +129,6 @@ DirectionC3::to_vector() const return Vector_3(dx(), dy(), dz()); } -template < class R > -inline -typename DirectionC3::Direction_3 -DirectionC3::operator-() const -{ - return DirectionC3(-dx(), -dy(), -dz()); -} - template < class R > const typename DirectionC3::FT & DirectionC3::delta(int i) const diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Sphere_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Sphere_3.h index 206f38de812..17d76ffd4a5 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Sphere_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Sphere_3.h @@ -37,7 +37,6 @@ class SphereC3 typedef typename R_::Point_3 Point_3; typedef typename R_::Vector_3 Vector_3; typedef typename R_::Sphere_3 Sphere_3; - typedef typename R_::Aff_transformation_3 Aff_transformation_3; typedef Triple Rep; typedef typename R_::template Handle::type Base; @@ -119,19 +118,6 @@ public: return get(base).third; } - Sphere_3 orthogonal_transform(const Aff_transformation_3 &t) const - { - // FIXME: precond: t.is_orthogonal() (*UNDEFINED*) - Vector_3 vec(FT(1), FT(0), FT(0)); // unit vector - vec = vec.transform(t); // transformed - FT sq_scale = vec.squared_length(); // squared scaling factor - - return SphereC3(t.transform(center()), - sq_scale * squared_radius(), - t.is_even() ? orientation() - : CGAL::opposite(orientation())); - } - // A circle is degenerate if its (squared) radius is null or negative bool is_degenerate() const; @@ -303,17 +289,6 @@ SphereC3::bbox() const maxx.sup(), maxy.sup(), maxz.sup()); } -/* -template < class R > -inline -EllipseC3::FT> SphereC3::i -transform(const Aff_transformationC3::FT> &t) const -{ - return SphereC3(t.transform(center()), - squared_radius(), - orientation()); -} -*/ #ifndef CGAL_NO_OSTREAM_INSERT_SPHEREC3 template < class R > diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h index 210a7ec9aa2..5d66dced742 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h @@ -72,7 +72,6 @@ public: bool has_on_unbounded_side(const Point_3 &p) const; bool is_degenerate() const; - FT volume() const; }; template < class R > @@ -136,14 +135,6 @@ operator[](int i) const return vertex(i); } -template < class R > -CGAL_KERNEL_MEDIUM_INLINE -typename TetrahedronC3::FT -TetrahedronC3::volume() const -{ - return R().compute_volume_3_object()(*this); -} - template < class R > Orientation TetrahedronC3:: diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 5d734149449..da5bd44845c 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -2872,6 +2872,7 @@ namespace CartesianKernelFunctors { { typedef typename K::Point_3 Point_3; typedef typename K::Vector_3 Vector_3; + typedef typename K::Tetrahedron_3 Tetrahedron_3; public: typedef typename K::Orientation result_type; typedef Arity_tag< 4 > Arity; @@ -2893,6 +2894,12 @@ namespace CartesianKernelFunctors { v.x(), v.y(), v.z(), w.x(), w.y(), w.z()); } + + result_type + operator()( const Tetrahedron_3& t) const + { + return t.rep().orientation(); + } }; template diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH3.h index cf0fb079737..4bd85d9887b 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH3.h @@ -74,9 +74,6 @@ public: base = Rep(-x,-y,-z,-w); } - DirectionH3 - operator-() const; - bool is_degenerate() const; bool operator==( const DirectionH3& d) const; @@ -137,12 +134,6 @@ bool DirectionH3::is_degenerate() const { return ((hx() == RT(0)) && (hy() == RT(0)) && (hz() == RT(0))); } -template -inline -DirectionH3 -DirectionH3::operator-() const -{ return DirectionH3(- hx(),- hy(),- hz() ); } - template inline typename DirectionH3::Vector_3 diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/SphereH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/SphereH3.h index 9f2d3de8c78..2cce983b638 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/SphereH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/SphereH3.h @@ -36,7 +36,6 @@ class SphereH3 typedef typename R_::RT RT; typedef typename R_::FT FT; typedef typename R_::Point_3 Point_3; - typedef typename R_::Aff_transformation_3 Aff_transformation_3; typedef Triple Rep; typedef typename R_::template Handle::type Base; @@ -77,8 +76,6 @@ public: Orientation orientation() const; - SphereH3 orthogonal_transform(const Aff_transformation_3& t) const; - bool is_degenerate() const; SphereH3 opposite() const; @@ -254,29 +251,6 @@ SphereH3::bbox() const maxx.sup(), maxy.sup(), maxz.sup()); } -template -SphereH3 -SphereH3:: -orthogonal_transform(const typename SphereH3::Aff_transformation_3& t) const -{ - typename R::Vector_3 vec( RT(1), RT(0), RT(0) ); // unit vector - vec = vec.transform(t); // transformed - FT sq_scale = FT( vec*vec ); // squared scaling factor - - if ( t.is_even() ) - { - return SphereH3(t.transform(center() ), - sq_scale * squared_radius(), - orientation() ); - } - else - { - return SphereH3(t.transform(center() ), - sq_scale * squared_radius(), - CGAL::opposite( orientation()) ); - } -} - #ifndef CGAL_NO_OSTREAM_INSERT_SPHEREH3 template < class R > diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h index 3ed6b8e706a..844a8d4dd26 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h @@ -3560,8 +3560,9 @@ namespace HomogeneousKernelFunctors { template class Orientation_3 { - typedef typename K::Point_3 Point_3; - typedef typename K::Vector_3 Vector_3; + typedef typename K::Point_3 Point_3; + typedef typename K::Vector_3 Vector_3; + typedef typename K::Tetrahedron_3 Tetrahedron_3; public: typedef typename K::Orientation result_type; typedef Arity_tag< 4 > Arity; @@ -3586,6 +3587,12 @@ namespace HomogeneousKernelFunctors { v.hx(), v.hy(), v.hz(), w.hx(), w.hy(), w.hz())); } + + result_type + operator()( const Tetrahedron_3& t) const + { + return t.rep().orientation(); + } }; diff --git a/Kernel_23/include/CGAL/Direction_2.h b/Kernel_23/include/CGAL/Direction_2.h index 810a35f295f..844c670e0de 100644 --- a/Kernel_23/include/CGAL/Direction_2.h +++ b/Kernel_23/include/CGAL/Direction_2.h @@ -135,7 +135,7 @@ public: Direction_2 operator-() const { - return Direction_2(-dx(), -dy()); + return R().construct_opposite_direction_2_object()(*this); } Vector_2 vector() const diff --git a/Kernel_23/include/CGAL/Direction_3.h b/Kernel_23/include/CGAL/Direction_3.h index 8d9d8195934..c8da4b4852a 100644 --- a/Kernel_23/include/CGAL/Direction_3.h +++ b/Kernel_23/include/CGAL/Direction_3.h @@ -76,6 +76,13 @@ public: { return t.transform(*this); } + + Direction_3 + operator-() const + { + return R().construct_opposite_direction_3_object()(*this); + } + }; diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index fbcee0a5453..bf183411cf9 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -557,7 +557,7 @@ namespace CommonKernelFunctors { }; template - class Construct_center_3 + class Construct_center_3 : Has_qrt { typedef typename K::Point_3 Point_3; typedef typename K::Sphere_3 Sphere_3; @@ -565,9 +565,9 @@ namespace CommonKernelFunctors { typedef Point_3 result_type; typedef Arity_tag< 1 > Arity; - Point_3 + const Point_3 & operator()(const Sphere_3& s) const - { return s.center(); } + { return s.rep().center(); } }; template @@ -770,27 +770,29 @@ namespace CommonKernelFunctors { template class Construct_opposite_direction_2 { - typedef typename K::Direction_2 Direction_2; + typedef typename K::Direction_2 Direction_2; + typedef typename Direction_2::Rep Rep; public: typedef Direction_2 result_type; typedef Arity_tag< 1 > Arity; Direction_2 operator()( const Direction_2& d) const - { return -d; } + { return Rep(-d.dx(), -d.dy()); } }; template class Construct_opposite_direction_3 { - typedef typename K::Direction_3 Direction_3; + typedef typename K::Direction_3 Direction_3; + typedef typename Direction_3::Rep Rep; public: typedef Direction_3 result_type; typedef Arity_tag< 1 > Arity; Direction_3 operator()( const Direction_3& d) const - { return -d; } + { return Rep(-d.dx(), -d.dy(), -d.dz()); } }; template @@ -829,7 +831,7 @@ namespace CommonKernelFunctors { Plane_3 operator()( const Plane_3& p) const - { return p.opposite(); } + { return p.rep().opposite(); } }; template @@ -1306,7 +1308,7 @@ namespace CommonKernelFunctors { Plane_3 operator()( const Triangle_3& t) const - { return t.supporting_plane(); } + { return t.rep().supporting_plane(); } }; template @@ -1372,7 +1374,7 @@ namespace CommonKernelFunctors { const Point_3 & operator()( const Triangle_3& t, int i) const - { return t.vertex(i); } + { return t.rep().vertex(i); } Point_3 operator()( const Iso_cuboid_3& r, int i) const @@ -1380,7 +1382,7 @@ namespace CommonKernelFunctors { const Point_3 & operator()( const Tetrahedron_3& t, int i) const - { return t.vertex(i); } + { return t.rep().vertex(i); } }; @@ -1765,7 +1767,7 @@ namespace CommonKernelFunctors { result_type operator()( const Tetrahedron_3& t, const Point_3& p) const - { return t.has_on_boundary(p); } + { return t.rep().has_on_boundary(p); } result_type operator()( const Iso_cuboid_3& c, const Point_3& p) const @@ -1813,7 +1815,7 @@ namespace CommonKernelFunctors { result_type operator()( const Tetrahedron_3& t, const Point_3& p) const - { return t.has_on_bounded_side(p); } + { return t.rep().has_on_bounded_side(p); } result_type operator()( const Iso_cuboid_3& c, const Point_3& p) const @@ -1861,7 +1863,7 @@ namespace CommonKernelFunctors { result_type operator()( const Tetrahedron_3& t, const Point_3& p) const - { return t.has_on_negative_side(p); } + { return t.rep().has_on_negative_side(p); } result_type operator()( const Plane_3& pl, const Point_3& p) const @@ -1909,7 +1911,7 @@ namespace CommonKernelFunctors { result_type operator()( const Tetrahedron_3& t, const Point_3& p) const - { return t.has_on_positive_side(p); } + { return t.rep().has_on_positive_side(p); } result_type operator()( const Plane_3& pl, const Point_3& p) const @@ -1959,7 +1961,7 @@ namespace CommonKernelFunctors { result_type operator()( const Tetrahedron_3& t, const Point_3& p) const - { return t.has_on_unbounded_side(p); } + { return t.rep().has_on_unbounded_side(p); } result_type operator()( const Iso_cuboid_3& c, const Point_3& p) const @@ -2104,11 +2106,11 @@ namespace CommonKernelFunctors { result_type operator()( const Triangle_3& t) const - { return t.is_degenerate(); } + { return t.rep().is_degenerate(); } result_type operator()( const Tetrahedron_3& t) const - { return t.is_degenerate(); } + { return t.rep().is_degenerate(); } }; template @@ -2233,7 +2235,7 @@ namespace CommonKernelFunctors { result_type operator()( const Tetrahedron_3& t, const Point_3& p) const - { return t.oriented_side(p); } + { return t.rep().oriented_side(p); } }; } // namespace CommonKernelFunctors diff --git a/Kernel_23/include/CGAL/Plane_3.h b/Kernel_23/include/CGAL/Plane_3.h index b61223ce317..d34993fbfc5 100644 --- a/Kernel_23/include/CGAL/Plane_3.h +++ b/Kernel_23/include/CGAL/Plane_3.h @@ -84,6 +84,11 @@ public: { return t.transform(*this); } + + Plane_3 opposite() const + { + return R().construct_opposite_plane_3_object()(*this); + } }; #ifndef CGAL_NO_OSTREAM_INSERT_PLANE_3 diff --git a/Kernel_23/include/CGAL/Sphere_3.h b/Kernel_23/include/CGAL/Sphere_3.h index ccb67346781..07d20af5878 100644 --- a/Kernel_23/include/CGAL/Sphere_3.h +++ b/Kernel_23/include/CGAL/Sphere_3.h @@ -31,6 +31,7 @@ class Sphere_3 : public R_::Kernel_base::Sphere_3 { typedef typename R_::FT FT; typedef typename R_::Point_3 Point_3; + typedef typename R_::Aff_transformation_3 Aff_transformation_3; typedef typename R_::Kernel_base::Sphere_3 RSphere_3; public: @@ -71,8 +72,39 @@ public: Sphere_3(const Point_3& p, const Orientation& o = COUNTERCLOCKWISE) : RSphere_3(p, o) {} + + Sphere_3 orthogonal_transform(const Aff_transformation_3 &t) const; + + // FIXME : why doesn't Qrt work here ? We loose optimization ! + //typename Qualified_result_of::type + Point_3 + center() const + { + return R().construct_center_3_object()(*this); + } + }; +template +Sphere_3 +Sphere_3:: +orthogonal_transform(const typename Sphere_3::Aff_transformation_3& t) const +{ + typedef typename R_::RT RT; + typedef typename R_::FT FT; + typedef typename R_::Vector_3 Vector_3; + + // FIXME: precond: t.is_orthogonal() (*UNDEFINED*) + Vector_3 vec(RT(1), RT(0), RT(0)); // unit vector + vec = vec.transform(t); // transformed + FT sq_scale = vec.squared_length(); // squared scaling factor + + return Sphere_3(t.transform(this->center()), + sq_scale * this->squared_radius(), + t.is_even() ? this->orientation() + : CGAL::opposite(this->orientation())); +} + CGAL_END_NAMESPACE #endif // CGAL_SPHERE_3_H diff --git a/Kernel_23/include/CGAL/Tetrahedron_3.h b/Kernel_23/include/CGAL/Tetrahedron_3.h index 8af2e8e40e6..07372c5d228 100644 --- a/Kernel_23/include/CGAL/Tetrahedron_3.h +++ b/Kernel_23/include/CGAL/Tetrahedron_3.h @@ -67,6 +67,73 @@ public: t.transform(this->vertex(3))); } + // FIXME TODO : Why doesn't Qrt work here ??? + //typename Qualified_result_of::type + Point_3 + vertex(int i) const + { + return R().construct_vertex_3_object()(*this,i); + } + + //typename Qualified_result_of::type + Point_3 + operator[](int i) const + { + return vertex(i); + } + + bool + is_degenerate() const + { + return R().is_degenerate_3_object()(*this); + } + + Orientation orientation() const + { + return R().orientation_3_object()(*this); + } + + Bounded_side bounded_side(const Point_3 &p) const + { + return R().bounded_side_3_object()(*this, p); + } + + Oriented_side oriented_side(const Point_3 &p) const + { + return R().oriented_side_3_object()(*this, p); + } + + bool has_on_positive_side(const Point_3 &p) const + { + return R().has_on_positive_side_3_object()(*this, p); + } + + bool has_on_negative_side(const Point_3 &p) const + { + return R().has_on_negative_side_3_object()(*this, p); + } + + bool has_on_boundary(const Point_3 &p) const + { + return R().has_on_boundary_3_object()(*this, p); + } + + bool has_on_bounded_side(const Point_3 &p) const + { + return R().has_on_bounded_side_3_object()(*this, p); + } + + bool has_on_unbounded_side(const Point_3 &p) const + { + return R().has_on_unbounded_side_3_object()(*this, p); + } + + typename Qualified_result_of::type + volume() const + { + return R().compute_volume_3_object()(*this); + } + }; #ifndef CGAL_NO_OSTREAM_INSERT_TETRAHEDRON_3 diff --git a/Kernel_23/include/CGAL/Triangle_3.h b/Kernel_23/include/CGAL/Triangle_3.h index bdb5d4a9096..46e7605a7b1 100644 --- a/Kernel_23/include/CGAL/Triangle_3.h +++ b/Kernel_23/include/CGAL/Triangle_3.h @@ -30,7 +30,9 @@ template class Triangle_3 : public R_::Kernel_base::Triangle_3 { typedef typename R_::RT RT; + typedef typename R_::FT FT; typedef typename R_::Point_3 Point_3; + typedef typename R_::Plane_3 Plane_3; typedef typename R_::Aff_transformation_3 Aff_transformation_3; typedef typename R_::Kernel_base::Triangle_3 RTriangle_3; public: @@ -63,6 +65,37 @@ public: t.transform(this->vertex(1)), t.transform(this->vertex(2))); } + + Plane_3 supporting_plane() const + { + return R().construct_supporting_plane_3_object()(*this); + } + + bool has_on(const Point_3 &p) const + { + return R().has_on_3_object()(*this, p); + } + + Point_3 vertex(int i) const // TODO : use Qrt + { + return R().construct_vertex_3_object()(*this, i); + } + + Point_3 operator[](int i) const // TODO : use Qrt + { + return vertex(i); + } + + bool is_degenerate() const + { + return R().is_degenerate_3_object()(*this); + } + + FT squared_area() const // TODO : use Qrt + { + return R().compute_squared_area_3_object()(*this); + } + }; #ifndef CGAL_NO_OSTREAM_INSERT_TRIANGLE_3