From 7cca53275702b4819b86cf647bb990d3912a0226 Mon Sep 17 00:00:00 2001
From: stonneau <stevetonneau@hotmail.fr>
Date: Thu, 27 Jun 2013 21:41:18 +0200
Subject: [PATCH] more cleaning

---
 include/spline/bezier_curve.h   |  5 +--
 include/spline/cubic_function.h | 74 +++++++++++++++++----------------
 include/spline/curve_abc.h      |  7 +++-
 include/spline/exact_cubic.h    |  7 +---
 src/tests/spline_test/Main.cpp  | 24 ++++++++++-
 5 files changed, 69 insertions(+), 48 deletions(-)

diff --git a/include/spline/bezier_curve.h b/include/spline/bezier_curve.h
index 7170c00..e02e4fa 100644
--- a/include/spline/bezier_curve.h
+++ b/include/spline/bezier_curve.h
@@ -63,7 +63,6 @@ struct bezier_curve : public  curve_abc<Time, Numeric, Dim, Safe, Point>
 /* Constructors - destructors */
 
 /*Operations*/
-	public:
 	public:
 	///  \brief Evaluation of the cubic spline at time t.
 	///  \param t : the time when to evaluate the spine
@@ -100,8 +99,8 @@ struct bezier_curve : public  curve_abc<Time, Numeric, Dim, Safe, Point>
 /*Operations*/
 
 /*Helpers*/
-	virtual time_t MinBound() const{return minBound_;}
-	virtual time_t MaxBound() const{return minBound_;}
+	virtual time_t min() const{return minBound_;}
+	virtual time_t max() const{return maxBound_;}
 /*Helpers*/
 
 	public:
diff --git a/include/spline/cubic_function.h b/include/spline/cubic_function.h
index 13b6f4f..61f9c45 100644
--- a/include/spline/cubic_function.h
+++ b/include/spline/cubic_function.h
@@ -22,64 +22,66 @@
 
 namespace spline
 {
-	/// \class CubicFunction
-	/// \brief Represents a cubic spline defined on the interval 
-	/// [tBegin, tEnd]. It follows the equation
-	/// x(t) = a + b(t - t_min_) + c(t - t_min_)^2 + d(t - t_min_)^3 
-	///
-	template<typename Time= double, typename Numeric=Time, int Dim=3, bool Safe=false
-	, typename Point= Eigen::Matrix<Numeric, Dim, 1> >
-	struct cubic_function : public curve_abc<Time, Numeric, Dim, Safe, Point>
-	{
+/// \class CubicFunction
+/// \brief Represents a cubic spline defined on the interval 
+/// [tBegin, tEnd]. It follows the equation
+/// x(t) = a + b(t - t_min_) + c(t - t_min_)^2 + d(t - t_min_)^3 
+///
+template<typename Time= double, typename Numeric=Time, int Dim=3, bool Safe=false
+, typename Point= Eigen::Matrix<Numeric, Dim, 1> >
+struct cubic_function : public curve_abc<Time, Numeric, Dim, Safe, Point>
+{
 	typedef Point 	point_t;
   	typedef Time 	time_t;
   	typedef Numeric	num_t;
 /* Constructors - destructors */
 	public:
-		///\brief Constructor
-		cubic_function(point_t const& a, point_t const& b, point_t const& c, point_t const &d, time_t min, time_t max)
-    			:a_(a), b_(b), c_(c), d_(d), t_min_(min), t_max_(max)
+	///\brief Constructor
+	cubic_function(point_t const& a, point_t const& b, point_t const& c, point_t const &d, time_t min, time_t max)
+		:a_(a), b_(b), c_(c), d_(d), t_min_(min), t_max_(max)
+	{
+		if(t_min_ >= t_max_ & Safe)
 		{
-			if(t_min_ >= t_max_ & Safe)
-			{
-				std::out_of_range("TODO");
-			}
+			std::out_of_range("TODO");
 		}
+	}
 
-		///\brief Destructor
-		~cubic_function()
-		{
-			// NOTHING
-		}
+	///\brief Destructor
+	~cubic_function()
+	{
+		// NOTHING
+	}
 
 	private:
-		//cubic_function(const cubic_function&);
-		//cubic_function& operator=(const cubic_function&);
+	cubic_function(const cubic_function&);
+	cubic_function& operator=(const cubic_function&);
 /* Constructors - destructors */
 
 /*Operations*/
 	public:
-		///  \brief Evaluation of the cubic spline at time t.
-		///  \param t : the time when to evaluate the spine
-		///  \param return : the value x(t)
-		virtual point_t operator()(time_t t) const 
-		{
-		    	if((t < t_min_ || t > t_max_) && Safe){ throw std::out_of_range("TODO");}
-		    	time_t const dt (t-t_min_);
-		    	return a_+ b_ * dt + c_ * dt*dt  + d_ * dt*dt*dt;
-		}
+	///  \brief Evaluation of the cubic spline at time t.
+	///  \param t : the time when to evaluate the spine
+	///  \param return : the value x(t)
+	virtual point_t operator()(time_t t) const 
+	{
+	    	if((t < t_min_ || t > t_max_) && Safe){ throw std::out_of_range("TODO");}
+	    	time_t const dt (t-t_min_);
+	    	return a_+ b_ * dt + c_ * dt*dt  + d_ * dt*dt*dt;
+	}
 /*Operations*/
 		
 /*Helpers*/
 	public:
-		num_t virtual MinBound() const {return t_min_;}
-		num_t virtual MaxBound() const {return t_max_;}
+	///  \brief Returns the minimum time for wich curve is defined
+	num_t virtual min() const {return t_min_;}
+	///  \brief Returns the maximum time for wich curve is defined
+	num_t virtual max() const {return t_max_;}
 /*Helpers*/
 
 /*Attributes*/
 	public:
-		const point_t a_, b_, c_ ,d_;
-		const time_t t_min_, t_max_;
+	const point_t a_, b_, c_ ,d_;
+	const time_t t_min_, t_max_;
 /*Attributes*/
 	}; //class CubicFunction
 }
diff --git a/include/spline/curve_abc.h b/include/spline/curve_abc.h
index 88e02d9..da3874d 100644
--- a/include/spline/curve_abc.h
+++ b/include/spline/curve_abc.h
@@ -46,8 +46,11 @@ struct  curve_abc : std::unary_function<Time, Point>
 /*Operations*/
 
 /*Helpers*/
-	virtual time_t MinBound() const = 0;
-	virtual time_t MaxBound() const = 0;
+	public:
+	///  \brief Returns the minimum time for wich curve is defined
+	virtual time_t min() const = 0;
+	///  \brief Returns the maximum time for wich curve is defined
+	virtual time_t max() const = 0;
 /*Helpers*/
 
 	};
diff --git a/include/spline/exact_cubic.h b/include/spline/exact_cubic.h
index 13ae33a..3c2e641 100644
--- a/include/spline/exact_cubic.h
+++ b/include/spline/exact_cubic.h
@@ -27,9 +27,6 @@
 
 #include <functional>
 #include <vector>
-#include <Eigen/StdVector>
-
-#include <iostream>
 
 namespace spline
 {
@@ -162,8 +159,8 @@ struct exact_cubic : public curve_abc<Time, Numeric, Dim, Safe, Point>
 
 	/*Helpers*/
 	public:
-	num_t virtual MinBound() const{return subSplines_.front()->t_min_;}
-	num_t virtual MaxBound() const{return subSplines_.back()->t_max_;}
+	num_t virtual min() const{return subSplines_.front()->t_min_;}
+	num_t virtual max() const{return subSplines_.back()->t_max_;}
 	/*Helpers*/
 
 	/*Attributes*/
diff --git a/src/tests/spline_test/Main.cpp b/src/tests/spline_test/Main.cpp
index 601646f..7f9da71 100644
--- a/src/tests/spline_test/Main.cpp
+++ b/src/tests/spline_test/Main.cpp
@@ -110,6 +110,16 @@ void CubicFunctionTest(bool& error)
 	{
 		std::cout << "Evaluation of cubic cf2 error, 1.1 should be an out of range value\n";
 	}
+	if(cf.max() != 1)
+	{
+		error = true;
+		std::cout << "Evaluation of exactCubic error, MaxBound should be equal to 1\n";
+	}
+	if(cf.min() != 0)
+	{
+		error = true;
+		std::cout << "Evaluation of exactCubic error, MinBound should be equal to 1\n";
+	}
 }
 
 /*bezier_curve Function tests*/
@@ -180,6 +190,16 @@ void BezierCurveTest(bool& error)
 	{
 		std::cout << "Evaluation of bezier cf error, 1.1 should be an out of range value\n";
 	}
+	if(cf.max() != 1)
+	{
+		error = true;
+		std::cout << "Evaluation of exactCubic error, MaxBound should be equal to 1\n";
+	}
+	if(cf.min() != 0)
+	{
+		error = true;
+		std::cout << "Evaluation of exactCubic error, MinBound should be equal to 1\n";
+	}
 }
 
 /*Exact Cubic Function tests*/
@@ -215,12 +235,12 @@ void ExactCubicNoErrorTest(bool& error)
 	{
 		std::cout << "Evaluation of exactCubic cf error, 1.2 should be an out of range value\n";
 	}
-	if(exactCubic.MaxBound() != 1)
+	if(exactCubic.max() != 1)
 	{
 		error = true;
 		std::cout << "Evaluation of exactCubic error, MaxBound should be equal to 1\n";
 	}
-	if(exactCubic.MinBound() != 0)
+	if(exactCubic.min() != 0)
 	{
 		error = true;
 		std::cout << "Evaluation of exactCubic error, MinBound should be equal to 1\n";
-- 
GitLab