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

Several entity-to-entity distances computation algorithms (cloud-cloud, cloud-mesh, point-triangle, etc.) More...

#include <DistanceComputationTools.h>

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

Classes

struct  Cloud2CloudDistancesComputationParams
 Cloud-to-cloud 'nearest neighbors' distances computation parameters. More...
 
struct  Cloud2MeshDistancesComputationParams
 Cloud-to-mesh distances computation parameters. More...
 

Public Types

enum  ERROR_MEASURES {
  RMS , MAX_DIST_68_PERCENT , MAX_DIST_95_PERCENT , MAX_DIST_99_PERCENT ,
  MAX_DIST
}
 Error estimators. More...
 
enum  DISTANCE_COMPUTATION_RESULTS {
  CANCELED_BY_USER = -1000 , ERROR_NULL_COMPAREDCLOUD , ERROR_NULL_COMPAREDOCTREE , ERROR_OUT_OF_MEMORY ,
  ERROR_ENABLE_SCALAR_FIELD_FAILURE , ERROR_EMPTY_COMPAREDCLOUD , ERROR_NULL_REFERENCECLOUD , ERROR_EMPTY_REFERENCECLOUD ,
  ERROR_NULL_REFERENCEMESH , ERROR_EMPTY_REFERENCEMESH , ERROR_NULL_REFERENCEPOLYLINE , ERROR_TOOSMALL_REFERENCEPOLYLINE ,
  NULL_PLANE_EQUATION , ERROR_NULL_OCTREE , ERROR_INVALID_OCTREE_AND_MESH_INTERSECTION , ERROR_OCTREE_AND_MESH_INTERSECTION_MISMATCH ,
  ERROR_CANT_USE_MAX_SEARCH_DIST_AND_CLOSEST_POINT_SET , ERROR_EXECUTE_FUNCTION_FOR_ALL_CELLS_AT_LEVEL_FAILURE , ERROR_EXECUTE_GET_POINTS_IN_CELL_BY_INDEX_FAILURE , ERROR_EXECUTE_CLOUD_MESH_DIST_CELL_FUNC_MT_FAILURE ,
  ERROR_GET_CELL_CODES_FAILURE , ERROR_GET_CELL_CODES_AND_INDEXES_FAILURE , ERROR_GET_CELL_INDEXES_FAILURE , ERROR_PROPAGATE_DISTANCE_FAILURE ,
  ERROR_SEED_POINT_INDEX_GREATER_THAN_COMPAREDCLOUD_SIZE , ERROR_INIT_DISTANCE_TRANSFORM_GRID_FAILURE , ERROR_INIT_PER_CELL_TRIANGLE_LIST_FAILURE , ERROR_INTERSECT_MESH_WITH_OCTREE_FAILURE ,
  ERROR_COMPUTE_CLOUD2_MESH_DISTANCE_WITH_OCTREE_FAILURE , ERROR_COMPUTE_CLOUD2_CLOUD_DISTANCE_FAILURE , ERROR_OCTREE_LEVEL_LT_ONE , ERROR_OCTREE_LEVEL_GT_MAX_OCTREE_LEVEL ,
  ERROR_SYNCHRONIZE_OCTREES_FAILURE , ERROR_PLANE_NORMAL_LT_ZERO , ERROR_INVALID_PRIMITIVE_DIMENSIONS , ERROR_CONE_R1_LT_CONE_R2 ,
  ERROR_CONELENGTH_ZERO , ERROR_COULDNOT_SYNCRONIZE_OCTREES , ERROR_BUILD_OCTREE_FAILURE , ERROR_BUILD_FAST_MARCHING_FAILURE ,
  ERROR_UNKOWN_ERRORMEASURES_TYPE , INVALID_INPUT , SUCCESS = 1
}
 Error codes returned by the distance computation methods.
 
enum  SOReturnCode { EMPTY_CLOUD , SYNCHRONIZED , DISJOINT , OUT_OF_MEMORY }
 Return codes for DistanceComputationTools::synchronizeOctrees.
 

Static Public Member Functions

static int computeCloud2CloudDistances (GenericIndexedCloudPersist *comparedCloud, GenericIndexedCloudPersist *referenceCloud, Cloud2CloudDistancesComputationParams &params, GenericProgressCallback *progressCb=nullptr, DgmOctree *compOctree=nullptr, DgmOctree *refOctree=nullptr)
 Computes the 'nearest neighbor' distances between two point clouds (formerly named "Hausdorff distance") More...
 
static int computeCloud2MeshDistances (GenericIndexedCloudPersist *pointCloud, GenericIndexedMesh *mesh, Cloud2MeshDistancesComputationParams &params, GenericProgressCallback *progressCb=nullptr, DgmOctree *cloudOctree=nullptr)
 Computes the distances between a point cloud and a mesh. More...
 
static int computeCloud2MeshDistancesWithOctree (const DgmOctree *octree, const GridAndMeshIntersection &intersection, Cloud2MeshDistancesComputationParams &params, GenericProgressCallback *progressCb=nullptr)
 Computes the distances between a point cloud and a mesh projected into a grid structure. More...
 
static int computePoint2MeshDistancesWithOctree (const CCVector3 &P, ScalarType &distance, const GridAndMeshIntersection &intersection, Cloud2MeshDistancesComputationParams &params)
 Computes the distances between a point and a mesh projected into a grid structure. More...
 
static int computeApproxCloud2CloudDistance (GenericIndexedCloudPersist *comparedCloud, GenericIndexedCloudPersist *referenceCloud, unsigned char octreeLevel, PointCoordinateType maxSearchDist=0, GenericProgressCallback *progressCb=nullptr, DgmOctree *compOctree=nullptr, DgmOctree *refOctree=nullptr)
 Computes approximate distances between two point clouds. More...
 
static ScalarType computePoint2TriangleDistance (const CCVector3 *P, const GenericTriangle *theTriangle, bool signedDistances, CCVector3 *nearestP=nullptr)
 Computes the distance between a point and a triangle. More...
 
static ScalarType computePoint2PlaneDistance (const CCVector3 *P, const PointCoordinateType *planeEquation)
 Computes the (signed) distance between a point and a plane. More...
 
static ScalarType computePoint2LineSegmentDistSquared (const CCVector3 *point, const CCVector3 *start, const CCVector3 *end)
 Computes the squared distance between a point and a line segment. More...
 
static int computeCloud2ConeEquation (GenericIndexedCloudPersist *cloud, const CCVector3 &coneP1, const CCVector3 &coneP2, const PointCoordinateType coneR1, const PointCoordinateType coneR2, bool signedDistances=true, bool solutionType=false, double *rms=nullptr)
 Computes the distance between each point in a cloud and a cone. More...
 
static int computeCloud2CylinderEquation (GenericIndexedCloudPersist *cloud, const CCVector3 &cylinderP1, const CCVector3 &cylinderP2, const PointCoordinateType cylinderRadius, bool signedDistances=true, bool solutionType=false, double *rms=nullptr)
 Computes the distance between each point in a cloud and a cylinder. More...
 
static int computeCloud2SphereEquation (GenericIndexedCloudPersist *cloud, const CCVector3 &sphereCenter, const PointCoordinateType sphereRadius, bool signedDistances=true, double *rms=nullptr)
 Computes the distance between each point in a cloud and a sphere. More...
 
static int computeCloud2PlaneEquation (GenericIndexedCloudPersist *cloud, const PointCoordinateType *planeEquation, bool signedDistances=true, double *rms=nullptr)
 Computes the distance between each point in a cloud and a plane. More...
 
static int computeCloud2RectangleEquation (GenericIndexedCloudPersist *cloud, PointCoordinateType widthX, PointCoordinateType widthY, const SquareMatrix &rotationTransform, const CCVector3 &center, bool signedDistances=true, double *rms=nullptr)
 Computes the distance between each point in a cloud and a rectangle. More...
 
static int computeCloud2BoxEquation (GenericIndexedCloudPersist *cloud, const CCVector3 &boxDimensions, const SquareMatrix &rotationTransform, const CCVector3 &boxCenter, bool signedDistances=true, double *rms=nullptr)
 Computes the distance between each point in a cloud and a box. More...
 
static int computeCloud2PolylineEquation (GenericIndexedCloudPersist *cloud, const Polyline *polyline, double *rms=nullptr)
 Computes the distance between each point in a cloud and a polyline. More...
 
static ScalarType ComputeCloud2PlaneDistance (GenericCloud *cloud, const PointCoordinateType *planeEquation, ERROR_MEASURES measureType)
 Computes the "distance" (see ERROR_MEASURES) between a point cloud and a plane. More...
 
static ScalarType ComputeCloud2PlaneRobustMax (GenericCloud *cloud, const PointCoordinateType *planeEquation, float percent)
 Computes the maximum distance between a point cloud and a plane. More...
 
static ScalarType ComputeCloud2PlaneMaxDistance (GenericCloud *cloud, const PointCoordinateType *planeEquation)
 Computes the maximum distance between a point cloud and a plane. More...
 
static ScalarType computeCloud2PlaneDistanceRMS (GenericCloud *cloud, const PointCoordinateType *planeEquation)
 Computes the Root Mean Square (RMS) distance between a cloud and a plane. More...
 
static PointCoordinateType ComputeSquareDistToSegment (const CCVector2 &P, const CCVector2 &A, const CCVector2 &B, bool onlyOrthogonal=false)
 Returns the (squared) distance from a point to a segment. More...
 
static bool computeGeodesicDistances (GenericIndexedCloudPersist *cloud, unsigned seedPointIndex, unsigned char octreeLevel, GenericProgressCallback *progressCb=nullptr)
 Computes geodesic distances over a point cloud "surface" (starting from a seed point) More...
 
static int diff (GenericIndexedCloudPersist *comparedCloud, GenericIndexedCloudPersist *referenceCloud, GenericProgressCallback *progressCb=nullptr)
 Computes the differences between two scalar fields associated to equivalent point clouds. More...
 
static SOReturnCode synchronizeOctrees (GenericIndexedCloudPersist *comparedCloud, GenericIndexedCloudPersist *referenceCloud, DgmOctree *&comparedOctree, DgmOctree *&referenceOctree, PointCoordinateType maxSearchDist=0, GenericProgressCallback *progressCb=nullptr)
 Synchronizes (and re-build if necessary) two octrees. More...
 
static bool MultiThreadSupport ()
 Returns whether multi-threading (parallel) computation is supported or not.
 

Static Protected Member Functions

static bool computeCellHausdorffDistance (const DgmOctree::octreeCell &cell, void **additionalParameters, NormalizedProgress *nProgress=nullptr)
 Computes the "nearest neighbor distance" without local modeling for all points of an octree cell. More...
 
static bool computeCellHausdorffDistanceWithLocalModel (const DgmOctree::octreeCell &cell, void **additionalParameters, NormalizedProgress *nProgress=nullptr)
 Computes the "nearest neighbor distance" with local modeling for all points of an octree cell. More...
 

Detailed Description

Several entity-to-entity distances computation algorithms (cloud-cloud, cloud-mesh, point-triangle, etc.)

Member Enumeration Documentation

◆ ERROR_MEASURES

Error estimators.

Enumerator
RMS 

Root Mean Square error

MAX_DIST_68_PERCENT 

Max distance @ 68% (1 sigma)

MAX_DIST_95_PERCENT 

Max distance @ 98% (2 sigmas)

MAX_DIST_99_PERCENT 

Max distance @ 99% (3 sigmas)

MAX_DIST 

Max distance

Member Function Documentation

◆ computeApproxCloud2CloudDistance()

int DistanceComputationTools::computeApproxCloud2CloudDistance ( GenericIndexedCloudPersist comparedCloud,
GenericIndexedCloudPersist referenceCloud,
unsigned char  octreeLevel,
PointCoordinateType  maxSearchDist = 0,
GenericProgressCallback progressCb = nullptr,
DgmOctree compOctree = nullptr,
DgmOctree refOctree = nullptr 
)
static

Computes approximate distances between two point clouds.

This methods uses an exact Distance Transform to approximate the real distances. Therefore, the greater the octree level is (it is used to determine the grid step), the finer the result will be (but more memory and time will be needed).

Parameters
comparedCloudthe compared cloud
referenceCloudthe reference cloud
octreeLevelthe octree level at which to compute the Distance Transform
maxSearchDistmax search distance (or any negative value if no max distance is defined)
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
compOctreethe pre-computed octree of the compared cloud (warning: both octrees must have the same cubical bounding-box - it is automatically computed if 0)
refOctreethe pre-computed octree of the reference cloud (warning: both octrees must have the same cubical bounding-box - it is automatically computed if 0)
Returns
negative error code or a positive value in case of success

◆ computeCellHausdorffDistance()

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

Computes the "nearest neighbor distance" without local modeling for all points of an octree cell.

This method has the generic syntax of a "cellular function" (see DgmOctree::localFunctionPtr). Specific parameters are transmitted via the "additionalParameters" structure. There are 3 additional parameters :

  • (GenericCloud*) the compared cloud
  • (GenericCloud*) the reference cloud
  • (DgmOctree*) the octree corresponding to the compared cloud
    Parameters
    cellstructure describing the cell on which processing is applied
    additionalParameterssee method description
    nProgressoptional (normalized) progress notification (per-point)

◆ computeCellHausdorffDistanceWithLocalModel()

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

Computes the "nearest neighbor distance" with local modeling for all points of an octree cell.

This method has the generic syntax of a "cellular function" (see DgmOctree::localFunctionPtr). Specific parameters are transmitted via the "additionalParameters" structure. There are 4 additional parameters :

  • (GenericCloud*) the compared cloud
  • (GenericCloud*) the reference cloud
  • (DgmOctree*) the octree corresponding to the compared cloud
  • (CC_LOCAL_MODEL_TYPES*) type of local model to apply
    Parameters
    cellstructure describing the cell on which processing is applied
    additionalParameterssee method description
    nProgressoptional (normalized) progress notification (per-point)

◆ computeCloud2BoxEquation()

int DistanceComputationTools::computeCloud2BoxEquation ( GenericIndexedCloudPersist cloud,
const CCVector3 boxDimensions,
const SquareMatrix rotationTransform,
const CCVector3 boxCenter,
bool  signedDistances = true,
double *  rms = nullptr 
)
static

Computes the distance between each point in a cloud and a box.

Parameters
[in]clouda 3D point cloud
[in]boxDimensionsbox 3D dimensions
[in]rotationTransformbox position in space
[in]boxCenterbox center point
[in]signedDistanceswhether to compute the signed or positive (absolute) distance (optional)
[out]rmswill be set with the Root Mean Square (RMS) distance between a cloud and a box (optional)
Returns
negative error code or a positive value in case of success

◆ computeCloud2CloudDistances()

int DistanceComputationTools::computeCloud2CloudDistances ( GenericIndexedCloudPersist comparedCloud,
GenericIndexedCloudPersist referenceCloud,
Cloud2CloudDistancesComputationParams params,
GenericProgressCallback progressCb = nullptr,
DgmOctree compOctree = nullptr,
DgmOctree refOctree = nullptr 
)
static

Computes the 'nearest neighbor' distances between two point clouds (formerly named "Hausdorff distance")

The main algorithm and its different versions (with or without local modeling) are described in Daniel Girardeau-Montaut's PhD manuscript (Chapter 2, section 2.3). It is the standard way to compare directly two dense point clouds.

Warning
The current scalar field of the compared cloud should be enabled. By default it will be reset to NAN_VALUE but one can avoid this by defining the Cloud2CloudDistancesComputationParams::resetFormerDistances parameters to false. But even in this case, only values above Cloud2CloudDistancesComputationParams::maxSearchDist will remain untouched.
Max search distance (Cloud2CloudDistancesComputationParams::maxSearchDist > 0) is not compatible with the determination of the Closest Point Set (Cloud2CloudDistancesComputationParams::CPSet)
Parameters
comparedCloudthe compared cloud (the distances will be computed for each point of this cloud)
referenceCloudthe reference cloud (the nearest neigbhor will be determined among these points)
paramsdistance computation parameters
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
compOctreethe pre-computed octree of the compared cloud (warning: both octrees must have the same cubical bounding-box - it is automatically computed if 0)
refOctreethe pre-computed octree of the reference cloud (warning: both octrees must have the same cubical bounding-box - it is automatically computed if 0)
Returns
0 if ok, a negative value otherwise

◆ computeCloud2ConeEquation()

int DistanceComputationTools::computeCloud2ConeEquation ( GenericIndexedCloudPersist cloud,
const CCVector3 coneP1,
const CCVector3 coneP2,
const PointCoordinateType  coneR1,
const PointCoordinateType  coneR2,
bool  signedDistances = true,
bool  solutionType = false,
double *  rms = nullptr 
)
static

Computes the distance between each point in a cloud and a cone.

Parameters
[in]clouda 3D point cloud
[in]coneP1center point associated with the larger radii
[in]coneP2center point associated with the smaller radii
[in]coneR1cone radius at coneP1 (larger)
[in]coneR2cone radius at coneP2 (smaller)
[in]signedDistanceswhether to compute the signed or positive (absolute) distance (optional)
[in]solutionTypeif true the scalar field will be set to which solution was selected 1-4 (optional)
[out]rmswill be set with the Root Mean Square (RMS) distance between a cloud and a cylinder (optional)
Returns
negative error code or a positive value in case of success

◆ computeCloud2CylinderEquation()

int DistanceComputationTools::computeCloud2CylinderEquation ( GenericIndexedCloudPersist cloud,
const CCVector3 cylinderP1,
const CCVector3 cylinderP2,
const PointCoordinateType  cylinderRadius,
bool  signedDistances = true,
bool  solutionType = false,
double *  rms = nullptr 
)
static

Computes the distance between each point in a cloud and a cylinder.

Parameters
[in]clouda 3D point cloud
[in]cylinderP1center bottom point
[in]cylinderP2center top point
[in]cylinderRadiuscylinder radius
[in]signedDistanceswhether to compute the signed or positive (absolute) distance (optional)
[in]solutionTypeif true the scalar field will be set to which solution was selected 1-4 (optional)
[out]rmswill be set with the Root Mean Square (RMS) distance between a cloud and a cylinder (optional)
Returns
negative error code or a positive value in case of success

◆ computeCloud2MeshDistances()

int DistanceComputationTools::computeCloud2MeshDistances ( GenericIndexedCloudPersist pointCloud,
GenericIndexedMesh mesh,
Cloud2MeshDistancesComputationParams params,
GenericProgressCallback progressCb = nullptr,
DgmOctree cloudOctree = nullptr 
)
static

Computes the distances between a point cloud and a mesh.

The algorithm, inspired from METRO by Cignoni et al., is described in Daniel Girardeau-Montaut's PhD manuscript (Chapter 2, section 2.2). It is the general way to compare a point cloud with a triangular mesh.

Parameters
pointCloudthe compared cloud (the distances will be computed on these points)
meshthe reference mesh (the distances will be computed relatively to its triangles)
paramsdistance computation parameters
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
cloudOctreethe pre-computed octree of the compared cloud (warning: its bounding box should be equal to the union of both point cloud and mesh bbs and it should be cubical - it is automatically computed if 0)
Returns
0 if ok, a negative value otherwise

◆ computeCloud2MeshDistancesWithOctree()

int DistanceComputationTools::computeCloud2MeshDistancesWithOctree ( const DgmOctree octree,
const GridAndMeshIntersection intersection,
Cloud2MeshDistancesComputationParams params,
GenericProgressCallback progressCb = nullptr 
)
static

Computes the distances between a point cloud and a mesh projected into a grid structure.

This method is used by computeCloud2MeshDistances, after intersectMeshWithOctree has been called.

Parameters
octreethe cloud octree
intersectiona specific structure corresponding the intersection of the mesh with the grid
paramsparameters
progressCbthe client method can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
Returns
-1 if an error occurred (e.g. not enough memory) and 0 otherwise

◆ ComputeCloud2PlaneDistance()

ScalarType DistanceComputationTools::ComputeCloud2PlaneDistance ( GenericCloud cloud,
const PointCoordinateType *  planeEquation,
ERROR_MEASURES  measureType 
)
static

Computes the "distance" (see ERROR_MEASURES) between a point cloud and a plane.

Parameters
clouda point cloud
planeEquationplane equation: [a,b,c,d] as 'ax+by+cz=d'
measureTypemeasure type

◆ computeCloud2PlaneDistanceRMS()

ScalarType DistanceComputationTools::computeCloud2PlaneDistanceRMS ( GenericCloud cloud,
const PointCoordinateType *  planeEquation 
)
static

Computes the Root Mean Square (RMS) distance between a cloud and a plane.

Sums the squared distances between each point of the cloud and the plane, then computes the mean value.

Warning
this method uses the cloud global iterator
Parameters
clouda point cloud
planeEquationplane equation: [a,b,c,d] as 'ax+by+cz=d'
Returns
the RMS of distances (or NaN if an error occurred)

◆ computeCloud2PlaneEquation()

int DistanceComputationTools::computeCloud2PlaneEquation ( GenericIndexedCloudPersist cloud,
const PointCoordinateType *  planeEquation,
bool  signedDistances = true,
double *  rms = nullptr 
)
static

Computes the distance between each point in a cloud and a plane.

Parameters
[in]clouda 3D point cloud
[in]planeEquationplane equation: [a,b,c,d] as 'ax+by+cz=d' with norm(a,bc)==1
[in]signedDistanceswhether to compute the signed or positive (absolute) distance (optional)
[out]rmswill be set with the Root Mean Square (RMS) distance between a cloud and a plane (optional)
Returns
negative error code or a positive value in case of success

◆ ComputeCloud2PlaneMaxDistance()

ScalarType DistanceComputationTools::ComputeCloud2PlaneMaxDistance ( GenericCloud cloud,
const PointCoordinateType *  planeEquation 
)
static

Computes the maximum distance between a point cloud and a plane.

Warning
this method uses the cloud global iterator
Parameters
clouda point cloud
planeEquationplane equation: [a,b,c,d] as 'ax+by+cz=d'
Returns
the max distance between the point and the plane

◆ ComputeCloud2PlaneRobustMax()

ScalarType DistanceComputationTools::ComputeCloud2PlaneRobustMax ( GenericCloud cloud,
const PointCoordinateType *  planeEquation,
float  percent 
)
static

Computes the maximum distance between a point cloud and a plane.

Warning
this method uses the cloud global iterator
Parameters
clouda point cloud
planeEquationplane equation: [a,b,c,d] as 'ax+by+cz=d'
percentpercentage of lowest values ignored
Returns
the max distance @ 'percent' % between the point and the plane

◆ computeCloud2PolylineEquation()

int DistanceComputationTools::computeCloud2PolylineEquation ( GenericIndexedCloudPersist cloud,
const Polyline polyline,
double *  rms = nullptr 
)
static

Computes the distance between each point in a cloud and a polyline.

Parameters
[in]clouda 3D point cloud
[in]polylinethe polyline to measure to
[out]rmswill be set with the Root Mean Square (RMS) distance between a cloud and a plane (optional)
Returns
negative error code or a positive value in case of success

◆ computeCloud2RectangleEquation()

int DistanceComputationTools::computeCloud2RectangleEquation ( GenericIndexedCloudPersist cloud,
PointCoordinateType  widthX,
PointCoordinateType  widthY,
const SquareMatrix rotationTransform,
const CCVector3 center,
bool  signedDistances = true,
double *  rms = nullptr 
)
static

Computes the distance between each point in a cloud and a rectangle.

Parameters
[in]clouda 3D point cloud
[in]widthXrectangle width
[in]widthYrectangle height
[in]rotationTransform(plane) rectangle position in space
[in]center(plane) rectangle center point
[in]signedDistanceswhether to compute the signed or positive (absolute) distance (optional)
[out]rmswill be set with the Root Mean Square (RMS) distance between a cloud and a rectangle (optional)
Returns
negative error code or a positive value in case of success

◆ computeCloud2SphereEquation()

int DistanceComputationTools::computeCloud2SphereEquation ( GenericIndexedCloudPersist cloud,
const CCVector3 sphereCenter,
const PointCoordinateType  sphereRadius,
bool  signedDistances = true,
double *  rms = nullptr 
)
static

Computes the distance between each point in a cloud and a sphere.

Parameters
[in]clouda 3D point cloud
[in]sphereCentersphere 3d center point
[in]sphereRadiussphere radius
[in]signedDistanceswhether to compute the signed or positive (absolute) distance (optional)
[out]rmswill be set with the Root Mean Square (RMS) distance between a cloud and a sphere (optional)
Returns
negative error code or a positive value in case of success

◆ computeGeodesicDistances()

bool DistanceComputationTools::computeGeodesicDistances ( GenericIndexedCloudPersist cloud,
unsigned  seedPointIndex,
unsigned char  octreeLevel,
GenericProgressCallback progressCb = nullptr 
)
static

Computes geodesic distances over a point cloud "surface" (starting from a seed point)

This method uses the FastMarching algorithm. Thereofre it needs an octree level as input parameter in order to create the corresponding 3D grid. The greater this level is, the finer the result will be, but more memory will be required as well. Moreover to get an interesting result the cells size should not be too small (the propagation will be stoped more easily on any encountered 'hole').

Parameters
cloudthe point cloud
seedPointIndexthe index of the point from where to start the propagation
octreeLevelthe octree at which to perform the Fast Marching propagation
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
Returns
true if the method succeeds

◆ computePoint2LineSegmentDistSquared()

ScalarType DistanceComputationTools::computePoint2LineSegmentDistSquared ( const CCVector3 point,
const CCVector3 start,
const CCVector3 end 
)
static

Computes the squared distance between a point and a line segment.

Parameters
pointa 3D point
startthe start of line segment
endthe end of line segment
Returns
the squared distance between the point and the line segment

◆ computePoint2MeshDistancesWithOctree()

int DistanceComputationTools::computePoint2MeshDistancesWithOctree ( const CCVector3 P,
ScalarType &  distance,
const GridAndMeshIntersection intersection,
Cloud2MeshDistancesComputationParams params 
)
static

Computes the distances between a point and a mesh projected into a grid structure.

Warning
Distance Transform acceleration is not supported.
No multi-thread support.
No Closest Point Set support.
Parameters
Pthe point
distancethe output distance
intersectiona specific structure corresponding the intersection of the mesh with the grid
paramsparameters
Returns
-1 if an error occurred (e.g. not enough memory) and 0 otherwise

◆ computePoint2PlaneDistance()

ScalarType DistanceComputationTools::computePoint2PlaneDistance ( const CCVector3 P,
const PointCoordinateType *  planeEquation 
)
static

Computes the (signed) distance between a point and a plane.

Parameters
Pa 3D point
planeEquationplane equation: [a,b,c,d] as 'ax+by+cz=d' with norm(a,bc)==1
Returns
the signed distance between the point and the plane

◆ computePoint2TriangleDistance()

ScalarType DistanceComputationTools::computePoint2TriangleDistance ( const CCVector3 P,
const GenericTriangle theTriangle,
bool  signedDistances,
CCVector3 nearestP = nullptr 
)
static

Computes the distance between a point and a triangle.

Warning
if not signed, the returned distance is SQUARED!
\param P                            a 3D point
\param theTriangle          a 3D triangle
\param signedDistances      whether to compute the signed or positive (SQUARED) distance
\param nearestP                     optional: returns the nearest point on the triangle

\return the distance between the point and the triangle

◆ ComputeSquareDistToSegment()

PointCoordinateType DistanceComputationTools::ComputeSquareDistToSegment ( const CCVector2 P,
const CCVector2 A,
const CCVector2 B,
bool  onlyOrthogonal = false 
)
static

Returns the (squared) distance from a point to a segment.

Parameters
P3D point
Afirst point of the segment
Bfirst point of the segment
onlyOrthogonalcomputes distance only if P lies 'in front' of AB (returns -1.0 otherwise)
Returns
squared distance (or potentially -1.0 if onlyOrthogonal is true)

◆ diff()

int DistanceComputationTools::diff ( GenericIndexedCloudPersist comparedCloud,
GenericIndexedCloudPersist referenceCloud,
GenericProgressCallback progressCb = nullptr 
)
static

Computes the differences between two scalar fields associated to equivalent point clouds.

The compared cloud should be smaller or equal to the reference cloud. Its points should be at the same position in space as points in the other cloud. The algorithm simply computes the difference between the scalar values associated to each couple of equivalent points.

Warning
The result is stored in the active scalar field (input) of the comparedCloud.
Moreover, the output scalar field should be different than the input scalar field!
Be sure to activate an OUTPUT scalar field on both clouds
Parameters
comparedCloudthe compared cloud
referenceCloudthe reference cloud
progressCbthe client application can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)

◆ synchronizeOctrees()

DistanceComputationTools::SOReturnCode DistanceComputationTools::synchronizeOctrees ( GenericIndexedCloudPersist comparedCloud,
GenericIndexedCloudPersist referenceCloud,
DgmOctree *&  comparedOctree,
DgmOctree *&  referenceOctree,
PointCoordinateType  maxSearchDist = 0,
GenericProgressCallback progressCb = nullptr 
)
static

Synchronizes (and re-build if necessary) two octrees.

Initializes the octrees before computing the distance between two clouds. Check if both octree have the same sizes and limits (in 3D) and rebuild them if necessary.

Parameters
comparedCloudthe cloud corresponding to the first octree
referenceCloudthe cloud corresponding to the second octree
comparedOctreethe first octree
referenceOctreethe second octree
maxSearchDistmax search distance (or any negative value if no max distance is defined)
progressCbthe client method can get some notification of the process progress through this callback mechanism (see GenericProgressCallback)
Returns
return code

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