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) \
30 template <typename Index, typename Scalar> \
31 struct OUT_TYPE##IndexQuery : Query<QueryInputIsIndex<Index>, QueryOutputIs##OUT_TYPE<Index, Scalar>> \
34 using Base = Query<QueryInputIsIndex<Index>, QueryOutputIs##OUT_TYPE<Index, Scalar>>; \
42#define DECLARE_POINT_QUERY_CLASS(OUT_TYPE) \
50 template <typename Index, typename DataPoint> \
51 struct OUT_TYPE##PointQuery \
52 : Query<QueryInputIsPosition<DataPoint>, QueryOutputIs##OUT_TYPE<Index, typename DataPoint::Scalar>> \
56 Query<QueryInputIsPosition<DataPoint>, QueryOutputIs##OUT_TYPE<Index, typename DataPoint::Scalar>>; \
98 template <
typename InputType_>
108 PONCA_MULTIARCH
inline const InputType&
input()
const {
return m_input; }
132 template <
typename Index>
133 struct QueryInputIsIndex :
public QueryInput<Index>
148 template <
typename IndexType>
154 template <
typename VectorType,
typename Container>
155 PONCA_MULTIARCH
inline const VectorType
getInputPosition(
const Container& c)
167 template <
typename DataPo
int>
168 struct QueryInputIsPosition :
public QueryInput<typename DataPoint::VectorType>
183 template <
typename IndexType>
189 template <
typename VectorType =
typename DataPo
int::VectorType,
typename Container>
202 template <
typename Index,
typename Scalar>
203 struct QueryOutputIsRange :
public QueryOutputBase
227 PONCA_MULTIARCH
inline Scalar
radius()
const
229 PONCA_MULTIARCH_STD_MATH(
sqrt);
248 PONCA_MULTIARCH
inline void reset() {}
261 template <
typename Index,
typename Scalar>
262 struct QueryOutputIsNearest :
public QueryOutputBase
278 PONCA_MULTIARCH
void reset()
297 template <
typename Index,
typename Scalar>
298 struct QueryOutputIsKNearest :
public QueryOutputBase
317 PONCA_MULTIARCH
void reset()
334 template <
typename Input_,
typename Output_>
335 struct Query :
public Input_,
public Output_
342 static_assert(std::is_base_of<QueryInputBase, QueryInType>::value,
343 "QueryInType must inherit Ponca::QueryInputBase");
344 static_assert(std::is_base_of<QueryOutputBase, QueryOutType>::value,
345 "QueryInType must inherit Ponca::QueryInputBase");
351 PONCA_MULTIARCH
inline Query(
const typename QueryOutType::OutputParameter&
outParam,
352 const typename QueryInType::InputType&
in)
358 template <
typename Base,
typename...
outputType>
361 QueryInType::operator()(
in);
362 QueryOutType::operator()(std::forward<outputType>(
out)...);
363 return *((Base*)(
this));
367 template <
typename Base>
368 PONCA_MULTIARCH
inline Base&
operator()(
const typename QueryInType::InputType& in)
370 QueryInType::operator()(in);
371 return *((Base*)(
this));
379 DECLARE_POINT_QUERY_CLASS(
Nearest)
380 DECLARE_POINT_QUERY_CLASS(
Range)
384#undef DECLARE_INDEX_QUERY_CLASS
385#undef DECLARE_POINT_QUERY_CLASS
Aggregator class used to declare specialized structures using CRTP.
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.
Scalar descentDistanceThreshold() const
Distance threshold used during tree descent to select nodes to explore.
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.
Index OutputParameter
Alias to Output type.
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.
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.
bool skipIndexFunctor(IndexType idx) const
Functor used to check if a given Idx must be skipped.
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 range query output.
This Source Code Form is subject to the terms of the Mozilla Public License, v.