CCCoreLib 31 May 2022
CloudCompare Core algorithms
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CCCoreLib::Grid3D< Type > Class Template Reference

Simple 3D grid structure. More...

#include <Grid3D.h>

Collaboration diagram for CCCoreLib::Grid3D< Type >:
Collaboration graph
[legend]

Classes

struct  CellToTest
 

Public Types

using GridElement = Type
 Cell type.
 
using genericCellTriIntersectionAction = std::function< void(const Tuple3i &, unsigned)>
 Generic function applied to a cell intersected by a triangle (used by the generic form of intersectWith)
 

Public Member Functions

 Grid3D ()
 Default constructor.
 
const Tuple3uisize () const
 Returns the grid dimensions.
 
bool isInitialized () const
 Returns whether the grid has been initialized or not.
 
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.
 
bool intersectWith (GenericIndexedMesh *mesh, PointCoordinateType cellLength, const CCVector3 &gridMinCorner, GridElement intersectValue=0, GenericProgressCallback *progressCb=nullptr)
 Intersects this grid with a mesh.
 
bool intersectWith (GenericIndexedMesh *mesh, PointCoordinateType cellLength, const CCVector3 &gridMinCorner, genericCellTriIntersectionAction action, GenericProgressCallback *progressCb=nullptr)
 Intersects this grid with a mesh (generic form)
 
bool intersectWith (GenericCloud *cloud, PointCoordinateType cellLength, const CCVector3 &gridMinCorner, GridElement intersectValue=0, GenericProgressCallback *progressCb=nullptr)
 Intersects this grid with a cloud.
 
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 (const Tuple3i &cellPos) const
 Returns the value of a given cell const version) More...
 
GridElementgetValue (const Tuple3i &cellPos)
 Returns the value of a given cell. More...
 
GridElementdata ()
 Gives access to the internal grid data (with margin)
 
const GridElementdata () const
 Gives access to the internal grid data (with margin) (const version)
 
unsigned innerCellCount () const
 Returns the number of cell count (whithout margin)
 
unsigned totalCellCount () const
 Returns the total number of cell count (with margin)
 

Protected Member Functions

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

Protected Attributes

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

Detailed Description

template<class Type>
class CCCoreLib::Grid3D< Type >

Simple 3D grid structure.

The grid data is contiguous in memory.

Member Function Documentation

◆ clear()

template<class Type >
void CCCoreLib::Grid3D< Type >::clear ( )
inline

Clears the grid.

Warning
If Type is a pointer type, memory should be released first

◆ getValue() [1/4]

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

Returns the value of a given cell.

Parameters
cellPosthe cell position
Returns
the cell value

◆ getValue() [2/4]

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

Returns the value of a given cell const version)

Parameters
cellPosthe cell position
Returns
the cell value

◆ getValue() [3/4]

template<class Type >
GridElement & CCCoreLib::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

◆ getValue() [4/4]

template<class Type >
const GridElement & CCCoreLib::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

◆ init()

template<class Type >
bool CCCoreLib::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

◆ setValue() [1/2]

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

Sets the value of a given cell.

Parameters
cellPosthe cell position
valuenew cell value

◆ setValue() [2/2]

template<class Type >
void CCCoreLib::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

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