param_func.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Software License Agreement (BSD License) *
3  * Copyright (C) 2016 by Horatiu George Todoran <todorangrg@gmail.com> *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions *
7  * are met: *
8  * *
9  * 1. Redistributions of source code must retain the above copyright *
10  * notice, this list of conditions and the following disclaimer. *
11  * 2. Redistributions in binary form must reproduce the above copyright *
12  * notice, this list of conditions and the following disclaimer in *
13  * the documentation and/or other materials provided with the *
14  * distribution. *
15  * 3. Neither the name of the copyright holder nor the names of its *
16  * contributors may be used to endorse or promote products derived *
17  * from this software without specific prior written permission. *
18  * *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
23  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, *
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER *
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY *
29  * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
30  * POSSIBILITY OF SUCH DAMAGE. *
31  ***************************************************************************/
32 
33 #ifndef PARAM_FUNC_HPP
34 #define PARAM_FUNC_HPP
35 
36 #include <memory>
37 #include <vector>
38 #include <map>
39 #include <tuw_control/utils.h>
40 
41 namespace tuw
42 {
43 // enums
45 enum class FuncEvalMode
46 {
47  DIFF1,
48  DIFF2,
49  INT1,
50  INT2,
51  FUNC,
52  ENUM_SIZE
53 };
55 enum class CtrlPtDim
56 {
57  VAL,
58  ARC
59 };
61 enum class EvalArcGuarantee
62 {
63  NONE,
64  NEAR_LAST,
65  AT_BEGIN,
66  AT_END
67 };
68 
71 static constexpr const std::size_t nrModesMax_ = asInt(FuncEvalMode::ENUM_SIZE) - 1;
72 using FuncEvalModesFlags = std::array<bool, nrModesMax_>;
73 
74 // structs
77 {
78  ParamFuncsStructure() : ctrlPtsSize(0), ctrlPtsArcRefIdx(0), evalReq()
79  {
80  evalReq.fill(false);
81  }
82  std::size_t ctrlPtsSize;
83  std::size_t ctrlPtsArcRefIdx;
85  FuncEvalModesFlags evalReq;
88 };
90 template <typename TNumType>
91 struct FuncCtrlPt
92 {
93  FuncCtrlPt(const TNumType& _val, TNumType& _arc) : val(_val), arc(_arc)
94  {
95  }
96  TNumType val;
97  TNumType& arc;
98 };
99 
100 namespace
101 {
102 template <class TDerived>
103 struct ParamFuncsBaseCRTPTraits;
104 }
105 
106 template <typename TDerived>
108 {
109 protected:
111 
112 protected:
113  using NumType = typename ParamFuncsBaseCRTPTraits<TDerived>::NumType;
114 
115 protected:
117 
118  // special class member functions
119 public:
120  ParamFuncsBaseCRTP() = default;
121 
122 public:
123  ~ParamFuncsBaseCRTP() = default;
124 
125 public:
126  ParamFuncsBaseCRTP(const ParamFuncsBaseCRTP&) = default;
127 
128 public:
129  ParamFuncsBaseCRTP& operator=(const ParamFuncsBaseCRTP&) = default;
130 
131 public:
133 
134 public:
135  ParamFuncsBaseCRTP& operator=(ParamFuncsBaseCRTP&&) = default;
136 
155 public:
156  template <typename TParamFucsStructVecArr>
157  void init(const TParamFucsStructVecArr& _paramFuncsStructure)
158  {
159  thisDerived().initImplCRTP(_paramFuncsStructure);
160  }
162 public:
163  std::size_t funcsSize() const
164  {
165  return thisDerived().funcsSizeImplCRTP();
166  }
168 public:
169  std::size_t funcsArcSize() const
170  {
171  return thisDerived().funcsArcSizeImplCRTP();
172  }
174 public:
175  std::size_t funcsArcSize(const std::size_t& _i) const
176  {
177  return thisDerived().funcsArcSizeImplCRTP(_i);
178  }
180 public:
181  std::size_t funcCtrlPtSize(const std::size_t& _i) const
182  {
183  return thisDerived().funcCtrlPtSizeImplCRTP(_i);
184  }
186 public:
188  {
189  return thisDerived().funcsArcBeginImplCRTP();
190  }
192 public:
193  const NumType& funcsArcBegin() const
194  {
195  return thisDerived().funcsArcBeginImplCRTP();
196  }
198 public:
200  {
201  return thisDerived().funcsArcEndImplCRTP();
202  }
204 public:
205  const NumType& funcsArcEnd() const
206  {
207  return thisDerived().funcsArcEndImplCRTP();
208  }
210 public:
211  const NumType& funcsArcEval() const
212  {
213  return thisDerived().funcsArcEvalImplCRTP();
214  }
216 public:
217  NumType& funcsArc(const std::size_t& _i, const std::size_t& _j)
218  {
219  return thisDerived().funcsArcImplCRTP(_i, _j);
220  }
222 public:
223  const NumType& funcsArc(const std::size_t& _i, const std::size_t& _j) const
224  {
225  return thisDerived().funcsArcImplCRTP(_i, _j);
226  }
228 public:
229  FuncCtrlPtType& ctrlPt(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx)
230  {
231  return thisDerived().ctrlPtImplCRTP(_funcIdx, _funcCtrlPtIdx);
232  }
234 public:
235  const FuncCtrlPtType& ctrlPt(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx) const
236  {
237  return thisDerived().ctrlPtImplCRTP(_funcIdx, _funcCtrlPtIdx);
238  }
240 public:
241  NumType& ctrlPtVal(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx,
242  const CtrlPtDim& _ctrlPtDim = CtrlPtDim::VAL)
243  {
244  return thisDerived().ctrlPtValImplCRTP(_funcIdx, _funcCtrlPtIdx, _ctrlPtDim);
245  }
247 public:
248  const NumType& ctrlPtVal(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx,
249  const CtrlPtDim& _ctrlPtDim = CtrlPtDim::VAL) const
250  {
251  return thisDerived().ctrlPtValImplCRTP(_funcIdx, _funcCtrlPtIdx, _ctrlPtDim);
252  }
253 
254 public:
255  void shiftStartCtrlPt(const NumType& _dt)
256  {
257  thisDerived().shiftStartCtrlPtImplCRTP(_dt);
258  }
259 
261 public:
262  void precompute()
263  {
264  thisDerived().precomputeImplCRTP();
265  }
267 public:
268  void setEvalArc(const NumType& _arcEval, const eAG& _eAG = eAG::NONE)
269  {
270  thisDerived().setEvalArcImplCRTP(_arcEval, _eAG);
271  }
273 public:
274  NumType computeFuncVal(const std::size_t& _funcIdx) const
275  {
276  return thisDerived().computeFuncValImplCRTP(_funcIdx);
277  }
280 public:
281  NumType computeFuncDiff1(const std::size_t& _funcIdx) const
282  {
283  return thisDerived().computeFuncDiff1ImplCRTP(_funcIdx);
284  }
287 public:
288  NumType computeFuncDiff2(const std::size_t& _funcIdx) const
289  {
290  return thisDerived().computeFuncDiff2ImplCRTP(_funcIdx);
291  }
294 public:
295  NumType computeFuncInt1(const std::size_t& _funcIdx) const
296  {
297  return thisDerived().computeFuncInt1ImplCRTP(_funcIdx);
298  }
301 public:
302  NumType computeFuncInt2(const std::size_t& _funcIdx) const
303  {
304  return thisDerived().computeFuncInt2ImplCRTP(_funcIdx);
305  }
306 
307 private:
308  TDerived& thisDerived()
309  {
310  return static_cast<TDerived&>(*this);
311  }
312 
313 private:
314  const TDerived& thisDerived() const
315  {
316  return static_cast<const TDerived&>(*this);
317  }
318 };
319 template <typename TNumType>
321 {
322 protected:
324 
325 protected:
327 
328  // special class member functions
329 public:
330  ParamFuncsBaseVirt() = default;
331 
332 public:
333  virtual ~ParamFuncsBaseVirt() = default;
334 
335 public:
336  ParamFuncsBaseVirt(const ParamFuncsBaseVirt&) = default;
337 
338 public:
339  ParamFuncsBaseVirt& operator=(const ParamFuncsBaseVirt&) = default;
340 
341 public:
343 
344 public:
345  ParamFuncsBaseVirt& operator=(ParamFuncsBaseVirt&&) = default;
346 
365 public:
366  void init(const std::vector<ParamFuncsStructure>& _paramFuncsStructure)
367  {
368  initImplVirt(_paramFuncsStructure);
369  }
371 public:
372  std::size_t funcsSize() const
373  {
374  return funcsSizeImplVirt();
375  }
377 public:
378  std::size_t funcsArcSize() const
379  {
380  return funcsArcSizeImplVirt();
381  }
383 public:
384  std::size_t funcsArcSize(const std::size_t& _i) const
385  {
386  return funcsArcSizeImplVirt(_i);
387  }
389 public:
390  std::size_t funcCtrlPtSize(const std::size_t& _i) const
391  {
392  return funcCtrlPtSizeImplVirt(_i);
393  }
395 public:
396  TNumType& funcsArcBegin()
397  {
398  return funcsArcBeginImplVirt();
399  }
401 public:
402  const TNumType& funcsArcBegin() const
403  {
404  return funcsArcBeginImplVirt();
405  }
407 public:
408  TNumType& funcsArcEnd()
409  {
410  return funcsArcEndImplVirt();
411  }
413 public:
414  const TNumType& funcsArcEnd() const
415  {
416  return funcsArcEndImplVirt();
417  }
419 public:
420  const TNumType& funcsArcEval() const
421  {
422  return funcsArcEvalImplVirt();
423  }
425 public:
426  TNumType& funcsArc(const std::size_t& _i, const std::size_t& _j)
427  {
428  return funcsArcImplVirt(_i, _j);
429  }
431 public:
432  const TNumType& funcsArc(const std::size_t& _i, const std::size_t& _j) const
433  {
434  return funcsArcImplVirt(_i, _j);
435  }
437 public:
438  FuncCtrlPtType& ctrlPt(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx)
439  {
440  return ctrlPtImplVirt(_funcIdx, _funcCtrlPtIdx);
441  }
443 public:
444  const FuncCtrlPtType& ctrlPt(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx) const
445  {
446  return ctrlPtImplVirt(_funcIdx, _funcCtrlPtIdx);
447  }
449 public:
450  TNumType& ctrlPtVal(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx,
451  const CtrlPtDim& _ctrlPtDim = CtrlPtDim::VAL)
452  {
453  return ctrlPtValImplVirt(_funcIdx, _funcCtrlPtIdx, _ctrlPtDim);
454  }
456 public:
457  const TNumType& ctrlPtVal(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx,
458  const CtrlPtDim& _ctrlPtDim = CtrlPtDim::VAL) const
459  {
460  return ctrlPtValImplVirt(_funcIdx, _funcCtrlPtIdx, _ctrlPtDim);
461  }
462 
463 public:
464  void shiftStartCtrlPt(const TNumType& _dt)
465  {
466  shiftStartCtrlPtImplVirt(_dt);
467  }
468 
470 public:
471  void precompute()
472  {
473  precomputeImplVirt();
474  }
476 public:
477  void setEvalArc(const TNumType& _arcEval, const eAG& _eAG = eAG::NONE)
478  {
479  setEvalArcImplVirt(_arcEval, _eAG);
480  }
482 public:
483  TNumType computeFuncVal(const std::size_t& _funcIdx) const
484  {
485  return computeFuncValImplVirt(_funcIdx);
486  }
489 public:
490  TNumType computeFuncDiff1(const std::size_t& _funcIdx) const
491  {
492  return computeFuncDiff1ImplVirt(_funcIdx);
493  }
496 public:
497  TNumType computeFuncDiff2(const std::size_t& _funcIdx) const
498  {
499  return computeFuncDiff2ImplVirt(_funcIdx);
500  }
503 public:
504  TNumType computeFuncInt1(const std::size_t& _funcIdx) const
505  {
506  return computeFuncInt1ImplVirt(_funcIdx);
507  }
510 public:
511  TNumType computeFuncInt2(const std::size_t& _funcIdx) const
512  {
513  return computeFuncInt2ImplVirt(_funcIdx);
514  }
515 
516  // pure virtual functions
517 private:
518  virtual void initImplVirt(const std::vector<ParamFuncsStructure>& _paramFuncsStructure) = 0;
519 
520 private:
521  virtual std::size_t funcsSizeImplVirt() const = 0;
522 
523 private:
524  virtual std::size_t funcsArcSizeImplVirt() const = 0;
525 
526 private:
527  virtual std::size_t funcsArcSizeImplVirt(const std::size_t& _i) const = 0;
528 
529 private:
530  virtual std::size_t funcCtrlPtSizeImplVirt(const std::size_t& _i) const = 0;
531 
532 private:
533  virtual TNumType& funcsArcBeginImplVirt() = 0;
534 
535 private:
536  virtual const TNumType& funcsArcBeginImplVirt() const = 0;
537 
538 private:
539  virtual TNumType& funcsArcEndImplVirt() = 0;
540 
541 private:
542  virtual const TNumType& funcsArcEndImplVirt() const = 0;
543 
544 private:
545  virtual const TNumType& funcsArcEvalImplVirt() const = 0;
546 
547 private:
548  virtual TNumType& funcsArcImplVirt(const std::size_t& _i, const std::size_t& _j) = 0;
549 
550 private:
551  virtual const TNumType& funcsArcImplVirt(const std::size_t& _i, const std::size_t& _j) const = 0;
552 
553 private:
554  virtual FuncCtrlPtType& ctrlPtImplVirt(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx) = 0;
555 
556 private:
557  virtual const FuncCtrlPtType& ctrlPtImplVirt(const std::size_t& _funcIdx,
558  const std::size_t& _funcCtrlPtIdx) const = 0;
559 
560 private:
561  virtual TNumType& ctrlPtValImplVirt(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx,
562  const CtrlPtDim& _ctrlPtDim) = 0;
563 
564 private:
565  virtual const TNumType& ctrlPtValImplVirt(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx,
566  const CtrlPtDim& _ctrlPtDim) const = 0;
567 
568 private:
569  virtual void shiftStartCtrlPtImplVirt(const TNumType& _dt) = 0;
570 
571 private:
572  virtual void precomputeImplVirt() = 0;
573 
574 private:
575  virtual void setEvalArcImplVirt(const TNumType& _arcEval, const eAG& _eAG) = 0;
576 
577 private:
578  virtual TNumType computeFuncValImplVirt(const std::size_t& _funcIdx) const = 0;
579 
580 private:
581  virtual TNumType computeFuncDiff1ImplVirt(const std::size_t& _funcIdx) const = 0;
582 
583 private:
584  virtual TNumType computeFuncDiff2ImplVirt(const std::size_t& _funcIdx) const = 0;
585 
586 private:
587  virtual TNumType computeFuncInt1ImplVirt(const std::size_t& _funcIdx) const = 0;
588 
589 private:
590  virtual TNumType computeFuncInt2ImplVirt(const std::size_t& _funcIdx) const = 0;
591 };
592 
593 template <typename TNumType>
595 {
597 protected:
598  std::vector<std::vector<TNumType>> funcCtrlPtArc_;
599 };
600 template <typename TNumType, size_t TArcLatticeSize>
602 {
604 protected:
605  std::array<std::vector<TNumType>, TArcLatticeSize> funcCtrlPtArc_;
606 };
607 
608 template <typename TNumType>
610 {
612 protected:
613  std::vector<FuncEvalModesFlags> funcEvalReq_;
615 protected:
616  std::vector<std::vector<FuncCtrlPt<TNumType>>> funcCtrlPt_;
618 protected:
619  std::vector<ParamFuncsStructure> paramFuncsStructure_;
621 protected:
622  std::vector<std::size_t> func2Arc_;
623 };
624 template <typename TNumType, size_t TFuncSize>
626 {
628 protected:
629  std::array<FuncEvalModesFlags, TFuncSize> funcEvalReq_;
631 protected:
632  std::array<std::vector<FuncCtrlPt<TNumType>>, TFuncSize> funcCtrlPt_;
634 protected:
635  std::array<ParamFuncsStructure, TFuncSize> paramFuncsStructure_;
637 protected:
638  std::array<std::size_t, TFuncSize> func2Arc_;
639 };
640 
641 template <typename TDerived, typename TNumType, int TFuncSize, int TArcLatticeSize>
642 class ParamFuncsBase : public ParamFuncsBaseCRTP<ParamFuncsBase<TDerived, TNumType, TFuncSize, TArcLatticeSize>>,
643  public ParamFuncsBaseVirt<TNumType>,
644  public std::conditional<TFuncSize == -1, ParamFuncsBaseFuncVarsDyn<TNumType>,
645  ParamFuncsBaseFuncVarsStatic<TNumType, TFuncSize>>::type,
646  public std::conditional<TArcLatticeSize == -1, ParamFuncsBaseArcVarsDyn<TNumType>,
647  ParamFuncsBaseArcVarsStatic<TNumType, TArcLatticeSize>>::type
648 {
649 public:
650  using NumType = TNumType;
651 
652 public:
654 
655 public:
656  static constexpr const int FuncSize = TFuncSize;
657 
658 private:
659  static constexpr const bool IsFuncDyn = TFuncSize == -1;
660 
661 private:
662  static constexpr const bool IsArcDyn = TArcLatticeSize == -1;
663 
664 protected:
666 
667  // special class member functions
668 public:
669  ParamFuncsBase() : funcsArcEval_(-1)
670  {
671  }
672 
673 public:
674  virtual ~ParamFuncsBase() = default;
675 
676 public:
678  {
679  using PfCpD = CtrlPtDim;
680  initBase(_other.paramFuncsStructure_);
681  for (size_t i = 0; i < funcsArcSize(); ++i)
682  {
683  for (size_t j = 0; j < funcsArcSize(i); ++j)
684  {
685  funcsArc(i, j) = _other.funcsArc(i, j);
686  }
687  }
688  for (size_t i = 0; i < funcsSize(); ++i)
689  {
690  for (size_t j = 0; j < funcCtrlPtSize(i); ++j)
691  {
692  ctrlPtVal(i, j, PfCpD::VAL) = _other.ctrlPtVal(i, j, PfCpD::VAL);
693  }
694  }
695  }
696 
697 public:
699  {
700  if (this == &_other)
701  {
702  return *this;
703  }
704 
705  using PfCpD = CtrlPtDim;
706  init(_other.paramFuncsStructure_);
707  for (size_t i = 0; i < funcsArcSize(); ++i)
708  {
709  for (size_t j = 0; j < funcsArcSize(i); ++j)
710  {
711  funcsArc(i, j) = _other.funcsArc(i, j);
712  }
713  }
714  for (size_t i = 0; i < funcsSize(); ++i)
715  {
716  for (size_t j = 0; j < funcCtrlPtSize(i); ++j)
717  {
718  ctrlPtVal(i, j, PfCpD::VAL) = _other.ctrlPtVal(i, j, PfCpD::VAL);
719  }
720  }
721  return *this;
722  }
723 
724 public:
725  ParamFuncsBase(ParamFuncsBase&&) = default;
726 
727 public:
728  ParamFuncsBase& operator=(ParamFuncsBase&&) = default;
729 
749 protected:
750  void initImpl()
751  {
752  thisDerived().initImplImpl();
753  }
754 
755 private:
756  void precomputeImplVirt() override final
757  {
758  thisDerived().precomputeImpl();
759  }
760 
761 private:
762  void setEvalArcImplVirt(const TNumType& _arcEval,
763  const typename ParamFuncsBaseCRTP<ParamFuncsBaseType>::eAG& _eAG) override final
764  {
765  thisDerived().setEvalArcImpl(_arcEval, _eAG);
766  }
767 
768 private:
769  TNumType computeFuncValImplVirt(const std::size_t& _funcIdx) const override final
770  {
771  return thisDerived().computeFuncValImpl(_funcIdx);
772  }
773 
774 private:
775  TNumType computeFuncDiff1ImplVirt(const std::size_t& _funcIdx) const override final
776  {
777  return thisDerived().computeFuncDiff1Impl(_funcIdx);
778  }
779 
780 private:
781  TNumType computeFuncDiff2ImplVirt(const std::size_t& _funcIdx) const override final
782  {
783  return thisDerived().computeFuncDiff2Impl(_funcIdx);
784  }
785 
786 private:
787  TNumType computeFuncInt1ImplVirt(const std::size_t& _funcIdx) const override final
788  {
789  return thisDerived().computeFuncInt1Impl(_funcIdx);
790  }
791 
792 private:
793  TNumType computeFuncInt2ImplVirt(const std::size_t& _funcIdx) const override final
794  {
795  return thisDerived().computeFuncInt2Impl(_funcIdx);
796  }
797 
798 private:
800  {
801  thisDerived().precomputeImpl();
802  }
803 
804 private:
805  void setEvalArcImplCRTP(const TNumType& _arcEval, const typename ParamFuncsBaseCRTP<ParamFuncsBaseType>::eAG& _eAG)
806  {
807  thisDerived().setEvalArcImpl(_arcEval, _eAG);
808  }
809 
810 private:
811  TNumType computeFuncValImplCRTP(const std::size_t& _funcIdx) const
812  {
813  return thisDerived().computeFuncValImpl(_funcIdx);
814  }
815 
816 private:
817  TNumType computeFuncDiff1ImplCRTP(const std::size_t& _funcIdx) const
818  {
819  return thisDerived().computeFuncDiff1Impl(_funcIdx);
820  }
821 
822 private:
823  TNumType computeFuncDiff2ImplCRTP(const std::size_t& _funcIdx) const
824  {
825  return thisDerived().computeFuncDiff2Impl(_funcIdx);
826  }
827 
828 private:
829  TNumType computeFuncInt1ImplCRTP(const std::size_t& _funcIdx) const
830  {
831  return thisDerived().computeFuncInt1Impl(_funcIdx);
832  }
833 
834 private:
835  TNumType computeFuncInt2ImplCRTP(const std::size_t& _funcIdx) const
836  {
837  return thisDerived().computeFuncInt2Impl(_funcIdx);
838  }
839 
840 private:
841  template <bool FuncDyn = IsFuncDyn, typename std::enable_if<FuncDyn>::type* = nullptr>
842  void initImplVirtDispatch(const std::vector<ParamFuncsStructure>& _paramFuncsStructure)
843  {
844  initImplCRTP(_paramFuncsStructure);
845  }
846 
847 private:
848  template <bool FuncDyn = IsFuncDyn, typename std::enable_if<!FuncDyn>::type* = nullptr>
849  void initImplVirtDispatch(const std::vector<ParamFuncsStructure>& _paramFuncsStructure)
850  {
851  if (_paramFuncsStructure.size() != TFuncSize)
852  {
853  throw std::runtime_error("Error in ParamFuncs::init: number of functions in init structure does not match "
854  "(static) number of param funcs");
855  }
856  std::array<ParamFuncsStructure, TFuncSize> pfsStatic;
857  for (size_t i = 0; i < pfsStatic.size(); ++i)
858  {
859  pfsStatic[i] = _paramFuncsStructure[i];
860  }
861  initImplCRTP(pfsStatic);
862  }
863 
864 private:
865  void initImplVirt(const std::vector<ParamFuncsStructure>& _paramFuncsStructure) override final
866  {
867  initImplVirtDispatch(_paramFuncsStructure);
868  }
869 
870 private:
871  std::size_t funcsSizeImplVirt() const override final
872  {
873  return funcsSizeImplCRTP();
874  }
875 
876 private:
877  std::size_t funcsArcSizeImplVirt() const override final
878  {
879  return funcsArcSizeImplCRTP();
880  }
881 
882 private:
883  std::size_t funcsArcSizeImplVirt(const std::size_t& _i) const override final
884  {
885  return funcsArcSizeImplCRTP(_i);
886  }
887 
888 private:
889  std::size_t funcCtrlPtSizeImplVirt(const std::size_t& _i) const override final
890  {
891  return funcCtrlPtSizeImplCRTP(_i);
892  }
893 
894 private:
895  TNumType& funcsArcBeginImplVirt() override final
896  {
897  return funcsArcBeginImplCRTP();
898  }
899 
900 private:
901  const TNumType& funcsArcBeginImplVirt() const override final
902  {
903  return funcsArcBeginImplCRTP();
904  }
905 
906 private:
907  TNumType& funcsArcEndImplVirt() override final
908  {
909  return funcsArcEndImplCRTP();
910  }
911 
912 private:
913  const TNumType& funcsArcEndImplVirt() const override final
914  {
915  return funcsArcEndImplCRTP();
916  }
917 
918 private:
919  const TNumType& funcsArcEvalImplVirt() const override final
920  {
921  return funcsArcEvalImplCRTP();
922  }
923 
924 private:
925  TNumType& funcsArcImplVirt(const std::size_t& _i, const std::size_t& _j) override final
926  {
927  return funcsArcImplCRTP(_i, _j);
928  }
929 
930 private:
931  const TNumType& funcsArcImplVirt(const std::size_t& _i, const std::size_t& _j) const override final
932  {
933  return funcsArcImplCRTP(_i, _j);
934  }
935 
936 private:
937  FuncCtrlPtType& ctrlPtImplVirt(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx) override final
938  {
939  return ctrlPtImplCRTP(_funcIdx, _funcCtrlPtIdx);
940  }
941 
942 private:
943  const FuncCtrlPtType& ctrlPtImplVirt(const std::size_t& _funcIdx,
944  const std::size_t& _funcCtrlPtIdx) const override final
945  {
946  return ctrlPtImplCRTP(_funcIdx, _funcCtrlPtIdx);
947  }
948 
949 private:
950  TNumType& ctrlPtValImplVirt(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx,
951  const CtrlPtDim& _ctrlPtDim) override final
952  {
953  return ctrlPtValImplCRTP(_funcIdx, _funcCtrlPtIdx, _ctrlPtDim);
954  }
955 
956 private:
957  const TNumType& ctrlPtValImplVirt(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx,
958  const CtrlPtDim& _ctrlPtDim) const override final
959  {
960  return ctrlPtValImplCRTP(_funcIdx, _funcCtrlPtIdx, _ctrlPtDim);
961  }
962 
963 private:
964  void shiftStartCtrlPtImplVirt(const TNumType& _dt) override final
965  {
966  shiftStartCtrlPtImplCRTP(_dt);
967  }
968 
969 private:
970  template <bool FuncDyn = (IsFuncDyn), bool ArcDyn = IsArcDyn,
971  typename std::enable_if<(FuncDyn) && (ArcDyn)>::type* = nullptr>
972  void initBase(const std::vector<ParamFuncsStructure>& _paramFuncsStructure)
973  {
974  this->paramFuncsStructure_ = _paramFuncsStructure;
975  const size_t funcsSize = _paramFuncsStructure.size();
976  if (funcsSize < 1)
977  {
978  throw std::runtime_error("Error in ParamFuncs::checkParamFuncsStructure: initialization with 0 number of "
979  "functions!");
980  }
981  this->funcCtrlPt_.resize(funcsSize);
982  for (auto& funcCtrlPtrI : this->funcCtrlPt_)
983  {
984  funcCtrlPtrI.clear();
985  }
986  this->func2Arc_.resize(funcsSize);
987  this->funcEvalReq_.resize(funcsSize);
988  this->funcCtrlPtArc_.clear();
989  std::vector<size_t> funcSameArcCtrlPtSize;
990  for (size_t i = 0; i < funcsSize; ++i)
991  {
992  const auto& paramFuncsStructureI = _paramFuncsStructure[i];
993  const size_t& funcCtrlPtsSize = paramFuncsStructureI.ctrlPtsSize;
994  if (funcCtrlPtsSize < 2)
995  {
996  throw std::runtime_error("Error in ParamFuncs::checkParamFuncsStructure: function has less than 2 control "
997  "points!");
998  }
999  auto& func2ArcI = this->func2Arc_[i];
1000  func2ArcI = paramFuncsStructureI.ctrlPtsArcRefIdx;
1001  if (func2ArcI >= this->funcCtrlPtArc_.size())
1002  {
1003  if (func2ArcI == this->funcCtrlPtArc_.size())
1004  {
1005  this->funcCtrlPtArc_.emplace_back(std::vector<TNumType>(funcCtrlPtsSize - 2, 0));
1006  funcSameArcCtrlPtSize.emplace_back(funcCtrlPtsSize);
1007  }
1008  else
1009  {
1010  throw std::runtime_error("Error in ParamFuncs::init: a ctrlPtsArcRefIdx is not consistent (new Idx not unit "
1011  "incremental)");
1012  }
1013  }
1014  if (funcCtrlPtsSize != funcSameArcCtrlPtSize[func2ArcI])
1015  {
1016  throw "Error in ParamFuncs::init: inconsistent number of control points for functions with same arc "
1017  "parametrization reference";
1018  }
1019  auto& funcCtrlPtI = this->funcCtrlPt_[i];
1020  funcCtrlPtI.reserve(funcCtrlPtsSize);
1021  funcCtrlPtI.emplace_back(FuncCtrlPtType(0, funcsArcBegin_));
1022  for (size_t j = 1; j < funcCtrlPtsSize - 1; ++j)
1023  {
1024  funcCtrlPtI.emplace_back(FuncCtrlPtType(0, this->funcCtrlPtArc_[func2ArcI][j - 1]));
1025  }
1026  funcCtrlPtI.emplace_back(FuncCtrlPtType(0, funcsArcEnd_));
1027 
1028  this->funcEvalReq_[i] = paramFuncsStructureI.evalReq;
1029  }
1030  }
1031 
1032 private:
1033  template <bool FuncDyn = (IsFuncDyn), bool ArcDyn = IsArcDyn,
1034  typename std::enable_if<(!FuncDyn) && (ArcDyn)>::type* = nullptr>
1035  void initBase(const std::array<ParamFuncsStructure, TFuncSize>& _paramFuncsStructure)
1036  {
1037  this->paramFuncsStructure_ = _paramFuncsStructure;
1038  for (auto& funcCtrlPtrI : this->funcCtrlPt_)
1039  {
1040  funcCtrlPtrI.clear();
1041  }
1042  this->funcCtrlPtArc_.clear();
1043  std::vector<size_t> funcSameArcCtrlPtSize;
1044  for (size_t i = 0; i < (size_t)TFuncSize; ++i)
1045  {
1046  const auto& paramFuncsStructureI = _paramFuncsStructure[i];
1047  const size_t& funcCtrlPtsSize = paramFuncsStructureI.ctrlPtsSize;
1048  if (funcCtrlPtsSize < 2)
1049  {
1050  throw std::runtime_error("Error in ParamFuncs::checkParamFuncsStructure: function has less than 2 control "
1051  "points!");
1052  }
1053  auto& func2ArcI = this->func2Arc_[i];
1054  func2ArcI = paramFuncsStructureI.ctrlPtsArcRefIdx;
1055  if (func2ArcI >= this->funcCtrlPtArc_.size())
1056  {
1057  if (func2ArcI == this->funcCtrlPtArc_.size())
1058  {
1059  this->funcCtrlPtArc_.emplace_back(std::vector<TNumType>(funcCtrlPtsSize - 2, 0));
1060  funcSameArcCtrlPtSize.emplace_back(funcCtrlPtsSize);
1061  }
1062  else
1063  {
1064  throw std::runtime_error("Error in ParamFuncs::init: a ctrlPtsArcRefIdx is not consistent (new Idx not unit "
1065  "incremental)");
1066  }
1067  }
1068  if (funcCtrlPtsSize != funcSameArcCtrlPtSize[func2ArcI])
1069  {
1070  throw "Error in ParamFuncs::init: inconsistent number of control points for functions with same arc "
1071  "parametrization reference";
1072  }
1073  auto& funcCtrlPtI = this->funcCtrlPt_[i];
1074  funcCtrlPtI.reserve(funcCtrlPtsSize);
1075  funcCtrlPtI.emplace_back(FuncCtrlPtType(0, funcsArcBegin_));
1076  for (size_t j = 1; j < funcCtrlPtsSize - 1; ++j)
1077  {
1078  funcCtrlPtI.emplace_back(FuncCtrlPtType(0, this->funcCtrlPtArc_[func2ArcI][j - 1]));
1079  }
1080  funcCtrlPtI.emplace_back(FuncCtrlPtType(0, funcsArcEnd_));
1081 
1082  this->funcEvalReq_[i] = paramFuncsStructureI.evalReq;
1083  }
1084  }
1085 
1086 private:
1087  template <bool FuncDyn = (IsFuncDyn), bool ArcDyn = IsArcDyn,
1088  typename std::enable_if<(FuncDyn) && (!ArcDyn)>::type* = nullptr>
1089  void initBase(const std::vector<ParamFuncsStructure>& _paramFuncsStructure)
1090  {
1091  this->paramFuncsStructure_ = _paramFuncsStructure;
1092  const size_t funcsSize = _paramFuncsStructure.size();
1093  if (funcsSize < 1)
1094  {
1095  throw std::runtime_error("Error in ParamFuncs::checkParamFuncsStructure: initialization with 0 number of "
1096  "functions!");
1097  }
1098  this->funcCtrlPt_.resize(funcsSize);
1099  for (auto& funcCtrlPtrI : this->funcCtrlPt_)
1100  {
1101  funcCtrlPtrI.clear();
1102  }
1103  this->func2Arc_.resize(funcsSize);
1104  this->funcEvalReq_.resize(funcsSize);
1105  std::array<size_t, TFuncSize> funcSameArcCtrlPtSize;
1106  std::vector<bool> initFuncCtrlPtArc(this->funcCtrlPtArc_.size(), false);
1107  for (size_t i = 0; i < funcsSize; ++i)
1108  {
1109  const auto& paramFuncsStructureI = _paramFuncsStructure[i];
1110  const size_t& funcCtrlPtsSize = paramFuncsStructureI.ctrlPtsSize;
1111  if (funcCtrlPtsSize < 2)
1112  {
1113  throw std::runtime_error("Error in ParamFuncs::checkParamFuncsStructure: function has less than 2 control "
1114  "points!");
1115  }
1116  auto& func2ArcI = this->func2Arc_[i];
1117  func2ArcI = paramFuncsStructureI.ctrlPtsArcRefIdx;
1118  if (func2ArcI < this->funcCtrlPtArc_.size())
1119  {
1120  if (initFuncCtrlPtArc[func2ArcI] == false)
1121  {
1122  this->funcCtrlPtArc_[func2ArcI] = std::vector<TNumType>(funcCtrlPtsSize - 2, 0);
1123  initFuncCtrlPtArc[func2ArcI] = true;
1124  }
1125  funcSameArcCtrlPtSize[func2ArcI] = funcCtrlPtsSize;
1126  }
1127  else
1128  {
1129  throw std::runtime_error("Error in ParamFuncs::init: a ctrlPtsArcRefIdx is not consistent (>= than the static "
1130  "arc lattice size)");
1131  }
1132  if (funcCtrlPtsSize != funcSameArcCtrlPtSize[func2ArcI])
1133  {
1134  throw "Error in ParamFuncs::init: inconsistent number of control points for functions with same arc "
1135  "parametrization reference";
1136  }
1137  auto& funcCtrlPtI = this->funcCtrlPt_[i];
1138  funcCtrlPtI.reserve(funcCtrlPtsSize);
1139  funcCtrlPtI.emplace_back(FuncCtrlPtType(0, funcsArcBegin_));
1140  for (size_t j = 1; j < funcCtrlPtsSize - 1; ++j)
1141  {
1142  funcCtrlPtI.emplace_back(FuncCtrlPtType(0, this->funcCtrlPtArc_[func2ArcI][j - 1]));
1143  }
1144  funcCtrlPtI.emplace_back(FuncCtrlPtType(0, funcsArcEnd_));
1145 
1146  this->funcEvalReq_[i] = paramFuncsStructureI.evalReq;
1147  }
1148  }
1149 
1150 private:
1151  template <bool FuncDyn = (IsFuncDyn), bool ArcDyn = IsArcDyn,
1152  typename std::enable_if<(!FuncDyn) && (!ArcDyn)>::type* = nullptr>
1153  void initBase(const std::array<ParamFuncsStructure, TFuncSize>& _paramFuncsStructure)
1154  {
1155  this->paramFuncsStructure_ = _paramFuncsStructure;
1156  for (auto& funcCtrlPtrI : this->funcCtrlPt_)
1157  {
1158  funcCtrlPtrI.clear();
1159  }
1160  std::array<size_t, TFuncSize> funcSameArcCtrlPtSize;
1161  std::vector<bool> initFuncCtrlPtArc(this->funcCtrlPtArc_.size(), false);
1162  for (size_t i = 0; i < (size_t)TFuncSize; ++i)
1163  {
1164  const auto& paramFuncsStructureI = _paramFuncsStructure[i];
1165  const size_t& funcCtrlPtsSize = paramFuncsStructureI.ctrlPtsSize;
1166  if (funcCtrlPtsSize < 2)
1167  {
1168  throw std::runtime_error("Error in ParamFuncs::checkParamFuncsStructure: function has less than 2 control "
1169  "points!");
1170  }
1171  auto& func2ArcI = this->func2Arc_[i];
1172  func2ArcI = paramFuncsStructureI.ctrlPtsArcRefIdx;
1173  if (func2ArcI < this->funcCtrlPtArc_.size())
1174  {
1175  if (initFuncCtrlPtArc[func2ArcI] == false)
1176  {
1177  this->funcCtrlPtArc_[func2ArcI] = std::vector<TNumType>(funcCtrlPtsSize - 2, 0);
1178  initFuncCtrlPtArc[func2ArcI] = true;
1179  }
1180  funcSameArcCtrlPtSize[func2ArcI] = funcCtrlPtsSize;
1181  }
1182  else
1183  {
1184  throw std::runtime_error("Error in ParamFuncs::init: a ctrlPtsArcRefIdx is not consistent (>= than the static "
1185  "arc lattice size)");
1186  }
1187  if (funcCtrlPtsSize != funcSameArcCtrlPtSize[func2ArcI])
1188  {
1189  throw std::runtime_error("Error in ParamFuncs::init: inconsistent number of control points for functions with "
1190  "same arc parametrization reference");
1191  }
1192  auto& funcCtrlPtI = this->funcCtrlPt_[i];
1193  funcCtrlPtI.reserve(funcCtrlPtsSize);
1194  funcCtrlPtI.emplace_back(FuncCtrlPtType(0, funcsArcBegin_));
1195  for (size_t j = 1; j < funcCtrlPtsSize - 1; ++j)
1196  {
1197  funcCtrlPtI.emplace_back(FuncCtrlPtType(0, this->funcCtrlPtArc_[func2ArcI][j - 1]));
1198  }
1199  funcCtrlPtI.emplace_back(FuncCtrlPtType(0, funcsArcEnd_));
1200 
1201  this->funcEvalReq_[i] = paramFuncsStructureI.evalReq;
1202  }
1203  }
1204 
1205 private:
1206  template <typename TParamFucsStructVecArr>
1207  void initImplCRTP(const TParamFucsStructVecArr& _paramFuncsStructure)
1208  {
1209  initBase(_paramFuncsStructure);
1210  initImpl();
1211  }
1212 
1213 private:
1214  std::size_t funcsSizeImplCRTP() const
1215  {
1216  return this->funcCtrlPt_.size();
1217  }
1218 
1219 private:
1220  std::size_t funcsArcSizeImplCRTP() const
1221  {
1222  return this->funcCtrlPtArc_.size();
1223  }
1224 
1225 private:
1226  std::size_t funcsArcSizeImplCRTP(const std::size_t& _i) const
1227  {
1228  return this->funcCtrlPtArc_[_i].size() + 2;
1229  }
1230 
1231 private:
1232  std::size_t funcCtrlPtSizeImplCRTP(const std::size_t& _i) const
1233  {
1234  return this->funcCtrlPt_[_i].size();
1235  }
1236 
1237 private:
1239  {
1240  return funcsArcBegin_;
1241  }
1242 
1243 private:
1244  const TNumType& funcsArcBeginImplCRTP() const
1245  {
1246  return funcsArcBegin_;
1247  }
1248 
1249 private:
1251  {
1252  return funcsArcEnd_;
1253  }
1254 
1255 private:
1256  const TNumType& funcsArcEndImplCRTP() const
1257  {
1258  return funcsArcEnd_;
1259  }
1260 
1261 private:
1262  const TNumType& funcsArcEvalImplCRTP() const
1263  {
1264  return funcsArcEval_;
1265  }
1266 
1267 private:
1268  TNumType& funcsArcImplCRTP(const std::size_t& _i, const std::size_t& _j)
1269  {
1270  if (_j == 0)
1271  {
1272  return funcsArcBegin_;
1273  }
1274  if (_j > this->funcCtrlPtArc_[_i].size())
1275  {
1276  return funcsArcEnd_;
1277  }
1278  return this->funcCtrlPtArc_[_i][_j - 1];
1279  }
1280 
1281 private:
1282  const TNumType& funcsArcImplCRTP(const std::size_t& _i, const std::size_t& _j) const
1283  {
1284  if (_j == 0)
1285  {
1286  return funcsArcBegin_;
1287  }
1288  if (_j > this->funcCtrlPtArc_[_i].size())
1289  {
1290  return funcsArcEnd_;
1291  }
1292  return this->funcCtrlPtArc_[_i][_j - 1];
1293  }
1294 
1295 private:
1296  FuncCtrlPtType& ctrlPtImplCRTP(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx)
1297  {
1298  return this->funcCtrlPt_[_funcIdx][_funcCtrlPtIdx];
1299  }
1300 
1301 private:
1302  const FuncCtrlPtType& ctrlPtImplCRTP(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx) const
1303  {
1304  return this->funcCtrlPt_[_funcIdx][_funcCtrlPtIdx];
1305  }
1306 
1307 private:
1308  TNumType& ctrlPtValImplCRTP(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx,
1309  const CtrlPtDim& _ctrlPtDim)
1310  {
1311  switch (_ctrlPtDim)
1312  {
1313  case CtrlPtDim::VAL:
1314  return this->funcCtrlPt_[_funcIdx][_funcCtrlPtIdx].val;
1315  break;
1316  case CtrlPtDim::ARC:
1317  return this->funcCtrlPt_[_funcIdx][_funcCtrlPtIdx].arc;
1318  break;
1319  default:
1320  throw "CtrlPtDim unrecognised in function ParamFuncs::ctrlPtVal !";
1321  break;
1322  }
1323  }
1324 
1325 private:
1326  const TNumType& ctrlPtValImplCRTP(const std::size_t& _funcIdx, const std::size_t& _funcCtrlPtIdx,
1327  const CtrlPtDim& _ctrlPtDim) const
1328  {
1329  switch (_ctrlPtDim)
1330  {
1331  case CtrlPtDim::VAL:
1332  return this->funcCtrlPt_[_funcIdx][_funcCtrlPtIdx].val;
1333  break;
1334  case CtrlPtDim::ARC:
1335  return this->funcCtrlPt_[_funcIdx][_funcCtrlPtIdx].arc;
1336  break;
1337  default:
1338  throw "CtrlPtDim unrecognised in function ParamFuncs::ctrlPtVal !";
1339  break;
1340  }
1341  }
1342 
1343 private:
1344  void shiftStartCtrlPtImplCRTP(const TNumType& _dt)
1345  {
1346  std::vector<TNumType> ctrlPtValPref(funcsSize(), 0);
1347  const TNumType dtBound = fmin(fmax(funcsArcBegin_, _dt), funcsArcEnd_ - funcsArcBegin_);
1348  const TNumType evalArc = funcsArcBegin_ + dtBound;
1349  setEvalArc(evalArc);
1350  for (size_t i = 0; i < funcsSize(); ++i)
1351  {
1352  ctrlPtValPref[i] = computeFuncVal(i);
1353  }
1354  for (size_t i = 0; i < funcsSize(); ++i)
1355  {
1356  for (size_t j = 0; j < funcCtrlPtSize(i); ++j)
1357  {
1358  if (ctrlPtVal(i, j, CtrlPtDim::ARC) < evalArc)
1359  {
1360  ctrlPtVal(i, j, CtrlPtDim::VAL) = ctrlPtValPref[i];
1361  }
1362  else
1363  {
1364  break;
1365  }
1366  }
1367  }
1368  for (size_t k = 0; k < funcsArcSize(); ++k)
1369  {
1370  for (size_t j = 0; j < this->funcCtrlPtArc_[k].size(); ++j)
1371  {
1372  this->funcCtrlPtArc_[k][j] = fmax(funcsArcBegin_, this->funcCtrlPtArc_[k][j] - dtBound);
1373  }
1374  }
1375  funcsArcEnd_ -= dtBound;
1376  precompute();
1377  setEvalArc(funcsArcBegin_);
1378  }
1379 
1380 private:
1381  TDerived& thisDerived()
1382  {
1383  return static_cast<TDerived&>(*this);
1384  }
1385 
1386 private:
1387  const TDerived& thisDerived() const
1388  {
1389  return static_cast<const TDerived&>(*this);
1390  }
1391 
1393 protected:
1394  TNumType funcsArcBegin_;
1396 protected:
1397  TNumType funcsArcEnd_;
1399 protected:
1400  TNumType funcsArcEval_;
1401 
1402  template <typename TDerived2>
1403  friend class ParamFuncsBaseCRTP;
1404  template <typename TNum2>
1405  friend class ParamFuncsBaseVirt;
1406 };
1407 template <typename TDerived, typename TNumType, int TFuncSize, int TArcLatticeSize>
1409 
1410 namespace
1411 {
1412 template <typename TDerived, typename TNumType, int TFuncSize, int TArcLatticeSize>
1413 struct ParamFuncsBaseCRTPTraits<ParamFuncsBase<TDerived, TNumType, TFuncSize, TArcLatticeSize>>
1414 {
1415  using NumType = TNumType;
1416 };
1417 
1418 } // namespace <anonymous>
1419 }
1420 
1421 #endif // PARAM_FUNC_HPP
Containts parametric function initialization data.
Definition: param_func.hpp:76
TNumType & arc
control point arc parameter
Definition: param_func.hpp:97
TNumType & funcsArc(const std::size_t &_i, const std::size_t &_j)
Access to the arc parameter vector at index _i, control point _j.
Definition: param_func.hpp:426
FuncCtrlPtType & ctrlPtImplCRTP(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx)
const TNumType & funcsArcEvalImplCRTP() const
std::size_t funcsSizeImplCRTP() const
std::size_t funcCtrlPtSizeImplCRTP(const std::size_t &_i) const
const NumType & funcsArc(const std::size_t &_i, const std::size_t &_j) const
Const access the arc parameter vector at index _i, control point _j.
Definition: param_func.hpp:223
TDerived & thisDerived()
Definition: param_func.hpp:308
std::size_t funcsArcSizeImplVirt(const std::size_t &_i) const overridefinal
Definition: param_func.hpp:883
std::array< std::vector< FuncCtrlPt< TNumType > >, TFuncSize > funcCtrlPt_
Stores the control points for all the parametrized functions.
Definition: param_func.hpp:632
void shiftStartCtrlPtImplVirt(const TNumType &_dt) overridefinal
Definition: param_func.hpp:964
control point value
TNumType & funcsArcBeginImplCRTP()
const TNumType & funcsArcEnd() const
Const access to the finall value of the arc parametrization.
Definition: param_func.hpp:414
void setEvalArc(const NumType &_arcEval, const eAG &_eAG=eAG::NONE)
Sets parametric function evaluation arc.
Definition: param_func.hpp:268
const NumType & ctrlPtVal(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx, const CtrlPtDim &_ctrlPtDim=CtrlPtDim::VAL) const
Const of a parametric function control point dimension.
Definition: param_func.hpp:248
FuncCtrlPtType & ctrlPt(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx)
Access of a parametric function control point.
Definition: param_func.hpp:438
std::vector< ParamFuncsStructure > paramFuncsStructure_
Initialization structure "store" variable.
Definition: param_func.hpp:619
TNumType computeFuncInt1ImplCRTP(const std::size_t &_funcIdx) const
Definition: param_func.hpp:829
ParamFuncsBase(const ParamFuncsBase &_other)
Definition: param_func.hpp:677
control point arc parameter
std::size_t funcsArcSizeImplCRTP(const std::size_t &_i) const
std::vector< FuncEvalModesFlags > funcEvalReq_
Flags for required function computation modes.
Definition: param_func.hpp:613
TNumType funcsArcEnd_
Arc parametrization at the end of the functions domain definitions (common for all functions)...
const TNumType & ctrlPtValImplVirt(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx, const CtrlPtDim &_ctrlPtDim) const overridefinal
Definition: param_func.hpp:957
std::size_t funcsArcSize() const
Number of arc parametrizations.
Definition: param_func.hpp:169
std::array< std::size_t, TFuncSize > func2Arc_
Maps the parametrized functions to their afferent arc parametrizations.
Definition: param_func.hpp:638
const TNumType & funcsArcImplCRTP(const std::size_t &_i, const std::size_t &_j) const
std::size_t funcCtrlPtSize(const std::size_t &_i) const
Number of control points for a parametric function.
Definition: param_func.hpp:181
NumType computeFuncInt2(const std::size_t &_funcIdx) const
Computes double integral of parametric function with index _funcIdx on interval [funcsArcBegin_, funcsArcEnd_].
Definition: param_func.hpp:302
void init(const std::vector< ParamFuncsStructure > &_paramFuncsStructure)
Initializes the control structure.
Definition: param_func.hpp:366
NumType computeFuncDiff2(const std::size_t &_funcIdx) const
Computes 2nd derivative of parametric function with index _funcIdx at parametric arc set by setEvalAr...
Definition: param_func.hpp:288
TNumType computeFuncValImplVirt(const std::size_t &_funcIdx) const overridefinal
Definition: param_func.hpp:769
function second derivative
constexpr auto asInt(Enumeration const value) -> typename std::underlying_type< Enumeration >::type
Definition: utils.h:87
void initImplVirtDispatch(const std::vector< ParamFuncsStructure > &_paramFuncsStructure)
Definition: param_func.hpp:842
TNumType & funcsArcEndImplVirt() overridefinal
Definition: param_func.hpp:907
const TNumType & funcsArcBegin() const
Const access to the initial value of the arc parametrization.
Definition: param_func.hpp:402
function value (always assumed to have the highest integer value of the enum)
TNumType computeFuncDiff1(const std::size_t &_funcIdx) const
Computes 1st derivative of parametric function with index _funcIdx at parametric arc set by setEvalAr...
Definition: param_func.hpp:490
const FuncCtrlPtType & ctrlPtImplCRTP(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx) const
void initImpl()
Called at end of init. To be used by extended classes.
Definition: param_func.hpp:750
friend class ParamFuncsBaseVirt
const TNumType & funcsArc(const std::size_t &_i, const std::size_t &_j) const
Const access the arc parameter vector at index _i, control point _j.
Definition: param_func.hpp:432
TNumType val
control point value
Definition: param_func.hpp:96
TNumType funcsArcBegin_
Arc parametrization at the beginning of the functions domain definitions (common for all functions)...
FuncCtrlPtType & ctrlPtImplVirt(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx) overridefinal
Definition: param_func.hpp:937
const TDerived & thisDerived() const
Definition: param_func.hpp:314
TNumType computeFuncInt1(const std::size_t &_funcIdx) const
Computes integral of parametric function with index _funcIdx on interval [funcsArcBegin_, funcsArcEnd_].
Definition: param_func.hpp:504
void init(const TParamFucsStructVecArr &_paramFuncsStructure)
Initializes the control structure.
Definition: param_func.hpp:157
void shiftStartCtrlPt(const NumType &_dt)
Definition: param_func.hpp:255
NumType & funcsArc(const std::size_t &_i, const std::size_t &_j)
Access to the arc parameter vector at index _i, control point _j.
Definition: param_func.hpp:217
NumType computeFuncInt1(const std::size_t &_funcIdx) const
Computes integral of parametric function with index _funcIdx on interval [funcsArcBegin_, funcsArcEnd_].
Definition: param_func.hpp:295
TNumType & funcsArcEnd()
Access to the final value of the arc parametrization.
Definition: param_func.hpp:408
void precompute()
Precomputes cached data.
Definition: param_func.hpp:262
std::array< ParamFuncsStructure, TFuncSize > paramFuncsStructure_
Initialization structure "store" variable.
Definition: param_func.hpp:635
TNumType computeFuncVal(const std::size_t &_funcIdx) const
Computes value of parametric function with index _funcIdx at parametric arc set by setEvalArc...
Definition: param_func.hpp:483
std::size_t funcsSize() const
Number of parametric functions.
Definition: param_func.hpp:163
const FuncCtrlPtType & ctrlPt(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx) const
Const access of a parametric function control point.
Definition: param_func.hpp:235
NumType & ctrlPtVal(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx, const CtrlPtDim &_ctrlPtDim=CtrlPtDim::VAL)
Access of a parametric function control point dimension.
Definition: param_func.hpp:241
function single integral
Control point variable.
Definition: param_func.hpp:91
TNumType computeFuncDiff2ImplCRTP(const std::size_t &_funcIdx) const
Definition: param_func.hpp:823
TNumType computeFuncDiff1ImplCRTP(const std::size_t &_funcIdx) const
Definition: param_func.hpp:817
std::size_t funcsArcSize() const
Number of arc parametrizations.
Definition: param_func.hpp:378
const FuncCtrlPtType & ctrlPtImplVirt(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx) const overridefinal
Definition: param_func.hpp:943
TNumType computeFuncDiff2(const std::size_t &_funcIdx) const
Computes 2nd derivative of parametric function with index _funcIdx at parametric arc set by setEvalAr...
Definition: param_func.hpp:497
void shiftStartCtrlPt(const TNumType &_dt)
Definition: param_func.hpp:464
std::size_t funcsSize() const
Number of parametric functions.
Definition: param_func.hpp:372
TNumType computeFuncInt2ImplVirt(const std::size_t &_funcIdx) const overridefinal
Definition: param_func.hpp:793
void precomputeImplVirt() overridefinal
Definition: param_func.hpp:756
typename ParamFuncsBaseCRTPTraits< ParamFuncsBase< ParamFuncsSpline0Dist< TNumType, TFuncSize, TArcLatticeSize >, TNumType, TFuncSize, TArcLatticeSize > >::NumType NumType
Definition: param_func.hpp:113
TDerived & thisDerived()
TNumType & funcsArcEndImplCRTP()
const TNumType & funcsArcEndImplVirt() const overridefinal
Definition: param_func.hpp:913
std::size_t funcsArcSizeImplVirt() const overridefinal
Definition: param_func.hpp:877
TNumType & ctrlPtVal(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx, const CtrlPtDim &_ctrlPtDim=CtrlPtDim::VAL)
Access of a parametric function control point dimension.
Definition: param_func.hpp:450
std::size_t funcCtrlPtSize(const std::size_t &_i) const
Number of control points for a parametric function.
Definition: param_func.hpp:390
NumType & funcsArcBegin()
Access to the initial value of the arc parametrization.
Definition: param_func.hpp:187
NumType computeFuncDiff1(const std::size_t &_funcIdx) const
Computes 1st derivative of parametric function with index _funcIdx at parametric arc set by setEvalAr...
Definition: param_func.hpp:281
void shiftStartCtrlPtImplCRTP(const TNumType &_dt)
TNumType & ctrlPtValImplCRTP(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx, const CtrlPtDim &_ctrlPtDim)
const TNumType & funcsArcBeginImplVirt() const overridefinal
Definition: param_func.hpp:901
std::vector< std::size_t > func2Arc_
Maps the parametrized functions to their afferent arc parametrizations.
Definition: param_func.hpp:622
TNumType computeFuncInt2(const std::size_t &_funcIdx) const
Computes double integral of parametric function with index _funcIdx on interval [funcsArcBegin_, funcsArcEnd_].
Definition: param_func.hpp:511
TNumType computeFuncInt2ImplCRTP(const std::size_t &_funcIdx) const
Definition: param_func.hpp:835
FuncCtrlPt(const TNumType &_val, TNumType &_arc)
Definition: param_func.hpp:93
void setEvalArcImplCRTP(const TNumType &_arcEval, const typename ParamFuncsBaseCRTP< ParamFuncsBaseType >::eAG &_eAG)
Definition: param_func.hpp:805
TNumType funcsArcEval_
Arc parametrization at the evaluation point (set by setEvalArc)/.
const TNumType & funcsArcImplVirt(const std::size_t &_i, const std::size_t &_j) const overridefinal
Definition: param_func.hpp:931
FuncCtrlPtType & ctrlPt(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx)
Access of a parametric function control point.
Definition: param_func.hpp:229
EvalArcGuarantee
Flags if any guarantees about evaluation arc relative to last evaluation arc are present.
Definition: param_func.hpp:61
void initBase(const std::array< ParamFuncsStructure, TFuncSize > &_paramFuncsStructure)
TNumType computeFuncInt1ImplVirt(const std::size_t &_funcIdx) const overridefinal
Definition: param_func.hpp:787
std::size_t funcsSizeImplVirt() const overridefinal
Definition: param_func.hpp:871
void setEvalArc(const TNumType &_arcEval, const eAG &_eAG=eAG::NONE)
Sets parametric function evaluation arc.
Definition: param_func.hpp:477
NumType & funcsArcEnd()
Access to the final value of the arc parametrization.
Definition: param_func.hpp:199
const TNumType & ctrlPtValImplCRTP(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx, const CtrlPtDim &_ctrlPtDim) const
std::size_t funcCtrlPtSizeImplVirt(const std::size_t &_i) const overridefinal
Definition: param_func.hpp:889
const FuncCtrlPtType & ctrlPt(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx) const
Const access of a parametric function control point.
Definition: param_func.hpp:444
CtrlPtDim
Control point variable dimension.
Definition: param_func.hpp:55
TNumType & ctrlPtValImplVirt(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx, const CtrlPtDim &_ctrlPtDim) overridefinal
Definition: param_func.hpp:950
void initBase(const std::vector< ParamFuncsStructure > &_paramFuncsStructure)
Definition: param_func.hpp:972
const TNumType & funcsArcBeginImplCRTP() const
const TNumType & ctrlPtVal(const std::size_t &_funcIdx, const std::size_t &_funcCtrlPtIdx, const CtrlPtDim &_ctrlPtDim=CtrlPtDim::VAL) const
Const of a parametric function control point dimension.
Definition: param_func.hpp:457
friend class ParamFuncsBaseCRTP
void precompute()
Precomputes cached data.
Definition: param_func.hpp:471
ParamFuncsBase & operator=(const ParamFuncsBase &_other)
Definition: param_func.hpp:698
close to previous evaluation arc
std::array< std::vector< TNumType >, TArcLatticeSize > funcCtrlPtArc_
Stores the control points arc parameters for all the parametrized functions.
Definition: param_func.hpp:605
TNumType & funcsArcBeginImplVirt() overridefinal
Definition: param_func.hpp:895
NumType computeFuncVal(const std::size_t &_funcIdx) const
Computes value of parametric function with index _funcIdx at parametric arc set by setEvalArc...
Definition: param_func.hpp:274
std::size_t funcsArcSize(const std::size_t &_i) const
Number of control points of parametrization _i.
Definition: param_func.hpp:175
std::array< bool, nrModesMax_ > FuncEvalModesFlags
Definition: param_func.hpp:72
TNumType computeFuncDiff2ImplVirt(const std::size_t &_funcIdx) const overridefinal
Definition: param_func.hpp:781
void initImplCRTP(const TParamFucsStructVecArr &_paramFuncsStructure)
TNumType & funcsArcBegin()
Access to the initial value of the arc parametrization.
Definition: param_func.hpp:396
std::size_t funcsArcSizeImplCRTP() const
TNumType computeFuncDiff1ImplVirt(const std::size_t &_funcIdx) const overridefinal
Definition: param_func.hpp:775
FuncEvalMode
Required type of computation relative to the parametric function.
Definition: param_func.hpp:45
std::array< FuncEvalModesFlags, TFuncSize > funcEvalReq_
Flags for required function computation modes.
Definition: param_func.hpp:629
std::vector< std::vector< FuncCtrlPt< TNumType > > > funcCtrlPt_
Stores the control points for all the parametrized functions.
Definition: param_func.hpp:616
const TDerived & thisDerived() const
const TNumType & funcsArcEvalImplVirt() const overridefinal
Definition: param_func.hpp:919
void initImplVirt(const std::vector< ParamFuncsStructure > &_paramFuncsStructure) overridefinal
Definition: param_func.hpp:865
function double integral
const TNumType & funcsArcEndImplCRTP() const
TNumType & funcsArcImplVirt(const std::size_t &_i, const std::size_t &_j) overridefinal
Definition: param_func.hpp:925
const TNumType & funcsArcEval() const
Const access to the active evaluation point arc parametrization.
Definition: param_func.hpp:420
void setEvalArcImplVirt(const TNumType &_arcEval, const typename ParamFuncsBaseCRTP< ParamFuncsBaseType >::eAG &_eAG) overridefinal
Definition: param_func.hpp:762
this evaluation arc is at the arc parametrization begin
const NumType & funcsArcEval() const
Const access to the active evaluation point arc parametrization.
Definition: param_func.hpp:211
this evaluation arc is at the arc parametrization end
std::vector< std::vector< TNumType > > funcCtrlPtArc_
Stores the control points arc parameters for all the parametrized functions.
Definition: param_func.hpp:598
TNumType & funcsArcImplCRTP(const std::size_t &_i, const std::size_t &_j)
function first derivative
TNumType computeFuncValImplCRTP(const std::size_t &_funcIdx) const
Definition: param_func.hpp:811
const NumType & funcsArcBegin() const
Const access to the initial value of the arc parametrization.
Definition: param_func.hpp:193
const NumType & funcsArcEnd() const
Const access to the finall value of the arc parametrization.
Definition: param_func.hpp:205
std::size_t funcsArcSize(const std::size_t &_i) const
Number of control points of parametrization _i.
Definition: param_func.hpp:384
static constexpr const std::size_t nrModesMax_
Maximum number of computation modes (except the parametric function itself FUNC). Currently 4 other c...
Definition: param_func.hpp:71


tuw_control
Author(s): George Todoran
autogenerated on Mon Jun 10 2019 15:27:21