ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::Grid3D< Type > Class Template Reference

Simple 3D grid structure. More...

#include <Grid3D.h>

Inheritance diagram for cloudViewer::Grid3D< Type >:
Collaboration diagram for cloudViewer::Grid3D< Type >:

Classes

struct  CellToTest
 

Public Types

using GridElement = Type
 Cell type. More...
 
using genericCellTriIntersectionAction = std::function< void(const Tuple3i &, unsigned)>
 

Public Member Functions

 Grid3D ()
 Default constructor. More...
 
const Tuple3uisize () const
 Returns the grid dimensions. More...
 
bool isInitialized () const
 Returns whether the grid has been initialized or not. More...
 
void clear ()
 Clears the grid. More...
 
bool init (unsigned di, unsigned dj, unsigned dk, unsigned margin, GridElement defaultCellValue=0)
 Initializes the grid. More...
 
Tuple3i computeCellPos (const CCVector3 &P, const CCVector3 &gridMinCorner, PointCoordinateType cellSize) const
 Computes the (grid) cell position that contains a given point. More...
 
bool intersectWith (GenericIndexedMesh *mesh, PointCoordinateType cellLength, const CCVector3 &gridMinCorner, GridElement intersectValue=0, GenericProgressCallback *progressCb=nullptr)
 Intersects this grid with a mesh. More...
 
bool intersectWith (GenericIndexedMesh *mesh, PointCoordinateType cellLength, const CCVector3 &gridMinCorner, genericCellTriIntersectionAction action, GenericProgressCallback *progressCb=nullptr)
 Intersects this grid with a mesh (generic form) More...
 
bool intersectWith (GenericCloud *cloud, PointCoordinateType cellLength, const CCVector3 &gridMinCorner, GridElement intersectValue=0, GenericProgressCallback *progressCb=nullptr)
 Intersects this grid with a cloud. More...
 
void setValue (int i, int j, int k, GridElement value)
 Sets the value of a given cell. More...
 
void setValue (const Tuple3i &cellPos, GridElement value)
 Sets the value of a given cell. More...
 
const GridElementgetValue (int i, int j, int k) const
 Returns the value of a given cell (const version) More...
 
GridElementgetValue (int i, int j, int k)
 Returns the value of a given cell. More...
 
const GridElementgetValue (Tuple3i &cellPos) const
 Returns the value of a given cell const version) More...
 
GridElementgetValue (Tuple3i &cellPos)
 Returns the value of a given cell. More...
 
GridElementdata ()
 Gives access to the internal grid data (with margin) More...
 
const GridElementdata () const
 Gives access to the internal grid data (with margin) (const version) More...
 
uint64_t innerCellCount () const
 Returns the number of cell count (whithout margin) More...
 
uint64_t totalCellCount () const
 Returns the total number of cell count (with margin) More...
 

Protected Member Functions

int64_t pos2index (int i, int j, int k) const
 Converts a 3D position to an absolute index. More...
 

Protected Attributes

std::vector< GridElementm_grid
 Grid data. More...
 
Tuple3ui m_innerSize
 Dimensions of the grid (without margin) More...
 
int64_t m_margin
 Margin. More...
 
int64_t m_rowSize
 1D row size (with margin) More...
 
int64_t m_sliceSize
 2D slice size (with margin) More...
 
uint64_t m_innerCellCount
 3D grid size without margin More...
 
uint64_t m_totalCellCount
 3D grid size with margin More...
 
int64_t m_marginShift
 First index of real data (i.e. after marin) More...
 

Detailed Description

template<class Type>
class cloudViewer::Grid3D< Type >

Simple 3D grid structure.

The grid data is contiguous in memory.

Definition at line 32 of file Grid3D.h.

Member Typedef Documentation

◆ genericCellTriIntersectionAction

template<class Type >
using cloudViewer::Grid3D< Type >::genericCellTriIntersectionAction = std::function<void(const Tuple3i&, unsigned)>

Generic function applied to a cell intersected by a triangle (used by the generic form of intersectWith)

Definition at line 151 of file Grid3D.h.

◆ GridElement

template<class Type >
using cloudViewer::Grid3D< Type >::GridElement = Type

Cell type.

Definition at line 35 of file Grid3D.h.

Constructor & Destructor Documentation

◆ Grid3D()

template<class Type >
cloudViewer::Grid3D< Type >::Grid3D ( )
inline

Default constructor.

Definition at line 38 of file Grid3D.h.

Member Function Documentation

◆ clear()

◆ computeCellPos()

template<class Type >
Tuple3i cloudViewer::Grid3D< Type >::computeCellPos ( const CCVector3 P,
const CCVector3 gridMinCorner,
PointCoordinateType  cellSize 
) const
inline

Computes the (grid) cell position that contains a given point.

Definition at line 111 of file Grid3D.h.

References Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.

Referenced by cloudViewer::Grid3D< Type >::intersectWith().

◆ data() [1/2]

template<class Type >
GridElement* cloudViewer::Grid3D< Type >::data ( )
inline

Gives access to the internal grid data (with margin)

Definition at line 527 of file Grid3D.h.

References cloudViewer::Grid3D< Type >::m_grid.

Referenced by cloudViewer::SaitoSquaredDistanceTransform::SDT_2D(), and cloudViewer::SaitoSquaredDistanceTransform::SDT_3D().

◆ data() [2/2]

template<class Type >
const GridElement* cloudViewer::Grid3D< Type >::data ( ) const
inline

Gives access to the internal grid data (with margin) (const version)

Definition at line 529 of file Grid3D.h.

References cloudViewer::Grid3D< Type >::m_grid.

◆ getValue() [1/4]

template<class Type >
GridElement& cloudViewer::Grid3D< Type >::getValue ( int  i,
int  j,
int  k 
)
inline

Returns the value of a given cell.

Parameters
ithe cell coordinate along the X dimension
jthe cell coordinate along the Y dimension
kthe cell coordinate along the Z dimension
Returns
the cell value

Definition at line 507 of file Grid3D.h.

References cloudViewer::Grid3D< Type >::m_grid, and cloudViewer::Grid3D< Type >::pos2index().

◆ getValue() [2/4]

template<class Type >
const GridElement& cloudViewer::Grid3D< Type >::getValue ( int  i,
int  j,
int  k 
) const
inline

Returns the value of a given cell (const version)

Parameters
ithe cell coordinate along the X dimension
jthe cell coordinate along the Y dimension
kthe cell coordinate along the Z dimension
Returns
the cell value

Definition at line 498 of file Grid3D.h.

References cloudViewer::Grid3D< Type >::m_grid, and cloudViewer::Grid3D< Type >::pos2index().

Referenced by cloudViewer::DistanceComputationTools::computeApproxCloud2CloudDistance(), cloudViewer::DistanceComputationTools::computeCloud2MeshDistancesWithOctree(), and cloudViewer::DistanceComputationTools::computeCloud2MeshDistanceWithOctree().

◆ getValue() [3/4]

template<class Type >
GridElement& cloudViewer::Grid3D< Type >::getValue ( Tuple3i cellPos)
inline

Returns the value of a given cell.

Parameters
cellPosthe cell position
Returns
the cell value

Definition at line 522 of file Grid3D.h.

References cloudViewer::Grid3D< Type >::m_grid, cloudViewer::Grid3D< Type >::pos2index(), Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.

◆ getValue() [4/4]

template<class Type >
const GridElement& cloudViewer::Grid3D< Type >::getValue ( Tuple3i cellPos) const
inline

Returns the value of a given cell const version)

Parameters
cellPosthe cell position
Returns
the cell value

Definition at line 515 of file Grid3D.h.

References cloudViewer::Grid3D< Type >::m_grid, cloudViewer::Grid3D< Type >::pos2index(), Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.

◆ init()

template<class Type >
bool cloudViewer::Grid3D< Type >::init ( unsigned  di,
unsigned  dj,
unsigned  dk,
unsigned  margin,
GridElement  defaultCellValue = 0 
)
inline

Initializes the grid.

The grid must be explicitelty initialized prior to any action.

Parameters
digrid size along the X dimension
djgrid size along the Y dimension
dkgrid size along the Z dimension
margingrid margin
defaultCellValuedefault cell value
Returns
true if the initialization succeeded

Definition at line 77 of file Grid3D.h.

References cloudViewer::Grid3D< Type >::m_grid, cloudViewer::Grid3D< Type >::m_innerCellCount, cloudViewer::Grid3D< Type >::m_innerSize, cloudViewer::Grid3D< Type >::m_margin, cloudViewer::Grid3D< Type >::m_marginShift, cloudViewer::Grid3D< Type >::m_rowSize, cloudViewer::Grid3D< Type >::m_sliceSize, cloudViewer::Grid3D< Type >::m_totalCellCount, Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.

Referenced by cloudViewer::ChamferDistanceTransform::init(), and cloudViewer::SaitoSquaredDistanceTransform::initGrid().

◆ innerCellCount()

template<class Type >
uint64_t cloudViewer::Grid3D< Type >::innerCellCount ( ) const
inline

Returns the number of cell count (whithout margin)

Definition at line 532 of file Grid3D.h.

References cloudViewer::Grid3D< Type >::m_innerCellCount.

◆ intersectWith() [1/3]

◆ intersectWith() [2/3]

◆ intersectWith() [3/3]

template<class Type >
bool cloudViewer::Grid3D< Type >::intersectWith ( GenericIndexedMesh mesh,
PointCoordinateType  cellLength,
const CCVector3 gridMinCorner,
GridElement  intersectValue = 0,
GenericProgressCallback progressCb = nullptr 
)
inline

Intersects this grid with a mesh.

Definition at line 135 of file Grid3D.h.

References cloudViewer::Grid3D< Type >::setValue().

◆ isInitialized()

template<class Type >
bool cloudViewer::Grid3D< Type >::isInitialized ( ) const
inline

Returns whether the grid has been initialized or not.

Definition at line 51 of file Grid3D.h.

References cloudViewer::Grid3D< Type >::m_totalCellCount.

Referenced by cloudViewer::Grid3D< Type >::intersectWith().

◆ pos2index()

template<class Type >
int64_t cloudViewer::Grid3D< Type >::pos2index ( int  i,
int  j,
int  k 
) const
inlineprotected

◆ setValue() [1/2]

template<class Type >
void cloudViewer::Grid3D< Type >::setValue ( const Tuple3i cellPos,
GridElement  value 
)
inline

Sets the value of a given cell.

Parameters
cellPosthe cell position
valuenew cell value

Definition at line 488 of file Grid3D.h.

References cloudViewer::Grid3D< Type >::m_grid, cloudViewer::Grid3D< Type >::pos2index(), Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.

◆ setValue() [2/2]

template<class Type >
void cloudViewer::Grid3D< Type >::setValue ( int  i,
int  j,
int  k,
GridElement  value 
)
inline

Sets the value of a given cell.

Parameters
ithe cell coordinate along the X dimension
jthe cell coordinate along the Y dimension
kthe cell coordinate along the Z dimension
valuenew cell value

Definition at line 480 of file Grid3D.h.

References cloudViewer::Grid3D< Type >::m_grid, and cloudViewer::Grid3D< Type >::pos2index().

Referenced by cloudViewer::DistanceComputationTools::computeApproxCloud2CloudDistance(), cloudViewer::DistanceComputationTools::intersectMeshWithOctree(), and cloudViewer::Grid3D< Type >::intersectWith().

◆ size()

template<class Type >
const Tuple3ui& cloudViewer::Grid3D< Type >::size ( ) const
inline

◆ totalCellCount()

template<class Type >
uint64_t cloudViewer::Grid3D< Type >::totalCellCount ( ) const
inline

Returns the total number of cell count (with margin)

Definition at line 534 of file Grid3D.h.

References cloudViewer::Grid3D< Type >::m_totalCellCount.

Member Data Documentation

◆ m_grid

◆ m_innerCellCount

template<class Type >
uint64_t cloudViewer::Grid3D< Type >::m_innerCellCount
protected

◆ m_innerSize

template<class Type >
Tuple3ui cloudViewer::Grid3D< Type >::m_innerSize
protected

Dimensions of the grid (without margin)

Definition at line 547 of file Grid3D.h.

Referenced by cloudViewer::Grid3D< Type >::clear(), cloudViewer::Grid3D< Type >::init(), and cloudViewer::Grid3D< Type >::size().

◆ m_margin

template<class Type >
int64_t cloudViewer::Grid3D< Type >::m_margin
protected

Margin.

Definition at line 549 of file Grid3D.h.

Referenced by cloudViewer::Grid3D< Type >::clear(), and cloudViewer::Grid3D< Type >::init().

◆ m_marginShift

template<class Type >
int64_t cloudViewer::Grid3D< Type >::m_marginShift
protected

First index of real data (i.e. after marin)

Definition at line 559 of file Grid3D.h.

Referenced by cloudViewer::Grid3D< Type >::clear(), cloudViewer::Grid3D< Type >::init(), and cloudViewer::Grid3D< Type >::pos2index().

◆ m_rowSize

template<class Type >
int64_t cloudViewer::Grid3D< Type >::m_rowSize
protected

◆ m_sliceSize

template<class Type >
int64_t cloudViewer::Grid3D< Type >::m_sliceSize
protected

2D slice size (with margin)

Definition at line 553 of file Grid3D.h.

Referenced by cloudViewer::Grid3D< Type >::clear(), cloudViewer::Grid3D< Type >::init(), and cloudViewer::Grid3D< Type >::pos2index().

◆ m_totalCellCount

template<class Type >
uint64_t cloudViewer::Grid3D< Type >::m_totalCellCount
protected

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