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

Several scalar field treatment algorithms (gradient, classification, etc.) More...

#include <ScalarFieldTools.h>

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

Static Public Member Functions

static ScalarType computeMeanScalarValue (GenericCloud *theCloud)
 Computes the mean value of a scalar field associated to a cloud. More...
 
static ScalarType computeMeanSquareScalarValue (GenericCloud *theCloud)
 Computes the mean square value of a scalar field associated to a cloud. More...
 
static int computeScalarFieldGradient (GenericIndexedCloudPersist *theCloud, PointCoordinateType radius, bool euclideanDistances, bool sameInAndOutScalarField=false, GenericProgressCallback *progressCb=nullptr, DgmOctree *theOctree=nullptr)
 Computes the geometrical gradient of a scalar field associated to a point cloud. More...
 
static bool applyScalarFieldGaussianFilter (PointCoordinateType sigma, GenericIndexedCloudPersist *theCloud, PointCoordinateType sigmaSF, GenericProgressCallback *progressCb=nullptr, DgmOctree *theOctree=nullptr)
 Computes a spatial gaussian filter on a scalar field associated to a point cloud. More...
 
static void multiplyScalarFields (GenericIndexedCloud *firstCloud, GenericIndexedCloud *secondCloud, GenericProgressCallback *progressCb=nullptr)
 Multiplies two scalar fields of the same size. More...
 
static void computeScalarFieldHistogram (const GenericCloud *theCloud, unsigned numberOfClasses, std::vector< int > &histo)
 Computes an histogram of the scalar field with a given number of classes. More...
 
static void computeScalarFieldExtremas (const GenericCloud *theCloud, ScalarType &minV, ScalarType &maxV)
 Compute the extreme values of a scalar field. More...
 
static unsigned countScalarFieldValidValues (const GenericCloud *theCloud)
 Count the number of valid values in a scalar field. More...
 
static bool computeKmeans (const GenericCloud *theCloud, unsigned char K, KMeanClass kmcc[], GenericProgressCallback *progressCb=nullptr)
 Classifies automaticaly a scalar field in K classes with the K-means algorithm. More...
 
static void SetScalarValueToNaN (const CCVector3 &P, ScalarType &scalarValue)
 Sets the distance value associated to a point. More...
 
static void SetScalarValueToZero (const CCVector3 &P, ScalarType &scalarValue)
 Sets the distance value associated to a point to zero. More...
 
static void SetScalarValueInverted (const CCVector3 &P, ScalarType &scalarValue)
 

Static Protected Member Functions

static bool computeMeanGradientOnPatch (const DgmOctree::octreeCell &cell, void **additionalParameters, NormalizedProgress *nProgress=nullptr)
 "Cellular" function to compute the gradient norms of points inside an octree cell More...
 
static bool computeCellGaussianFilter (const DgmOctree::octreeCell &cell, void **additionalParameters, NormalizedProgress *nProgress=nullptr)
 "Cellular" function to apply a gaussian filter on the scalar values of points inside an octree cell More...
 

Detailed Description

Several scalar field treatment algorithms (gradient, classification, etc.)

This toolbox provides several algorithms to apply treatments and handle scalar fields

Member Function Documentation

◆ applyScalarFieldGaussianFilter()

bool ScalarFieldTools::applyScalarFieldGaussianFilter ( PointCoordinateType  sigma,
GenericIndexedCloudPersist theCloud,
PointCoordinateType  sigmaSF,
GenericProgressCallback progressCb = nullptr,
DgmOctree theOctree = nullptr 
)
static

Computes a spatial gaussian filter on a scalar field associated to a point cloud.

The "amplitutde" of the gaussian filter must be precised (sigma). As 99% of the gaussian distribution is between -3*sigma and +3*sigma around the mean value, this filter will only look for neighbouring points (around each point) in a sphere of radius 3*sigma. It also permits to use the filter as a bilateral filter. Where the wights are computed also considering the distance of the neighbor's scalar value from the current point scalar value. (weighted with gaussian as distances are) Warning: this method assumes the input scalar field is different from output.

Parameters
sigmafilter variance
theClouda point cloud (associated to scalar values)
sigmaSFthe sigma for the bilateral filter. when different than -1 turns the gaussian filter into a bilateral filter
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
theOctreethe octree, if it has already been computed
Returns
success

◆ computeCellGaussianFilter()

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

"Cellular" function to apply a gaussian filter on the scalar values of points inside an octree cell

This function is meant to be applied to all cells of the octree The method also permits to use a bilateral behaviour for the filter. This is automatically switched on if its sigmaSF parameter in additionalParameters is different than -1 (it is of the form DgmOctree::localFunctionPtr). See ScalarFieldTools::applyScalarFieldGaussianFilter. Method parameters (defined in "additionalParameters") are :

  • (PointCoordinateType*) sigma
  • (std::vector<ScalarType>*) the smoothed values
    Parameters
    cellstructure describing the cell on which processing is applied
    additionalParameterssee method description
    nProgressoptional (normalized) progress notification (per-point)

◆ computeKmeans()

bool ScalarFieldTools::computeKmeans ( const GenericCloud theCloud,
unsigned char  K,
KMeanClass  kmcc[],
GenericProgressCallback progressCb = nullptr 
)
static

Classifies automaticaly a scalar field in K classes with the K-means algorithm.

The initial K classes positions are regularly spaced between the lowest and the highest values of the scalar field. Eventually the algorithm will converge and produce K classes.

Parameters
theClouda point cloud (associated to scalar values)
Kthe number of classes
kmccan array of size K which will be filled with the computed classes limits (see ScalarFieldTools::KmeanClass)
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)

◆ computeMeanGradientOnPatch()

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

"Cellular" function to compute the gradient norms of points inside an octree cell

This function is meant to be applied to all cells of the octree (it is of the form DgmOctree::localFunctionPtr). See ScalarFieldTools::computeScalarFieldGradient. Method parameters (defined in "additionalParameters") are :

  • (GenericCloud*) the point cloud
  • (bool*) specifies if the scalar values are euclidean distances
  • (PointCoordinateType*) radius
  • (std::vector<ScalarType>*) the gradient norms container
    Parameters
    cellstructure describing the cell on which processing is applied
    additionalParameterssee method description
    nProgressoptional (normalized) progress notification (per-point)

◆ computeMeanScalarValue()

ScalarType ScalarFieldTools::computeMeanScalarValue ( GenericCloud theCloud)
static

Computes the mean value of a scalar field associated to a cloud.

Returns the mean of SF values associated to each point of a cloud Warning: be sure to activate an OUTPUT scalar field on the cloud

Parameters
theCloudthe point cloud
Returns
the associated scalar field mean value

◆ computeMeanSquareScalarValue()

ScalarType ScalarFieldTools::computeMeanSquareScalarValue ( GenericCloud theCloud)
static

Computes the mean square value of a scalar field associated to a cloud.

Returns the mean of squared SF values associated to each point of a cloud Warning: be sure to activate an OUTPUT scalar field on the cloud

Parameters
theCloudthe point cloud
Returns
the associated scalar field mean of squares value

◆ computeScalarFieldExtremas()

void ScalarFieldTools::computeScalarFieldExtremas ( const GenericCloud theCloud,
ScalarType &  minV,
ScalarType &  maxV 
)
static

Compute the extreme values of a scalar field.

Parameters
theClouda point cloud, with a scalar field activated
minVa field to store the minimum value
maxVa field to store the maximum value

◆ computeScalarFieldGradient()

int ScalarFieldTools::computeScalarFieldGradient ( GenericIndexedCloudPersist theCloud,
PointCoordinateType  radius,
bool  euclideanDistances,
bool  sameInAndOutScalarField = false,
GenericProgressCallback progressCb = nullptr,
DgmOctree theOctree = nullptr 
)
static

Computes the geometrical gradient of a scalar field associated to a point cloud.

See Daniel Girardeau-Montaut's PhD manuscript (Chapter 3, section 3.3.2) for more information. As explained in this section, if the scalar field corresponds to (euclidean) distances between the points and another entity, then it is possible to filter out aberrant values.

Parameters
theClouda point cloud (associated to scalar values)
radiusspherical neighborhood size (or 0 for automatic size)
euclideanDistancesindicates if the scalar values are euclidean distances
sameInAndOutScalarFieldspecifies that the 'in' and 'out' scalar field of the input point cloud are the same structure
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
theOctreethe octree, if it has already been computed
Returns
error code (0 if ok)

◆ computeScalarFieldHistogram()

void ScalarFieldTools::computeScalarFieldHistogram ( const GenericCloud theCloud,
unsigned  numberOfClasses,
std::vector< int > &  histo 
)
static

Computes an histogram of the scalar field with a given number of classes.

The scalar values are projected in a given number of classes, regularly spaced between the lowest and the highest value of the scalar field.

Parameters
theClouda point cloud (associated to scalar values)
numberOfClassesnumber of histogram classes
histonumber of elements per histogram class

◆ countScalarFieldValidValues()

unsigned ScalarFieldTools::countScalarFieldValidValues ( const GenericCloud theCloud)
static

Count the number of valid values in a scalar field.

Parameters
theClouda point cloud, with a scalar field activated

◆ multiplyScalarFields()

void ScalarFieldTools::multiplyScalarFields ( GenericIndexedCloud firstCloud,
GenericIndexedCloud secondCloud,
GenericProgressCallback progressCb = nullptr 
)
static

Multiplies two scalar fields of the same size.

The first scalar field is updated (S1 = S1*S2).

Parameters
firstCloudthe first point cloud (associated to scalar values)
secondCloudthe second point cloud (associated to scalar values)
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)

◆ SetScalarValueToNaN()

void ScalarFieldTools::SetScalarValueToNaN ( const CCVector3 P,
ScalarType &  scalarValue 
)
static

Sets the distance value associated to a point.

Generic function that can be used with the GenericCloud::foreach() method.

Parameters
Pa 3D point
scalarValueits associated scalar value

◆ SetScalarValueToZero()

void ScalarFieldTools::SetScalarValueToZero ( const CCVector3 P,
ScalarType &  scalarValue 
)
static

Sets the distance value associated to a point to zero.

Generic function that can be used with the GenericCloud::foreach() method.

Parameters
Pa 3D point
scalarValueits associated scalar value

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