10#include "./indexSquaredDistance.h"
11#include "../Common/Containers/limitedPriorityQueue.h"
13#include PONCA_MULTIARCH_INCLUDE_STD(cmath)
14#include PONCA_MULTIARCH_INCLUDE_STD(limits)
22#define DECLARE_INDEX_QUERY_CLASS(OUT_TYPE) \
29template <typename Index, typename Scalar> \
30struct OUT_TYPE##IndexQuery : Query<QueryInputIsIndex<Index>, QueryOutputIs##OUT_TYPE<Index, Scalar>> \
33 using Base = Query<QueryInputIsIndex<Index>, QueryOutputIs##OUT_TYPE<Index, Scalar>>; \
42#define DECLARE_POINT_QUERY_CLASS(OUT_TYPE) \
49template <typename Index, typename DataPoint> \
50struct OUT_TYPE##PointQuery : Query<QueryInputIsPosition<DataPoint>, \
51 QueryOutputIs##OUT_TYPE<Index, typename DataPoint::Scalar>> \
54 using Base = Query<QueryInputIsPosition<DataPoint>, QueryOutputIs##OUT_TYPE<Index, typename DataPoint::Scalar>>; \
93 template<
typename InputType_>
126 template <
typename Index>
143 template <
typename IndexType>
146 template <
typename VectorType,
typename Container>
157 template<
typename DataPo
int>
174 template <
typename IndexType>
177 template <
typename VectorType=
typename DataPo
int::VectorType,
typename Container>
188 template<
typename Index,
typename Scalar>
212 PONCA_MULTIARCH
inline Scalar
radius()
const {
213 PONCA_MULTIARCH_STD_MATH(sqrt);
234 PONCA_MULTIARCH
inline void reset() { }
247 template<
typename Index,
typename Scalar>
281 template<
typename Index,
typename Scalar>
299 m_queue.push({-1, PONCA_MULTIARCH_CU_STD_NAMESPACE(numeric_limits)<Scalar>::max()});
313 template<
typename Input_,
typename Output_>
314 struct Query :
public Input_,
public Output_ {
320 static_assert(std::is_base_of<QueryInputBase, QueryInType>::value,
321 "QueryInType must inherit Ponca::QueryInputBase");
322 static_assert(std::is_base_of<QueryOutputBase, QueryOutType>::value,
323 "QueryInType must inherit Ponca::QueryInputBase");
326 PONCA_MULTIARCH
inline Query(
const typename QueryInType::InputType &in)
330 PONCA_MULTIARCH
inline Query(
const typename QueryOutType::OutputParameter &outParam,
331 const typename QueryInType::InputType &in)
335 template<
typename Base,
typename... outputType>
336 PONCA_MULTIARCH
inline Base&
operator()(
const typename QueryInType::InputType &in, outputType&&... out){
337 QueryInType:: operator()(in);
338 QueryOutType::operator()(std::forward<outputType>(out)...);
339 return *((Base*)(
this));
343 template<
typename Base>
344 PONCA_MULTIARCH
inline Base&
operator()(
const typename QueryInType::InputType &in){
345 QueryInType:: operator()(in);
346 return *((Base*)(
this));
350DECLARE_INDEX_QUERY_CLASS(KNearest)
351DECLARE_INDEX_QUERY_CLASS(Nearest)
352DECLARE_INDEX_QUERY_CLASS(Range)
353DECLARE_POINT_QUERY_CLASS(KNearest)
354DECLARE_POINT_QUERY_CLASS(Nearest)
355DECLARE_POINT_QUERY_CLASS(Range)
359#undef DECLARE_INDEX_QUERY_CLASS
360#undef DECLARE_POINT_QUERY_CLASS
The limited_priority_queue class is similar to std::priority_queue but has a limited capacity and han...
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.
QueryOutputIsKNearest(OutputParameter k=0)
Default constructor that initialize the output parameter value.
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.
Index OutputParameter
Alias to Output type.
QueryInputIsPosition(const InputType &point=InputType::Zero())
Default constructor that initialize the input position.
limited_priority_queue< IndexSquaredDistance< Index, Scalar > > m_queue
Queue storing the neighbors.
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.
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)
void reset()
Reset Query for a new search.
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.
void operator()(OutputParameter k)
Access operator that resets the output parameter.
Output_ QueryOutType
Alias to the output type.
Scalar m_squared_distance
Distance to the nearest neighbor.
limited_priority_queue< IndexSquaredDistance< Index, Scalar > > & queue()
Access to the priority queue storing the neighbors.
Scalar descentDistanceThreshold() const
Distance threshold used during tree descent to select nodes to explore.
void operator()(OutputParameter radius)
Access operator that resets the output parameter.
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.
QueryInputIsIndex(const InputType &point=-1)
Default constructor that initialize the input index.
void setInput(const InputType &input)
Edit the input.
void operator()(const InputType &point=InputType::Zero())
Access operator that resets the input index.
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.