Ponca  8e4373a7fc557bbfb1afb9210d70f03872388d04
Point Cloud Analysis library
Loading...
Searching...
No Matches
weightFunc.h
1/*
2 This Source Code Form is subject to the terms of the Mozilla Public
3 License, v. 2.0. If a copy of the MPL was not distributed with this
4 file, You can obtain one at http://mozilla.org/MPL/2.0/.
5*/
6
7#pragma once
8
9#include "./defines.h"
10#include PONCA_MULTIARCH_INCLUDE_CU_STD(utility)
11
12namespace Ponca
13{
26template<class DataPoint>
28public:
30 using Scalar = typename DataPoint::Scalar;
32 using VectorType = typename DataPoint::VectorType;
33
35 static constexpr bool hasLocalFrame = true;
36
37 PONCA_MULTIARCH inline explicit CenteredNeighborhoodFrame(const VectorType & _evalPos = VectorType::Zero())
38 : m_p(_evalPos) {}
39
41 PONCA_MULTIARCH inline void changeNeighborhoodFrame(const VectorType& _newEvalPos) { m_p = _newEvalPos; };
42
48 PONCA_MULTIARCH [[nodiscard]] inline VectorType convertToGlobalBasis(const VectorType& _q) const { return _q + m_p; }
49
56 PONCA_MULTIARCH [[nodiscard]] inline VectorType convertToLocalBasis(const VectorType& _q) const { return _q - m_p; }
57
62 PONCA_MULTIARCH [[nodiscard]] inline VectorType evalPos() const { return m_p; }
63
64private:
65 VectorType m_p;
66};
77template<class DataPoint>
79public:
81 using Scalar = typename DataPoint::Scalar;
83 using VectorType = typename DataPoint::VectorType;
84
86 static constexpr bool hasLocalFrame = false;
87
88 PONCA_MULTIARCH inline explicit GlobalNeighborhoodFrame(const VectorType & /*_evalPos*/ = VectorType::Zero()) {}
89
91 PONCA_MULTIARCH inline void changeNeighborhoodFrame(const VectorType& /*_newEvalPos*/) {};
92
98 PONCA_MULTIARCH [[nodiscard]] inline const VectorType& convertToGlobalBasis(const VectorType& _q) const { return _q; }
99
105 PONCA_MULTIARCH [[nodiscard]] inline const VectorType& convertToLocalBasis(const VectorType& _q) const { return _q; }
106};
107
108
125template <class DataPoint, class WeightKernel>
127{
128public:
130 using Scalar = typename DataPoint::Scalar;
132 using VectorType = typename DataPoint::VectorType;
134 using MatrixType = typename DataPoint::MatrixType;
136 using WeightReturnType = PONCA_MULTIARCH_CU_STD_NAMESPACE(pair)<Scalar, VectorType>;
140 static constexpr bool isCompact = WeightKernel::isCompact;
141
146 PONCA_MULTIARCH inline DistWeightFunc(const VectorType & _evalPos = VectorType::Zero(),
147 const Scalar& _t = Scalar(1.))
148 : NeighborhoodFrame(_evalPos), m_t(_t)
149 {
150 //\todo manage that assert on __host__ and __device__
151 //assert(_t > Scalar(0));
152 }
153
168 PONCA_MULTIARCH inline WeightReturnType operator()(const DataPoint& q) const;
169
170
186 PONCA_MULTIARCH [[nodiscard]] inline VectorType spacedw(const VectorType& _q,
187 const DataPoint& /*attributes*/) const;
188
189
210 PONCA_MULTIARCH [[nodiscard]] inline MatrixType spaced2w(const VectorType& _q,
211 const DataPoint& /*attributes*/) const;
212
227 PONCA_MULTIARCH [[nodiscard]] inline Scalar scaledw(const VectorType& _q,
228 const DataPoint& /*attributes*/) const;
229
248 PONCA_MULTIARCH [[nodiscard]] inline Scalar scaled2w(const VectorType& _q,
249 const DataPoint& /*attributes*/) const;
250
270 PONCA_MULTIARCH [[nodiscard]] inline VectorType scaleSpaced2w(const VectorType& _q,
271 const DataPoint& /*attributes*/) const;
272
274 PONCA_MULTIARCH [[nodiscard]] inline Scalar evalScale() const { return m_t; }
275
276protected:
278 WeightKernel m_wk;
280};// class DistWeightFunc
281
282
290template <class DataPoint, template <typename>typename _NeighborhoodFrame>
291class NoWeightFuncBase : public _NeighborhoodFrame<DataPoint>
292{
293public:
295 using Scalar = typename DataPoint::Scalar;
297 using VectorType = typename DataPoint::VectorType;
299 using MatrixType = typename DataPoint::MatrixType;
301 using WeightReturnType = PONCA_MULTIARCH_CU_STD_NAMESPACE(pair)<Scalar, VectorType>;
302
303 using NeighborhoodFrame = _NeighborhoodFrame<DataPoint>;
304
308 PONCA_MULTIARCH inline NoWeightFuncBase(const VectorType& v = VectorType::Zero(), Scalar = 0)
309 : NeighborhoodFrame(v){ }
310
315 PONCA_MULTIARCH inline WeightReturnType operator()(const DataPoint& _q) const
316 {
317 return {Scalar(1), NeighborhoodFrame::convertToLocalBasis(_q.pos())};
318 }
319
320
325 PONCA_MULTIARCH [[nodiscard]] inline VectorType spacedw(const VectorType& /*_q*/,
326 const DataPoint& /*attributes*/) const
327 { return VectorType::Zeros(); }
328
329
334 PONCA_MULTIARCH [[nodiscard]] inline MatrixType spaced2w(const VectorType& /*_q*/,
335 const DataPoint& /*attributes*/) const
336 { return MatrixType::Zeros(); }
337
342 PONCA_MULTIARCH [[nodiscard]] inline Scalar scaledw(const VectorType& /*_q*/,
343 const DataPoint& /*attributes*/) const
344 { return Scalar(0); }
345
350 PONCA_MULTIARCH [[nodiscard]] inline Scalar scaled2w(const VectorType& /*_q*/,
351 const DataPoint& /*attributes*/) const
352 { return Scalar(0); }
353
359 PONCA_MULTIARCH [[nodiscard]] inline VectorType scaleSpaced2w(const VectorType& /*_q*/,
360 const DataPoint& /*attributes*/) const
361 { return VectorType::Zeros(); }
362};// class DistWeightFuncBase
363
364template <class DataPoint>
366using NoWeightFunc = NoWeightFuncBase<DataPoint, CenteredNeighborhoodFrame>;
367
368template <class DataPoint>
370using NoWeightFuncGlobal = NoWeightFuncBase<DataPoint, GlobalNeighborhoodFrame>;
371#include "weightFunc.hpp"
372
373}// namespace Ponca
NeighborhoodFrame that express 3d points relatively to a prescribed center.
Definition weightFunc.h:27
typename DataPoint::VectorType VectorType
Vector type from DataPoint.
Definition weightFunc.h:32
typename DataPoint::Scalar Scalar
Scalar type from DataPoint.
Definition weightFunc.h:30
VectorType convertToGlobalBasis(const VectorType &_q) const
Convert query from local to global coordinate system, such as .
Definition weightFunc.h:48
VectorType convertToLocalBasis(const VectorType &_q) const
Convert query from global to local coordinate system, such as .
Definition weightFunc.h:56
void changeNeighborhoodFrame(const VectorType &_newEvalPos)
Change neighborhood frame (move basis center)
Definition weightFunc.h:41
static constexpr bool hasLocalFrame
Flag indicating that this class modifies the coordinates when passing from global to local.
Definition weightFunc.h:35
VectorType evalPos() const
Get access to the stored points of evaluation.
Definition weightFunc.h:62
Weight neighbors according to the euclidean distance between a query and a reference position.
Definition weightFunc.h:127
Scalar scaledw(const VectorType &_q, const DataPoint &) const
First order derivative in scale .
Scalar scaled2w(const VectorType &_q, const DataPoint &) const
Second order derivative in scale .
VectorType scaleSpaced2w(const VectorType &_q, const DataPoint &) const
Cross derivative in scale and in space (for each spatial dimension .
MatrixType spaced2w(const VectorType &_q, const DataPoint &) const
Second order derivative in space (for each spatial dimension .
typename DataPoint::MatrixType MatrixType
Matrix type from DataPoint.
Definition weightFunc.h:134
DistWeightFunc(const VectorType &_evalPos=VectorType::Zero(), const Scalar &_t=Scalar(1.))
Constructor that defines the current evaluation scale.
Definition weightFunc.h:146
Scalar evalScale() const
Access to the evaluation scale set during the initialization.
Definition weightFunc.h:274
VectorType spacedw(const VectorType &_q, const DataPoint &) const
First order derivative in space (for each spatial dimension .
std::pair< Scalar, VectorType > WeightReturnType
Return type of the method #w()
Definition weightFunc.h:136
typename DataPoint::Scalar Scalar
Scalar type from DataPoint.
Definition weightFunc.h:130
WeightReturnType operator()(const DataPoint &q) const
Compute the weight of the given query with respect to its coordinates.
WeightKernel m_wk
1D function applied to weight queries
Definition weightFunc.h:278
static constexpr bool isCompact
Flag indicating if the weighting kernel is compact of not.
Definition weightFunc.h:140
Scalar m_t
Evaluation scale.
Definition weightFunc.h:277
typename DataPoint::VectorType VectorType
Vector type from DataPoint.
Definition weightFunc.h:132
NeighborhoodFrame that keep points in the global frame without applying any transformation.
Definition weightFunc.h:78
static constexpr bool hasLocalFrame
Flag indicating that this class does not modify the coordinates when passing from global to local.
Definition weightFunc.h:86
const VectorType & convertToGlobalBasis(const VectorType &_q) const
Convert position from local to global coordinate system : does nothing as this is global frame.
Definition weightFunc.h:98
typename DataPoint::Scalar Scalar
Scalar type from DataPoint.
Definition weightFunc.h:81
void changeNeighborhoodFrame(const VectorType &)
Change neighborhood frame (has no effect for global basis)
Definition weightFunc.h:91
typename DataPoint::VectorType VectorType
Vector type from DataPoint.
Definition weightFunc.h:83
const VectorType & convertToLocalBasis(const VectorType &_q) const
Convert query from global to local coordinate system : does nothing as this is global frame.
Definition weightFunc.h:105
Base Weighting function that set uniform weight to all samples.
Definition weightFunc.h:292
WeightReturnType operator()(const DataPoint &_q) const
Compute the weight of the given query, which is always $1$.
Definition weightFunc.h:315
typename DataPoint::MatrixType MatrixType
Matrix type from DataPoint.
Definition weightFunc.h:299
VectorType spacedw(const VectorType &, const DataPoint &) const
First order derivative in space (for each spatial dimension , which are always $0$.
Definition weightFunc.h:325
Scalar scaledw(const VectorType &, const DataPoint &) const
First order derivative in scale , which are always $0$.
Definition weightFunc.h:342
Scalar scaled2w(const VectorType &, const DataPoint &) const
Second order derivative in scale , which are always $0$.
Definition weightFunc.h:350
typename DataPoint::VectorType VectorType
Vector type from DataPoint.
Definition weightFunc.h:297
std::pair< Scalar, VectorType > WeightReturnType
Return type of the method #w()
Definition weightFunc.h:301
VectorType scaleSpaced2w(const VectorType &, const DataPoint &) const
Cross derivative in scale and in space (for each spatial dimension , which are always $0$.
Definition weightFunc.h:359
NoWeightFuncBase(const VectorType &v=VectorType::Zero(), Scalar=0)
Default constructor.
Definition weightFunc.h:308
MatrixType spaced2w(const VectorType &, const DataPoint &) const
Second order derivative in space (for each spatial dimension , which are always $0$.
Definition weightFunc.h:334
typename DataPoint::Scalar Scalar
Scalar type from DataPoint.
Definition weightFunc.h:295
This Source Code Form is subject to the terms of the Mozilla Public License, v.