Visual Computing Library
Loading...
Searching...
No Matches
vcl::AbstractGrid< GridType, ValueType, DerivedGrid > Class Template Reference

The AbstractGrid class describes a generic Spatial Data Structure organized on a regular grid, that allows to store elements (ValueType) in a particular way that will be managed by its derived classes (e.g. StaticGrid, HashTableGrid). More...

#include <vclib/space/complex/grid/abstract_grid.h>

Inheritance diagram for vcl::AbstractGrid< GridType, ValueType, DerivedGrid >:

Classes

struct  DistIterPairComparator
 
struct  IterComparator
 

Public Types

using IntersectsCellFunction = std::function< bool(const typename GridType::BBoxType &, const RemoveCVRefAndPointer< ValueType > &)>
 The IntersectsCellFunction type is a std::function that takes as input a bounding box and a value, and returns true if the value intersects the bounding box.
 
using KeyType = GridType::CellCoord
 
template<typename QueryValueType >
using QueryDistFunction = std::function< typename GridType::ScalarType(const QueryValueType &, const RemoveCVRefAndPointer< ValueType > &)>
 The QueryDistFunction type is a std::function that takes as input a query value and a value stored in the grid, and returns the distance between the two values.
 
template<typename QueryValueType >
using QueryBoundedDistFunction = std::function< typename GridType::ScalarType(const QueryValueType &, const RemoveCVRefAndPointer< ValueType > &, typename GridType::ScalarType)>
 The QueryBoundedDistFunction type is a std::function that takes as input a query value, a value stored in the grid, and a maximum distance between the two values, and returns the distance between the two values. If the distance is greater than the maximum distance, the function must return a value greater than the maximum distance.
 

Public Member Functions

bool cellEmpty (const KeyType &k) const
 
std::size_t countInCell (const KeyType &k) const
 
bool insert (const ValueType &v)
 Inserts the given element in the AbstractGrid.
 
template<typename ObjIterator >
uint insert (ObjIterator begin, ObjIterator end)
 Inserts all the elements from begin to end. The type referenced by the iterator must be the ValueType of the AbstractGrid.
 
template<Range Rng>
uint insert (Rng &&r)
 Inserts all the elements contained in the input range r, from begin to end. The type referenced by the iterator must be the ValueType of the AbstractGrid.
 
bool erase (const ValueType &v)
 
bool eraseAllInCell (const KeyType &k)
 
uint countInSphere (const Sphere< typename GridType::ScalarType > &s) const
 
auto valuesInSphere (const Sphere< typename GridType::ScalarType > &s) const
 
void eraseInSphere (const Sphere< typename GridType::ScalarType > &s)
 
template<typename QueryValueType >
auto closestValue (const QueryValueType &qv, QueryBoundedDistFunction< QueryValueType > distFunction, typename GridType::ScalarType &dist) const
 
template<typename QueryValueType >
auto closestValue (const QueryValueType &qv, QueryDistFunction< QueryValueType > distFunction, typename GridType::ScalarType &dist) const
 
template<typename QueryValueType >
auto closestValue (const QueryValueType &qv, QueryDistFunction< QueryValueType > distFunction) const
 
template<typename QueryValueType >
auto closestValue (const QueryValueType &qv, typename GridType::ScalarType &dist) const
 
template<typename QueryValueType >
auto closestValue (const QueryValueType &qv) const
 
template<typename QueryValueType >
auto kClosestValues (const QueryValueType &qv, uint n, QueryDistFunction< QueryValueType > distFunction) const
 
template<typename QueryValueType >
auto kClosestValues (const QueryValueType &qv, uint n) const
 

Protected Member Functions

 AbstractGrid ()
 Empty constructor, creates an usable AbstractGrid, since the Grid is not initialized.
 
 AbstractGrid (const GridType &grid, IntersectsCellFunction intersects=nullptr)
 Creates a AbstractGrid that allows to store ValueType values on the given grid.
 
template<PointConcept PointType>
 AbstractGrid (const PointType &min, const PointType &max, const KeyType &sizes, IntersectsCellFunction intersects=nullptr)
 Creates a AbstractGrid that allows to store ValueType values on a Grid having min as minimum coordinte of the Grid, max as maximum coordinate of the grid, and the number of cells per dimension given by sizes.
 
template<typename BoxType >
 AbstractGrid (const BoxType &bbox, const KeyType &sizes, IntersectsCellFunction intersects=nullptr)
 Creates a AbstractGrid that allows to store ValueType values on a Grid bounded by bbox, and having the number of cells per dimension given by sizes.
 
template<typename ObjIterator >
 AbstractGrid (ObjIterator begin, ObjIterator end, IntersectsCellFunction intersects=nullptr)
 Creates an AbstractGrid having a proper Grid to store the elements.
 
template<Range Rng>
 AbstractGrid (Rng &&r, IntersectsCellFunction intersects=nullptr)
 Creates an AbstractGrid having a proper Grid to store the elements.
 

Protected Attributes

IntersectsCellFunction mIntersectsFun
 

Private Types

using VT = RemoveCVRefAndPointer< ValueType >
 
using Boxui = Box< Point< uint, GridType::DIM > >
 

Private Member Functions

DerivedGridderived ()
 
const DerivedGridderived () const
 
template<typename Iterator >
bool valueIsInSpehere (const Iterator &it, const Sphere< typename GridType::ScalarType > &s) const
 
template<typename QueryValueType >
auto closestInCells (const QueryValueType &qv, typename GridType::ScalarType &dist, const Boxui &interval, QueryBoundedDistFunction< QueryValueType > distFunction, const Boxui &ignore=Boxui()) const
 
template<typename QueryValueType >
auto valuesInCellNeighborhood (const QueryValueType &qv, uint n, QueryDistFunction< QueryValueType > distFunction, Boxui &ignore) const
 

Detailed Description

template<typename GridType, typename ValueType, typename DerivedGrid>
class vcl::AbstractGrid< GridType, ValueType, DerivedGrid >

The AbstractGrid class describes a generic Spatial Data Structure organized on a regular grid, that allows to store elements (ValueType) in a particular way that will be managed by its derived classes (e.g. StaticGrid, HashTableGrid).

This class cannot be instantiated. You can only instantiate a derived class.

This class provides only constructor and member functions that are common with all the derived classes. Note that derived class can hide some of the member exposed in this class (e.g. they could disallow the possibility to remove elements from a grid).

Member Typedef Documentation

◆ IntersectsCellFunction

template<typename GridType , typename ValueType , typename DerivedGrid >
using vcl::AbstractGrid< GridType, ValueType, DerivedGrid >::IntersectsCellFunction = std::function<bool( const typename GridType::BBoxType&, const RemoveCVRefAndPointer<ValueType>&)>

The IntersectsCellFunction type is a std::function that takes as input a bounding box and a value, and returns true if the value intersects the bounding box.

It is used to customize the behavior of the grid when inserting values.

◆ QueryBoundedDistFunction

template<typename GridType , typename ValueType , typename DerivedGrid >
using vcl::AbstractGrid< GridType, ValueType, DerivedGrid >::QueryBoundedDistFunction = std::function<typename GridType::ScalarType( const QueryValueType&, const RemoveCVRefAndPointer<ValueType>&, typename GridType::ScalarType)>

The QueryBoundedDistFunction type is a std::function that takes as input a query value, a value stored in the grid, and a maximum distance between the two values, and returns the distance between the two values. If the distance is greater than the maximum distance, the function must return a value greater than the maximum distance.

It is used to customize the behavior of the grid when querying values, and it allows to speedup the query by avoiding to compute some distances that are greater than the maximum distance.

◆ QueryDistFunction

template<typename GridType , typename ValueType , typename DerivedGrid >
using vcl::AbstractGrid< GridType, ValueType, DerivedGrid >::QueryDistFunction = std::function<typename GridType::ScalarType( const QueryValueType&, const RemoveCVRefAndPointer<ValueType>&)>

The QueryDistFunction type is a std::function that takes as input a query value and a value stored in the grid, and returns the distance between the two values.

It is used to customize the behavior of the grid when querying values.

Constructor & Destructor Documentation

◆ AbstractGrid() [1/5]

template<typename GridType , typename ValueType , typename DerivedGrid >
vcl::AbstractGrid< GridType, ValueType, DerivedGrid >::AbstractGrid ( const GridType &  grid,
IntersectsCellFunction  intersects = nullptr 
)
inlineprotected

Creates a AbstractGrid that allows to store ValueType values on the given grid.

Parameters
[in]gridthe grid on which the values will be stored.
[in]intersectsthe function that will be used to check if a inserted value intersects (lies in) a cell. If nullptr, the default intersects function will be used.

◆ AbstractGrid() [2/5]

template<typename GridType , typename ValueType , typename DerivedGrid >
template<PointConcept PointType>
vcl::AbstractGrid< GridType, ValueType, DerivedGrid >::AbstractGrid ( const PointType &  min,
const PointType &  max,
const KeyType &  sizes,
IntersectsCellFunction  intersects = nullptr 
)
inlineprotected

Creates a AbstractGrid that allows to store ValueType values on a Grid having min as minimum coordinte of the Grid, max as maximum coordinate of the grid, and the number of cells per dimension given by sizes.

Parameters
[in]min
[in]max
[in]sizes
[in]intersectsthe function that will be used to check if a inserted value intersects (lies in) a cell. If nullptr, the default intersects function will be used.

◆ AbstractGrid() [3/5]

template<typename GridType , typename ValueType , typename DerivedGrid >
template<typename BoxType >
vcl::AbstractGrid< GridType, ValueType, DerivedGrid >::AbstractGrid ( const BoxType &  bbox,
const KeyType &  sizes,
IntersectsCellFunction  intersects = nullptr 
)
inlineprotected

Creates a AbstractGrid that allows to store ValueType values on a Grid bounded by bbox, and having the number of cells per dimension given by sizes.

Parameters
[in]bbox
[in]sizes
[in]intersectsthe function that will be used to check if a inserted value intersects (lies in) a cell. If nullptr, the default intersects function will be used.

◆ AbstractGrid() [4/5]

template<typename GridType , typename ValueType , typename DerivedGrid >
template<typename ObjIterator >
vcl::AbstractGrid< GridType, ValueType, DerivedGrid >::AbstractGrid ( ObjIterator  begin,
ObjIterator  end,
IntersectsCellFunction  intersects = nullptr 
)
inlineprotected

Creates an AbstractGrid having a proper Grid to store the elements.

The bounding box and the sizes of the Grid are automatically computed. Bounding box is computed starting from the bounding box of all the iterated elements, and then inflated. The number of cells per dimension is computed using the vcl::bestGridSize function.

Note
This constructor does not insert the elements in the Grid Data Structure. Pure virtual classes cannot call pure virtual member functions from constuctors. It is duty of each derived class to insert the elements after calling this constructor.
Parameters
[in]begin
[in]end
[in]intersectsthe function that will be used to check if a inserted value intersects (lies in) a cell. If nullptr, the default intersects function will be used.

◆ AbstractGrid() [5/5]

template<typename GridType , typename ValueType , typename DerivedGrid >
template<Range Rng>
vcl::AbstractGrid< GridType, ValueType, DerivedGrid >::AbstractGrid ( Rng &&  r,
IntersectsCellFunction  intersects = nullptr 
)
inlineprotected

Creates an AbstractGrid having a proper Grid to store the elements.

The bounding box and the sizes of the Grid are automatically computed. Bounding box is computed starting from the bounding box of all the iterated elements, and then inflated. The number of cells per dimension is computed using the vcl::bestGridSize function.

Note
This constructor does not insert the elements in the Grid Data Structure. Pure virtual classes cannot call pure virtual member functions from constuctors. It is duty of each derived class to insert the elements after calling this constructor.
Parameters
[in]ra range that satisfies the concept std::ranges::range
[in]intersectsthe function that will be used to check if a inserted value intersects (lies in) a cell. If nullptr, the default intersects function will be used.

Member Function Documentation

◆ closestInCells()

template<typename GridType , typename ValueType , typename DerivedGrid >
auto vcl::AbstractGrid< GridType, ValueType, DerivedGrid >::closestInCells ( const QueryValueType qv,
typename GridType::ScalarType &  dist,
const Boxui interval,
QueryBoundedDistFunction< QueryValueType distFunction,
const Boxui ignore = Boxui() 
) const
inlineprivate

This function is meant to be called by another function of the AbstractGrid. Returns the closest Value (if any) to the given query value contained in the given interval

◆ insert() [1/3]

template<typename GridType , typename ValueType , typename DerivedGrid >
bool vcl::AbstractGrid< GridType, ValueType, DerivedGrid >::insert ( const ValueType &  v)
inline

Inserts the given element in the AbstractGrid.

If the ValueType is Puntual (a Point or a Vertex), the element will be inserted in just one cell of the grid. If the element is a spatial object having a bounding box with min != max, the element will be stored in all the cells where its bounding box lies.

Parameters
v
Returns

◆ insert() [2/3]

template<typename GridType , typename ValueType , typename DerivedGrid >
template<typename ObjIterator >
uint vcl::AbstractGrid< GridType, ValueType, DerivedGrid >::insert ( ObjIterator  begin,
ObjIterator  end 
)
inline

Inserts all the elements from begin to end. The type referenced by the iterator must be the ValueType of the AbstractGrid.

Parameters
begin
end
Returns
The number of inserted elements.

◆ insert() [3/3]

template<typename GridType , typename ValueType , typename DerivedGrid >
template<Range Rng>
uint vcl::AbstractGrid< GridType, ValueType, DerivedGrid >::insert ( Rng &&  r)
inline

Inserts all the elements contained in the input range r, from begin to end. The type referenced by the iterator must be the ValueType of the AbstractGrid.

Parameters
ra range that satisfies the concept std::ranges::range
Returns
The number of inserted elements.

◆ valueIsInSpehere()

template<typename GridType , typename ValueType , typename DerivedGrid >
template<typename Iterator >
bool vcl::AbstractGrid< GridType, ValueType, DerivedGrid >::valueIsInSpehere ( const Iterator &  it,
const Sphere< typename GridType::ScalarType > &  s 
) const
inlineprivate

This function is meant to be called by another function of the AbstractGrid. Checks if the current iterated value is inside a sphere


The documentation for this class was generated from the following file: