Code-Eli  0.3.6
piecewise_capped_surface_creator_test_suite.hpp
Go to the documentation of this file.
1 /*********************************************************************************
2 * Copyright (c) 2014 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 piecewise_capped_surface_creator_test_suite_hpp
14 #define piecewise_capped_surface_creator_test_suite_hpp
15 
16 #include <cmath> // std::pow, std::exp
17 
18 #include <typeinfo> // typeid
19 #include <string> // std::string
20 #include <sstream> // std::stringstream
21 #include <iomanip> // std::setw
22 #include <limits> // std::numeric_limits
23 
24 #include "eli/constants/math.hpp"
25 
28 
32 
33 template<typename data__>
35 {
36  private:
44 
45  tolerance_type tol;
46 
47  protected:
48  void AddTests(const float &)
49  {
50  // add the tests
52  }
53  void AddTests(const double &)
54  {
55  // add the tests
57  }
58  void AddTests(const long double &)
59  {
60  // add the tests
62  }
63 
64  public:
66  {
67  AddTests(data__());
68  }
70  {
71  }
72 
73  private:
75  {
77 
78  piecewise_surface_type s_orig;
79  bool rtn_flag;
80 
81  // create cylinder with both ends open
82  {
85  typedef typename rib_data_type::curve_type rib_curve_type;
86 
87  index_type nsegs(2);
88  std::vector<rib_data_type> ribs(nsegs+1);
89  std::vector<typename skinning_creator_type::index_type> max_degree(nsegs);
90  std::vector<data_type> u(nsegs+1);
91  rib_curve_type rc1, rc2, rc3;
92  skinning_creator_type gc;
93 
94  // create the 3 ribs
95  {
97  point_type start, origin;
98 
99  // set the parameters for first circle
100  u[0]=-1;
101  start << 1, 0, 0;
102  origin << 0, 0, 0;
103 
104  // create the first circle
105  circle_creator.set(start, origin);
106  rtn_flag = circle_creator.create(rc1);
107  TEST_ASSERT(rtn_flag);
108 
109  // set the parameters for second circle
110  u[1]=1;
111  start << 1, 0, 1;
112  origin << 0, 0, 1;
113 
114  // create the second circle
115  circle_creator.set(start, origin);
116  rtn_flag = circle_creator.create(rc2);
117  TEST_ASSERT(rtn_flag);
118 
119  // set the parameters for third circle
120  u[2]=2;
121  start << 1, 0, 3;
122  origin << 0, 0, 3;
123 
124  // create the third circle
125  circle_creator.set(start, origin);
126  rtn_flag = circle_creator.create(rc3);
127  TEST_ASSERT(rtn_flag);
128  }
129 
130  // set the rib data
131  ribs[0].set_f(rc1);
132  ribs[1].set_f(rc2);
133  ribs[2].set_f(rc3);
134 
135  // set the maximum degrees of each segment
136  max_degree[0]=0;
137 
138  // create the cylinder
139  rtn_flag=gc.set_conditions(ribs, max_degree, false);
140  TEST_ASSERT(rtn_flag);
141  gc.set_u0(u[0]);
142  gc.set_segment_du(u[1]-u[0], 0);
143  gc.set_segment_du(u[2]-u[1], 1);
144  rtn_flag = gc.create(s_orig);
145  TEST_ASSERT(rtn_flag);
146 
147 // if (rtn_flag && (typeid(data_type)==typeid(float)))
148 // {
149 // std::cout.flush();
150 // eli::test::octave_start(1);
151 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
152 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
153 // eli::test::octave_print(1, ribs[2].get_f(), "rib2", true);
154 // eli::test::octave_print(1, s_orig, "surf", true);
155 // eli::test::octave_finish(1);
156 // }
157  }
158 
159  // cap umin edge
160  {
161  piecewise_surface_type s_umin_cap(s_orig);
162  capped_creator_type cc;
163 
164  rtn_flag = cc.set_conditions(s_umin_cap, 0.5, capped_creator_type::CAP_UMIN);
165  TEST_ASSERT(rtn_flag);
166 
167  rtn_flag = cc.create(s_umin_cap);
168  TEST_ASSERT(rtn_flag);
169 
170 // if (rtn_flag && (typeid(data_type)==typeid(float)))
171 // {
172 // std::cout.flush();
173 // eli::test::octave_start(1);
174 // eli::test::octave_print(1, s_umin_cap, "surf", true);
175 // eli::test::octave_finish(1);
176 // }
177  }
178 
179  // cap umax edge
180  {
181  piecewise_surface_type s_umax_cap(s_orig);
182  capped_creator_type cc;
183 
184  rtn_flag = cc.set_conditions(s_umax_cap, 0.5, capped_creator_type::CAP_UMAX);
185  TEST_ASSERT(rtn_flag);
186 
187  rtn_flag = cc.create(s_umax_cap);
188  TEST_ASSERT(rtn_flag);
189 
190 // if (rtn_flag && (typeid(data_type)==typeid(float)))
191 // {
192 // std::cout.flush();
193 // eli::test::octave_start(1);
194 // eli::test::octave_print(1, s_umax_cap, "surf", true);
195 // eli::test::octave_finish(1);
196 // }
197  }
198 
199  // cap umin & umax edge
200  {
201  piecewise_surface_type s_uminmax_cap(s_orig);
202  capped_creator_type cc;
203 
204  rtn_flag = cc.set_conditions(s_uminmax_cap, 0.5, capped_creator_type::CAP_UMIN);
205  TEST_ASSERT(rtn_flag);
206 
207  rtn_flag = cc.create(s_uminmax_cap);
208  TEST_ASSERT(rtn_flag);
209 
210  rtn_flag = cc.set_conditions(s_uminmax_cap, 0.5, capped_creator_type::CAP_UMAX);
211  TEST_ASSERT(rtn_flag);
212 
213  rtn_flag = cc.create(s_uminmax_cap);
214  TEST_ASSERT(rtn_flag);
215 
216  if (rtn_flag && (typeid(data_type)==typeid(float)))
217  {
218  std::cout.flush();
220  eli::test::octave_print(1, s_uminmax_cap, "surf", true);
222  }
223  }
224  }
225 };
226 
227 #endif
228 
eli::geom::surface::piecewise< eli::geom::surface::bezier, data__, 3 > piecewise_surface_type
Definition: piecewise_capped_surface_creator_test_suite.hpp:37
void octave_print(int figno, const eli::geom::curve::piecewise< eli::geom::curve::bezier, data__, 3 > &pc, const std::string &name="", bool show_control_points=true)
Definition: octave_helpers.hpp:62
surface_type::point_type point_type
Definition: piecewise.hpp:59
void octave_start(int figno)
Definition: octave_helpers.hpp:43
piecewise_surface_type::index_type index_type
Definition: piecewise_capped_surface_creator_test_suite.hpp:42
tolerance_type tol
Definition: piecewise_capped_surface_creator_test_suite.hpp:45
void AddTests(const float &)
Definition: piecewise_capped_surface_creator_test_suite.hpp:48
eli::geom::curve::piecewise< eli::geom::curve::bezier, data__, 3 > piecewise_curve_type
Definition: piecewise_capped_surface_creator_test_suite.hpp:38
piecewise_capped_surface_creator_test_suite()
Definition: piecewise_capped_surface_creator_test_suite.hpp:65
piecewise_surface_type::point_type point_type
Definition: piecewise_capped_surface_creator_test_suite.hpp:40
data__ data_type
Definition: piecewise.hpp:66
Definition: piecewise_capped_surface_creator_test_suite.hpp:34
Definition: piecewise.hpp:37
Definition: piecewise.hpp:244
Definition: piecewise_general_skinning_surface_creator.hpp:40
void create_flat_capped_surface_test()
Definition: piecewise_capped_surface_creator_test_suite.hpp:74
piecewise_surface_type::data_type data_type
Definition: piecewise_capped_surface_creator_test_suite.hpp:41
void octave_finish(int figno)
Definition: octave_helpers.hpp:51
~piecewise_capped_surface_creator_test_suite()
Definition: piecewise_capped_surface_creator_test_suite.hpp:69
Definition: piecewise_circle_creator.hpp:244
Definition: piecewise_connection_data.hpp:32
tol__ tolerance_type
Definition: piecewise.hpp:68
surface_type::index_type index_type
Definition: piecewise.hpp:58
void AddTests(const double &)
Definition: piecewise_capped_surface_creator_test_suite.hpp:53
virtual bool create(piecewise< bezier, data_type, dim__, tolerance_type > &pc) const
Definition: piecewise_circle_creator.hpp:110
piecewise_surface_type::tolerance_type tolerance_type
Definition: piecewise_capped_surface_creator_test_suite.hpp:43
void AddTests(const long double &)
Definition: piecewise_capped_surface_creator_test_suite.hpp:58
void set(const point_type &orig, const point_type &x, const point_type &y, const data_type &r)
Definition: piecewise_circle_creator.hpp:283
surface__< data__, dim__, tol__ > surface_type
Definition: piecewise.hpp:57
Definition: piecewise_capped_surface_creator.hpp:38
piecewise_surface_type::surface_type surface_type
Definition: piecewise_capped_surface_creator_test_suite.hpp:39