DGtal  0.9.2
MongeJetFittingMeanCurvatureEstimator.h
1 
17 #pragma once
18 
34 #if defined(MongeJetFittingMeanCurvatureEstimator_RECURSES)
35 #error Recursive header files inclusion detected in MongeJetFittingMeanCurvatureEstimator.h
36 #else // defined(MongeJetFittingMeanCurvatureEstimator_RECURSES)
37 
38 #define MongeJetFittingMeanCurvatureEstimator_RECURSES
39 
40 #if !defined MongeJetFittingMeanCurvatureEstimator_h
41 
42 #define MongeJetFittingMeanCurvatureEstimator_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 MongeJetFittingMeanCurvatureEstimator
89  template <typename TSurfel, typename TEmbedder>
91  {
92  public:
93 
94  typedef TSurfel Surfel;
95  typedef TEmbedder SCellEmbedder;
96  typedef double Quantity;
97  typedef typename SCellEmbedder::RealPoint RealPoint;
98 
99  typedef CGAL::Cartesian<double> CGALKernel;
100  typedef CGALKernel::Point_3 CGALPoint;
101  typedef CGAL::Monge_via_jet_fitting<CGALKernel> CGALMongeViaJet;
102  typedef CGALMongeViaJet::Monge_form CGALMongeForm;
103 
112  const double h, unsigned int d = 4):
113  myEmbedder(&anEmbedder), myH(h), myD(d)
114  {
115  FATAL_ERROR_MSG(d>=2,"Polynomial surface degree must be greater than 2");
116  }
117 
124  void pushSurfel(const Surfel & aSurf,
125  const double aDistance)
126  {
127  BOOST_VERIFY(aDistance==aDistance);
128 
129  RealPoint p = myEmbedder->operator()(aSurf);
130  CGALPoint pp(p[0]*myH,p[1]*myH,p[2]*myH);
131  myPoints.push_back(pp);
132  }
133 
139  Quantity eval()
140  {
141  CGALMongeForm monge_form;
142  CGALMongeViaJet monge_fit;
143 
144  monge_form = monge_fit(myPoints.begin() , myPoints.end(), myD, (2<myD)? myD : 2);
145 
146  double k1 = monge_form.principal_curvatures ( 0 );
147  double k2 = monge_form.principal_curvatures ( 1 );
148  return 0.5*(k1+k2);
149  }
150 
155  void reset()
156  {
157  myPoints.clear();
158  }
159 
160 
161  private:
162 
164  const SCellEmbedder * myEmbedder;
165 
167  std::vector<CGALPoint> myPoints;
168 
170  double myH;
171 
173  unsigned int myD;
174 
175  }; // end of class MongeJetFittingMeanCurvatureEstimator
176  }
177 } // namespace DGtal
178 
179 
180 // //
182 
183 #endif // !defined MongeJetFittingMeanCurvatureEstimator_h
184 
185 #undef MongeJetFittingMeanCurvatureEstimator_RECURSES
186 #endif // else defined(MongeJetFittingMeanCurvatureEstimator_RECURSES)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
unsigned int myD
Degree of the polynomial surface to fit.
const SCellEmbedder * myEmbedder
Alias of the geometrical embedder.
Aim: Estimates Mean curvature using CGAL Jet Fitting and Monge Form.
DGtal is the top-level namespace which contains all DGtal functions and types.
MongeJetFittingMeanCurvatureEstimator(ConstAlias< SCellEmbedder > anEmbedder, const double h, unsigned int d=4)