Code-Eli  0.3.6
piecewise_point_creator.hpp
Go to the documentation of this file.
1 /*********************************************************************************
2 * Copyright (c) 2013 David D. Marshall <ddmarsha@calpoly.edu>
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * David D. Marshall - initial code and implementation
11 ********************************************************************************/
12 
13 #ifndef eli_geom_curve_piecewise_point_creator_hpp
14 #define eli_geom_curve_piecewise_point_creator_hpp
15 
16 #include <vector>
17 
18 #include "eli/code_eli.hpp"
19 
23 
24 namespace eli
25 {
26  namespace geom
27  {
28  namespace curve
29  {
30  template<typename data__, unsigned short dim__, typename tol__>
31  class piecewise_point_creator: public piecewise_creator_base<data__, dim__, tol__>
32  {
33  public:
39 
40  piecewise_point_creator() : piecewise_creator_base<data_type, dim__, tolerance_type>(4, 0) {}
41  piecewise_point_creator(const index_type &ns) : piecewise_creator_base<data_type, dim__, tolerance_type>(ns, 0) {}
43  : piecewise_creator_base<data_type, dim__, tolerance_type>(ppc), point(ppc.point) {}
45 
46  void set_point(const point_type &p)
47  {
48  point=p;
49  }
50  point_type get_point() const
51  {
52  return point;
53  }
54 
56  {
57  typedef piecewise<bezier, data_type, dim__, tolerance_type> piecewise_curve_type;
58  typedef typename piecewise_curve_type::curve_type curve_type;
59  typedef typename piecewise_curve_type::error_code error_code;
60 
61  pc.clear();
62 
63  curve_type c(1);
64  error_code err;
65 
66  // set the start parameter
67  pc.set_t0(this->get_t0());
68 
69  // set the control points
70  for (index_type i=0; i<this->get_number_segments(); ++i)
71  {
72  c.set_control_point(point, 0);
73  c.set_control_point(point, 1);
74  err=pc.push_back(c, this->get_segment_dt(i));
75  if (err!=piecewise_curve_type::NO_ERRORS)
76  {
77  pc.clear();
78  pc.set_t0(0);
79  return false;
80  }
81  }
82 
83  assert(pc.closed());
84  return true;
85  }
86 
87  private:
88  point_type point;
89  };
90  }
91  }
92 }
93 #endif
94 
data__ data_type
Definition: piecewise_creator_base.hpp:33
Definition: math.hpp:20
base_class_type::index_type index_type
Definition: piecewise_point_creator.hpp:37
point_type point
Definition: piecewise_point_creator.hpp:88
piecewise_point_creator(const index_type &ns)
Definition: piecewise_point_creator.hpp:41
virtual ~piecewise_point_creator()
Definition: piecewise_point_creator.hpp:44
error_code push_back(const curve_type &curve, const data_type &dt=1.0)
Definition: piecewise.hpp:688
bool closed() const
Definition: piecewise.hpp:501
Definition: piecewise.hpp:244
Eigen::Matrix< data_type, 1, dim__ > point_type
Definition: piecewise_creator_base.hpp:34
index_type get_number_segments() const
Definition: piecewise_creator_base.hpp:47
piecewise_creator_base< data__, dim__, tol__ > base_class_type
Definition: piecewise_point_creator.hpp:34
base_class_type::data_type data_type
Definition: piecewise_point_creator.hpp:35
piecewise_point_creator(const piecewise_point_creator< data_type, dim__, tolerance_type > &ppc)
Definition: piecewise_point_creator.hpp:42
base_class_type::point_type point_type
Definition: piecewise_point_creator.hpp:36
data_type get_segment_dt(const index_type &i) const
Definition: piecewise_creator_base.hpp:78
void clear()
Definition: piecewise.hpp:599
void set_point(const point_type &p)
Definition: piecewise_point_creator.hpp:46
point_type get_point() const
Definition: piecewise_point_creator.hpp:50
tol__ tolerance_type
Definition: piecewise_creator_base.hpp:36
piecewise_point_creator()
Definition: piecewise_point_creator.hpp:40
void set_t0(const data_type &t0_in)
Definition: piecewise.hpp:340
data_type get_t0() const
Definition: piecewise_creator_base.hpp:62
point_type::Index index_type
Definition: piecewise_creator_base.hpp:35
virtual bool create(piecewise< bezier, data_type, dim__, tolerance_type > &pc) const
Definition: piecewise_point_creator.hpp:55
base_class_type::tolerance_type tolerance_type
Definition: piecewise_point_creator.hpp:38
Definition: piecewise_point_creator.hpp:31
Definition: piecewise_creator_base.hpp:30