CCCoreLib 31 May 2022
CloudCompare Core algorithms
Public Types | Static Public Member Functions | Static Protected Member Functions | List of all members
CCCoreLib::GeometricalAnalysisTools Class Reference

Several algorithms to compute point-clouds geometric characteristics (curvature, density, etc.) More...

#include <GeometricalAnalysisTools.h>

Inheritance diagram for CCCoreLib::GeometricalAnalysisTools:
Inheritance graph
[legend]
Collaboration diagram for CCCoreLib::GeometricalAnalysisTools:
Collaboration graph
[legend]

Public Types

enum  GeomCharacteristic {
  Feature , Curvature , LocalDensity , ApproxLocalDensity ,
  Roughness , MomentOrder1
}
 
enum  Density { DENSITY_KNN = 1 , DENSITY_2D , DENSITY_3D }
 Density measurement. More...
 
enum  ErrorCode {
  NoError = 0 , InvalidInput = -1 , NotEnoughPoints = -2 , OctreeComputationFailed = -3 ,
  ProcessFailed = -4 , UnhandledCharacteristic = -5 , NotEnoughMemory = -6 , ProcessCancelledByUser = -7
}
 

Static Public Member Functions

static ErrorCode ComputeCharactersitic (GeomCharacteristic c, int subOption, GenericIndexedCloudPersist *cloud, PointCoordinateType kernelRadius, const CCVector3 *roughnessUpDir=nullptr, GenericProgressCallback *progressCb=nullptr, DgmOctree *inputOctree=nullptr)
 Unified way to compute a geometric characteristic. More...
 
static ErrorCode ComputeLocalDensityApprox (GenericIndexedCloudPersist *cloud, Density densityType, GenericProgressCallback *progressCb=nullptr, DgmOctree *inputOctree=nullptr)
 Computes the local density (approximate) More...
 
static CCVector3 ComputeGravityCenter (GenericCloud *theCloud)
 Computes the gravity center of a point cloud. More...
 
static CCVector3 ComputeWeightedGravityCenter (GenericCloud *theCloud, ScalarField *weights)
 Computes the weighted gravity center of a point cloud. More...
 
static SquareMatrixd ComputeCrossCovarianceMatrix (GenericCloud *P, GenericCloud *Q, const CCVector3 &pGravityCenter, const CCVector3 &qGravityCenter)
 Computes the cross covariance matrix between two clouds (same size) More...
 
static SquareMatrixd ComputeWeightedCrossCovarianceMatrix (GenericCloud *P, GenericCloud *Q, const CCVector3 &pGravityCenter, const CCVector3 &qGravityCenter, ScalarField *coupleWeights=nullptr)
 Computes the cross covariance matrix between two clouds (same size) - weighted version. More...
 
static SquareMatrixd ComputeCovarianceMatrix (GenericCloud *theCloud, const PointCoordinateType *_gravityCenter=nullptr)
 Computes the covariance matrix of a clouds. More...
 
static ErrorCode FlagDuplicatePoints (GenericIndexedCloudPersist *theCloud, double minDistanceBetweenPoints=std::numeric_limits< double >::epsilon(), GenericProgressCallback *progressCb=nullptr, DgmOctree *inputOctree=nullptr)
 Flag duplicate points. More...
 
static ErrorCode DetectSphereRobust (GenericIndexedCloudPersist *cloud, double outliersRatio, CCVector3 &center, PointCoordinateType &radius, double &rms, GenericProgressCallback *progressCb=nullptr, double confidence=0.99, unsigned seed=0)
 Tries to detect a sphere in a point cloud. More...
 
static ErrorCode ComputeSphereFrom4 (const CCVector3 &A, const CCVector3 &B, const CCVector3 &C, const CCVector3 &D, CCVector3 &center, PointCoordinateType &radius)
 Computes the center and radius of a sphere passing through 4 points. More...
 

Static Protected Member Functions

static bool ComputeGeomCharacteristicAtLevel (const DgmOctree::octreeCell &cell, void **additionalParameters, NormalizedProgress *nProgress=nullptr)
 Computes geom characteristic inside a cell. More...
 
static bool ComputeApproxPointsDensityInACellAtLevel (const DgmOctree::octreeCell &cell, void **additionalParameters, NormalizedProgress *nProgress=nullptr)
 Computes approximate point density inside a cell. More...
 
static bool FlagDuplicatePointsInACellAtLevel (const DgmOctree::octreeCell &cell, void **additionalParameters, NormalizedProgress *nProgress=nullptr)
 Flags duplicate points inside a cell. More...
 
static bool RefineSphereLS (GenericIndexedCloudPersist *cloud, CCVector3 &center, PointCoordinateType &radius, double minReltaiveCenterShift=1.0e-3)
 Refines the estimation of a sphere by (iterative) least-squares.
 

Detailed Description

Several algorithms to compute point-clouds geometric characteristics (curvature, density, etc.)

Member Enumeration Documentation

◆ Density

Density measurement.

Enumerator
DENSITY_KNN 

The number of points inside the neighborhing sphere

DENSITY_2D 

The number of points divided by the area of the circle that has the same radius as the neighborhing sphere (2D approximation)

DENSITY_3D 

The number of points divided by the neighborhing sphere volume (3D)

◆ GeomCharacteristic

Enumerator
Feature 

See Neighbourhood::GeomFeature

Curvature 

See Neighbourhood::CurvatureType

LocalDensity 

Accurate local density (see GeometricalAnalysisTools::Density)

ApproxLocalDensity 

Approximate local density (see GeometricalAnalysisTools::Density)

Roughness 

Roughness

MomentOrder1 

1st order moment

Member Function Documentation

◆ ComputeApproxPointsDensityInACellAtLevel()

bool GeometricalAnalysisTools::ComputeApproxPointsDensityInACellAtLevel ( const DgmOctree::octreeCell cell,
void **  additionalParameters,
NormalizedProgress nProgress = nullptr 
)
staticprotected

Computes approximate point density inside a cell.

Parameters
cellstructure describing the cell on which processing is applied
additionalParameterssee method description
nProgressoptional (normalized) progress notification (per-point)

◆ ComputeCharactersitic()

GeometricalAnalysisTools::ErrorCode GeometricalAnalysisTools::ComputeCharactersitic ( GeomCharacteristic  c,
int  subOption,
GenericIndexedCloudPersist cloud,
PointCoordinateType  kernelRadius,
const CCVector3 roughnessUpDir = nullptr,
GenericProgressCallback progressCb = nullptr,
DgmOctree inputOctree = nullptr 
)
static

Unified way to compute a geometric characteristic.

Once the main geometric characterstic is chosen, the subOption parameter is used to specify the actual feature / curvature type / local density computation algorithm if necessary.

Parameters
cgeometric characterstic
subOptionfeature / curvature type / local density computation algorithm or nothing (0)
cloudcloud to compute the characteristic on
kernelRadiusneighbouring sphere radius
roughnessUpDirup direction to compute signed roughness values (optional)
progressCbclient application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
inputOctreeif not set as input, octree will be automatically computed.
Returns
succes

◆ ComputeCovarianceMatrix()

SquareMatrixd GeometricalAnalysisTools::ComputeCovarianceMatrix ( GenericCloud theCloud,
const PointCoordinateType *  _gravityCenter = nullptr 
)
static

Computes the covariance matrix of a clouds.

Warning
this method uses the cloud global iterator
Parameters
theCloudpoint cloud
_gravityCenterif available, its gravity center
Returns
covariance matrix

◆ ComputeCrossCovarianceMatrix()

SquareMatrixd GeometricalAnalysisTools::ComputeCrossCovarianceMatrix ( GenericCloud P,
GenericCloud Q,
const CCVector3 pGravityCenter,
const CCVector3 qGravityCenter 
)
static

Computes the cross covariance matrix between two clouds (same size)

Used in the ICP algorithm between the cloud to register and the "Closest Points Set" determined from the reference cloud.

Warning
this method uses the clouds global iterators
Parameters
Pthe cloud to register
Qthe "Closest Point Set"
pGravityCenterthe gravity center of P
qGravityCenterthe gravity center of Q
Returns
cross covariance matrix

◆ ComputeGeomCharacteristicAtLevel()

bool GeometricalAnalysisTools::ComputeGeomCharacteristicAtLevel ( const DgmOctree::octreeCell cell,
void **  additionalParameters,
NormalizedProgress nProgress = nullptr 
)
staticprotected

Computes geom characteristic inside a cell.

Parameters
cellstructure describing the cell on which processing is applied
additionalParameterssee method description
nProgressoptional (normalized) progress notification (per-point)

◆ ComputeGravityCenter()

CCVector3 GeometricalAnalysisTools::ComputeGravityCenter ( GenericCloud theCloud)
static

Computes the gravity center of a point cloud.

Warning
this method uses the cloud global iterator
Parameters
theCloudcloud
Returns
gravity center

◆ ComputeLocalDensityApprox()

GeometricalAnalysisTools::ErrorCode GeometricalAnalysisTools::ComputeLocalDensityApprox ( GenericIndexedCloudPersist cloud,
Density  densityType,
GenericProgressCallback progressCb = nullptr,
DgmOctree inputOctree = nullptr 
)
static

Computes the local density (approximate)

Old method (based only on the distance to the nearest neighbor).

Warning
As only one neighbor is extracted, the DENSITY_KNN type corresponds in fact to the (inverse) distance to the nearest neighbor.
This method assumes the input scalar field is different from the output one.
Parameters
cloudprocessed cloud
densityTypethe 'type' of density to compute
progressCbclient application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
inputOctreeif not set as input, octree will be automatically computed.
Returns
success (0) or error code (<0)

◆ ComputeSphereFrom4()

GeometricalAnalysisTools::ErrorCode GeometricalAnalysisTools::ComputeSphereFrom4 ( const CCVector3 A,
const CCVector3 B,
const CCVector3 C,
const CCVector3 D,
CCVector3 center,
PointCoordinateType &  radius 
)
static

Computes the center and radius of a sphere passing through 4 points.

Parameters
[in]Afirst point
[in]Bsecond point
[in]Cthird point
[in]Dfourth point
[out]centercenter of the sphere
[out]radiusradius of the sphere
Returns
success

◆ ComputeWeightedCrossCovarianceMatrix()

SquareMatrixd GeometricalAnalysisTools::ComputeWeightedCrossCovarianceMatrix ( GenericCloud P,
GenericCloud Q,
const CCVector3 pGravityCenter,
const CCVector3 qGravityCenter,
ScalarField coupleWeights = nullptr 
)
static

Computes the cross covariance matrix between two clouds (same size) - weighted version.

Used in the ICP algorithm between the cloud to register and the "Closest Points Set" determined from the reference cloud.

Warning
this method uses the clouds global iterators
Parameters
Pthe cloud to register
Qthe "Closest Point Set"
pGravityCenterthe gravity center of P
qGravityCenterthe gravity center of Q
coupleWeightsweights for each (Pi,Qi) couple (optional)
Returns
weighted cross covariance matrix

◆ ComputeWeightedGravityCenter()

CCVector3 GeometricalAnalysisTools::ComputeWeightedGravityCenter ( GenericCloud theCloud,
ScalarField weights 
)
static

Computes the weighted gravity center of a point cloud.

Warning
this method uses the cloud global iterator
Parameters
theCloudcloud
weightsper point weights (only absolute values are considered)
Returns
gravity center

◆ DetectSphereRobust()

GeometricalAnalysisTools::ErrorCode GeometricalAnalysisTools::DetectSphereRobust ( GenericIndexedCloudPersist cloud,
double  outliersRatio,
CCVector3 center,
PointCoordinateType &  radius,
double &  rms,
GenericProgressCallback progressCb = nullptr,
double  confidence = 0.99,
unsigned  seed = 0 
)
static

Tries to detect a sphere in a point cloud.

Inspired from "Parameter Estimation Techniques: A Tutorial with Application to Conic Fitting" by Zhengyou Zhang (Inria Technical Report 2676). More specifically the section 9.5 about Least Median of Squares.

Parameters
[in]cloudinput cloud
[in]outliersRatioproportion of outliers (between 0 and 1)
[out]centercenter of the detected sphere
[out]radiusradius of the detected sphere
[out]rmsresiduals RMS for the detected sphere
[in]progressCbfor progress notification (optional)
[in]confidenceprobability that the detected sphere is the right one (strictly below 1)
[in]seedif different than 0, this seed will be used for random numbers generation (instead of a random one)
Returns
success

◆ FlagDuplicatePoints()

GeometricalAnalysisTools::ErrorCode GeometricalAnalysisTools::FlagDuplicatePoints ( GenericIndexedCloudPersist theCloud,
double  minDistanceBetweenPoints = std::numeric_limits<double>::epsilon(),
GenericProgressCallback progressCb = nullptr,
DgmOctree inputOctree = nullptr 
)
static

Flag duplicate points.

This method only requires an output scalar field. Duplicate points will be associated to scalar value 1 (and 0 for the others).

Parameters
theCloudprocessed cloud
minDistanceBetweenPointsmin distance between (output) points
progressCbclient application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
inputOctreeif not set as input, octree will be automatically computed.
Returns
success (0) or error code (<0)

◆ FlagDuplicatePointsInACellAtLevel()

bool GeometricalAnalysisTools::FlagDuplicatePointsInACellAtLevel ( const DgmOctree::octreeCell cell,
void **  additionalParameters,
NormalizedProgress nProgress = nullptr 
)
staticprotected

Flags duplicate points inside a cell.

Parameters
cellstructure describing the cell on which processing is applied
additionalParameterssee method description
nProgressoptional (normalized) progress notification (per-point)

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