00001
00002
00008 #if !defined(__geom_ComplexWithFreeVertexOnManifold_h__)
00009 #define __geom_ComplexWithFreeVertexOnManifold_h__
00010
00011 #if defined(DEBUG_geom) && !defined(DEBUG_ComplexWithFreeVertexOnManifold)
00012 #define DEBUG_ComplexWithFreeVertexOnManifold
00013 #endif
00014
00015 #include "ComplexWithFreeVertex.h"
00016
00017 BEGIN_NAMESPACE_GEOM
00018
00019
00021
00052 template<template<int,typename> class QF,
00053 int N, int M,
00054 class _Manifold,
00055 typename T = double>
00056 class ComplexWithFreeVertexOnManifoldBase :
00057 public ComplexWithFreeVertex<QF,N,T> {
00058 private:
00059
00060
00061
00062
00063
00064 typedef ComplexWithFreeVertex<QF,N,T> Base;
00065
00066 public:
00067
00068
00069
00070
00071
00073 typedef typename Base::Number Number;
00074
00076 typedef typename Base::Vertex Vertex;
00077
00079 typedef _Manifold Manifold;
00080
00082 typedef ads::FixedArray<M,Number> ManifoldPoint;
00083
00085 typedef typename Base::Face Face;
00086
00087 protected:
00088
00089
00090
00091
00092
00094 const Manifold* _manifold;
00095
00096 private:
00097
00098
00099
00100
00101
00102
00103 ComplexWithFreeVertexOnManifoldBase
00104 (const ComplexWithFreeVertexOnManifoldBase&);
00105
00106
00107 ComplexWithFreeVertexOnManifoldBase&
00108 operator=(const ComplexWithFreeVertexOnManifoldBase&);
00109
00110 protected:
00111
00112
00115
00117 ComplexWithFreeVertexOnManifoldBase() :
00118 Base()
00119 {}
00120
00122 template<typename FaceIterator>
00123 ComplexWithFreeVertexOnManifoldBase(FaceIterator beginning,
00124 FaceIterator end) :
00125 Base(beginning, end),
00126 _manifold(0)
00127 {}
00128
00130 ~ComplexWithFreeVertexOnManifoldBase()
00131 {}
00132
00134
00137
00139 using Base::getFreeVertex;
00140
00142
00145
00147 using Base::set;
00148
00150 void
00151 setManifold(const Manifold* manifold) {
00152 assert(manifold != 0);
00153 _manifold = manifold;
00154 }
00155
00157
00160
00162 void
00163 computeBBox(const ManifoldPoint& point, BBox<N,T>* bb) {
00164 Base::computeBBox(computePosition(point), bb);
00165 }
00166
00168 Number
00169 computeContent(const ManifoldPoint& point) {
00170 return Base::computeContent(computePosition(point));
00171 }
00172
00174 void
00175 computeGradientOfContent(const Vertex& v, Vertex* gradient) {
00176 Base::computeGradientOfContent(v, gradient);
00177 }
00178
00180 Number
00181 computeNorm2(const Vertex& v) {
00182 return Base::computeNorm2(v);
00183 }
00184
00186 Number
00187 computeNorm2(const ManifoldPoint& point) {
00188 return Base::computeNorm2(computePosition(point));
00189 }
00190
00192 void
00193 computeGradientOfNorm2(const Vertex& v, Vertex* gradient) {
00194 Base::computeGradientOfNorm2(v, gradient);
00195 }
00196
00198 Number
00199 computeNorm2Modified(const Vertex& v) {
00200 return Base::computeNorm2Modified(v);
00201 }
00202
00204 Number
00205 computeNorm2Modified(const ManifoldPoint& point) {
00206 return Base::computeNorm2Modified(computePosition(point));
00207 }
00208
00210 void
00211 computeGradientOfNorm2Modified(const Vertex& v, Vertex* gradient) {
00212 Base::computeGradientOfNorm2Modified(v, gradient);
00213 }
00214
00215
00216 Vertex
00217 computePosition(const ManifoldPoint& point) {
00218 assert(_manifold != 0);
00219 return _manifold->computePosition(point);
00220 }
00221
00223 };
00224
00225
00226
00227
00228
00229
00230
00231
00232
00234
00265 template<template<int,typename> class QF,
00266 int N, int M,
00267 class _Manifold,
00268 typename T = double>
00269 class ComplexWithFreeVertexOnManifold;
00270
00271
00272
00273
00274
00275
00277
00309 template<template<int,typename> class QF,
00310 int N,
00311 class _Manifold,
00312 typename T>
00313 class ComplexWithFreeVertexOnManifold<QF,N,1,_Manifold,T> :
00314 public ComplexWithFreeVertexOnManifoldBase<QF,N,1,_Manifold,T> {
00315 private:
00316
00317
00318
00319
00320
00321 typedef ComplexWithFreeVertexOnManifoldBase<QF,N,1,_Manifold,T> Base;
00322
00323 public:
00324
00325
00326
00327
00328
00330 typedef typename Base::Number Number;
00331
00333 typedef typename Base::Vertex Vertex;
00334
00336 typedef typename Base::Manifold Manifold;
00337
00339 typedef typename Base::ManifoldPoint ManifoldPoint;
00340
00342 typedef typename Base::Face Face;
00343
00344 private:
00345
00346
00347
00348
00349
00350 using Base::_manifold;
00351
00352
00353
00354
00355
00356
00357 ComplexWithFreeVertexOnManifold(const ComplexWithFreeVertexOnManifold&);
00358
00359
00360 ComplexWithFreeVertexOnManifold&
00361 operator=(const ComplexWithFreeVertexOnManifold&);
00362
00363 public:
00364
00365
00368
00370 ComplexWithFreeVertexOnManifold()
00371 {}
00372
00374 template<typename FaceIterator>
00375 ComplexWithFreeVertexOnManifold(FaceIterator beginning, FaceIterator end) :
00376 Base(beginning, end)
00377 {}
00378
00380 ~ComplexWithFreeVertexOnManifold()
00381 {}
00382
00384
00387
00389 using Base::getFreeVertex;
00390
00392
00395
00397 using Base::set;
00398
00400 using Base::setManifold;
00401
00403
00406
00408 using Base::computeBBox;
00409
00411 using Base::computeContent;
00412
00414 void
00415 computeGradientOfContent(const ManifoldPoint& point,
00416 ManifoldPoint* gradient) {
00417
00418 Vertex spaceGradient;
00419 Base::computeGradientOfContent(computePosition(point), &spaceGradient);
00420
00421 (*gradient)[0] = computeDotProduct(spaceGradient,
00422 computeDerivative(point));
00423 }
00424
00426 using Base::computeNorm2;
00427
00429 void
00430 computeGradientOfNorm2(const ManifoldPoint& point,
00431 ManifoldPoint* gradient) {
00432
00433 Vertex spaceGradient;
00434 Base::computeGradientOfNorm2(computePosition(point), &spaceGradient);
00435
00436 (*gradient)[0] = computeDotProduct(spaceGradient,
00437 computeDerivative(point));
00438 }
00439
00441 using Base::computeNorm2Modified;
00442
00444 void
00445 computeGradientOfNorm2Modified(const ManifoldPoint& point,
00446 ManifoldPoint* gradient) {
00447
00448 Vertex spaceGradient;
00449 Base::computeGradientOfNorm2Modified(computePosition(point),
00450 &spaceGradient);
00451
00452 (*gradient)[0] = computeDotProduct(spaceGradient,
00453 computeDerivative(point));
00454 }
00455
00457
00458 private:
00459
00460
00461 using Base::computePosition;
00462
00463
00464 Vertex
00465 computeDerivative(const ManifoldPoint& point) {
00466 assert(_manifold != 0);
00467 return _manifold->computeDerivative(point);
00468 }
00469 };
00470
00471
00472
00473
00474
00475
00476
00477
00479
00511 template<template<int,typename> class QF,
00512 int N,
00513 class _Manifold,
00514 typename T>
00515 class ComplexWithFreeVertexOnManifold<QF,N,2,_Manifold,T> :
00516 public ComplexWithFreeVertexOnManifoldBase<QF,N,2,_Manifold,T> {
00517 private:
00518
00519
00520
00521
00522
00523 typedef ComplexWithFreeVertexOnManifoldBase<QF,N,2,_Manifold,T> Base;
00524
00525 public:
00526
00527
00528
00529
00530
00532 typedef typename Base::Number Number;
00533
00535 typedef typename Base::Vertex Vertex;
00536
00538 typedef typename Base::Manifold Manifold;
00539
00541 typedef typename Base::ManifoldPoint ManifoldPoint;
00542
00544 typedef typename Base::Face Face;
00545
00546 private:
00547
00548
00549
00550
00551
00552 using Base::_manifold;
00553
00554
00555
00556
00557
00558
00559 ComplexWithFreeVertexOnManifold(const ComplexWithFreeVertexOnManifold&);
00560
00561
00562 ComplexWithFreeVertexOnManifold&
00563 operator=(const ComplexWithFreeVertexOnManifold&);
00564
00565 public:
00566
00567
00570
00572 ComplexWithFreeVertexOnManifold()
00573 {}
00574
00576 template<typename FaceIterator>
00577 ComplexWithFreeVertexOnManifold(FaceIterator beginning, FaceIterator end) :
00578 Base(beginning, end)
00579 {}
00580
00582 ~ComplexWithFreeVertexOnManifold()
00583 {}
00584
00586
00589
00591 using Base::getFreeVertex;
00592
00594
00597
00599 using Base::set;
00600
00602 using Base::setManifold;
00603
00605
00608
00610 using Base::computeBBox;
00611
00613 using Base::computeContent;
00614
00616 void
00617 computeGradientOfContent(const ManifoldPoint& point,
00618 ManifoldPoint* gradient) {
00619
00620 Vertex spaceGradient;
00621 Base::computeGradientOfContent(computePosition(point), &spaceGradient);
00622
00623 Vertex dxds, dxdt;
00624 #ifdef __INTEL_COMPILER
00625
00626
00627
00628 assert(_manifold != 0);
00629 _manifold->computeDerivative(point, &dxds, &dxdt)
00630 #else
00631 computeDerivative(point, &dxds, &dxdt)
00632 #endif
00633 (*gradient)[0] = computeDotProduct(spaceGradient, dxds);
00634 (*gradient)[1] = computeDotProduct(spaceGradient, dxdt);
00635 }
00636
00638 using Base::computeNorm2;
00639
00641 void
00642 computeGradientOfNorm2(const ManifoldPoint& point,
00643 ManifoldPoint* gradient) {
00644
00645 Vertex spaceGradient;
00646 Base::computeGradientOfNorm2(computePosition(point), &spaceGradient);
00647
00648 Vertex dxds, dxdt;
00649 #ifdef __INTEL_COMPILER
00650
00651
00652
00653 assert(_manifold != 0);
00654 _manifold->computeDerivative(point, &dxds, &dxdt)
00655 #else
00656 computeDerivative(point, &dxds, &dxdt)
00657 #endif
00658 (*gradient)[0] = computeDotProduct(spaceGradient, dxds);
00659 (*gradient)[1] = computeDotProduct(spaceGradient, dxdt);
00660 }
00661
00663 using Base::computeNorm2Modified;
00664
00666 void
00667 computeGradientOfNorm2Modified(const ManifoldPoint& point,
00668 ManifoldPoint* gradient) {
00669
00670 Vertex spaceGradient;
00671 Base::computeGradientOfNorm2Modified(computePosition(point),
00672 &spaceGradient);
00673
00674 Vertex dxds, dxdt;
00675 computeDerivative(point, &dxds, &dxdt);
00676 (*gradient)[0] = computeDotProduct(spaceGradient, dxds);
00677 (*gradient)[1] = computeDotProduct(spaceGradient, dxdt);
00678 }
00679
00681
00682 private:
00683
00684
00685 using Base::computePosition;
00686
00687
00688 void
00689 computeDerivative(const ManifoldPoint& point, Vertex* dxds, Vertex* dxdt) {
00690 assert(_manifold != 0);
00691 _manifold->computeDerivative(point, dxds, dxdt);
00692 }
00693 };
00694
00695
00696
00697
00698
00699
00700
00701
00703 template<class Complex>
00704 class ComplexManifoldNorm2 :
00705 public std::unary_function<typename Complex::ManifoldPoint,
00706 typename Complex::Number> {
00707 private:
00708
00709 typedef std::unary_function<typename Complex::ManifoldPoint,
00710 typename Complex::Number> Base;
00711
00712 public:
00713
00715 typedef typename Base::argument_type argument_type;
00717 typedef typename Base::result_type result_type;
00718
00719 private:
00720
00721 mutable Complex& _sc;
00722
00723
00724 ComplexManifoldNorm2();
00725
00726
00727 ComplexManifoldNorm2&
00728 operator=(const ComplexManifoldNorm2&);
00729
00730 public:
00731
00733 ComplexManifoldNorm2(Complex& sc) :
00734 _sc(sc)
00735 {}
00736
00738 ComplexManifoldNorm2(const ComplexManifoldNorm2& other) :
00739 _sc(other._sc)
00740 {}
00741
00743 Complex&
00744 getComplex() const {
00745 return _sc;
00746 }
00747
00749 result_type
00750 operator()(const argument_type& x) const {
00751 return _sc.computeNorm2(x);
00752 }
00753
00755 void
00756 gradient(const argument_type& x, argument_type& grad) const {
00757 _sc.computeGradientOfNorm2(x, &grad);
00758 }
00759 };
00760
00761
00762
00763
00765 template<class Complex>
00766 class ComplexManifoldNorm2Mod :
00767 public std::unary_function<typename Complex::ManifoldPoint,
00768 typename Complex::Number> {
00769 private:
00770
00771 typedef std::unary_function<typename Complex::ManifoldPoint,
00772 typename Complex::Number> Base;
00773
00774 public:
00775
00777 typedef typename Base::argument_type argument_type;
00779 typedef typename Base::result_type result_type;
00780
00781 private:
00782
00783 mutable Complex& _sc;
00784
00785
00786 ComplexManifoldNorm2Mod();
00787
00788
00789 ComplexManifoldNorm2Mod&
00790 operator=(const ComplexManifoldNorm2Mod&);
00791
00792 public:
00793
00795 ComplexManifoldNorm2Mod(Complex& sc) :
00796 _sc(sc)
00797 {}
00798
00800 ComplexManifoldNorm2Mod(const ComplexManifoldNorm2Mod& x) :
00801 _sc(x._sc)
00802 {}
00803
00805 Complex&
00806 getComplex() const {
00807 return _sc;
00808 }
00809
00811 result_type
00812 operator()(const argument_type& x) const {
00813 return _sc.computeNorm2Modified(x);
00814 }
00815
00817 void
00818 gradient(const argument_type& x, argument_type& grad) const {
00819 _sc.computeGradientOfNorm2Modified(x, &grad);
00820 }
00821 };
00822
00823 END_NAMESPACE_GEOM
00824
00825 #define __geom_ComplexWithFreeVertexOnManifold_ipp__
00826 #include "ComplexWithFreeVertexOnManifold.ipp"
00827 #undef __geom_ComplexWithFreeVertexOnManifold_ipp__
00828
00829 #endif