Parasol Planning Library (PPL)
GridOverlay Class Reference

#include <GridOverlay.h>

Public Types

Local Types
enum class  CellSet : unsigned char { Boundary = 1 , Interior = 2 , Closure = 3 }
 The types of cell sets for use with LocateCells. More...
 
typedef std::vector< std::vector< const WorkspaceRegion * > > DecompositionMap
 A mapping from a grid cell index to a set of workspace regions. More...
 
typedef std::array< size_t, 3 > IndexSet
 A set of X, Y, Z indexes for a grid cell. More...
 

Public Member Functions

Construction
 GridOverlay (const Boundary *const _b, const double _length)
 
 ~GridOverlay () noexcept
 
Cell Finders
size_t Size () const noexcept
 Get the number of cells in the grid. More...
 
size_t Size (const size_t _i) const noexcept
 
size_t LocateCell (const Cfg &_cfg) const
 
size_t LocateCell (const Point3d &_p) const
 
std::unordered_set< size_t > LocateCells (const Boundary *const _b, const CellSet _type=CellSet::Closure) const
 
std::unordered_set< size_t > LocateCells (const GMSPolyhedron &_polyhedron, const mathtool::Transformation &_transformation={}, const CellSet _type=CellSet::Closure) const
 
std::unordered_set< size_t > LocateBBXCells (const Boundary *const _b) const
 
std::unordered_set< size_t > LocateBBXCells (const Point3d &_min, const Point3d &_max) const
 
std::unordered_set< size_t > LocateFacetNeighbors (const size_t _index) const
 
std::unordered_set< size_t > LocateEdgeNeighbors (const size_t _index) const
 
std::unordered_set< size_t > LocateVertexNeighbors (const size_t _index) const
 
std::unordered_set< size_t > LocateAllNeighbors (const size_t _index) const
 
Cell Properties
double CellLength () const noexcept
 Get the length of the grid cells. More...
 
Point3d CellCenter (const size_t _index) const noexcept
 
Decomposition Mapping
DecompositionMap ComputeDecompositionMap (const WorkspaceDecomposition *const _decomposition, const bool _useCollisionDetection=false) const
 
Testing
void Test (const size_t _trials=0) const
 

Detailed Description

A 3d grid overlay of a given boundary.

The cells are implicitly represented as either a tuple (x,y,z) or a single 'cell index', which enumerates all cells with a single number. The grid is defined over the minimum and maximum ranges of the boundary, so there may be grid cells partially or completely outside of the boundary (depending its shape and size).

Todo:
Generalize to support 2d grids as well as 3d.

Member Typedef Documentation

◆ DecompositionMap

typedef std::vector<std::vector<const WorkspaceRegion*> > GridOverlay::DecompositionMap

A mapping from a grid cell index to a set of workspace regions.

◆ IndexSet

typedef std::array<size_t, 3> GridOverlay::IndexSet

A set of X, Y, Z indexes for a grid cell.

Member Enumeration Documentation

◆ CellSet

enum GridOverlay::CellSet : unsigned char
strong

The types of cell sets for use with LocateCells.

Enumerator
Boundary 
Interior 
Closure 

Constructor & Destructor Documentation

◆ GridOverlay()

GridOverlay::GridOverlay ( const Boundary *const  _b,
const double  _length 
)

Construct a grid overlay with cells of a given length.

Parameters
_bThe boundary to overlay.
_lengthThe cell length to use.

◆ ~GridOverlay()

GridOverlay::~GridOverlay ( )
defaultnoexcept

Member Function Documentation

◆ CellCenter()

Point3d GridOverlay::CellCenter ( const size_t  _index) const
noexcept

Get the center of a cell.

Parameters
_indexThe cell index.
Returns
The center of cell _index.

◆ CellLength()

double GridOverlay::CellLength ( ) const
noexcept

Get the length of the grid cells.

◆ ComputeDecompositionMap()

GridOverlay::DecompositionMap GridOverlay::ComputeDecompositionMap ( const WorkspaceDecomposition *const  _decomposition,
const bool  _useCollisionDetection = false 
) const

Create a map from grid cell index to the set of decomposition regions which are near to or touch the grid cell.

Parameters
_decompositionThe workspace decomposition object to map.
_useCollisionDetectionUse PQP collision detection to refine the test?
Returns
A mapping m, where m[i] gives a set of _decomposition regions. If not using PQP then the regions are those whos BBX touches grid cell i, otherwise the regions actually touch cell i.

◆ LocateAllNeighbors()

std::unordered_set< size_t > GridOverlay::LocateAllNeighbors ( const size_t  _index) const

Locate all neighbors of a cell.

Parameters
_indexThe cell index.
Returns
The neighbor cell indexes.

◆ LocateBBXCells() [1/2]

std::unordered_set< size_t > GridOverlay::LocateBBXCells ( const Boundary *const  _b) const

Find the cells that contain a given boundary's bounding box.

Parameters
_bThe boundary of interest.
Returns
A set of cell indexes that contain _b's bounding box.

◆ LocateBBXCells() [2/2]

std::unordered_set< size_t > GridOverlay::LocateBBXCells ( const Point3d &  _min,
const Point3d &  _max 
) const

Find the cells that contain a bounding box around two points.

Parameters
_minThe low-range values.
_maxThe high-range values.
Returns
A set of cell indexes that contain the bounding box around _min, _max.

◆ LocateCell() [1/2]

size_t GridOverlay::LocateCell ( const Cfg _cfg) const

Find the cell that contains the reference point of a configuration.

Parameters
_cfgThe configuration to locate.
Returns
The index of the cell which contains _cfg's translational DOFs.

◆ LocateCell() [2/2]

size_t GridOverlay::LocateCell ( const Point3d &  _p) const

Find the cell that contains a reference point.

Parameters
_pThe point to locate.
Returns
The index of the cell which contains _p.

◆ LocateCells() [1/2]

std::unordered_set< size_t > GridOverlay::LocateCells ( const Boundary *const  _b,
const CellSet  _type = CellSet::Closure 
) const

Find the cells that touch a given boundary.

Parameters
_bThe boundary of interest.
_typeThe type of cell set to include.
Returns
A set of cell indexes that touch _b as described by _type.

◆ LocateCells() [2/2]

std::unordered_set< size_t > GridOverlay::LocateCells ( const GMSPolyhedron _polyhedron,
const mathtool::Transformation &  _transformation = {},
const CellSet  _type = CellSet::Closure 
) const

Find the cells that touch a given polyhedron.

Parameters
_polyhedronThe polyhedron of interest.
_transformationThe transformation for _polyhedron.
_typeThe type of cell set to include.
Returns
A set of cell indexes that touch _polyhedron as described by _type.
Todo:
Can make the !_interior version more efficient by computing bbx cells for each facet.
Todo:
Can make both versions more efficient by avoiding re-building the _polyhedron's BBX each time. Add min/max pts and transform them with the poly, use here.

◆ LocateEdgeNeighbors()

std::unordered_set< size_t > GridOverlay::LocateEdgeNeighbors ( const size_t  _index) const

Locate the neighbors of a cell which share an edge but not a facet.

Parameters
_indexThe cell index.
Returns
The neighbor cell indexes.

◆ LocateFacetNeighbors()

std::unordered_set< size_t > GridOverlay::LocateFacetNeighbors ( const size_t  _index) const

Locate the neighbors of a cell which share a facet.

Parameters
_indexThe cell index.
Returns
The neighbor cell indexes.

◆ LocateVertexNeighbors()

std::unordered_set< size_t > GridOverlay::LocateVertexNeighbors ( const size_t  _index) const

Locate the neighbors of a cell which share a vertex but not an edge or facet.

Parameters
_indexThe cell index.
Returns
The neighbor cell indexes.

◆ Size() [1/2]

size_t GridOverlay::Size ( ) const
noexcept

Get the number of cells in the grid.

◆ Size() [2/2]

size_t GridOverlay::Size ( const size_t  _i) const
noexcept

Get the number of cells in a given dimension.

Parameters
_iThe index for the dimension of interest.
Returns
The number of cells in dimension _i.

◆ Test()

void GridOverlay::Test ( const size_t  _trials = 0) const

Test this object.

Parameters
_trialsSample this number of grid cells to test. Or, use zero to test all cells.
Exceptions
Ifthe test fails.

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