DGtal
1.1.0
src
DGtal
geometry
surfaces
estimation
estimationFunctors
LinearLeastSquareFittingNormalVectorEstimator.h
1
17
#pragma once
18
34
#if defined(LinearLeastSquareFittingNormalVectorEstimator_RECURSES)
35
#error Recursive header files inclusion detected in LinearLeastSquareFittingNormalVectorEstimator.h
36
#else // defined(LinearLeastSquareFittingNormalVectorEstimator_RECURSES)
37
38
#define LinearLeastSquareFittingNormalVectorEstimator_RECURSES
39
40
#if !defined LinearLeastSquareFittingNormalVectorEstimator_h
41
42
#define LinearLeastSquareFittingNormalVectorEstimator_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/linear_least_squares_fitting_3.h>
57
#include <vector>
58
60
61
namespace
DGtal
62
{
63
namespace
functors
64
{
66
// template class LinearLeastSquareFittingNormalVectorEstimator
78
template
<
typename
TSurfel,
typename
TEmbedder>
79
class
LinearLeastSquareFittingNormalVectorEstimator
80
{
81
public
:
82
83
typedef
TSurfel
Surfel
;
84
typedef
TEmbedder
SCellEmbedder
;
85
typedef
typename
SCellEmbedder::RealPoint
RealPoint
;
86
typedef
RealPoint
Quantity
;
87
88
typedef
CGAL::Cartesian<double>
CGALKernel
;
89
typedef
CGALKernel::Point_3
CGALPoint
;
90
typedef
CGALKernel::Plane_3
CGALPlane
;
91
typedef
CGALKernel::Vector_3
CGALVector
;
92
99
LinearLeastSquareFittingNormalVectorEstimator
(
ConstAlias<SCellEmbedder>
anEmbedder,
const
double
h):
100
myEmbedder
(&anEmbedder),
myH
(h)
101
{
102
}
103
110
void
pushSurfel
(
const
Surfel
& aSurf,
111
const
double
aDistance)
112
{
113
BOOST_VERIFY(aDistance == aDistance);
114
RealPoint
p =
myEmbedder
->operator()(aSurf);
115
CGALPoint
pp(p[0],p[1],p[2]);
116
myPoints
.push_back(pp);
117
}
118
124
Quantity
eval
( )
125
{
126
CGALPlane
plane;
127
CGAL::linear_least_squares_fitting_3(
myPoints
.begin(),
myPoints
.end(), plane, CGAL::Dimension_tag<0>());
128
CGALVector
v = plane.orthogonal_vector();
129
RealPoint
vv(v.x(),v.y(),v.z());
130
return
vv.getNormalized();
131
}
132
137
void
reset
()
138
{
139
myPoints
.clear();
140
}
141
142
143
private
:
144
146
const
SCellEmbedder
*
myEmbedder
;
147
149
std::vector<CGALPoint>
myPoints
;
150
152
double
myH
;
153
154
155
156
};
// end of class LinearLeastSquareFittingNormalVectorEstimator
157
}
158
}
// namespace DGtal
159
160
161
// //
163
164
#endif // !defined LinearLeastSquareFittingNormalVectorEstimator_h
165
166
#undef LinearLeastSquareFittingNormalVectorEstimator_RECURSES
167
#endif // else defined(LinearLeastSquareFittingNormalVectorEstimator_RECURSES)
DGtal::functors::LinearLeastSquareFittingNormalVectorEstimator::myEmbedder
const SCellEmbedder * myEmbedder
Alias of the geometrical embedder.
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:146
DGtal::functors::LinearLeastSquareFittingNormalVectorEstimator::CGALPoint
CGALKernel::Point_3 CGALPoint
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:89
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::LinearLeastSquareFittingNormalVectorEstimator::Quantity
RealPoint Quantity
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:86
DGtal::functors::LinearLeastSquareFittingNormalVectorEstimator
Aim: Estimates normal vector using CGAL linear least squares plane fitting.
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:80
DGtal::functors::LinearLeastSquareFittingNormalVectorEstimator::eval
Quantity eval()
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:124
DGtal::functors::LinearLeastSquareFittingNormalVectorEstimator::pushSurfel
void pushSurfel(const Surfel &aSurf, const double aDistance)
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:110
DGtal::functors::LinearLeastSquareFittingNormalVectorEstimator::myH
double myH
Grid Step.
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:152
DGtal::functors::LinearLeastSquareFittingNormalVectorEstimator::LinearLeastSquareFittingNormalVectorEstimator
LinearLeastSquareFittingNormalVectorEstimator(ConstAlias< SCellEmbedder > anEmbedder, const double h)
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:99
DGtal::functors::LinearLeastSquareFittingNormalVectorEstimator::SCellEmbedder
TEmbedder SCellEmbedder
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:84
DGtal::functors::LinearLeastSquareFittingNormalVectorEstimator::CGALKernel
CGAL::Cartesian< double > CGALKernel
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:88
DGtal::functors::LinearLeastSquareFittingNormalVectorEstimator::reset
void reset()
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:137
DGtal::functors::LinearLeastSquareFittingNormalVectorEstimator::CGALPlane
CGALKernel::Plane_3 CGALPlane
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:90
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition:
ClosedIntegerHalfPlane.h:49
DGtal::functors::LinearLeastSquareFittingNormalVectorEstimator::CGALVector
CGALKernel::Vector_3 CGALVector
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:91
DGtal::functors::LinearLeastSquareFittingNormalVectorEstimator::Surfel
TSurfel Surfel
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:83
DGtal::functors::LinearLeastSquareFittingNormalVectorEstimator::myPoints
std::vector< CGALPoint > myPoints
Array of CGAL points.
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:149
DGtal::functors::LinearLeastSquareFittingNormalVectorEstimator::RealPoint
SCellEmbedder::RealPoint RealPoint
Definition:
LinearLeastSquareFittingNormalVectorEstimator.h:85
RealPoint
Z2i::RealPoint RealPoint
Definition:
testAstroid2D.cpp:46
Generated on Fri Oct 9 2020 08:58:04 for DGtal by
1.8.20