From ac9b5b2fbdb29f0cf925bef7156cbc69819bd802 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 13 Apr 2021 19:38:28 +0100 Subject: [PATCH 01/19] Add Aff_transformation_3::is_translation() which checks the rep --- .../include/CGAL/Cartesian/Aff_transformation_3.h | 3 +++ .../CGAL/Cartesian/Aff_transformation_rep_3.h | 7 +++++++ .../include/CGAL/Cartesian/Scaling_rep_3.h | 6 ++++++ .../include/CGAL/Cartesian/Translation_rep_3.h | 5 +++++ .../CGAL/Homogeneous/Aff_transformationH3.h | 15 +++++++++++++++ Nef_3/include/CGAL/Nef_polyhedron_3.h | 8 ++++++-- 6 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_3.h index 7a04f837092..dce2d467b1e 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_3.h @@ -161,6 +161,9 @@ public: bool is_even() const { return this->Ptr()->is_even(); } bool is_odd() const { return ! (this->Ptr()->is_even()); } + bool is_translation() const { return this->Ptr()->is_translation(); } + + FT cartesian(int i, int j) const { return this->Ptr()->cartesian(i,j); } FT homogeneous(int i, int j) const { return cartesian(i,j); } FT m(int i, int j) const { return cartesian(i,j); } diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h index 406cb7accca..2af5a97cedd 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h @@ -54,6 +54,7 @@ public: virtual Aff_transformation_3 inverse() const = 0; virtual Aff_transformation_3 transpose() const = 0; virtual bool is_even() const = 0; + virtual bool is_translation() const = 0; virtual FT cartesian(int i, int j) const = 0; virtual std::ostream &print(std::ostream &os) const = 0; }; @@ -144,6 +145,12 @@ public: t31, t32, t33) == POSITIVE; } + + virtual bool is_translation() const + { + return false; + } + virtual FT cartesian(int i, int j) const { switch (i) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_3.h index 061f1806a9e..d90928efddb 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_3.h @@ -121,6 +121,12 @@ public: return true; } + virtual bool is_translation() const + { + return false; + } + + virtual FT cartesian(int i, int j) const { if (i!=j) return FT(0); diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h index 6377c1a3d8a..9f0d718a64e 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h @@ -125,6 +125,11 @@ public: return true; } + virtual bool is_translation() const + { + return true; + } + virtual FT cartesian(int i, int j) const { if (j==i) return FT(1); diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h index b67c4f024a3..1ee88421490 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h @@ -87,6 +87,9 @@ public: virtual FT cartesian(int i, int j) const = 0; + + virtual bool + is_translation() const = 0; }; template < class R_ > @@ -212,6 +215,12 @@ public: is_even() const { return true; } + virtual bool + is_translation() const + { + return false; + } + virtual RT homogeneous(int i, int j) const { return (i==j) ? RT(1) : RT(0); } @@ -693,6 +702,12 @@ bool Translation_repH3::is_even() const { return true; } +template < class R > +inline +bool +Translation_repH3::is_translation() const +{ return true; } + template < class R > CGAL_KERNEL_LARGE_INLINE typename Translation_repH3::RT diff --git a/Nef_3/include/CGAL/Nef_polyhedron_3.h b/Nef_3/include/CGAL/Nef_polyhedron_3.h index 8a2e1e16520..c1a0791152f 100644 --- a/Nef_3/include/CGAL/Nef_polyhedron_3.h +++ b/Nef_3/include/CGAL/Nef_polyhedron_3.h @@ -1710,6 +1710,8 @@ protected: bool ninety = is_90degree_rotation(aff); bool scale = is_scaling(aff); + bool translate = aff.is_translation(); + Vertex_iterator vi; CGAL_forall_vertices( vi, snc()) { @@ -1726,8 +1728,10 @@ protected: vertex_list.push_back(vi); } else { vi->point() = vi->point().transform( aff); - SM_decorator sdeco(&*vi); - sdeco.transform( linear); + if(! translate){ + SM_decorator sdeco(&*vi); + sdeco.transform( linear); + } } } From 56a3a35a7d45c07efacc63111305007ea302ce58 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 13 Apr 2021 20:05:13 +0100 Subject: [PATCH 02/19] Fix Homogeneous --- .../CGAL/Homogeneous/Aff_transformationH3.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h index 1ee88421490..fb06bfd0d1c 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h @@ -139,6 +139,9 @@ public: virtual bool is_even() const; + virtual bool + is_translation() const; + virtual RT homogeneous(int i, int j) const ; @@ -273,6 +276,9 @@ public: virtual bool is_even() const; + virtual bool + is_translation() const; + virtual RT homogeneous(int i, int j) const ; @@ -548,6 +554,14 @@ Aff_transformation_repH3::is_even() const t20, t21, t22 ) ) == POSITIVE ); } +template < class R > +CGAL_KERNEL_INLINE +bool +Aff_transformation_repH3::is_translation() const + return false; +} + + template < class R > CGAL_KERNEL_LARGE_INLINE typename Aff_transformation_repH3::RT From a841ee4d1aa7b09fcfc23a0b6f072b2e9d9ebce1 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 13 Apr 2021 20:10:22 +0100 Subject: [PATCH 03/19] Fix Homogeneous --- .../include/CGAL/Homogeneous/Aff_transformationH3.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h index fb06bfd0d1c..42b76bbed7b 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h @@ -558,6 +558,7 @@ template < class R > CGAL_KERNEL_INLINE bool Aff_transformation_repH3::is_translation() const +{ return false; } From 01cc9ec65351480472cb5e8fe6ba59fafc19451c Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 15 Apr 2021 13:14:42 +0100 Subject: [PATCH 04/19] Scaling a plane means scaling Plane_3::d() --- .../include/CGAL/Cartesian/Aff_transformation_3.h | 4 ++++ .../CGAL/Cartesian/Aff_transformation_rep_3.h | 14 ++++++++++++++ .../include/CGAL/Cartesian/Scaling_rep_3.h | 11 +++++++++++ .../include/CGAL/Cartesian/Translation_rep_3.h | 9 +++++++++ 4 files changed, 38 insertions(+) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_3.h index dce2d467b1e..db82d2b78fa 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_3.h @@ -144,6 +144,9 @@ public: Plane_3 transform(const Plane_3& p) const { + if(is_scaling()){ + return this->Ptr()->transform(p); + } if (is_even()) return Plane_3(transform(p.point()), transpose().inverse().transform(p.orthogonal_direction())); @@ -162,6 +165,7 @@ public: bool is_odd() const { return ! (this->Ptr()->is_even()); } bool is_translation() const { return this->Ptr()->is_translation(); } + bool is_scaling() const { return this->Ptr()->is_scaling(); } FT cartesian(int i, int j) const { return this->Ptr()->cartesian(i,j); } diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h index 2af5a97cedd..1d326dfa092 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h @@ -31,6 +31,7 @@ public: typedef typename R::Point_3 Point_3; typedef typename R::Vector_3 Vector_3; typedef typename R::Direction_3 Direction_3; + typedef typename R::Plane_3 Plane_3; typedef typename R::Aff_transformation_3 Aff_transformation_3; virtual ~Aff_transformation_rep_baseC3(){} @@ -38,6 +39,7 @@ public: virtual Point_3 transform(const Point_3 &p) const = 0; virtual Vector_3 transform(const Vector_3 &v) const = 0; virtual Direction_3 transform(const Direction_3 &d) const = 0; + virtual Plane_3 transform(const Plane_3& p) const = 0; virtual Aff_transformation_3 operator*( const Aff_transformation_rep_baseC3 &t) const = 0; @@ -55,6 +57,7 @@ public: virtual Aff_transformation_3 transpose() const = 0; virtual bool is_even() const = 0; virtual bool is_translation() const = 0; + virtual bool is_scaling() const = 0; virtual FT cartesian(int i, int j) const = 0; virtual std::ostream &print(std::ostream &os) const = 0; }; @@ -128,6 +131,12 @@ public: t31 * v.x() + t32 * v.y() + t33 * v.z()); } + virtual Plane_3 transform(const Plane_3& p) const + { + return p; // fix or never call + } + + // Note that Aff_transformation is not defined yet, // so the following 6 functions have to be implemented // outside class body @@ -151,6 +160,11 @@ public: return false; } + virtual bool is_scaling() const + { + return false; + } + virtual FT cartesian(int i, int j) const { switch (i) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_3.h index d90928efddb..402f1fedb25 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_3.h @@ -34,6 +34,7 @@ public: typedef typename Transformation_base_3::Point_3 Point_3; typedef typename Transformation_base_3::Vector_3 Vector_3; typedef typename Transformation_base_3::Direction_3 Direction_3; + typedef typename Transformation_base_3::Plane_3 Plane_3; typedef typename Transformation_base_3::Aff_transformation_3 Aff_transformation_3; @@ -59,6 +60,12 @@ public: return d; } + virtual Plane_3 transform(const Plane_3 &p) const + { + // direction ( which is (p.a(), p.b(), p.c())) does not change + return Plane_3(p.a(),p.b(),p.c(), p.d()*scalefactor_); + } + virtual Aff_transformation_3 operator*(const Transformation_base_3 &t) const { return t.compose(*this); @@ -126,6 +133,10 @@ public: return false; } + virtual bool is_scaling() const + { + return true; + } virtual FT cartesian(int i, int j) const { diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h index 9f0d718a64e..99c1838356a 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h @@ -56,6 +56,11 @@ public: return d; } + virtual Plane_3 transform(const Plane_3 &d) const + { + return d; // fix or never call it + } + virtual Aff_transformation_3 operator*(const Transformation_base_3 &t) const { return t.compose(*this); @@ -130,6 +135,10 @@ public: return true; } + virtual bool is_scaling() const + { + return false; + } virtual FT cartesian(int i, int j) const { if (j==i) return FT(1); From 91ea4909c2908b249392f8cf9745b95ed31a1a74 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 15 Apr 2021 13:36:58 +0100 Subject: [PATCH 05/19] Fixes --- .../CGAL/Cartesian/Aff_transformation_rep_3.h | 1 + .../include/CGAL/Cartesian/Translation_rep_3.h | 1 + .../CGAL/Homogeneous/Aff_transformationH3.h | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h index 1d326dfa092..98a69b3a568 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h @@ -79,6 +79,7 @@ public: typedef typename Transformation_base_3::Point_3 Point_3; typedef typename Transformation_base_3::Vector_3 Vector_3; typedef typename Transformation_base_3::Direction_3 Direction_3; + typedef typename Transformation_base_3::Plane_3 Plane_3; typedef typename Transformation_base_3:: Aff_transformation_3 Aff_transformation_3; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h index 99c1838356a..eb897160252 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h @@ -34,6 +34,7 @@ public: typedef typename Transformation_base_3::Point_3 Point_3; typedef typename Transformation_base_3::Vector_3 Vector_3; typedef typename Transformation_base_3::Direction_3 Direction_3; + typedef typename Transformation_base_3::Plane_3 Plane_3; typedef typename Transformation_base_3::Aff_transformation_3 Aff_transformation_3; diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h index 42b76bbed7b..3e6f57ec140 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h @@ -90,6 +90,9 @@ public: virtual bool is_translation() const = 0; + + virtual bool + is_scaling() const = 0; }; template < class R_ > @@ -142,6 +145,9 @@ public: virtual bool is_translation() const; + virtual bool + is_scaling() const; + virtual RT homogeneous(int i, int j) const ; @@ -224,6 +230,12 @@ public: return false; } + virtual bool + is_scaling() const + { + return false; + } + virtual RT homogeneous(int i, int j) const { return (i==j) ? RT(1) : RT(0); } @@ -279,6 +291,9 @@ public: virtual bool is_translation() const; + virtual bool + is_scaling() const; + virtual RT homogeneous(int i, int j) const ; From 153413e8d59907ee9dde79bb13cc0fd23338e103 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 15 Apr 2021 13:58:33 +0100 Subject: [PATCH 06/19] Add code for translation of Plane_3 and move generic code down to the rep --- .../include/CGAL/Cartesian/Aff_transformation_3.h | 12 +----------- .../CGAL/Cartesian/Aff_transformation_rep_3.h | 7 ++++++- .../include/CGAL/Cartesian/Translation_rep_3.h | 8 ++++++-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_3.h index db82d2b78fa..d696e1917a3 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_3.h @@ -143,17 +143,7 @@ public: Plane_3 transform(const Plane_3& p) const - { - if(is_scaling()){ - return this->Ptr()->transform(p); - } - if (is_even()) - return Plane_3(transform(p.point()), - transpose().inverse().transform(p.orthogonal_direction())); - else - return Plane_3(transform(p.point()), - - transpose().inverse().transform(p.orthogonal_direction())); - } + { return this->Ptr()->transform(p); } Plane_3 operator()(const Plane_3& p) const diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h index 98a69b3a568..813a452f026 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h @@ -134,7 +134,12 @@ public: virtual Plane_3 transform(const Plane_3& p) const { - return p; // fix or never call + if (is_even()) + return Plane_3(transform(p.point()), + transpose().inverse().transform(p.orthogonal_direction())); + else + return Plane_3(transform(p.point()), + - transpose().inverse().transform(p.orthogonal_direction())); } diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h index eb897160252..488dc17f4e4 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h @@ -57,9 +57,13 @@ public: return d; } - virtual Plane_3 transform(const Plane_3 &d) const + virtual Plane_3 transform(const Plane_3 &p) const { - return d; // fix or never call it + // direction ( which is (p.a(), p.b(), p.c())) does not change + return Plane_3(p.a(), + p.b(), + p.c(), + p.d() - ( p.a()*translationvector_.x() + p.b()*translationvector_.y() + p.c()*translationvector_.z())); } virtual Aff_transformation_3 operator*(const Transformation_base_3 &t) const From 35fc3c7d2dc5927a40302a7c76e4bdda681b376d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 20 Apr 2021 09:04:23 +0100 Subject: [PATCH 07/19] Add missing implementations for Homogeneous. Fix the test for Filtered_cartesian as it has become more exact now --- .../CGAL/Homogeneous/Aff_transformationH3.h | 35 ++++++++++++++++++- .../CGAL/_test_cls_aff_transformation_3.h | 2 +- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h index 3e6f57ec140..8db74b21d65 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h @@ -233,7 +233,7 @@ public: virtual bool is_scaling() const { - return false; + return true; } virtual RT @@ -370,6 +370,12 @@ public: bool is_odd() const; + bool + is_scaling() const; + + bool + is_translation() const; + FT cartesian(int i, int j) const { return this->Ptr()->cartesian(i,j); } @@ -577,6 +583,14 @@ Aff_transformation_repH3::is_translation() const return false; } +template < class R > +CGAL_KERNEL_INLINE +bool +Aff_transformation_repH3::is_scaling() const +{ + return false; +} + template < class R > CGAL_KERNEL_LARGE_INLINE @@ -738,6 +752,12 @@ bool Translation_repH3::is_translation() const { return true; } +template < class R > +inline +bool +Translation_repH3::is_scaling() const +{ return false; } + template < class R > CGAL_KERNEL_LARGE_INLINE typename Translation_repH3::RT @@ -935,6 +955,19 @@ bool Aff_transformationH3::is_odd() const { return ( ! (this->Ptr()->is_even() )); } + +template < class R > +inline +bool +Aff_transformationH3::is_scaling() const +{ return this->Ptr()->is_scaling(); } + +template < class R > +inline +bool +Aff_transformationH3::is_translation() const +{ return this->Ptr()->is_translation(); } + template < class R > CGAL_KERNEL_INLINE Aff_transformationH3 diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h index c10c07d1b1c..e4d53323454 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h @@ -261,7 +261,7 @@ _test_cls_aff_transformation_3(const R& ) assert( vec.transform(translate) == vec.transform(gtrans) ); assert( dir.transform(translate) == dir.transform(gtrans) ); assert( pnt.transform(translate) == pnt.transform(gtrans) ); - assert( pla.transform(translate) == pla.transform(gtrans) ); + assert( pla.transform(translate) == pla.transform(gtrans) || nonexact ); // xrefl tdir = d0.transform(xrefl); From f0fea275afc675aa58930f4ae16b893d6b5541a6 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 21 Apr 2021 15:03:39 +0100 Subject: [PATCH 08/19] default in the base class --- .../CGAL/Homogeneous/Aff_transformationH3.h | 41 +------------------ 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h index 8db74b21d65..d28b56e0e5e 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h @@ -89,10 +89,10 @@ public: cartesian(int i, int j) const = 0; virtual bool - is_translation() const = 0; + is_translation() const { return false; } virtual bool - is_scaling() const = 0; + is_scaling() const { return false; } }; template < class R_ > @@ -142,12 +142,6 @@ public: virtual bool is_even() const; - virtual bool - is_translation() const; - - virtual bool - is_scaling() const; - virtual RT homogeneous(int i, int j) const ; @@ -224,12 +218,6 @@ public: is_even() const { return true; } - virtual bool - is_translation() const - { - return false; - } - virtual bool is_scaling() const { @@ -291,9 +279,6 @@ public: virtual bool is_translation() const; - virtual bool - is_scaling() const; - virtual RT homogeneous(int i, int j) const ; @@ -575,22 +560,6 @@ Aff_transformation_repH3::is_even() const t20, t21, t22 ) ) == POSITIVE ); } -template < class R > -CGAL_KERNEL_INLINE -bool -Aff_transformation_repH3::is_translation() const -{ - return false; -} - -template < class R > -CGAL_KERNEL_INLINE -bool -Aff_transformation_repH3::is_scaling() const -{ - return false; -} - template < class R > CGAL_KERNEL_LARGE_INLINE @@ -752,12 +721,6 @@ bool Translation_repH3::is_translation() const { return true; } -template < class R > -inline -bool -Translation_repH3::is_scaling() const -{ return false; } - template < class R > CGAL_KERNEL_LARGE_INLINE typename Translation_repH3::RT From 8a446d1778f8e40a3e0dc9a53a18d3d401631c58 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 22 Apr 2021 08:49:52 +0100 Subject: [PATCH 09/19] Document is_scaling() and is_translation() --- Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h index 7d3889def8c..6181b0bc6d5 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h @@ -199,6 +199,17 @@ returns `true`, if the transformation is reflecting. */ bool is_odd() const; +/*! +returns `true`, if the transformation type is the specialized scaling. +*/ +bool is_scaling() const; + +/*! +returns `true`, if the transformation type is the specialized translation. +*/ +bool is_translation() const; + + /// @} /// \name Matrix Entry Access From 7485e3887b51df76108171373d0515b82dcfa586 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 22 Apr 2021 13:43:07 +0100 Subject: [PATCH 10/19] Improve documentation and the example that performs affine transformations --- Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h | 4 ++-- Nef_3/doc/Nef_3/Nef_3.txt | 1 - Nef_3/examples/Nef_3/transformation.cpp | 11 ++--------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h index 6181b0bc6d5..1b5781e7f89 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h @@ -200,12 +200,12 @@ returns `true`, if the transformation is reflecting. bool is_odd() const; /*! -returns `true`, if the transformation type is the specialized scaling. +returns `true`, if the object was constructed using the tag `CGAL::Scaling`, or as a composition of such objects. */ bool is_scaling() const; /*! -returns `true`, if the transformation type is the specialized translation. +returns `true`, if the object was constructed using the tag `CGAL::Translation`, or as a composition of such objects. */ bool is_translation() const; diff --git a/Nef_3/doc/Nef_3/Nef_3.txt b/Nef_3/doc/Nef_3/Nef_3.txt index b4fee9d321a..636630cd569 100644 --- a/Nef_3/doc/Nef_3/Nef_3.txt +++ b/Nef_3/doc/Nef_3/Nef_3.txt @@ -579,4 +579,3 @@ the `Object_handle` can represent a `Vertex_const_handle`, a */ } /* namespace CGAL */ - diff --git a/Nef_3/examples/Nef_3/transformation.cpp b/Nef_3/examples/Nef_3/transformation.cpp index 74d1108888f..0e79e62e832 100644 --- a/Nef_3/examples/Nef_3/transformation.cpp +++ b/Nef_3/examples/Nef_3/transformation.cpp @@ -4,11 +4,7 @@ #include -//instead of -//typedef CGAL::Extended_homogeneous Kernel; -// workaround for VC++ -struct Kernel : public CGAL::Extended_homogeneous {}; - +typedef CGAL::Extended_homogeneous Kernel; typedef CGAL::Nef_polyhedron_3 Nef_polyhedron; typedef Nef_polyhedron::Plane_3 Plane_3; typedef Nef_polyhedron::Vector_3 Vector_3; @@ -22,10 +18,7 @@ int main() { 0,0,-1, 0,1,0, 1); - Aff_transformation_3 scale(3,0,0, - 0,3,0, - 0,0,3, - 2); + Aff_transformation_3 scale(CGAL::SCALING, 3, 2); N.transform(transl); CGAL_assertion(N == Nef_polyhedron(Plane_3(0,1,0,-7))); From a8d15183ce64acdf67825af17729dac291a7dee6 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 22 Apr 2021 13:57:26 +0100 Subject: [PATCH 11/19] So glad to have a native speaker on board --- Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h index 1b5781e7f89..d7cd385eaa0 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h @@ -200,12 +200,12 @@ returns `true`, if the transformation is reflecting. bool is_odd() const; /*! -returns `true`, if the object was constructed using the tag `CGAL::Scaling`, or as a composition of such objects. +returns `true`, if the object was constructed using the tag `CGAL::Scaling`, or is the result of the composition of only scaling transformations. */ bool is_scaling() const; /*! -returns `true`, if the object was constructed using the tag `CGAL::Translation`, or as a composition of such objects. +returns `true`, if the object was constructed using the tag `CGAL::Translation`, or is the result of the composition of only translation transformations. */ bool is_translation() const; From e73b8de89fd469c811ba156cbbd106624537f445 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 22 Apr 2021 21:17:24 +0100 Subject: [PATCH 12/19] Add the 2D stuff. In homogeneous add Scaling_repH3 --- .../CGAL/Cartesian/Aff_transformation_2.h | 5 + .../CGAL/Cartesian/Aff_transformation_rep_2.h | 5 + .../CGAL/Cartesian/Aff_transformation_rep_3.h | 15 +- .../include/CGAL/Cartesian/Reflection_rep_2.h | 5 + .../include/CGAL/Cartesian/Rotation_rep_2.h | 6 + .../include/CGAL/Cartesian/Scaling_rep_2.h | 5 + .../include/CGAL/Cartesian/Scaling_rep_3.h | 5 - .../CGAL/Cartesian/Translation_rep_2.h | 7 +- .../CGAL/Cartesian/Translation_rep_3.h | 4 - .../CGAL/Homogeneous/Aff_transformationH2.h | 51 +++++++ .../CGAL/Homogeneous/Aff_transformationH3.h | 130 ++++++++++++++++-- .../doc/Kernel_23/CGAL/Aff_transformation_2.h | 20 +++ .../doc/Kernel_23/CGAL/Aff_transformation_3.h | 4 +- .../CGAL/_test_cls_aff_transformation_2.h | 32 ++++- .../CGAL/_test_cls_aff_transformation_3.h | 10 ++ 15 files changed, 268 insertions(+), 36 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_2.h index bb646e29e66..16395549ab3 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_2.h @@ -165,6 +165,11 @@ public: bool is_even() const { return this->Ptr()->is_even(); } bool is_odd() const { return ! (this->Ptr()->is_even()); } + bool is_translation() const { return this->Ptr()->is_translation(); } + bool is_scaling() const { return this->Ptr()->is_scaling(); } + bool is_reflection() const { return this->Ptr()->is_reflection(); } + bool is_rotation() const { return this->Ptr()->is_rotation(); } + FT cartesian(int i, int j) const { return this->Ptr()->cartesian(i,j); } FT homogeneous(int i, int j) const { return cartesian(i,j); } FT m(int i, int j) const { return cartesian(i,j); } diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_2.h index 4737742e568..afce7dc25ed 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_2.h @@ -60,6 +60,11 @@ public: virtual Aff_transformation_2 inverse() const = 0; virtual bool is_even() const = 0; + virtual bool is_translation() const { return false; } + virtual bool is_scaling() const { return false; } + virtual bool is_rotation() const { return false; } + virtual bool is_reflection() const { return false; } + virtual FT cartesian(int i, int j) const = 0; virtual std::ostream &print(std::ostream &os) const = 0; }; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h index 813a452f026..2e441e194d3 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Aff_transformation_rep_3.h @@ -56,8 +56,9 @@ public: virtual Aff_transformation_3 inverse() const = 0; virtual Aff_transformation_3 transpose() const = 0; virtual bool is_even() const = 0; - virtual bool is_translation() const = 0; - virtual bool is_scaling() const = 0; + + virtual bool is_translation() const { return false; } + virtual bool is_scaling() const { return false; } virtual FT cartesian(int i, int j) const = 0; virtual std::ostream &print(std::ostream &os) const = 0; }; @@ -161,16 +162,6 @@ public: } - virtual bool is_translation() const - { - return false; - } - - virtual bool is_scaling() const - { - return false; - } - virtual FT cartesian(int i, int j) const { switch (i) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h index b534706373e..7a89746ffba 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Reflection_rep_2.h @@ -147,6 +147,11 @@ typedef typename CGAL::Line_2 Line_2; return true; } + virtual bool is_reflection() const + { + return true; + } + FT cartesian(int i, int j) const { switch (i) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Rotation_rep_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Rotation_rep_2.h index 092ff614195..2ea097c733b 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Rotation_rep_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Rotation_rep_2.h @@ -139,11 +139,17 @@ public: -sinus_*t.t21 + cosinus_*t.t22, t.t23); } + bool is_even() const { return true; } + bool is_rotation() const + { + return true; + } + FT cartesian(int i, int j) const { switch (i) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_2.h index dc0b74f5905..166fa4e1a53 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_2.h @@ -120,6 +120,11 @@ public: return true; } + bool is_scaling() const + { + return true; + } + FT cartesian(int i, int j) const { if (i!=j) return FT(0); diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_3.h index 402f1fedb25..a6b26320a8e 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Scaling_rep_3.h @@ -128,11 +128,6 @@ public: return true; } - virtual bool is_translation() const - { - return false; - } - virtual bool is_scaling() const { return true; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_2.h index 55e3b14fbc1..84b88ba46c5 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_2.h @@ -121,7 +121,12 @@ public: return Aff_transformation_2(TRANSLATION, - translationvector_); } - bool is_even() const + bool is_even() const + { + return true; + } + + virtual bool is_translation() const { return true; } diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h index 488dc17f4e4..28a1d4ef811 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Translation_rep_3.h @@ -140,10 +140,6 @@ public: return true; } - virtual bool is_scaling() const - { - return false; - } virtual FT cartesian(int i, int j) const { if (j==i) return FT(1); diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH2.h index 3a42574fa9d..a97ca83abf5 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH2.h @@ -58,6 +58,11 @@ class Aff_transformation_rep_baseH2 : public Ref_counted_virtual general_form() const = 0; virtual bool is_even() const = 0; + virtual bool is_translation() const { return false; } + virtual bool is_scaling() const { return false; } + virtual bool is_reflection() const { return false; } + virtual bool is_rotation() const { return false; } + virtual RT homogeneous(int i, int j) const = 0; virtual FT cartesian(int i, int j) const = 0; }; @@ -247,6 +252,10 @@ class Translation_repH2 : public Aff_transformation_rep_baseH2 is_even() const { return true; } + virtual bool + is_translation() const + { return true; } + virtual Aff_transformation_repH2 general_form() const { @@ -321,6 +330,11 @@ class Rotation_repH2 : public Aff_transformation_rep_baseH2 { return true; } + + virtual bool + is_rotation() const + { return true; } + virtual Aff_transformation_repH2 general_form() const { @@ -392,6 +406,10 @@ class Scaling_repH2 : public Aff_transformation_rep_baseH2 is_even() const { return true; } + virtual bool + is_scaling() const + { return true; } + virtual Aff_transformation_repH2 general_form() const { @@ -456,6 +474,10 @@ class Reflection_repH2 : public Aff_transformation_rep_baseH2 is_even() const { return false; } + virtual bool + is_reflection() const + { return true; } + virtual Aff_transformation_repH2 general_form() const { @@ -576,6 +598,11 @@ public: bool is_even() const; bool is_odd() const; + bool is_translation() const; + bool is_scaling() const; + bool is_rotation() const; + bool is_reflection() const; + // Access functions for matrix form FT cartesian(int i, int j) const; RT homogeneous(int i, int j) const; @@ -739,6 +766,30 @@ Aff_transformationH2:: is_odd() const { return ! is_even(); } +template < class R > +bool +Aff_transformationH2:: +is_translation() const +{ return this->Ptr()->is_translation(); } + +template < class R > +bool +Aff_transformationH2:: +is_scaling() const +{ return this->Ptr()->is_scaling(); } + +template < class R > +bool +Aff_transformationH2:: +is_rotation() const +{ return this->Ptr()->is_rotation(); } + +template < class R > +bool +Aff_transformationH2:: +is_reflection() const +{ return this->Ptr()->is_reflection(); } + template < class R > inline typename Aff_transformationH2::FT diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h index d28b56e0e5e..71209b65230 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h @@ -82,17 +82,17 @@ public: virtual bool is_even() const = 0; - virtual RT - homogeneous(int i, int j) const = 0; - - virtual FT - cartesian(int i, int j) const = 0; - virtual bool is_translation() const { return false; } virtual bool is_scaling() const { return false; } + + virtual RT + homogeneous(int i, int j) const = 0; + + virtual FT + cartesian(int i, int j) const = 0; }; template < class R_ > @@ -233,6 +233,118 @@ public: { return (i==j) ? FT(1) : FT(0); } }; +template < class R > +class Scaling_repH3 : public Aff_transformation_rep_baseH3 +{ + public: + typedef typename R::RT RT; + typedef typename R::FT FT; + typedef typename R::Point_3 Point_3; + typedef typename R::Vector_3 Vector_3; + typedef typename R::Direction_3 Direction_3; + + Scaling_repH3() + {} + + Scaling_repH3(const RT& scaling_numerator, + const RT& scaling_denominator) : + _sf_num(scaling_numerator), _sf_den(scaling_denominator) + { + if ( scaling_denominator < RT(0) ) + { + _sf_num = - _sf_num; + _sf_den = - _sf_den; + }; + } + + virtual ~Scaling_repH3() + {} + + virtual Point_3 + transform(const Point_3 & p) const + { + return Point_3( p.hx() * _sf_num, + p.hy() * _sf_num, + p.hz() * _sf_num, + p.hw() * _sf_den ); + } + virtual Vector_3 + transform(const Vector_3 & v) const + { + return Vector_3( v.hx() * _sf_num, + v.hy() * _sf_num, + v.hz() * _sf_num, + v.hw() * _sf_den ); + } + + virtual Direction_3 + transform(const Direction_3 & d) const + { return d; } + + virtual Plane_3 + transform(const Plane_3 & p) const + { + return Plane_3(p.a()*_sf_den, p.b()*_sf_den, p.c()*_sf_den, p.d()*_sf_num); + } + + virtual Aff_transformation_3 + inverse() const + { return Aff_transformation_3(SCALING, _sf_den, _sf_num); } + + virtual Aff_transformation_3 + transpose() const + { return Aff_transformation_3(SCALING, _sf_num, _sf_den); } + + virtual bool + is_even() const + { return true; } + + virtual bool + is_scaling() const + { return true; } + + virtual Aff_transformation_repH3 + general_form() const + { + return + Aff_transformation_repH3(_sf_num, RT(0) , RT(0) ,RT(0) , + RT(0) , _sf_num, RT(0) ,RT(0) , + RT(0) , RT(0) , _sf_num,RT(0) , + _sf_den ); + } + + virtual RT homogeneous(int i, int j) const; + virtual FT cartesian(int i, int j) const; + + + private: + RT _sf_num; + RT _sf_den; +}; + + +template < class R > +typename Scaling_repH3::RT +Scaling_repH3:: +homogeneous(int i, int j) const +{ + if(i!=j) return RT(0); + if (i==3) return _sf_den; + return _sf_num; +} + +template +typename Scaling_repH3::FT +Scaling_repH3:: +cartesian(int i, int j) const +{ + if(i!=j) return FT(0); + if (i==3) return FT(1); + return FT(_sf_num) / FT(_sf_den); +} + + + template < class R_ > class Translation_repH3 : public Aff_transformation_rep_baseH3 { @@ -828,11 +940,7 @@ CGAL_KERNEL_INLINE Aff_transformationH3:: Aff_transformationH3(const Scaling&, const RT& num, const RT& den) { - const RT RT0(0); - initialize_with(Aff_transformation_repH3(num, RT0, RT0, RT0, - RT0, num, RT0, RT0, - RT0, RT0, num, RT0, - den )); + initialize_with(Scaling_repH3(num, den )); } template < class R > diff --git a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h index fef888b81d2..c63f673aa32 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h @@ -273,6 +273,26 @@ returns `true`, if the transformation is reflecting. */ bool is_odd() const; +/*! +returns `true`, if the object was constructed using the tag `CGAL::Scaling`, or is the result of the composition of only such scaling transformations objects. +*/ +bool is_scaling() const; + +/*! +returns `true`, if the object was constructed using the tag `CGAL::Translation`, or is the result of the composition of only such translation transformations objects. +*/ +bool is_translation() const; + +/*! +returns `true`, if the object was constructed using the tag `CGAL::Rotation`, or is the result of the composition of only such rotation transformations objects. +*/ +bool is_rotation() const; + +/*! +returns `true`, if the object was constructed using the tag `CGAL::Reflection`, or is the result of the composition of only such reflection transformations objects. +*/ +bool is_reflection() const; + /// @} /// \name Matrix Entry Access diff --git a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h index d7cd385eaa0..57416f82201 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h @@ -200,12 +200,12 @@ returns `true`, if the transformation is reflecting. bool is_odd() const; /*! -returns `true`, if the object was constructed using the tag `CGAL::Scaling`, or is the result of the composition of only scaling transformations. +returns `true`, if the object was constructed using the tag `CGAL::Scaling`, or is the result of the composition of only such scaling transformations objects. */ bool is_scaling() const; /*! -returns `true`, if the object was constructed using the tag `CGAL::Translation`, or is the result of the composition of only translation transformations. +returns `true`, if the object was constructed using the tag `CGAL::Translation`, or is the result of the composition of only such translation transformations objects. */ bool is_translation() const; diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h index 31f104419fb..ccdde6d298c 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_2.h @@ -135,7 +135,9 @@ _test_cls_aff_transformation_2(const R& ) CGAL::Aff_transformation_2 rot3( CGAL::ROTATION, RT(3),RT(4),RT(5)); - + CGAL::Aff_transformation_2 refle(CGAL::REFLECTION, CGAL::Line_2( + CGAL::Point_2(1,3), + CGAL::Point_2(2,1))); CGAL::Aff_transformation_2 a[14]; @@ -295,6 +297,34 @@ _test_cls_aff_transformation_2(const R& ) assert( rot3.is_even() ); assert( xrefl.is_odd() ); + // translation + assert( translate.is_translation() ); + assert( ! scale11.is_translation() ); + assert( ! gtrans.is_translation() ); + assert( ! rot90.is_translation() ); + assert( ! refle.is_translation() ); + + // scaling + assert( scale11.is_scaling() ); + assert( ! translate.is_scaling() ); + assert( ! gscale.is_scaling() ); + assert( ! rot90.is_scaling() ); + assert( ! refle.is_scaling() ); + + // reflection + assert( ! scale11.is_reflection() ); + assert( ! translate.is_reflection() ); + assert( ! gscale.is_reflection() ); + assert( ! rot90.is_reflection() ); + assert( refle.is_reflection() ); + + // rotation + assert( ! scale11.is_rotation() ); + assert( ! translate.is_rotation() ); + assert( ! gscale.is_rotation() ); + assert( rot90.is_rotation() ); + assert( !refle.is_rotation() ); + // rotation assert( d0.transform( rot90 ) == d1 ); assert( d1.transform( rot90.inverse() ) == d0 ); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h index e4d53323454..3c0db87e36f 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h @@ -151,6 +151,16 @@ _test_cls_aff_transformation_3(const R& ) assert( ident.is_even() ); assert( xrefl.is_odd() ); + // translation + assert( translate.is_translation() ); + assert( ! scale11.is_translation() ); + assert( ! gtrans.is_translation() ); + + // scaling + assert( scale11.is_scaling() ); + assert( ! translate.is_scaling() ); + assert( ! gscale.is_scaling() ); + CGAL::Aff_transformation_3 a[11]; std::cout << '.'; From 4dbf38aad3b29e0909d2fdd10afa98d76bbf317d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 22 Apr 2021 21:31:28 +0100 Subject: [PATCH 13/19] Add typedefs --- .../include/CGAL/Homogeneous/Aff_transformationH3.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h index 71209b65230..52353a37ec3 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h @@ -242,6 +242,8 @@ class Scaling_repH3 : public Aff_transformation_rep_baseH3 typedef typename R::Point_3 Point_3; typedef typename R::Vector_3 Vector_3; typedef typename R::Direction_3 Direction_3; + typedef typename R::Plane_3 Plane_3; + typedef typename R::Aff_transformation_3 Aff_transformation_3; Scaling_repH3() {} From b62fffc9311ebca6e41a2ac0b4941cad56965b3d Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 23 Apr 2021 08:08:06 +0100 Subject: [PATCH 14/19] Add compose operations for scaling and translation --- .../CGAL/Homogeneous/Aff_transformationH3.h | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h index 52353a37ec3..ebed7d51499 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h @@ -93,6 +93,8 @@ public: virtual FT cartesian(int i, int j) const = 0; + + virtual Aff_transformation_3 compose(const Aff_transformation_rep_baseH3* aff) const { return Aff_transformation_3(); } }; template < class R_ > @@ -315,6 +317,12 @@ class Scaling_repH3 : public Aff_transformation_rep_baseH3 _sf_den ); } + Aff_transformation_3 compose(const Aff_transformation_rep_baseH3* aff) const + { + const Scaling_repH3* sr = dynamic_cast(aff); + return Aff_transformation_3(SCALING, _sf_num * sr->_sf_num, _sf_den * sr->_sf_den); + } + virtual RT homogeneous(int i, int j) const; virtual FT cartesian(int i, int j) const; @@ -399,6 +407,12 @@ public: virtual FT cartesian(int i, int j) const ; + Aff_transformation_3 compose(const Aff_transformation_rep_baseH3* aff) const + { + const Translation_repH3* sr = dynamic_cast(aff); + return Aff_transformation_3(TRANSLATION, tv + sr->tv); + } + friend class Aff_transformationH3; private: @@ -1047,9 +1061,16 @@ Aff_transformationH3 operator*(const Aff_transformationH3& left_argument, const Aff_transformationH3& right_argument ) { - return _general_transformation_composition( - left_argument.Ptr() ->general_form(), - right_argument.Ptr()->general_form() ); + if(left_argument.is_scaling() && right_argument.is_scaling()){ + return left_argument.Ptr()->compose(right_argument.Ptr()); + } + + if(left_argument.is_translation() && right_argument.is_translation()){ + return left_argument.Ptr()->compose(right_argument.Ptr()); + } + + return _general_transformation_composition(left_argument.Ptr() ->general_form(), + right_argument.Ptr()->general_form() ); } template < class R > From 607c3172b4e6f4c1decd2ae4bb230452b5e62d91 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 23 Apr 2021 08:19:03 +0100 Subject: [PATCH 15/19] Add typedefs (not needed for VC) --- .../include/CGAL/Homogeneous/Aff_transformationH3.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h index ebed7d51499..331d51df109 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h @@ -246,6 +246,8 @@ class Scaling_repH3 : public Aff_transformation_rep_baseH3 typedef typename R::Direction_3 Direction_3; typedef typename R::Plane_3 Plane_3; typedef typename R::Aff_transformation_3 Aff_transformation_3; + typedef Aff_transformation_rep_baseH3 Base; + typedef Scaling_repH3 Self; Scaling_repH3() {} @@ -317,9 +319,9 @@ class Scaling_repH3 : public Aff_transformation_rep_baseH3 _sf_den ); } - Aff_transformation_3 compose(const Aff_transformation_rep_baseH3* aff) const + Aff_transformation_3 compose(const Base* aff) const { - const Scaling_repH3* sr = dynamic_cast(aff); + const Self* sr = dynamic_cast(aff); return Aff_transformation_3(SCALING, _sf_num * sr->_sf_num, _sf_den * sr->_sf_den); } @@ -365,6 +367,8 @@ class Translation_repH3 : public Aff_transformation_rep_baseH3 typedef typename R_::Direction_3 Direction_3; typedef typename R_::Plane_3 Plane_3; typedef typename R_::Aff_transformation_3 Aff_transformation_3; + typedef Aff_transformation_rep_baseH3 Base; + typedef Translation_repH3 Self; public: typedef R_ R; @@ -407,9 +411,9 @@ public: virtual FT cartesian(int i, int j) const ; - Aff_transformation_3 compose(const Aff_transformation_rep_baseH3* aff) const + Aff_transformation_3 compose(const Base* aff) const { - const Translation_repH3* sr = dynamic_cast(aff); + const Self* sr = dynamic_cast(aff); return Aff_transformation_3(TRANSLATION, tv + sr->tv); } From c7e4eaca7e8ad880afa5051092449cbaa66db711 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 23 Apr 2021 11:50:26 +0100 Subject: [PATCH 16/19] fix doc --- Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h | 8 ++++---- Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h index c63f673aa32..0300279b5ee 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_2.h @@ -274,22 +274,22 @@ returns `true`, if the transformation is reflecting. bool is_odd() const; /*! -returns `true`, if the object was constructed using the tag `CGAL::Scaling`, or is the result of the composition of only such scaling transformations objects. +returns `true`, if the object was constructed using the tag `CGAL::Scaling`, or is the result of the composition of only such scaling transformation objects. */ bool is_scaling() const; /*! -returns `true`, if the object was constructed using the tag `CGAL::Translation`, or is the result of the composition of only such translation transformations objects. +returns `true`, if the object was constructed using the tag `CGAL::Translation`, or is the result of the composition of only such translation transformation objects. */ bool is_translation() const; /*! -returns `true`, if the object was constructed using the tag `CGAL::Rotation`, or is the result of the composition of only such rotation transformations objects. +returns `true`, if the object was constructed using the tag `CGAL::Rotation`, or is the result of the composition of only such rotation transformation objects. */ bool is_rotation() const; /*! -returns `true`, if the object was constructed using the tag `CGAL::Reflection`, or is the result of the composition of only such reflection transformations objects. +returns `true`, if the object was constructed using the tag `CGAL::Reflection`, or is the result of the composition of only such reflection transformation objects. */ bool is_reflection() const; diff --git a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h index 57416f82201..cfb2c924cb8 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Aff_transformation_3.h @@ -200,12 +200,12 @@ returns `true`, if the transformation is reflecting. bool is_odd() const; /*! -returns `true`, if the object was constructed using the tag `CGAL::Scaling`, or is the result of the composition of only such scaling transformations objects. +returns `true`, if the object was constructed using the tag `CGAL::Scaling`, or is the result of the composition of only such scaling transformation objects. */ bool is_scaling() const; /*! -returns `true`, if the object was constructed using the tag `CGAL::Translation`, or is the result of the composition of only such translation transformations objects. +returns `true`, if the object was constructed using the tag `CGAL::Translation`, or is the result of the composition of only such translation transformation objects. */ bool is_translation() const; From b55cef90434889c6fee7fdc6a20f34d19a33e3a7 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 27 Apr 2021 14:13:54 +0100 Subject: [PATCH 17/19] Identity is not a scaling --- .../include/CGAL/Homogeneous/Aff_transformationH3.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h index 331d51df109..efb21c829e2 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h @@ -220,12 +220,6 @@ public: is_even() const { return true; } - virtual bool - is_scaling() const - { - return true; - } - virtual RT homogeneous(int i, int j) const { return (i==j) ? RT(1) : RT(0); } From 24dd2aeca78741f65d81ee0c138f85fe690bdbeb Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 27 Apr 2021 15:27:16 +0100 Subject: [PATCH 18/19] Add to CHANGES.md --- Installation/CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 38102e7205f..5d9042fe1a7 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -25,6 +25,10 @@ Release date: June 2021 A comprehensive list of the supported file formats is available in the Stream_support package [here](https://doc.cgal.org/5.3/Stream_support/index.html#IOstreamSupportedFormats); inversely, the following [page](https://doc.cgal.org/5.3/Stream_support/IOStreamSupportedFileFormats.html) can be used to find out which CGAL data structures can be used given a specific file format. +### [2D and 3D Linear Geometry Kernel](https://doc.cgal.org/5.3/Manual/packages.html#PkgKernel23) + +- Added functions to the classes `Aff_transformation_2` and `Aff_transformation_3`, which enable to determine if they internally have a specialized representation. + ### [Quadtrees, Octrees, and Orthtrees](https://doc.cgal.org/5.3/Manual/packages.html#PkgOrthree) (new package) - This package implements a tree data structure in which each node From 69a489039b386eb1cb7d58524c4c70d876d112aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 30 Apr 2021 11:31:02 +0200 Subject: [PATCH 19/19] remove unused variable --- .../include/CGAL/Homogeneous/Aff_transformationH3.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h index efb21c829e2..f269496d79d 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Aff_transformationH3.h @@ -94,7 +94,9 @@ public: virtual FT cartesian(int i, int j) const = 0; - virtual Aff_transformation_3 compose(const Aff_transformation_rep_baseH3* aff) const { return Aff_transformation_3(); } + // this function has a default here as it is only used for "pure" scaling and translation + // and not for the other types (Identity and general case) + virtual Aff_transformation_3 compose(const Aff_transformation_rep_baseH3*) const { return Aff_transformation_3(); } }; template < class R_ >