DGtal  1.4.beta
examplePlaneProbingTetrahedronEstimator.cpp File Reference
#include <iostream>
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/Common.h"
#include "DGtal/geometry/surfaces/DigitalPlanePredicate.h"
#include "DGtal/geometry/surfaces/estimation/PlaneProbingTetrahedronEstimator.h"
Include dependency graph for examplePlaneProbingTetrahedronEstimator.cpp:

Go to the source code of this file.

## Typedefs

using Integer = int

using Space = SpaceND< 3, Integer >

using Point = Space::Vector

using Vector = Space::Point

int main (void)

## Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Date
2020/12/04

An example file that shows how to construct and use a DGtal::PlaneProbingTetrahedronEstimator on an analytical digital plane.

This file is part of the DGtal library.

Definition in file examplePlaneProbingTetrahedronEstimator.cpp.

## ◆ Integer

 using Integer = int

Definition at line 42 of file examplePlaneProbingTetrahedronEstimator.cpp.

## ◆ Point

 using Point = Space::Vector

Definition at line 44 of file examplePlaneProbingTetrahedronEstimator.cpp.

## ◆ Space

 using Space = SpaceND<3, Integer>

Definition at line 43 of file examplePlaneProbingTetrahedronEstimator.cpp.

## ◆ Vector

 using Vector = Space::Point

Definition at line 45 of file examplePlaneProbingTetrahedronEstimator.cpp.

## ◆ main()

 int main ( void )

[PlaneProbingTetrahedronEstimatorConstruction]

[PlaneProbingTetrahedronEstimatorConstruction]

[PlaneProbingTetrahedronEstimatorUsage]

[PlaneProbingTetrahedronEstimatorUsage]

Definition at line 49 of file examplePlaneProbingTetrahedronEstimator.cpp.

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 }.
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;
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 }
Point
Space::Vector Point
DGtal::DigitalPlanePredicate
Aim: Representing digital planes, which are digitizations of Euclidean planes, as point predicates.
Definition: DigitalPlanePredicate.h:72
Vector
FreemanChain< int >::Vector Vector
Definition: testCombinDSS.cpp:60
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:106
Point
MyPointD Point
Definition: testClone2.cpp:383