DGtal  1.5.beta
examplePlaneProbingTetrahedronEstimator.cpp
Go to the documentation of this file.
1 
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;
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 }.
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 // //
Aim: Representing digital planes, which are digitizations of Euclidean planes, as point predicates.
bool advance(std::vector< PointOnProbingRay > const &aNeighbors)
Aim: A class that locally estimates a normal on a digital set using only a predicate "does a point x ...
DigitalPlane::Point Vector
DGtal is the top-level namespace which contains all DGtal functions and types.
MyPointD Point
Definition: testClone2.cpp:383