Visual Computing Library
|
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>
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 | |
DerivedGrid * | derived () |
const DerivedGrid * | derived () 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 |
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).
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.
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.
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.
|
inlineprotected |
Creates a AbstractGrid that allows to store ValueType values on the given grid.
[in] | grid | the grid on which the values will be stored. |
[in] | intersects | the 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. |
|
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
.
[in] | min | |
[in] | max | |
[in] | sizes | |
[in] | intersects | the 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. |
|
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
.
[in] | bbox | |
[in] | sizes | |
[in] | intersects | the 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. |
|
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.
[in] | begin | |
[in] | end | |
[in] | intersects | the 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. |
|
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.
[in] | r | a range that satisfies the concept std::ranges::range |
[in] | intersects | the 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. |
|
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
|
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.
v |
|
inline |
Inserts all the elements from begin
to end
. The type referenced by the iterator must be the ValueType of the AbstractGrid.
begin | |
end |
|
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.
r | a range that satisfies the concept std::ranges::range |
|
inlineprivate |
This function is meant to be called by another function of the AbstractGrid. Checks if the current iterated value is inside a sphere