Code-Eli  0.3.6
piecewise_creator_base.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_creator_base_hpp
14 #define eli_geom_curve_piecewise_creator_base_hpp
15 
16 #include <vector>
17 
18 #include "eli/code_eli.hpp"
19 
22 
23 namespace eli
24 {
25  namespace geom
26  {
27  namespace curve
28  {
29  template<typename data__, unsigned short dim__, typename tol__>
31  {
32  public:
33  typedef data__ data_type;
34  typedef Eigen::Matrix<data_type, 1, dim__> point_type;
35  typedef typename point_type::Index index_type;
36  typedef tol__ tolerance_type;
37 
38  public:
39  piecewise_creator_base(index_type n, const data_type &tt0) : dt(n), t0(tt0)
40  {
41  for (index_type i=0; i<static_cast<index_type>(dt.size()); ++i)
42  dt[i]=1;
43  }
46 
47  index_type get_number_segments() const
48  {
49  return static_cast<index_type>(dt.size());
50  }
51  void set_number_segments(const index_type &ns)
52  {
53  dt.resize(ns);
54  for (index_type i=0; i<ns; ++i)
55  dt[i]=1;
56 
57  // tell child classes that number of segments changed
59  }
60 
61  void set_t0(const data_type &tt0) {t0=tt0;}
62  data_type get_t0() const {return t0;}
63 
64  void set_segment_dt(const data_type &dtt, const index_type &i)
65  {
66  if ((dtt>0) && (i>=0) && (i<static_cast<index_type>(dt.size())))
67  dt[i]=dtt;
68  else
69  assert(false);
70  }
71 
72 #if (defined(NDEBUG) && defined(__GNUC__))
73 # if ((__GNUC__==4) && (__GNUC_MINOR__==6))
74 # pragma GCC diagnostic push
75 # pragma GCC diagnostic ignored "-Wstrict-overflow"
76 # endif
77 #endif
78  data_type get_segment_dt(const index_type &i) const
79  {
80  if ((i<0) || (i>=static_cast<index_type>(dt.size())))
81  {
82  assert(false);
83  return static_cast<data_type>(-1);
84  }
85 
86  return dt[i];
87  }
88 #if (defined(NDEBUG) && defined(__GNUC__))
89 # if ((__GNUC__==4) && (__GNUC_MINOR__==6))
90 # pragma GCC diagnostic pop
91 # endif
92 #endif
93 
95 
96  private:
97  virtual void number_segments_changed() {};
98 
99  private:
100  std::vector<data_type> dt;
101  data_type t0;
102  };
103  }
104  }
105 }
106 #endif
piecewise_creator_base(index_type n, const data_type &tt0)
Definition: piecewise_creator_base.hpp:39
data__ data_type
Definition: piecewise_creator_base.hpp:33
Definition: math.hpp:20
void set_segment_dt(const data_type &dtt, const index_type &i)
Definition: piecewise_creator_base.hpp:64
Definition: piecewise.hpp:244
Eigen::Matrix< data_type, 1, dim__ > point_type
Definition: piecewise_creator_base.hpp:34
virtual ~piecewise_creator_base()
Definition: piecewise_creator_base.hpp:45
index_type get_number_segments() const
Definition: piecewise_creator_base.hpp:47
void set_number_segments(const index_type &ns)
Definition: piecewise_creator_base.hpp:51
virtual void number_segments_changed()
Definition: piecewise_creator_base.hpp:97
data_type get_segment_dt(const index_type &i) const
Definition: piecewise_creator_base.hpp:78
tol__ tolerance_type
Definition: piecewise_creator_base.hpp:36
piecewise_creator_base(const piecewise_creator_base< data_type, dim__, tolerance_type > &pcb)
Definition: piecewise_creator_base.hpp:44
data_type get_t0() const
Definition: piecewise_creator_base.hpp:62
point_type::Index index_type
Definition: piecewise_creator_base.hpp:35
std::vector< data_type > dt
Definition: piecewise_creator_base.hpp:97
void set_t0(const data_type &tt0)
Definition: piecewise_creator_base.hpp:61
Definition: piecewise_creator_base.hpp:30
data_type t0
Definition: piecewise_creator_base.hpp:101
virtual bool create(piecewise< bezier, data_type, dim__, tolerance_type > &pc) const =0