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

A specific point could structure to handle subsets of points, provided with several geometric processings. More...

#include <Neighbourhood.h>

Collaboration diagram for CCCoreLib::Neighbourhood:
Collaboration graph
[legend]

Public Types

enum  GeomElement { FLAG_DEPRECATED = 0 , FLAG_GRAVITY_CENTER = 1 , FLAG_LS_PLANE = 2 , FLAG_QUADRIC = 4 }
 Geometric properties/elements that can be computed from the set of points (see Neighbourhood::getGeometricalElement)
 
enum  CurvatureType { GAUSSIAN_CURV = 1 , MEAN_CURV , NORMAL_CHANGE_RATE }
 Curvature type.
 
enum  InputVectorsUsage { UseOXYasBase , UseYAsUpDir , None }
 Defines how input vectors of projectPointsOn2DPlane should be used.
 
enum  GeomFeature {
  EigenValuesSum = 1 , Omnivariance , EigenEntropy , Anisotropy ,
  Planarity , Linearity , PCA1 , PCA2 ,
  SurfaceVariation , Sphericity , Verticality , EigenValue1 ,
  EigenValue2 , EigenValue3
}
 Geometric feature computed from eigen values/vectors. More...
 

Public Member Functions

 Neighbourhood (GenericIndexedCloudPersist *associatedCloud)
 Default constructor. More...
 
virtual ~Neighbourhood ()=default
 Default destructor.
 
virtual void reset ()
 Resets structure (depreactes all associated geometrical fetaures)
 
GenericIndexedCloudPersistassociatedCloud () const
 Returns associated cloud.
 
GenericIndexedMeshtriangulateOnPlane (bool duplicateVertices, PointCoordinateType maxEdgeLength, std::string &outputErrorStr)
 Applies 2D Delaunay triangulation. More...
 
GenericIndexedMeshtriangulateFromQuadric (unsigned stepsX, unsigned stepsY)
 Fit a quadric on point set (see getQuadric) then triangulates it inside bounding box.
 
template<class Vec2D >
bool projectPointsOn2DPlane (std::vector< Vec2D > &points2D, const PointCoordinateType *planeEquation=nullptr, CCVector3 *O=nullptr, CCVector3 *X=nullptr, CCVector3 *Y=nullptr, InputVectorsUsage vectorsUsage=None)
 Projects points on the best fitting LS plane. More...
 
double computeFeature (GeomFeature feature)
 Computes the given feature on a set of point. More...
 
ScalarType computeMomentOrder1 (const CCVector3 &P)
 Computes the 1st order moment of a set of point (based on the eigenvalues) More...
 
ScalarType computeRoughness (const CCVector3 &P, const CCVector3 *roughnessUpDir=nullptr)
 Computes the roughness of a point (by fitting a 2D plane on its neighbors) More...
 
ScalarType computeCurvature (const CCVector3 &P, CurvatureType cType)
 Computes the curvature of a set of point (by fitting a 2.5D quadric) More...
 
const CCVector3getGravityCenter ()
 Returns gravity center. More...
 
void setGravityCenter (const CCVector3 &G)
 Sets gravity center. More...
 
const PointCoordinateType * getLSPlane ()
 Returns best interpolating plane equation (Least-square) More...
 
void setLSPlane (const PointCoordinateType eq[4], const CCVector3 &X, const CCVector3 &Y, const CCVector3 &N)
 Sets the best interpolating plane equation (Least-square) More...
 
const CCVector3getLSPlaneX ()
 Returns best interpolating plane (Least-square) 'X' base vector. More...
 
const CCVector3getLSPlaneY ()
 Returns best interpolating plane (Least-square) 'Y' base vector. More...
 
const CCVector3getLSPlaneNormal ()
 Returns best interpolating plane (Least-square) normal vector. More...
 
const PointCoordinateType * getQuadric (Tuple3ub *dims=nullptr)
 Returns the best interpolating 2.5D quadric. More...
 
bool compute3DQuadric (double quadricEquation[10])
 Computes the best interpolating quadric (Least-square) More...
 
SquareMatrixd computeCovarianceMatrix ()
 Computes the covariance matrix.
 
PointCoordinateType computeLargestRadius ()
 Returns the set 'radius' (i.e. the distance between the gravity center and the its farthest point)
 

Static Public Attributes

static constexpr int IGNORE_MAX_EDGE_LENGTH = 0
 
static constexpr bool DUPLICATE_VERTICES = true
 
static constexpr bool DO_NOT_DUPLICATE_VERTICES = false
 

Protected Member Functions

void computeGravityCenter ()
 Computes the gravity center.
 
bool computeLeastSquareBestFittingPlane ()
 Computes the least-square best fitting plane.
 
bool computeQuadric ()
 Computes best fitting 2.5D quadric.
 

Protected Attributes

PointCoordinateType m_quadricEquation [6]
 2.5D Quadric equation More...
 
Tuple3ub m_quadricEquationDirections
 2.5D Quadric equation dimensions More...
 
PointCoordinateType m_lsPlaneEquation [4]
 Least-square best fitting plane parameters. More...
 
CCVector3 m_lsPlaneVectors [3]
 Least-square best fitting plane base vectors. More...
 
CCVector3 m_gravityCenter
 Gravity center. More...
 
unsigned char m_structuresValidity
 Geometrical elements validity (flags)
 
GenericIndexedCloudPersistm_associatedCloud
 Associated cloud.
 

Detailed Description

A specific point could structure to handle subsets of points, provided with several geometric processings.

Typically suited for "nearest neighbours". It implements the GenericIndexCloud interface by inheriting the ReferenceCloud class.

Member Enumeration Documentation

◆ GeomFeature

Geometric feature computed from eigen values/vectors.

Most of them are defined in "Contour detection in unstructured 3D point clouds", Hackel et al, 2016 PCA1 and PCA2 are defined in "3D terrestrial lidar data classification of complex natural scenes using a multi-scale dimensionality criterion: Applications in geomorphology", Brodu and Lague, 2012

Constructor & Destructor Documentation

◆ Neighbourhood()

Neighbourhood::Neighbourhood ( GenericIndexedCloudPersist associatedCloud)
explicit

Default constructor.

Parameters
associatedCloudreference cloud

Member Function Documentation

◆ compute3DQuadric()

bool Neighbourhood::compute3DQuadric ( double  quadricEquation[10])

Computes the best interpolating quadric (Least-square)

Parameters
[out]quadricEquationan array of 10 coefficients [a,b,c,d,e,f,g,l,m,n] such as a.x^2+b.y^2+c.z^2+2e.x.y+2f.y.z+2g.z.x+2l.x+2m.y+2n.z+d = 0
Returns
success

◆ computeCurvature()

ScalarType Neighbourhood::computeCurvature ( const CCVector3 P,
CurvatureType  cType 
)

Computes the curvature of a set of point (by fitting a 2.5D quadric)

Returns
curvature value at a given position P or CCCoreLib::NAN_VALUE if the computation failed
Warning
The curvature value is always unsigned

◆ computeFeature()

double Neighbourhood::computeFeature ( GeomFeature  feature)

Computes the given feature on a set of point.

Returns
feature value

◆ computeMomentOrder1()

ScalarType Neighbourhood::computeMomentOrder1 ( const CCVector3 P)

Computes the 1st order moment of a set of point (based on the eigenvalues)

Returns
1st order moment at a given position P DGM: The article states that the result should be between 0 and 1, but this is actually wrong (as (a + b)^2 can be > a^2 + b^2)

◆ computeRoughness()

ScalarType Neighbourhood::computeRoughness ( const CCVector3 P,
const CCVector3 roughnessUpDir = nullptr 
)

Computes the roughness of a point (by fitting a 2D plane on its neighbors)

Parameters
Ppoint for which to compute the roughness value
roughnessUpDirup direction to compute a signed roughness value (optional)
Returns
roughness value at a given position P
Warning
The point P shouldn't be in the set of points

◆ getGravityCenter()

const CCVector3 * Neighbourhood::getGravityCenter ( )

Returns gravity center.

Returns
0 if computation failed

◆ getLSPlane()

const PointCoordinateType * Neighbourhood::getLSPlane ( )

Returns best interpolating plane equation (Least-square)

Returns an array of the form [a,b,c,d] such as: ax + by + cz = d

Returns
0 if computation failed

◆ getLSPlaneNormal()

const CCVector3 * Neighbourhood::getLSPlaneNormal ( )

Returns best interpolating plane (Least-square) normal vector.

This corresponds to the smallest eigen value (i.e. the second largest cloud dimension)

Returns
0 if computation failed

◆ getLSPlaneX()

const CCVector3 * Neighbourhood::getLSPlaneX ( )

Returns best interpolating plane (Least-square) 'X' base vector.

This corresponds to the largest eigen value (i.e. the largest cloud dimension)

Returns
0 if computation failed

◆ getLSPlaneY()

const CCVector3 * Neighbourhood::getLSPlaneY ( )

Returns best interpolating plane (Least-square) 'Y' base vector.

This corresponds to the second largest eigen value (i.e. the second largest cloud dimension)

Returns
0 if computation failed

◆ getQuadric()

const PointCoordinateType * Neighbourhood::getQuadric ( Tuple3ub dims = nullptr)

Returns the best interpolating 2.5D quadric.

Returns an array of the form [a,b,c,d,e,f] such as: Z = a + b.X + c.Y + d.X^2 + e.X.Y + f.Y^2

Warning
: 'X','Y' and 'Z' are output in dims (optional): dims = [index(X),index(Y),index(Z)] where: 0=x, 1=y, 2=z
Returns
0 if computation failed

◆ projectPointsOn2DPlane()

template<class Vec2D >
bool CCCoreLib::Neighbourhood::projectPointsOn2DPlane ( std::vector< Vec2D > &  points2D,
const PointCoordinateType *  planeEquation = nullptr,
CCVector3 O = nullptr,
CCVector3 X = nullptr,
CCVector3 Y = nullptr,
InputVectorsUsage  vectorsUsage = None 
)
inline

Projects points on the best fitting LS plane.

Projected points are stored in the points2D vector.

Parameters
points2Doutput set
planeEquationcustom plane equation (otherwise the default Neighbouhood's one is used)
Oif set, the local plane base origin will be output here
Xif set, the local plane base X vector will be output here
Yif set, the local plane base Y vector will be output here
vectorsUsageDefines how input vectors should be used
Returns
success

◆ setGravityCenter()

void Neighbourhood::setGravityCenter ( const CCVector3 G)

Sets gravity center.

Handle with care!

Parameters
Ggravity center

◆ setLSPlane()

void Neighbourhood::setLSPlane ( const PointCoordinateType  eq[4],
const CCVector3 X,
const CCVector3 Y,
const CCVector3 N 
)

Sets the best interpolating plane equation (Least-square)

Handle with care!

Parameters
eqplane equation (ax + by + cz = d)
Xlocal base X vector
Ylocal base Y vector
Nnormal vector

◆ triangulateOnPlane()

GenericIndexedMesh * Neighbourhood::triangulateOnPlane ( bool  duplicateVertices,
PointCoordinateType  maxEdgeLength,
std::string &  outputErrorStr 
)

Applies 2D Delaunay triangulation.

Cloud selection is first projected on the best least-square plane.

Parameters
duplicateVerticeswhether to duplicate vertices (a new point cloud is created) or to use the associated one)
maxEdgeLengthmax edge length for output triangles (IGNORE_MAX_EDGE_LENGTH = ignored)
outputErrorStrerror (if any)

Member Data Documentation

◆ m_gravityCenter

CCVector3 CCCoreLib::Neighbourhood::m_gravityCenter
protected

Gravity center.

Only valid if 'structuresValidity & GRAVITY_CENTER != 0'.

◆ m_lsPlaneEquation

PointCoordinateType CCCoreLib::Neighbourhood::m_lsPlaneEquation[4]
protected

Least-square best fitting plane parameters.

Array [a,b,c,d] such that ax+by+cz = d Only valid if 'structuresValidity & LS_PLANE != 0'.

◆ m_lsPlaneVectors

CCVector3 CCCoreLib::Neighbourhood::m_lsPlaneVectors[3]
protected

Least-square best fitting plane base vectors.

Only valid if 'structuresValidity & LS_PLANE != 0'.

◆ m_quadricEquation

PointCoordinateType CCCoreLib::Neighbourhood::m_quadricEquation[6]
protected

2.5D Quadric equation

Array [a,b,c,d,e,f] such that Z = a + b.X + c.Y + d.X^2 + e.X.Y + f.Y^2.

Warning
: 'X','Y' and 'Z' are defined by 'm_quadricEquationDirections' Only valid if 'structuresValidity & QUADRIC != 0'.

◆ m_quadricEquationDirections

Tuple3ub CCCoreLib::Neighbourhood::m_quadricEquationDirections
protected

2.5D Quadric equation dimensions

Array (index(X),index(Y),index(Z)) where: 0=x, 1=y, 2=z Only valid if 'structuresValidity & QUADRIC != 0'.


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