DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
examplePlaneProbingTetrahedronEstimator.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include "ConfigExamples.h"
33
#include "DGtal/helpers/StdDefs.h"
34
#include "DGtal/base/Common.h"
35
#include "DGtal/geometry/surfaces/DigitalPlanePredicate.h"
36
#include "DGtal/geometry/surfaces/estimation/PlaneProbingTetrahedronEstimator.h"
38
39
using namespace
std
;
40
using namespace
DGtal
;
41
42
using
Integer
= int;
43
using
Space
=
SpaceND<3, Integer>
;
44
using
Point
=
Space::Vector
;
45
using
Vector
=
Space::Point
;
46
48
49
int
main
(
void
)
50
{
52
// The general form is ProbingEstimator<Predicate, mode> where
53
// - Predicate is a model of concepts::PointPredicate, see DigitalPlanePredicate or DigitalSurfacePredicate for instance,
54
// - mode specifies the candidate set, it is one of { ProbingMode::H, ProbingMode::R, ProbingMode::R1, ProbingMode::L }.
55
using
DigitalPlane
=
DigitalPlanePredicate<Space>
;
56
using
Estimator
=
PlaneProbingTetrahedronEstimator<DigitalPlane, ProbingMode::R1>
;
57
58
// We start by constructing the predicate, here a standard digital plane of normal (2, 6, 15)
59
Vector
n(2, 6, 15);
60
DigitalPlane
plane(n, 0, n.norm1());
61
62
// Instantiation: estimator(startingPoint, initialFrame, predicate) where
63
// (startingPoint, initialFrame) describes the initial tetrahedron.
64
Point
o(0, 0, 0);
65
std::array<Point, 3> m = {
Point
(1, 0, 0),
Point
(0, 1, 0),
Point
(0, 0, 1) };
66
Estimator
estimator(o, m, plane);
68
70
int
it = 0;
71
while
(estimator.
advance
().first) {
72
it++;
73
74
// You can examine the current configuration of the H-neighborhood, using PlaneProbingTetrahedronEstimator::hexagonState
75
auto
state = estimator.
hexagonState
();
76
if
(state == Estimator::Neighborhood::HexagonState::Planar) {
77
std::cout <<
"Planar"
<< std::endl;
78
}
else
if
(state == Estimator::Neighborhood::HexagonState::Empty) {
79
std::cout <<
"Empty"
<< std::endl;
80
}
else
if
(state == Estimator::Neighborhood::HexagonState::NonPlanar) {
81
std::cout <<
"NonPlanar"
<< std::endl;
82
}
else
if
(state == Estimator::Neighborhood::HexagonState::NonConvex) {
83
std::cout <<
"NonConvex"
<< std::endl;
84
}
85
86
// Here, we display the current frame (the vectors m_k) and the current estimation
87
std::clog <<
"it = "
<< it <<
" "
88
<< estimator.
m
(0) <<
" "
<< estimator.
m
(1) <<
" "
<< estimator.
m
(2) <<
" "
89
<< estimator.
getNormal
() << std::endl;
90
}
91
92
// This loop can also be reduced to:
93
// Point n = estimator.compute()
95
96
ASSERT(estimator.
getNormal
() == n);
97
98
return
0;
99
}
100
// //
DGtal::DigitalPlanePredicate
Aim: Representing digital planes, which are digitizations of Euclidean planes, as point predicates.
Definition
DigitalPlanePredicate.h:73
DGtal::PlaneProbingParallelepipedEstimator::m
Vector m(int aIndex) const
DGtal::PlaneProbingParallelepipedEstimator::hexagonState
HexagonState hexagonState() const
DGtal::PlaneProbingParallelepipedEstimator::getNormal
Vector getNormal() const
DGtal::PlaneProbingParallelepipedEstimator::advance
bool advance(std::vector< PointOnProbingRay > const &aNeighbors)
DGtal::PlaneProbingTetrahedronEstimator
Aim: A class that locally estimates a normal on a digital set using only a predicate "does a point x ...
Definition
PlaneProbingTetrahedronEstimator.h:112
DGtal::SpaceND
Definition
SpaceND.h:96
DGtal::SpaceND< 3, Integer >::Point
PointVector< dim, Integer > Point
Definition
SpaceND.h:110
DGtal::SpaceND< 3, Integer >::Vector
PointVector< dim, Integer > Vector
Definition
SpaceND.h:113
DigitalPlane
DigitalPlanePredicate< Z3i::Space > DigitalPlane
Definition
examplePlaneProbingParallelepipedEstimator.cpp:42
Estimator
PlaneProbingParallelepipedEstimator< DigitalPlane, ProbingMode::R1 > Estimator
Definition
examplePlaneProbingParallelepipedEstimator.cpp:46
Integer
Point::Coordinate Integer
Definition
examplePlaneProbingParallelepipedEstimator.cpp:44
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
std
STL namespace.
DGtal::Space
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
examples
geometry
surfaces
examplePlaneProbingTetrahedronEstimator.cpp
Generated on
for DGtal by
1.18.0