DGtal  1.4.beta
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)
38 #define MongeJetFittingGaussianCurvatureEstimator_RECURSES
39 
40 #if !defined MongeJetFittingGaussianCurvatureEstimator_h
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)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
Aim: Estimates Gaussian curvature using CGAL Jet Fitting and Monge Form.
const SCellEmbedder * myEmbedder
Alias of the geometrical embedder.
MongeJetFittingGaussianCurvatureEstimator(ConstAlias< SCellEmbedder > anEmbedder, const double h, unsigned int d=4)
DGtal is the top-level namespace which contains all DGtal functions and types.
PointVector< 3, double > RealPoint