From 01cc9ec65351480472cb5e8fe6ba59fafc19451c Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 15 Apr 2021 13:14:42 +0100 Subject: [PATCH] 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);