ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::ChamferDistanceTransform Class Reference

Class to compute a Chamfer distance field on a 3D grid. More...

#include <ChamferDistanceTransform.h>

Inheritance diagram for cloudViewer::ChamferDistanceTransform:
Collaboration diagram for cloudViewer::ChamferDistanceTransform:

Public Member Functions

bool init (const Tuple3ui &gridSize)
 Initializes the grid. More...
 
int propagateDistance (CHAMFER_DISTANCE_TYPE type, GenericProgressCallback *progressCb=nullptr)
 Computes the Chamfer distance on the whole grid. More...
 
- Public Member Functions inherited from cloudViewer::Grid3D< unsigned short >
 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...
 

Static Public Attributes

static const unsigned short MAX_DIST = 0xFAFA
 Max possible 'distance'. More...
 

Additional Inherited Members

- Public Types inherited from cloudViewer::Grid3D< unsigned short >
using GridElement = unsigned short
 Cell type. More...
 
using genericCellTriIntersectionAction = std::function< void(const Tuple3i &, unsigned)>
 
- Protected Member Functions inherited from cloudViewer::Grid3D< unsigned short >
int64_t pos2index (int i, int j, int k) const
 Converts a 3D position to an absolute index. More...
 
- Protected Attributes inherited from cloudViewer::Grid3D< unsigned short >
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

Class to compute a Chamfer distance field on a 3D grid.

Internally we use 'unsigned short' value to limit memory consumption. For computational reasons, the max computable 'distance' is 0xFAFA = 64250.

Definition at line 24 of file ChamferDistanceTransform.h.

Member Function Documentation

◆ init()

bool cloudViewer::ChamferDistanceTransform::init ( const Tuple3ui gridSize)
inline

Initializes the grid.

'Zero' cells must be initialized with setValue(0). The grid must be explicitelty initialized prior to any action.

Returns
true if the initialization succeeded

Definition at line 37 of file ChamferDistanceTransform.h.

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

Referenced by define_ChamferDistanceTransform().

◆ propagateDistance()

int ChamferDistanceTransform::propagateDistance ( CHAMFER_DISTANCE_TYPE  type,
GenericProgressCallback progressCb = nullptr 
)

Computes the Chamfer distance on the whole grid.

Propagates the distances on the whole grid. The 'zeros' should have already been initialized before calling this method (see ChamferDistanceTransform::setZero).

Parameters
typethe Chamfer distance type
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
Returns
max distance (or -1 if an error occurred)

Definition at line 112 of file ChamferDistanceTransform.cpp.

References BackwardNeighbours111, BackwardNeighbours345, CHAMFER_111, CHAMFER_345, ForwardNeighbours111, ForwardNeighbours345, cloudViewer::Grid3D< unsigned short >::m_grid, cloudViewer::Grid3D< unsigned short >::m_innerSize, cloudViewer::Grid3D< unsigned short >::m_rowSize, cloudViewer::Grid3D< unsigned short >::m_sliceSize, min(), cloudViewer::NormalizedProgress::oneStep(), cloudViewer::Grid3D< unsigned short >::pos2index(), cloudViewer::GenericProgressCallback::setInfo(), cloudViewer::GenericProgressCallback::setMethodTitle(), cloudViewer::GenericProgressCallback::start(), cloudViewer::GenericProgressCallback::textCanBeEdited(), type, cloudViewer::GenericProgressCallback::update(), Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.

Referenced by define_ChamferDistanceTransform().

Member Data Documentation

◆ MAX_DIST

const unsigned short cloudViewer::ChamferDistanceTransform::MAX_DIST = 0xFAFA
static

Max possible 'distance'.

Warning
Never pass a 'constant initializer' by reference

Definition at line 30 of file ChamferDistanceTransform.h.

Referenced by define_ChamferDistanceTransform().


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