From 982ea9f1a6e0fe01d2b8aadc49b43d7b3e4f41ab Mon Sep 17 00:00:00 2001
From: Sergi Hernandez Juan <shernand@iri.upc.edu>
Date: Thu, 31 Dec 2020 17:48:45 +0100
Subject: [PATCH] Moved the default and copy constructors as protected. Removed
 the parameter constructor. Implemented the function to get the start and end
 curvature. Solved a bug: the min_s parameter is not needed to compute the
 local coordinates.

---
 include/opendrive_param_poly3.h |  7 ++++---
 src/opendrive_param_poly3.cpp   | 21 +++++++--------------
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/include/opendrive_param_poly3.h b/include/opendrive_param_poly3.h
index 8613d06..cbb4943 100644
--- a/include/opendrive_param_poly3.h
+++ b/include/opendrive_param_poly3.h
@@ -13,20 +13,21 @@ typedef struct
 
 class COpendriveParamPoly3 : public COpendriveGeometry
 {
+  friend class COpendriveRoadNode;
   private:
     TOpendrivePoly3Params u;
     TOpendrivePoly3Params v;
     bool normalized;
   protected:
+    COpendriveParamPoly3();
+    COpendriveParamPoly3(const COpendriveParamPoly3 &object);
     virtual bool transform_local_pose(TOpendriveTrackPoint &track,TOpendriveLocalPoint &local) const;
     virtual void print(std::ostream &out);
     virtual void load_params(const planView::geometry_type &geometry_info);
     virtual std::string get_name(void);
   public:
-    COpendriveParamPoly3();
-    COpendriveParamPoly3(double min_s, double max_s, double x, double y, double heading,TOpendrivePoly3Params &u,TOpendrivePoly3Params &v,bool normalized);
-    COpendriveParamPoly3(const COpendriveParamPoly3 &object);
     virtual COpendriveGeometry *clone(void);
+    virtual void get_curvature(double &start,double &end);
     TOpendrivePoly3Params get_u_params(void);
     TOpendrivePoly3Params get_v_params(void);
     bool is_normalized(void);
diff --git a/src/opendrive_param_poly3.cpp b/src/opendrive_param_poly3.cpp
index 12cdddb..d973be2 100644
--- a/src/opendrive_param_poly3.cpp
+++ b/src/opendrive_param_poly3.cpp
@@ -14,19 +14,6 @@ COpendriveParamPoly3::COpendriveParamPoly3()
   this->normalized=true;
 }
 
-COpendriveParamPoly3::COpendriveParamPoly3(double min_s, double max_s, double x, double y, double heading,TOpendrivePoly3Params &u,TOpendrivePoly3Params &v,bool normalized) : COpendriveGeometry(min_s,max_s,x,y,heading)
-{
-  this->u.a=u.a;
-  this->u.b=u.b;
-  this->u.c=u.c;
-  this->u.d=u.d;
-  this->v.a=v.a;
-  this->v.b=v.b;
-  this->v.c=v.c;
-  this->v.d=v.d;
-  this->normalized=normalized;
-}
-
 COpendriveParamPoly3::COpendriveParamPoly3(const COpendriveParamPoly3 &object) : COpendriveGeometry(object)
 {
   this->u.a=object.u.a;
@@ -42,7 +29,7 @@ COpendriveParamPoly3::COpendriveParamPoly3(const COpendriveParamPoly3 &object) :
 
 bool COpendriveParamPoly3::transform_local_pose(TOpendriveTrackPoint &track,TOpendriveLocalPoint &local) const
 {
-  double p = (this->normalized ? (track.s - this->min_s)/(this->max_s - this->min_s): (track.s - this->min_s));
+  double p = (this->normalized ? track.s/((this->max_s - this->min_s)/this->scale_factor):track.s);
   double p2 = p*p;
   double p3 = p2*p;
   double du = this->u.b + 2*this->u.c*p + 3*this->u.d*p2;
@@ -93,6 +80,12 @@ COpendriveGeometry *COpendriveParamPoly3::clone(void)
   return new_poly;
 }
 
+void COpendriveParamPoly3::get_curvature(double &start,double &end)
+{
+  start=0.0;
+  end=0.0;
+}
+
 TOpendrivePoly3Params COpendriveParamPoly3::get_u_params(void)
 {
   return this->u;
-- 
GitLab