Code-Eli  0.3.6
piecewise_general_skinning_surface_creator_test_suite.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 piecewise_general_skinning_surface_creator_test_suite_suite_hpp
14 #define piecewise_general_skinning_surface_creator_test_suite_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 #include <iterator> // std::insert_iterator
24 
25 #include "eli/constants/math.hpp"
26 
29 
32 
33 #include "octave_helpers.hpp"
34 
35 template<typename data__>
37 {
38  private:
50 
51  tolerance_type tol;
52 
53  protected:
54  void AddTests(const float &)
55  {
56  // add the tests
63  }
64  void AddTests(const double &)
65  {
66  // add the tests
73  }
74  void AddTests(const long double &)
75  {
76  // add the tests
83  }
84 
85  public:
87  {
88  AddTests(data__());
89  }
91  {
92  }
93 
94  private:
96  {
97  rib_curve_type rc1, rc2, rc3;
98  point_type p1, p2, p3;
99  bool rtn_flag;
100 
101  p1 << 1, 0, 0;
102  p2 << 2, 2, 2;
103  p3 << 3, 2, 1;
104 
105  // create three rib curves
106  piecewise_line_creator_type plc(1);
107 
108  plc.set_corner(p1, 0);
109  plc.set_corner(p2, 1);
110  plc.create(rc1);
111 
112  plc.set_corner(p1, 0);
113  plc.set_corner(p3, 1);
114  plc.create(rc2);
115 
116  plc.set_corner(p3, 0);
117  plc.set_corner(p2, 1);
118  plc.create(rc3);
119 
120  // set rib
121  {
122  rib_data_type rib;
123 
124  // should start in bad state
125  rtn_flag=rib.check_state();
126  TEST_ASSERT(!rtn_flag);
127  TEST_ASSERT(rib.get_continuity()==rib_data_type::C0);
128  TEST_ASSERT(!rib.use_f());
129 
130  // add rib
131  rtn_flag=rib.set_f(rc1);
132  TEST_ASSERT(rtn_flag);
133  TEST_ASSERT(rib.get_continuity()==rib_data_type::C0);
134  TEST_ASSERT(rib.use_f());
135 
136  // unset rib
137  rtn_flag=rib.unset_f();
138  TEST_ASSERT(!rtn_flag);
139  TEST_ASSERT(!rib.use_f());
140  }
141 
142  // set rib and fp
143  {
144  rib_data_type rib;
145 
146  // should start in bad state
147  rtn_flag=rib.check_state();
148  TEST_ASSERT(!rtn_flag);
149  TEST_ASSERT(rib.get_continuity()==rib_data_type::C0);
150  TEST_ASSERT(!rib.use_f());
151  TEST_ASSERT(!rib.use_left_fp());
152  TEST_ASSERT(!rib.use_right_fp());
153 
154  // add left fp
155  rtn_flag=rib.set_left_fp(rc1);
156  TEST_ASSERT(!rtn_flag);
157  TEST_ASSERT(rib.get_left_fp()==rc1);
158  TEST_ASSERT(!rib.use_f());
159  TEST_ASSERT(rib.use_left_fp());
160  TEST_ASSERT(!rib.use_right_fp());
161 
162  // add rib
163  rtn_flag=rib.set_f(rc1);
164  TEST_ASSERT(rtn_flag);
165  TEST_ASSERT(rib.get_continuity()==rib_data_type::C0);
166  TEST_ASSERT(rib.use_f());
167  TEST_ASSERT(rib.use_left_fp());
168  TEST_ASSERT(!rib.use_right_fp());
169 
170  // add right fp
171  rtn_flag=rib.set_right_fp(rc2);
172  TEST_ASSERT(rtn_flag);
173  TEST_ASSERT(rib.get_right_fp()==rc2);
174  TEST_ASSERT(rib.use_f());
175  TEST_ASSERT(rib.use_left_fp());
176  TEST_ASSERT(rib.use_right_fp());
177 
178  // remove left fp
179  rtn_flag=rib.unset_left_fp();
180  TEST_ASSERT(rtn_flag);
181  TEST_ASSERT(rib.use_f());
182  TEST_ASSERT(!rib.use_left_fp());
183  TEST_ASSERT(rib.use_right_fp());
184 
185  // remove left fp again
186  rtn_flag=rib.unset_left_fp();
187  TEST_ASSERT(rtn_flag);
188  TEST_ASSERT(rib.use_f());
189  TEST_ASSERT(!rib.use_left_fp());
190  TEST_ASSERT(rib.use_right_fp());
191 
192  // remove right fp
193  rtn_flag=rib.unset_right_fp();
194  TEST_ASSERT(rtn_flag);
195  TEST_ASSERT(rib.use_f());
196  TEST_ASSERT(!rib.use_left_fp());
197  TEST_ASSERT(!rib.use_right_fp());
198 
199  // add fp
200  rtn_flag=rib.set_fp(rc2);
201  TEST_ASSERT(rtn_flag);
202  TEST_ASSERT(rib.get_left_fp()==rc2);
203  TEST_ASSERT(rib.get_right_fp()==rc2);
204  TEST_ASSERT(rib.use_f());
205  TEST_ASSERT(rib.use_left_fp());
206  TEST_ASSERT(rib.use_right_fp());
207 
208  // remove right fp
209  rtn_flag=rib.unset_right_fp();
210  TEST_ASSERT(rtn_flag);
211  TEST_ASSERT(rib.use_f());
212  TEST_ASSERT(rib.use_left_fp());
213  TEST_ASSERT(!rib.use_right_fp());
214  }
215 
216  // set rib, fp and fpp
217  {
218  rib_data_type rib;
219 
220  // should start in bad state
221  rtn_flag=rib.check_state();
222  TEST_ASSERT(!rtn_flag);
223  TEST_ASSERT(rib.get_continuity()==rib_data_type::C0);
224  TEST_ASSERT(!rib.use_f());
225  TEST_ASSERT(!rib.use_left_fp());
226  TEST_ASSERT(!rib.use_right_fp());
227  TEST_ASSERT(!rib.use_left_fpp());
228  TEST_ASSERT(!rib.use_right_fpp());
229 
230  // add left fpp
231  rtn_flag=rib.set_left_fpp(rc1);
232  TEST_ASSERT(!rtn_flag);
233  TEST_ASSERT(rib.get_left_fpp()==rc1);
234  TEST_ASSERT(!rib.use_f());
235  TEST_ASSERT(!rib.use_left_fp());
236  TEST_ASSERT(!rib.use_right_fp());
237  TEST_ASSERT(rib.use_left_fpp());
238  TEST_ASSERT(!rib.use_right_fpp());
239 
240  // add right fpp
241  rtn_flag=rib.set_right_fpp(rc2);
242  TEST_ASSERT(!rtn_flag);
243  TEST_ASSERT(rib.get_right_fpp()==rc2);
244  TEST_ASSERT(!rib.use_f());
245  TEST_ASSERT(!rib.use_left_fp());
246  TEST_ASSERT(!rib.use_right_fp());
247  TEST_ASSERT(rib.use_left_fpp());
248  TEST_ASSERT(rib.use_right_fpp());
249 
250  // add rib
251  rtn_flag=rib.set_f(rc1);
252  TEST_ASSERT(rtn_flag);
253  TEST_ASSERT(rib.get_continuity()==rib_data_type::C0);
254  TEST_ASSERT(rib.use_f());
255  TEST_ASSERT(!rib.use_left_fp());
256  TEST_ASSERT(!rib.use_right_fp());
257  TEST_ASSERT(rib.use_left_fpp());
258  TEST_ASSERT(rib.use_right_fpp());
259 
260  // remove right fpp
261  rtn_flag=rib.unset_right_fpp();
262  TEST_ASSERT(rtn_flag);
263  TEST_ASSERT(rib.use_f());
264  TEST_ASSERT(!rib.use_left_fp());
265  TEST_ASSERT(!rib.use_right_fp());
266  TEST_ASSERT(rib.use_left_fpp());
267  TEST_ASSERT(!rib.use_right_fp());
268 
269  // remove right fpp again
270  rtn_flag=rib.unset_right_fpp();
271  TEST_ASSERT(rtn_flag);
272  TEST_ASSERT(rib.use_f());
273  TEST_ASSERT(!rib.use_left_fp());
274  TEST_ASSERT(!rib.use_right_fp());
275  TEST_ASSERT(rib.use_left_fpp());
276  TEST_ASSERT(!rib.use_right_fp());
277 
278  // remove left fpp
279  rtn_flag=rib.unset_left_fpp();
280  TEST_ASSERT(rtn_flag);
281  TEST_ASSERT(rib.use_f());
282  TEST_ASSERT(!rib.use_left_fp());
283  TEST_ASSERT(!rib.use_right_fp());
284  TEST_ASSERT(!rib.use_left_fpp());
285  TEST_ASSERT(!rib.use_right_fpp());
286 
287  // add fp
288  rtn_flag=rib.set_fp(rc2);
289  TEST_ASSERT(rtn_flag);
290  TEST_ASSERT(rib.get_left_fp()==rc2);
291  TEST_ASSERT(rib.get_right_fp()==rc2);
292  TEST_ASSERT(rib.use_f());
293  TEST_ASSERT(rib.use_left_fp());
294  TEST_ASSERT(rib.use_right_fp());
295  TEST_ASSERT(!rib.use_left_fpp());
296  TEST_ASSERT(!rib.use_right_fpp());
297 
298  // add fpp
299  rtn_flag=rib.set_fpp(rc1);
300  TEST_ASSERT(rtn_flag);
301  TEST_ASSERT(rib.get_left_fpp()==rc1);
302  TEST_ASSERT(rib.get_right_fpp()==rc1);
303  TEST_ASSERT(rib.use_f());
304  TEST_ASSERT(rib.use_left_fp());
305  TEST_ASSERT(rib.use_right_fp());
306  TEST_ASSERT(rib.use_left_fpp());
307  TEST_ASSERT(rib.use_right_fpp());
308 
309  // remove right fp
310  rtn_flag=rib.unset_right_fp();
311  TEST_ASSERT(rtn_flag);
312  TEST_ASSERT(rib.use_f());
313  TEST_ASSERT(rib.use_left_fp());
314  TEST_ASSERT(!rib.use_right_fp());
315  TEST_ASSERT(rib.use_left_fpp());
316  TEST_ASSERT(rib.use_right_fpp());
317 
318  // remove right fpp
319  rtn_flag=rib.unset_right_fpp();
320  TEST_ASSERT(rtn_flag);
321  TEST_ASSERT(rib.use_f());
322  TEST_ASSERT(rib.use_left_fp());
323  TEST_ASSERT(!rib.use_right_fp());
324  TEST_ASSERT(rib.use_left_fpp());
325  TEST_ASSERT(!rib.use_right_fpp());
326 
327  // remove everything
328  rtn_flag=rib.unset_fpp();
329  TEST_ASSERT(rtn_flag);
330  rtn_flag=rib.unset_fp();
331  TEST_ASSERT(rtn_flag);
332  rtn_flag=rib.unset_f();
333  TEST_ASSERT(!rtn_flag);
334 
335  // add everything to right only
336  rtn_flag=rib.set_f(rc2);
337  TEST_ASSERT(rtn_flag);
338  rtn_flag=rib.set_right_fp(rc1);
339  TEST_ASSERT(rtn_flag);
340  rtn_flag=rib.set_right_fpp(rc3);
341  TEST_ASSERT(rtn_flag);
342  TEST_ASSERT(rib.use_f());
343  TEST_ASSERT(rib.get_f()==rc2);
344  TEST_ASSERT(rib.get_right_fp()==rc1);
345  TEST_ASSERT(rib.get_right_fpp()==rc3);
346  TEST_ASSERT(!rib.use_left_fp());
347  TEST_ASSERT(rib.use_right_fp());
348  TEST_ASSERT(!rib.use_left_fpp());
349  TEST_ASSERT(rib.use_right_fpp());
350  }
351 
352  // set conditions with C1
353  {
354  rib_data_type rib;
355 
356  // start with point
357  rtn_flag=rib.set_f(rc1);
358  TEST_ASSERT(rtn_flag);
359  TEST_ASSERT(rib.get_continuity()==rib_data_type::C0);
360  TEST_ASSERT(rib.use_f());
361  TEST_ASSERT(!rib.use_left_fp());
362  TEST_ASSERT(!rib.use_right_fp());
363  TEST_ASSERT(!rib.use_left_fpp());
364  TEST_ASSERT(!rib.use_right_fpp());
365 
366  // set continuity to C1
367  rtn_flag=rib.set_continuity(rib_data_type::C1);
368  TEST_ASSERT(rtn_flag);
369  TEST_ASSERT(rib.get_continuity()==rib_data_type::C1);
370  TEST_ASSERT(rib.use_f());
371  TEST_ASSERT(!rib.use_left_fp());
372  TEST_ASSERT(!rib.use_right_fp());
373  TEST_ASSERT(!rib.use_left_fpp());
374  TEST_ASSERT(!rib.use_right_fpp());
375 
376  // add left fp
377  rtn_flag=rib.set_left_fp(rc2);
378  TEST_ASSERT(rtn_flag);
379  TEST_ASSERT(rib.get_continuity()==rib_data_type::C1);
380  TEST_ASSERT(rib.use_f());
381  TEST_ASSERT(rib.use_left_fp());
382  TEST_ASSERT(rib.use_right_fp());
383  TEST_ASSERT(!rib.use_left_fpp());
384  TEST_ASSERT(!rib.use_right_fpp());
385 
386  // unset left fp
387  rtn_flag=rib.unset_left_fp();
388  TEST_ASSERT(!rtn_flag);
389  rtn_flag=rib.unset_right_fp();
390  TEST_ASSERT(rtn_flag);
391  TEST_ASSERT(rib.get_continuity()==rib_data_type::C1);
392  TEST_ASSERT(rib.use_f());
393  TEST_ASSERT(!rib.use_left_fp());
394  TEST_ASSERT(!rib.use_right_fp());
395  TEST_ASSERT(!rib.use_left_fpp());
396  TEST_ASSERT(!rib.use_right_fpp());
397 
398  // add right fp
399  rtn_flag=rib.set_right_fp(rc2);
400  TEST_ASSERT(rtn_flag);
401  TEST_ASSERT(rib.get_continuity()==rib_data_type::C1);
402  TEST_ASSERT(rib.use_f());
403  TEST_ASSERT(rib.use_left_fp());
404  TEST_ASSERT(rib.use_right_fp());
405  TEST_ASSERT(!rib.use_left_fpp());
406  TEST_ASSERT(!rib.use_right_fpp());
407 
408  // change continuity
409  rtn_flag=rib.unset_left_fp();
410  TEST_ASSERT(!rtn_flag);
411  rtn_flag=rib.set_continuity(rib_data_type::C0);
412  TEST_ASSERT(rtn_flag);
413  TEST_ASSERT(rib.get_continuity()==rib_data_type::C0);
414  TEST_ASSERT(rib.use_f());
415  TEST_ASSERT(!rib.use_left_fp());
416  TEST_ASSERT(rib.use_right_fp());
417  TEST_ASSERT(!rib.use_left_fpp());
418  TEST_ASSERT(!rib.use_right_fpp());
419 
420  // add fp
421  rtn_flag=rib.set_fp(rc1);
422  TEST_ASSERT(rtn_flag);
423  TEST_ASSERT(rib.get_continuity()==rib_data_type::C0);
424  TEST_ASSERT(rib.use_f());
425  TEST_ASSERT(rib.use_left_fp());
426  TEST_ASSERT(rib.use_right_fp());
427  TEST_ASSERT(!rib.use_left_fpp());
428  TEST_ASSERT(!rib.use_right_fpp());
429 
430  // change continuity
431  rtn_flag=rib.set_continuity(rib_data_type::C1);
432  TEST_ASSERT(rtn_flag);
433  TEST_ASSERT(rib.get_continuity()==rib_data_type::C1);
434  TEST_ASSERT(rib.use_f());
435  TEST_ASSERT(rib.use_left_fp());
436  TEST_ASSERT(rib.use_right_fp());
437  TEST_ASSERT(!rib.use_left_fpp());
438  TEST_ASSERT(!rib.use_right_fpp());
439 
440  // unset left fp
441  rtn_flag=rib.unset_left_fp();
442  TEST_ASSERT(!rtn_flag);
443  TEST_ASSERT(rib.get_continuity()==rib_data_type::C1);
444  TEST_ASSERT(rib.use_f());
445  TEST_ASSERT(!rib.use_left_fp());
446  TEST_ASSERT(rib.use_right_fp());
447  TEST_ASSERT(!rib.use_left_fpp());
448  TEST_ASSERT(!rib.use_right_fpp());
449 
450  // set left fp to change left and right value
451  rtn_flag=rib.set_left_fp(rc2);
452  TEST_ASSERT(rtn_flag);
453  TEST_ASSERT(rib.get_left_fp()==rc2);
454  TEST_ASSERT(rib.get_right_fp()==rc2);
455  TEST_ASSERT(rib.get_continuity()==rib_data_type::C1);
456  TEST_ASSERT(rib.use_f());
457  TEST_ASSERT(rib.use_left_fp());
458  TEST_ASSERT(rib.use_right_fp());
459  TEST_ASSERT(!rib.use_left_fpp());
460  TEST_ASSERT(!rib.use_right_fpp());
461 
462  // set left fp
463  rtn_flag=rib.set_left_fp(rib.get_right_fp());
464  TEST_ASSERT(rtn_flag);
465  TEST_ASSERT(rib.get_continuity()==rib_data_type::C1);
466  TEST_ASSERT(rib.use_f());
467  TEST_ASSERT(rib.use_left_fp());
468  TEST_ASSERT(rib.use_right_fp());
469  TEST_ASSERT(!rib.use_left_fpp());
470  TEST_ASSERT(!rib.use_right_fpp());
471  }
472 
473  // set point, fp, fpp and C2
474  {
475  rib_data_type rib;
476 
477  // start with point and fp
478  rtn_flag=rib.set_f(rc1);
479  TEST_ASSERT(rtn_flag);
480  rtn_flag=rib.set_fp(rc2);
481  TEST_ASSERT(rtn_flag);
482  rtn_flag=rib.set_continuity(rib_data_type::C1);
483  TEST_ASSERT(rtn_flag);
484  TEST_ASSERT(rib.get_continuity()==rib_data_type::C1);
485  TEST_ASSERT(rib.use_f());
486  TEST_ASSERT(rib.use_left_fp());
487  TEST_ASSERT(rib.use_right_fp());
488  TEST_ASSERT(!rib.use_left_fpp());
489  TEST_ASSERT(!rib.use_right_fpp());
490 
491  // set continuity to C2
492  rtn_flag=rib.set_continuity(rib_data_type::C2);
493  TEST_ASSERT(rtn_flag);
494  TEST_ASSERT(rib.get_continuity()==rib_data_type::C2);
495  TEST_ASSERT(rib.use_f());
496  TEST_ASSERT(rib.use_left_fp());
497  TEST_ASSERT(rib.use_right_fp());
498  TEST_ASSERT(!rib.use_left_fpp());
499  TEST_ASSERT(!rib.use_right_fpp());
500 
501  // unset left fp
502  rtn_flag=rib.unset_left_fp();
503  TEST_ASSERT(!rtn_flag);
504  TEST_ASSERT(rib.get_continuity()==rib_data_type::C2);
505  TEST_ASSERT(rib.use_f());
506  TEST_ASSERT(!rib.use_left_fp());
507  TEST_ASSERT(rib.use_right_fp());
508  TEST_ASSERT(!rib.use_left_fpp());
509  TEST_ASSERT(!rib.use_right_fpp());
510 
511  // unset right fp
512  rtn_flag=rib.unset_right_fp();
513  TEST_ASSERT(rtn_flag);
514  TEST_ASSERT(rib.get_continuity()==rib_data_type::C2);
515  TEST_ASSERT(rib.use_f());
516  TEST_ASSERT(!rib.use_left_fp());
517  TEST_ASSERT(!rib.use_right_fp());
518  TEST_ASSERT(!rib.use_left_fpp());
519  TEST_ASSERT(!rib.use_right_fpp());
520 
521  // set fpp
522  rtn_flag=rib.set_fpp(rc1);
523  TEST_ASSERT(rtn_flag);
524  TEST_ASSERT(rib.get_continuity()==rib_data_type::C2);
525  TEST_ASSERT(rib.use_f());
526  TEST_ASSERT(!rib.use_left_fp());
527  TEST_ASSERT(!rib.use_right_fp());
528  TEST_ASSERT(rib.use_left_fpp());
529  TEST_ASSERT(rib.use_right_fpp());
530 
531  // unset left fpp
532  rtn_flag=rib.unset_left_fpp();
533  TEST_ASSERT(!rtn_flag);
534  TEST_ASSERT(rib.get_continuity()==rib_data_type::C2);
535  TEST_ASSERT(rib.use_f());
536  TEST_ASSERT(!rib.use_left_fp());
537  TEST_ASSERT(!rib.use_right_fp());
538  TEST_ASSERT(!rib.use_left_fpp());
539  TEST_ASSERT(rib.use_right_fpp());
540 
541  // set left fpp to set both left and right values
542  rtn_flag=rib.set_left_fpp(rc3);
543  TEST_ASSERT(rtn_flag);
544  TEST_ASSERT(rib.get_continuity()==rib_data_type::C2);
545  TEST_ASSERT(rib.use_f());
546  TEST_ASSERT(!rib.use_left_fp());
547  TEST_ASSERT(!rib.use_right_fp());
548  TEST_ASSERT(rib.use_left_fpp());
549  TEST_ASSERT(rib.use_right_fpp());
550 
551  // set left fpp
552  rtn_flag=rib.set_left_fpp(rib.get_right_fpp());
553  TEST_ASSERT(rtn_flag);
554  TEST_ASSERT(rib.get_continuity()==rib_data_type::C2);
555  TEST_ASSERT(rib.use_f());
556  TEST_ASSERT(!rib.use_left_fp());
557  TEST_ASSERT(!rib.use_right_fp());
558  TEST_ASSERT(rib.use_left_fpp());
559  TEST_ASSERT(rib.use_right_fpp());
560 
561  // set fp
562  rtn_flag=rib.set_fp(rc2);
563  TEST_ASSERT(rtn_flag);
564  TEST_ASSERT(rib.get_continuity()==rib_data_type::C2);
565  TEST_ASSERT(rib.use_f());
566  TEST_ASSERT(rib.use_left_fp());
567  TEST_ASSERT(rib.use_right_fp());
568  TEST_ASSERT(rib.use_left_fpp());
569  TEST_ASSERT(rib.use_right_fpp());
570  }
571 
572  // copy constructor, equivalence and assignment operators
573  {
574  rib_data_type r1, r2, r3;
575 
576  // defaults should be the same
577  TEST_ASSERT(r1==r2);
578 
579  // manually build identical ones
580  r1.set_f(rc2);
581  r1.set_left_fp(rc1);
582  r1.set_right_fpp(rc3);
583  r2.set_f(rc2);
584  r2.set_left_fp(rc1);
585  r2.set_right_fpp(rc3);
586  TEST_ASSERT(r1==r2);
587 
588  // assignment operator
589  r3=r2;
590  TEST_ASSERT(r3==r1);
591  TEST_ASSERT(r3==r2);
592 
593  // set value for r2's fpp and then don't use it
594  r1.unset_fpp();
595  r2.unset_fpp();
596  r3.unset_fpp();
597  r2.set_fpp(rc1);
598  r2.unset_fpp();
599  TEST_ASSERT(r3==r1);
600  TEST_ASSERT(r3==r2);
601 
602  // copy constructor
603  rib_data_type r4(r3);
604  TEST_ASSERT(r4==r3);
605  }
606 
607  // test the joint interface
608  {
609  rib_data_type r1;
610  data_type s1, s2, s3, s4, s5;
611 
612  s1=static_cast<data_type>(0.25);
613  s2=static_cast<data_type>(0.35);
614  s3=static_cast<data_type>(0.45);
615  s4=static_cast<data_type>(0.55);
616  s5=static_cast<data_type>(0.70);
617  rc1.split(s1);
618  rc1.split(s4);
619  rc2.split(s2);
620  rc2.split(s3);
621  rc2.split(s4);
622  rc3.split(s3);
623  rc3.split(s5);
624 
625  r1.set_f(rc1);
626  r1.set_fp(rc2);
627  r1.set_fpp(rc3);
628 
629  // get the joints from the rib
630  std::vector<data_type> rjoints;
631  r1.get_joints(std::back_inserter(rjoints));
632 
633  TEST_ASSERT(rjoints.size()==7);
634  if (rjoints.size()==7)
635  {
636  TEST_ASSERT(tol.approximately_equal(rc1.get_t0(), rjoints[0]));
637  TEST_ASSERT(tol.approximately_equal(s1, rjoints[1]));
638  TEST_ASSERT(tol.approximately_equal(s2, rjoints[2]));
639  TEST_ASSERT(tol.approximately_equal(s3, rjoints[3]));
640  TEST_ASSERT(tol.approximately_equal(s4, rjoints[4]));
641  TEST_ASSERT(tol.approximately_equal(s5, rjoints[5]));
642  TEST_ASSERT(tol.approximately_equal(rc1.get_tmax(), rjoints[6]));
643  }
644 
645  // split the ribs at the specified locations
646  std::vector<index_type> r1degs;
647  r1.split(rjoints.begin(), rjoints.end(), std::back_inserter(r1degs));
648 
649  // check the degree
650  TEST_ASSERT(r1degs.size()==6);
651  if (r1degs.size()==6)
652  {
653  TEST_ASSERT(r1degs[0]==1);
654  TEST_ASSERT(r1degs[1]==1);
655  TEST_ASSERT(r1degs[2]==1);
656  TEST_ASSERT(r1degs[3]==1);
657  TEST_ASSERT(r1degs[4]==1);
658  TEST_ASSERT(r1degs[5]==1);
659  }
660 
661  // check the joint locations
662  rjoints.clear();
663  r1.get_f().get_parameters(std::back_inserter(rjoints));
664  TEST_ASSERT(rjoints.size()==7);
665  if (rjoints.size()==7)
666  {
667  TEST_ASSERT(tol.approximately_equal(rc1.get_t0(), rjoints[0]));
668  TEST_ASSERT(tol.approximately_equal(s1, rjoints[1]));
669  TEST_ASSERT(tol.approximately_equal(s2, rjoints[2]));
670  TEST_ASSERT(tol.approximately_equal(s3, rjoints[3]));
671  TEST_ASSERT(tol.approximately_equal(s4, rjoints[4]));
672  TEST_ASSERT(tol.approximately_equal(s5, rjoints[5]));
673  TEST_ASSERT(tol.approximately_equal(rc1.get_tmax(), rjoints[6]));
674  }
675  rjoints.clear();
676  r1.get_left_fp().get_parameters(std::back_inserter(rjoints));
677  TEST_ASSERT(rjoints.size()==7);
678  if (rjoints.size()==7)
679  {
680  TEST_ASSERT(tol.approximately_equal(rc1.get_t0(), rjoints[0]));
681  TEST_ASSERT(tol.approximately_equal(s1, rjoints[1]));
682  TEST_ASSERT(tol.approximately_equal(s2, rjoints[2]));
683  TEST_ASSERT(tol.approximately_equal(s3, rjoints[3]));
684  TEST_ASSERT(tol.approximately_equal(s4, rjoints[4]));
685  TEST_ASSERT(tol.approximately_equal(s5, rjoints[5]));
686  TEST_ASSERT(tol.approximately_equal(rc1.get_tmax(), rjoints[6]));
687  }
688  rjoints.clear();
689  r1.get_right_fp().get_parameters(std::back_inserter(rjoints));
690  TEST_ASSERT(rjoints.size()==7);
691  if (rjoints.size()==7)
692  {
693  TEST_ASSERT(tol.approximately_equal(rc1.get_t0(), rjoints[0]));
694  TEST_ASSERT(tol.approximately_equal(s1, rjoints[1]));
695  TEST_ASSERT(tol.approximately_equal(s2, rjoints[2]));
696  TEST_ASSERT(tol.approximately_equal(s3, rjoints[3]));
697  TEST_ASSERT(tol.approximately_equal(s4, rjoints[4]));
698  TEST_ASSERT(tol.approximately_equal(s5, rjoints[5]));
699  TEST_ASSERT(tol.approximately_equal(rc1.get_tmax(), rjoints[6]));
700  }
701  rjoints.clear();
702  r1.get_left_fpp().get_parameters(std::back_inserter(rjoints));
703  TEST_ASSERT(rjoints.size()==7);
704  if (rjoints.size()==7)
705  {
706  TEST_ASSERT(tol.approximately_equal(rc1.get_t0(), rjoints[0]));
707  TEST_ASSERT(tol.approximately_equal(s1, rjoints[1]));
708  TEST_ASSERT(tol.approximately_equal(s2, rjoints[2]));
709  TEST_ASSERT(tol.approximately_equal(s3, rjoints[3]));
710  TEST_ASSERT(tol.approximately_equal(s4, rjoints[4]));
711  TEST_ASSERT(tol.approximately_equal(s5, rjoints[5]));
712  TEST_ASSERT(tol.approximately_equal(rc1.get_tmax(), rjoints[6]));
713  }
714  rjoints.clear();
715  r1.get_right_fpp().get_parameters(std::back_inserter(rjoints));
716  TEST_ASSERT(rjoints.size()==7);
717  if (rjoints.size()==7)
718  {
719  TEST_ASSERT(tol.approximately_equal(rc1.get_t0(), rjoints[0]));
720  TEST_ASSERT(tol.approximately_equal(s1, rjoints[1]));
721  TEST_ASSERT(tol.approximately_equal(s2, rjoints[2]));
722  TEST_ASSERT(tol.approximately_equal(s3, rjoints[3]));
723  TEST_ASSERT(tol.approximately_equal(s4, rjoints[4]));
724  TEST_ASSERT(tol.approximately_equal(s5, rjoints[5]));
725  TEST_ASSERT(tol.approximately_equal(rc1.get_tmax(), rjoints[6]));
726  }
727  }
728  }
729 
731  {
732  // simple surface connecting 2 lines
733  {
734  index_type nsegs(1);
735  std::vector<rib_data_type> ribs(nsegs+1);
736  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
737  point_type p;
738  rib_curve_type rc1, rc2;
739  general_creator_type gc;
740  piecewise_surface_type s;
741  point_type p00, p01, p10, p11;
742  data_type u0(2), v0(1), u1(4), v1(5), v;
743  bool rtn_flag;
744 
745  // four corners of surface
746  p00 << 1, 1, 1;
747  p01 << 2, 3, 1;
748  p10 << 3, 2, 3;
749  p11 << 4, 4, 4;
750 
751  // create two rib curves
752  piecewise_line_creator_type plc(1);
753 
754  plc.set_corner(p00, 0);
755  plc.set_corner(p01, 1);
756  plc.set_t0(v0);
757  plc.set_segment_dt(v1-v0, 0);
758  plc.create(rc1);
759 
760  plc.set_corner(p10, 0);
761  plc.set_corner(p11, 1);
762  plc.set_t0(v0);
763  plc.set_segment_dt(v1-v0, 0);
764  plc.create(rc2);
765 
766  // set the rib data
767  ribs[0].set_f(rc1);
768  ribs[1].set_f(rc2);
769 
770  // set the maximum degrees of each segment
771  max_degree[0]=0;
772 
773  // create surface
774  rtn_flag=gc.set_conditions(ribs, max_degree, false);
775  TEST_ASSERT(rtn_flag);
776  gc.set_u0(u0);
777  gc.set_segment_du(u1-u0, 0);
778  rtn_flag=gc.create(s);
779  TEST_ASSERT(rtn_flag);
780 
781  // test the resulting curve
782  point_type p_test, p_ref;
783 
784  p_test=s.f(u0, v0);
785  TEST_ASSERT(tol.approximately_equal(p00, p_test));
786 // std::cout << "p=" << p00
787 // << "\tpc=" << ribs[0].get_f().f(v0)
788 // << "\tp_test=" << p_test << "\tdiff="
789 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
790  p_test=s.f(u1, v0);
791  TEST_ASSERT(tol.approximately_equal(p10, p_test));
792 // std::cout << "p=" << p10
793 // << "\tpc=" << ribs[1].get_f().f(v0)
794 // << "\tp_test=" << p_test << "\tdiff="
795 // << (p10-p_test).norm() << std::endl;
796  p_test=s.f(u0, v1);
797  TEST_ASSERT(tol.approximately_equal(p01, p_test));
798 // std::cout << "p=" << p01
799 // << "\tpc=" << ribs[0].get_f().f(v1)
800 // << "\tp_test=" << p_test << "\tdiff="
801 // << (p01-p_test).norm() << std::endl;
802  p_test=s.f(u1, v1);
803  TEST_ASSERT(tol.approximately_equal(p11, p_test));
804 // std::cout << "p=" << p11
805 // << "\tpc=" << ribs[1].get_f().f(v1)
806 // << "\tp_test=" << p_test << "\tdiff="
807 // << (p11-p_test).norm() << std::endl;
808  v=(v0+v1)/2;
809  p_test=s.f(u0, v);
810  p_ref=ribs[0].get_f().f(v);
811  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
812 // std::cout << "p=" << p_ref
813 // << "\tp_test=" << p_test << "\tdiff="
814 // << (p_ref-p_test).norm() << std::endl;
815  p_test=s.f(u1, v);
816  p_ref=ribs[1].get_f().f(v);
817  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
818 // std::cout << "p=" << p_ref
819 // << "\tp_test=" << p_test << "\tdiff="
820 // << (p_ref-p_test).norm() << std::endl;
821 
822 // if (rtn_flag && (typeid(data_type)==typeid(float)))
823 // {
824 // std::cout.flush();
825 // eli::test::octave_start(1);
826 // eli::test::octave_print(1, s, "surf", true);
827 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
828 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
829 // eli::test::octave_finish(1);
830 // }
831  }
832 
833  // surface connecting 2 lines with specified slopes
834  {
835  index_type nsegs(1);
836  std::vector<rib_data_type> ribs(nsegs+1);
837  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
838  point_type p;
839  rib_curve_type rc1, rc2, rs1, rs2;
840  general_creator_type gc;
841  piecewise_surface_type s;
842  point_type p00, p01, p10, p11, s00, s01, s10, s11;
843  data_type u0(2), v0(1), u1(4), v1(5), v;
844  bool rtn_flag;
845 
846  // four corners of surface
847  p00 << 1, 1, 1;
848  p01 << 2, 3, 1;
849  p10 << 3, 2, 3;
850  p11 << 4, 4, 4;
851  s00 << 2, 2, 0;
852  s01 << 1, 3, 2;
853  s10 << 2, 1, 0;
854  s11 << 2, 0, 1;
855 
856  // create two rib curves && two slope curves
857  piecewise_line_creator_type plc(1);
858 
859  plc.set_corner(p00, 0);
860  plc.set_corner(p01, 1);
861  plc.set_t0(v0);
862  plc.set_segment_dt(v1-v0, 0);
863  plc.create(rc1);
864 
865  plc.set_corner(s00, 0);
866  plc.set_corner(s01, 1);
867  plc.set_t0(v0);
868  plc.set_segment_dt(v1-v0, 0);
869  plc.create(rs1);
870 
871  plc.set_corner(p10, 0);
872  plc.set_corner(p11, 1);
873  plc.set_t0(v0);
874  plc.set_segment_dt(v1-v0, 0);
875  plc.create(rc2);
876 
877  plc.set_corner(s10, 0);
878  plc.set_corner(s11, 1);
879  plc.set_t0(v0);
880  plc.set_segment_dt(v1-v0, 0);
881  plc.create(rs2);
882 
883  // set the rib data
884  ribs[0].set_f(rc1);
885  ribs[0].set_right_fp(rs1);
886  ribs[1].set_f(rc2);
887  ribs[1].set_left_fp(rs2);
888 
889  // set the maximum degrees of each segment
890  max_degree[0]=0;
891 
892  // create surface
893  rtn_flag=gc.set_conditions(ribs, max_degree, false);
894  TEST_ASSERT(rtn_flag);
895  gc.set_u0(u0);
896  gc.set_segment_du(u1-u0, 0);
897  rtn_flag=gc.create(s);
898  TEST_ASSERT(rtn_flag);
899 
900  // test the resulting curve
901  point_type p_test, p_ref;
902 
903  p_test=s.f(u0, v0);
904  TEST_ASSERT(tol.approximately_equal(p00, p_test));
905 // std::cout << "p=" << p00
906 // << "\tpc=" << ribs[0].get_f().f(v0)
907 // << "\tp_test=" << p_test << "\tdiff="
908 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
909  p_test=s.f(u1, v0);
910  TEST_ASSERT(tol.approximately_equal(p10, p_test));
911 // std::cout << "p=" << p10
912 // << "\tpc=" << ribs[1].get_f().f(v0)
913 // << "\tp_test=" << p_test << "\tdiff="
914 // << (p10-p_test).norm() << std::endl;
915  p_test=s.f(u0, v1);
916  TEST_ASSERT(tol.approximately_equal(p01, p_test));
917 // std::cout << "p=" << p01
918 // << "\tpc=" << ribs[0].get_f().f(v1)
919 // << "\tp_test=" << p_test << "\tdiff="
920 // << (p01-p_test).norm() << std::endl;
921  p_test=s.f(u1, v1);
922  TEST_ASSERT(tol.approximately_equal(p11, p_test));
923 // std::cout << "p=" << p11
924 // << "\tpc=" << ribs[1].get_f().f(v1)
925 // << "\tp_test=" << p_test << "\tdiff="
926 // << (p11-p_test).norm() << std::endl;
927  v=(v0+v1)/2;
928  p_test=s.f(u0, v);
929  p_ref=ribs[0].get_f().f(v);
930  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
931 // std::cout << "p=" << p_ref
932 // << "\tp_test=" << p_test << "\tdiff="
933 // << (p_ref-p_test).norm() << std::endl;
934  p_test=s.f(u1, v);
935  p_ref=ribs[1].get_f().f(v);
936  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
937 // std::cout << "p=" << p_ref
938 // << "\tp_test=" << p_test << "\tdiff="
939 // << (p_ref-p_test).norm() << std::endl;
940  p_test=s.f_u(u0, v);
941  p_ref=ribs[0].get_right_fp().f(v);
942  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
943 // std::cout << "p=" << p_ref
944 // << "\tp_test=" << p_test << "\tdiff="
945 // << (p_ref-p_test).norm() << std::endl;
946  p_test=s.f_u(u1, v);
947  p_ref=ribs[1].get_left_fp().f(v);
948  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
949 // std::cout << "p=" << p_ref
950 // << "\tp_test=" << p_test << "\tdiff="
951 // << (p_ref-p_test).norm() << std::endl;
952 
953 // if (rtn_flag && (typeid(data_type)==typeid(float)))
954 // {
955 // std::cout.flush();
956 // eli::test::octave_start(1);
957 // eli::test::octave_print(1, s, "surf", false);
958 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
959 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
960 // eli::test::octave_print(1, ribs[0].get_f(), ribs[0].get_right_fp(), "rve0");
961 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_left_fp(), "lve1");
962 // eli::test::octave_finish(1);
963 // }
964  }
965 
966  // surface connecting 2 lines with specified 1st and 2nd derivatives
967  {
968  index_type nsegs(1);
969  std::vector<rib_data_type> ribs(nsegs+1);
970  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
971  point_type p;
972  rib_curve_type rc1, rc2, rs1, rs2, ra1, ra2;
973  general_creator_type gc;
974  piecewise_surface_type s;
975  point_type p00, p01, p10, p11, s00, s01, s10, s11, a00, a01, a10, a11;
976  data_type u0(2), v0(1), u1(4), v1(5), v;
977  bool rtn_flag;
978 
979  // four corners of surface
980  p00 << 1, 1, 1;
981  p01 << 2, 3, 1;
982  p10 << 3, 2, 3;
983  p11 << 4, 4, 4;
984  s00 << 2, 2, 0;
985  s01 << 1, 3, 2;
986  s10 << 2, 1, 0;
987  s11 << 2, 0, 1;
988  a00 << 0, 1, 0;
989  a01 << 1, 0, 1;
990  a10 << 1, 0, 1;
991  a11 << 0, 1, 0;
992 
993  // create two rib curves && two slope curves
994  piecewise_line_creator_type plc(1);
995 
996  plc.set_corner(p00, 0);
997  plc.set_corner(p01, 1);
998  plc.set_t0(v0);
999  plc.set_segment_dt(v1-v0, 0);
1000  plc.create(rc1);
1001 
1002  plc.set_corner(s00, 0);
1003  plc.set_corner(s01, 1);
1004  plc.set_t0(v0);
1005  plc.set_segment_dt(v1-v0, 0);
1006  plc.create(rs1);
1007 
1008  plc.set_corner(a00, 0);
1009  plc.set_corner(a01, 1);
1010  plc.set_t0(v0);
1011  plc.set_segment_dt(v1-v0, 0);
1012  plc.create(ra1);
1013 
1014  plc.set_corner(p10, 0);
1015  plc.set_corner(p11, 1);
1016  plc.set_t0(v0);
1017  plc.set_segment_dt(v1-v0, 0);
1018  plc.create(rc2);
1019 
1020  plc.set_corner(s10, 0);
1021  plc.set_corner(s11, 1);
1022  plc.set_t0(v0);
1023  plc.set_segment_dt(v1-v0, 0);
1024  plc.create(rs2);
1025 
1026  plc.set_corner(a10, 0);
1027  plc.set_corner(a11, 1);
1028  plc.set_t0(v0);
1029  plc.set_segment_dt(v1-v0, 0);
1030  plc.create(ra2);
1031 
1032  // set the rib data
1033  ribs[0].set_f(rc1);
1034  ribs[0].set_right_fp(rs1);
1035  ribs[0].set_right_fpp(ra1);
1036  ribs[1].set_f(rc2);
1037  ribs[1].set_left_fp(rs2);
1038  ribs[1].set_left_fpp(ra2);
1039 
1040  // set the maximum degrees of each segment
1041  max_degree[0]=0;
1042 
1043  // create surface
1044  rtn_flag=gc.set_conditions(ribs, max_degree, false);
1045  TEST_ASSERT(rtn_flag);
1046  gc.set_u0(u0);
1047  gc.set_segment_du(u1-u0, 0);
1048  rtn_flag=gc.create(s);
1049  TEST_ASSERT(rtn_flag);
1050 
1051  // test the resulting curve
1052  point_type p_test, p_ref;
1053 
1054  p_test=s.f(u0, v0);
1055  TEST_ASSERT(tol.approximately_equal(p00, p_test));
1056 // std::cout << "p=" << p00
1057 // << "\tpc=" << ribs[0].get_f().f(v0)
1058 // << "\tp_test=" << p_test << "\tdiff="
1059 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
1060  p_test=s.f(u1, v0);
1061  TEST_ASSERT(tol.approximately_equal(p10, p_test));
1062 // std::cout << "p=" << p10
1063 // << "\tpc=" << ribs[1].get_f().f(v0)
1064 // << "\tp_test=" << p_test << "\tdiff="
1065 // << (p10-p_test).norm() << std::endl;
1066  p_test=s.f(u0, v1);
1067  TEST_ASSERT(tol.approximately_equal(p01, p_test));
1068 // std::cout << "p=" << p01
1069 // << "\tpc=" << ribs[0].get_f().f(v1)
1070 // << "\tp_test=" << p_test << "\tdiff="
1071 // << (p01-p_test).norm() << std::endl;
1072  p_test=s.f(u1, v1);
1073  TEST_ASSERT(tol.approximately_equal(p11, p_test));
1074 // std::cout << "p=" << p11
1075 // << "\tpc=" << ribs[1].get_f().f(v1)
1076 // << "\tp_test=" << p_test << "\tdiff="
1077 // << (p11-p_test).norm() << std::endl;
1078  v=(v0+v1)/2;
1079  p_test=s.f(u0, v);
1080  p_ref=ribs[0].get_f().f(v);
1081  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1082 // std::cout << "p=" << p_ref
1083 // << "\tp_test=" << p_test << "\tdiff="
1084 // << (p_ref-p_test).norm() << std::endl;
1085  p_test=s.f(u1, v);
1086  p_ref=ribs[1].get_f().f(v);
1087  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1088 // std::cout << "p=" << p_ref
1089 // << "\tp_test=" << p_test << "\tdiff="
1090 // << (p_ref-p_test).norm() << std::endl;
1091  p_test=s.f_u(u0, v);
1092  p_ref=ribs[0].get_right_fp().f(v);
1093  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1094 // std::cout << "p=" << p_ref
1095 // << "\tp_test=" << p_test << "\tdiff="
1096 // << (p_ref-p_test).norm() << std::endl;
1097  p_test=s.f_uu(u0, v);
1098  p_ref=ribs[0].get_right_fpp().f(v);
1099  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1100 // std::cout << "p=" << p_ref
1101 // << "\tp_test=" << p_test << "\tdiff="
1102 // << (p_ref-p_test).norm() << std::endl;
1103  p_test=s.f_u(u1, v);
1104  p_ref=ribs[1].get_left_fp().f(v);
1105  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1106 // std::cout << "p=" << p_ref
1107 // << "\tp_test=" << p_test << "\tdiff="
1108 // << (p_ref-p_test).norm() << std::endl;
1109  p_test=s.f_uu(u1, v);
1110  p_ref=ribs[1].get_left_fpp().f(v);
1111  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1112 // std::cout << "p=" << p_ref
1113 // << "\tp_test=" << p_test << "\tdiff="
1114 // << (p_ref-p_test).norm() << std::endl;
1115 
1116 // if (rtn_flag && (typeid(data_type)==typeid(float)))
1117 // {
1118 // std::cout.flush();
1119 // eli::test::octave_start(1);
1120 // eli::test::octave_print(1, s, "surf", false);
1121 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
1122 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
1123 // eli::test::octave_print(1, ribs[0].get_f(), ribs[0].get_right_fp(), "rve0");
1124 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_left_fp(), "lve1");
1125 // eli::test::octave_finish(1);
1126 // }
1127  }
1128 
1129  // surface connecting 2 cubic curves with specified 1st and 2nd derivatives
1130  {
1131  index_type nsegs(1);
1132  std::vector<rib_data_type> ribs(nsegs+1);
1133  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1134  point_type p;
1135  rib_curve_type rc1, rc2, rs1, rs2, ra1, ra2;
1136  general_creator_type gc;
1137  piecewise_surface_type s;
1138  point_type p00, p01, p10, p11, s00, s01, s10, s11, a00, a01, a10, a11;
1139  data_type u0(2), v0(1), u1(4), v1(5), v;
1140  bool rtn_flag;
1141 
1142  // four corners of surface
1143  p00 << 1, 1, 1;
1144  p01 << 2, 3, 1;
1145  p10 << 3, 2, 3;
1146  p11 << 4, 4, 4;
1147  s00 << 2, 2, 0;
1148  s01 << 1, 3, 2;
1149  s10 << 2, 1, 0;
1150  s11 << 2, 0, 1;
1151  a00 << 0, 1, 0;
1152  a01 << 1, 0, 1;
1153  a10 << 1, 0, 1;
1154  a11 << 0, 1, 0;
1155 
1156  // create two rib curves && two slope curves
1157  typename rib_curve_type::curve_type curve(3);
1158  typename rib_curve_type::control_point_type cp[4];
1159 
1160  // manually create cubic curves for ribs
1161  cp[0]=p00;
1162  cp[1] << 0, 2, 1;
1163  cp[2] << 1, 3, 1;
1164  cp[3]=p01;
1165  for (index_type i=0; i<4; ++i)
1166  {
1167  curve.set_control_point(cp[i], i);
1168  }
1169  rc1.push_front(curve, v1-v0);
1170  rc1.set_t0(v0);
1171 
1172  cp[0]=p10;
1173  cp[1] << 1, 2, 3;
1174  cp[2] << 2, 3, 4;
1175  cp[3]=p11;
1176  for (index_type i=0; i<4; ++i)
1177  {
1178  curve.set_control_point(cp[i], i);
1179  }
1180  rc2.push_front(curve, v1-v0);
1181  rc2.set_t0(v0);
1182 
1183  // create 1st and 2nd derivative curves
1184  piecewise_line_creator_type plc(1);
1185 
1186  plc.set_corner(s00, 0);
1187  plc.set_corner(s01, 1);
1188  plc.set_t0(v0);
1189  plc.set_segment_dt(v1-v0, 0);
1190  plc.create(rs1);
1191 
1192  plc.set_corner(a00, 0);
1193  plc.set_corner(a01, 1);
1194  plc.set_t0(v0);
1195  plc.set_segment_dt(v1-v0, 0);
1196  plc.create(ra1);
1197 
1198  plc.set_corner(s10, 0);
1199  plc.set_corner(s11, 1);
1200  plc.set_t0(v0);
1201  plc.set_segment_dt(v1-v0, 0);
1202  plc.create(rs2);
1203 
1204  plc.set_corner(a10, 0);
1205  plc.set_corner(a11, 1);
1206  plc.set_t0(v0);
1207  plc.set_segment_dt(v1-v0, 0);
1208  plc.create(ra2);
1209 
1210  // set the rib data
1211  ribs[0].set_f(rc1);
1212  ribs[0].set_right_fp(rs1);
1213  ribs[0].set_right_fpp(ra1);
1214  ribs[1].set_f(rc2);
1215  ribs[1].set_left_fp(rs2);
1216  ribs[1].set_left_fpp(ra2);
1217 
1218  // set the maximum degrees of each segment
1219  max_degree[0]=0;
1220 
1221  // create surface
1222  rtn_flag=gc.set_conditions(ribs, max_degree, false);
1223  TEST_ASSERT(rtn_flag);
1224  gc.set_u0(u0);
1225  gc.set_segment_du(u1-u0, 0);
1226  rtn_flag=gc.create(s);
1227  TEST_ASSERT(rtn_flag);
1228 
1229  // test the resulting curve
1230  point_type p_test, p_ref;
1231 
1232  p_test=s.f(u0, v0);
1233  TEST_ASSERT(tol.approximately_equal(p00, p_test));
1234 // std::cout << "p=" << p00
1235 // << "\tpc=" << ribs[0].get_f().f(v0)
1236 // << "\tp_test=" << p_test << "\tdiff="
1237 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
1238  p_test=s.f(u1, v0);
1239  TEST_ASSERT(tol.approximately_equal(p10, p_test));
1240 // std::cout << "p=" << p10
1241 // << "\tpc=" << ribs[1].get_f().f(v0)
1242 // << "\tp_test=" << p_test << "\tdiff="
1243 // << (p10-p_test).norm() << std::endl;
1244  p_test=s.f(u0, v1);
1245  TEST_ASSERT(tol.approximately_equal(p01, p_test));
1246 // std::cout << "p=" << p01
1247 // << "\tpc=" << ribs[0].get_f().f(v1)
1248 // << "\tp_test=" << p_test << "\tdiff="
1249 // << (p01-p_test).norm() << std::endl;
1250  p_test=s.f(u1, v1);
1251  TEST_ASSERT(tol.approximately_equal(p11, p_test));
1252 // std::cout << "p=" << p11
1253 // << "\tpc=" << ribs[1].get_f().f(v1)
1254 // << "\tp_test=" << p_test << "\tdiff="
1255 // << (p11-p_test).norm() << std::endl;
1256  v=(v0+v1)/2;
1257  p_test=s.f(u0, v);
1258  p_ref=ribs[0].get_f().f(v);
1259  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1260 // std::cout << "p=" << p_ref
1261 // << "\tp_test=" << p_test << "\tdiff="
1262 // << (p_ref-p_test).norm() << std::endl;
1263  p_test=s.f(u1, v);
1264  p_ref=ribs[1].get_f().f(v);
1265  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1266 // std::cout << "p=" << p_ref
1267 // << "\tp_test=" << p_test << "\tdiff="
1268 // << (p_ref-p_test).norm() << std::endl;
1269  p_test=s.f_u(u0, v);
1270  p_ref=ribs[0].get_right_fp().f(v);
1271  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1272 // std::cout << "p=" << p_ref
1273 // << "\tp_test=" << p_test << "\tdiff="
1274 // << (p_ref-p_test).norm() << std::endl;
1275  p_test=s.f_uu(u0, v);
1276  p_ref=ribs[0].get_right_fpp().f(v);
1277  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1278 // std::cout << "p=" << p_ref
1279 // << "\tp_test=" << p_test << "\tdiff="
1280 // << (p_ref-p_test).norm() << std::endl;
1281  p_test=s.f_u(u1, v);
1282  p_ref=ribs[1].get_left_fp().f(v);
1283  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1284 // std::cout << "p=" << p_ref
1285 // << "\tp_test=" << p_test << "\tdiff="
1286 // << (p_ref-p_test).norm() << std::endl;
1287  p_test=s.f_uu(u1, v);
1288  p_ref=ribs[1].get_left_fpp().f(v);
1289  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1290 // std::cout << "p=" << p_ref
1291 // << "\tp_test=" << p_test << "\tdiff="
1292 // << (p_ref-p_test).norm() << std::endl;
1293 
1294 // if (rtn_flag && (typeid(data_type)==typeid(float)))
1295 // {
1296 // std::cout.flush();
1297 // eli::test::octave_start(1);
1298 // eli::test::octave_print(1, s, "surf", false);
1299 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
1300 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
1301 // eli::test::octave_print(1, ribs[0].get_f(), ribs[0].get_right_fp(), "rve0");
1302 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_left_fp(), "lve1");
1303 // eli::test::octave_finish(1);
1304 // }
1305  }
1306 
1307  // surface connecting 1 line and 1 cubic curves with specified 1st and 2nd derivatives
1308  {
1309  index_type nsegs(1);
1310  std::vector<rib_data_type> ribs(nsegs+1);
1311  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1312  point_type p;
1313  rib_curve_type rc1, rc2, rs1, rs2, ra1, ra2;
1314  general_creator_type gc;
1315  piecewise_surface_type s;
1316  point_type p00, p01, p10, p11, s00, s01, s10, s11, a00, a01, a10, a11;
1317  data_type u0(2), v0(1), u1(4), v1(5), v;
1318  bool rtn_flag;
1319 
1320  // four corners of surface
1321  p00 << 1, 1, 1;
1322  p01 << 2, 3, 1;
1323  p10 << 3, 2, 3;
1324  p11 << 4, 4, 4;
1325  s00 << 2, 2, 0;
1326  s01 << 1, 3, 2;
1327  s10 << 2, 1, 0;
1328  s11 << 2, 0, 1;
1329  a00 << 0, 1, 0;
1330  a01 << 1, 0, 1;
1331  a10 << 1, 0, 1;
1332  a11 << 0, 1, 0;
1333 
1334  // create two rib curves && two slope curves
1335  typename rib_curve_type::curve_type curve(3);
1336  typename rib_curve_type::control_point_type cp[4];
1337 
1338  // manually create cubic curve for rib
1339  cp[0]=p00;
1340  cp[1] << 0, 2, 1;
1341  cp[2] << 1, 3, 1;
1342  cp[3]=p01;
1343  for (index_type i=0; i<4; ++i)
1344  {
1345  curve.set_control_point(cp[i], i);
1346  }
1347  rc1.push_front(curve, v1-v0);
1348  rc1.set_t0(v0);
1349 
1350  // create 1st and 2nd derivative curves
1351  piecewise_line_creator_type plc(1);
1352 
1353  plc.set_corner(s00, 0);
1354  plc.set_corner(s01, 1);
1355  plc.set_t0(v0);
1356  plc.set_segment_dt(v1-v0, 0);
1357  plc.create(rs1);
1358 
1359  plc.set_corner(a00, 0);
1360  plc.set_corner(a01, 1);
1361  plc.set_t0(v0);
1362  plc.set_segment_dt(v1-v0, 0);
1363  plc.create(ra1);
1364 
1365  plc.set_corner(p10, 0);
1366  plc.set_corner(p11, 1);
1367  plc.set_t0(v0);
1368  plc.set_segment_dt(v1-v0, 0);
1369  plc.create(rc2);
1370 
1371  plc.set_corner(s10, 0);
1372  plc.set_corner(s11, 1);
1373  plc.set_t0(v0);
1374  plc.set_segment_dt(v1-v0, 0);
1375  plc.create(rs2);
1376 
1377  plc.set_corner(a10, 0);
1378  plc.set_corner(a11, 1);
1379  plc.set_t0(v0);
1380  plc.set_segment_dt(v1-v0, 0);
1381  plc.create(ra2);
1382 
1383  // set the rib data
1384  ribs[0].set_f(rc1);
1385  ribs[0].set_right_fp(rs1);
1386  ribs[0].set_right_fpp(ra1);
1387  ribs[1].set_f(rc2);
1388  ribs[1].set_left_fp(rs2);
1389  ribs[1].set_left_fpp(ra2);
1390 
1391  // set the maximum degrees of each segment
1392  max_degree[0]=0;
1393 
1394  // create surface
1395  rtn_flag=gc.set_conditions(ribs, max_degree, false);
1396  TEST_ASSERT(rtn_flag);
1397  gc.set_u0(u0);
1398  gc.set_segment_du(u1-u0, 0);
1399  rtn_flag=gc.create(s);
1400  TEST_ASSERT(rtn_flag);
1401 
1402  // test the resulting curve
1403  point_type p_test, p_ref;
1404 
1405  p_test=s.f(u0, v0);
1406  TEST_ASSERT(tol.approximately_equal(p00, p_test));
1407 // std::cout << "p=" << p00
1408 // << "\tpc=" << ribs[0].get_f().f(v0)
1409 // << "\tp_test=" << p_test << "\tdiff="
1410 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
1411  p_test=s.f(u1, v0);
1412  TEST_ASSERT(tol.approximately_equal(p10, p_test));
1413 // std::cout << "p=" << p10
1414 // << "\tpc=" << ribs[1].get_f().f(v0)
1415 // << "\tp_test=" << p_test << "\tdiff="
1416 // << (p10-p_test).norm() << std::endl;
1417  p_test=s.f(u0, v1);
1418  TEST_ASSERT(tol.approximately_equal(p01, p_test));
1419 // std::cout << "p=" << p01
1420 // << "\tpc=" << ribs[0].get_f().f(v1)
1421 // << "\tp_test=" << p_test << "\tdiff="
1422 // << (p01-p_test).norm() << std::endl;
1423  p_test=s.f(u1, v1);
1424  TEST_ASSERT(tol.approximately_equal(p11, p_test));
1425 // std::cout << "p=" << p11
1426 // << "\tpc=" << ribs[1].get_f().f(v1)
1427 // << "\tp_test=" << p_test << "\tdiff="
1428 // << (p11-p_test).norm() << std::endl;
1429  v=(v0+v1)/2;
1430  p_test=s.f(u0, v);
1431  p_ref=ribs[0].get_f().f(v);
1432  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1433 // std::cout << "p=" << p_ref
1434 // << "\tp_test=" << p_test << "\tdiff="
1435 // << (p_ref-p_test).norm() << std::endl;
1436  p_test=s.f(u1, v);
1437  p_ref=ribs[1].get_f().f(v);
1438  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1439 // std::cout << "p=" << p_ref
1440 // << "\tp_test=" << p_test << "\tdiff="
1441 // << (p_ref-p_test).norm() << std::endl;
1442  p_test=s.f_u(u0, v);
1443  p_ref=ribs[0].get_right_fp().f(v);
1444  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1445 // std::cout << "p=" << p_ref
1446 // << "\tp_test=" << p_test << "\tdiff="
1447 // << (p_ref-p_test).norm() << std::endl;
1448  p_test=s.f_uu(u0, v);
1449  p_ref=ribs[0].get_right_fpp().f(v);
1450  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1451 // std::cout << "p=" << p_ref
1452 // << "\tp_test=" << p_test << "\tdiff="
1453 // << (p_ref-p_test).norm() << std::endl;
1454  p_test=s.f_u(u1, v);
1455  p_ref=ribs[1].get_left_fp().f(v);
1456  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1457 // std::cout << "p=" << p_ref
1458 // << "\tp_test=" << p_test << "\tdiff="
1459 // << (p_ref-p_test).norm() << std::endl;
1460  p_test=s.f_uu(u1, v);
1461  p_ref=ribs[1].get_left_fpp().f(v);
1462  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1463 // std::cout << "p=" << p_ref
1464 // << "\tp_test=" << p_test << "\tdiff="
1465 // << (p_ref-p_test).norm() << std::endl;
1466 
1467 // if (rtn_flag && (typeid(data_type)==typeid(float)))
1468 // {
1469 // std::cout.flush();
1470 // eli::test::octave_start(1);
1471 // eli::test::octave_print(1, s, "surf", true);
1472 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
1473 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
1474 // eli::test::octave_print(1, ribs[0].get_f(), ribs[0].get_right_fp(), "rve0");
1475 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_left_fp(), "lve1");
1476 // eli::test::octave_finish(1);
1477 // }
1478  }
1479  }
1480 
1482  {
1483  // surface connecting ribs made of 2 line segments each
1484  {
1485  index_type nsegs(1);
1486  std::vector<rib_data_type> ribs(nsegs+1);
1487  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1488  point_type p;
1489  rib_curve_type rc1, rc2;
1490  general_creator_type gc;
1491  piecewise_surface_type s;
1492  point_type p00, p01, p10, p11;
1493  data_type u0(2), v0(1), u1(4), v1(5), v;
1494  bool rtn_flag;
1495 
1496  // four corners of surface
1497  p00 << 1, 1, 1;
1498  p01 << 2, 3, 1;
1499  p10 << 3, 2, 3;
1500  p11 << 4, 4, 4;
1501 
1502  // create two rib curves
1503  piecewise_line_creator_type plc(1);
1504 
1505  plc.set_corner(p00, 0);
1506  plc.set_corner(p01, 1);
1507  plc.set_t0(v0);
1508  plc.set_segment_dt(v1-v0, 0);
1509  plc.create(rc1);
1510  rc1.split((v0+v1)/2);
1511 
1512  plc.set_corner(p10, 0);
1513  plc.set_corner(p11, 1);
1514  plc.set_t0(v0);
1515  plc.set_segment_dt(v1-v0, 0);
1516  plc.create(rc2);
1517  rc2.split((v0+v1)/2);
1518 
1519  // set the rib data
1520  ribs[0].set_f(rc1);
1521  ribs[1].set_f(rc2);
1522 
1523  // set the maximum degrees of each segment
1524  max_degree[0]=0;
1525 
1526  // create surface
1527  rtn_flag=gc.set_conditions(ribs, max_degree, false);
1528  TEST_ASSERT(rtn_flag);
1529  gc.set_u0(u0);
1530  gc.set_segment_du(u1-u0, 0);
1531  rtn_flag=gc.create(s);
1532  TEST_ASSERT(rtn_flag);
1533 
1534  // test the resulting curve
1535  point_type p_test, p_ref;
1536 
1537  p_test=s.f(u0, v0);
1538  TEST_ASSERT(tol.approximately_equal(p00, p_test));
1539 // std::cout << "p=" << p00
1540 // << "\tpc=" << ribs[0].get_f().f(v0)
1541 // << "\tp_test=" << p_test << "\tdiff="
1542 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
1543  p_test=s.f(u1, v0);
1544  TEST_ASSERT(tol.approximately_equal(p10, p_test));
1545 // std::cout << "p=" << p10
1546 // << "\tpc=" << ribs[1].get_f().f(v0)
1547 // << "\tp_test=" << p_test << "\tdiff="
1548 // << (p10-p_test).norm() << std::endl;
1549  p_test=s.f(u0, v1);
1550  TEST_ASSERT(tol.approximately_equal(p01, p_test));
1551 // std::cout << "p=" << p01
1552 // << "\tpc=" << ribs[0].get_f().f(v1)
1553 // << "\tp_test=" << p_test << "\tdiff="
1554 // << (p01-p_test).norm() << std::endl;
1555  p_test=s.f(u1, v1);
1556  TEST_ASSERT(tol.approximately_equal(p11, p_test));
1557 // std::cout << "p=" << p11
1558 // << "\tpc=" << ribs[1].get_f().f(v1)
1559 // << "\tp_test=" << p_test << "\tdiff="
1560 // << (p11-p_test).norm() << std::endl;
1561  v=v0+(v1-v0)/4;
1562  p_test=s.f(u0, v);
1563  p_ref=ribs[0].get_f().f(v);
1564  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1565 // std::cout << "p=" << p_ref
1566 // << "\tp_test=" << p_test << "\tdiff="
1567 // << (p_ref-p_test).norm() << std::endl;
1568  p_test=s.f(u1, v);
1569  p_ref=ribs[1].get_f().f(v);
1570  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1571 // std::cout << "p=" << p_ref
1572 // << "\tp_test=" << p_test << "\tdiff="
1573 // << (p_ref-p_test).norm() << std::endl;
1574  v=v0+3*(v1-v0)/4;
1575  p_test=s.f(u0, v);
1576  p_ref=ribs[0].get_f().f(v);
1577  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1578 // std::cout << "p=" << p_ref
1579 // << "\tp_test=" << p_test << "\tdiff="
1580 // << (p_ref-p_test).norm() << std::endl;
1581  p_test=s.f(u1, v);
1582  p_ref=ribs[1].get_f().f(v);
1583  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1584 // std::cout << "p=" << p_ref
1585 // << "\tp_test=" << p_test << "\tdiff="
1586 // << (p_ref-p_test).norm() << std::endl;
1587 
1588 // if (rtn_flag && (typeid(data_type)==typeid(float)))
1589 // {
1590 // std::cout.flush();
1591 // eli::test::octave_start(1);
1592 // eli::test::octave_print(1, s, "surf", true);
1593 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
1594 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
1595 // eli::test::octave_finish(1);
1596 // }
1597  }
1598 
1599  // surface connecting ribs made of 2 cubic segments each
1600  {
1601  index_type nsegs(1);
1602  std::vector<rib_data_type> ribs(nsegs+1);
1603  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1604  point_type p;
1605  rib_curve_type rc1, rc2;
1606  general_creator_type gc;
1607  piecewise_surface_type s;
1608  point_type p00, p01, p10, p11;
1609  data_type u0(2), v0(1), u1(4), v1(5), v;
1610  bool rtn_flag;
1611 
1612  // four corners of surface
1613  p00 << 1, 1, 1;
1614  p01 << 2, 3, 1;
1615  p10 << 3, 2, 3;
1616  p11 << 4, 4, 4;
1617 
1618  // create two rib curves && two slope curves
1619  typename rib_curve_type::curve_type curve(3);
1620  typename rib_curve_type::control_point_type cp[4];
1621 
1622  // manually create cubic curves for ribs
1623  cp[0]=p00;
1624  cp[1] << 0, 2, 1;
1625  cp[2] << 1, 3, 1;
1626  cp[3]=p01;
1627  for (index_type i=0; i<4; ++i)
1628  {
1629  curve.set_control_point(cp[i], i);
1630  }
1631  rc1.push_front(curve, v1-v0);
1632  rc1.set_t0(v0);
1633  rc1.split((v0+v1)/2);
1634 
1635  cp[0]=p10;
1636  cp[1] << 1, 2, 3;
1637  cp[2] << 2, 3, 4;
1638  cp[3]=p11;
1639  for (index_type i=0; i<4; ++i)
1640  {
1641  curve.set_control_point(cp[i], i);
1642  }
1643  rc2.push_front(curve, v1-v0);
1644  rc2.set_t0(v0);
1645  rc2.split((v0+v1)/2);
1646 
1647  // set the rib data
1648  ribs[0].set_f(rc1);
1649  ribs[1].set_f(rc2);
1650 
1651  // set the maximum degrees of each segment
1652  max_degree[0]=0;
1653 
1654  // create surface
1655  rtn_flag=gc.set_conditions(ribs, max_degree, false);
1656  TEST_ASSERT(rtn_flag);
1657  gc.set_u0(u0);
1658  gc.set_segment_du(u1-u0, 0);
1659  rtn_flag=gc.create(s);
1660  TEST_ASSERT(rtn_flag);
1661 
1662  // test the resulting curve
1663  point_type p_test, p_ref;
1664 
1665  p_test=s.f(u0, v0);
1666  TEST_ASSERT(tol.approximately_equal(p00, p_test));
1667 // std::cout << "p=" << p00
1668 // << "\tpc=" << ribs[0].get_f().f(v0)
1669 // << "\tp_test=" << p_test << "\tdiff="
1670 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
1671  p_test=s.f(u1, v0);
1672  TEST_ASSERT(tol.approximately_equal(p10, p_test));
1673 // std::cout << "p=" << p10
1674 // << "\tpc=" << ribs[1].get_f().f(v0)
1675 // << "\tp_test=" << p_test << "\tdiff="
1676 // << (p10-p_test).norm() << std::endl;
1677  p_test=s.f(u0, v1);
1678  TEST_ASSERT(tol.approximately_equal(p01, p_test));
1679 // std::cout << "p=" << p01
1680 // << "\tpc=" << ribs[0].get_f().f(v1)
1681 // << "\tp_test=" << p_test << "\tdiff="
1682 // << (p01-p_test).norm() << std::endl;
1683  p_test=s.f(u1, v1);
1684  TEST_ASSERT(tol.approximately_equal(p11, p_test));
1685 // std::cout << "p=" << p11
1686 // << "\tpc=" << ribs[1].get_f().f(v1)
1687 // << "\tp_test=" << p_test << "\tdiff="
1688 // << (p11-p_test).norm() << std::endl;
1689  v=v0+(v1-v0)/4;
1690  p_test=s.f(u0, v);
1691  p_ref=ribs[0].get_f().f(v);
1692  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1693 // std::cout << "p=" << p_ref
1694 // << "\tp_test=" << p_test << "\tdiff="
1695 // << (p_ref-p_test).norm() << std::endl;
1696  p_test=s.f(u1, v);
1697  p_ref=ribs[1].get_f().f(v);
1698  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1699 // std::cout << "p=" << p_ref
1700 // << "\tp_test=" << p_test << "\tdiff="
1701 // << (p_ref-p_test).norm() << std::endl;
1702  v=v0+3*(v1-v0)/4;
1703  p_test=s.f(u0, v);
1704  p_ref=ribs[0].get_f().f(v);
1705  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1706 // std::cout << "p=" << p_ref
1707 // << "\tp_test=" << p_test << "\tdiff="
1708 // << (p_ref-p_test).norm() << std::endl;
1709  p_test=s.f(u1, v);
1710  p_ref=ribs[1].get_f().f(v);
1711  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1712 // std::cout << "p=" << p_ref
1713 // << "\tp_test=" << p_test << "\tdiff="
1714 // << (p_ref-p_test).norm() << std::endl;
1715 
1716 // if (rtn_flag && (typeid(data_type)==typeid(float)))
1717 // {
1718 // std::cout.flush();
1719 // eli::test::octave_start(1);
1720 // eli::test::octave_print(1, s, "surf", true);
1721 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
1722 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
1723 // eli::test::octave_finish(1);
1724 // }
1725  }
1726 
1727  // surface connecting ribs made of 2 cubic segments each, specified 1st
1728  {
1729  index_type nsegs(1);
1730  std::vector<rib_data_type> ribs(nsegs+1);
1731  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1732  point_type p;
1733  rib_curve_type rc1, rc2, rs1, rs2;
1734  general_creator_type gc;
1735  piecewise_surface_type s;
1736  point_type p00, p01, p10, p11, s00, s01, s10, s11;
1737  data_type u0(2), v0(1), u1(4), v1(5), v;
1738  bool rtn_flag;
1739 
1740  // four corners of surface
1741  p00 << 1, 1, 1;
1742  p01 << 2, 3, 1;
1743  p10 << 3, 2, 3;
1744  p11 << 4, 4, 4;
1745  s00 << 2, 2, 0;
1746  s01 << 1, 3, 2;
1747  s10 << 2, 1, 0;
1748  s11 << 2, 0, 1;
1749 
1750  // create two rib curves && two slope curves
1751  typename rib_curve_type::curve_type curve(3);
1752  typename rib_curve_type::control_point_type cp[4];
1753 
1754  // manually create cubic curves for ribs
1755  cp[0]=p00;
1756  cp[1] << 0, 2, 1;
1757  cp[2] << 1, 3, 1;
1758  cp[3]=p01;
1759  for (index_type i=0; i<4; ++i)
1760  {
1761  curve.set_control_point(cp[i], i);
1762  }
1763  rc1.push_front(curve, v1-v0);
1764  rc1.set_t0(v0);
1765  rc1.split((v0+v1)/2);
1766 
1767  cp[0]=p10;
1768  cp[1] << 1, 2, 3;
1769  cp[2] << 2, 3, 4;
1770  cp[3]=p11;
1771  for (index_type i=0; i<4; ++i)
1772  {
1773  curve.set_control_point(cp[i], i);
1774  }
1775  rc2.push_front(curve, v1-v0);
1776  rc2.set_t0(v0);
1777  rc2.split((v0+v1)/2);
1778 
1779  // create two two slope curves
1780  piecewise_line_creator_type plc(1);
1781 
1782  plc.set_corner(s00/2, 0);
1783  plc.set_corner(s01/2, 1);
1784  plc.set_t0(v0);
1785  plc.set_segment_dt(v1-v0, 0);
1786  plc.create(rs1);
1787 
1788  plc.set_corner(s10/2, 0);
1789  plc.set_corner(s11/2, 1);
1790  plc.set_t0(v0);
1791  plc.set_segment_dt(v1-v0, 0);
1792  plc.create(rs2);
1793 
1794  // set the rib data
1795  ribs[0].set_f(rc1);
1796  ribs[0].set_right_fp(rs1);
1797  ribs[1].set_f(rc2);
1798  ribs[1].set_left_fp(rs2);
1799 
1800  // set the maximum degrees of each segment
1801  max_degree[0]=0;
1802 
1803  // create surface
1804  rtn_flag=gc.set_conditions(ribs, max_degree, false);
1805  TEST_ASSERT(rtn_flag);
1806  gc.set_u0(u0);
1807  gc.set_segment_du(u1-u0, 0);
1808  rtn_flag=gc.create(s);
1809  TEST_ASSERT(rtn_flag);
1810 
1811  // test the resulting curve
1812  point_type p_test, p_ref;
1813 
1814  p_test=s.f(u0, v0);
1815  TEST_ASSERT(tol.approximately_equal(p00, p_test));
1816 // std::cout << "p=" << p00
1817 // << "\tpc=" << ribs[0].get_f().f(v0)
1818 // << "\tp_test=" << p_test << "\tdiff="
1819 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
1820  p_test=s.f(u1, v0);
1821  TEST_ASSERT(tol.approximately_equal(p10, p_test));
1822 // std::cout << "p=" << p10
1823 // << "\tpc=" << ribs[1].get_f().f(v0)
1824 // << "\tp_test=" << p_test << "\tdiff="
1825 // << (p10-p_test).norm() << std::endl;
1826  p_test=s.f(u0, v1);
1827  TEST_ASSERT(tol.approximately_equal(p01, p_test));
1828 // std::cout << "p=" << p01
1829 // << "\tpc=" << ribs[0].get_f().f(v1)
1830 // << "\tp_test=" << p_test << "\tdiff="
1831 // << (p01-p_test).norm() << std::endl;
1832  p_test=s.f(u1, v1);
1833  TEST_ASSERT(tol.approximately_equal(p11, p_test));
1834 // std::cout << "p=" << p11
1835 // << "\tpc=" << ribs[1].get_f().f(v1)
1836 // << "\tp_test=" << p_test << "\tdiff="
1837 // << (p11-p_test).norm() << std::endl;
1838  v=v0+(v1-v0)/4;
1839  p_test=s.f(u0, v);
1840  p_ref=ribs[0].get_f().f(v);
1841  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1842 // std::cout << "p=" << p_ref
1843 // << "\tp_test=" << p_test << "\tdiff="
1844 // << (p_ref-p_test).norm() << std::endl;
1845  p_test=s.f(u1, v);
1846  p_ref=ribs[1].get_f().f(v);
1847  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1848 // std::cout << "p=" << p_ref
1849 // << "\tp_test=" << p_test << "\tdiff="
1850 // << (p_ref-p_test).norm() << std::endl;
1851  p_test=s.f_u(u0, v);
1852  p_ref=ribs[0].get_right_fp().f(v);
1853  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1854 // std::cout << "p=" << p_ref
1855 // << "\tp_test=" << p_test << "\tdiff="
1856 // << (p_ref-p_test).norm() << std::endl;
1857  p_test=s.f_u(u1, v);
1858  p_ref=ribs[1].get_left_fp().f(v);
1859  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1860 // std::cout << "p=" << p_ref
1861 // << "\tp_test=" << p_test << "\tdiff="
1862 // << (p_ref-p_test).norm() << std::endl;
1863  v=v0+3*(v1-v0)/4;
1864  p_test=s.f(u0, v);
1865  p_ref=ribs[0].get_f().f(v);
1866  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1867 // std::cout << "p=" << p_ref
1868 // << "\tp_test=" << p_test << "\tdiff="
1869 // << (p_ref-p_test).norm() << std::endl;
1870  p_test=s.f(u1, v);
1871  p_ref=ribs[1].get_f().f(v);
1872  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1873 // std::cout << "p=" << p_ref
1874 // << "\tp_test=" << p_test << "\tdiff="
1875 // << (p_ref-p_test).norm() << std::endl;
1876  p_test=s.f_u(u0, v);
1877  p_ref=ribs[0].get_right_fp().f(v);
1878  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1879 // std::cout << "p=" << p_ref
1880 // << "\tp_test=" << p_test << "\tdiff="
1881 // << (p_ref-p_test).norm() << std::endl;
1882  p_test=s.f_u(u1, v);
1883  p_ref=ribs[1].get_left_fp().f(v);
1884  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
1885 // std::cout << "p=" << p_ref
1886 // << "\tp_test=" << p_test << "\tdiff="
1887 // << (p_ref-p_test).norm() << std::endl;
1888 
1889 // if (rtn_flag && (typeid(data_type)==typeid(float)))
1890 // {
1891 // std::cout.flush();
1892 // eli::test::octave_start(1);
1893 // eli::test::octave_print(1, s, "surf", true);
1894 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
1895 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
1896 // eli::test::octave_print(1, ribs[0].get_f(), ribs[0].get_right_fp(), "rve0");
1897 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_left_fp(), "lve1");
1898 // eli::test::octave_finish(1);
1899 // }
1900  }
1901 
1902  // surface connecting ribs made of 2 cubic segments each, specified 1st and 2nd derivatives
1903  {
1904  index_type nsegs(1);
1905  std::vector<rib_data_type> ribs(nsegs+1);
1906  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
1907  point_type p;
1908  rib_curve_type rc1, rc2, rs1, rs2, ra1, ra2;
1909  general_creator_type gc;
1910  piecewise_surface_type s;
1911  point_type p00, p01, p10, p11, s00, s01, s10, s11, a00, a01, a10, a11;
1912  data_type u0(2), v0(1), u1(4), v1(5), v;
1913  bool rtn_flag;
1914 
1915  // four corners of surface
1916  p00 << 1, 1, 1;
1917  p01 << 2, 3, 1;
1918  p10 << 3, 2, 3;
1919  p11 << 4, 4, 4;
1920  s00 << 2, 2, 0;
1921  s01 << 1, 3, 2;
1922  s10 << 2, 1, 0;
1923  s11 << 2, 0, 1;
1924  a00 << 0, 1, 0;
1925  a01 << 1, 0, 1;
1926  a10 << 1, 0, 1;
1927  a11 << 0, 1, 0;
1928 
1929  // create two rib curves && two slope curves
1930  typename rib_curve_type::curve_type curve(3);
1931  typename rib_curve_type::control_point_type cp[4];
1932 
1933  // manually create cubic curves for ribs
1934  cp[0]=p00;
1935  cp[1] << 0, 2, 1;
1936  cp[2] << 1, 3, 1;
1937  cp[3]=p01;
1938  for (index_type i=0; i<4; ++i)
1939  {
1940  curve.set_control_point(cp[i], i);
1941  }
1942  rc1.push_front(curve, v1-v0);
1943  rc1.set_t0(v0);
1944  rc1.split((v0+v1)/2);
1945 
1946  cp[0]=p10;
1947  cp[1] << 1, 2, 3;
1948  cp[2] << 2, 3, 4;
1949  cp[3]=p11;
1950  for (index_type i=0; i<4; ++i)
1951  {
1952  curve.set_control_point(cp[i], i);
1953  }
1954  rc2.push_front(curve, v1-v0);
1955  rc2.set_t0(v0);
1956  rc2.split((v0+v1)/2);
1957 
1958  // create two two slope curves
1959  piecewise_line_creator_type plc(1);
1960 
1961  plc.set_corner(s00/2, 0);
1962  plc.set_corner(s01/2, 1);
1963  plc.set_t0(v0);
1964  plc.set_segment_dt(v1-v0, 0);
1965  plc.create(rs1);
1966 
1967  plc.set_corner(a00, 0);
1968  plc.set_corner(a01, 1);
1969  plc.set_t0(v0);
1970  plc.set_segment_dt(v1-v0, 0);
1971  plc.create(ra1);
1972 
1973  plc.set_corner(s10/2, 0);
1974  plc.set_corner(s11/2, 1);
1975  plc.set_t0(v0);
1976  plc.set_segment_dt(v1-v0, 0);
1977  plc.create(rs2);
1978 
1979  plc.set_corner(a10, 0);
1980  plc.set_corner(a11, 1);
1981  plc.set_t0(v0);
1982  plc.set_segment_dt(v1-v0, 0);
1983  plc.create(ra2);
1984 
1985  // set the rib data
1986  ribs[0].set_f(rc1);
1987  ribs[0].set_right_fp(rs1);
1988  ribs[0].set_right_fpp(ra1);
1989  ribs[1].set_f(rc2);
1990  ribs[1].set_left_fp(rs2);
1991  ribs[1].set_left_fpp(ra2);
1992 
1993  // set the maximum degrees of each segment
1994  max_degree[0]=0;
1995 
1996  // create surface
1997  rtn_flag=gc.set_conditions(ribs, max_degree, false);
1998  TEST_ASSERT(rtn_flag);
1999  gc.set_u0(u0);
2000  gc.set_segment_du(u1-u0, 0);
2001  rtn_flag=gc.create(s);
2002  TEST_ASSERT(rtn_flag);
2003 
2004  // test the resulting curve
2005  point_type p_test, p_ref;
2006 
2007  p_test=s.f(u0, v0);
2008  TEST_ASSERT(tol.approximately_equal(p00, p_test));
2009 // std::cout << "p=" << p00
2010 // << "\tpc=" << ribs[0].get_f().f(v0)
2011 // << "\tp_test=" << p_test << "\tdiff="
2012 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
2013  p_test=s.f(u1, v0);
2014  TEST_ASSERT(tol.approximately_equal(p10, p_test));
2015 // std::cout << "p=" << p10
2016 // << "\tpc=" << ribs[1].get_f().f(v0)
2017 // << "\tp_test=" << p_test << "\tdiff="
2018 // << (p10-p_test).norm() << std::endl;
2019  p_test=s.f(u0, v1);
2020  TEST_ASSERT(tol.approximately_equal(p01, p_test));
2021 // std::cout << "p=" << p01
2022 // << "\tpc=" << ribs[0].get_f().f(v1)
2023 // << "\tp_test=" << p_test << "\tdiff="
2024 // << (p01-p_test).norm() << std::endl;
2025  p_test=s.f(u1, v1);
2026  TEST_ASSERT(tol.approximately_equal(p11, p_test));
2027 // std::cout << "p=" << p11
2028 // << "\tpc=" << ribs[1].get_f().f(v1)
2029 // << "\tp_test=" << p_test << "\tdiff="
2030 // << (p11-p_test).norm() << std::endl;
2031  v=v0+(v1-v0)/4;
2032  p_test=s.f(u0, v);
2033  p_ref=ribs[0].get_f().f(v);
2034  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2035 // std::cout << "p=" << p_ref
2036 // << "\tp_test=" << p_test << "\tdiff="
2037 // << (p_ref-p_test).norm() << std::endl;
2038  p_test=s.f(u1, v);
2039  p_ref=ribs[1].get_f().f(v);
2040  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2041 // std::cout << "p=" << p_ref
2042 // << "\tp_test=" << p_test << "\tdiff="
2043 // << (p_ref-p_test).norm() << std::endl;
2044  p_test=s.f_u(u0, v);
2045  p_ref=ribs[0].get_right_fp().f(v);
2046  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2047 // std::cout << "p=" << p_ref
2048 // << "\tp_test=" << p_test << "\tdiff="
2049 // << (p_ref-p_test).norm() << std::endl;
2050  p_test=s.f_u(u1, v);
2051  p_ref=ribs[1].get_left_fp().f(v);
2052  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2053 // std::cout << "p=" << p_ref
2054 // << "\tp_test=" << p_test << "\tdiff="
2055 // << (p_ref-p_test).norm() << std::endl;
2056  p_test=s.f_uu(u0, v);
2057  p_ref=ribs[0].get_right_fpp().f(v);
2058  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2059 // std::cout << "p=" << p_ref
2060 // << "\tp_test=" << p_test << "\tdiff="
2061 // << (p_ref-p_test).norm() << std::endl;
2062  p_test=s.f_uu(u1, v);
2063  p_ref=ribs[1].get_left_fpp().f(v);
2064  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2065 // std::cout << "p=" << p_ref
2066 // << "\tp_test=" << p_test << "\tdiff="
2067 // << (p_ref-p_test).norm() << std::endl;
2068  v=v0+3*(v1-v0)/4;
2069  p_test=s.f(u0, v);
2070  p_ref=ribs[0].get_f().f(v);
2071  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2072 // std::cout << "p=" << p_ref
2073 // << "\tp_test=" << p_test << "\tdiff="
2074 // << (p_ref-p_test).norm() << std::endl;
2075  p_test=s.f(u1, v);
2076  p_ref=ribs[1].get_f().f(v);
2077  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2078 // std::cout << "p=" << p_ref
2079 // << "\tp_test=" << p_test << "\tdiff="
2080 // << (p_ref-p_test).norm() << std::endl;
2081  p_test=s.f_u(u0, v);
2082  p_ref=ribs[0].get_right_fp().f(v);
2083  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2084 // std::cout << "p=" << p_ref
2085 // << "\tp_test=" << p_test << "\tdiff="
2086 // << (p_ref-p_test).norm() << std::endl;
2087  p_test=s.f_u(u1, v);
2088  p_ref=ribs[1].get_left_fp().f(v);
2089  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2090 // std::cout << "p=" << p_ref
2091 // << "\tp_test=" << p_test << "\tdiff="
2092 // << (p_ref-p_test).norm() << std::endl;
2093  p_test=s.f_uu(u0, v);
2094  p_ref=ribs[0].get_right_fpp().f(v);
2095  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2096 // std::cout << "p=" << p_ref
2097 // << "\tp_test=" << p_test << "\tdiff="
2098 // << (p_ref-p_test).norm() << std::endl;
2099  p_test=s.f_uu(u1, v);
2100  p_ref=ribs[1].get_left_fpp().f(v);
2101  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2102 // std::cout << "p=" << p_ref
2103 // << "\tp_test=" << p_test << "\tdiff="
2104 // << (p_ref-p_test).norm() << std::endl;
2105 
2106 // if (rtn_flag && (typeid(data_type)==typeid(float)))
2107 // {
2108 // std::cout.flush();
2109 // eli::test::octave_start(1);
2110 // eli::test::octave_print(1, s, "surf", true);
2111 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
2112 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
2113 // eli::test::octave_print(1, ribs[0].get_f(), ribs[0].get_right_fp(), "rve0");
2114 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_left_fp(), "lve1");
2115 // eli::test::octave_finish(1);
2116 // }
2117  }
2118 
2119  // surface connecting 1 rib with 1 cubic segment and 1 rib made of 2 cubic segments, specified 1st and 2nd derivatives
2120  {
2121  index_type nsegs(1);
2122  std::vector<rib_data_type> ribs(nsegs+1);
2123  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
2124  point_type p;
2125  rib_curve_type rc1, rc2, rs1, rs2, ra1, ra2;
2126  general_creator_type gc;
2127  piecewise_surface_type s;
2128  point_type p00, p01, p10, p11, s00, s01, s10, s11, a00, a01, a10, a11;
2129  data_type u0(2), v0(1), u1(4), v1(5), v;
2130  bool rtn_flag;
2131 
2132  // four corners of surface
2133  p00 << 1, 1, 1;
2134  p01 << 2, 3, 1;
2135  p10 << 3, 2, 3;
2136  p11 << 4, 4, 4;
2137  s00 << 2, 2, 0;
2138  s01 << 1, 3, 2;
2139  s10 << 2, 1, 0;
2140  s11 << 2, 0, 1;
2141  a00 << 0, 1, 0;
2142  a01 << 1, 0, 1;
2143  a10 << 1, 0, 1;
2144  a11 << 0, 1, 0;
2145 
2146  // create two rib curves && two slope curves
2147  typename rib_curve_type::curve_type curve(3);
2148  typename rib_curve_type::control_point_type cp[4];
2149 
2150  // manually create cubic curves for ribs
2151  cp[0]=p00;
2152  cp[1] << 0, 2, 1;
2153  cp[2] << 1, 3, 1;
2154  cp[3]=p01;
2155  for (index_type i=0; i<4; ++i)
2156  {
2157  curve.set_control_point(cp[i], i);
2158  }
2159  rc1.push_front(curve, v1-v0);
2160  rc1.set_t0(v0);
2161  rc1.split((v0+v1)/2);
2162 
2163  cp[0]=p10;
2164  cp[1] << 1, 2, 3;
2165  cp[2] << 2, 3, 4;
2166  cp[3]=p11;
2167  for (index_type i=0; i<4; ++i)
2168  {
2169  curve.set_control_point(cp[i], i);
2170  }
2171  rc2.push_front(curve, v1-v0);
2172  rc2.set_t0(v0);
2173 
2174  // create two two slope curves
2175  piecewise_line_creator_type plc(1);
2176 
2177  plc.set_corner(s00/2, 0);
2178  plc.set_corner(s01/2, 1);
2179  plc.set_t0(v0);
2180  plc.set_segment_dt(v1-v0, 0);
2181  plc.create(rs1);
2182 
2183  plc.set_corner(a00, 0);
2184  plc.set_corner(a01, 1);
2185  plc.set_t0(v0);
2186  plc.set_segment_dt(v1-v0, 0);
2187  plc.create(ra1);
2188 
2189  plc.set_corner(s10/2, 0);
2190  plc.set_corner(s11/2, 1);
2191  plc.set_t0(v0);
2192  plc.set_segment_dt(v1-v0, 0);
2193  plc.create(rs2);
2194 
2195  plc.set_corner(a10, 0);
2196  plc.set_corner(a11, 1);
2197  plc.set_t0(v0);
2198  plc.set_segment_dt(v1-v0, 0);
2199  plc.create(ra2);
2200 
2201  // set the rib data
2202  ribs[0].set_f(rc1);
2203  ribs[0].set_right_fp(rs1);
2204  ribs[0].set_right_fpp(ra1);
2205  ribs[1].set_f(rc2);
2206  ribs[1].set_left_fp(rs2);
2207  ribs[1].set_left_fpp(ra2);
2208 
2209  // set the maximum degrees of each segment
2210  max_degree[0]=0;
2211 
2212  // create surface
2213  rtn_flag=gc.set_conditions(ribs, max_degree, false);
2214  TEST_ASSERT(rtn_flag);
2215  gc.set_u0(u0);
2216  gc.set_segment_du(u1-u0, 0);
2217  rtn_flag=gc.create(s);
2218  TEST_ASSERT(rtn_flag);
2219 
2220  // test the resulting curve
2221  point_type p_test, p_ref;
2222 
2223  p_test=s.f(u0, v0);
2224  TEST_ASSERT(tol.approximately_equal(p00, p_test));
2225 // std::cout << "p=" << p00
2226 // << "\tpc=" << ribs[0].get_f().f(v0)
2227 // << "\tp_test=" << p_test << "\tdiff="
2228 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
2229  p_test=s.f(u1, v0);
2230  TEST_ASSERT(tol.approximately_equal(p10, p_test));
2231 // std::cout << "p=" << p10
2232 // << "\tpc=" << ribs[1].get_f().f(v0)
2233 // << "\tp_test=" << p_test << "\tdiff="
2234 // << (p10-p_test).norm() << std::endl;
2235  p_test=s.f(u0, v1);
2236  TEST_ASSERT(tol.approximately_equal(p01, p_test));
2237 // std::cout << "p=" << p01
2238 // << "\tpc=" << ribs[0].get_f().f(v1)
2239 // << "\tp_test=" << p_test << "\tdiff="
2240 // << (p01-p_test).norm() << std::endl;
2241  p_test=s.f(u1, v1);
2242  TEST_ASSERT(tol.approximately_equal(p11, p_test));
2243 // std::cout << "p=" << p11
2244 // << "\tpc=" << ribs[1].get_f().f(v1)
2245 // << "\tp_test=" << p_test << "\tdiff="
2246 // << (p11-p_test).norm() << std::endl;
2247  v=v0+(v1-v0)/4;
2248  p_test=s.f(u0, v);
2249  p_ref=ribs[0].get_f().f(v);
2250  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2251 // std::cout << "p=" << p_ref
2252 // << "\tp_test=" << p_test << "\tdiff="
2253 // << (p_ref-p_test).norm() << std::endl;
2254  p_test=s.f(u1, v);
2255  p_ref=ribs[1].get_f().f(v);
2256  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2257 // std::cout << "p=" << p_ref
2258 // << "\tp_test=" << p_test << "\tdiff="
2259 // << (p_ref-p_test).norm() << std::endl;
2260  p_test=s.f_u(u0, v);
2261  p_ref=ribs[0].get_right_fp().f(v);
2262  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2263 // std::cout << "p=" << p_ref
2264 // << "\tp_test=" << p_test << "\tdiff="
2265 // << (p_ref-p_test).norm() << std::endl;
2266  p_test=s.f_u(u1, v);
2267  p_ref=ribs[1].get_left_fp().f(v);
2268  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2269 // std::cout << "p=" << p_ref
2270 // << "\tp_test=" << p_test << "\tdiff="
2271 // << (p_ref-p_test).norm() << std::endl;
2272  p_test=s.f_uu(u0, v);
2273  p_ref=ribs[0].get_right_fpp().f(v);
2274  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2275 // std::cout << "p=" << p_ref
2276 // << "\tp_test=" << p_test << "\tdiff="
2277 // << (p_ref-p_test).norm() << std::endl;
2278  p_test=s.f_uu(u1, v);
2279  p_ref=ribs[1].get_left_fpp().f(v);
2280  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2281 // std::cout << "p=" << p_ref
2282 // << "\tp_test=" << p_test << "\tdiff="
2283 // << (p_ref-p_test).norm() << std::endl;
2284  v=v0+3*(v1-v0)/4;
2285  p_test=s.f(u0, v);
2286  p_ref=ribs[0].get_f().f(v);
2287  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2288 // std::cout << "p=" << p_ref
2289 // << "\tp_test=" << p_test << "\tdiff="
2290 // << (p_ref-p_test).norm() << std::endl;
2291  p_test=s.f(u1, v);
2292  p_ref=ribs[1].get_f().f(v);
2293  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2294 // std::cout << "p=" << p_ref
2295 // << "\tp_test=" << p_test << "\tdiff="
2296 // << (p_ref-p_test).norm() << std::endl;
2297  p_test=s.f_u(u0, v);
2298  p_ref=ribs[0].get_right_fp().f(v);
2299  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2300 // std::cout << "p=" << p_ref
2301 // << "\tp_test=" << p_test << "\tdiff="
2302 // << (p_ref-p_test).norm() << std::endl;
2303  p_test=s.f_u(u1, v);
2304  p_ref=ribs[1].get_left_fp().f(v);
2305  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2306 // std::cout << "p=" << p_ref
2307 // << "\tp_test=" << p_test << "\tdiff="
2308 // << (p_ref-p_test).norm() << std::endl;
2309  p_test=s.f_uu(u0, v);
2310  p_ref=ribs[0].get_right_fpp().f(v);
2311  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2312 // std::cout << "p=" << p_ref
2313 // << "\tp_test=" << p_test << "\tdiff="
2314 // << (p_ref-p_test).norm() << std::endl;
2315  p_test=s.f_uu(u1, v);
2316  p_ref=ribs[1].get_left_fpp().f(v);
2317  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2318 // std::cout << "p=" << p_ref
2319 // << "\tp_test=" << p_test << "\tdiff="
2320 // << (p_ref-p_test).norm() << std::endl;
2321 
2322 // if (rtn_flag && (typeid(data_type)==typeid(float)))
2323 // {
2324 // std::cout.flush();
2325 // eli::test::octave_start(1);
2326 // eli::test::octave_print(1, s, "surf", true);
2327 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
2328 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
2329 // eli::test::octave_print(1, ribs[0].get_f(), ribs[0].get_right_fp(), "rve0");
2330 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_left_fp(), "lve1");
2331 // eli::test::octave_finish(1);
2332 // }
2333  }
2334 
2335  // surface connecting ribs made of 2 cubic segments each with different split locations, specified 1st and 2nd derivatives
2336  {
2337  index_type nsegs(1);
2338  std::vector<rib_data_type> ribs(nsegs+1);
2339  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
2340  point_type p;
2341  rib_curve_type rc1, rc2, rs1, rs2, ra1, ra2;
2342  general_creator_type gc;
2343  piecewise_surface_type s;
2344  point_type p00, p01, p10, p11, s00, s01, s10, s11, a00, a01, a10, a11;
2345  data_type u0(2), v0(1), u1(4), v1(5), v;
2346  bool rtn_flag;
2347 
2348  // four corners of surface
2349  p00 << 1, 1, 1;
2350  p01 << 2, 3, 1;
2351  p10 << 3, 2, 3;
2352  p11 << 4, 4, 4;
2353  s00 << 2, 2, 0;
2354  s01 << 1, 3, 2;
2355  s10 << 2, 1, 0;
2356  s11 << 2, 0, 1;
2357  a00 << 0, 1, 0;
2358  a01 << 1, 0, 1;
2359  a10 << 1, 0, 1;
2360  a11 << 0, 1, 0;
2361 
2362  // create two rib curves && two slope curves
2363  typename rib_curve_type::curve_type curve(3);
2364  typename rib_curve_type::control_point_type cp[4];
2365 
2366  // manually create cubic curves for ribs
2367  cp[0]=p00;
2368  cp[1] << 0, 2, 1;
2369  cp[2] << 1, 3, 1;
2370  cp[3]=p01;
2371  for (index_type i=0; i<4; ++i)
2372  {
2373  curve.set_control_point(cp[i], i);
2374  }
2375  rc1.push_front(curve, v1-v0);
2376  rc1.set_t0(v0);
2377  rc1.split(v0+(v1-v0)/4);
2378 
2379  cp[0]=p10;
2380  cp[1] << 1, 2, 3;
2381  cp[2] << 2, 3, 4;
2382  cp[3]=p11;
2383  for (index_type i=0; i<4; ++i)
2384  {
2385  curve.set_control_point(cp[i], i);
2386  }
2387  rc2.push_front(curve, v1-v0);
2388  rc2.set_t0(v0);
2389  rc2.split(v0+3*(v1-v0)/4);
2390 
2391  // create two two slope curves
2392  piecewise_line_creator_type plc(1);
2393 
2394  plc.set_corner(s00/2, 0);
2395  plc.set_corner(s01/2, 1);
2396  plc.set_t0(v0);
2397  plc.set_segment_dt(v1-v0, 0);
2398  plc.create(rs1);
2399 
2400  plc.set_corner(a00, 0);
2401  plc.set_corner(a01, 1);
2402  plc.set_t0(v0);
2403  plc.set_segment_dt(v1-v0, 0);
2404  plc.create(ra1);
2405 
2406  plc.set_corner(s10/2, 0);
2407  plc.set_corner(s11/2, 1);
2408  plc.set_t0(v0);
2409  plc.set_segment_dt(v1-v0, 0);
2410  plc.create(rs2);
2411 
2412  plc.set_corner(a10, 0);
2413  plc.set_corner(a11, 1);
2414  plc.set_t0(v0);
2415  plc.set_segment_dt(v1-v0, 0);
2416  plc.create(ra2);
2417 
2418  // set the rib data
2419  ribs[0].set_f(rc1);
2420  ribs[0].set_right_fp(rs1);
2421  ribs[0].set_right_fpp(ra1);
2422  ribs[1].set_f(rc2);
2423  ribs[1].set_left_fp(rs2);
2424  ribs[1].set_left_fpp(ra2);
2425 
2426  // set the maximum degrees of each segment
2427  max_degree[0]=0;
2428 
2429  // create surface
2430  rtn_flag=gc.set_conditions(ribs, max_degree, false);
2431  TEST_ASSERT(rtn_flag);
2432  gc.set_u0(u0);
2433  gc.set_segment_du(u1-u0, 0);
2434  rtn_flag=gc.create(s);
2435  TEST_ASSERT(rtn_flag);
2436 
2437  // test the resulting curve
2438  point_type p_test, p_ref;
2439 
2440  p_test=s.f(u0, v0);
2441  TEST_ASSERT(tol.approximately_equal(p00, p_test));
2442 // std::cout << "p=" << p00
2443 // << "\tpc=" << ribs[0].get_f().f(v0)
2444 // << "\tp_test=" << p_test << "\tdiff="
2445 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
2446  p_test=s.f(u1, v0);
2447  TEST_ASSERT(tol.approximately_equal(p10, p_test));
2448 // std::cout << "p=" << p10
2449 // << "\tpc=" << ribs[1].get_f().f(v0)
2450 // << "\tp_test=" << p_test << "\tdiff="
2451 // << (p10-p_test).norm() << std::endl;
2452  p_test=s.f(u0, v1);
2453  TEST_ASSERT(tol.approximately_equal(p01, p_test));
2454 // std::cout << "p=" << p01
2455 // << "\tpc=" << ribs[0].get_f().f(v1)
2456 // << "\tp_test=" << p_test << "\tdiff="
2457 // << (p01-p_test).norm() << std::endl;
2458  p_test=s.f(u1, v1);
2459  TEST_ASSERT(tol.approximately_equal(p11, p_test));
2460 // std::cout << "p=" << p11
2461 // << "\tpc=" << ribs[1].get_f().f(v1)
2462 // << "\tp_test=" << p_test << "\tdiff="
2463 // << (p11-p_test).norm() << std::endl;
2464  v=v0+(v1-v0)/8;
2465  p_test=s.f(u0, v);
2466  p_ref=ribs[0].get_f().f(v);
2467  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2468 // std::cout << "p=" << p_ref
2469 // << "\tp_test=" << p_test << "\tdiff="
2470 // << (p_ref-p_test).norm() << std::endl;
2471  p_test=s.f(u1, v);
2472  p_ref=ribs[1].get_f().f(v);
2473  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2474 // std::cout << "p=" << p_ref
2475 // << "\tp_test=" << p_test << "\tdiff="
2476 // << (p_ref-p_test).norm() << std::endl;
2477  p_test=s.f_u(u0, v);
2478  p_ref=ribs[0].get_right_fp().f(v);
2479  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2480 // std::cout << "p=" << p_ref
2481 // << "\tp_test=" << p_test << "\tdiff="
2482 // << (p_ref-p_test).norm() << std::endl;
2483  p_test=s.f_u(u1, v);
2484  p_ref=ribs[1].get_left_fp().f(v);
2485  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2486 // std::cout << "p=" << p_ref
2487 // << "\tp_test=" << p_test << "\tdiff="
2488 // << (p_ref-p_test).norm() << std::endl;
2489  p_test=s.f_uu(u0, v);
2490  p_ref=ribs[0].get_right_fpp().f(v);
2491  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2492 // std::cout << "p=" << p_ref
2493 // << "\tp_test=" << p_test << "\tdiff="
2494 // << (p_ref-p_test).norm() << std::endl;
2495  p_test=s.f_uu(u1, v);
2496  p_ref=ribs[1].get_left_fpp().f(v);
2497  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2498 // std::cout << "p=" << p_ref
2499 // << "\tp_test=" << p_test << "\tdiff="
2500 // << (p_ref-p_test).norm() << std::endl;
2501  v=v0+3*(v1-v0)/4;
2502  p_test=s.f(u0, v);
2503  p_ref=ribs[0].get_f().f(v);
2504  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2505 // std::cout << "p=" << p_ref
2506 // << "\tp_test=" << p_test << "\tdiff="
2507 // << (p_ref-p_test).norm() << std::endl;
2508  p_test=s.f(u1, v);
2509  p_ref=ribs[1].get_f().f(v);
2510  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2511 // std::cout << "p=" << p_ref
2512 // << "\tp_test=" << p_test << "\tdiff="
2513 // << (p_ref-p_test).norm() << std::endl;
2514  p_test=s.f_u(u0, v);
2515  p_ref=ribs[0].get_right_fp().f(v);
2516  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2517 // std::cout << "p=" << p_ref
2518 // << "\tp_test=" << p_test << "\tdiff="
2519 // << (p_ref-p_test).norm() << std::endl;
2520  p_test=s.f_u(u1, v);
2521  p_ref=ribs[1].get_left_fp().f(v);
2522  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2523 // std::cout << "p=" << p_ref
2524 // << "\tp_test=" << p_test << "\tdiff="
2525 // << (p_ref-p_test).norm() << std::endl;
2526  p_test=s.f_uu(u0, v);
2527  p_ref=ribs[0].get_right_fpp().f(v);
2528  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2529 // std::cout << "p=" << p_ref
2530 // << "\tp_test=" << p_test << "\tdiff="
2531 // << (p_ref-p_test).norm() << std::endl;
2532  p_test=s.f_uu(u1, v);
2533  p_ref=ribs[1].get_left_fpp().f(v);
2534  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2535 // std::cout << "p=" << p_ref
2536 // << "\tp_test=" << p_test << "\tdiff="
2537 // << (p_ref-p_test).norm() << std::endl;
2538 
2539 // if (rtn_flag && (typeid(data_type)==typeid(float)))
2540 // {
2541 // std::cout.flush();
2542 // eli::test::octave_start(1);
2543 // eli::test::octave_print(1, s, "surf", true);
2544 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
2545 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
2546 // eli::test::octave_print(1, ribs[0].get_f(), ribs[0].get_right_fp(), "rve0");
2547 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_left_fp(), "lve1");
2548 // eli::test::octave_finish(1);
2549 // }
2550  }
2551  }
2552 
2554  {
2555  // surface connecting 3 ribs made of 1 line segment each
2556  {
2557  index_type nsegs(2);
2558  std::vector<rib_data_type> ribs(nsegs+1);
2559  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
2560  point_type p;
2561  rib_curve_type rc1, rc2, rc3;
2562  general_creator_type gc;
2563  piecewise_surface_type s;
2564  point_type p00, p01, p10, p11, p20, p21;
2565  data_type u0(2), v0(1), u1(4), v1(5), u2(7), v;
2566  bool rtn_flag;
2567 
2568  // four corners of surface
2569  p00 << 1, 1, 1;
2570  p01 << 2, 3, 1;
2571  p10 << 3, 2, 3;
2572  p11 << 4, 4, 4;
2573  p20 << 5, 2, 5;
2574  p21 << 5, 5, 6;
2575 
2576  // create two rib curves
2577  piecewise_line_creator_type plc(1);
2578 
2579  plc.set_corner(p00, 0);
2580  plc.set_corner(p01, 1);
2581  plc.set_t0(v0);
2582  plc.set_segment_dt(v1-v0, 0);
2583  plc.create(rc1);
2584 
2585  plc.set_corner(p10, 0);
2586  plc.set_corner(p11, 1);
2587  plc.set_t0(v0);
2588  plc.set_segment_dt(v1-v0, 0);
2589  plc.create(rc2);
2590 
2591  plc.set_corner(p20, 0);
2592  plc.set_corner(p21, 1);
2593  plc.set_t0(v0);
2594  plc.set_segment_dt(v1-v0, 0);
2595  plc.create(rc3);
2596 
2597  // set the rib data
2598  ribs[0].set_f(rc1);
2599  ribs[1].set_f(rc2);
2600  ribs[2].set_f(rc3);
2601 
2602  // set the maximum degrees of each segment
2603  max_degree[0]=0;
2604  max_degree[1]=0;
2605 
2606  // create surface
2607  rtn_flag=gc.set_conditions(ribs, max_degree, false);
2608  TEST_ASSERT(rtn_flag);
2609  gc.set_u0(u0);
2610  gc.set_segment_du(u1-u0, 0);
2611  gc.set_segment_du(u2-u1, 1);
2612  rtn_flag=gc.create(s);
2613  TEST_ASSERT(rtn_flag);
2614 
2615  // test the resulting curve
2616  point_type p_test, p_ref;
2617 
2618  p_test=s.f(u0, v0);
2619  TEST_ASSERT(tol.approximately_equal(p00, p_test));
2620 // std::cout << "p=" << p00
2621 // << "\tpc=" << ribs[0].get_f().f(v0)
2622 // << "\tp_test=" << p_test << "\tdiff="
2623 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
2624  p_test=s.f(u1, v0);
2625  TEST_ASSERT(tol.approximately_equal(p10, p_test));
2626 // std::cout << "p=" << p10
2627 // << "\tpc=" << ribs[1].get_f().f(v0)
2628 // << "\tp_test=" << p_test << "\tdiff="
2629 // << (p10-p_test).norm() << std::endl;
2630  p_test=s.f(u2, v0);
2631  TEST_ASSERT(tol.approximately_equal(p20, p_test));
2632 // std::cout << "p=" << p20
2633 // << "\tpc=" << ribs[2].get_f().f(v0)
2634 // << "\tp_test=" << p_test << "\tdiff="
2635 // << (p20-p_test).norm() << std::endl;
2636  p_test=s.f(u0, v1);
2637  TEST_ASSERT(tol.approximately_equal(p01, p_test));
2638 // std::cout << "p=" << p01
2639 // << "\tpc=" << ribs[0].get_f().f(v1)
2640 // << "\tp_test=" << p_test << "\tdiff="
2641 // << (p01-p_test).norm() << std::endl;
2642  p_test=s.f(u1, v1);
2643  TEST_ASSERT(tol.approximately_equal(p11, p_test));
2644 // std::cout << "p=" << p11
2645 // << "\tpc=" << ribs[1].get_f().f(v1)
2646 // << "\tp_test=" << p_test << "\tdiff="
2647 // << (p11-p_test).norm() << std::endl;
2648  p_test=s.f(u2, v1);
2649  TEST_ASSERT(tol.approximately_equal(p21, p_test));
2650 // std::cout << "p=" << p21
2651 // << "\tpc=" << ribs[2].get_f().f(v1)
2652 // << "\tp_test=" << p_test << "\tdiff="
2653 // << (p21-p_test).norm() << std::endl;
2654  v=v0+(v1-v0)/2;
2655  p_test=s.f(u0, v);
2656  p_ref=ribs[0].get_f().f(v);
2657  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2658 // std::cout << "p=" << p_ref
2659 // << "\tp_test=" << p_test << "\tdiff="
2660 // << (p_ref-p_test).norm() << std::endl;
2661  p_test=s.f(u1, v);
2662  p_ref=ribs[1].get_f().f(v);
2663  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2664 // std::cout << "p=" << p_ref
2665 // << "\tp_test=" << p_test << "\tdiff="
2666 // << (p_ref-p_test).norm() << std::endl;
2667  p_test=s.f(u2, v);
2668  p_ref=ribs[2].get_f().f(v);
2669  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2670 // std::cout << "p=" << p_ref
2671 // << "\tp_test=" << p_test << "\tdiff="
2672 // << (p_ref-p_test).norm() << std::endl;
2673 
2674 // if (rtn_flag && (typeid(data_type)==typeid(float)))
2675 // {
2676 // std::cout.flush();
2677 // eli::test::octave_start(1);
2678 // eli::test::octave_print(1, s, "surf", true);
2679 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
2680 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
2681 // eli::test::octave_print(1, ribs[2].get_f(), "rib2", true);
2682 // eli::test::octave_finish(1);
2683 // }
2684  }
2685 
2686  // surface connecting 3 ribs made of 2 cubic segments each
2687  {
2688  index_type nsegs(2);
2689  std::vector<rib_data_type> ribs(nsegs+1);
2690  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
2691  point_type p;
2692  rib_curve_type rc1, rc2, rc3;
2693  general_creator_type gc;
2694  piecewise_surface_type s;
2695  point_type p00, p01, p10, p11, p20, p21;
2696  data_type u0(2), v0(1), u1(4), v1(5), u2(7), v;
2697  bool rtn_flag;
2698 
2699  // four corners of surface
2700  p00 << 1, 1, 1;
2701  p01 << 2, 3, 1;
2702  p10 << 3, 2, 3;
2703  p11 << 4, 4, 4;
2704  p20 << 5, 2, 5;
2705  p21 << 5, 5, 6;
2706 
2707  // create rib curves
2708  typename rib_curve_type::curve_type curve(3);
2709  typename rib_curve_type::control_point_type cp[4];
2710 
2711  // manually create cubic curves for ribs
2712  cp[0]=p00;
2713  cp[1] << 0, 2, 1;
2714  cp[2] << 1, 3, 1;
2715  cp[3]=p01;
2716  for (index_type i=0; i<4; ++i)
2717  {
2718  curve.set_control_point(cp[i], i);
2719  }
2720  rc1.push_front(curve, v1-v0);
2721  rc1.set_t0(v0);
2722  rc1.split((v0+v1)/2);
2723 
2724  cp[0]=p10;
2725  cp[1] << 1, 2, 3;
2726  cp[2] << 2, 3, 4;
2727  cp[3]=p11;
2728  for (index_type i=0; i<4; ++i)
2729  {
2730  curve.set_control_point(cp[i], i);
2731  }
2732  rc2.push_front(curve, v1-v0);
2733  rc2.set_t0(v0);
2734  rc2.split((v0+v1)/2);
2735 
2736  cp[0]=p20;
2737  cp[1] << 4, 3, 5;
2738  cp[2] << 4, 4, 6;
2739  cp[3]=p21;
2740  for (index_type i=0; i<4; ++i)
2741  {
2742  curve.set_control_point(cp[i], i);
2743  }
2744  rc3.push_front(curve, v1-v0);
2745  rc3.set_t0(v0);
2746  rc3.split((v0+v1)/2);
2747 
2748  // set the rib data
2749  ribs[0].set_f(rc1);
2750  ribs[1].set_f(rc2);
2751  ribs[2].set_f(rc3);
2752 
2753  // set the maximum degrees of each segment
2754  max_degree[0]=0;
2755  max_degree[1]=0;
2756 
2757  // create surface
2758  rtn_flag=gc.set_conditions(ribs, max_degree, false);
2759  TEST_ASSERT(rtn_flag);
2760  gc.set_u0(u0);
2761  gc.set_segment_du(u1-u0, 0);
2762  gc.set_segment_du(u2-u1, 1);
2763  rtn_flag=gc.create(s);
2764  TEST_ASSERT(rtn_flag);
2765 
2766  // test the resulting curve
2767  point_type p_test, p_ref;
2768 
2769  p_test=s.f(u0, v0);
2770  TEST_ASSERT(tol.approximately_equal(p00, p_test));
2771 // std::cout << "p=" << p00
2772 // << "\tpc=" << ribs[0].get_f().f(v0)
2773 // << "\tp_test=" << p_test << "\tdiff="
2774 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
2775  p_test=s.f(u1, v0);
2776  TEST_ASSERT(tol.approximately_equal(p10, p_test));
2777 // std::cout << "p=" << p10
2778 // << "\tpc=" << ribs[1].get_f().f(v0)
2779 // << "\tp_test=" << p_test << "\tdiff="
2780 // << (p10-p_test).norm() << std::endl;
2781  p_test=s.f(u2, v0);
2782  TEST_ASSERT(tol.approximately_equal(p20, p_test));
2783 // std::cout << "p=" << p20
2784 // << "\tpc=" << ribs[2].get_f().f(v0)
2785 // << "\tp_test=" << p_test << "\tdiff="
2786 // << (p20-p_test).norm() << std::endl;
2787  p_test=s.f(u0, v1);
2788  TEST_ASSERT(tol.approximately_equal(p01, p_test));
2789 // std::cout << "p=" << p01
2790 // << "\tpc=" << ribs[0].get_f().f(v1)
2791 // << "\tp_test=" << p_test << "\tdiff="
2792 // << (p01-p_test).norm() << std::endl;
2793  p_test=s.f(u1, v1);
2794  TEST_ASSERT(tol.approximately_equal(p11, p_test));
2795 // std::cout << "p=" << p11
2796 // << "\tpc=" << ribs[1].get_f().f(v1)
2797 // << "\tp_test=" << p_test << "\tdiff="
2798 // << (p11-p_test).norm() << std::endl;
2799  p_test=s.f(u2, v1);
2800  TEST_ASSERT(tol.approximately_equal(p21, p_test));
2801 // std::cout << "p=" << p21
2802 // << "\tpc=" << ribs[2].get_f().f(v1)
2803 // << "\tp_test=" << p_test << "\tdiff="
2804 // << (p21-p_test).norm() << std::endl;
2805  v=v0+(v1-v0)/4;
2806  p_test=s.f(u0, v);
2807  p_ref=ribs[0].get_f().f(v);
2808  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2809 // std::cout << "p=" << p_ref
2810 // << "\tp_test=" << p_test << "\tdiff="
2811 // << (p_ref-p_test).norm() << std::endl;
2812  p_test=s.f(u1, v);
2813  p_ref=ribs[1].get_f().f(v);
2814  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2815 // std::cout << "p=" << p_ref
2816 // << "\tp_test=" << p_test << "\tdiff="
2817 // << (p_ref-p_test).norm() << std::endl;
2818  p_test=s.f(u2, v);
2819  p_ref=ribs[2].get_f().f(v);
2820  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2821 // std::cout << "p=" << p_ref
2822 // << "\tp_test=" << p_test << "\tdiff="
2823 // << (p_ref-p_test).norm() << std::endl;
2824  v=v0+3*(v1-v0)/4;
2825  p_test=s.f(u0, v);
2826  p_ref=ribs[0].get_f().f(v);
2827  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2828 // std::cout << "p=" << p_ref
2829 // << "\tp_test=" << p_test << "\tdiff="
2830 // << (p_ref-p_test).norm() << std::endl;
2831  p_test=s.f(u1, v);
2832  p_ref=ribs[1].get_f().f(v);
2833  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2834 // std::cout << "p=" << p_ref
2835 // << "\tp_test=" << p_test << "\tdiff="
2836 // << (p_ref-p_test).norm() << std::endl;
2837  p_test=s.f(u2, v);
2838  p_ref=ribs[2].get_f().f(v);
2839  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
2840 // std::cout << "p=" << p_ref
2841 // << "\tp_test=" << p_test << "\tdiff="
2842 // << (p_ref-p_test).norm() << std::endl;
2843 
2844 // if (rtn_flag && (typeid(data_type)==typeid(float)))
2845 // {
2846 // std::cout.flush();
2847 // eli::test::octave_start(1);
2848 // eli::test::octave_print(1, s, "surf", true);
2849 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
2850 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
2851 // eli::test::octave_print(1, ribs[2].get_f(), "rib2", true);
2852 // eli::test::octave_finish(1);
2853 // }
2854  }
2855 
2856  // surface connecting ribs made of 3 cubic segments each, specified continuous 1st derivative
2857  {
2858  index_type nsegs(2);
2859  std::vector<rib_data_type> ribs(nsegs+1);
2860  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
2861  point_type p;
2862  rib_curve_type rc1, rc2, rc3, rs1, rs2, rs3;
2863  general_creator_type gc;
2864  piecewise_surface_type s;
2865  point_type p00, p01, p10, p11, p20, p21, s00, s01, s10, s11, s20, s21;
2866  data_type u0(2), v0(1), u1(4), v1(5), u2(7), v;
2867  bool rtn_flag;
2868 
2869  // four corners of surface
2870  p00 << 1, 1, 1;
2871  p01 << 2, 3, 1;
2872  p10 << 3, 2, 3;
2873  p11 << 4, 4, 4;
2874  p20 << 5, 2, 5;
2875  p21 << 5, 5, 6;
2876  s00 << 2, 2, 0;
2877  s01 << 1, 3, 2;
2878  s10 << 2, 1, 0;
2879  s11 << 2, 0, 1;
2880  s20 << 1, 0, 1;
2881  s21 << 1, 0, 1;
2882 
2883  // create rib curves
2884  typename rib_curve_type::curve_type curve(3);
2885  typename rib_curve_type::control_point_type cp[4];
2886 
2887  // manually create cubic curves for ribs
2888  cp[0]=p00;
2889  cp[1] << 0, 2, 1;
2890  cp[2] << 1, 3, 1;
2891  cp[3]=p01;
2892  for (index_type i=0; i<4; ++i)
2893  {
2894  curve.set_control_point(cp[i], i);
2895  }
2896  rc1.push_front(curve, v1-v0);
2897  rc1.set_t0(v0);
2898  rc1.split((v0+v1)/2);
2899 
2900  cp[0]=p10;
2901  cp[1] << 1, 2, 3;
2902  cp[2] << 2, 3, 4;
2903  cp[3]=p11;
2904  for (index_type i=0; i<4; ++i)
2905  {
2906  curve.set_control_point(cp[i], i);
2907  }
2908  rc2.push_front(curve, v1-v0);
2909  rc2.set_t0(v0);
2910  rc2.split((v0+v1)/2);
2911 
2912  cp[0]=p20;
2913  cp[1] << 4, 3, 5;
2914  cp[2] << 4, 4, 6;
2915  cp[3]=p21;
2916  for (index_type i=0; i<4; ++i)
2917  {
2918  curve.set_control_point(cp[i], i);
2919  }
2920  rc3.push_front(curve, v1-v0);
2921  rc3.set_t0(v0);
2922  rc3.split((v0+v1)/2);
2923 
2924  // create two two slope curves
2925  piecewise_line_creator_type plc(1);
2926 
2927  plc.set_corner(s00/2, 0);
2928  plc.set_corner(s01/2, 1);
2929  plc.set_t0(v0);
2930  plc.set_segment_dt(v1-v0, 0);
2931  plc.create(rs1);
2932 
2933  plc.set_corner(s10/2, 0);
2934  plc.set_corner(s11/2, 1);
2935  plc.set_t0(v0);
2936  plc.set_segment_dt(v1-v0, 0);
2937  plc.create(rs2);
2938 
2939  plc.set_corner(s20/2, 0);
2940  plc.set_corner(s21/2, 1);
2941  plc.set_t0(v0);
2942  plc.set_segment_dt(v1-v0, 0);
2943  plc.create(rs3);
2944 
2945  // set the rib data
2946  ribs[0].set_f(rc1);
2947  ribs[0].set_right_fp(rs1);
2948  ribs[1].set_f(rc2);
2949  ribs[1].set_fp(rs2);
2950  ribs[2].set_f(rc3);
2951  ribs[2].set_left_fp(rs3);
2952 
2953  // set the maximum degrees of each segment
2954  max_degree[0]=0;
2955  max_degree[1]=0;
2956 
2957  // create surface
2958  rtn_flag=gc.set_conditions(ribs, max_degree, false);
2959  TEST_ASSERT(rtn_flag);
2960  gc.set_u0(u0);
2961  gc.set_segment_du(u1-u0, 0);
2962  gc.set_segment_du(u2-u1, 1);
2963  rtn_flag=gc.create(s);
2964  TEST_ASSERT(rtn_flag);
2965 
2966  // test the resulting curve
2967  point_type p_test, p_ref;
2968 
2969  p_test=s.f(u0, v0);
2970  TEST_ASSERT(tol.approximately_equal(p00, p_test));
2971 // std::cout << "p=" << p00
2972 // << "\tpc=" << ribs[0].get_f().f(v0)
2973 // << "\tp_test=" << p_test << "\tdiff="
2974 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
2975  p_test=s.f(u1, v0);
2976  TEST_ASSERT(tol.approximately_equal(p10, p_test));
2977 // std::cout << "p=" << p10
2978 // << "\tpc=" << ribs[1].get_f().f(v0)
2979 // << "\tp_test=" << p_test << "\tdiff="
2980 // << (p10-p_test).norm() << std::endl;
2981  p_test=s.f(u2, v0);
2982  TEST_ASSERT(tol.approximately_equal(p20, p_test));
2983 // std::cout << "p=" << p20
2984 // << "\tpc=" << ribs[2].get_f().f(v0)
2985 // << "\tp_test=" << p_test << "\tdiff="
2986 // << (p20-p_test).norm() << std::endl;
2987  p_test=s.f(u0, v1);
2988  TEST_ASSERT(tol.approximately_equal(p01, p_test));
2989 // std::cout << "p=" << p01
2990 // << "\tpc=" << ribs[0].get_f().f(v1)
2991 // << "\tp_test=" << p_test << "\tdiff="
2992 // << (p01-p_test).norm() << std::endl;
2993  p_test=s.f(u1, v1);
2994  TEST_ASSERT(tol.approximately_equal(p11, p_test));
2995 // std::cout << "p=" << p11
2996 // << "\tpc=" << ribs[1].get_f().f(v1)
2997 // << "\tp_test=" << p_test << "\tdiff="
2998 // << (p11-p_test).norm() << std::endl;
2999  p_test=s.f(u2, v1);
3000  TEST_ASSERT(tol.approximately_equal(p21, p_test));
3001 // std::cout << "p=" << p21
3002 // << "\tpc=" << ribs[2].get_f().f(v1)
3003 // << "\tp_test=" << p_test << "\tdiff="
3004 // << (p21-p_test).norm() << std::endl;
3005  v=v0+(v1-v0)/4;
3006  p_test=s.f(u0, v);
3007  p_ref=ribs[0].get_f().f(v);
3008  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3009 // std::cout << "p=" << p_ref
3010 // << "\tp_test=" << p_test << "\tdiff="
3011 // << (p_ref-p_test).norm() << std::endl;
3012  p_test=s.f(u1, v);
3013  p_ref=ribs[1].get_f().f(v);
3014  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3015 // std::cout << "p=" << p_ref
3016 // << "\tp_test=" << p_test << "\tdiff="
3017 // << (p_ref-p_test).norm() << std::endl;
3018  p_test=s.f(u2, v);
3019  p_ref=ribs[2].get_f().f(v);
3020  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3021 // std::cout << "p=" << p_ref
3022 // << "\tp_test=" << p_test << "\tdiff="
3023 // << (p_ref-p_test).norm() << std::endl;
3024  p_test=s.f_u(u0, v);
3025  p_ref=ribs[0].get_right_fp().f(v);
3026  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3027 // std::cout << "p=" << p_ref
3028 // << "\tp_test=" << p_test << "\tdiff="
3029 // << (p_ref-p_test).norm() << std::endl;
3030  p_test=s.f_u(u1, v);
3031  p_ref=ribs[1].get_left_fp().f(v);
3032  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3033 // std::cout << "p=" << p_ref
3034 // << "\tp_test=" << p_test << "\tdiff="
3035 // << (p_ref-p_test).norm() << std::endl;
3036  p_test=s.f_u(u2, v);
3037  p_ref=ribs[2].get_left_fp().f(v);
3038  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3039 // std::cout << "p=" << p_ref
3040 // << "\tp_test=" << p_test << "\tdiff="
3041 // << (p_ref-p_test).norm() << std::endl;
3042  v=v0+3*(v1-v0)/4;
3043  p_test=s.f(u0, v);
3044  p_ref=ribs[0].get_f().f(v);
3045  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3046 // std::cout << "p=" << p_ref
3047 // << "\tp_test=" << p_test << "\tdiff="
3048 // << (p_ref-p_test).norm() << std::endl;
3049  p_test=s.f(u1, v);
3050  p_ref=ribs[1].get_f().f(v);
3051  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3052 // std::cout << "p=" << p_ref
3053 // << "\tp_test=" << p_test << "\tdiff="
3054 // << (p_ref-p_test).norm() << std::endl;
3055  p_test=s.f(u2, v);
3056  p_ref=ribs[2].get_f().f(v);
3057  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3058 // std::cout << "p=" << p_ref
3059 // << "\tp_test=" << p_test << "\tdiff="
3060 // << (p_ref-p_test).norm() << std::endl;
3061  p_test=s.f_u(u0, v);
3062  p_ref=ribs[0].get_right_fp().f(v);
3063  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3064 // std::cout << "p=" << p_ref
3065 // << "\tp_test=" << p_test << "\tdiff="
3066 // << (p_ref-p_test).norm() << std::endl;
3067  p_test=s.f_u(u1, v);
3068  p_ref=ribs[1].get_left_fp().f(v);
3069  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3070 // std::cout << "p=" << p_ref
3071 // << "\tp_test=" << p_test << "\tdiff="
3072 // << (p_ref-p_test).norm() << std::endl;
3073  p_test=s.f_u(u2, v);
3074  p_ref=ribs[2].get_left_fp().f(v);
3075  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3076 // std::cout << "p=" << p_ref
3077 // << "\tp_test=" << p_test << "\tdiff="
3078 // << (p_ref-p_test).norm() << std::endl;
3079 
3080 // if (rtn_flag && (typeid(data_type)==typeid(float)))
3081 // {
3082 // std::cout.flush();
3083 // eli::test::octave_start(1);
3084 // eli::test::octave_print(1, s, "surf", true);
3085 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
3086 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
3087 // eli::test::octave_print(1, ribs[2].get_f(), "rib2", true);
3088 // eli::test::octave_print(1, ribs[0].get_f(), ribs[0].get_right_fp(), "rve0");
3089 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_left_fp(), "lve1");
3090 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_right_fp(), "rve1");
3091 // eli::test::octave_print(1, ribs[2].get_f(), ribs[2].get_left_fp(), "lve2");
3092 // eli::test::octave_finish(1);
3093 // }
3094  }
3095 
3096  // surface connecting ribs made of 3 cubic segments each, specified discontinuous 1st derivative
3097  {
3098  index_type nsegs(2);
3099  std::vector<rib_data_type> ribs(nsegs+1);
3100  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
3101  point_type p;
3102  rib_curve_type rc1, rc2, rc3, rs1, rs2l, rs2r, rs3;
3103  general_creator_type gc;
3104  piecewise_surface_type s;
3105  point_type p00, p01, p10, p11, p20, p21, s00, s01, sl10, sl11, sr10, sr11, s20, s21;
3106  data_type u0(2), v0(1), u1(4), v1(5), u2(7), v;
3107  bool rtn_flag;
3108 
3109  // four corners of surface
3110  p00 << 1, 1, 1;
3111  p01 << 2, 3, 1;
3112  p10 << 3, 2, 3;
3113  p11 << 4, 4, 4;
3114  p20 << 5, 2, 5;
3115  p21 << 5, 5, 6;
3116  s00 << 2, 2, 0;
3117  s01 << 1, 3, 2;
3118  sl10 << 0, 1, 1;
3119  sl11 << 0, 0, 2;
3120  sr10 << 2, 1, 0;
3121  sr11 << 2, 0, 1;
3122  s20 << 1, 0, 1;
3123  s21 << 1, 0, 1;
3124 
3125  // create rib curves
3126  typename rib_curve_type::curve_type curve(3);
3127  typename rib_curve_type::control_point_type cp[4];
3128 
3129  // manually create cubic curves for ribs
3130  cp[0]=p00;
3131  cp[1] << 0, 2, 1;
3132  cp[2] << 1, 3, 1;
3133  cp[3]=p01;
3134  for (index_type i=0; i<4; ++i)
3135  {
3136  curve.set_control_point(cp[i], i);
3137  }
3138  rc1.push_front(curve, v1-v0);
3139  rc1.set_t0(v0);
3140  rc1.split((v0+v1)/2);
3141 
3142  cp[0]=p10;
3143  cp[1] << 1, 2, 3;
3144  cp[2] << 2, 3, 4;
3145  cp[3]=p11;
3146  for (index_type i=0; i<4; ++i)
3147  {
3148  curve.set_control_point(cp[i], i);
3149  }
3150  rc2.push_front(curve, v1-v0);
3151  rc2.set_t0(v0);
3152  rc2.split((v0+v1)/2);
3153 
3154  cp[0]=p20;
3155  cp[1] << 4, 3, 5;
3156  cp[2] << 4, 4, 6;
3157  cp[3]=p21;
3158  for (index_type i=0; i<4; ++i)
3159  {
3160  curve.set_control_point(cp[i], i);
3161  }
3162  rc3.push_front(curve, v1-v0);
3163  rc3.set_t0(v0);
3164  rc3.split((v0+v1)/2);
3165 
3166  // create two two slope curves
3167  piecewise_line_creator_type plc(1);
3168 
3169  plc.set_corner(s00/2, 0);
3170  plc.set_corner(s01/2, 1);
3171  plc.set_t0(v0);
3172  plc.set_segment_dt(v1-v0, 0);
3173  plc.create(rs1);
3174 
3175  plc.set_corner(sl10/2, 0);
3176  plc.set_corner(sl11/2, 1);
3177  plc.set_t0(v0);
3178  plc.set_segment_dt(v1-v0, 0);
3179  plc.create(rs2l);
3180 
3181  plc.set_corner(sr10/2, 0);
3182  plc.set_corner(sr11/2, 1);
3183  plc.set_t0(v0);
3184  plc.set_segment_dt(v1-v0, 0);
3185  plc.create(rs2r);
3186 
3187  plc.set_corner(s20/2, 0);
3188  plc.set_corner(s21/2, 1);
3189  plc.set_t0(v0);
3190  plc.set_segment_dt(v1-v0, 0);
3191  plc.create(rs3);
3192 
3193  // set the rib data
3194  ribs[0].set_f(rc1);
3195  ribs[0].set_right_fp(rs1);
3196  ribs[1].set_f(rc2);
3197  ribs[1].set_left_fp(rs2l);
3198  ribs[1].set_right_fp(rs2r);
3199  ribs[2].set_f(rc3);
3200  ribs[2].set_left_fp(rs3);
3201 
3202  // set the maximum degrees of each segment
3203  max_degree[0]=0;
3204  max_degree[1]=0;
3205 
3206  // create surface
3207  rtn_flag=gc.set_conditions(ribs, max_degree, false);
3208  TEST_ASSERT(rtn_flag);
3209  gc.set_u0(u0);
3210  gc.set_segment_du(u1-u0, 0);
3211  gc.set_segment_du(u2-u1, 1);
3212  rtn_flag=gc.create(s);
3213  TEST_ASSERT(rtn_flag);
3214 
3215  // test the resulting curve
3216  point_type p_test, p_ref;
3217  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
3218 
3219  p_test=s.f(u0, v0);
3220  TEST_ASSERT(tol.approximately_equal(p00, p_test));
3221 // std::cout << "p=" << p00
3222 // << "\tpc=" << ribs[0].get_f().f(v0)
3223 // << "\tp_test=" << p_test << "\tdiff="
3224 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
3225  p_test=s.f(u1, v0);
3226  TEST_ASSERT(tol.approximately_equal(p10, p_test));
3227 // std::cout << "p=" << p10
3228 // << "\tpc=" << ribs[1].get_f().f(v0)
3229 // << "\tp_test=" << p_test << "\tdiff="
3230 // << (p10-p_test).norm() << std::endl;
3231  p_test=s.f(u2, v0);
3232  TEST_ASSERT(tol.approximately_equal(p20, p_test));
3233 // std::cout << "p=" << p20
3234 // << "\tpc=" << ribs[2].get_f().f(v0)
3235 // << "\tp_test=" << p_test << "\tdiff="
3236 // << (p20-p_test).norm() << std::endl;
3237  p_test=s.f(u0, v1);
3238  TEST_ASSERT(tol.approximately_equal(p01, p_test));
3239 // std::cout << "p=" << p01
3240 // << "\tpc=" << ribs[0].get_f().f(v1)
3241 // << "\tp_test=" << p_test << "\tdiff="
3242 // << (p01-p_test).norm() << std::endl;
3243  p_test=s.f(u1, v1);
3244  TEST_ASSERT(tol.approximately_equal(p11, p_test));
3245 // std::cout << "p=" << p11
3246 // << "\tpc=" << ribs[1].get_f().f(v1)
3247 // << "\tp_test=" << p_test << "\tdiff="
3248 // << (p11-p_test).norm() << std::endl;
3249  p_test=s.f(u2, v1);
3250  TEST_ASSERT(tol.approximately_equal(p21, p_test));
3251 // std::cout << "p=" << p21
3252 // << "\tpc=" << ribs[2].get_f().f(v1)
3253 // << "\tp_test=" << p_test << "\tdiff="
3254 // << (p21-p_test).norm() << std::endl;
3255  v=v0+(v1-v0)/4;
3256  p_test=s.f(u0, v);
3257  p_ref=ribs[0].get_f().f(v);
3258  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3259 // std::cout << "p=" << p_ref
3260 // << "\tp_test=" << p_test << "\tdiff="
3261 // << (p_ref-p_test).norm() << std::endl;
3262  p_test=s.f(u1, v);
3263  p_ref=ribs[1].get_f().f(v);
3264  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3265 // std::cout << "p=" << p_ref
3266 // << "\tp_test=" << p_test << "\tdiff="
3267 // << (p_ref-p_test).norm() << std::endl;
3268  p_test=s.f(u2, v);
3269  p_ref=ribs[2].get_f().f(v);
3270  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3271 // std::cout << "p=" << p_ref
3272 // << "\tp_test=" << p_test << "\tdiff="
3273 // << (p_ref-p_test).norm() << std::endl;
3274  p_test=s.f_u(u0, v);
3275  p_ref=ribs[0].get_right_fp().f(v);
3276  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3277 // std::cout << "p=" << p_ref
3278 // << "\tp_test=" << p_test << "\tdiff="
3279 // << (p_ref-p_test).norm() << std::endl;
3280  p_test=s.f_u(u1-small_num, v);
3281  p_ref=ribs[1].get_left_fp().f(v);
3282  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3283 // std::cout << "p=" << p_ref
3284 // << "\tp_test=" << p_test << "\tdiff="
3285 // << (p_ref-p_test).norm() << std::endl;
3286  p_test=s.f_u(u1+small_num, v);
3287  p_ref=ribs[1].get_right_fp().f(v);
3288  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3289 // std::cout << "p=" << p_ref
3290 // << "\tp_test=" << p_test << "\tdiff="
3291 // << (p_ref-p_test).norm() << std::endl;
3292  p_test=s.f_u(u2, v);
3293  p_ref=ribs[2].get_left_fp().f(v);
3294  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3295 // std::cout << "p=" << p_ref
3296 // << "\tp_test=" << p_test << "\tdiff="
3297 // << (p_ref-p_test).norm() << std::endl;
3298  v=v0+3*(v1-v0)/4;
3299  p_test=s.f(u0, v);
3300  p_ref=ribs[0].get_f().f(v);
3301  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3302 // std::cout << "p=" << p_ref
3303 // << "\tp_test=" << p_test << "\tdiff="
3304 // << (p_ref-p_test).norm() << std::endl;
3305  p_test=s.f(u1, v);
3306  p_ref=ribs[1].get_f().f(v);
3307  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3308 // std::cout << "p=" << p_ref
3309 // << "\tp_test=" << p_test << "\tdiff="
3310 // << (p_ref-p_test).norm() << std::endl;
3311  p_test=s.f(u2, v);
3312  p_ref=ribs[2].get_f().f(v);
3313  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3314 // std::cout << "p=" << p_ref
3315 // << "\tp_test=" << p_test << "\tdiff="
3316 // << (p_ref-p_test).norm() << std::endl;
3317  p_test=s.f_u(u0, v);
3318  p_ref=ribs[0].get_right_fp().f(v);
3319  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3320 // std::cout << "p=" << p_ref
3321 // << "\tp_test=" << p_test << "\tdiff="
3322 // << (p_ref-p_test).norm() << std::endl;
3323  p_test=s.f_u(u1-small_num, v);
3324  p_ref=ribs[1].get_left_fp().f(v);
3325  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3326 // std::cout << "p=" << p_ref
3327 // << "\tp_test=" << p_test << "\tdiff="
3328 // << (p_ref-p_test).norm() << std::endl;
3329  p_test=s.f_u(u1+small_num, v);
3330  p_ref=ribs[1].get_right_fp().f(v);
3331  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3332 // std::cout << "p=" << p_ref
3333 // << "\tp_test=" << p_test << "\tdiff="
3334 // << (p_ref-p_test).norm() << std::endl;
3335  p_test=s.f_u(u2, v);
3336  p_ref=ribs[2].get_left_fp().f(v);
3337  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3338 // std::cout << "p=" << p_ref
3339 // << "\tp_test=" << p_test << "\tdiff="
3340 // << (p_ref-p_test).norm() << std::endl;
3341 
3342 // if (rtn_flag && (typeid(data_type)==typeid(float)))
3343 // {
3344 // std::cout.flush();
3345 // eli::test::octave_start(1);
3346 // eli::test::octave_print(1, s, "surf", true);
3347 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
3348 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
3349 // eli::test::octave_print(1, ribs[2].get_f(), "rib2", true);
3350 // eli::test::octave_print(1, ribs[0].get_f(), ribs[0].get_right_fp(), "rve0");
3351 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_left_fp(), "lve1");
3352 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_right_fp(), "rve1");
3353 // eli::test::octave_print(1, ribs[2].get_f(), ribs[2].get_left_fp(), "lve2");
3354 // eli::test::octave_finish(1);
3355 // }
3356  }
3357 
3358  // surface connecting ribs made of 3 cubic segments each, specified continuous 1st & 2nd derivatives
3359  {
3360  index_type nsegs(2);
3361  std::vector<rib_data_type> ribs(nsegs+1);
3362  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
3363  point_type p;
3364  rib_curve_type rc1, rc2, rc3, rs1, rs2, rs3, ra1, ra2, ra3;
3365  general_creator_type gc;
3366  piecewise_surface_type s;
3367  point_type p00, p01, p10, p11, p20, p21, s00, s01, s10, s11, s20, s21, a00, a01, a10, a11, a20, a21;
3368  data_type u0(2), v0(1), u1(4), v1(5), u2(7), v;
3369  bool rtn_flag;
3370 
3371  // four corners of surface
3372  p00 << 1, 1, 1;
3373  p01 << 2, 3, 1;
3374  p10 << 3, 2, 3;
3375  p11 << 4, 4, 4;
3376  p20 << 5, 2, 5;
3377  p21 << 5, 5, 6;
3378  s00 << 2, 2, 0;
3379  s01 << 1, 3, 2;
3380  s10 << 2, 1, 0;
3381  s11 << 2, 0, 1;
3382  s20 << 1, 0, 1;
3383  s21 << 1, 0, 1;
3384  a00 << 0, 1, 0;
3385  a01 << 1, 0, 1;
3386  a10 << 1, 0, 1;
3387  a11 << 0, 1, 0;
3388  a20 << 0, 1, 0;
3389  a21 << 1, 0, 1;
3390 
3391  // create rib curves
3392  typename rib_curve_type::curve_type curve(3);
3393  typename rib_curve_type::control_point_type cp[4];
3394 
3395  // manually create cubic curves for ribs
3396  cp[0]=p00;
3397  cp[1] << 0, 2, 1;
3398  cp[2] << 1, 3, 1;
3399  cp[3]=p01;
3400  for (index_type i=0; i<4; ++i)
3401  {
3402  curve.set_control_point(cp[i], i);
3403  }
3404  rc1.push_front(curve, v1-v0);
3405  rc1.set_t0(v0);
3406  rc1.split((v0+v1)/2);
3407 
3408  cp[0]=p10;
3409  cp[1] << 1, 2, 3;
3410  cp[2] << 2, 3, 4;
3411  cp[3]=p11;
3412  for (index_type i=0; i<4; ++i)
3413  {
3414  curve.set_control_point(cp[i], i);
3415  }
3416  rc2.push_front(curve, v1-v0);
3417  rc2.set_t0(v0);
3418  rc2.split((v0+v1)/2);
3419 
3420  cp[0]=p20;
3421  cp[1] << 4, 3, 5;
3422  cp[2] << 4, 4, 6;
3423  cp[3]=p21;
3424  for (index_type i=0; i<4; ++i)
3425  {
3426  curve.set_control_point(cp[i], i);
3427  }
3428  rc3.push_front(curve, v1-v0);
3429  rc3.set_t0(v0);
3430  rc3.split((v0+v1)/2);
3431 
3432  // create two two slope curves
3433  piecewise_line_creator_type plc(1);
3434 
3435  plc.set_corner(s00/2, 0);
3436  plc.set_corner(s01/2, 1);
3437  plc.set_t0(v0);
3438  plc.set_segment_dt(v1-v0, 0);
3439  plc.create(rs1);
3440 
3441  plc.set_corner(a00, 0);
3442  plc.set_corner(a01, 1);
3443  plc.set_t0(v0);
3444  plc.set_segment_dt(v1-v0, 0);
3445  plc.create(ra1);
3446 
3447  plc.set_corner(s10/2, 0);
3448  plc.set_corner(s11/2, 1);
3449  plc.set_t0(v0);
3450  plc.set_segment_dt(v1-v0, 0);
3451  plc.create(rs2);
3452 
3453  plc.set_corner(a10, 0);
3454  plc.set_corner(a11, 1);
3455  plc.set_t0(v0);
3456  plc.set_segment_dt(v1-v0, 0);
3457  plc.create(ra2);
3458 
3459  plc.set_corner(s20/2, 0);
3460  plc.set_corner(s21/2, 1);
3461  plc.set_t0(v0);
3462  plc.set_segment_dt(v1-v0, 0);
3463  plc.create(rs3);
3464 
3465  plc.set_corner(a20, 0);
3466  plc.set_corner(a21, 1);
3467  plc.set_t0(v0);
3468  plc.set_segment_dt(v1-v0, 0);
3469  plc.create(ra3);
3470 
3471  // set the rib data
3472  ribs[0].set_f(rc1);
3473  ribs[0].set_right_fp(rs1);
3474  ribs[0].set_right_fpp(ra1);
3475  ribs[1].set_f(rc2);
3476  ribs[1].set_fp(rs2);
3477  ribs[1].set_fpp(ra2);
3478  ribs[2].set_f(rc3);
3479  ribs[2].set_left_fp(rs3);
3480  ribs[2].set_left_fpp(ra3);
3481 
3482  // set the maximum degrees of each segment
3483  max_degree[0]=0;
3484  max_degree[1]=0;
3485 
3486  // create surface
3487  rtn_flag=gc.set_conditions(ribs, max_degree, false);
3488  TEST_ASSERT(rtn_flag);
3489  gc.set_u0(u0);
3490  gc.set_segment_du(u1-u0, 0);
3491  gc.set_segment_du(u2-u1, 1);
3492  rtn_flag=gc.create(s);
3493  TEST_ASSERT(rtn_flag);
3494 
3495  // test the resulting curve
3496  point_type p_test, p_ref;
3497 
3498  p_test=s.f(u0, v0);
3499  TEST_ASSERT(tol.approximately_equal(p00, p_test));
3500 // std::cout << "p=" << p00
3501 // << "\tpc=" << ribs[0].get_f().f(v0)
3502 // << "\tp_test=" << p_test << "\tdiff="
3503 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
3504  p_test=s.f(u1, v0);
3505  TEST_ASSERT(tol.approximately_equal(p10, p_test));
3506 // std::cout << "p=" << p10
3507 // << "\tpc=" << ribs[1].get_f().f(v0)
3508 // << "\tp_test=" << p_test << "\tdiff="
3509 // << (p10-p_test).norm() << std::endl;
3510  p_test=s.f(u2, v0);
3511  TEST_ASSERT(tol.approximately_equal(p20, p_test));
3512 // std::cout << "p=" << p20
3513 // << "\tpc=" << ribs[2].get_f().f(v0)
3514 // << "\tp_test=" << p_test << "\tdiff="
3515 // << (p20-p_test).norm() << std::endl;
3516  p_test=s.f(u0, v1);
3517  TEST_ASSERT(tol.approximately_equal(p01, p_test));
3518 // std::cout << "p=" << p01
3519 // << "\tpc=" << ribs[0].get_f().f(v1)
3520 // << "\tp_test=" << p_test << "\tdiff="
3521 // << (p01-p_test).norm() << std::endl;
3522  p_test=s.f(u1, v1);
3523  TEST_ASSERT(tol.approximately_equal(p11, p_test));
3524 // std::cout << "p=" << p11
3525 // << "\tpc=" << ribs[1].get_f().f(v1)
3526 // << "\tp_test=" << p_test << "\tdiff="
3527 // << (p11-p_test).norm() << std::endl;
3528  p_test=s.f(u2, v1);
3529  TEST_ASSERT(tol.approximately_equal(p21, p_test));
3530 // std::cout << "p=" << p21
3531 // << "\tpc=" << ribs[2].get_f().f(v1)
3532 // << "\tp_test=" << p_test << "\tdiff="
3533 // << (p21-p_test).norm() << std::endl;
3534  v=v0+(v1-v0)/4;
3535  p_test=s.f(u0, v);
3536  p_ref=ribs[0].get_f().f(v);
3537  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3538 // std::cout << "p=" << p_ref
3539 // << "\tp_test=" << p_test << "\tdiff="
3540 // << (p_ref-p_test).norm() << std::endl;
3541  p_test=s.f(u1, v);
3542  p_ref=ribs[1].get_f().f(v);
3543  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3544 // std::cout << "p=" << p_ref
3545 // << "\tp_test=" << p_test << "\tdiff="
3546 // << (p_ref-p_test).norm() << std::endl;
3547  p_test=s.f(u2, v);
3548  p_ref=ribs[2].get_f().f(v);
3549  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3550 // std::cout << "p=" << p_ref
3551 // << "\tp_test=" << p_test << "\tdiff="
3552 // << (p_ref-p_test).norm() << std::endl;
3553  p_test=s.f_u(u0, v);
3554  p_ref=ribs[0].get_right_fp().f(v);
3555  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3556 // std::cout << "p=" << p_ref
3557 // << "\tp_test=" << p_test << "\tdiff="
3558 // << (p_ref-p_test).norm() << std::endl;
3559  p_test=s.f_u(u1, v);
3560  p_ref=ribs[1].get_left_fp().f(v);
3561  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3562 // std::cout << "p=" << p_ref
3563 // << "\tp_test=" << p_test << "\tdiff="
3564 // << (p_ref-p_test).norm() << std::endl;
3565  p_test=s.f_u(u2, v);
3566  p_ref=ribs[2].get_left_fp().f(v);
3567  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3568 // std::cout << "p=" << p_ref
3569 // << "\tp_test=" << p_test << "\tdiff="
3570 // << (p_ref-p_test).norm() << std::endl;
3571  p_test=s.f_uu(u0, v);
3572  p_ref=ribs[0].get_right_fpp().f(v);
3573  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3574 // std::cout << "p=" << p_ref
3575 // << "\tp_test=" << p_test << "\tdiff="
3576 // << (p_ref-p_test).norm() << std::endl;
3577  p_test=s.f_uu(u1, v);
3578  p_ref=ribs[1].get_left_fpp().f(v);
3579  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3580 // std::cout << "p=" << p_ref
3581 // << "\tp_test=" << p_test << "\tdiff="
3582 // << (p_ref-p_test).norm() << std::endl;
3583  p_test=s.f_uu(u2, v);
3584  p_ref=ribs[2].get_left_fpp().f(v);
3585  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3586 // std::cout << "p=" << p_ref
3587 // << "\tp_test=" << p_test << "\tdiff="
3588 // << (p_ref-p_test).norm() << std::endl;
3589  v=v0+3*(v1-v0)/4;
3590  p_test=s.f(u0, v);
3591  p_ref=ribs[0].get_f().f(v);
3592  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3593 // std::cout << "p=" << p_ref
3594 // << "\tp_test=" << p_test << "\tdiff="
3595 // << (p_ref-p_test).norm() << std::endl;
3596  p_test=s.f(u1, v);
3597  p_ref=ribs[1].get_f().f(v);
3598  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3599 // std::cout << "p=" << p_ref
3600 // << "\tp_test=" << p_test << "\tdiff="
3601 // << (p_ref-p_test).norm() << std::endl;
3602  p_test=s.f(u2, v);
3603  p_ref=ribs[2].get_f().f(v);
3604  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3605 // std::cout << "p=" << p_ref
3606 // << "\tp_test=" << p_test << "\tdiff="
3607 // << (p_ref-p_test).norm() << std::endl;
3608  p_test=s.f_u(u0, v);
3609  p_ref=ribs[0].get_right_fp().f(v);
3610  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3611 // std::cout << "p=" << p_ref
3612 // << "\tp_test=" << p_test << "\tdiff="
3613 // << (p_ref-p_test).norm() << std::endl;
3614  p_test=s.f_u(u1, v);
3615  p_ref=ribs[1].get_left_fp().f(v);
3616  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3617 // std::cout << "p=" << p_ref
3618 // << "\tp_test=" << p_test << "\tdiff="
3619 // << (p_ref-p_test).norm() << std::endl;
3620  p_test=s.f_u(u2, v);
3621  p_ref=ribs[2].get_left_fp().f(v);
3622  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3623 // std::cout << "p=" << p_ref
3624 // << "\tp_test=" << p_test << "\tdiff="
3625 // << (p_ref-p_test).norm() << std::endl;
3626  p_test=s.f_uu(u0, v);
3627  p_ref=ribs[0].get_right_fpp().f(v);
3628  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3629 // std::cout << "p=" << p_ref
3630 // << "\tp_test=" << p_test << "\tdiff="
3631 // << (p_ref-p_test).norm() << std::endl;
3632  p_test=s.f_uu(u1, v);
3633  p_ref=ribs[1].get_left_fpp().f(v);
3634  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3635 // std::cout << "p=" << p_ref
3636 // << "\tp_test=" << p_test << "\tdiff="
3637 // << (p_ref-p_test).norm() << std::endl;
3638  p_test=s.f_uu(u2, v);
3639  p_ref=ribs[2].get_left_fpp().f(v);
3640  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3641 // std::cout << "p=" << p_ref
3642 // << "\tp_test=" << p_test << "\tdiff="
3643 // << (p_ref-p_test).norm() << std::endl;
3644 
3645 // if (rtn_flag && (typeid(data_type)==typeid(float)))
3646 // {
3647 // std::cout.flush();
3648 // eli::test::octave_start(1);
3649 // eli::test::octave_print(1, s, "surf", true);
3650 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
3651 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
3652 // eli::test::octave_print(1, ribs[2].get_f(), "rib2", true);
3653 // eli::test::octave_print(1, ribs[0].get_f(), ribs[0].get_right_fp(), "rve0");
3654 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_left_fp(), "lve1");
3655 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_right_fp(), "rve1");
3656 // eli::test::octave_print(1, ribs[2].get_f(), ribs[2].get_left_fp(), "lve2");
3657 // eli::test::octave_finish(1);
3658 // }
3659  }
3660 
3661  // surface connecting ribs made of 3 cubic segments each, specified continuous 1st derivative & discontinuous 2nd derivative
3662  {
3663  index_type nsegs(2);
3664  std::vector<rib_data_type> ribs(nsegs+1);
3665  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
3666  point_type p;
3667  rib_curve_type rc1, rc2, rc3, rs1, rs2, rs3, ra1, ra2l, ra2r, ra3;
3668  general_creator_type gc;
3669  piecewise_surface_type s;
3670  point_type p00, p01, p10, p11, p20, p21, s00, s01, s10, s11, s20, s21, a00, a01, al10, al11, ar10, ar11, a20, a21;
3671  data_type u0(2), v0(1), u1(4), v1(5), u2(7), v;
3672  bool rtn_flag;
3673 
3674  // four corners of surface
3675  p00 << 1, 1, 1;
3676  p01 << 2, 3, 1;
3677  p10 << 3, 2, 3;
3678  p11 << 4, 4, 4;
3679  p20 << 5, 2, 5;
3680  p21 << 5, 5, 6;
3681  s00 << 2, 2, 0;
3682  s01 << 1, 3, 2;
3683  s10 << 2, 1, 0;
3684  s11 << 2, 0, 1;
3685  s20 << 1, 0, 1;
3686  s21 << 1, 0, 1;
3687  a00 << 0, 1, 0;
3688  a01 << 1, 0, 1;
3689  al10 << 1, 0, 1;
3690  al11 << 0, 1, 0;
3691  ar10 << -1, 0, -1;
3692  ar11 << 0, -1, 0;
3693  a20 << 0, 1, 0;
3694  a21 << 1, 0, 1;
3695 
3696  // create rib curves
3697  typename rib_curve_type::curve_type curve(3);
3698  typename rib_curve_type::control_point_type cp[4];
3699 
3700  // manually create cubic curves for ribs
3701  cp[0]=p00;
3702  cp[1] << 0, 2, 1;
3703  cp[2] << 1, 3, 1;
3704  cp[3]=p01;
3705  for (index_type i=0; i<4; ++i)
3706  {
3707  curve.set_control_point(cp[i], i);
3708  }
3709  rc1.push_front(curve, v1-v0);
3710  rc1.set_t0(v0);
3711  rc1.split((v0+v1)/2);
3712 
3713  cp[0]=p10;
3714  cp[1] << 1, 2, 3;
3715  cp[2] << 2, 3, 4;
3716  cp[3]=p11;
3717  for (index_type i=0; i<4; ++i)
3718  {
3719  curve.set_control_point(cp[i], i);
3720  }
3721  rc2.push_front(curve, v1-v0);
3722  rc2.set_t0(v0);
3723  rc2.split((v0+v1)/2);
3724 
3725  cp[0]=p20;
3726  cp[1] << 4, 3, 5;
3727  cp[2] << 4, 4, 6;
3728  cp[3]=p21;
3729  for (index_type i=0; i<4; ++i)
3730  {
3731  curve.set_control_point(cp[i], i);
3732  }
3733  rc3.push_front(curve, v1-v0);
3734  rc3.set_t0(v0);
3735  rc3.split((v0+v1)/2);
3736 
3737  // create two two slope curves
3738  piecewise_line_creator_type plc(1);
3739 
3740  plc.set_corner(s00/2, 0);
3741  plc.set_corner(s01/2, 1);
3742  plc.set_t0(v0);
3743  plc.set_segment_dt(v1-v0, 0);
3744  plc.create(rs1);
3745 
3746  plc.set_corner(a00, 0);
3747  plc.set_corner(a01, 1);
3748  plc.set_t0(v0);
3749  plc.set_segment_dt(v1-v0, 0);
3750  plc.create(ra1);
3751 
3752  plc.set_corner(s10/2, 0);
3753  plc.set_corner(s11/2, 1);
3754  plc.set_t0(v0);
3755  plc.set_segment_dt(v1-v0, 0);
3756  plc.create(rs2);
3757 
3758  plc.set_corner(al10, 0);
3759  plc.set_corner(al11, 1);
3760  plc.set_t0(v0);
3761  plc.set_segment_dt(v1-v0, 0);
3762  plc.create(ra2l);
3763 
3764  plc.set_corner(ar10, 0);
3765  plc.set_corner(ar11, 1);
3766  plc.set_t0(v0);
3767  plc.set_segment_dt(v1-v0, 0);
3768  plc.create(ra2r);
3769 
3770  plc.set_corner(s20/2, 0);
3771  plc.set_corner(s21/2, 1);
3772  plc.set_t0(v0);
3773  plc.set_segment_dt(v1-v0, 0);
3774  plc.create(rs3);
3775 
3776  plc.set_corner(a20, 0);
3777  plc.set_corner(a21, 1);
3778  plc.set_t0(v0);
3779  plc.set_segment_dt(v1-v0, 0);
3780  plc.create(ra3);
3781 
3782  // set the rib data
3783  ribs[0].set_f(rc1);
3784  ribs[0].set_right_fp(rs1);
3785  ribs[0].set_right_fpp(ra1);
3786  ribs[1].set_f(rc2);
3787  ribs[1].set_fp(rs2);
3788  ribs[1].set_left_fpp(ra2l);
3789  ribs[1].set_right_fpp(ra2r);
3790  ribs[2].set_f(rc3);
3791  ribs[2].set_left_fp(rs3);
3792  ribs[2].set_left_fpp(ra3);
3793 
3794  // set the maximum degrees of each segment
3795  max_degree[0]=0;
3796  max_degree[1]=0;
3797 
3798  // create surface
3799  rtn_flag=gc.set_conditions(ribs, max_degree, false);
3800  TEST_ASSERT(rtn_flag);
3801  gc.set_u0(u0);
3802  gc.set_segment_du(u1-u0, 0);
3803  gc.set_segment_du(u2-u1, 1);
3804  rtn_flag=gc.create(s);
3805  TEST_ASSERT(rtn_flag);
3806 
3807  // test the resulting curve
3808  point_type p_test, p_ref;
3809  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
3810 
3811  p_test=s.f(u0, v0);
3812  TEST_ASSERT(tol.approximately_equal(p00, p_test));
3813 // std::cout << "p=" << p00
3814 // << "\tpc=" << ribs[0].get_f().f(v0)
3815 // << "\tp_test=" << p_test << "\tdiff="
3816 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
3817  p_test=s.f(u1, v0);
3818  TEST_ASSERT(tol.approximately_equal(p10, p_test));
3819 // std::cout << "p=" << p10
3820 // << "\tpc=" << ribs[1].get_f().f(v0)
3821 // << "\tp_test=" << p_test << "\tdiff="
3822 // << (p10-p_test).norm() << std::endl;
3823  p_test=s.f(u2, v0);
3824  TEST_ASSERT(tol.approximately_equal(p20, p_test));
3825 // std::cout << "p=" << p20
3826 // << "\tpc=" << ribs[2].get_f().f(v0)
3827 // << "\tp_test=" << p_test << "\tdiff="
3828 // << (p20-p_test).norm() << std::endl;
3829  p_test=s.f(u0, v1);
3830  TEST_ASSERT(tol.approximately_equal(p01, p_test));
3831 // std::cout << "p=" << p01
3832 // << "\tpc=" << ribs[0].get_f().f(v1)
3833 // << "\tp_test=" << p_test << "\tdiff="
3834 // << (p01-p_test).norm() << std::endl;
3835  p_test=s.f(u1, v1);
3836  TEST_ASSERT(tol.approximately_equal(p11, p_test));
3837 // std::cout << "p=" << p11
3838 // << "\tpc=" << ribs[1].get_f().f(v1)
3839 // << "\tp_test=" << p_test << "\tdiff="
3840 // << (p11-p_test).norm() << std::endl;
3841  p_test=s.f(u2, v1);
3842  TEST_ASSERT(tol.approximately_equal(p21, p_test));
3843 // std::cout << "p=" << p21
3844 // << "\tpc=" << ribs[2].get_f().f(v1)
3845 // << "\tp_test=" << p_test << "\tdiff="
3846 // << (p21-p_test).norm() << std::endl;
3847  v=v0+(v1-v0)/4;
3848  p_test=s.f(u0, v);
3849  p_ref=ribs[0].get_f().f(v);
3850  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3851 // std::cout << "p=" << p_ref
3852 // << "\tp_test=" << p_test << "\tdiff="
3853 // << (p_ref-p_test).norm() << std::endl;
3854  p_test=s.f(u1, v);
3855  p_ref=ribs[1].get_f().f(v);
3856  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3857 // std::cout << "p=" << p_ref
3858 // << "\tp_test=" << p_test << "\tdiff="
3859 // << (p_ref-p_test).norm() << std::endl;
3860  p_test=s.f(u2, v);
3861  p_ref=ribs[2].get_f().f(v);
3862  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3863 // std::cout << "p=" << p_ref
3864 // << "\tp_test=" << p_test << "\tdiff="
3865 // << (p_ref-p_test).norm() << std::endl;
3866  p_test=s.f_u(u0, v);
3867  p_ref=ribs[0].get_right_fp().f(v);
3868  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3869 // std::cout << "p=" << p_ref
3870 // << "\tp_test=" << p_test << "\tdiff="
3871 // << (p_ref-p_test).norm() << std::endl;
3872  p_test=s.f_u(u1, v);
3873  p_ref=ribs[1].get_left_fp().f(v);
3874  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3875 // std::cout << "p=" << p_ref
3876 // << "\tp_test=" << p_test << "\tdiff="
3877 // << (p_ref-p_test).norm() << std::endl;
3878  p_test=s.f_u(u2, v);
3879  p_ref=ribs[2].get_left_fp().f(v);
3880  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3881 // std::cout << "p=" << p_ref
3882 // << "\tp_test=" << p_test << "\tdiff="
3883 // << (p_ref-p_test).norm() << std::endl;
3884  p_test=s.f_uu(u0, v);
3885  p_ref=ribs[0].get_right_fpp().f(v);
3886  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3887 // std::cout << "p=" << p_ref
3888 // << "\tp_test=" << p_test << "\tdiff="
3889 // << (p_ref-p_test).norm() << std::endl;
3890  p_test=s.f_uu(u1-small_num, v);
3891  p_ref=ribs[1].get_left_fpp().f(v);
3892  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3893 // std::cout << "p=" << p_ref
3894 // << "\tp_test=" << p_test << "\tdiff="
3895 // << (p_ref-p_test).norm() << std::endl;
3896  p_test=s.f_uu(u1+small_num, v);
3897  p_ref=ribs[1].get_right_fpp().f(v);
3898  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3899 // std::cout << "p=" << p_ref
3900 // << "\tp_test=" << p_test << "\tdiff="
3901 // << (p_ref-p_test).norm() << std::endl;
3902  p_test=s.f_uu(u2, v);
3903  p_ref=ribs[2].get_left_fpp().f(v);
3904  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3905 // std::cout << "p=" << p_ref
3906 // << "\tp_test=" << p_test << "\tdiff="
3907 // << (p_ref-p_test).norm() << std::endl;
3908  v=v0+3*(v1-v0)/4;
3909  p_test=s.f(u0, v);
3910  p_ref=ribs[0].get_f().f(v);
3911  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3912 // std::cout << "p=" << p_ref
3913 // << "\tp_test=" << p_test << "\tdiff="
3914 // << (p_ref-p_test).norm() << std::endl;
3915  p_test=s.f(u1, v);
3916  p_ref=ribs[1].get_f().f(v);
3917  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3918 // std::cout << "p=" << p_ref
3919 // << "\tp_test=" << p_test << "\tdiff="
3920 // << (p_ref-p_test).norm() << std::endl;
3921  p_test=s.f(u2, v);
3922  p_ref=ribs[2].get_f().f(v);
3923  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3924 // std::cout << "p=" << p_ref
3925 // << "\tp_test=" << p_test << "\tdiff="
3926 // << (p_ref-p_test).norm() << std::endl;
3927  p_test=s.f_u(u0, v);
3928  p_ref=ribs[0].get_right_fp().f(v);
3929  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3930 // std::cout << "p=" << p_ref
3931 // << "\tp_test=" << p_test << "\tdiff="
3932 // << (p_ref-p_test).norm() << std::endl;
3933  p_test=s.f_u(u1, v);
3934  p_ref=ribs[1].get_left_fp().f(v);
3935  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3936 // std::cout << "p=" << p_ref
3937 // << "\tp_test=" << p_test << "\tdiff="
3938 // << (p_ref-p_test).norm() << std::endl;
3939  p_test=s.f_u(u2, v);
3940  p_ref=ribs[2].get_left_fp().f(v);
3941  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3942 // std::cout << "p=" << p_ref
3943 // << "\tp_test=" << p_test << "\tdiff="
3944 // << (p_ref-p_test).norm() << std::endl;
3945  p_test=s.f_uu(u0, v);
3946  p_ref=ribs[0].get_right_fpp().f(v);
3947  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3948 // std::cout << "p=" << p_ref
3949 // << "\tp_test=" << p_test << "\tdiff="
3950 // << (p_ref-p_test).norm() << std::endl;
3951  p_test=s.f_uu(u1-small_num, v);
3952  p_ref=ribs[1].get_left_fpp().f(v);
3953  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3954 // std::cout << "p=" << p_ref
3955 // << "\tp_test=" << p_test << "\tdiff="
3956 // << (p_ref-p_test).norm() << std::endl;
3957  p_test=s.f_uu(u1+small_num, v);
3958  p_ref=ribs[1].get_right_fpp().f(v);
3959  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3960 // std::cout << "p=" << p_ref
3961 // << "\tp_test=" << p_test << "\tdiff="
3962 // << (p_ref-p_test).norm() << std::endl;
3963  p_test=s.f_uu(u2, v);
3964  p_ref=ribs[2].get_left_fpp().f(v);
3965  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
3966 // std::cout << "p=" << p_ref
3967 // << "\tp_test=" << p_test << "\tdiff="
3968 // << (p_ref-p_test).norm() << std::endl;
3969 
3970 // if (rtn_flag && (typeid(data_type)==typeid(float)))
3971 // {
3972 // std::cout.flush();
3973 // eli::test::octave_start(1);
3974 // eli::test::octave_print(1, s, "surf", true);
3975 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
3976 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
3977 // eli::test::octave_print(1, ribs[2].get_f(), "rib2", true);
3978 // eli::test::octave_print(1, ribs[0].get_f(), ribs[0].get_right_fp(), "rve0");
3979 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_left_fp(), "lve1");
3980 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_right_fp(), "rve1");
3981 // eli::test::octave_print(1, ribs[2].get_f(), ribs[2].get_left_fp(), "lve2");
3982 // eli::test::octave_finish(1);
3983 // }
3984  }
3985 
3986  // surface connecting ribs of variying order and segment count, specified continuous 1st & 2nd derivatives
3987  {
3988  index_type nsegs(2);
3989  std::vector<rib_data_type> ribs(nsegs+1);
3990  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
3991  point_type p;
3992  rib_curve_type rc1, rc2, rc3, rs1, rs2, rs3, ra1, ra2, ra3;
3993  general_creator_type gc;
3994  piecewise_surface_type s;
3995  point_type p00, p01, p10, p11, p20, p21, s00, s01, s10, s11, s20, s21, a00, a01, a10, a11, a20, a21;
3996  data_type u0(2), v0(1), u1(4), v1(5), u2(7), v;
3997  bool rtn_flag;
3998 
3999  // four corners of surface
4000  p00 << 1, 1, 1;
4001  p01 << 2, 3, 1;
4002  p10 << 3, 2, 3;
4003  p11 << 4, 4, 4;
4004  p20 << 5, 2, 5;
4005  p21 << 5, 5, 6;
4006  s00 << 2, 2, 0;
4007  s01 << 1, 3, 2;
4008  s10 << 2, 1, 0;
4009  s11 << 2, 0, 1;
4010  s20 << 1, 0, 1;
4011  s21 << 1, 0, 1;
4012  a00 << 0, 1, 0;
4013  a01 << 1, 0, 1;
4014  a10 << 1, 0, 1;
4015  a11 << 0, 1, 0;
4016  a20 << 0, 1, 0;
4017  a21 << 1, 0, 1;
4018 
4019  // create rib curves
4020  typename rib_curve_type::curve_type curve(3);
4021  typename rib_curve_type::control_point_type cp[4];
4022 
4023  // manually create cubic curves for ribs
4024  cp[0]=p00;
4025  cp[1] << 0, 2, 1;
4026  cp[2] << 1, 3, 1;
4027  cp[3]=p01;
4028  for (index_type i=0; i<4; ++i)
4029  {
4030  curve.set_control_point(cp[i], i);
4031  }
4032  rc1.push_front(curve, v1-v0);
4033  rc1.set_t0(v0);
4034 
4035  cp[0]=p10;
4036  cp[1] << 1, 2, 3;
4037  cp[2] << 2, 3, 4;
4038  cp[3]=p11;
4039  for (index_type i=0; i<4; ++i)
4040  {
4041  curve.set_control_point(cp[i], i);
4042  }
4043  rc2.push_front(curve, v1-v0);
4044  rc2.set_t0(v0);
4045  rc2.split(v0+(v1-v0)/4);
4046 
4047  cp[0]=p20;
4048  cp[1] << 4, 3, 5;
4049  cp[2] << 4, 4, 6;
4050  cp[3]=p21;
4051  for (index_type i=0; i<4; ++i)
4052  {
4053  curve.set_control_point(cp[i], i);
4054  }
4055  rc3.push_front(curve, v1-v0);
4056  rc3.set_t0(v0);
4057  rc3.split((v0+v1)/2);
4058 
4059  // create two two slope curves
4060  piecewise_line_creator_type plc(1);
4061 
4062  plc.set_corner(p20, 0);
4063  plc.set_corner(p21, 1);
4064  plc.set_t0(v0);
4065  plc.set_segment_dt(v1-v0, 0);
4066  plc.create(rc3);
4067 
4068  plc.set_corner(s00/2, 0);
4069  plc.set_corner(s01/2, 1);
4070  plc.set_t0(v0);
4071  plc.set_segment_dt(v1-v0, 0);
4072  plc.create(rs1);
4073  rs1.split((v0+v1)/2);
4074 
4075  plc.set_corner(a00, 0);
4076  plc.set_corner(a01, 1);
4077  plc.set_t0(v0);
4078  plc.set_segment_dt(v1-v0, 0);
4079  plc.create(ra1);
4080 
4081  plc.set_corner(s10/2, 0);
4082  plc.set_corner(s11/2, 1);
4083  plc.set_t0(v0);
4084  plc.set_segment_dt(v1-v0, 0);
4085  plc.create(rs2);
4086 
4087  plc.set_corner(a10, 0);
4088  plc.set_corner(a11, 1);
4089  plc.set_t0(v0);
4090  plc.set_segment_dt(v1-v0, 0);
4091  plc.create(ra2);
4092  ra2.split(v0+4*(v1-v0)/5);
4093 
4094  plc.set_corner(s20/2, 0);
4095  plc.set_corner(s21/2, 1);
4096  plc.set_t0(v0);
4097  plc.set_segment_dt(v1-v0, 0);
4098  plc.create(rs3);
4099 
4100  plc.set_corner(a20, 0);
4101  plc.set_corner(a21, 1);
4102  plc.set_t0(v0);
4103  plc.set_segment_dt(v1-v0, 0);
4104  plc.create(ra3);
4105 
4106  // set the rib data
4107  ribs[0].set_f(rc1);
4108  ribs[0].set_right_fp(rs1);
4109  ribs[0].set_right_fpp(ra1);
4110  ribs[1].set_f(rc2);
4111  ribs[1].set_fp(rs2);
4112  ribs[1].set_fpp(ra2);
4113  ribs[2].set_f(rc3);
4114  ribs[2].set_left_fp(rs3);
4115  ribs[2].set_left_fpp(ra3);
4116 
4117  // set the maximum degrees of each segment
4118  max_degree[0]=0;
4119  max_degree[1]=0;
4120 
4121  // create surface
4122  rtn_flag=gc.set_conditions(ribs, max_degree, false);
4123  TEST_ASSERT(rtn_flag);
4124  gc.set_u0(u0);
4125  gc.set_segment_du(u1-u0, 0);
4126  gc.set_segment_du(u2-u1, 1);
4127  rtn_flag=gc.create(s);
4128  TEST_ASSERT(rtn_flag);
4129 
4130  // test the resulting curve
4131  point_type p_test, p_ref;
4132 
4133  p_test=s.f(u0, v0);
4134  TEST_ASSERT(tol.approximately_equal(p00, p_test));
4135 // std::cout << "p=" << p00
4136 // << "\tpc=" << ribs[0].get_f().f(v0)
4137 // << "\tp_test=" << p_test << "\tdiff="
4138 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
4139  p_test=s.f(u1, v0);
4140  TEST_ASSERT(tol.approximately_equal(p10, p_test));
4141 // std::cout << "p=" << p10
4142 // << "\tpc=" << ribs[1].get_f().f(v0)
4143 // << "\tp_test=" << p_test << "\tdiff="
4144 // << (p10-p_test).norm() << std::endl;
4145  p_test=s.f(u2, v0);
4146  TEST_ASSERT(tol.approximately_equal(p20, p_test));
4147 // std::cout << "p=" << p20
4148 // << "\tpc=" << ribs[2].get_f().f(v0)
4149 // << "\tp_test=" << p_test << "\tdiff="
4150 // << (p20-p_test).norm() << std::endl;
4151  p_test=s.f(u0, v1);
4152  TEST_ASSERT(tol.approximately_equal(p01, p_test));
4153 // std::cout << "p=" << p01
4154 // << "\tpc=" << ribs[0].get_f().f(v1)
4155 // << "\tp_test=" << p_test << "\tdiff="
4156 // << (p01-p_test).norm() << std::endl;
4157  p_test=s.f(u1, v1);
4158  TEST_ASSERT(tol.approximately_equal(p11, p_test));
4159 // std::cout << "p=" << p11
4160 // << "\tpc=" << ribs[1].get_f().f(v1)
4161 // << "\tp_test=" << p_test << "\tdiff="
4162 // << (p11-p_test).norm() << std::endl;
4163  p_test=s.f(u2, v1);
4164  TEST_ASSERT(tol.approximately_equal(p21, p_test));
4165 // std::cout << "p=" << p21
4166 // << "\tpc=" << ribs[2].get_f().f(v1)
4167 // << "\tp_test=" << p_test << "\tdiff="
4168 // << (p21-p_test).norm() << std::endl;
4169  v=v0+(v1-v0)/4;
4170  p_test=s.f(u0, v);
4171  p_ref=ribs[0].get_f().f(v);
4172  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4173 // std::cout << "p=" << p_ref
4174 // << "\tp_test=" << p_test << "\tdiff="
4175 // << (p_ref-p_test).norm() << std::endl;
4176  p_test=s.f(u1, v);
4177  p_ref=ribs[1].get_f().f(v);
4178  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4179 // std::cout << "p=" << p_ref
4180 // << "\tp_test=" << p_test << "\tdiff="
4181 // << (p_ref-p_test).norm() << std::endl;
4182  p_test=s.f(u2, v);
4183  p_ref=ribs[2].get_f().f(v);
4184  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4185 // std::cout << "p=" << p_ref
4186 // << "\tp_test=" << p_test << "\tdiff="
4187 // << (p_ref-p_test).norm() << std::endl;
4188  p_test=s.f_u(u0, v);
4189  p_ref=ribs[0].get_right_fp().f(v);
4190  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4191 // std::cout << "p=" << p_ref
4192 // << "\tp_test=" << p_test << "\tdiff="
4193 // << (p_ref-p_test).norm() << std::endl;
4194  p_test=s.f_u(u1, v);
4195  p_ref=ribs[1].get_left_fp().f(v);
4196  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4197 // std::cout << "p=" << p_ref
4198 // << "\tp_test=" << p_test << "\tdiff="
4199 // << (p_ref-p_test).norm() << std::endl;
4200  p_test=s.f_u(u2, v);
4201  p_ref=ribs[2].get_left_fp().f(v);
4202  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4203 // std::cout << "p=" << p_ref
4204 // << "\tp_test=" << p_test << "\tdiff="
4205 // << (p_ref-p_test).norm() << std::endl;
4206  p_test=s.f_uu(u0, v);
4207  p_ref=ribs[0].get_right_fpp().f(v);
4208  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4209 // std::cout << "p=" << p_ref
4210 // << "\tp_test=" << p_test << "\tdiff="
4211 // << (p_ref-p_test).norm() << std::endl;
4212  p_test=s.f_uu(u1, v);
4213  p_ref=ribs[1].get_left_fpp().f(v);
4214  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4215 // std::cout << "p=" << p_ref
4216 // << "\tp_test=" << p_test << "\tdiff="
4217 // << (p_ref-p_test).norm() << std::endl;
4218  p_test=s.f_uu(u2, v);
4219  p_ref=ribs[2].get_left_fpp().f(v);
4220  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4221 // std::cout << "p=" << p_ref
4222 // << "\tp_test=" << p_test << "\tdiff="
4223 // << (p_ref-p_test).norm() << std::endl;
4224  v=v0+3*(v1-v0)/4;
4225  p_test=s.f(u0, v);
4226  p_ref=ribs[0].get_f().f(v);
4227  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4228 // std::cout << "p=" << p_ref
4229 // << "\tp_test=" << p_test << "\tdiff="
4230 // << (p_ref-p_test).norm() << std::endl;
4231  p_test=s.f(u1, v);
4232  p_ref=ribs[1].get_f().f(v);
4233  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4234 // std::cout << "p=" << p_ref
4235 // << "\tp_test=" << p_test << "\tdiff="
4236 // << (p_ref-p_test).norm() << std::endl;
4237  p_test=s.f(u2, v);
4238  p_ref=ribs[2].get_f().f(v);
4239  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4240 // std::cout << "p=" << p_ref
4241 // << "\tp_test=" << p_test << "\tdiff="
4242 // << (p_ref-p_test).norm() << std::endl;
4243  p_test=s.f_u(u0, v);
4244  p_ref=ribs[0].get_right_fp().f(v);
4245  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4246 // std::cout << "p=" << p_ref
4247 // << "\tp_test=" << p_test << "\tdiff="
4248 // << (p_ref-p_test).norm() << std::endl;
4249  p_test=s.f_u(u1, v);
4250  p_ref=ribs[1].get_left_fp().f(v);
4251  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4252 // std::cout << "p=" << p_ref
4253 // << "\tp_test=" << p_test << "\tdiff="
4254 // << (p_ref-p_test).norm() << std::endl;
4255  p_test=s.f_u(u2, v);
4256  p_ref=ribs[2].get_left_fp().f(v);
4257  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4258 // std::cout << "p=" << p_ref
4259 // << "\tp_test=" << p_test << "\tdiff="
4260 // << (p_ref-p_test).norm() << std::endl;
4261  p_test=s.f_uu(u0, v);
4262  p_ref=ribs[0].get_right_fpp().f(v);
4263  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4264 // std::cout << "p=" << p_ref
4265 // << "\tp_test=" << p_test << "\tdiff="
4266 // << (p_ref-p_test).norm() << std::endl;
4267  p_test=s.f_uu(u1, v);
4268  p_ref=ribs[1].get_left_fpp().f(v);
4269  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4270 // std::cout << "p=" << p_ref
4271 // << "\tp_test=" << p_test << "\tdiff="
4272 // << (p_ref-p_test).norm() << std::endl;
4273  p_test=s.f_uu(u2, v);
4274  p_ref=ribs[2].get_left_fpp().f(v);
4275  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4276 // std::cout << "p=" << p_ref
4277 // << "\tp_test=" << p_test << "\tdiff="
4278 // << (p_ref-p_test).norm() << std::endl;
4279 
4280 // if (rtn_flag && (typeid(data_type)==typeid(float)))
4281 // {
4282 // std::cout.flush();
4283 // eli::test::octave_start(1);
4284 // eli::test::octave_print(1, s, "surf", true);
4285 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
4286 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
4287 // eli::test::octave_print(1, ribs[2].get_f(), "rib2", true);
4288 // eli::test::octave_print(1, ribs[0].get_f(), ribs[0].get_right_fp(), "rve0");
4289 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_left_fp(), "lve1");
4290 // eli::test::octave_print(1, ribs[1].get_f(), ribs[1].get_right_fp(), "rve1");
4291 // eli::test::octave_print(1, ribs[2].get_f(), ribs[2].get_left_fp(), "lve2");
4292 // eli::test::octave_finish(1);
4293 // }
4294  }
4295  }
4296 
4298  {
4299  // surface connecting 3 ribs made of 1 line segment each with C1 continuity at joint
4300  {
4301  index_type nsegs(2);
4302  std::vector<rib_data_type> ribs(nsegs+1);
4303  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
4304  point_type p;
4305  rib_curve_type rc1, rc2, rc3;
4306  general_creator_type gc;
4307  piecewise_surface_type s;
4308  point_type p00, p01, p10, p11, p20, p21;
4309  data_type u0(2), v0(1), u1(4), v1(5), u2(7), v;
4310  bool rtn_flag;
4311 
4312  // four corners of surface
4313  p00 << 1, 1, 1;
4314  p01 << 2, 3, 1;
4315  p10 << 3, 2, 3;
4316  p11 << 4, 4, 4;
4317  p20 << 5, 2, 5;
4318  p21 << 5, 5, 6;
4319 
4320  // create two rib curves
4321  piecewise_line_creator_type plc(1);
4322 
4323  plc.set_corner(p00, 0);
4324  plc.set_corner(p01, 1);
4325  plc.set_t0(v0);
4326  plc.set_segment_dt(v1-v0, 0);
4327  plc.create(rc1);
4328 
4329  plc.set_corner(p10, 0);
4330  plc.set_corner(p11, 1);
4331  plc.set_t0(v0);
4332  plc.set_segment_dt(v1-v0, 0);
4333  plc.create(rc2);
4334 
4335  plc.set_corner(p20, 0);
4336  plc.set_corner(p21, 1);
4337  plc.set_t0(v0);
4338  plc.set_segment_dt(v1-v0, 0);
4339  plc.create(rc3);
4340 
4341  // set the rib data
4342  ribs[0].set_f(rc1);
4343  ribs[1].set_f(rc2);
4344  ribs[1].set_continuity(rib_data_type::C1);
4345  ribs[2].set_f(rc3);
4346 
4347  // set the maximum degrees of each segment
4348  max_degree[0]=0;
4349  max_degree[1]=0;
4350 
4351  // create surface
4352  rtn_flag=gc.set_conditions(ribs, max_degree, false);
4353  TEST_ASSERT(rtn_flag);
4354  gc.set_u0(u0);
4355  gc.set_segment_du(u1-u0, 0);
4356  gc.set_segment_du(u2-u1, 1);
4357  rtn_flag=gc.create(s);
4358  TEST_ASSERT(rtn_flag);
4359 
4360  // test the resulting curve
4361  point_type p_test, p_ref;
4362  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
4363 
4364  p_test=s.f(u0, v0);
4365  TEST_ASSERT(tol.approximately_equal(p00, p_test));
4366 // std::cout << "p=" << p00
4367 // << "\tpc=" << ribs[0].get_f().f(v0)
4368 // << "\tp_test=" << p_test << "\tdiff="
4369 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
4370  p_test=s.f(u1, v0);
4371  TEST_ASSERT(tol.approximately_equal(p10, p_test));
4372 // std::cout << "p=" << p10
4373 // << "\tpc=" << ribs[1].get_f().f(v0)
4374 // << "\tp_test=" << p_test << "\tdiff="
4375 // << (p10-p_test).norm() << std::endl;
4376  p_test=s.f(u2, v0);
4377  TEST_ASSERT(tol.approximately_equal(p20, p_test));
4378 // std::cout << "p=" << p20
4379 // << "\tpc=" << ribs[2].get_f().f(v0)
4380 // << "\tp_test=" << p_test << "\tdiff="
4381 // << (p20-p_test).norm() << std::endl;
4382  p_test=s.f(u0, v1);
4383  TEST_ASSERT(tol.approximately_equal(p01, p_test));
4384 // std::cout << "p=" << p01
4385 // << "\tpc=" << ribs[0].get_f().f(v1)
4386 // << "\tp_test=" << p_test << "\tdiff="
4387 // << (p01-p_test).norm() << std::endl;
4388  p_test=s.f(u1, v1);
4389  TEST_ASSERT(tol.approximately_equal(p11, p_test));
4390 // std::cout << "p=" << p11
4391 // << "\tpc=" << ribs[1].get_f().f(v1)
4392 // << "\tp_test=" << p_test << "\tdiff="
4393 // << (p11-p_test).norm() << std::endl;
4394  p_test=s.f(u2, v1);
4395  TEST_ASSERT(tol.approximately_equal(p21, p_test));
4396 // std::cout << "p=" << p21
4397 // << "\tpc=" << ribs[2].get_f().f(v1)
4398 // << "\tp_test=" << p_test << "\tdiff="
4399 // << (p21-p_test).norm() << std::endl;
4400  v=v0+(v1-v0)/2;
4401  p_test=s.f(u0, v);
4402  p_ref=ribs[0].get_f().f(v);
4403  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4404 // std::cout << "p=" << p_ref
4405 // << "\tp_test=" << p_test << "\tdiff="
4406 // << (p_ref-p_test).norm() << std::endl;
4407  p_test=s.f(u1, v);
4408  p_ref=ribs[1].get_f().f(v);
4409  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4410 // std::cout << "p=" << p_ref
4411 // << "\tp_test=" << p_test << "\tdiff="
4412 // << (p_ref-p_test).norm() << std::endl;
4413  p_test=s.f(u2, v);
4414  p_ref=ribs[2].get_f().f(v);
4415  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4416 // std::cout << "p=" << p_ref
4417 // << "\tp_test=" << p_test << "\tdiff="
4418 // << (p_ref-p_test).norm() << std::endl;
4419  p_test=s.f_u(u1-small_num, v);
4420  p_ref=s.f_u(u1+small_num, v);
4421  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4422 // std::cout << "p_left=" << p_test
4423 // << "\tp_right=" << p_ref << "\tdiff="
4424 // << (p_ref-p_test).norm() << std::endl;
4425 
4426 // if (rtn_flag && (typeid(data_type)==typeid(float)))
4427 // {
4428 // std::cout.flush();
4429 // eli::test::octave_start(1);
4430 // eli::test::octave_print(1, s, "surf", true);
4431 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
4432 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
4433 // eli::test::octave_print(1, ribs[2].get_f(), "rib2", true);
4434 // eli::test::octave_finish(1);
4435 // }
4436  }
4437 
4438  // surface connecting 3 ribs made of 2 cubic segments each with C1 continuity at joint
4439  {
4440  index_type nsegs(2);
4441  std::vector<rib_data_type> ribs(nsegs+1);
4442  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
4443  point_type p;
4444  rib_curve_type rc1, rc2, rc3;
4445  general_creator_type gc;
4446  piecewise_surface_type s;
4447  point_type p00, p01, p10, p11, p20, p21;
4448  data_type u0(2), v0(1), u1(4), v1(5), u2(7), v;
4449  bool rtn_flag;
4450 
4451  // four corners of surface
4452  p00 << 1, 1, 1;
4453  p01 << 2, 3, 1;
4454  p10 << 3, 2, 3;
4455  p11 << 4, 4, 4;
4456  p20 << 5, 2, 5;
4457  p21 << 5, 5, 6;
4458 
4459  // create rib curves
4460  typename rib_curve_type::curve_type curve(3);
4461  typename rib_curve_type::control_point_type cp[4];
4462 
4463  // manually create cubic curves for ribs
4464  cp[0]=p00;
4465  cp[1] << 0, 2, 1;
4466  cp[2] << 1, 3, 1;
4467  cp[3]=p01;
4468  for (index_type i=0; i<4; ++i)
4469  {
4470  curve.set_control_point(cp[i], i);
4471  }
4472  rc1.push_front(curve, v1-v0);
4473  rc1.set_t0(v0);
4474  rc1.split((v0+v1)/2);
4475 
4476  cp[0]=p10;
4477  cp[1] << 1, 2, 3;
4478  cp[2] << 2, 3, 4;
4479  cp[3]=p11;
4480  for (index_type i=0; i<4; ++i)
4481  {
4482  curve.set_control_point(cp[i], i);
4483  }
4484  rc2.push_front(curve, v1-v0);
4485  rc2.set_t0(v0);
4486  rc2.split((v0+v1)/2);
4487 
4488  cp[0]=p20;
4489  cp[1] << 4, 3, 5;
4490  cp[2] << 4, 4, 6;
4491  cp[3]=p21;
4492  for (index_type i=0; i<4; ++i)
4493  {
4494  curve.set_control_point(cp[i], i);
4495  }
4496  rc3.push_front(curve, v1-v0);
4497  rc3.set_t0(v0);
4498  rc3.split((v0+v1)/2);
4499 
4500  // set the rib data
4501  ribs[0].set_f(rc1);
4502  ribs[1].set_f(rc2);
4503  ribs[1].set_continuity(rib_data_type::C1);
4504  ribs[2].set_f(rc3);
4505 
4506  // set the maximum degrees of each segment
4507  max_degree[0]=0;
4508  max_degree[1]=0;
4509 
4510  // create surface
4511  rtn_flag=gc.set_conditions(ribs, max_degree, false);
4512  TEST_ASSERT(rtn_flag);
4513  gc.set_u0(u0);
4514  gc.set_segment_du(u1-u0, 0);
4515  gc.set_segment_du(u2-u1, 1);
4516  rtn_flag=gc.create(s);
4517  TEST_ASSERT(rtn_flag);
4518 
4519  // test the resulting curve
4520  point_type p_test, p_ref;
4521  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
4522 
4523  p_test=s.f(u0, v0);
4524  TEST_ASSERT(tol.approximately_equal(p00, p_test));
4525 // std::cout << "p=" << p00
4526 // << "\tpc=" << ribs[0].get_f().f(v0)
4527 // << "\tp_test=" << p_test << "\tdiff="
4528 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
4529  p_test=s.f(u1, v0);
4530  TEST_ASSERT(tol.approximately_equal(p10, p_test));
4531 // std::cout << "p=" << p10
4532 // << "\tpc=" << ribs[1].get_f().f(v0)
4533 // << "\tp_test=" << p_test << "\tdiff="
4534 // << (p10-p_test).norm() << std::endl;
4535  p_test=s.f(u2, v0);
4536  TEST_ASSERT(tol.approximately_equal(p20, p_test));
4537 // std::cout << "p=" << p20
4538 // << "\tpc=" << ribs[2].get_f().f(v0)
4539 // << "\tp_test=" << p_test << "\tdiff="
4540 // << (p20-p_test).norm() << std::endl;
4541  p_test=s.f(u0, v1);
4542  TEST_ASSERT(tol.approximately_equal(p01, p_test));
4543 // std::cout << "p=" << p01
4544 // << "\tpc=" << ribs[0].get_f().f(v1)
4545 // << "\tp_test=" << p_test << "\tdiff="
4546 // << (p01-p_test).norm() << std::endl;
4547  p_test=s.f(u1, v1);
4548  TEST_ASSERT(tol.approximately_equal(p11, p_test));
4549 // std::cout << "p=" << p11
4550 // << "\tpc=" << ribs[1].get_f().f(v1)
4551 // << "\tp_test=" << p_test << "\tdiff="
4552 // << (p11-p_test).norm() << std::endl;
4553  p_test=s.f(u2, v1);
4554  TEST_ASSERT(tol.approximately_equal(p21, p_test));
4555 // std::cout << "p=" << p21
4556 // << "\tpc=" << ribs[2].get_f().f(v1)
4557 // << "\tp_test=" << p_test << "\tdiff="
4558 // << (p21-p_test).norm() << std::endl;
4559  v=v0+(v1-v0)/4;
4560  p_test=s.f(u0, v);
4561  p_ref=ribs[0].get_f().f(v);
4562  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4563 // std::cout << "p=" << p_ref
4564 // << "\tp_test=" << p_test << "\tdiff="
4565 // << (p_ref-p_test).norm() << std::endl;
4566  p_test=s.f(u1, v);
4567  p_ref=ribs[1].get_f().f(v);
4568  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4569 // std::cout << "p=" << p_ref
4570 // << "\tp_test=" << p_test << "\tdiff="
4571 // << (p_ref-p_test).norm() << std::endl;
4572  p_test=s.f(u2, v);
4573  p_ref=ribs[2].get_f().f(v);
4574  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4575 // std::cout << "p=" << p_ref
4576 // << "\tp_test=" << p_test << "\tdiff="
4577 // << (p_ref-p_test).norm() << std::endl;
4578  p_test=s.f_u(u1-small_num, v);
4579  p_ref=s.f_u(u1+small_num, v);
4580  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4581 // std::cout << "p_left=" << p_test
4582 // << "\tp_right=" << p_ref << "\tdiff="
4583 // << (p_ref-p_test).norm() << std::endl;
4584  v=v0+3*(v1-v0)/4;
4585  p_test=s.f(u0, v);
4586  p_ref=ribs[0].get_f().f(v);
4587  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4588 // std::cout << "p=" << p_ref
4589 // << "\tp_test=" << p_test << "\tdiff="
4590 // << (p_ref-p_test).norm() << std::endl;
4591  p_test=s.f(u1, v);
4592  p_ref=ribs[1].get_f().f(v);
4593  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4594 // std::cout << "p=" << p_ref
4595 // << "\tp_test=" << p_test << "\tdiff="
4596 // << (p_ref-p_test).norm() << std::endl;
4597  p_test=s.f(u2, v);
4598  p_ref=ribs[2].get_f().f(v);
4599  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4600 // std::cout << "p=" << p_ref
4601 // << "\tp_test=" << p_test << "\tdiff="
4602 // << (p_ref-p_test).norm() << std::endl;
4603  p_test=s.f_u(u1-small_num, v);
4604  p_ref=s.f_u(u1+small_num, v);
4605  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4606 // std::cout << "p_left=" << p_test
4607 // << "\tp_right=" << p_ref << "\tdiff="
4608 // << (p_ref-p_test).norm() << std::endl;
4609 
4610 // if (rtn_flag && (typeid(data_type)==typeid(float)))
4611 // {
4612 // std::cout.flush();
4613 // eli::test::octave_start(1);
4614 // eli::test::octave_print(1, s, "surf", true);
4615 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
4616 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
4617 // eli::test::octave_print(1, ribs[2].get_f(), "rib2", true);
4618 // eli::test::octave_finish(1);
4619 // }
4620  }
4621 
4622  // surface connecting 3 ribs made of 1 line segment each with C2 continuity at joint
4623  {
4624  index_type nsegs(2);
4625  std::vector<rib_data_type> ribs(nsegs+1);
4626  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
4627  point_type p;
4628  rib_curve_type rc1, rc2, rc3;
4629  general_creator_type gc;
4630  piecewise_surface_type s;
4631  point_type p00, p01, p10, p11, p20, p21;
4632  data_type u0(2), v0(1), u1(4), v1(5), u2(7), v;
4633  bool rtn_flag;
4634 
4635  // four corners of surface
4636  p00 << 1, 1, 1;
4637  p01 << 2, 3, 1;
4638  p10 << 3, 2, 3;
4639  p11 << 4, 4, 4;
4640  p20 << 5, 2, 5;
4641  p21 << 5, 5, 6;
4642 
4643  // create two rib curves
4644  piecewise_line_creator_type plc(1);
4645 
4646  plc.set_corner(p00, 0);
4647  plc.set_corner(p01, 1);
4648  plc.set_t0(v0);
4649  plc.set_segment_dt(v1-v0, 0);
4650  plc.create(rc1);
4651 
4652  plc.set_corner(p10, 0);
4653  plc.set_corner(p11, 1);
4654  plc.set_t0(v0);
4655  plc.set_segment_dt(v1-v0, 0);
4656  plc.create(rc2);
4657 
4658  plc.set_corner(p20, 0);
4659  plc.set_corner(p21, 1);
4660  plc.set_t0(v0);
4661  plc.set_segment_dt(v1-v0, 0);
4662  plc.create(rc3);
4663 
4664  // set the rib data
4665  ribs[0].set_f(rc1);
4666  ribs[1].set_f(rc2);
4667  ribs[1].set_continuity(rib_data_type::C2);
4668  ribs[2].set_f(rc3);
4669 
4670  // set the maximum degrees of each segment
4671  max_degree[0]=0;
4672  max_degree[1]=0;
4673 
4674  // create surface
4675  rtn_flag=gc.set_conditions(ribs, max_degree, false);
4676  TEST_ASSERT(rtn_flag);
4677  gc.set_u0(u0);
4678  gc.set_segment_du(u1-u0, 0);
4679  gc.set_segment_du(u2-u1, 1);
4680  rtn_flag=gc.create(s);
4681  TEST_ASSERT(rtn_flag);
4682 
4683  // test the resulting curve
4684  point_type p_test, p_ref;
4685  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
4686 
4687  p_test=s.f(u0, v0);
4688  TEST_ASSERT(tol.approximately_equal(p00, p_test));
4689 // std::cout << "p=" << p00
4690 // << "\tpc=" << ribs[0].get_f().f(v0)
4691 // << "\tp_test=" << p_test << "\tdiff="
4692 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
4693  p_test=s.f(u1, v0);
4694  TEST_ASSERT(tol.approximately_equal(p10, p_test));
4695 // std::cout << "p=" << p10
4696 // << "\tpc=" << ribs[1].get_f().f(v0)
4697 // << "\tp_test=" << p_test << "\tdiff="
4698 // << (p10-p_test).norm() << std::endl;
4699  p_test=s.f(u2, v0);
4700  TEST_ASSERT(tol.approximately_equal(p20, p_test));
4701 // std::cout << "p=" << p20
4702 // << "\tpc=" << ribs[2].get_f().f(v0)
4703 // << "\tp_test=" << p_test << "\tdiff="
4704 // << (p20-p_test).norm() << std::endl;
4705  p_test=s.f(u0, v1);
4706  TEST_ASSERT(tol.approximately_equal(p01, p_test));
4707 // std::cout << "p=" << p01
4708 // << "\tpc=" << ribs[0].get_f().f(v1)
4709 // << "\tp_test=" << p_test << "\tdiff="
4710 // << (p01-p_test).norm() << std::endl;
4711  p_test=s.f(u1, v1);
4712  TEST_ASSERT(tol.approximately_equal(p11, p_test));
4713 // std::cout << "p=" << p11
4714 // << "\tpc=" << ribs[1].get_f().f(v1)
4715 // << "\tp_test=" << p_test << "\tdiff="
4716 // << (p11-p_test).norm() << std::endl;
4717  p_test=s.f(u2, v1);
4718  TEST_ASSERT(tol.approximately_equal(p21, p_test));
4719 // std::cout << "p=" << p21
4720 // << "\tpc=" << ribs[2].get_f().f(v1)
4721 // << "\tp_test=" << p_test << "\tdiff="
4722 // << (p21-p_test).norm() << std::endl;
4723  v=v0+(v1-v0)/2;
4724  p_test=s.f(u0, v);
4725  p_ref=ribs[0].get_f().f(v);
4726  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4727 // std::cout << "p=" << p_ref
4728 // << "\tp_test=" << p_test << "\tdiff="
4729 // << (p_ref-p_test).norm() << std::endl;
4730  p_test=s.f(u1, v);
4731  p_ref=ribs[1].get_f().f(v);
4732  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4733 // std::cout << "p=" << p_ref
4734 // << "\tp_test=" << p_test << "\tdiff="
4735 // << (p_ref-p_test).norm() << std::endl;
4736  p_test=s.f(u2, v);
4737  p_ref=ribs[2].get_f().f(v);
4738  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4739 // std::cout << "p=" << p_ref
4740 // << "\tp_test=" << p_test << "\tdiff="
4741 // << (p_ref-p_test).norm() << std::endl;
4742  p_test=s.f_u(u1-small_num, v);
4743  p_ref=s.f_u(u1+small_num, v);
4744  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4745 // std::cout << "p_left=" << p_test
4746 // << "\tp_right=" << p_ref << "\tdiff="
4747 // << (p_ref-p_test).norm() << std::endl;
4748  p_test=s.f_uu(u1-small_num, v);
4749  p_ref=s.f_uu(u1+small_num, v);
4750  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4751 // std::cout << "p_left=" << p_test
4752 // << "\tp_right=" << p_ref << "\tdiff="
4753 // << (p_ref-p_test).norm() << std::endl;
4754 
4755 // if (rtn_flag && (typeid(data_type)==typeid(float)))
4756 // {
4757 // std::cout.flush();
4758 // eli::test::octave_start(1);
4759 // eli::test::octave_print(1, s, "surf", true);
4760 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
4761 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
4762 // eli::test::octave_print(1, ribs[2].get_f(), "rib2", true);
4763 // eli::test::octave_finish(1);
4764 // }
4765  }
4766 
4767  // surface connecting 3 ribs made of 2 cubic segments each with C2 continuity at joint
4768  {
4769  index_type nsegs(2);
4770  std::vector<rib_data_type> ribs(nsegs+1);
4771  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
4772  point_type p;
4773  rib_curve_type rc1, rc2, rc3;
4774  general_creator_type gc;
4775  piecewise_surface_type s;
4776  point_type p00, p01, p10, p11, p20, p21;
4777  data_type u0(2), v0(1), u1(4), v1(5), u2(7), v;
4778  bool rtn_flag;
4779 
4780  // four corners of surface
4781  p00 << 1, 1, 1;
4782  p01 << 2, 3, 1;
4783  p10 << 3, 2, 3;
4784  p11 << 4, 4, 4;
4785  p20 << 5, 2, 5;
4786  p21 << 5, 5, 6;
4787 
4788  // create rib curves
4789  typename rib_curve_type::curve_type curve(3);
4790  typename rib_curve_type::control_point_type cp[4];
4791 
4792  // manually create cubic curves for ribs
4793  cp[0]=p00;
4794  cp[1] << 0, 2, 1;
4795  cp[2] << 1, 3, 1;
4796  cp[3]=p01;
4797  for (index_type i=0; i<4; ++i)
4798  {
4799  curve.set_control_point(cp[i], i);
4800  }
4801  rc1.push_front(curve, v1-v0);
4802  rc1.set_t0(v0);
4803  rc1.split((v0+v1)/2);
4804 
4805  cp[0]=p10;
4806  cp[1] << 1, 2, 3;
4807  cp[2] << 2, 3, 4;
4808  cp[3]=p11;
4809  for (index_type i=0; i<4; ++i)
4810  {
4811  curve.set_control_point(cp[i], i);
4812  }
4813  rc2.push_front(curve, v1-v0);
4814  rc2.set_t0(v0);
4815  rc2.split((v0+v1)/2);
4816 
4817  cp[0]=p20;
4818  cp[1] << 4, 3, 5;
4819  cp[2] << 4, 4, 6;
4820  cp[3]=p21;
4821  for (index_type i=0; i<4; ++i)
4822  {
4823  curve.set_control_point(cp[i], i);
4824  }
4825  rc3.push_front(curve, v1-v0);
4826  rc3.set_t0(v0);
4827  rc3.split((v0+v1)/2);
4828 
4829  // set the rib data
4830  ribs[0].set_f(rc1);
4831  ribs[1].set_f(rc2);
4832  ribs[1].set_continuity(rib_data_type::C2);
4833  ribs[2].set_f(rc3);
4834 
4835  // set the maximum degrees of each segment
4836  max_degree[0]=0;
4837  max_degree[1]=0;
4838 
4839  // create surface
4840  rtn_flag=gc.set_conditions(ribs, max_degree, false);
4841  TEST_ASSERT(rtn_flag);
4842  gc.set_u0(u0);
4843  gc.set_segment_du(u1-u0, 0);
4844  gc.set_segment_du(u2-u1, 1);
4845  rtn_flag=gc.create(s);
4846  TEST_ASSERT(rtn_flag);
4847 
4848  // test the resulting curve
4849  point_type p_test, p_ref;
4850  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
4851 
4852  p_test=s.f(u0, v0);
4853  TEST_ASSERT(tol.approximately_equal(p00, p_test));
4854 // std::cout << "p=" << p00
4855 // << "\tpc=" << ribs[0].get_f().f(v0)
4856 // << "\tp_test=" << p_test << "\tdiff="
4857 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
4858  p_test=s.f(u1, v0);
4859  TEST_ASSERT(tol.approximately_equal(p10, p_test));
4860 // std::cout << "p=" << p10
4861 // << "\tpc=" << ribs[1].get_f().f(v0)
4862 // << "\tp_test=" << p_test << "\tdiff="
4863 // << (p10-p_test).norm() << std::endl;
4864  p_test=s.f(u2, v0);
4865  TEST_ASSERT(tol.approximately_equal(p20, p_test));
4866 // std::cout << "p=" << p20
4867 // << "\tpc=" << ribs[2].get_f().f(v0)
4868 // << "\tp_test=" << p_test << "\tdiff="
4869 // << (p20-p_test).norm() << std::endl;
4870  p_test=s.f(u0, v1);
4871  TEST_ASSERT(tol.approximately_equal(p01, p_test));
4872 // std::cout << "p=" << p01
4873 // << "\tpc=" << ribs[0].get_f().f(v1)
4874 // << "\tp_test=" << p_test << "\tdiff="
4875 // << (p01-p_test).norm() << std::endl;
4876  p_test=s.f(u1, v1);
4877  TEST_ASSERT(tol.approximately_equal(p11, p_test));
4878 // std::cout << "p=" << p11
4879 // << "\tpc=" << ribs[1].get_f().f(v1)
4880 // << "\tp_test=" << p_test << "\tdiff="
4881 // << (p11-p_test).norm() << std::endl;
4882  p_test=s.f(u2, v1);
4883  TEST_ASSERT(tol.approximately_equal(p21, p_test));
4884 // std::cout << "p=" << p21
4885 // << "\tpc=" << ribs[2].get_f().f(v1)
4886 // << "\tp_test=" << p_test << "\tdiff="
4887 // << (p21-p_test).norm() << std::endl;
4888  v=v0+(v1-v0)/4;
4889  p_test=s.f(u0, v);
4890  p_ref=ribs[0].get_f().f(v);
4891  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4892 // std::cout << "p=" << p_ref
4893 // << "\tp_test=" << p_test << "\tdiff="
4894 // << (p_ref-p_test).norm() << std::endl;
4895  p_test=s.f(u1, v);
4896  p_ref=ribs[1].get_f().f(v);
4897  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4898 // std::cout << "p=" << p_ref
4899 // << "\tp_test=" << p_test << "\tdiff="
4900 // << (p_ref-p_test).norm() << std::endl;
4901  p_test=s.f(u2, v);
4902  p_ref=ribs[2].get_f().f(v);
4903  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4904 // std::cout << "p=" << p_ref
4905 // << "\tp_test=" << p_test << "\tdiff="
4906 // << (p_ref-p_test).norm() << std::endl;
4907  p_test=s.f_u(u1-small_num, v);
4908  p_ref=s.f_u(u1+small_num, v);
4909  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4910 // std::cout << "p_left=" << p_test
4911 // << "\tp_right=" << p_ref << "\tdiff="
4912 // << (p_ref-p_test).norm() << std::endl;
4913  p_test=s.f_uu(u1-small_num, v);
4914  p_ref=s.f_uu(u1+small_num, v);
4915  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4916 // std::cout << "p_left=" << p_test
4917 // << "\tp_right=" << p_ref << "\tdiff="
4918 // << (p_ref-p_test).norm() << std::endl;
4919  v=v0+3*(v1-v0)/4;
4920  p_test=s.f(u0, v);
4921  p_ref=ribs[0].get_f().f(v);
4922  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4923 // std::cout << "p=" << p_ref
4924 // << "\tp_test=" << p_test << "\tdiff="
4925 // << (p_ref-p_test).norm() << std::endl;
4926  p_test=s.f(u1, v);
4927  p_ref=ribs[1].get_f().f(v);
4928  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4929 // std::cout << "p=" << p_ref
4930 // << "\tp_test=" << p_test << "\tdiff="
4931 // << (p_ref-p_test).norm() << std::endl;
4932  p_test=s.f(u2, v);
4933  p_ref=ribs[2].get_f().f(v);
4934  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4935 // std::cout << "p=" << p_ref
4936 // << "\tp_test=" << p_test << "\tdiff="
4937 // << (p_ref-p_test).norm() << std::endl;
4938  p_test=s.f_u(u1-small_num, v);
4939  p_ref=s.f_u(u1+small_num, v);
4940  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4941 // std::cout << "p_left=" << p_test
4942 // << "\tp_right=" << p_ref << "\tdiff="
4943 // << (p_ref-p_test).norm() << std::endl;
4944  p_test=s.f_uu(u1-small_num, v);
4945  p_ref=s.f_uu(u1+small_num, v);
4946  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
4947 // std::cout << "p_left=" << p_test
4948 // << "\tp_right=" << p_ref << "\tdiff="
4949 // << (p_ref-p_test).norm() << std::endl;
4950 
4951 // if (rtn_flag && (typeid(data_type)==typeid(float)))
4952 // {
4953 // std::cout.flush();
4954 // eli::test::octave_start(1);
4955 // eli::test::octave_print(1, s, "surf", true);
4956 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
4957 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
4958 // eli::test::octave_print(1, ribs[2].get_f(), "rib2", true);
4959 // eli::test::octave_finish(1);
4960 // }
4961  }
4962  }
4963 
4965  {
4966  // surface connecting 3 ribs made of 1 line segment each with C1 continuity at joint
4967  {
4968  index_type nsegs(2);
4969  std::vector<rib_data_type> ribs(nsegs+1);
4970  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
4971  point_type p;
4972  rib_curve_type rc1, rc2, rc3;
4973  general_creator_type gc;
4974  piecewise_surface_type s;
4975  point_type p00, p01, p10, p11, p20, p21;
4976  data_type u0(2), v0(1), u1(4), v1(5), u2(7), v;
4977  bool rtn_flag;
4978 
4979  // four corners of surface
4980  p00 << 1, 1, 1;
4981  p01 << 2, 3, 1;
4982  p10 << 3, 2, 3;
4983  p11 << 4, 4, 4;
4984  p20 << 5, 2, 5;
4985  p21 << 5, 5, 6;
4986 
4987  // create two rib curves
4988  piecewise_line_creator_type plc(1);
4989 
4990  plc.set_corner(p00, 0);
4991  plc.set_corner(p01, 1);
4992  plc.set_t0(v0);
4993  plc.set_segment_dt(v1-v0, 0);
4994  plc.create(rc1);
4995 
4996  plc.set_corner(p10, 0);
4997  plc.set_corner(p11, 1);
4998  plc.set_t0(v0);
4999  plc.set_segment_dt(v1-v0, 0);
5000  plc.create(rc2);
5001 
5002  plc.set_corner(p20, 0);
5003  plc.set_corner(p21, 1);
5004  plc.set_t0(v0);
5005  plc.set_segment_dt(v1-v0, 0);
5006  plc.create(rc3);
5007 
5008  // set the rib data
5009  ribs[0].set_f(rc1);
5010  ribs[1].set_f(rc2);
5011  ribs[1].set_continuity(rib_data_type::C1);
5012  ribs[2].set_f(rc3);
5013 
5014  // set the maximum degrees of each segment
5015  max_degree[0]=1;
5016  max_degree[1]=0;
5017 
5018  // create surface
5019  rtn_flag=gc.set_conditions(ribs, max_degree, false);
5020  TEST_ASSERT(rtn_flag);
5021  gc.set_u0(u0);
5022  gc.set_segment_du(u1-u0, 0);
5023  gc.set_segment_du(u2-u1, 1);
5024  rtn_flag=gc.create(s);
5025  TEST_ASSERT(rtn_flag);
5026 
5027  // test the resulting curve
5028  point_type p_test, p_ref;
5029  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
5030 
5031  p_test=s.f(u0, v0);
5032  TEST_ASSERT(tol.approximately_equal(p00, p_test));
5033 // std::cout << "p=" << p00
5034 // << "\tpc=" << ribs[0].get_f().f(v0)
5035 // << "\tp_test=" << p_test << "\tdiff="
5036 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
5037  p_test=s.f(u1, v0);
5038  TEST_ASSERT(tol.approximately_equal(p10, p_test));
5039 // std::cout << "p=" << p10
5040 // << "\tpc=" << ribs[1].get_f().f(v0)
5041 // << "\tp_test=" << p_test << "\tdiff="
5042 // << (p10-p_test).norm() << std::endl;
5043  p_test=s.f(u2, v0);
5044  TEST_ASSERT(tol.approximately_equal(p20, p_test));
5045 // std::cout << "p=" << p20
5046 // << "\tpc=" << ribs[2].get_f().f(v0)
5047 // << "\tp_test=" << p_test << "\tdiff="
5048 // << (p20-p_test).norm() << std::endl;
5049  p_test=s.f(u0, v1);
5050  TEST_ASSERT(tol.approximately_equal(p01, p_test));
5051 // std::cout << "p=" << p01
5052 // << "\tpc=" << ribs[0].get_f().f(v1)
5053 // << "\tp_test=" << p_test << "\tdiff="
5054 // << (p01-p_test).norm() << std::endl;
5055  p_test=s.f(u1, v1);
5056  TEST_ASSERT(tol.approximately_equal(p11, p_test));
5057 // std::cout << "p=" << p11
5058 // << "\tpc=" << ribs[1].get_f().f(v1)
5059 // << "\tp_test=" << p_test << "\tdiff="
5060 // << (p11-p_test).norm() << std::endl;
5061  p_test=s.f(u2, v1);
5062  TEST_ASSERT(tol.approximately_equal(p21, p_test));
5063 // std::cout << "p=" << p21
5064 // << "\tpc=" << ribs[2].get_f().f(v1)
5065 // << "\tp_test=" << p_test << "\tdiff="
5066 // << (p21-p_test).norm() << std::endl;
5067  v=v0+(v1-v0)/2;
5068  p_test=s.f(u0, v);
5069  p_ref=ribs[0].get_f().f(v);
5070  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
5071 // std::cout << "p=" << p_ref
5072 // << "\tp_test=" << p_test << "\tdiff="
5073 // << (p_ref-p_test).norm() << std::endl;
5074  p_test=s.f(u1, v);
5075  p_ref=ribs[1].get_f().f(v);
5076  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
5077 // std::cout << "p=" << p_ref
5078 // << "\tp_test=" << p_test << "\tdiff="
5079 // << (p_ref-p_test).norm() << std::endl;
5080  p_test=s.f(u2, v);
5081  p_ref=ribs[2].get_f().f(v);
5082  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
5083 // std::cout << "p=" << p_ref
5084 // << "\tp_test=" << p_test << "\tdiff="
5085 // << (p_ref-p_test).norm() << std::endl;
5086  p_test=s.f_u(u1-small_num, v);
5087  p_ref=s.f_u(u1+small_num, v);
5088  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
5089 // std::cout << "p_left=" << p_test
5090 // << "\tp_right=" << p_ref << "\tdiff="
5091 // << (p_ref-p_test).norm() << std::endl;
5092 
5093 // if (rtn_flag && (typeid(data_type)==typeid(float)))
5094 // {
5095 // std::cout.flush();
5096 // eli::test::octave_start(1);
5097 // eli::test::octave_print(1, s, "surf", true);
5098 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
5099 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
5100 // eli::test::octave_print(1, ribs[2].get_f(), "rib2", true);
5101 // eli::test::octave_finish(1);
5102 // }
5103  }
5104 
5105  // surface connecting 3 ribs made of 1 line segment each with C2 continuity at rib and limit first patch to 1st order
5106  {
5107  index_type nsegs(2);
5108  std::vector<rib_data_type> ribs(nsegs+1);
5109  std::vector<typename general_creator_type::index_type> max_degree(nsegs);
5110  point_type p;
5111  rib_curve_type rc1, rc2, rc3;
5112  general_creator_type gc;
5113  piecewise_surface_type s;
5114  point_type p00, p01, p10, p11, p20, p21;
5115  data_type u0(2), v0(1), u1(4), v1(5), u2(7), v;
5116  bool rtn_flag;
5117 
5118  // four corners of surface
5119  p00 << 1, 1, 1;
5120  p01 << 2, 3, 1;
5121  p10 << 3, 2, 3;
5122  p11 << 4, 4, 4;
5123  p20 << 5, 2, 5;
5124  p21 << 5, 5, 6;
5125 
5126  // create two rib curves
5127  piecewise_line_creator_type plc(1);
5128 
5129  plc.set_corner(p00, 0);
5130  plc.set_corner(p01, 1);
5131  plc.set_t0(v0);
5132  plc.set_segment_dt(v1-v0, 0);
5133  plc.create(rc1);
5134 
5135  plc.set_corner(p10, 0);
5136  plc.set_corner(p11, 1);
5137  plc.set_t0(v0);
5138  plc.set_segment_dt(v1-v0, 0);
5139  plc.create(rc2);
5140 
5141  plc.set_corner(p20, 0);
5142  plc.set_corner(p21, 1);
5143  plc.set_t0(v0);
5144  plc.set_segment_dt(v1-v0, 0);
5145  plc.create(rc3);
5146 
5147  // set the rib data
5148  ribs[0].set_f(rc1);
5149  ribs[1].set_f(rc2);
5150  ribs[1].set_continuity(rib_data_type::C2);
5151  ribs[2].set_f(rc3);
5152 
5153  // set the maximum degrees of each segment to be too small
5154  max_degree[0]=1;
5155  max_degree[1]=1;
5156  rtn_flag=gc.set_conditions(ribs, max_degree, false);
5157  TEST_ASSERT(rtn_flag);
5158  rtn_flag=gc.create(s);
5159  TEST_ASSERT(!rtn_flag);
5160 
5161  // set the maximum degree to be unlimited
5162  max_degree[1]=0;
5163 
5164  // create surface
5165  rtn_flag=gc.set_conditions(ribs, max_degree, false);
5166  TEST_ASSERT(rtn_flag);
5167  gc.set_u0(u0);
5168  gc.set_segment_du(u1-u0, 0);
5169  gc.set_segment_du(u2-u1, 1);
5170  rtn_flag=gc.create(s);
5171  TEST_ASSERT(rtn_flag);
5172 
5173  // test the resulting curve
5174  point_type p_test, p_ref;
5175  data_type small_num(100*std::numeric_limits<data_type>::epsilon());
5176 
5177  p_test=s.f(u0, v0);
5178  TEST_ASSERT(tol.approximately_equal(p00, p_test));
5179 // std::cout << "p=" << p00
5180 // << "\tpc=" << ribs[0].get_f().f(v0)
5181 // << "\tp_test=" << p_test << "\tdiff="
5182 // << (ribs[0].get_f().f(v0)-p_test).norm() << std::endl;
5183  p_test=s.f(u1, v0);
5184  TEST_ASSERT(tol.approximately_equal(p10, p_test));
5185 // std::cout << "p=" << p10
5186 // << "\tpc=" << ribs[1].get_f().f(v0)
5187 // << "\tp_test=" << p_test << "\tdiff="
5188 // << (p10-p_test).norm() << std::endl;
5189  p_test=s.f(u2, v0);
5190  TEST_ASSERT(tol.approximately_equal(p20, p_test));
5191 // std::cout << "p=" << p20
5192 // << "\tpc=" << ribs[2].get_f().f(v0)
5193 // << "\tp_test=" << p_test << "\tdiff="
5194 // << (p20-p_test).norm() << std::endl;
5195  p_test=s.f(u0, v1);
5196  TEST_ASSERT(tol.approximately_equal(p01, p_test));
5197 // std::cout << "p=" << p01
5198 // << "\tpc=" << ribs[0].get_f().f(v1)
5199 // << "\tp_test=" << p_test << "\tdiff="
5200 // << (p01-p_test).norm() << std::endl;
5201  p_test=s.f(u1, v1);
5202  TEST_ASSERT(tol.approximately_equal(p11, p_test));
5203 // std::cout << "p=" << p11
5204 // << "\tpc=" << ribs[1].get_f().f(v1)
5205 // << "\tp_test=" << p_test << "\tdiff="
5206 // << (p11-p_test).norm() << std::endl;
5207  p_test=s.f(u2, v1);
5208  TEST_ASSERT(tol.approximately_equal(p21, p_test));
5209 // std::cout << "p=" << p21
5210 // << "\tpc=" << ribs[2].get_f().f(v1)
5211 // << "\tp_test=" << p_test << "\tdiff="
5212 // << (p21-p_test).norm() << std::endl;
5213  v=v0+(v1-v0)/2;
5214  p_test=s.f(u0, v);
5215  p_ref=ribs[0].get_f().f(v);
5216  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
5217 // std::cout << "p=" << p_ref
5218 // << "\tp_test=" << p_test << "\tdiff="
5219 // << (p_ref-p_test).norm() << std::endl;
5220  p_test=s.f(u1, v);
5221  p_ref=ribs[1].get_f().f(v);
5222  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
5223 // std::cout << "p=" << p_ref
5224 // << "\tp_test=" << p_test << "\tdiff="
5225 // << (p_ref-p_test).norm() << std::endl;
5226  p_test=s.f(u2, v);
5227  p_ref=ribs[2].get_f().f(v);
5228  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
5229 // std::cout << "p=" << p_ref
5230 // << "\tp_test=" << p_test << "\tdiff="
5231 // << (p_ref-p_test).norm() << std::endl;
5232  p_test=s.f_u(u1-small_num, v);
5233  p_ref=s.f_u(u1+small_num, v);
5234  TEST_ASSERT(tol.approximately_equal(p_test, p_ref));
5235 // std::cout << "p_left=" << p_test
5236 // << "\tp_right=" << p_ref << "\tdiff="
5237 // << (p_ref-p_test).norm() << std::endl;
5238 
5239 // if (rtn_flag && (typeid(data_type)==typeid(float)))
5240 // {
5241 // std::cout.flush();
5242 // eli::test::octave_start(1);
5243 // eli::test::octave_print(1, s, "surf", true);
5244 // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true);
5245 // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true);
5246 // eli::test::octave_print(1, ribs[2].get_f(), "rib2", true);
5247 // eli::test::octave_finish(1);
5248 // }
5249  }
5250  }
5251 };
5252 
5253 #endif
5254 
eli::geom::curve::piecewise< eli::geom::curve::bezier, data__, 3 > piecewise_curve_type
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:40
bool set_right_fp(const curve_type &fpr)
Definition: piecewise_connection_data.hpp:409
void create_multirib_coupled_surface_test()
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:4297
bool set_fpp(const curve_type &p)
Definition: piecewise_connection_data.hpp:501
const curve_type & get_f() const
Definition: piecewise_connection_data.hpp:383
surface_type::point_type point_type
Definition: piecewise.hpp:59
bool unset_right_fp()
Definition: piecewise_connection_data.hpp:456
piecewise_surface_type::surface_type surface_type
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:41
void get_parameters(it__ itt) const
Definition: piecewise.hpp:380
bool use_left_fpp() const
Definition: piecewise_connection_data.hpp:541
void AddTests(const long double &)
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:74
bool check_state() const
Definition: piecewise_connection_data.hpp:560
eli::geom::surface::connection_data< data__, 3, tolerance_type > rib_data_type
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:46
void create_single_surface_test()
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:730
data_type get_tmax() const
Definition: piecewise.hpp:333
Definition: piecewise_linear_creator.hpp:31
void AddTests(const double &)
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:64
Definition: piecewise_connection_data.hpp:46
void set_segment_dt(const data_type &dtt, const index_type &i)
Definition: piecewise_creator_base.hpp:64
piecewise_surface_type::index_type index_type
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:44
const curve_type & get_left_fpp() const
Definition: piecewise_connection_data.hpp:509
eli::geom::surface::piecewise< eli::geom::surface::bezier, data__, 3 > piecewise_surface_type
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:39
data__ data_type
Definition: piecewise.hpp:66
point_type f_u(const data_type &u, const data_type &v) const
Definition: piecewise.hpp:910
bool unset_fpp()
Definition: piecewise_connection_data.hpp:523
bool set_right_fpp(const curve_type &fppr)
Definition: piecewise_connection_data.hpp:487
connection_continuity get_continuity() const
Definition: piecewise_connection_data.hpp:555
point_type f(const data_type &u, const data_type &v) const
Definition: piecewise.hpp:897
bool set_continuity(connection_continuity jc)
Definition: piecewise_connection_data.hpp:550
const curve_type & get_right_fp() const
Definition: piecewise_connection_data.hpp:435
bool use_right_fp() const
Definition: piecewise_connection_data.hpp:467
Definition: piecewise.hpp:37
void set_u0(const data_type &uu0)
Definition: piecewise_general_skinning_surface_creator.hpp:76
Definition: piecewise.hpp:244
error_code push_front(const curve_type &curve, const data_type &dt=1.0)
Definition: piecewise.hpp:646
void create_rib_test()
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:95
eli::geom::curve::piecewise_linear_creator< data__, 3, tolerance_type > piecewise_line_creator_type
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:48
Definition: piecewise_general_skinning_surface_creator.hpp:40
Definition: piecewise_connection_data.hpp:48
eli::geom::surface::piecewise_general_skinning_surface_creator< data__, 3, tolerance_type > general_creator_type
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:49
bool set_conditions(const std::vector< rib_data_type > &rbs, const std::vector< index_type > &maxd, bool cl=false)
Definition: piecewise_general_skinning_surface_creator.hpp:83
const curve_type & get_right_fpp() const
Definition: piecewise_connection_data.hpp:513
rib_data_type::curve_type rib_curve_type
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:47
piecewise_general_skinning_surface_creator_test_suite()
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:86
bool set_left_fpp(const curve_type &fppl)
Definition: piecewise_connection_data.hpp:473
bool use_right_fpp() const
Definition: piecewise_connection_data.hpp:545
void create_multijoint_rib_single_surface_test()
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:1481
bool unset_right_fpp()
Definition: piecewise_connection_data.hpp:534
void set_segment_du(const data_type &duu, const index_type &i)
Definition: piecewise_general_skinning_surface_creator.hpp:78
Definition: piecewise_connection_data.hpp:32
void AddTests(const float &)
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:54
tol__ tolerance_type
Definition: piecewise.hpp:68
const curve_type & get_left_fp() const
Definition: piecewise_connection_data.hpp:431
void split(it1__ itb, it1__ ite, it2__ itd)
Definition: piecewise_connection_data.hpp:225
void create_multirib_surface_test()
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:2553
point_type f_uu(const data_type &u, const data_type &v) const
Definition: piecewise.hpp:942
virtual bool create(piecewise< bezier, data_type, dim__, tolerance_type > &pc) const
Definition: piecewise_linear_creator.hpp:63
void get_joints(output_it__ it_in) const
Definition: piecewise_connection_data.hpp:135
bool set_left_fp(const curve_type &fpl)
Definition: piecewise_connection_data.hpp:395
tolerance_type tol
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:51
surface_type::index_type index_type
Definition: piecewise.hpp:58
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:36
bool unset_f()
Definition: piecewise_connection_data.hpp:384
void create_max_degree_surface_test()
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:4964
bool set_fp(const curve_type &p)
Definition: piecewise_connection_data.hpp:423
bool use_left_fp() const
Definition: piecewise_connection_data.hpp:463
void set_corner(const point_type &c, const index_type &i)
Definition: piecewise_linear_creator.hpp:46
piecewise_surface_type::data_type data_type
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:43
data_type get_t0() const
Definition: piecewise.hpp:335
bool use_f() const
Definition: piecewise_connection_data.hpp:389
void set_control_point(const control_point_type &cp, const index_type &i)
Definition: bezier.hpp:201
bool set_f(const curve_type &ff)
Definition: piecewise_connection_data.hpp:377
~piecewise_general_skinning_surface_creator_test_suite()
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:90
void set_t0(const data_type &t0_in)
Definition: piecewise.hpp:340
Definition: piecewise_connection_data.hpp:47
piecewise_surface_type::tolerance_type tolerance_type
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:45
error_code split(const data_type &t)
Definition: piecewise.hpp:1055
bool unset_left_fpp()
Definition: piecewise_connection_data.hpp:528
curve_type::control_point_type control_point_type
Definition: piecewise.hpp:273
bool unset_fp()
Definition: piecewise_connection_data.hpp:445
Definition: bezier.hpp:109
void set_t0(const data_type &tt0)
Definition: piecewise_creator_base.hpp:61
surface__< data__, dim__, tol__ > surface_type
Definition: piecewise.hpp:57
virtual bool create(piecewise_surface_type &ps) const
Definition: piecewise_general_skinning_surface_creator.hpp:165
bool unset_left_fp()
Definition: piecewise_connection_data.hpp:450
piecewise_surface_type::point_type point_type
Definition: piecewise_general_skinning_surface_creator_test_suite.hpp:42