ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccOctree Class Reference

Octree structure. More...

#include <ecvOctree.h>

Inheritance diagram for ccOctree:
Collaboration diagram for ccOctree:

Classes

struct  BestRadiusParams
 Parameters for the GuessBestRadius method. More...
 

Public Types

enum  DisplayMode { WIRE = 0 , MEAN_POINTS , MEAN_CUBES = 2 }
 Octree displaying methods. More...
 
typedef QSharedPointer< ccOctreeShared
 Shared pointer. More...
 
- Public Types inherited from cloudViewer::DgmOctree
enum  RayCastProcess { RC_NEAREST_POINT , RC_CLOSE_POINTS }
 Ray casting processes. More...
 
using CellCode = unsigned
 Type of the code of an octree cell. More...
 
using cellCodesContainer = std::vector< CellCode >
 Octree cell codes container. More...
 
using cellIndexesContainer = std::vector< unsigned int >
 Octree cell indexes container. More...
 
using NeighboursSet = std::vector< PointDescriptor >
 A set of neighbours. More...
 
using NeighbourCellsSet = std::vector< CellDescriptor >
 A set of neighbour cells descriptors. More...
 
using cellsContainer = std::vector< IndexAndCode >
 Container of 'IndexAndCode' structures. More...
 
using octreeCellFunc = bool(*)(const octreeCell &, void **, NormalizedProgress *)
 

Signals

void updated ()
 Signal sent when the octree organization is modified (cleared, etc.) More...
 

Public Member Functions

 ccOctree (ccGenericPointCloud *cloud)
 Default constructor. More...
 
virtual ~ccOctree ()
 Destructor. More...
 
void multiplyBoundingBox (const PointCoordinateType multFactor)
 Multiplies the bounding-box of the octree. More...
 
void translateBoundingBox (const CCVector3 &T)
 Translates the bounding-box of the octree. More...
 
ccBBox getSquareBB () const
 Returns the octree (square) bounding-box. More...
 
ccBBox getPointsBB () const
 Returns the points bounding-box. More...
 
virtual void clear () override
 Clears the octree. More...
 
int getDisplayedLevel () const
 Returns the currently displayed octree level. More...
 
void setDisplayedLevel (int level)
 Sets the currently displayed octree level. More...
 
bool isVisible () const
 Returns whether octree is visible or not. More...
 
void setVisible (bool state)
 Sets octree visibility. More...
 
DisplayMode getDisplayMode () const
 Returns the currently display mode. More...
 
void setDisplayMode (DisplayMode mode)
 Sets the currently display mode. More...
 
void draw (CC_DRAW_CONTEXT &context)
 Draws the octree. More...
 
bool intersectWithFrustum (ccCameraSensor *sensor, std::vector< unsigned > &inCameraFrustum)
 Intersects octree with a camera sensor. More...
 
bool pointPicking (const CCVector2d &clickPos, const ccGLCameraParameters &camera, PointDescriptor &output, double pickWidth_pix=3.0) const
 Octree-driven point picking algorithm. More...
 
- Public Member Functions inherited from cloudViewer::DgmOctree
 DgmOctree (GenericIndexedCloudPersist *cloud)
 DgmOctree constructor. More...
 
 ~DgmOctree () override=default
 DgmOctree destructor. More...
 
int build (GenericProgressCallback *progressCb=nullptr)
 Builds the structure. More...
 
int build (const CCVector3 &octreeMin, const CCVector3 &octreeMax, const CCVector3 *pointsMinFilter=nullptr, const CCVector3 *pointsMaxFilter=nullptr, GenericProgressCallback *progressCb=nullptr)
 Builds the structure with constraints. More...
 
unsigned getNumberOfProjectedPoints () const
 Returns the number of points projected into the octree. More...
 
const CCVector3getOctreeMins () const
 Returns the lower boundaries of the octree. More...
 
const CCVector3getOctreeMaxs () const
 Returns the higher boundaries of the octree. More...
 
void getBoundingBox (CCVector3 &bbMin, CCVector3 &bbMax) const
 Returns the octree bounding box. More...
 
const int * getMinFillIndexes (unsigned char level) const
 
const int * getMaxFillIndexes (unsigned char level) const
 
const PointCoordinateTypegetCellSize (unsigned char level) const
 Returns the octree cells length for a given level of subdivision. More...
 
void getCellDistanceFromBorders (const Tuple3i &cellPos, unsigned char level, int *cellDists) const
 
void getCellDistanceFromBorders (const Tuple3i &cellPos, unsigned char level, int neighbourhoodLength, int *cellDists) const
 
bool getPointsInCellByCellIndex (ReferenceCloud *cloud, unsigned cellIndex, unsigned char level, bool clearOutputCloud=true) const
 Returns the points lying in a specific cell. More...
 
bool getPointsInCell (CellCode cellCode, unsigned char level, ReferenceCloud *subset, bool isCodeTruncated=false, bool clearOutputCloud=true) const
 Returns the points lying in a specific cell. More...
 
ReferenceCloudgetPointsInCellsWithSortedCellCodes (cellCodesContainer &cellCodes, unsigned char level, ReferenceCloud *subset, bool areCodesTruncated=false) const
 Returns the points lying in multiple cells. More...
 
unsigned findPointNeighbourhood (const CCVector3 *_queryPoint, ReferenceCloud *Yk, unsigned maxNumberOfNeighbors, unsigned char level, double &maxSquareDist, double maxSearchDist=0, int *finalNeighbourhoodSize=nullptr) const
 Finds the nearest neighbours around a query point. More...
 
double findTheNearestNeighborStartingFromCell (NearestNeighboursSearchStruct &nNSS) const
 
unsigned findNearestNeighborsStartingFromCell (NearestNeighboursSearchStruct &nNSS, bool getOnlyPointsWithValidScalar=false) const
 
int findNeighborsInASphereStartingFromCell (NearestNeighboursSearchStruct &nNSS, double radius, bool sortValues=true) const
 Advanced form of the nearest neighbours search algorithm (in a sphere) More...
 
int getPointsInSphericalNeighbourhood (const CCVector3 &sphereCenter, PointCoordinateType radius, NeighboursSet &neighbours, unsigned char level) const
 Returns the points falling inside a sphere. More...
 
std::size_t getPointsInCylindricalNeighbourhood (CylindricalNeighbourhood &params) const
 Returns the points falling inside a cylinder. More...
 
std::size_t getPointsInCylindricalNeighbourhoodProgressive (ProgressiveCylindricalNeighbourhood &params) const
 Same as getPointsInCylindricalNeighbourhood with progressive approach. More...
 
std::size_t getPointsInBoxNeighbourhood (BoxNeighbourhood &params) const
 Returns the points falling inside a box. More...
 
void getTheCellPosWhichIncludesThePoint (const CCVector3 *thePoint, Tuple3i &cellPos) const
 
void getTheCellPosWhichIncludesThePoint (const CCVector3 *thePoint, Tuple3i &cellPos, unsigned char level) const
 
void getTheCellPosWhichIncludesThePoint (const CCVector3 *thePoint, Tuple3i &cellPos, unsigned char level, bool &inBounds) const
 
void getCellPos (CellCode code, unsigned char level, Tuple3i &cellPos, bool isCodeTruncated) const
 
void computeCellCenter (CellCode code, unsigned char level, CCVector3 &center, bool isCodeTruncated=false) const
 
void computeCellCenter (const Tuple3i &cellPos, unsigned char level, CCVector3 &center) const
 
void computeCellCenter (const Tuple3s &cellPos, unsigned char level, CCVector3 &center) const
 Short version of computeCellCenter. More...
 
void computeCellLimits (CellCode code, unsigned char level, CCVector3 &cellMin, CCVector3 &cellMax, bool isCodeTruncated=false) const
 Returns the spatial limits of a given cell. More...
 
unsigned char findBestLevelForAGivenNeighbourhoodSizeExtraction (PointCoordinateType radius) const
 
unsigned char findBestLevelForComparisonWithOctree (const DgmOctree *theOtherOctree) const
 
unsigned char findBestLevelForAGivenPopulationPerCell (unsigned indicativeNumberOfPointsPerCell) const
 
unsigned char findBestLevelForAGivenCellNumber (unsigned indicativeNumberOfCells) const
 
const CellCodegetCellCode (unsigned index) const
 Returns the ith cell code. More...
 
bool getCellCodes (unsigned char level, cellCodesContainer &vec, bool truncatedCodes=false) const
 
bool getCellIndexes (unsigned char level, cellIndexesContainer &vec) const
 
bool getCellCodesAndIndexes (unsigned char level, cellsContainer &vec, bool truncatedCodes=false) const
 
void diff (const cellCodesContainer &codesA, const cellCodesContainer &codesB, cellCodesContainer &diffA, cellCodesContainer &diffB) const
 
bool diff (unsigned char octreeLevel, const cellsContainer &codesA, const cellsContainer &codesB, int &diffA, int &diffB, int &cellsA, int &cellsB) const
 
const unsigned & getCellNumber (unsigned char level) const
 Returns the number of cells for a given level of subdivision. More...
 
double computeMeanOctreeDensity (unsigned char level) const
 
int extractCCs (const cellCodesContainer &cellCodes, unsigned char level, bool sixConnexity, GenericProgressCallback *progressCb=nullptr) const
 
int extractCCs (unsigned char level, bool sixConnexity, GenericProgressCallback *progressCb=nullptr) const
 
unsigned executeFunctionForAllCellsStartingAtLevel (unsigned char startingLevel, octreeCellFunc func, void **additionalParameters, unsigned minNumberOfPointsPerCell, unsigned maxNumberOfPointsPerCell, bool multiThread=true, GenericProgressCallback *progressCb=nullptr, const char *functionTitle=nullptr, int maxThreadCount=0)
 
unsigned executeFunctionForAllCellsAtLevel (unsigned char level, octreeCellFunc func, void **additionalParameters, bool multiThread=false, GenericProgressCallback *progressCb=nullptr, const char *functionTitle=nullptr, int maxThreadCount=0)
 
bool rayCast (const CCVector3 &rayAxis, const CCVector3 &rayOrigin, double maxRadiusOrFov, bool isFOV, RayCastProcess process, std::vector< PointDescriptor > &output) const
 Ray casting algorithm. More...
 
GenericIndexedCloudPersistassociatedCloud () const
 Returns the associated cloud. More...
 
const cellsContainerpointsAndTheirCellCodes () const
 Returns the octree 'structure'. More...
 
- Public Member Functions inherited from cloudViewer::GenericOctree
virtual ~GenericOctree ()=default
 Default destructor. More...
 

Static Public Member Functions

static void ComputeAverageColor (cloudViewer::ReferenceCloud *subset, ccGenericPointCloud *sourceCloud, ColorCompType meanCol[])
 Computes the average color of a set of points. More...
 
static CCVector3 ComputeAverageNorm (cloudViewer::ReferenceCloud *subset, ccGenericPointCloud *sourceCloud)
 Computes the average normal of a set of points. More...
 
static PointCoordinateType GuessNaiveRadius (ccGenericPointCloud *cloud)
 Tries to guess a very naive 'local radius' for octree-based computation. More...
 
static PointCoordinateType GuessBestRadius (ccGenericPointCloud *cloud, const BestRadiusParams &params, cloudViewer::DgmOctree *cloudOctree=nullptr, cloudViewer::GenericProgressCallback *progressCb=nullptr)
 Tries to guess the best 'local radius' for octree-based computation. More...
 
static PointCoordinateType GuessBestRadiusAutoComputeOctree (ccGenericPointCloud *cloud, const BestRadiusParams &params, QWidget *parentWidget=nullptr)
 
- Static Public Member Functions inherited from cloudViewer::DgmOctree
static unsigned char GET_BIT_SHIFT (unsigned char level)
 Returns the binary shift for a given level of subdivision. More...
 
static int OCTREE_LENGTH (int level)
 
static CellCode GenerateTruncatedCellCode (const Tuple3i &cellPos, unsigned char level)
 
static CellCode GenerateTruncatedCellCode (const Tuple3s &pos, unsigned char level)
 Short version of GenerateTruncatedCellCode. More...
 
static PointCoordinateType ComputeMinDistanceToCellBorder (const CCVector3 &queryPoint, PointCoordinateType cs, const CCVector3 &cellCenter)
 
static bool MultiThreadSupport ()
 

Static Protected Member Functions

static bool DrawCellAsABox (const cloudViewer::DgmOctree::octreeCell &cell, void **additionalParameters, cloudViewer::NormalizedProgress *nProgress=0)
 
static bool DrawCellAsAPoint (const cloudViewer::DgmOctree::octreeCell &cell, void **additionalParameters, cloudViewer::NormalizedProgress *nProgress=0)
 
static bool DrawCellAsAPrimitive (const cloudViewer::DgmOctree::octreeCell &cell, void **additionalParameters, cloudViewer::NormalizedProgress *nProgress=0)
 

Protected Attributes

ccGenericPointCloudm_theAssociatedCloudAsGPC
 Associated cloud (as a ccGenericPointCloud) More...
 
int m_displayedLevel
 Displayed level. More...
 
DisplayMode m_displayMode
 Display mode. More...
 
ccOctreeFrustumIntersectorm_frustumIntersector
 For frustum intersection. More...
 
bool m_visible
 For Octree Display. More...
 
- Protected Attributes inherited from cloudViewer::DgmOctree
cellsContainer m_thePointsAndTheirCellCodes
 The coded octree structure. More...
 
GenericIndexedCloudPersistm_theAssociatedCloud
 Associated cloud. More...
 
unsigned m_numberOfProjectedPoints
 Number of points projected in the octree. More...
 
unsigned m_nearestPow2
 
CCVector3 m_dimMin
 Min coordinates of the octree bounding-box. More...
 
CCVector3 m_dimMax
 Max coordinates of the octree bounding-box. More...
 
CCVector3 m_pointsMin
 
CCVector3 m_pointsMax
 
PointCoordinateType m_cellSize [MAX_OCTREE_LEVEL+2]
 Cell dimensions for all subdivision levels. More...
 
int m_fillIndexes [(MAX_OCTREE_LEVEL+1) *6]
 
unsigned m_cellCount [MAX_OCTREE_LEVEL+1]
 Number of cells per level of subdivision. More...
 
unsigned m_maxCellPopulation [MAX_OCTREE_LEVEL+1]
 Max cell population per level of subdivision. More...
 
double m_averageCellPopulation [MAX_OCTREE_LEVEL+1]
 Average cell population per level of subdivision. More...
 
double m_stdDevCellPopulation [MAX_OCTREE_LEVEL+1]
 Std. dev. of cell population per level of subdivision. More...
 

Additional Inherited Members

- Static Public Attributes inherited from cloudViewer::DgmOctree
static const int MAX_OCTREE_LEVEL = 10
 Max octree subdivision level. More...
 
static const int MAX_OCTREE_LENGTH = (1 << MAX_OCTREE_LEVEL)
 Max octree length at last level of subdivision (number of cells) More...
 
static const CellCode INVALID_CELL_CODE = (~static_cast<CellCode>(0))
 Invalid cell code. More...
 
- Protected Member Functions inherited from cloudViewer::DgmOctree
int genericBuild (GenericProgressCallback *progressCb=nullptr)
 Generic method to build the octree structure. More...
 
void updateMinAndMaxTables ()
 Updates the tables containing octree limits and boundaries. More...
 
void updateCellSizeTable ()
 
void updateCellCountTable ()
 
void computeCellsStatistics (unsigned char level)
 Computes statistics about cells for a given level of subdivision. More...
 
void getNeighborCellsAround (const Tuple3i &cellPos, cellIndexesContainer &neighborCellsIndexes, int neighbourhoodLength, unsigned char level) const
 
void getPointsInNeighbourCellsAround (NearestNeighboursSearchStruct &nNSS, int neighbourhoodLength, bool getOnlyPointsWithValidScalar=false) const
 Gets point in the neighbourhing cells of a specific cell. More...
 
unsigned getCellIndex (CellCode truncatedCellCode, unsigned char bitDec) const
 Returns the index of a given cell represented by its code. More...
 
unsigned getCellIndex (CellCode truncatedCellCode, unsigned char bitDec, unsigned begin, unsigned end) const
 Returns the index of a given cell represented by its code. More...
 

Detailed Description

Octree structure.

Extends the cloudViewer::DgmOctree class.

Definition at line 27 of file ecvOctree.h.

Member Typedef Documentation

◆ Shared

typedef QSharedPointer<ccOctree> ccOctree::Shared

Shared pointer.

Definition at line 32 of file ecvOctree.h.

Member Enumeration Documentation

◆ DisplayMode

Octree displaying methods.

Enumerator
WIRE 

The octree is displayed as wired boxes (one box per cell)

MEAN_POINTS 

The octree is displayed as points (one point per cell = the center of gravity of the points lying in it)

MEAN_CUBES 

The octree is displayed as plain 3D cubes (one cube per cell)

Definition at line 77 of file ecvOctree.h.

Constructor & Destructor Documentation

◆ ccOctree()

ccOctree::ccOctree ( ccGenericPointCloud cloud)
explicit

Default constructor.

Parameters
clouda point cloud

◆ ~ccOctree()

virtual ccOctree::~ccOctree ( )
virtual

Destructor.

Member Function Documentation

◆ clear()

virtual void ccOctree::clear ( )
overridevirtual

Clears the octree.

Reimplemented from cloudViewer::DgmOctree.

◆ ComputeAverageColor()

static void ccOctree::ComputeAverageColor ( cloudViewer::ReferenceCloud subset,
ccGenericPointCloud sourceCloud,
ColorCompType  meanCol[] 
)
static

Computes the average color of a set of points.

◆ ComputeAverageNorm()

static CCVector3 ccOctree::ComputeAverageNorm ( cloudViewer::ReferenceCloud subset,
ccGenericPointCloud sourceCloud 
)
static

Computes the average normal of a set of points.

Referenced by qFacets::createFacets().

◆ draw()

void ccOctree::draw ( CC_DRAW_CONTEXT context)

Draws the octree.

◆ DrawCellAsABox()

static bool ccOctree::DrawCellAsABox ( const cloudViewer::DgmOctree::octreeCell cell,
void **  additionalParameters,
cloudViewer::NormalizedProgress nProgress = 0 
)
staticprotected

◆ DrawCellAsAPoint()

static bool ccOctree::DrawCellAsAPoint ( const cloudViewer::DgmOctree::octreeCell cell,
void **  additionalParameters,
cloudViewer::NormalizedProgress nProgress = 0 
)
staticprotected

◆ DrawCellAsAPrimitive()

static bool ccOctree::DrawCellAsAPrimitive ( const cloudViewer::DgmOctree::octreeCell cell,
void **  additionalParameters,
cloudViewer::NormalizedProgress nProgress = 0 
)
staticprotected

◆ getDisplayedLevel()

int ccOctree::getDisplayedLevel ( ) const
inline

Returns the currently displayed octree level.

Definition at line 67 of file ecvOctree.h.

Referenced by ccPropertiesTreeDelegate::fillWithPointOctree().

◆ getDisplayMode()

DisplayMode ccOctree::getDisplayMode ( ) const
inline

Returns the currently display mode.

Definition at line 87 of file ecvOctree.h.

◆ getPointsBB()

ccBBox ccOctree::getPointsBB ( ) const

Returns the points bounding-box.

◆ getSquareBB()

ccBBox ccOctree::getSquareBB ( ) const

Returns the octree (square) bounding-box.

◆ GuessBestRadius()

static PointCoordinateType ccOctree::GuessBestRadius ( ccGenericPointCloud cloud,
const BestRadiusParams params,
cloudViewer::DgmOctree cloudOctree = nullptr,
cloudViewer::GenericProgressCallback progressCb = nullptr 
)
static

Tries to guess the best 'local radius' for octree-based computation.

The ideal radius is determined by randomly sampling up to 200 points and looking at their neighborhood.

Parameters
cloudpoint cloud on which to process the normals.
paramsparameters
cloudOctreeinput cloud octree (optional)
progressCbprogress notification (optional)
Returns
the best radius (strictly positive value) or 0 if an error occurred

◆ GuessBestRadiusAutoComputeOctree()

static PointCoordinateType ccOctree::GuessBestRadiusAutoComputeOctree ( ccGenericPointCloud cloud,
const BestRadiusParams params,
QWidget *  parentWidget = nullptr 
)
static

Tries to guess the best 'local radius' for octree-based computation (auto-computes the octree if necessary) The ideal radius is determined by randomly sampling up to 200 points and looking at their neighborhood.

Parameters
cloudpoint cloud on which to process the normals.
paramsparameters
parentWidgetparent widget (for the progress dialog, if any has to be shown)
Returns
the best radius (strictly positive value) or 0 if an error occurred

Referenced by FastGlobalRegistrationDialog::autoEstimateRadius().

◆ GuessNaiveRadius()

static PointCoordinateType ccOctree::GuessNaiveRadius ( ccGenericPointCloud cloud)
static

Tries to guess a very naive 'local radius' for octree-based computation.

Parameters
cloudpoint cloud on which to process the normals.
Returns
naive radius (one percent of the cloud largest dimension by default, unless the cloud have very few points)

Referenced by FastGlobalRegistrationDialog::FastGlobalRegistrationDialog().

◆ intersectWithFrustum()

bool ccOctree::intersectWithFrustum ( ccCameraSensor sensor,
std::vector< unsigned > &  inCameraFrustum 
)

Intersects octree with a camera sensor.

◆ isVisible()

bool ccOctree::isVisible ( ) const
inline

Returns whether octree is visible or not.

Definition at line 72 of file ecvOctree.h.

◆ multiplyBoundingBox()

void ccOctree::multiplyBoundingBox ( const PointCoordinateType  multFactor)

Multiplies the bounding-box of the octree.

If the cloud coordinates are simply multiplied by the same factor, there is no use in recomputing the octree structure. It's sufficient to update its bounding-box.

Parameters
multFactormultiplication factor

◆ pointPicking()

bool ccOctree::pointPicking ( const CCVector2d clickPos,
const ccGLCameraParameters camera,
PointDescriptor output,
double  pickWidth_pix = 3.0 
) const

Octree-driven point picking algorithm.

◆ setDisplayedLevel()

void ccOctree::setDisplayedLevel ( int  level)

Sets the currently displayed octree level.

◆ setDisplayMode()

void ccOctree::setDisplayMode ( DisplayMode  mode)

Sets the currently display mode.

◆ setVisible()

void ccOctree::setVisible ( bool  state)
inline

Sets octree visibility.

Definition at line 74 of file ecvOctree.h.

◆ translateBoundingBox()

void ccOctree::translateBoundingBox ( const CCVector3 T)

Translates the bounding-box of the octree.

If the cloud has been simply translated, there is no use to recompute the octree structure. It's sufficient to update its bounding-box.

Parameters
Ttranslation vector

◆ updated

void ccOctree::updated ( )
signal

Signal sent when the octree organization is modified (cleared, etc.)

Member Data Documentation

◆ m_displayedLevel

int ccOctree::m_displayedLevel
protected

Displayed level.

Definition at line 183 of file ecvOctree.h.

◆ m_displayMode

DisplayMode ccOctree::m_displayMode
protected

Display mode.

Definition at line 186 of file ecvOctree.h.

◆ m_frustumIntersector

ccOctreeFrustumIntersector* ccOctree::m_frustumIntersector
protected

For frustum intersection.

Definition at line 189 of file ecvOctree.h.

◆ m_theAssociatedCloudAsGPC

ccGenericPointCloud* ccOctree::m_theAssociatedCloudAsGPC
protected

Associated cloud (as a ccGenericPointCloud)

Definition at line 180 of file ecvOctree.h.

◆ m_visible

bool ccOctree::m_visible
protected

For Octree Display.

Definition at line 192 of file ecvOctree.h.


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