Commit 5b1a835e authored by JasonChmn's avatar JasonChmn Committed by Pierre Fernbach
Browse files

[Serialization] Add serialization of Dim getter for all curves

parent c61f7bc5
......@@ -440,6 +440,7 @@ namespace curves
if (version) {
// Do something depending on version ?
}
ar & boost::serialization::make_nvp("dim", dim_);
ar & boost::serialization::make_nvp("T_min", T_min_);
ar & boost::serialization::make_nvp("T_max", T_max_);
ar & boost::serialization::make_nvp("mult_T", mult_T_);
......
......@@ -43,7 +43,7 @@ namespace curves
/// \brief Empty constructor. Curve obtained this way can not perform other class functions.
///
cubic_hermite_spline()
: T_min_(0), T_max_(0)
: dim_(0), T_min_(0), T_max_(0)
{}
/// \brief Constructor.
......@@ -66,12 +66,18 @@ namespace curves
{
control_points_.push_back(*it);
}
// Set dimension according to size of points
if (control_points_.size()!=0)
{
dim_ = control_points_[0].first.size();
}
// Set time
setTime(time_control_points);
}
cubic_hermite_spline(const cubic_hermite_spline& other)
: control_points_(other.control_points_), time_control_points_(other.time_control_points_),
: dim_(other.dim_), control_points_(other.control_points_), time_control_points_(other.time_control_points_),
duration_splines_(other.duration_splines_), T_min_(other.T_min_), T_max_(other.T_max_),
size_(other.size_), degree_(other.degree_)
{}
......@@ -88,7 +94,7 @@ namespace curves
///
virtual Point operator()(const Time t) const
{
check_if_not_empty();
check_conditions();
if(Safe &! (T_min_ <= t && t <= T_max_))
{
throw std::invalid_argument("can't evaluate cubic hermite spline, out of range");
......@@ -110,7 +116,7 @@ namespace curves
///
virtual Point derivate(const Time t, const std::size_t order) const
{
check_if_not_empty();
check_conditions();
return evalCubicHermiteSpline(t, order);
}
......@@ -314,12 +320,16 @@ namespace curves
return left_id-1;
}
void check_if_not_empty() const
void check_conditions() const
{
if (control_points_.size() == 0)
{
throw std::runtime_error("Error in cubic hermite : there is no control points set / did you use empty constructor ?");
}
else if(dim_ == 0)
{
throw std::runtime_error("Error in cubic hermite : Dimension of points is zero / did you use empty constructor ?");
}
}
/// \brief compute duration of each spline.
......@@ -399,6 +409,7 @@ namespace curves
if (version) {
// Do something depending on version ?
}
ar & boost::serialization::make_nvp("dim", dim_);
ar & boost::serialization::make_nvp("control_points", control_points_);
ar & boost::serialization::make_nvp("time_control_points", time_control_points_);
ar & boost::serialization::make_nvp("duration_splines", duration_splines_);
......
......@@ -334,6 +334,7 @@ namespace curves
if (version) {
// Do something depending on version ?
}
ar & boost::serialization::make_nvp("dim", dim_);
ar & boost::serialization::make_nvp("curves", curves_);
ar & boost::serialization::make_nvp("time_curves", time_curves_);
ar & boost::serialization::make_nvp("size", size_);
......
......@@ -257,6 +257,7 @@ namespace curves
if (version) {
// Do something depending on version ?
}
ar & boost::serialization::make_nvp("dim", dim_);
ar & boost::serialization::make_nvp("coefficients", coefficients_);
ar & boost::serialization::make_nvp("dim", dim_);
ar & boost::serialization::make_nvp("degree", degree_);
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment