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

#include <SaitoSquaredDistanceTransform.h>

Inheritance diagram for cloudViewer::SaitoSquaredDistanceTransform:
Collaboration diagram for cloudViewer::SaitoSquaredDistanceTransform:

Public Member Functions

 SaitoSquaredDistanceTransform ()=default
 Default constructor. More...
 
bool initGrid (const Tuple3ui &gridSize)
 Initializes the grid. More...
 
bool initDT (GenericIndexedMesh *mesh, PointCoordinateType cellLength, const CCVector3 &gridMinCorner, GenericProgressCallback *progressCb=nullptr)
 Initializes the distance transform with a mesh. More...
 
bool initDT (GenericCloud *cloud, PointCoordinateType cellLength, const CCVector3 &gridMinCorner, GenericProgressCallback *progressCb=nullptr)
 Initializes the distance transform with a cloud. More...
 
bool propagateDistance (GenericProgressCallback *progressCb=nullptr)
 Computes the exact Squared Distance Transform on the whole grid. More...
 
- Public Member Functions inherited from cloudViewer::Grid3D< unsigned >
 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 Protected Member Functions

static bool EDT_1D (GridElement *slice, std::size_t r, std::size_t c)
 1D Euclidean Distance Transform More...
 
static bool SDT_2D (Grid3D< GridElement > &image, std::size_t sliceIndex, const std::vector< GridElement > &sq)
 2D Exact Squared Distance Transform More...
 
static bool SDT_3D (Grid3D< GridElement > &image, GenericProgressCallback *progressCb=nullptr)
 3D Exact Squared Distance Transform More...
 

Additional Inherited Members

- Public Types inherited from cloudViewer::Grid3D< unsigned >
using GridElement = unsigned
 Cell type. More...
 
using genericCellTriIntersectionAction = std::function< void(const Tuple3i &, unsigned)>
 
- Protected Member Functions inherited from cloudViewer::Grid3D< unsigned >
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 >
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 Squared Distance Field with the Saito algorithm on a 3D grid

Definition at line 25 of file SaitoSquaredDistanceTransform.h.

Constructor & Destructor Documentation

◆ SaitoSquaredDistanceTransform()

cloudViewer::SaitoSquaredDistanceTransform::SaitoSquaredDistanceTransform ( )
default

Default constructor.

Member Function Documentation

◆ EDT_1D()

bool SaitoSquaredDistanceTransform::EDT_1D ( GridElement slice,
std::size_t  r,
std::size_t  c 
)
staticprotected

1D Euclidean Distance Transform

Definition at line 19 of file SaitoSquaredDistanceTransform.cpp.

Referenced by SDT_2D().

◆ initDT() [1/2]

bool cloudViewer::SaitoSquaredDistanceTransform::initDT ( GenericCloud cloud,
PointCoordinateType  cellLength,
const CCVector3 gridMinCorner,
GenericProgressCallback progressCb = nullptr 
)
inline

Initializes the distance transform with a cloud.

Definition at line 50 of file SaitoSquaredDistanceTransform.h.

◆ initDT() [2/2]

bool cloudViewer::SaitoSquaredDistanceTransform::initDT ( GenericIndexedMesh mesh,
PointCoordinateType  cellLength,
const CCVector3 gridMinCorner,
GenericProgressCallback progressCb = nullptr 
)
inline

Initializes the distance transform with a mesh.

Definition at line 42 of file SaitoSquaredDistanceTransform.h.

◆ initGrid()

bool cloudViewer::SaitoSquaredDistanceTransform::initGrid ( const Tuple3ui gridSize)
inline

Initializes the grid.

The memory for the grid must be explicitelty reserved prior to any action.

Returns
true if the initialization succeeded

Definition at line 35 of file SaitoSquaredDistanceTransform.h.

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

Referenced by cloudViewer::DistanceComputationTools::computeApproxCloud2CloudDistance(), and cloudViewer::DistanceComputationTools::computeCloud2MeshDistances().

◆ propagateDistance()

bool cloudViewer::SaitoSquaredDistanceTransform::propagateDistance ( GenericProgressCallback progressCb = nullptr)
inline

Computes the exact Squared Distance Transform on the whole grid.

Propagates the distances on the whole grid.

Base on the implementation by R. Fabbri (which is itslef based on
two independent implementations by O. Cuisenaire and J. C. Torelli).

PAPER
T. Saito and J.I. Toriwaki, "New algorithms for Euclidean distance
transformations of an n-dimensional digitised picture with

applications", Pattern Recognition, 27(11), pp. 1551-1565, 1994

    \warning Output distances are squared

    \param progressCb progress callback (optional)
    \return success

Definition at line 73 of file SaitoSquaredDistanceTransform.h.

Referenced by cloudViewer::DistanceComputationTools::computeApproxCloud2CloudDistance(), and cloudViewer::DistanceComputationTools::computeCloud2MeshDistances().

◆ SDT_2D()

bool SaitoSquaredDistanceTransform::SDT_2D ( Grid3D< GridElement > &  image,
std::size_t  sliceIndex,
const std::vector< GridElement > &  sq 
)
staticprotected

2D Exact Squared Distance Transform

Definition at line 55 of file SaitoSquaredDistanceTransform.cpp.

References cloudViewer::Grid3D< Type >::data(), EDT_1D(), cloudViewer::Grid3D< Type >::size(), Tuple3Tpl< Type >::x, and Tuple3Tpl< Type >::y.

Referenced by SDT_3D().

◆ SDT_3D()


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