![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
Fast Marching algorithm (front propagation) More...
#include <FastMarching.h>
Classes | |
| class | Cell |
| A generic Fast Marching grid cell. More... | |
Public Member Functions | |
| FastMarching () | |
| Default constructor. More... | |
| virtual | ~FastMarching () |
| Destructor. More... | |
| virtual bool | setSeedCell (const Tuple3i &pos) |
| Sets a given cell as "seed". More... | |
| virtual int | propagate ()=0 |
| Propagates the front. More... | |
| virtual void | cleanLastPropagation () |
| virtual float | getTime (Tuple3i &pos, bool absoluteCoordinates=false) const |
| Returns the front arrival time at a given cell. More... | |
| virtual void | setExtendedConnectivity (bool state) |
| Sets extended connectivity mode. More... | |
Protected Member Functions | |
| unsigned | pos2index (const Tuple3i &pos) const |
| virtual int | initGridWithOctree (DgmOctree *octree, unsigned char gridLevel) |
| virtual int | initGrid (float step, unsigned dim[3]) |
| Intializes the grid with a given step and dimensions. More... | |
| virtual int | initOther () |
| virtual float | computeT (unsigned index) |
| Computes the front arrival time at a given cell. More... | |
| virtual float | computeTCoefApprox (Cell *currentCell, Cell *neighbourCell) const =0 |
| Computes the front acceleration between two cells. More... | |
| virtual int | step ()=0 |
| Propagates the front (one step) More... | |
| virtual void | initTrialCells () |
| Initializes the TRIAL cells list. More... | |
| virtual bool | instantiateGrid (unsigned size)=0 |
| Instantiates grid in memory. More... | |
| template<class T > | |
| bool | instantiateGridTpl (unsigned size) |
| Grid instantiation helper. More... | |
| virtual void | addTrialCell (unsigned index) |
| Add a cell to the TRIAL cells list. More... | |
| virtual void | addActiveCell (unsigned index) |
| Add a cell to the ACTIVE cells list. More... | |
| virtual void | addIgnoredCell (unsigned index) |
| Add a cell to the IGNORED cells list. More... | |
| virtual unsigned | getNearestTrialCell () |
| Returns the TRIAL cell with the smallest front arrival time. More... | |
| void | resetCells (std::vector< unsigned > &list) |
| Resets the state of cells in a given list. More... | |
Protected Attributes | |
| std::vector< unsigned > | m_activeCells |
| ACTIVE cells list. More... | |
| std::vector< unsigned > | m_trialCells |
| TRIAL cells list. More... | |
| std::vector< unsigned > | m_ignoredCells |
| IGNORED cells lits. More... | |
| bool | m_initialized |
| Specifiies whether structure is initialized or not. More... | |
| unsigned | m_dx |
| Grid size along the X dimension. More... | |
| unsigned | m_dy |
| Grid size along the Y dimension. More... | |
| unsigned | m_dz |
| Grid size along the Z dimension. More... | |
| unsigned | m_rowSize |
| Shift for cell access acceleration (Y dimension) More... | |
| unsigned | m_sliceSize |
| Shift for cell access acceleration (Z dimension) More... | |
| unsigned | m_indexShift |
| First index of innerbound grid. More... | |
| unsigned | m_gridSize |
| Grid size. More... | |
| Cell ** | m_theGrid |
| Grid used to process Fast Marching. More... | |
| DgmOctree * | m_octree |
| Associated octree. More... | |
| unsigned char | m_gridLevel |
| Equivalent octree subdivision level. More... | |
| float | m_cellSize |
| Octree cell size at equivalent subdivision level. More... | |
| Tuple3i | m_minFillIndexes |
| Octree min fill indexes at 'm_gridLevel'. More... | |
| unsigned | m_numberOfNeighbours |
| Current number of neighbours (6 or 26) More... | |
| int | m_neighboursIndexShift [26] |
| Neighbours coordinates shifts in grid. More... | |
| float | m_neighboursDistance [26] |
| Neighbours distance weight. More... | |
Fast Marching algorithm (front propagation)
Implementation of the Fast Marching algorithm [Sethian 1996]. Inspired from the "vtkFastMarching" class of the "Slicer" project (http://www.slicer.org).
| FastMarching::FastMarching | ( | ) |
Default constructor.
References CC_FM_MAX_NUMBER_OF_NEIGHBOURS, m_neighboursDistance, and m_neighboursIndexShift.
|
virtual |
Destructor.
References m_gridSize, and m_theGrid.
|
protectedvirtual |
Add a cell to the ACTIVE cells list.
| index | index of the cell |
References cloudViewer::FastMarching::Cell::ACTIVE_CELL, m_activeCells, m_theGrid, and cloudViewer::FastMarching::Cell::state.
Referenced by cloudViewer::FastMarchingForPropagation::findPeaks(), setSeedCell(), ccFastMarchingForNormsDirection::step(), cloudViewer::FastMarchingForPropagation::step(), and FastMarchingForFacetExtraction::step().
|
protectedvirtual |
Add a cell to the IGNORED cells list.
| index | index of the cell |
References cloudViewer::FastMarching::Cell::EMPTY_CELL, m_ignoredCells, m_theGrid, and cloudViewer::FastMarching::Cell::state.
Referenced by ccFastMarchingForNormsDirection::step(), cloudViewer::FastMarchingForPropagation::step(), and FastMarchingForFacetExtraction::step().
|
protectedvirtual |
Add a cell to the TRIAL cells list.
| index | index of the cell |
References m_theGrid, m_trialCells, cloudViewer::FastMarching::Cell::state, and cloudViewer::FastMarching::Cell::TRIAL_CELL.
Referenced by ccFastMarchingForNormsDirection::initTrialCells(), FastMarchingForFacetExtraction::initTrialCells(), initTrialCells(), ccFastMarchingForNormsDirection::step(), cloudViewer::FastMarchingForPropagation::step(), and FastMarchingForFacetExtraction::step().
|
virtual |
Finalizes an iteration process Resets the different lists and the grid. This method should be called after each propagation (before starting a new one).
References m_activeCells, m_ignoredCells, m_trialCells, and resetCells().
Referenced by define_FastMarching(), FastMarchingForFacetExtraction::ExtractPlanarFacets(), cloudViewer::AutoSegmentationTools::frontPropagationBasedSegmentation(), and ccFastMarchingForNormsDirection::OrientNormals().
|
protectedvirtual |
Computes the front arrival time at a given cell.
the cell is represented by its index in the cell list
| index | the cell index |
References cloudViewer::FastMarching::Cell::ACTIVE_CELL, cloudViewer::c_FastMarchingNeighbourPosShift, CC_FM_MAX_NUMBER_OF_NEIGHBOURS, computeTCoefApprox(), m_neighboursDistance, m_neighboursIndexShift, m_numberOfNeighbours, m_theGrid, cloudViewer::FastMarching::Cell::state, cloudViewer::FastMarching::Cell::T, cloudViewer::FastMarching::Cell::T_INF(), and cloudViewer::FastMarching::Cell::TRIAL_CELL.
Referenced by ccFastMarchingForNormsDirection::step(), cloudViewer::FastMarchingForPropagation::step(), and FastMarchingForFacetExtraction::step().
|
protectedpure virtual |
Computes the front acceleration between two cells.
| currentCell | the "central" cell |
| neighbourCell | the other cell |
Implemented in FastMarchingForFacetExtraction, ccFastMarchingForNormsDirection, and cloudViewer::FastMarchingForPropagation.
Referenced by computeT(), and initTrialCells().
|
protectedvirtual |
Returns the TRIAL cell with the smallest front arrival time.
References m_theGrid, m_trialCells, and cloudViewer::FastMarching::Cell::T.
Referenced by ccFastMarchingForNormsDirection::step(), cloudViewer::FastMarchingForPropagation::step(), and FastMarchingForFacetExtraction::step().
Returns the front arrival time at a given cell.
This method should only be called after the propagation succeeded. The coordinates of the cell can be absolute (i.e. expressed relatively to the octree borders) or relative (i.e. expressed relatively to the Fast Marching grid).
| pos | the cell position (3 integer coordinates) |
| absoluteCoordinates | whether the cell coordinates are absolute or relative |
References m_rowSize, m_sliceSize, m_theGrid, pos2index(), cloudViewer::FastMarching::Cell::T, Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.
Referenced by define_FastMarching().
|
protectedvirtual |
Intializes the grid with a given step and dimensions.
| step | grid step |
| dim | grid dimensions in 3D |
References initOther(), m_cellSize, m_dx, m_dy, m_dz, m_gridLevel, m_minFillIndexes, m_octree, and step().
|
protectedvirtual |
Intializes the grid as a snapshot of an octree structure at a given subdivision level
| octree | input octree |
| gridLevel | subdivision level |
References cloudViewer::DgmOctree::getCellSize(), cloudViewer::DgmOctree::getMaxFillIndexes(), cloudViewer::DgmOctree::getMinFillIndexes(), initOther(), m_cellSize, m_dx, m_dy, m_dz, m_gridLevel, m_minFillIndexes, m_octree, cloudViewer::DgmOctree::MAX_OCTREE_LEVEL, octree, Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.
Referenced by cloudViewer::FastMarchingForPropagation::init(), ccFastMarchingForNormsDirection::init(), and FastMarchingForFacetExtraction::init().
|
protectedvirtual |
Intializes other dimension-related variables and finishes the initialization job
References cloudViewer::c_FastMarchingNeighbourPosShift, CC_FM_MAX_NUMBER_OF_NEIGHBOURS, instantiateGrid(), m_activeCells, m_cellSize, m_dx, m_dy, m_dz, m_gridSize, m_ignoredCells, m_indexShift, m_neighboursDistance, m_neighboursIndexShift, m_rowSize, m_sliceSize, and m_trialCells.
Referenced by initGrid(), and initGridWithOctree().
|
protectedvirtual |
Initializes the TRIAL cells list.
See the Fast Marching algorithm theory for more information
Reimplemented in FastMarchingForFacetExtraction, and ccFastMarchingForNormsDirection.
References addTrialCell(), computeTCoefApprox(), cloudViewer::FastMarching::Cell::FAR_CELL, m_activeCells, m_neighboursDistance, m_neighboursIndexShift, m_numberOfNeighbours, m_theGrid, cloudViewer::FastMarching::Cell::state, and cloudViewer::FastMarching::Cell::T.
Referenced by cloudViewer::FastMarchingForPropagation::propagate().
|
protectedpure virtual |
Instantiates grid in memory.
Grid is also filled with zeros.
| size | grid size |
Implemented in FastMarchingForFacetExtraction, cloudViewer::FastMarchingForPropagation, and ccFastMarchingForNormsDirection.
Referenced by initOther().
|
inlineprotected |
Grid instantiation helper.
References size.
|
inlineprotected |
References Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.
Referenced by getTime(), cloudViewer::FastMarchingForPropagation::init(), ccFastMarchingForNormsDirection::init(), FastMarchingForFacetExtraction::init(), setSeedCell(), and FastMarchingForFacetExtraction::setSeedCell().
|
pure virtual |
Propagates the front.
The seeds should have already been initialized
Implemented in cloudViewer::FastMarchingForPropagation, FastMarchingForFacetExtraction, and ccFastMarchingForNormsDirection.
|
protected |
Resets the state of cells in a given list.
Warning: the list will be cleared!
References cloudViewer::FastMarching::Cell::FAR_CELL, m_theGrid, cloudViewer::FastMarching::Cell::state, cloudViewer::FastMarching::Cell::T, and cloudViewer::FastMarching::Cell::T_INF().
Referenced by cleanLastPropagation().
|
inlinevirtual |
Sets extended connectivity mode.
To use common edges instead of common faces (much slower)
Referenced by define_FastMarching().
|
virtual |
Sets a given cell as "seed".
| pos | the cell position in the grid (3 integer coordinates) |
Reimplemented in FastMarchingForFacetExtraction.
References cloudViewer::FastMarching::Cell::ACTIVE_CELL, addActiveCell(), m_gridSize, m_theGrid, pos2index(), cloudViewer::FastMarching::Cell::state, and cloudViewer::FastMarching::Cell::T.
Referenced by cloudViewer::DistanceComputationTools::computeGeodesicDistances(), define_FastMarching(), cloudViewer::AutoSegmentationTools::frontPropagationBasedSegmentation(), ccFastMarchingForNormsDirection::OrientNormals(), and FastMarchingForFacetExtraction::setSeedCell().
|
protectedpure virtual |
Propagates the front (one step)
Implemented in FastMarchingForFacetExtraction, cloudViewer::FastMarchingForPropagation, and ccFastMarchingForNormsDirection.
Referenced by initGrid().
|
protected |
ACTIVE cells list.
Referenced by addActiveCell(), cleanLastPropagation(), cloudViewer::FastMarchingForPropagation::extractPropagatedPoints(), initOther(), ccFastMarchingForNormsDirection::initTrialCells(), FastMarchingForFacetExtraction::initTrialCells(), initTrialCells(), cloudViewer::FastMarchingForPropagation::setPropagationTimingsAsDistances(), ccFastMarchingForNormsDirection::step(), cloudViewer::FastMarchingForPropagation::step(), FastMarchingForFacetExtraction::updateFlagsTable(), and ccFastMarchingForNormsDirection::updateResolvedTable().
|
protected |
Octree cell size at equivalent subdivision level.
Referenced by initGrid(), initGridWithOctree(), initOther(), and cloudViewer::FastMarchingForPropagation::step().
|
protected |
Grid size along the X dimension.
Referenced by cloudViewer::FastMarchingForPropagation::findPeaks(), initGrid(), initGridWithOctree(), and initOther().
|
protected |
Grid size along the Y dimension.
Referenced by cloudViewer::FastMarchingForPropagation::findPeaks(), initGrid(), initGridWithOctree(), and initOther().
|
protected |
Grid size along the Z dimension.
Referenced by cloudViewer::FastMarchingForPropagation::findPeaks(), initGrid(), initGridWithOctree(), and initOther().
|
protected |
Equivalent octree subdivision level.
Referenced by FastMarchingForFacetExtraction::addCellToCurrentFacet(), FastMarchingForFacetExtraction::computeTCoefApprox(), cloudViewer::FastMarchingForPropagation::extractPropagatedPoints(), initGrid(), initGridWithOctree(), cloudViewer::FastMarchingForPropagation::setPropagationTimingsAsDistances(), FastMarchingForFacetExtraction::updateFlagsTable(), and ccFastMarchingForNormsDirection::updateResolvedTable().
|
protected |
Grid size.
Referenced by initOther(), setSeedCell(), and ~FastMarching().
|
protected |
IGNORED cells lits.
Referenced by addIgnoredCell(), cleanLastPropagation(), and initOther().
|
protected |
First index of innerbound grid.
Referenced by initOther().
|
protected |
Specifiies whether structure is initialized or not.
Referenced by FastMarchingForFacetExtraction::addCellToCurrentFacet(), cloudViewer::FastMarchingForPropagation::extractPropagatedPoints(), cloudViewer::FastMarchingForPropagation::findPeaks(), cloudViewer::FastMarchingForPropagation::init(), ccFastMarchingForNormsDirection::init(), FastMarchingForFacetExtraction::init(), cloudViewer::FastMarchingForPropagation::setPropagationTimingsAsDistances(), ccFastMarchingForNormsDirection::step(), cloudViewer::FastMarchingForPropagation::step(), FastMarchingForFacetExtraction::step(), FastMarchingForFacetExtraction::updateFlagsTable(), and ccFastMarchingForNormsDirection::updateResolvedTable().
|
protected |
Octree min fill indexes at 'm_gridLevel'.
Referenced by initGrid(), and initGridWithOctree().
|
protected |
Neighbours distance weight.
Referenced by computeT(), FastMarching(), initOther(), ccFastMarchingForNormsDirection::initTrialCells(), FastMarchingForFacetExtraction::initTrialCells(), and initTrialCells().
|
protected |
Neighbours coordinates shifts in grid.
Referenced by computeT(), FastMarching(), cloudViewer::FastMarchingForPropagation::findPeaks(), initOther(), ccFastMarchingForNormsDirection::initTrialCells(), FastMarchingForFacetExtraction::initTrialCells(), initTrialCells(), ccFastMarchingForNormsDirection::resolveCellOrientation(), ccFastMarchingForNormsDirection::step(), cloudViewer::FastMarchingForPropagation::step(), and FastMarchingForFacetExtraction::step().
|
protected |
Current number of neighbours (6 or 26)
Referenced by computeT(), ccFastMarchingForNormsDirection::initTrialCells(), FastMarchingForFacetExtraction::initTrialCells(), initTrialCells(), ccFastMarchingForNormsDirection::resolveCellOrientation(), ccFastMarchingForNormsDirection::step(), cloudViewer::FastMarchingForPropagation::step(), and FastMarchingForFacetExtraction::step().
|
protected |
Associated octree.
Referenced by FastMarchingForFacetExtraction::addCellToCurrentFacet(), FastMarchingForFacetExtraction::computeTCoefApprox(), cloudViewer::FastMarchingForPropagation::extractPropagatedPoints(), initGrid(), initGridWithOctree(), cloudViewer::FastMarchingForPropagation::setPropagationTimingsAsDistances(), FastMarchingForFacetExtraction::setSeedCell(), FastMarchingForFacetExtraction::updateFlagsTable(), and ccFastMarchingForNormsDirection::updateResolvedTable().
|
protected |
Shift for cell access acceleration (Y dimension)
Referenced by cloudViewer::FastMarchingForPropagation::findPeaks(), getTime(), and initOther().
|
protected |
Shift for cell access acceleration (Z dimension)
Referenced by cloudViewer::FastMarchingForPropagation::findPeaks(), getTime(), and initOther().
|
protected |
Grid used to process Fast Marching.
Referenced by addActiveCell(), FastMarchingForFacetExtraction::addCellToCurrentFacet(), addIgnoredCell(), addTrialCell(), computeT(), cloudViewer::FastMarchingForPropagation::extractPropagatedPoints(), cloudViewer::FastMarchingForPropagation::findPeaks(), getNearestTrialCell(), getTime(), cloudViewer::FastMarchingForPropagation::init(), ccFastMarchingForNormsDirection::init(), FastMarchingForFacetExtraction::init(), ccFastMarchingForNormsDirection::initTrialCells(), FastMarchingForFacetExtraction::initTrialCells(), initTrialCells(), resetCells(), ccFastMarchingForNormsDirection::resolveCellOrientation(), cloudViewer::FastMarchingForPropagation::setPropagationTimingsAsDistances(), setSeedCell(), ccFastMarchingForNormsDirection::step(), cloudViewer::FastMarchingForPropagation::step(), FastMarchingForFacetExtraction::step(), FastMarchingForFacetExtraction::updateFlagsTable(), ccFastMarchingForNormsDirection::updateResolvedTable(), and ~FastMarching().
|
protected |
TRIAL cells list.
Referenced by addTrialCell(), cleanLastPropagation(), getNearestTrialCell(), and initOther().