DGtal  1.1.0
MongeJetFittingGaussianCurvatureEstimator.h
1 
17 #pragma once
18 
34 #if defined(MongeJetFittingGaussianCurvatureEstimator_RECURSES)
35 #error Recursive header files inclusion detected in MongeJetFittingGaussianCurvatureEstimator.h
36 #else // defined(MongeJetFittingGaussianCurvatureEstimator_RECURSES)
37 
38 #define MongeJetFittingGaussianCurvatureEstimator_RECURSES
39 
40 #if !defined MongeJetFittingGaussianCurvatureEstimator_h
41 
42 #define MongeJetFittingGaussianCurvatureEstimator_h
43 
45 // Inclusions
46 #include <iostream>
47 #include <DGtal/base/Common.h>
48 #include <DGtal/topology/SCellsFunctors.h>
49 
50 #ifndef WITH_CGAL
51 #error You need to have activated CGAL (WITH_CGAL) to include this file.
52 #endif
53 
54 //CGAL
55 #include <CGAL/Cartesian.h>
56 #include <CGAL/Monge_via_jet_fitting.h>
57 #include <vector>
58 
60 
61 namespace DGtal
62 {
63  namespace functors
64  {
66  // template class MongeJetFittingGaussianCurvatureEstimator
76  template <typename TSurfel, typename TEmbedder>
78  {
79  public:
80 
81  typedef TSurfel Surfel;
82  typedef TEmbedder SCellEmbedder;
83  typedef double Quantity;
85 
86  typedef CGAL::Cartesian<double> CGALKernel;
87  typedef CGALKernel::Point_3 CGALPoint;
88  typedef CGAL::Monge_via_jet_fitting<CGALKernel> CGALMongeViaJet;
89  typedef CGALMongeViaJet::Monge_form CGALMongeForm;
90 
99  const double h, unsigned int d = 4):
100  myEmbedder(&anEmbedder), myH(h), myD(d)
101  {
102  FATAL_ERROR_MSG(d>=2,"Polynomial surface degree must be greater than 2");
103  }
104 
111  void pushSurfel(const Surfel & aSurf,
112  const double aDistance)
113  {
114  BOOST_VERIFY(aDistance==aDistance);
115 
116  RealPoint p = myEmbedder->operator()(aSurf);
117  CGALPoint pp(p[0]*myH,p[1]*myH,p[2]*myH);
118  myPoints.push_back(pp);
119  }
120 
127  {
128  CGALMongeForm monge_form;
129  CGALMongeViaJet monge_fit;
130 
131  monge_form = monge_fit(myPoints.begin() , myPoints.end(), myD, (2<myD)? myD : 2);
132 
133  double k1 = monge_form.principal_curvatures ( 0 );
134  double k2 = monge_form.principal_curvatures ( 1 );
135  return (k1*k2);
136  }
137 
142  void reset()
143  {
144  myPoints.clear();
145  }
146 
147 
148  private:
149 
152 
154  std::vector<CGALPoint> myPoints;
155 
157  double myH;
158 
160  unsigned int myD;
161 
162  }; // end of class MongeJetFittingGaussianCurvatureEstimator
163  }
164 } // namespace DGtal
165 
166 
167 // //
169 
170 #endif // !defined MongeJetFittingGaussianCurvatureEstimator_h
171 
172 #undef MongeJetFittingGaussianCurvatureEstimator_RECURSES
173 #endif // else defined(MongeJetFittingGaussianCurvatureEstimator_RECURSES)
DGtal::ConstAlias
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::eval
Quantity eval()
Definition: MongeJetFittingGaussianCurvatureEstimator.h:126
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::CGALKernel
CGAL::Cartesian< double > CGALKernel
Definition: MongeJetFittingGaussianCurvatureEstimator.h:86
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator
Aim: Estimates Gaussian curvature using CGAL Jet Fitting and Monge Form.
Definition: MongeJetFittingGaussianCurvatureEstimator.h:78
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::Quantity
double Quantity
Definition: MongeJetFittingGaussianCurvatureEstimator.h:83
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::pushSurfel
void pushSurfel(const Surfel &aSurf, const double aDistance)
Definition: MongeJetFittingGaussianCurvatureEstimator.h:111
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::SCellEmbedder
TEmbedder SCellEmbedder
Definition: MongeJetFittingGaussianCurvatureEstimator.h:82
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::CGALMongeForm
CGALMongeViaJet::Monge_form CGALMongeForm
Definition: MongeJetFittingGaussianCurvatureEstimator.h:89
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::CGALMongeViaJet
CGAL::Monge_via_jet_fitting< CGALKernel > CGALMongeViaJet
Definition: MongeJetFittingGaussianCurvatureEstimator.h:88
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::Surfel
TSurfel Surfel
Definition: MongeJetFittingGaussianCurvatureEstimator.h:81
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::RealPoint
SCellEmbedder::RealPoint RealPoint
Definition: MongeJetFittingGaussianCurvatureEstimator.h:84
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::reset
void reset()
Definition: MongeJetFittingGaussianCurvatureEstimator.h:142
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::myPoints
std::vector< CGALPoint > myPoints
Array of CGAL points.
Definition: MongeJetFittingGaussianCurvatureEstimator.h:154
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::myD
unsigned int myD
Degree of the polynomial surface to fit.
Definition: MongeJetFittingGaussianCurvatureEstimator.h:160
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::CGALPoint
CGALKernel::Point_3 CGALPoint
Definition: MongeJetFittingGaussianCurvatureEstimator.h:87
RealPoint
Z2i::RealPoint RealPoint
Definition: testAstroid2D.cpp:46
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::myH
double myH
Grid Step.
Definition: MongeJetFittingGaussianCurvatureEstimator.h:157
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::MongeJetFittingGaussianCurvatureEstimator
MongeJetFittingGaussianCurvatureEstimator(ConstAlias< SCellEmbedder > anEmbedder, const double h, unsigned int d=4)
Definition: MongeJetFittingGaussianCurvatureEstimator.h:98
DGtal::functors::MongeJetFittingGaussianCurvatureEstimator::myEmbedder
const SCellEmbedder * myEmbedder
Alias of the geometrical embedder.
Definition: MongeJetFittingGaussianCurvatureEstimator.h:151