10#include "./indexSquaredDistance.h"
11#include "../Common/Containers/limitedPriorityQueue.h"
13#include PONCA_MULTIARCH_INCLUDE_STD(cmath)
14#include PONCA_MULTIARCH_INCLUDE_STD(limits)
55 template <
typename InputType_>
89 template <
typename Index>
105 template <
typename IndexType>
111 template <
typename VectorType,
typename Container>
124 template <
typename DataPo
int>
140 template <
typename IndexType>
146 template <
typename VectorType =
typename DataPo
int::VectorType,
typename Container>
149 return Base::input();
159 template <
typename Index,
typename Scalar>
184 PONCA_MULTIARCH
inline Scalar
radius()
const
186 PONCA_MULTIARCH_STD_MATH(
sqrt);
205 PONCA_MULTIARCH
inline void reset() {}
218 template <
typename Index,
typename Scalar>
256 template <
typename Index,
typename Scalar,
int MAX_KNN_SIZE>
292 template <
typename Input_,
typename Output_>
293 struct Query :
public Input_,
public Output_
300 static_assert(std::is_base_of<QueryInputBase, QueryInType>::value,
301 "QueryInType must inherit Ponca::QueryInputBase");
302 static_assert(std::is_base_of<QueryOutputBase, QueryOutType>::value,
303 "QueryInType must inherit Ponca::QueryInputBase");
309 PONCA_MULTIARCH
inline Query(
const typename QueryOutType::OutputParameter&
outParam,
310 const typename QueryInType::InputType&
in)
316 template <
typename Base,
typename...
outputType>
319 QueryInType::operator()(
in);
320 QueryOutType::operator()(std::forward<outputType>(
out)...);
321 return *((Base*)(
this));
325 template <
typename Base>
326 PONCA_MULTIARCH
inline Base&
operator()(
const typename QueryInType::InputType&
in)
328 QueryInType::operator()(
in);
329 return *((Base*)(
this));
333#define POINT_QUERY_DOC(OUT_TYPE)
\
341#define INDEX_QUERY_DOC(OUT_TYPE)
\
349 POINT_QUERY_DOC(KNearest)
351 template <
typename Index,
typename DataPo
int,
int MAX_KNN_SIZE>
355 template <
typename Index,
typename DataPo
int>
358 POINT_QUERY_DOC(
Range)
359 template <
typename Index,
typename DataPo
int>
364 template <
typename Index,
typename Scalar,
int MAX_KNN_SIZE>
367 template <
typename Index,
typename Scalar>
370 template <
typename Index,
typename Scalar>
374#undef POINT_QUERY_DOC
375#undef INDEX_QUERY_DOC
Aggregator class used to declare specialized structures using CRTP.
QueryInput(InputType input)
Default constructor that initialize the input field.
Index get() const
Get the closest points.
Scalar squaredRadius() const
Generic method to access the radius squared.
void operator()(const InputType &point=InputType::Zero())
Access operator that resets the input point.
Base & operator()(const typename QueryInType::InputType &in)
Access operator that resets the input parameter only.
Scalar descentDistanceThreshold() const
Distance threshold used during tree descent to select nodes to explore.
void operator()(OutputParameter k)
Access operator that resets the output parameter.
const VectorType getInputPosition(const Container &)
Generic method to access input position. The VectorType needs to be passed as a template argument.
InputType_ InputType
Alias to the templated input type.
Scalar descentDistanceThreshold() const
Distance threshold used during tree descent to select nodes to explore.
QueryOutputIsRange(OutputParameter radius=OutputParameter(0))
Default constructor that initialize the output parameter value.
QueryInputIsPosition(const InputType &point=InputType::Zero())
Default constructor that initialize the input position.
bool skipIndexFunctor(IndexType idx) const
Functor used to check if a given Idx must be skipped.
typename Base::InputType InputType
Alias to the templated input type (Index)
const VectorType getInputPosition(const Container &c)
Generic method to access input position. The VectorType needs to be passed as a template argument.
LimitedPriorityQueue< IndexSquaredDistance< Index, Scalar >, MAX_KNN_SIZE > Queue
Alias to LimitedPriorityQueue.
Index m_nearest
Index of the nearest neighbor.
void operator()()
Access operator.
Query(const typename QueryOutType::OutputParameter &outParam, const typename QueryInType::InputType &in)
Default constructor that initialize the input and output parameters.
Scalar radius() const
Generic method to access the radius.
Scalar OutputParameter
Alias to Output type.
void reset()
Reset Query for a new search.
typename QueryOutputBase::DummyOutputParameter OutputParameter
Alias to Output type.
Scalar m_squared_radius
Radius used for the search.
void setSquaredRadius(Scalar radius)
Set the squared radius distance of the query.
typename Base::InputType InputType
Alias to the templated input type (Index)
Base & operator()(const typename QueryInType::InputType &in, outputType &&... out)
Access operator that resets the input and output parameters.
Input_ QueryInType
Alias to the input type.
void setRadius(Scalar radius)
Set the radius distance of the query.
QueryOutputIsNearest()
Default constructor.
void reset()
Reset Query for a new search.
Output_ QueryOutType
Alias to the output type.
Index OutputParameter
Alias to Output type.
Scalar descentDistanceThreshold() const
Distance threshold used during tree descent to select nodes to explore.
Scalar m_squared_distance
Distance to the nearest neighbor.
void operator()(OutputParameter radius)
Access operator that resets the output parameter.
Queue & queue()
Access to the priority queue storing the neighbors.
const InputType & input() const
Read access to the input.
Query(const typename QueryInType::InputType &in)
Default constructor that initialize the input parameter only.
bool skipIndexFunctor(IndexType idx) const
Functor used to check if a given Idx must be skipped.
QueryOutputIsKNearest(OutputParameter k=0)
Default constructor that initialize the output parameter value.
QueryInputIsIndex(const InputType &point=-1)
Default constructor that initialize the input index.
void setInput(const InputType &input)
Edit the input.
void reset()
Reset Query for a new search.
void operator()(const InputType &point=InputType::Zero())
Access operator that resets the input index.
Queue m_queue
Queue storing the neighbors.
#define INDEX_QUERY_DOC(OUT_TYPE)
Base Query class combining QueryInputIsPosition and QueryOutputIs##OUT_TYPE##.
Composes the Query object depending on an input type and output type.
Base class for queries output types.
Class to construct the knearest queries.
Class to construct the nearest query output.
Class to construct the range query output.
This Source Code Form is subject to the terms of the Mozilla Public License, v.