DGtal  1.3.beta
PolygonalCalculus.h
1 
17 #pragma once
18 
30 // Inclusions
32 #include <iostream>
33 #include <functional>
34 #include <vector>
35 #include <string>
36 #include <map>
37 #include <unordered_map>
38 #include "DGtal/base/ConstAlias.h"
39 #include "DGtal/base/Common.h"
40 #include "DGtal/shapes/SurfaceMesh.h"
41 #include "DGtal/math/linalg/EigenSupport.h"
43 
44 namespace DGtal
45 {
46 
48 // template class PolygonalCalculus
69 template <typename TRealPoint, typename TRealVector>
71 {
72  // ----------------------- Standard services ------------------------------
73 public:
74 
76  static const Dimension dimension = TRealPoint::dimension;
77  BOOST_STATIC_ASSERT( ( dimension == 3 ) );
78 
81 
85  typedef typename MySurfaceMesh::Vertex Vertex;
87  typedef typename MySurfaceMesh::Face Face;
92 
98  typedef Vector Form;
105 
108 
111 
117  bool globalInternalCacheEnabled = false):
118  mySurfaceMesh(&surf), myGlobalCacheEnabled(globalInternalCacheEnabled)
119  {
120  myEmbedder =[&](Face f,Vertex v){ return mySurfaceMesh->position(v);};
122  init();
123  };
124 
132  const std::function<Real3dPoint(Face,Vertex)> &embedder,
133  bool globalInternalCacheEnabled = false):
134  mySurfaceMesh(&surf), myEmbedder(embedder), myGlobalCacheEnabled(globalInternalCacheEnabled)
135  {
137  init();
138  };
139 
147  const std::function<Real3dVector(Vertex)> &embedder,
148  bool globalInternalCacheEnabled = false):
149  mySurfaceMesh(&surf), myVertexNormalEmbedder(embedder),
150  myGlobalCacheEnabled(globalInternalCacheEnabled)
151  {
152  myEmbedder = [&](Face f,Vertex v){ return mySurfaceMesh->position(v); };
153  init();
154  };
155 
167  const std::function<Real3dPoint(Face,Vertex)> &pos_embedder,
168  const std::function<Vector(Vertex)> &normal_embedder,
169  bool globalInternalCacheEnabled = false) :
170  mySurfaceMesh(&surf), myEmbedder(pos_embedder),
171  myVertexNormalEmbedder(normal_embedder),
172  myGlobalCacheEnabled(globalInternalCacheEnabled)
173  {
174  init();
175  };
176 
180  PolygonalCalculus() = delete;
181 
185  ~PolygonalCalculus() = default;
186 
191  PolygonalCalculus ( const PolygonalCalculus & other ) = delete;
192 
197  PolygonalCalculus ( PolygonalCalculus && other ) = delete;
198 
204  PolygonalCalculus & operator= ( const PolygonalCalculus & other ) = delete;
205 
211  PolygonalCalculus & operator= ( PolygonalCalculus && other ) = delete;
212 
214 
215  // ----------------------- embedding services --------------------------
216  //MARK: Embedding services
219 
222  void setEmbedder(const std::function<Real3dPoint(Face,Vertex)> &externalFunctor)
223  {
224  myEmbedder = externalFunctor;
225  }
226 
227 
228  // ----------------------- Per face operators --------------------------------------
229  //MARK: Per face operator on scalars
232 
236  DenseMatrix X(const Face f) const
237  {
238  if (checkCache(X_,f))
239  return myGlobalCache[X_][f];
240 
241  const auto vertices = mySurfaceMesh->incidentVertices(f);
242  const auto nf = myFaceDegree[f];
243  DenseMatrix Xt(nf,3);
244  size_t cpt=0;
245  for(auto v: vertices)
246  {
247  Xt(cpt,0) = myEmbedder(f,v)[0];
248  Xt(cpt,1) = myEmbedder(f,v)[1];
249  Xt(cpt,2) = myEmbedder(f,v)[2];
250  ++cpt;
251  }
252 
253  setInCache(X_,f,Xt);
254  return Xt;
255  }
256 
257 
261  DenseMatrix D(const Face f) const
262  {
263  if (checkCache(D_,f))
264  return myGlobalCache[D_][f];
265 
266  const auto nf = myFaceDegree[f];
267  DenseMatrix d = DenseMatrix::Zero(nf ,nf);
268  for(auto i=0; i < nf; ++i)
269  {
270  d(i,i) = -1.;
271  d(i, (i+1)%nf) = 1.;
272  }
273 
274  setInCache(D_,f,d);
275  return d;
276  }
277 
281  DenseMatrix E(const Face f) const
282  {
283  if (checkCache(E_,f))
284  return myGlobalCache[E_][f];
285 
286  DenseMatrix op = D(f)*X(f);
287 
288  setInCache(E_,f,op);
289  return op;
290  }
291 
295  DenseMatrix A(const Face f) const
296  {
297  if (checkCache(A_,f))
298  return myGlobalCache[A_][f];
299 
300  const auto nf = myFaceDegree[f];
301  DenseMatrix a = DenseMatrix::Zero(nf ,nf);
302  for(auto i=0; i < nf; ++i)
303  {
304  a(i, (i+1)%nf) = 0.5;
305  a(i,i) = 0.5;
306  }
307 
308  setInCache(A_,f,a);
309  return a;
310  }
311 
312 
316  Vector vectorArea(const Face f) const
317  {
318  Real3dPoint af(0.0,0.0,0.0);
319  const auto vertices = mySurfaceMesh->incidentVertices(f);
320  auto it = vertices.cbegin();
321  auto itnext = vertices.cbegin();
322  ++itnext;
323  while (it != vertices.cend())
324  {
325  auto xi = myEmbedder(f,*it);
326  auto xip = myEmbedder(f,*itnext);
327  af += xi.crossProduct(xip);
328  ++it;
329  ++itnext;
330  if (itnext == vertices.cend())
331  itnext = vertices.cbegin();
332  }
333  Eigen::Vector3d output = {af[0],af[1],af[2]};
334  return 0.5*output;
335  }
336 
340  double faceArea(const Face f) const
341  {
342  return vectorArea(f).norm();
343  }
344 
348  Vector faceNormal(const Face f) const
349  {
350  Vector v = vectorArea(f);
351  v.normalize();
352  return v;
353  }
354 
359  {
360  Vector v = faceNormal(f);
361  return {v(0),v(1),v(2)};
362  }
363 
367  DenseMatrix coGradient(const Face f) const
368  {
369  if (checkCache(COGRAD_,f))
370  return myGlobalCache[COGRAD_][f];
371  DenseMatrix op = E(f).transpose() * A(f);
372  setInCache(COGRAD_, f, op);
373  return op;
374  }
375 
378  DenseMatrix bracket(const Vector &n) const
379  {
380  DenseMatrix brack(3,3);
381  brack << 0.0 , -n(2), n(1),
382  n(2), 0.0 , -n(0),
383  -n(1) , n(0),0.0 ;
384  return brack;
385  }
386 
390  DenseMatrix gradient(const Face f) const
391  {
392  if (checkCache(GRAD_,f))
393  return myGlobalCache[GRAD_][f];
394 
395  DenseMatrix op = -1.0/faceArea(f) * bracket( faceNormal(f) ) * coGradient(f);
396 
397  setInCache(GRAD_,f,op);
398  return op;
399  }
400 
404  DenseMatrix flat(const Face f) const
405  {
406  if (checkCache(FLAT_,f))
407  return myGlobalCache[FLAT_][f];
408  DenseMatrix n = faceNormal(f);
409  DenseMatrix op = E(f)*( DenseMatrix::Identity(3,3) - n*n.transpose());
410  setInCache(FLAT_,f,op);
411  return op;
412  }
413 
417  DenseMatrix B(const Face f) const
418  {
419  if (checkCache(B_,f))
420  return myGlobalCache[B_][f];
421  DenseMatrix res = A(f) * X(f);
422  setInCache(B_,f,res);
423  return res;
424  }
425 
428  Vector centroid(const Face f) const
429  {
430  const auto nf = myFaceDegree[f];
431  return 1.0/(double)nf * X(f).transpose() * Vector::Ones(nf);
432  }
433 
437  {
438  const Vector c = centroid(f);
439  return {c(0),c(1),c(2)};
440  }
441 
445  DenseMatrix sharp(const Face f) const
446  {
447  if (checkCache(SHARP_,f))
448  return myGlobalCache[SHARP_][f];
449 
450  const auto nf = myFaceDegree[f];
451  DenseMatrix op = 1.0/faceArea(f) * bracket(faceNormal(f)) *
452  ( B(f).transpose() - centroid(f)* Vector::Ones(nf).transpose() );
453 
454  setInCache(SHARP_,f,op);
455  return op;
456  }
457 
461  DenseMatrix P(const Face f) const
462  {
463  if (checkCache(P_,f))
464  return myGlobalCache[P_][f];
465 
466  const auto nf = myFaceDegree[f];
467  DenseMatrix op = DenseMatrix::Identity(nf,nf) - flat(f)*sharp(f);
468 
469  setInCache(P_, f, op);
470  return op;
471  }
472 
477  DenseMatrix M(const Face f, const double lambda=1.0) const
478  {
479  if (checkCache(M_,f))
480  return myGlobalCache[M_][f];
481 
482  DenseMatrix Uf = sharp(f);
483  DenseMatrix Pf = P(f);
484  DenseMatrix op = faceArea(f) * Uf.transpose()*Uf + lambda * Pf.transpose()*Pf;
485 
486  setInCache(M_,f,op);
487  return op;
488  }
489 
505  DenseMatrix divergence(const Face f, const double lambda=1.0) const
506  {
507  if (checkCache(DIVERGENCE_,f))
508  return myGlobalCache[DIVERGENCE_][f];
509 
510  DenseMatrix op = -1.0 * D(f).transpose() * M(f);
511  setInCache(DIVERGENCE_,f,op);
512 
513  return op;
514  }
515 
519  DenseMatrix curl(const Face f) const
520  {
521  if (checkCache(CURL_,f))
522  return myGlobalCache[CURL_][f];
523 
524  DenseMatrix op = DenseMatrix::Identity(myFaceDegree[f],myFaceDegree[f]);
525 
526  setInCache(CURL_,f,op);
527  return op;
528  }
529 
530 
545  DenseMatrix laplaceBeltrami(const Face f, const double lambda=1.0) const
546  {
547  if (checkCache(L_,f))
548  return myGlobalCache[L_][f];
549 
550  DenseMatrix Df = D(f);
551  // Laplacian is a negative operator.
552  DenseMatrix op = -1.0 * Df.transpose() * M(f,lambda) * Df;
553 
554  setInCache(L_, f, op);
555  return op;
556  }
558 
559  // ----------------------- Vector calculus----------------------------------
560  //MARK: Vector Field Calculus
563 
564 public:
567  DenseMatrix Tv(const Vertex & v) const
568  {
569  Eigen::Vector3d nv = n_v(v);
570  ASSERT(std::abs(nv.norm() - 1.0) < 0.001);
571  const auto & N = getSurfaceMeshPtr()->neighborVertices(v);
572  auto neighbor = *N.begin();
573  Real3dPoint tangentVector = getSurfaceMeshPtr()->position(v) -
574  getSurfaceMeshPtr()->position(neighbor);
575  Eigen::Vector3d w = toVec3(tangentVector);
576  Eigen::Vector3d uu = project(w,nv).normalized();
577  Eigen::Vector3d vv = nv.cross(uu);
578 
579  DenseMatrix tanB(3,2);
580  tanB.col(0) = uu;
581  tanB.col(1) = vv;
582  return tanB;
583  }
584 
587  DenseMatrix Tf(const Face & f) const
588  {
589  Eigen::Vector3d nf = faceNormal(f);
590  ASSERT(std::abs(nf.norm() - 1.0) < 0.001);
591  const auto & N = getSurfaceMeshPtr()->incidentVertices(f);
592  auto v1 = *(N.begin());
593  auto v2 = *(N.begin() + 1);
594  Real3dPoint tangentVector =
596  Eigen::Vector3d w = toVec3(tangentVector);
597  Eigen::Vector3d uu = project(w,nf).normalized();
598  Eigen::Vector3d vv = nf.cross(uu);
599 
600  DenseMatrix tanB(3,2);
601  tanB.col(0) = uu;
602  tanB.col(1) = vv;
603  return tanB;
604  }
605 
611  Vector toExtrinsicVector(const Vertex v, const Vector & I) const
612  {
613  DenseMatrix T = Tv(v);
614  return T.col(0) * I(0) + T.col(1) * I(1);
615  }
616 
621  std::vector<Vector> toExtrinsicVectors(const std::vector<Vector> & I) const
622  {
623  std::vector<Vector> ext(mySurfaceMesh->nbVertices());
624  for (auto v = 0; v < mySurfaceMesh->nbVertices(); v++)
625  ext[v] = toExtrinsicVector(v,I[v]);
626  return ext;
627  }
628 
631  DenseMatrix Qvf(const Vertex & v, const Face & f) const
632  {
633  Eigen::Vector3d nf = faceNormal(f);
634  Eigen::Vector3d nv = n_v(v);
635  double c = nv.dot(nf);
636  ASSERT(std::abs( c + 1.0) > 0.0001);
637  auto vv = nv.cross(nf);
638  DenseMatrix skew = bracket(vv);
639  return Eigen::Matrix3d::Identity() + skew +
640  1.0 / (1.0 + c) * skew * skew;
641  }
642 
645  DenseMatrix Rvf(const Vertex & v, const Face & f) const
646  {
647  return Tf(f).transpose() * Qvf(v,f) * Tv(v);
648  }
649 
653  {
654  DenseMatrix N(myFaceDegree[f],3);
655  uint cpt = 0;
657  {
658  N.block(cpt,0,3,1) = n_v(v).transpose();
659  cpt++;
660  }
661  DenseMatrix GN = gradient(f) * N, Tf = T_f(f);
662 
663  return 0.5 * Tf.transpose() * (GN + GN.transpose()) * Tf;
664  }
665 
674  {
675  DenseMatrix uf_nabla(myFaceDegree[f], 2);
676  size_t cpt = 0;
677  for (auto v : mySurfaceMesh->incidentVertices(f))
678  {
679  uf_nabla.block(cpt,0,1,2) =
680  (Rvf(v,f) * uf.block(2 * cpt,0,2,1)).transpose();
681  ++cpt;
682  }
683  return uf_nabla;
684  }
685 
696  {
697  return Tf(f).transpose() * gradient(f) *
699  }
700 
712  {
713  return P(f) * D(f) * transportAndFormatVectorField(f,uf);
714  }
715 
722  {
723  return kroneckerWithI2(Tf(f).transpose() * gradient(f)) * blockConnection(f);
724  }
725 
732  {
733  return kroneckerWithI2(P(f) * D(f)) * blockConnection(f);
734  ;
735  }
736 
749  DenseMatrix connectionLaplacian(const Face & f, double lambda = 1.0) const
750  {
751  if (checkCache(CON_L_,f))
752  return myGlobalCache[CON_L_][f];
755  DenseMatrix L = -(faceArea(f) * G.transpose() * G + lambda * P.transpose() * P);
756  setInCache(CON_L_,f,L);
757  return L;
758  }
760 
761  // ----------------------- Global operators --------------------------------------
762  //MARK: Global Operators
765 
767  Form form0() const
768  {
769  return Form::Zero( nbVertices() );
770  }
773  {
774  SparseMatrix Id0( nbVertices(), nbVertices() );
775  Id0.setIdentity();
776  return Id0;
777  }
778 
794  SparseMatrix globalLaplaceBeltrami(const double lambda=1.0) const
795  {
797  std::vector<Triplet> triplets;
798  for( auto f = 0; f < mySurfaceMesh->nbFaces(); ++f )
799  {
800  auto nf = myFaceDegree[f];
801  DenseMatrix Lap = this->laplaceBeltrami(f,lambda);
802  const auto vertices = mySurfaceMesh->incidentVertices(f);
803  for(auto i=0; i < nf; ++i)
804  for(auto j=0; j < nf; ++j)
805  {
806  auto v = Lap(i,j);
807  if (v!= 0.0)
808  triplets.emplace_back( Triplet( (SparseMatrix::StorageIndex)vertices[ i ], (SparseMatrix::StorageIndex)vertices[ j ],
809  Lap( i, j ) ) );
810  }
811  }
812  lapGlobal.setFromTriplets(triplets.begin(), triplets.end());
813  return lapGlobal;
814  }
815 
822  {
824  std::vector<Triplet> triplets;
825  for ( auto v = 0; v < mySurfaceMesh->nbVertices(); ++v )
826  {
827  auto faces = mySurfaceMesh->incidentFaces(v);
828  auto varea = 0.0;
829  for(auto f: faces)
830  varea += faceArea(f) /(double)myFaceDegree[f];
831  triplets.emplace_back(Triplet(v,v,varea));
832  }
833  M.setFromTriplets(triplets.begin(),triplets.end());
834  return M;
835  }
836 
842  {
844  for ( int k = 0; k < iM0.outerSize(); ++k )
845  for ( typename SparseMatrix::InnerIterator it( iM0, k ); it; ++it )
846  it.valueRef() = 1.0 / it.value();
847  return iM0;
848  }
849 
867  SparseMatrix globalConnectionLaplace(const double lambda = 1.0) const
868  {
869  auto nv = mySurfaceMesh->nbVertices();
870  SparseMatrix lapGlobal(2 * nv, 2 * nv);
871  SparseMatrix local(2 * nv, 2 * nv);
872  std::vector<Triplet> triplets;
873  for (auto f = 0; f < mySurfaceMesh->nbFaces(); f++)
874  {
875  auto nf = degree(f);
876  DenseMatrix Lap = connectionLaplacian(f,lambda);
877  const auto vertices = mySurfaceMesh->incidentVertices(f);
878  for (auto i = 0u; i < nf; ++i)
879  for (auto j = 0u; j < nf; ++j)
880  for (short k1 = 0; k1 < 2; k1++)
881  for (short k2 = 0; k2 < 2; k2++)
882  {
883  auto v = Lap(2 * i + k1, 2 * j + k2);
884  if (v != 0.0)
885  triplets.emplace_back(Triplet(2 * vertices[i] + k1,
886  2 * vertices[j] + k2, v));
887  }
888  }
889  lapGlobal.setFromTriplets(triplets.begin(), triplets.end());
890  return lapGlobal;
891  }
892 
900  {
901  auto nv = mySurfaceMesh->nbVertices();
902  SparseMatrix M(2 * nv, 2 * nv);
903  std::vector<Triplet> triplets;
904  for (auto v = 0; v < mySurfaceMesh->nbVertices(); ++v)
905  {
906  auto faces = mySurfaceMesh->incidentFaces(v);
907  auto varea = 0.0;
908  for (auto f : faces)
909  varea += faceArea(f) / (double)myFaceDegree[f];
910  triplets.emplace_back(Triplet(2 * v, 2 * v, varea));
911  triplets.emplace_back(Triplet(2 * v + 1, 2 * v + 1, varea));
912  }
913  M.setFromTriplets(triplets.begin(), triplets.end());
914  return M;
915  }
917 
918  // ----------------------- Cache mechanism --------------------------------------
921 
938  std::vector<DenseMatrix> getOperatorCacheMatrix(const std::function<DenseMatrix(Face)> &perFaceOperator) const
939  {
940  std::vector<DenseMatrix> cache;
941  for(auto f=0; f < mySurfaceMesh->nbFaces(); ++f)
942  cache.push_back(perFaceOperator(f));
943  return cache;
944  }
945 
962  std::vector<Vector> getOperatorCacheVector(const std::function<Vector(Face)> &perFaceVectorOperator) const
963  {
964  std::vector<Vector> cache;
965  for(auto f=0; f < mySurfaceMesh->nbFaces(); ++f)
966  cache.push_back(perFaceVectorOperator(f));
967  return cache;
968  }
969 
973  {
974  myGlobalCacheEnabled = true;
975  }
976 
980  {
981  myGlobalCacheEnabled = false;
982  myGlobalCache.clear();
983  }
984 
986 
987  // ----------------------- Common --------------------------------------
988 public:
991 
994  void init()
995  {
997  }
998 
1002  size_t faceDegree(Face f) const
1003  {
1004  return myFaceDegree[f];
1005  }
1006 
1008  size_t nbVertices() const
1009  {
1010  return mySurfaceMesh->nbVertices();
1011  }
1012 
1014  size_t nbFaces() const
1015  {
1016  return mySurfaceMesh->nbFaces();
1017  }
1018 
1021  size_t degree(const Face f) const
1022  {
1023  return myFaceDegree[f];
1024  }
1025 
1028  {
1029  return mySurfaceMesh;
1030  }
1031 
1036  void selfDisplay ( std::ostream & out ) const
1037  {
1038  out << "[PolygonalCalculus]: ";
1040  out<< "internal cache enabled, ";
1041  else
1042  out<<"internal cache disabled, ";
1043  out <<"SurfaceMesh="<<*mySurfaceMesh;
1044  }
1045 
1050  bool isValid() const
1051  {
1052  return true;
1053  }
1054 
1056 
1057  // ------------------------- Protected Datas ------------------------------
1058  //MARK: Protected
1059 
1060 protected:
1063 
1066 
1069  {
1070  myFaceDegree.resize(mySurfaceMesh->nbFaces());
1071  for(auto f = 0; f < mySurfaceMesh->nbFaces(); ++f)
1072  {
1073  auto vertices = mySurfaceMesh->incidentVertices(f);
1074  auto nf = vertices.size();
1075  myFaceDegree[f] = nf;
1076  }
1077  }
1078 
1083  bool checkCache(OPERATOR key, const Face f) const
1084  {
1086  if (myGlobalCache[key].find(f) != myGlobalCache[key].end())
1087  return true;
1088  return false;
1089  }
1090 
1095  void setInCache(OPERATOR key, const Face f,
1096  const DenseMatrix &ope) const
1097  {
1099  myGlobalCache[key][f] = ope;
1100  }
1101 
1106  static Vector project(const Vector & u, const Vector & n)
1107  {
1108  return u - (u.dot(n) / n.squaredNorm()) * n;
1109  }
1110 
1115  static Vector toVector(const Eigen::Vector3d & x)
1116  {
1117  Vector X(3);
1118  for (int i = 0; i < 3; i++)
1119  X(i) = x(i);
1120  return X;
1121  }
1122 
1126  static Eigen::Vector3d toVec3(const Real3dPoint & x)
1127  {
1128  return Eigen::Vector3d(x(0),x(1),x(2));
1129  }
1130 
1135  static Real3dVector toReal3dVector(const Eigen::Vector3d & x)
1136  {
1137  return { x(0), x(1), x(2)};
1138  }
1139 
1140 
1147  {
1148  Vector n(3);
1149  n(0) = 0.;
1150  n(1) = 0.;
1151  n(2) = 0.;
1152  for (auto f : mySurfaceMesh->incidentFaces(v))
1153  n += vectorArea(f);
1154  return n.normalized();
1155  }
1156 
1159  Eigen::Vector3d n_v(const Vertex & v) const
1160  {
1161  return toVec3(myVertexNormalEmbedder(v));
1162  }
1163 
1164  //Covariant operators routines
1167  {
1168  auto nf = degree(f);
1169  DenseMatrix RU_fO = DenseMatrix::Zero(nf * 2,nf * 2);
1170  size_t cpt = 0;
1171  for (auto v : getSurfaceMeshPtr()->incidentVertices(f))
1172  {
1173  auto Rv = Rvf(v,f);
1174  RU_fO.block<2,2>(2 * cpt,2 * cpt) = Rv;
1175  ++cpt;
1176  }
1177  return RU_fO;
1178  }
1179 
1182  {
1183  size_t h = M.rows();
1184  size_t w = M.cols();
1185  DenseMatrix MK = DenseMatrix::Zero(h * 2,w * 2);
1186  for (size_t j = 0; j < h; j++)
1187  for (size_t i = 0; i < w; i++)
1188  {
1189  MK(2 * j, 2 * i) = M(j, i);
1190  MK(2 * j + 1, 2 * i + 1) = M(j, i);
1191  }
1192  return MK;
1193  }
1194 
1195 
1196 
1198 
1199  // ------------------------- Internals ------------------------------------
1200  //MARK: Internals
1201 private:
1202 
1205 
1207  std::function<Real3dPoint(Face, Vertex)> myEmbedder;
1208 
1211 
1213  std::vector<size_t> myFaceDegree;
1214 
1217  mutable std::array<std::unordered_map<Face,DenseMatrix>, 15> myGlobalCache;
1218 
1219 }; // end of class PolygonalCalculus
1220 
1227 template <typename TP, typename TV>
1228 std::ostream&
1229 operator<< ( std::ostream & out, const PolygonalCalculus<TP,TV> & object )
1230 {
1231  object.selfDisplay( out );
1232  return out;
1233 }
1234 
1235 } // namespace DGtal
DGtal::SurfaceMesh::Vertex
Index Vertex
Definition: SurfaceMesh.h:108
DGtal::PolygonalCalculus::Face
MySurfaceMesh::Face Face
Face type.
Definition: PolygonalCalculus.h:87
DGtal::PolygonalCalculus::getOperatorCacheMatrix
std::vector< DenseMatrix > getOperatorCacheMatrix(const std::function< DenseMatrix(Face)> &perFaceOperator) const
Definition: PolygonalCalculus.h:938
DGtal::PolygonalCalculus::DIVERGENCE_
@ DIVERGENCE_
Definition: PolygonalCalculus.h:1065
DGtal::PolygonalCalculus::updateFaceDegree
void updateFaceDegree()
Update the face degree cache.
Definition: PolygonalCalculus.h:1068
DGtal::PolygonalCalculus::vectorArea
Vector vectorArea(const Face f) const
Definition: PolygonalCalculus.h:316
DGtal::PolygonalCalculus::A_
@ A_
Definition: PolygonalCalculus.h:1065
DGtal::PolygonalCalculus::Form
Vector Form
Global 0-form, 1-form, 2-form are Vector.
Definition: PolygonalCalculus.h:98
DGtal::SurfaceMesh::position
RealPoint & position(Vertex v)
Definition: SurfaceMesh.h:637
DGtal::ConstAlias
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
DGtal::PolygonalCalculus::toExtrinsicVectors
std::vector< Vector > toExtrinsicVectors(const std::vector< Vector > &I) const
Definition: PolygonalCalculus.h:621
DGtal::SurfaceMesh::RealVector
TRealVector RealVector
Definition: SurfaceMesh.h:94
DGtal::PolygonalCalculus::faceNormalAsDGtalVector
Real3dVector faceNormalAsDGtalVector(const Face f) const
Definition: PolygonalCalculus.h:358
DGtal::PolygonalCalculus::X_
@ X_
Definition: PolygonalCalculus.h:1065
DGtal::PolygonalCalculus::globalLaplaceBeltrami
SparseMatrix globalLaplaceBeltrami(const double lambda=1.0) const
Definition: PolygonalCalculus.h:794
DGtal::PolygonalCalculus::selfDisplay
void selfDisplay(std::ostream &out) const
Definition: PolygonalCalculus.h:1036
DGtal::PolygonalCalculus::SparseMatrix
LinAlg::SparseMatrix SparseMatrix
Type of sparse matrix.
Definition: PolygonalCalculus.h:102
DGtal::PolygonalCalculus::L_
@ L_
Definition: PolygonalCalculus.h:1065
DGtal::PolygonalCalculus::PolygonalCalculus
PolygonalCalculus(const ConstAlias< MySurfaceMesh > surf, bool globalInternalCacheEnabled=false)
Definition: PolygonalCalculus.h:116
DGtal::PolygonalCalculus::transportAndFormatVectorField
DenseMatrix transportAndFormatVectorField(const Face f, const Vector &uf)
Definition: PolygonalCalculus.h:673
DGtal::PolygonalCalculus::centroidAsDGtalPoint
Real3dPoint centroidAsDGtalPoint(const Face f) const
Definition: PolygonalCalculus.h:436
DGtal::PolygonalCalculus::setInCache
void setInCache(OPERATOR key, const Face f, const DenseMatrix &ope) const
Definition: PolygonalCalculus.h:1095
DGtal::PolygonalCalculus::PolygonalCalculus
PolygonalCalculus(const ConstAlias< MySurfaceMesh > surf, const std::function< Real3dPoint(Face, Vertex)> &pos_embedder, const std::function< Vector(Vertex)> &normal_embedder, bool globalInternalCacheEnabled=false)
Definition: PolygonalCalculus.h:166
DGtal::Dimension
DGtal::uint32_t Dimension
Definition: Common.h:137
DGtal::SurfaceMesh
Aim: Represents an embedded mesh as faces and a list of vertices. Vertices may be shared among faces ...
Definition: SurfaceMesh.h:91
DGtal::PolygonalCalculus::divergence
DenseMatrix divergence(const Face f, const double lambda=1.0) const
Definition: PolygonalCalculus.h:505
DGtal::PolygonalCalculus::faceArea
double faceArea(const Face f) const
Definition: PolygonalCalculus.h:340
DGtal::PolygonalCalculus::dimension
static const Dimension dimension
Concept checking.
Definition: PolygonalCalculus.h:76
DGtal::PolygonalCalculus::OPERATOR
OPERATOR
Enum for operators in the internal cache strategy.
Definition: PolygonalCalculus.h:1065
DGtal::PolygonalCalculus::myGlobalCache
std::array< std::unordered_map< Face, DenseMatrix >, 15 > myGlobalCache
Definition: PolygonalCalculus.h:1217
DGtal::PolygonalCalculus::globalInverseLumpedMassMatrix
SparseMatrix globalInverseLumpedMassMatrix() const
Definition: PolygonalCalculus.h:841
DGtal::PolygonalCalculus::nbFaces
size_t nbFaces() const
Definition: PolygonalCalculus.h:1014
DGtal::PolygonalCalculus::getSurfaceMeshPtr
const MySurfaceMesh * getSurfaceMeshPtr() const
Definition: PolygonalCalculus.h:1027
DGtal::PolygonalCalculus::P_
@ P_
Definition: PolygonalCalculus.h:1065
DGtal::PolygonalCalculus::setEmbedder
void setEmbedder(const std::function< Real3dPoint(Face, Vertex)> &externalFunctor)
Definition: PolygonalCalculus.h:222
DGtal::PolygonalCalculus
Implements differential operators on polygonal surfaces from .
Definition: PolygonalCalculus.h:70
DGtal::PolygonalCalculus::doubledGlobalLumpedMassMatrix
SparseMatrix doubledGlobalLumpedMassMatrix() const
Definition: PolygonalCalculus.h:899
DGtal::EigenLinearAlgebraBackend::DenseVector
Eigen::VectorXd DenseVector
Definition: EigenSupport.h:98
DGtal::PolygonalCalculus::SHARP_
@ SHARP_
Definition: PolygonalCalculus.h:1065
DGtal::PolygonalCalculus::covariantProjection
DenseMatrix covariantProjection(const Face f, const Vector &uf)
Definition: PolygonalCalculus.h:711
DGtal::EigenLinearAlgebraBackend::DenseMatrix
Eigen::MatrixXd DenseMatrix
Definition: EigenSupport.h:99
DGtal::PolygonalCalculus::toVector
static Vector toVector(const Eigen::Vector3d &x)
toVector convert Real3dPoint to Eigen::VectorXd
Definition: PolygonalCalculus.h:1115
DGtal::PolygonalCalculus::coGradient
DenseMatrix coGradient(const Face f) const
Definition: PolygonalCalculus.h:367
DGtal::EigenLinearAlgebraBackend::Triplet
Eigen::Triplet< double, SparseMatrix::StorageIndex > Triplet
Definition: EigenSupport.h:103
DGtal::PolygonalCalculus::globalConnectionLaplace
SparseMatrix globalConnectionLaplace(const double lambda=1.0) const
Definition: PolygonalCalculus.h:867
DGtal::PolygonalCalculus::form0
Form form0() const
Definition: PolygonalCalculus.h:767
DGtal::PolygonalCalculus::laplaceBeltrami
DenseMatrix laplaceBeltrami(const Face f, const double lambda=1.0) const
Definition: PolygonalCalculus.h:545
DGtal::SurfaceMesh::nbVertices
Size nbVertices() const
Definition: SurfaceMesh.h:280
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::PolygonalCalculus::DenseMatrix
LinAlg::DenseMatrix DenseMatrix
Type of dense matrix.
Definition: PolygonalCalculus.h:100
DGtal::SurfaceMesh::incidentFaces
const Faces & incidentFaces(Vertex v) const
Definition: SurfaceMesh.h:313
DGtal::PolygonalCalculus::Triplet
LinAlg::Triplet Triplet
Type of sparse matrix triplet.
Definition: PolygonalCalculus.h:104
DGtal::PolygonalCalculus::E
DenseMatrix E(const Face f) const
Definition: PolygonalCalculus.h:281
DGtal::PolygonalCalculus::P
DenseMatrix P(const Face f) const
Definition: PolygonalCalculus.h:461
DGtal::PolygonalCalculus::D
DenseMatrix D(const Face f) const
Definition: PolygonalCalculus.h:261
DGtal::PolygonalCalculus::M_
@ M_
Definition: PolygonalCalculus.h:1065
DGtal::PolygonalCalculus::checkCache
bool checkCache(OPERATOR key, const Face f) const
Definition: PolygonalCalculus.h:1083
DGtal::PolygonalCalculus::myVertexNormalEmbedder
std::function< Real3dVector(Vertex)> myVertexNormalEmbedder
Embedding function (vertex)->R^3 for the vertex normal.
Definition: PolygonalCalculus.h:1210
DGtal::PolygonalCalculus::D_
@ D_
Definition: PolygonalCalculus.h:1065
DGtal::PolygonalCalculus::B_
@ B_
Definition: PolygonalCalculus.h:1065
DGtal::PolygonalCalculus::toReal3dVector
static Real3dVector toReal3dVector(const Eigen::Vector3d &x)
toReal3dVector converts Eigen::Vector3d to Real3dVector.
Definition: PolygonalCalculus.h:1135
DGtal::PolygonalCalculus::sharp
DenseMatrix sharp(const Face f) const
Definition: PolygonalCalculus.h:445
DGtal::PolygonalCalculus::getOperatorCacheVector
std::vector< Vector > getOperatorCacheVector(const std::function< Vector(Face)> &perFaceVectorOperator) const
Definition: PolygonalCalculus.h:962
DGtal::PolygonalCalculus::gradient
DenseMatrix gradient(const Face f) const
Definition: PolygonalCalculus.h:390
DGtal::PolygonalCalculus::MySurfaceMesh
SurfaceMesh< TRealPoint, TRealVector > MySurfaceMesh
Type of SurfaceMesh.
Definition: PolygonalCalculus.h:83
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::PolygonalCalculus::faceDegree
size_t faceDegree(Face f) const
Definition: PolygonalCalculus.h:1002
DGtal::PolygonalCalculus::centroid
Vector centroid(const Face f) const
Definition: PolygonalCalculus.h:428
DGtal::PolygonalCalculus::covariantGradient
DenseMatrix covariantGradient(const Face f, const Vector &uf)
Definition: PolygonalCalculus.h:695
DGtal::PolygonalCalculus::FLAT_
@ FLAT_
Definition: PolygonalCalculus.h:1065
DGtal::EigenLinearAlgebraBackend
Aim: Provide linear algebra backend using Eigen dense and sparse matrix as well as dense vector....
Definition: EigenSupport.h:96
DGtal::PolygonalCalculus::LinAlg
EigenLinearAlgebraBackend LinAlg
Linear Algebra Backend from Eigen.
Definition: PolygonalCalculus.h:94
DGtal::PolygonalCalculus::computeVertexNormal
Vector computeVertexNormal(const Vertex &v) const
Definition: PolygonalCalculus.h:1146
DGtal::PolygonalCalculus::PolygonalCalculus
PolygonalCalculus(const ConstAlias< MySurfaceMesh > surf, const std::function< Real3dVector(Vertex)> &embedder, bool globalInternalCacheEnabled=false)
Definition: PolygonalCalculus.h:146
DGtal::PolygonalCalculus::init
void init()
Definition: PolygonalCalculus.h:994
DGtal::PolygonalCalculus::Tf
DenseMatrix Tf(const Face &f) const
Definition: PolygonalCalculus.h:587
DGtal::PolygonalCalculus::isValid
bool isValid() const
Definition: PolygonalCalculus.h:1050
DGtal::PolygonalCalculus::Solver
LinAlg::SolverSimplicialLDLT Solver
Type of a sparse matrix solver.
Definition: PolygonalCalculus.h:107
DGtal::PolygonalCalculus::CURL_
@ CURL_
Definition: PolygonalCalculus.h:1065
DGtal::PolygonalCalculus::project
static Vector project(const Vector &u, const Vector &n)
Definition: PolygonalCalculus.h:1106
DGtal::PolygonalCalculus::myEmbedder
std::function< Real3dPoint(Face, Vertex)> myEmbedder
Embedding function (face,vertex)->R^3 for the vertex position wrt. the face.
Definition: PolygonalCalculus.h:1207
DGtal::PolygonalCalculus::curl
DenseMatrix curl(const Face f) const
Definition: PolygonalCalculus.h:519
DGtal::PolygonalCalculus::toExtrinsicVector
Vector toExtrinsicVector(const Vertex v, const Vector &I) const
toExtrinsicVector
Definition: PolygonalCalculus.h:611
DGtal::PolygonalCalculus::disableInternalGlobalCache
void disableInternalGlobalCache()
Definition: PolygonalCalculus.h:979
DGtal::PolygonalCalculus::Real3dPoint
MySurfaceMesh::RealPoint Real3dPoint
Position type.
Definition: PolygonalCalculus.h:89
DGtal::PolygonalCalculus::BOOST_STATIC_ASSERT
BOOST_STATIC_ASSERT((dimension==3))
DGtal::PolygonalCalculus::blockConnection
DenseMatrix blockConnection(const Face &f) const
Definition: PolygonalCalculus.h:1166
DGtal::PolygonalCalculus::Real3dVector
MySurfaceMesh::RealVector Real3dVector
Real vector type.
Definition: PolygonalCalculus.h:91
DGtal::SurfaceMesh::Face
Index Face
Definition: SurfaceMesh.h:106
DGtal::PolygonalCalculus::mySurfaceMesh
const MySurfaceMesh * mySurfaceMesh
Underlying SurfaceMesh.
Definition: PolygonalCalculus.h:1204
DGtal::PolygonalCalculus::nbVertices
size_t nbVertices() const
Definition: PolygonalCalculus.h:1008
DGtal::EigenLinearAlgebraBackend::SolverSimplicialLDLT
Eigen::SimplicialLDLT< SparseMatrix > SolverSimplicialLDLT
Definition: EigenSupport.h:107
DGtal::PolygonalCalculus::M
DenseMatrix M(const Face f, const double lambda=1.0) const
Definition: PolygonalCalculus.h:477
DGtal::PolygonalCalculus::X
DenseMatrix X(const Face f) const
Definition: PolygonalCalculus.h:236
DGtal::PolygonalCalculus::toVec3
static Eigen::Vector3d toVec3(const Real3dPoint &x)
toVec3 convert Real3dPoint to Eigen::Vector3d
Definition: PolygonalCalculus.h:1126
DGtal::PolygonalCalculus::Rvf
DenseMatrix Rvf(const Vertex &v, const Face &f) const
Definition: PolygonalCalculus.h:645
DGtal::PolygonalCalculus::Vertex
MySurfaceMesh::Vertex Vertex
Vertex type.
Definition: PolygonalCalculus.h:85
DGtal::PolygonalCalculus::Qvf
DenseMatrix Qvf(const Vertex &v, const Face &f) const
Definition: PolygonalCalculus.h:631
DGtal::PolygonalCalculus::PolygonalCalculus
PolygonalCalculus()=delete
DGtal::PolygonalCalculus::B
DenseMatrix B(const Face f) const
Definition: PolygonalCalculus.h:417
DGtal::PolygonalCalculus::n_v
Eigen::Vector3d n_v(const Vertex &v) const
Definition: PolygonalCalculus.h:1159
DGtal::SurfaceMesh::neighborVertices
const Vertices & neighborVertices(Vertex v) const
Definition: SurfaceMesh.h:323
DGtal::PolygonalCalculus::Vector
LinAlg::DenseVector Vector
Type of Vector.
Definition: PolygonalCalculus.h:96
DGtal::PolygonalCalculus::identity0
SparseMatrix identity0() const
Definition: PolygonalCalculus.h:772
DGtal::PolygonalCalculus::myFaceDegree
std::vector< size_t > myFaceDegree
Cache containing the face degree.
Definition: PolygonalCalculus.h:1213
DGtal::SurfaceMesh::RealPoint
TRealPoint RealPoint
Definition: SurfaceMesh.h:93
DGtal::PolygonalCalculus::myGlobalCacheEnabled
bool myGlobalCacheEnabled
Global cache.
Definition: PolygonalCalculus.h:1216
DGtal::PolygonalCalculus::COGRAD_
@ COGRAD_
Definition: PolygonalCalculus.h:1065
DGtal::PolygonalCalculus::faceNormal
Vector faceNormal(const Face f) const
Definition: PolygonalCalculus.h:348
DGtal::PolygonalCalculus::GRAD_
@ GRAD_
Definition: PolygonalCalculus.h:1065
DGtal::PolygonalCalculus::Self
PolygonalCalculus< TRealPoint, TRealVector > Self
Self type.
Definition: PolygonalCalculus.h:80
DGtal::EigenLinearAlgebraBackend::SparseMatrix
Eigen::SparseMatrix< DenseVector::Scalar, Eigen::ColMajor, DenseVector::Index > SparseMatrix
Definition: EigenSupport.h:102
DGtal::PolygonalCalculus::flat
DenseMatrix flat(const Face f) const
Definition: PolygonalCalculus.h:404
DGtal::PolygonalCalculus::~PolygonalCalculus
~PolygonalCalculus()=default
DGtal::PolygonalCalculus::operator=
PolygonalCalculus & operator=(const PolygonalCalculus &other)=delete
DGtal::PolygonalCalculus::CON_L_
@ CON_L_
Definition: PolygonalCalculus.h:1065
DGtal::PolygonalCalculus::globalLumpedMassMatrix
SparseMatrix globalLumpedMassMatrix() const
Definition: PolygonalCalculus.h:821
DGtal::PolygonalCalculus::connectionLaplacian
DenseMatrix connectionLaplacian(const Face &f, double lambda=1.0) const
Definition: PolygonalCalculus.h:749
DGtal::PolygonalCalculus::kroneckerWithI2
DenseMatrix kroneckerWithI2(const DenseMatrix &M) const
Definition: PolygonalCalculus.h:1181
DGtal::SurfaceMesh::incidentVertices
const Vertices & incidentVertices(Face f) const
Definition: SurfaceMesh.h:307
DGtal::PolygonalCalculus::PolygonalCalculus
PolygonalCalculus(const ConstAlias< MySurfaceMesh > surf, const std::function< Real3dPoint(Face, Vertex)> &embedder, bool globalInternalCacheEnabled=false)
Definition: PolygonalCalculus.h:131
DGtal::PolygonalCalculus::bracket
DenseMatrix bracket(const Vector &n) const
Definition: PolygonalCalculus.h:378
DGtal::PolygonalCalculus::covariantGradient_f
DenseMatrix covariantGradient_f(const Face &f) const
Definition: PolygonalCalculus.h:721
DGtal::PolygonalCalculus::enableInternalGlobalCache
void enableInternalGlobalCache()
Definition: PolygonalCalculus.h:972
DGtal::PolygonalCalculus::shapeOperator
DenseMatrix shapeOperator(const Face f) const
Definition: PolygonalCalculus.h:652
DGtal::SurfaceMesh::nbFaces
Size nbFaces() const
Definition: SurfaceMesh.h:288
DGtal::PolygonalCalculus::E_
@ E_
Definition: PolygonalCalculus.h:1065
DGtal::PolygonalCalculus::covariantProjection_f
DenseMatrix covariantProjection_f(const Face &f) const
Definition: PolygonalCalculus.h:731
DGtal::PolygonalCalculus::Tv
DenseMatrix Tv(const Vertex &v) const
Definition: PolygonalCalculus.h:567
DGtal::PolygonalCalculus::A
DenseMatrix A(const Face f) const
Definition: PolygonalCalculus.h:295
DGtal::PolygonalCalculus::degree
size_t degree(const Face f) const
Definition: PolygonalCalculus.h:1021