DGtal 1.3.0
Loading...
Searching...
No Matches
MongeJetFittingPrincipalCurvaturesEstimator.h
1
17#pragma once
18
34#if defined(MongeJetFittingPrincipalCurvaturesEstimator_RECURSES)
35#error Recursive header files inclusion detected in MongeJetFittingPrincipalCurvaturesEstimator.h
36#else // defined(MongeJetFittingPrincipalCurvaturesEstimator_RECURSES)
38#define MongeJetFittingPrincipalCurvaturesEstimator_RECURSES
39
40#if !defined MongeJetFittingPrincipalCurvaturesEstimator_h
42#define MongeJetFittingPrincipalCurvaturesEstimator_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
61namespace DGtal
62{
63 namespace functors
64 {
66 // template class MongeJetFittingPrincipalCurvaturesEstimator
76 template <typename TSurfel, typename TEmbedder>
78 {
79 public:
80
81 typedef TSurfel Surfel;
82 typedef TEmbedder SCellEmbedder;
83 typedef std::pair<double, double> Quantity;
84 typedef typename SCellEmbedder::RealPoint RealPoint;
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
91
99 MongeJetFittingPrincipalCurvaturesEstimator(ConstAlias<SCellEmbedder> anEmbedder, 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 Quantity result;
136 result.first = k1;
137 result.second = k2;
138 return result;
139 }
140
145 void reset()
146 {
147 myPoints.clear();
148 }
149
150
151 private:
152
155
157 std::vector<CGALPoint> myPoints;
158
160 double myH;
161
163 unsigned int myD;
164
165
166 }; // end of class MongeJetFittingPrincipalCurvaturesEstimator
167 }
168} // namespace DGtal
169
170
171// //
173
174#endif // !defined MongeJetFittingPrincipalCurvaturesEstimator_h
175
176#undef MongeJetFittingPrincipalCurvaturesEstimator_RECURSES
177#endif // else defined(MongeJetFittingPrincipalCurvaturesEstimator_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.
MongeJetFittingPrincipalCurvaturesEstimator(ConstAlias< SCellEmbedder > anEmbedder, const double h, unsigned int d=4)
DGtal is the top-level namespace which contains all DGtal functions and types.