DGtal 1.4.0
Loading...
Searching...
No Matches
MongeJetFittingNormalVectorEstimator.h
1
17#pragma once
18
34#if defined(MongeJetFittingNormalVectorEstimator_RECURSES)
35#error Recursive header files inclusion detected in MongeJetFittingNormalVectorEstimator.h
36#else // defined(MongeJetFittingNormalVectorEstimator_RECURSES)
38#define MongeJetFittingNormalVectorEstimator_RECURSES
39
40#if !defined MongeJetFittingNormalVectorEstimator_h
42#define MongeJetFittingNormalVectorEstimator_h
43
45// Inclusions
46#include <iostream>
47#include <DGtal/base/Common.h>
48#include <DGtal/topology/SCellsFunctors.h>
49
50//CGAL
51#include <CGAL/Cartesian.h>
52#include <CGAL/Monge_via_jet_fitting.h>
53#include <vector>
54
56
57namespace DGtal
58{
59 namespace functors
60 {
62 // template class MongeJetFittingNormalVectorEstimator
80 template <typename TSurfel, typename TEmbedder>
82 {
83 public:
84
85 typedef TSurfel Surfel;
86 typedef TEmbedder SCellEmbedder;
87 typedef typename SCellEmbedder::RealPoint RealPoint;
89
90 typedef CGAL::Cartesian<double> CGALKernel;
91 typedef CGALKernel::Point_3 CGALPoint;
92 typedef CGALKernel::Vector_3 CGALVector;
93 typedef CGAL::Monge_via_jet_fitting<CGALKernel> CGALMongeViaJet;
94 typedef CGALMongeViaJet::Monge_form CGALMongeForm;
95
104 const double h, unsigned int d = 4):
105 myEmbedder(&anEmbedder), myH(h), myD(d)
106 {
107 FATAL_ERROR_MSG(d>=2, "Polynomial surface degree must be greater than 2");
108 }
109
116 void pushSurfel(const Surfel & aSurf,
117 const double aDistance)
118 {
119 BOOST_VERIFY(aDistance == aDistance);
120
121 RealPoint p = myEmbedder->operator()(aSurf);
122 CGALPoint pp(p[0]*myH,p[1]*myH,p[2]*myH);
123 myPoints.push_back(pp);
124 }
125
132 {
133 CGALMongeForm monge_form;
134 CGALMongeViaJet monge_fit;
135
136 monge_form = monge_fit(myPoints.begin() , myPoints.end(), myD, (2<myD)? myD : 2);
137
138 CGALVector v= monge_form.normal_direction ( );
139
140 return RealPoint(v.x(),v.y(),v.z());
141 }
142
147 void reset()
148 {
149 myPoints.clear();
150 }
151
152
153 private:
154
157
159 std::vector<CGALPoint> myPoints;
160
161 //Grid step
162 double myH;
163
165 unsigned int myD;
166
167 }; // end of class MongeJetFittingNormalVectorEstimator
168 }
169} // namespace DGtal
170
171
172// //
174
175#endif // !defined MongeJetFittingNormalVectorEstimator_h
176
177#undef MongeJetFittingNormalVectorEstimator_RECURSES
178#endif // else defined(MongeJetFittingNormalVectorEstimator_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 normal vector using CGAL Jet Fitting and Monge Form.
MongeJetFittingNormalVectorEstimator(ConstAlias< SCellEmbedder > anEmbedder, const double h, unsigned int d=4)
const SCellEmbedder * myEmbedder
Alias of the geometrical embedder.
unsigned int myD
Degree of the polynomial surface to fit.
DGtal is the top-level namespace which contains all DGtal functions and types.