Ponca  4d2a58fa5c6375adef5c4b208f4d47e016cecd6d
Point Cloud Analysis library
Loading...
Searching...
No Matches
meanPlaneFit.h
1/*
2 Copyright (C) 2018 Nicolas Mellado <nmellado0@gmail.com>
3
4 This Source Code Form is subject to the terms of the Mozilla Public
5 License, v. 2.0. If a copy of the MPL was not distributed with this
6 file, You can obtain one at http://mozilla.org/MPL/2.0/.
7*/
8
9#pragma once
10#include "../../defines.h"
11#include "../concepts.h"
12
13#include "../primitive/plane.h" // used to define MeanPlaneFit
14#include "../tools/mean.h" // used to define MeanPlaneFit
15
16#define MEAN_PLANE_REQUIREMENTS ProvidesMeanPosition<T>&& ProvidesMeanNormal<T>&& ProvidesPlane<T>
17
18namespace Ponca
19{
20
31 template <class DataPoint, class _NFilter, typename T>
32 requires MEAN_PLANE_REQUIREMENTS
33 class MeanPlaneFitImpl : public T
34 {
35 PONCA_FITTING_DECLARE_DEFAULT_TYPES
36 PONCA_FITTING_DECLARE_MATRIX_TYPE
37 public:
38 PONCA_EXPLICIT_CAST_OPERATORS(MeanPlaneFitImpl, meanPlaneFit)
39
40 PONCA_FITTING_APIDOC_FINALIZE
41 PONCA_MULTIARCH inline FIT_RESULT finalize()
42 {
43 // handle specific configurations
44 if (Base::finalize() == STABLE)
45 {
46 if (Base::plane().isValid())
47 Base::m_eCurrentState = CONFLICT_ERROR_FOUND;
48 Base::setPlane(Base::m_sumN / Base::getWeightSum(), Base::barycenterLocal());
49 }
50 return Base::m_eCurrentState;
51 }
52 PONCA_FITTING_IS_SIGNED(true)
53 }; // class MeanPlaneFitImpl
54
57 template <class DataPoint, class _NFilter, typename T>
59 DataPoint, _NFilter,
62} // namespace Ponca
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:260
Plane fitting procedure computing the mean position and orientation from oriented points.
FIT_RESULT finalize()
Finalize the procedure.
MeanPlaneFitImpl< DataPoint, _NFilter, T > & meanPlaneFit()
Explicit conversion to MeanPlaneFitImpl , to access methods potentially hidden by heritage.
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition concepts.h:11
FIT_RESULT
Enum corresponding to the state of a fitting method (and what the finalize function returns)
Definition enums.h:15
@ CONFLICT_ERROR_FOUND
Multiple classes of the fitting procedure initialize the primitive.
Definition enums.h:27
@ STABLE
The fitting is stable and ready to use.
Definition enums.h:17