Ponca  6f9f1b59d7c8c4654a710cfcef7342f4f5c79ba1
Point Cloud Analysis library
Loading...
Searching...
No Matches
weightFilter.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 "../../Common/Assert.h"
10#include "../defines.h"
11#include "./frame.h"
12#include PONCA_MULTIARCH_INCLUDE_CU_STD(utility)
13
14namespace Ponca
15{
32 template <class _DataPoint, class WeightKernel>
34 {
35 public:
39 using Scalar = typename DataPoint::Scalar;
41 using VectorType = typename DataPoint::VectorType;
43 using MatrixType = typename DataPoint::MatrixType;
45 using WeightReturnType = PONCA_MULTIARCH_CU_STD_NAMESPACE(pair)<Scalar, VectorType>;
49 static constexpr bool isCompact = WeightKernel::isCompact;
50
55 PONCA_MULTIARCH inline DistWeightFilter(const VectorType& _evalPos = VectorType::Zero(),
56 const Scalar& _t = Scalar(1.))
58 {
59 PONCA_ASSERT(_t > Scalar(0));
60 }
61
63 PONCA_MULTIARCH inline DistWeightFilter(const DataPoint& _evalPoint, const Scalar& _t = Scalar(1.))
65 {
66 PONCA_ASSERT(_t > Scalar(0));
67 }
68
83 PONCA_MULTIARCH inline WeightReturnType operator()(const DataPoint& q) const;
84
100 PONCA_MULTIARCH [[nodiscard]] inline VectorType spacedw(const VectorType& _q,
101 const DataPoint& /*attributes*/) const;
102
124 PONCA_MULTIARCH [[nodiscard]] inline MatrixType spaced2w(const VectorType& _q,
125 const DataPoint& /*attributes*/) const;
126
141 PONCA_MULTIARCH [[nodiscard]] inline Scalar scaledw(const VectorType& _q,
142 const DataPoint& /*attributes*/) const;
143
162 PONCA_MULTIARCH [[nodiscard]] inline Scalar scaled2w(const VectorType& _q,
163 const DataPoint& /*attributes*/) const;
164
184 PONCA_MULTIARCH [[nodiscard]] inline VectorType scaleSpaced2w(const VectorType& _q,
185 const DataPoint& /*attributes*/) const;
186
188 PONCA_MULTIARCH [[nodiscard]] inline Scalar evalScale() const { return m_t; }
189
190 PONCA_MULTIARCH [[nodiscard]] inline NeighborhoodFrame& frame() { return *this; }
191 PONCA_MULTIARCH [[nodiscard]] inline const NeighborhoodFrame& frame() const { return *this; }
192
193 protected:
197 }; // class DistWeightFunc
198
199 namespace internal
200 {
208 template <class _DataPoint, template <typename> typename _NeighborhoodFrame>
209 class NoWeightFilterBase : public _NeighborhoodFrame<_DataPoint>
210 {
211 public:
215 using Scalar = typename DataPoint::Scalar;
217 using VectorType = typename DataPoint::VectorType;
219 using MatrixType = typename DataPoint::MatrixType;
221 using WeightReturnType = PONCA_MULTIARCH_CU_STD_NAMESPACE(pair)<Scalar, VectorType>;
222
224
228 PONCA_MULTIARCH inline NoWeightFilterBase(const VectorType& v = VectorType::Zero(), Scalar = 0)
230 {
231 }
232
234 PONCA_MULTIARCH inline NoWeightFilterBase(const DataPoint& v, Scalar = 0) : NoWeightFilterBase(v.pos()) {}
235
240 PONCA_MULTIARCH inline WeightReturnType operator()(const DataPoint& _q) const
241 {
242 return {Scalar(1), NeighborhoodFrame::convertToLocalBasis(_q.pos())};
243 }
244
250 PONCA_MULTIARCH [[nodiscard]] inline VectorType spacedw(const VectorType& /*_q*/,
251 const DataPoint& /*attributes*/) const
252 {
253 return VectorType::Zeros();
254 }
255
261 PONCA_MULTIARCH [[nodiscard]] inline MatrixType spaced2w(const VectorType& /*_q*/,
262 const DataPoint& /*attributes*/) const
263 {
264 return MatrixType::Zeros();
265 }
266
271 PONCA_MULTIARCH [[nodiscard]] inline Scalar scaledw(const VectorType& /*_q*/,
272 const DataPoint& /*attributes*/) const
273 {
274 return Scalar(0);
275 }
276
281 PONCA_MULTIARCH [[nodiscard]] inline Scalar scaled2w(const VectorType& /*_q*/,
282 const DataPoint& /*attributes*/) const
283 {
284 return Scalar(0);
285 }
286
292 PONCA_MULTIARCH [[nodiscard]] inline VectorType scaleSpaced2w(const VectorType& /*_q*/,
293 const DataPoint& /*attributes*/) const
294 {
295 return VectorType::Zeros();
296 }
297
298 PONCA_MULTIARCH [[nodiscard]] inline NeighborhoodFrame& frame() { return *this; }
299 PONCA_MULTIARCH [[nodiscard]] inline const NeighborhoodFrame& frame() const { return *this; }
300 }; // class NoWeightFuncBase
301
302 template <typename DataPoint>
303 inline constexpr typename DataPoint::VectorType ConvertDataPointToNormal(const DataPoint& pt)
304 {
305 return pt.normal();
306 }
307 } // namespace internal
308
317 template <class _DataPoint, typename DataType, typename NeighborFilter, auto DataConverter>
318 class FilterWithAttributes : public NeighborFilter
319 {
320 public:
323 using Base = NeighborFilter;
325 using Scalar = typename DataPoint::Scalar;
327 using VectorType = typename DataPoint::VectorType;
329 using MatrixType = typename DataPoint::MatrixType;
331 using WeightReturnType = PONCA_MULTIARCH_CU_STD_NAMESPACE(pair)<Scalar, VectorType>;
332
337 PONCA_MULTIARCH inline FilterWithAttributes(const VectorType& _evalPos = VectorType::Zero(),
338 const Scalar& _t = Scalar(1), const DataType& _data = DataType{})
339 : Base(_evalPos, _t), m_data(_data)
340 {
341 }
342
348 PONCA_MULTIARCH inline FilterWithAttributes(const DataPoint& _evalPoint, const Scalar& _t = Scalar(0))
350 {
351 }
352
354 PONCA_MULTIARCH inline const DataType& data() const { return m_data; }
355
356 protected:
358 }; // class FilterWithAttributes
359
360 template <class DataPoint>
364 struct NoWeightFilter : public internal::NoWeightFilterBase<DataPoint, CenteredNeighborhoodFrame>
365 {
367 };
368
369 template <class DataPoint>
376
377#include "weightFilter.hpp"
378
379} // namespace Ponca
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:260
typename P::Scalar Scalar
Scalar type used for computation, as defined from template parameter P
Definition basket.h:268
NeighborhoodFrame that express 3d points relatively to a prescribed center.
Definition frame.h:28
Weight neighbors according to the Euclidean distance between a query and a reference position.
WeightKernel m_wk
1D function applied to weight queries
_DataPoint DataPoint
Alias to _DataPoint template parameter.
typename DataPoint::MatrixType MatrixType
Matrix type from DataPoint.
std::pair< Scalar, VectorType > WeightReturnType
Return type of the method #w()
CenteredNeighborhoodFrame< DataPoint > NeighborhoodFrame
Frame used to express the neighbors locally.
Scalar scaledw(const VectorType &_q, const DataPoint &) const
First order derivative in scale .
Scalar m_t
Evaluation scale.
typename DataPoint::VectorType VectorType
Vector type from DataPoint.
typename DataPoint::Scalar Scalar
Scalar type from DataPoint.
DistWeightFilter(const VectorType &_evalPos=VectorType::Zero(), const Scalar &_t=Scalar(1.))
Constructor that defines the current evaluation scale.
static constexpr bool isCompact
Flag indicating if the weighting kernel is compact of not.
Scalar scaled2w(const VectorType &_q, const DataPoint &) const
Second order derivative in scale .
DistWeightFilter(const DataPoint &_evalPoint, const Scalar &_t=Scalar(1.))
!
MatrixType spaced2w(const VectorType &_q, const DataPoint &) const
Second order derivative in space (for each spatial dimension .
WeightReturnType operator()(const DataPoint &q) const
Compute the weight of the given query with respect to its coordinates.
VectorType scaleSpaced2w(const VectorType &_q, const DataPoint &) const
Cross derivative in scale and in space (for each spatial dimension .
VectorType spacedw(const VectorType &_q, const DataPoint &) const
First order derivative in space (for each spatial dimension .
Scalar evalScale() const
Access to the evaluation scale set during the initialization.
This class extends a NeighborFilter class to also store additional data, for use outside the scope of...
typename DataPoint::Scalar Scalar
Scalar type from DataPoint.
FilterWithAttributes(const DataPoint &_evalPoint, const Scalar &_t=Scalar(0))
Constructor that defines the current evaluation scale and construct the DataType from the _evalPoint ...
FilterWithAttributes(const VectorType &_evalPos=VectorType::Zero(), const Scalar &_t=Scalar(1), const DataType &_data=DataType{})
Constructor that defines the current evaluation scale.
DataType m_data
Evaluation normal.
typename DataPoint::VectorType VectorType
Vector type from DataPoint.
std::pair< Scalar, VectorType > WeightReturnType
Return type of the method #w()
typename DataPoint::MatrixType MatrixType
Matrix type from DataPoint.
const DataType & data() const
Access to the evaluation normal set during the initialization.
NeighborhoodFrame that keep points in the global frame without applying any transformation This class...
Definition frame.h:106
Weighting function that set uniform weight to all samples.
Scalar scaled2w(const VectorType &, const DataPoint &) const
Second order derivative in scale , which are always $0$.
typename DataPoint::Scalar Scalar
Scalar type from DataPoint.
std::pair< Scalar, VectorType > WeightReturnType
Return type of the method #w()
Scalar scaledw(const VectorType &, const DataPoint &) const
First order derivative in scale , which are always $0$.
typename DataPoint::VectorType VectorType
Vector type from DataPoint.
VectorType spacedw(const VectorType &, const DataPoint &) const
First order derivative in space (for each spatial dimension , which are always $0$.
typename DataPoint::MatrixType MatrixType
Matrix type from DataPoint.
NoWeightFilterBase(const DataPoint &v, Scalar=0)
!
VectorType scaleSpaced2w(const VectorType &, const DataPoint &) const
Cross derivative in scale and in space (for each spatial dimension , which are always $0$.
WeightReturnType operator()(const DataPoint &_q) const
Compute the weight of the given query, which is always $1$.
MatrixType spaced2w(const VectorType &, const DataPoint &) const
Second order derivative in space (for each spatial dimension , which are always $0$.
NoWeightFilterBase(const VectorType &v=VectorType::Zero(), Scalar=0)
Default constructor.
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition concepts.h:11
Weighting function that set uniform weight to all samples and keep neighbors coordinates in global fr...
Weighting function that set uniform weight to all samples, but transform neighbors coordinates to loc...