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

#include <GeometricalAnalysisTools.h>

Inheritance diagram for cloudViewer::GeometricalAnalysisTools:
Collaboration diagram for cloudViewer::GeometricalAnalysisTools:

Public Types

enum  GeomCharacteristic {
  Feature , Curvature , LocalDensity , ApproxLocalDensity ,
  Roughness , MomentOrder1
}
 
enum  Density { DENSITY_KNN , 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 (const 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)
 
static cloudViewer::SquareMatrixd ComputeCovarianceMatrix (const 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 ErrorCode DetectCircle (GenericIndexedCloudPersist *cloud, CCVector3 &center, CCVector3 &normal, PointCoordinateType &radius, double &rms, GenericProgressCallback *progressCb=nullptr)
 Detects a circle from a point cloud. 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. More...
 

Detailed Description

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

Definition at line 22 of file GeometricalAnalysisTools.h.

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)

Definition at line 36 of file GeometricalAnalysisTools.h.

◆ ErrorCode

Enumerator
NoError 
InvalidInput 
NotEnoughPoints 
OctreeComputationFailed 
ProcessFailed 
UnhandledCharacteristic 
NotEnoughMemory 
ProcessCancelledByUser 

Definition at line 46 of file GeometricalAnalysisTools.h.

◆ 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

Definition at line 24 of file GeometricalAnalysisTools.h.

Member Function Documentation

◆ ComputeApproxPointsDensityInACellAtLevel()

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

◆ 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

Definition at line 29 of file GeometricalAnalysisTools.cpp.

References ApproxLocalDensity, cloudViewer::DgmOctree::build(), ComputeGeomCharacteristicAtLevel(), ComputeLocalDensityApprox(), Curvature, DENSITY_2D, DENSITY_3D, DENSITY_KNN, cloudViewer::GenericCloud::enableScalarField(), cloudViewer::DgmOctree::executeFunctionForAllCellsAtLevel(), Feature, cloudViewer::DgmOctree::findBestLevelForAGivenNeighbourhoodSizeExtraction(), cloudViewer::GenericCloud::getPointScalarValue(), InvalidInput, LocalDensity, M_PI, MomentOrder1, NoError, NotEnoughPoints, octree, OctreeComputationFailed, ProcessFailed, result, Roughness, s_UnitSphereVolume, cloudViewer::GenericCloud::setPointScalarValue(), cloudViewer::GenericCloud::size(), and UnhandledCharacteristic.

Referenced by ccTrace::buildCurvatureCost(), and ccLibAlgorithms::ComputeGeomCharacteristic().

◆ ComputeCovarianceMatrix()

cloudViewer::SquareMatrixd GeometricalAnalysisTools::ComputeCovarianceMatrix ( const 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

Definition at line 562 of file GeometricalAnalysisTools.cpp.

References cloudViewer::SquareMatrixTpl< Scalar >::clear(), ComputeGravityCenter(), cloudViewer::SquareMatrixTpl< Scalar >::m_values, points, cloudViewer::GenericCloud::size(), Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.

◆ ComputeCrossCovarianceMatrix()

cloudViewer::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

Definition at line 611 of file GeometricalAnalysisTools.cpp.

References count, cloudViewer::GenericCloud::getNextPoint(), cloudViewer::GenericCloud::placeIteratorAtBeginning(), cloudViewer::SquareMatrixTpl< Scalar >::row(), cloudViewer::SquareMatrixTpl< Scalar >::scale(), cloudViewer::GenericCloud::size(), Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.

Referenced by cloudViewer::RegistrationTools::RegistrationProcedure().

◆ 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)

Definition at line 154 of file GeometricalAnalysisTools.cpp.

References cloudViewer::DgmOctree::NearestNeighboursSearchStruct::alreadyVisitedNeighbourhoodSize, cloudViewer::DgmOctree::NearestNeighboursSearchStruct::cellCenter, cloudViewer::DgmOctree::NearestNeighboursSearchStruct::cellPos, cloudViewer::DgmOctree::computeCellCenter(), cloudViewer::Neighbourhood::computeCurvature(), cloudViewer::Neighbourhood::computeFeature(), cloudViewer::Neighbourhood::computeMomentOrder1(), cloudViewer::Neighbourhood::computeRoughness(), Curvature, Feature, cloudViewer::DgmOctree::findNeighborsInASphereStartingFromCell(), cloudViewer::DgmOctree::getCellPos(), cloudViewer::DgmOctree::getCellSize(), cloudViewer::ReferenceCloud::getPoint(), cloudViewer::ReferenceCloud::getPointGlobalIndex(), cloudViewer::ReferenceCloud::getPointPersistentPtr(), cloudViewer::DgmOctree::NearestNeighboursSearchStruct::level, cloudViewer::DgmOctree::octreeCell::level, LocalDensity, MomentOrder1, NAN_VALUE, nProgress, cloudViewer::NormalizedProgress::oneStep(), cloudViewer::DgmOctree::octreeCell::parentOctree, cloudViewer::DgmOctree::octreeCell::points, cloudViewer::DgmOctree::NearestNeighboursSearchStruct::pointsInNeighbourhood, cloudViewer::DgmOctree::NearestNeighboursSphericalSearchStruct::prepare(), cloudViewer::DgmOctree::NearestNeighboursSearchStruct::queryPoint, Roughness, cloudViewer::ReferenceCloud::setPointScalarValue(), cloudViewer::ReferenceCloud::size(), std::swap(), and cloudViewer::DgmOctree::octreeCell::truncatedCode.

Referenced by ComputeCharactersitic().

◆ ComputeGravityCenter()

CCVector3 GeometricalAnalysisTools::ComputeGravityCenter ( const GenericCloud theCloud)
static

Computes the gravity center of a point cloud.

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

Definition at line 517 of file GeometricalAnalysisTools.cpp.

References count, and cloudViewer::GenericCloud::size().

Referenced by ComputeCovarianceMatrix(), and cloudViewer::RegistrationTools::RegistrationProcedure().

◆ 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)

Definition at line 409 of file GeometricalAnalysisTools.cpp.

References cloudViewer::DgmOctree::build(), ComputeApproxPointsDensityInACellAtLevel(), cloudViewer::GenericCloud::enableScalarField(), cloudViewer::DgmOctree::executeFunctionForAllCellsAtLevel(), cloudViewer::DgmOctree::findBestLevelForAGivenPopulationPerCell(), InvalidInput, NoError, NotEnoughPoints, OctreeComputationFailed, ProcessFailed, result, and cloudViewer::GenericCloud::size().

Referenced by ComputeCharactersitic(), and ccAlignDlg::estimateDelta().

◆ 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

Definition at line 1228 of file GeometricalAnalysisTools.cpp.

References dmat_solve(), NoError, Vector3Tpl< Type >::norm(), Vector3Tpl< Type >::norm2d(), ProcessFailed, Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.

Referenced by DetectSphereRobust().

◆ ComputeWeightedCrossCovarianceMatrix()

cloudViewer::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

Definition at line 650 of file GeometricalAnalysisTools.cpp.

References abs(), count, cloudViewer::ScalarField::currentSize(), Vector3Tpl< double >::fromArray(), cloudViewer::GenericCloud::getNextPoint(), cloudViewer::ScalarField::getValue(), cloudViewer::GenericCloud::placeIteratorAtBeginning(), cloudViewer::SquareMatrixTpl< Scalar >::row(), cloudViewer::SquareMatrixTpl< Scalar >::scale(), cloudViewer::GenericCloud::size(), cloudViewer::ScalarField::ValidValue(), Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.

Referenced by cloudViewer::RegistrationTools::RegistrationProcedure().

◆ 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

Definition at line 537 of file GeometricalAnalysisTools.cpp.

References count, cloudViewer::ScalarField::currentSize(), and cloudViewer::GenericCloud::size().

Referenced by cloudViewer::RegistrationTools::RegistrationProcedure().

◆ DetectCircle()

GeometricalAnalysisTools::ErrorCode GeometricalAnalysisTools::DetectCircle ( GenericIndexedCloudPersist cloud,
CCVector3 center,
CCVector3 normal,
PointCoordinateType radius,
double &  rms,
GenericProgressCallback progressCb = nullptr 
)
static

◆ 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

Definition at line 769 of file GeometricalAnalysisTools.cpp.

References cloudViewer::ReferenceCloud::addPointIndex(), ComputeSphereFrom4(), dist(), error(), cloudViewer::GenericIndexedCloud::getPoint(), InvalidInput, min(), NoError, NotEnoughMemory, NotEnoughPoints, nProgress, cloudViewer::NormalizedProgress::oneStep(), ProcessCancelledByUser, ProcessFailed, RefineSphereLS(), cloudViewer::ReferenceCloud::reserve(), cloudViewer::ReferenceCloud::resize(), cloudViewer::GenericProgressCallback::setInfo(), cloudViewer::GenericProgressCallback::setMethodTitle(), cloudViewer::GenericCloud::size(), cloudViewer::ReferenceCloud::size(), cloudViewer::GenericProgressCallback::start(), cloudViewer::GenericProgressCallback::textCanBeEdited(), and cloudViewer::GenericProgressCallback::update().

Referenced by ccPointPairRegistrationDlg::convertToSphereCenter().

◆ 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)

Definition at line 300 of file GeometricalAnalysisTools.cpp.

References cloudViewer::DgmOctree::build(), cloudViewer::GenericCloud::enableScalarField(), cloudViewer::DgmOctree::executeFunctionForAllCellsAtLevel(), cloudViewer::DgmOctree::findBestLevelForAGivenNeighbourhoodSizeExtraction(), FlagDuplicatePointsInACellAtLevel(), cloudViewer::GenericCloud::forEach(), InvalidInput, NoError, NotEnoughPoints, OctreeComputationFailed, ProcessFailed, result, cloudViewer::ScalarFieldTools::SetScalarValueToZero(), and cloudViewer::GenericCloud::size().

◆ FlagDuplicatePointsInACellAtLevel()

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

◆ RefineSphereLS()

bool GeometricalAnalysisTools::RefineSphereLS ( GenericIndexedCloudPersist cloud,
CCVector3 center,
PointCoordinateType radius,
double  minReltaiveCenterShift = 1.0e-3 
)
staticprotected

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