From 78f61fa8af48f2a4c98f5e3aba6f9c1c199dd512 Mon Sep 17 00:00:00 2001
From: Sergi Hernandez Juan <shernand@iri.upc.edu>
Date: Thu, 31 Dec 2020 17:47:14 +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 (removed the get_start_curvature() and get_end_curvature()
 functions). Solved a bug: the min_s parameter is not needed to compute the
 local coordinates.

---
 include/opendrive_spiral.h |  9 ++++-----
 src/opendrive_spiral.cpp   | 21 +++++++--------------
 2 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/include/opendrive_spiral.h b/include/opendrive_spiral.h
index a97e3bb..73624a0 100644
--- a/include/opendrive_spiral.h
+++ b/include/opendrive_spiral.h
@@ -5,21 +5,20 @@
 
 class COpendriveSpiral : public COpendriveGeometry
 {
+  friend class COpendriveRoadNode;
   private:
     double start_curvature;
     double end_curvature;
   protected:
+    COpendriveSpiral();
+    COpendriveSpiral(const COpendriveSpiral &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:
-    COpendriveSpiral();
-    COpendriveSpiral(double min_s, double max_s, double x, double y, double heading,double start_curv,double end_curv);
-    COpendriveSpiral(const COpendriveSpiral &object);
     virtual COpendriveGeometry *clone(void);
-    double get_start_curvature(void);
-    double get_end_curvature(void);
+    virtual void get_curvature(double &start,double &end);
     void operator=(const COpendriveSpiral &object);
     ~COpendriveSpiral();
 };
diff --git a/src/opendrive_spiral.cpp b/src/opendrive_spiral.cpp
index 6880f91..d11ac2b 100644
--- a/src/opendrive_spiral.cpp
+++ b/src/opendrive_spiral.cpp
@@ -6,12 +6,6 @@ COpendriveSpiral::COpendriveSpiral()
   this->end_curvature=0.0;
 }
 
-COpendriveSpiral::COpendriveSpiral(double min_s, double max_s, double x, double y, double heading,double start_curv,double end_curv) : COpendriveGeometry(min_s,max_s,x,y,heading)
-{
-  this->start_curvature=start_curv;
-  this->end_curvature=end_curv;
-}
-
 COpendriveSpiral::COpendriveSpiral(const COpendriveSpiral &object) : COpendriveGeometry(object)
 {
   this->start_curvature=object.start_curvature;
@@ -25,8 +19,11 @@ bool COpendriveSpiral::transform_local_pose(TOpendriveTrackPoint &track,TOpendri
 
 void COpendriveSpiral::print(std::ostream &out)
 {
+  double start_curvature,end_curvature;
+
   COpendriveGeometry::print(out);
-  out << "          start_curvature = " << this->get_start_curvature() << ", end_curvature = " << this->get_end_curvature() << std::endl;
+  this->get_curvature(start_curvature,end_curvature);
+  out << "          start_curvature = " << start_curvature << ", end_curvature = " << end_curvature << std::endl;
 }
 
 void COpendriveSpiral::load_params(const planView::geometry_type &geometry_info)
@@ -47,14 +44,10 @@ COpendriveGeometry *COpendriveSpiral::clone(void)
   return new_spiral;
 }
 
-double COpendriveSpiral::get_start_curvature(void)
-{
-  return this->start_curvature*this->scale_factor;
-}
-
-double COpendriveSpiral::get_end_curvature(void)
+void COpendriveSpiral::get_curvature(double &start,double &end)
 {
-  return this->end_curvature*this->scale_factor;
+  start=this->start_curvature*this->scale_factor;
+  end=this->end_curvature*this->scale_factor;
 }
 
 void COpendriveSpiral::operator=(const COpendriveSpiral &object)
-- 
GitLab