ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccNormalVectors Class Reference

Compressed normal vectors handler. More...

#include <ecvNormalVectors.h>

Public Types

enum  Orientation {
  PLUS_X = 0 , MINUS_X = 1 , PLUS_Y = 2 , MINUS_Y = 3 ,
  PLUS_Z = 4 , MINUS_Z = 5 , PLUS_BARYCENTER , MINUS_BARYCENTER = 7 ,
  PLUS_ORIGIN = 8 , MINUS_ORIGIN = 9 , PREVIOUS = 10 , PLUS_SENSOR_ORIGIN ,
  MINUS_SENSOR_ORIGIN , UNDEFINED = 255
}
 'Default' orientations More...
 

Public Member Functions

const CCVector3getNormal (unsigned normIndex) const
 Returns the precomputed normal corresponding to a given compressed index. More...
 
CCVector3getNormal (unsigned normIndex)
 
const std::vector< CCVector3 > & getNormals () const
 
std::vector< CCVector3 > & getNormals ()
 
virtual ~ccNormalVectors ()
 Default destructor. More...
 
bool enableNormalHSVColorsArray ()
 Allocates normal HSV colors array. More...
 
const ecvColor::RgbgetNormalHSVColor (unsigned index) const
 Returns the HSV color equivalent to a given compressed normal index. More...
 
const std::vector< ecvColor::Rgb > & getNormalHSVColorArray () const
 Returns the HSV color array. More...
 

Static Public Member Functions

static ccNormalVectorsGetUniqueInstance ()
 Returns unique instance. More...
 
static void ReleaseUniqueInstance ()
 Releases unique instance. More...
 
static unsigned GetNumberOfVectors ()
 Returns the number of compressed normal vectors. More...
 
static const CCVector3GetNormal (unsigned normIndex)
 Static access to ccNormalVectors::getNormal. More...
 
static CCVector3GetNormalPtr (unsigned normIndex)
 
static const std::vector< CCVector3 > & GetNormals ()
 
static std::vector< CCVector3 > & GetNormalsPtr ()
 
static CompressedNormType GetNormIndex (const PointCoordinateType N[])
 Returns the compressed index corresponding to a normal vector. More...
 
static CompressedNormType GetNormIndex (const CCVector3 &N)
 Returns the compressed index corresponding to a normal vector (shortcut) More...
 
static bool ComputeCloudNormals (ccGenericPointCloud *cloud, NormsIndexesTableType &theNormsCodes, CV_LOCAL_MODEL_TYPES localModel, PointCoordinateType localRadius, Orientation preferredOrientation=UNDEFINED, cloudViewer::GenericProgressCallback *progressCb=nullptr, cloudViewer::DgmOctree *inputOctree=nullptr)
 Computes normal at each point of a given cloud. More...
 
static PointCoordinateType GuessNaiveRadius (ccGenericPointCloud *cloud)
 
static PointCoordinateType GuessBestRadius (ccGenericPointCloud *cloud, cloudViewer::DgmOctree *cloudOctree=nullptr, cloudViewer::GenericProgressCallback *progressCb=nullptr)
 
static bool UpdateNormalOrientations (ccGenericPointCloud *theCloud, NormsIndexesTableType &theNormsCodes, Orientation preferredOrientation)
 Updates normals orientation based on a preferred orientation. More...
 
static void ConvertNormalToStrikeAndDip (const CCVector3 &N, PointCoordinateType &strike_deg, PointCoordinateType &dip_deg)
 
static void ConvertNormalToDipAndDipDir (const CCVector3 &N, PointCoordinateType &dip_deg, PointCoordinateType &dipDir_deg)
 Converts a normal vector to geological 'dip direction & dip' parameters. More...
 
static CCVector3 ConvertDipAndDipDirToNormal (PointCoordinateType dip_deg, PointCoordinateType dipDir_deg, bool upward=true)
 
static QString ConvertStrikeAndDipToString (double &strike_deg, double &dip_deg)
 
static QString ConvertDipAndDipDirToString (PointCoordinateType dip_deg, PointCoordinateType dipDir_deg)
 Converts geological 'dip direction & dip' parameters to a string. More...
 
static void ConvertNormalToHSV (const CCVector3 &N, float &H, float &S, float &V)
 Converts a normal vector to HSV color space. More...
 
static ecvColor::Rgb ConvertNormalToRGB (const CCVector3 &N)
 Converts a normal vector to RGB color space. More...
 
static bool ComputeNormalWithLS (cloudViewer::GenericIndexedCloudPersist *pointAndNeighbors, CCVector3 &N)
 Helper: computes the normal (with best LS fit) More...
 
static bool ComputeNormalWithTri (cloudViewer::GenericIndexedCloudPersist *pointAndNeighbors, CCVector3 &N)
 Helper: computes the normal (with Delaunay 2.5D) More...
 
static bool ComputeNormalWithQuadric (cloudViewer::GenericIndexedCloudPersist *points, const CCVector3 &P, CCVector3 &N)
 Helper: computes the normal (with Delaunay 2.5D) More...
 

Protected Member Functions

 ccNormalVectors ()
 Default constructor. More...
 
bool init ()
 Inits internal structures. More...
 

Static Protected Member Functions

static bool ComputeNormsAtLevelWithQuadric (const cloudViewer::DgmOctree::octreeCell &cell, void **additionalParameters, cloudViewer::NormalizedProgress *nProgress=nullptr)
 Cellular method for octree-based normal computation. More...
 
static bool ComputeNormsAtLevelWithLS (const cloudViewer::DgmOctree::octreeCell &cell, void **additionalParameters, cloudViewer::NormalizedProgress *nProgress=nullptr)
 Cellular method for octree-based normal computation. More...
 
static bool ComputeNormsAtLevelWithTri (const cloudViewer::DgmOctree::octreeCell &cell, void **additionalParameters, cloudViewer::NormalizedProgress *nProgress=nullptr)
 Cellular method for octree-based normal computation. More...
 

Protected Attributes

std::vector< CCVector3m_theNormalVectors
 Compressed normal vectors. More...
 
std::vector< ecvColor::Rgbm_theNormalHSVColors
 'HSV' colors corresponding to each compressed normal index More...
 

Detailed Description

Compressed normal vectors handler.

Definition at line 20 of file ecvNormalVectors.h.

Member Enumeration Documentation

◆ Orientation

'Default' orientations

Enumerator
PLUS_X 

N.x always positive.

MINUS_X 

N.x always negative.

PLUS_Y 

N.y always positive.

MINUS_Y 

N.y always negative.

PLUS_Z 

N.z always positive.

MINUS_Z 

N.z always negative.

PLUS_BARYCENTER 

Normals always opposite to the cloud barycenter.

MINUS_BARYCENTER 

Normals always towards the cloud barycenter.

PLUS_ORIGIN 

Normals always opposite to the origin.

MINUS_ORIGIN 

Normals always towards the origin.

PREVIOUS 

Re-use previous normal (if any)

PLUS_SENSOR_ORIGIN 

Normals opposite to the associated sensor origin (if any, and if multiple, the first one will be used)

MINUS_SENSOR_ORIGIN 

Normals towards the associated sensor origin (if any, and if multiple, the first one will be used)

UNDEFINED 

Undefined (no orientation is required)

Definition at line 70 of file ecvNormalVectors.h.

Constructor & Destructor Documentation

◆ ~ccNormalVectors()

ccNormalVectors::~ccNormalVectors ( )
virtual

Default destructor.

Definition at line 51 of file ecvNormalVectors.cpp.

◆ ccNormalVectors()

ccNormalVectors::ccNormalVectors ( )
protected

Default constructor.

Shouldn't be called directly. Use 'GetUniqueInstance' instead.

Definition at line 49 of file ecvNormalVectors.cpp.

References init().

Referenced by GetUniqueInstance().

Member Function Documentation

◆ ComputeCloudNormals()

bool ccNormalVectors::ComputeCloudNormals ( ccGenericPointCloud cloud,
NormsIndexesTableType theNormsCodes,
CV_LOCAL_MODEL_TYPES  localModel,
PointCoordinateType  localRadius,
Orientation  preferredOrientation = UNDEFINED,
cloudViewer::GenericProgressCallback progressCb = nullptr,
cloudViewer::DgmOctree inputOctree = nullptr 
)
static

Computes normal at each point of a given cloud.

Parameters
cloudpoint cloud on which to process the normals.
theNormsCodesarray in which the normals indexes are stored
localModelwhich kind of model to use for the computation (LS = plane, QUADRIC = quadratic Height Function, TRI = triangulation)
localRadiuslocal neighborhood radius (not necessary for TRI)
preferredOrientationspecifies a preferred orientation for normals (optional)
progressCbprogress notification (optional)
inputOctreeinputOctree input cloud octree (optional).
Returns
success

Definition at line 403 of file ecvNormalVectors.cpp.

References cloudViewer::DgmOctree::build(), ComputeNormsAtLevelWithLS(), ComputeNormsAtLevelWithQuadric(), ComputeNormsAtLevelWithTri(), ccArray< Type, N, ComponentType >::currentSize(), cloudViewer::DgmOctree::executeFunctionForAllCellsAtLevel(), cloudViewer::DgmOctree::executeFunctionForAllCellsStartingAtLevel(), cloudViewer::DgmOctree::findBestLevelForAGivenNeighbourhoodSizeExtraction(), cloudViewer::DgmOctree::findBestLevelForAGivenPopulationPerCell(), GetNormIndex(), ccArray< Type, N, ComponentType >::isAllocated(), cloudViewer::GenericProgressCallback::isCancelRequested(), LS, NUMBER_OF_POINTS_FOR_NORM_WITH_TRI, QUADRIC, CCShareable::release(), ccArray< Type, N, ComponentType >::resizeSafe(), ccArray< Type, N, ComponentType >::setValue(), cloudViewer::GenericCloud::size(), TRI, UNDEFINED, and UpdateNormalOrientations().

Referenced by ccPointCloud::computeNormalsWithOctree().

◆ ComputeNormalWithLS()

bool ccNormalVectors::ComputeNormalWithLS ( cloudViewer::GenericIndexedCloudPersist pointAndNeighbors,
CCVector3 N 
)
static

Helper: computes the normal (with best LS fit)

Definition at line 550 of file ecvNormalVectors.cpp.

References cloudViewer::Neighbourhood::getLSPlaneNormal(), and cloudViewer::GenericCloud::size().

Referenced by ComputeNormsAtLevelWithLS().

◆ ComputeNormalWithQuadric()

bool ccNormalVectors::ComputeNormalWithQuadric ( cloudViewer::GenericIndexedCloudPersist points,
const CCVector3 P,
CCVector3 N 
)
static

Helper: computes the normal (with Delaunay 2.5D)

The normal is computed at the first point (assuming the others are its neighbors).

Definition at line 518 of file ecvNormalVectors.cpp.

References cloudViewer::Neighbourhood::getGravityCenter(), cloudViewer::Neighbourhood::getQuadric(), Vector3Tpl< Type >::normalize(), points, Tuple3Tpl< Type >::u, Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.

Referenced by ComputeNormsAtLevelWithQuadric().

◆ ComputeNormalWithTri()

◆ ComputeNormsAtLevelWithLS()

bool ccNormalVectors::ComputeNormsAtLevelWithLS ( const cloudViewer::DgmOctree::octreeCell cell,
void **  additionalParameters,
cloudViewer::NormalizedProgress nProgress = nullptr 
)
staticprotected

◆ ComputeNormsAtLevelWithQuadric()

bool ccNormalVectors::ComputeNormsAtLevelWithQuadric ( const cloudViewer::DgmOctree::octreeCell cell,
void **  additionalParameters,
cloudViewer::NormalizedProgress nProgress = nullptr 
)
staticprotected

◆ ComputeNormsAtLevelWithTri()

bool ccNormalVectors::ComputeNormsAtLevelWithTri ( const cloudViewer::DgmOctree::octreeCell cell,
void **  additionalParameters,
cloudViewer::NormalizedProgress nProgress = nullptr 
)
staticprotected

◆ ConvertDipAndDipDirToNormal()

CCVector3 ccNormalVectors::ConvertDipAndDipDirToNormal ( PointCoordinateType  dip_deg,
PointCoordinateType  dipDir_deg,
bool  upward = true 
)
static

Converts a couple of geological 'dip direction & dip' parameters to a unit normal vector

Parameters
[in]dip_degvalue (in degrees)
[in]dipDir_degdip direction value(in degrees)
[in]upwardwhether the output normal vector should point towards Z+ (true) or Z- (false)
Returns
unit normal vector

Definition at line 892 of file ecvNormalVectors.cpp.

References ConvertNormalToDipAndDipDir(), and cloudViewer::DegreesToRadians().

Referenced by ccCompass::importFoliations(), ccCompassImport::importFoliations(), ccApplyTransformationDlg::initFromDipAndDipDir(), ccPlaneEditDlg::onDipDirChanged(), and ccPlaneEditDlg::updatePlane().

◆ ConvertDipAndDipDirToString()

QString ccNormalVectors::ConvertDipAndDipDirToString ( PointCoordinateType  dip_deg,
PointCoordinateType  dipDir_deg 
)
static

Converts geological 'dip direction & dip' parameters to a string.

Parameters
[in]dip_degdip angle value (in degrees)
[in]dipDir_degdip direction value (in degrees)
Returns
formatted string "Dip direction: [dipDir]° - Dip angle: [dip]°"

Definition at line 815 of file ecvNormalVectors.cpp.

Referenced by StereogramDialog::init(), and CommandMatchBestFitPlane::process().

◆ ConvertNormalToDipAndDipDir()

void ccNormalVectors::ConvertNormalToDipAndDipDir ( const CCVector3 N,
PointCoordinateType dip_deg,
PointCoordinateType dipDir_deg 
)
static

◆ ConvertNormalToHSV()

void ccNormalVectors::ConvertNormalToHSV ( const CCVector3 N,
float H,
float S,
float V 
)
static

Converts a normal vector to HSV color space.

Uses 'strike & dip' parameters (H=strike, S=dip, V=constant)

Parameters
[in]Nnormal (should be normalized!)
[out]Hhue [0;360[
[out]Ssaturation [0;1]
[out]Vvalue [0;1]

Definition at line 922 of file ecvNormalVectors.cpp.

References ConvertNormalToDipAndDipDir().

◆ ConvertNormalToRGB()

ecvColor::Rgb ccNormalVectors::ConvertNormalToRGB ( const CCVector3 N)
static

Converts a normal vector to RGB color space.

Uses 'ConvertNormalToHSV' then converts HSV to RGB.

Parameters
[in]Nnormal (should be normalized!)
Returns
RGB value (components between 0 and MAX_COLOR_COMP)

Definition at line 936 of file ecvNormalVectors.cpp.

References ecvColor::RgbTpl< Type >::b, ecvColor::RgbTpl< Type >::g, ecvColor::MAX, ecvColor::RgbTpl< Type >::r, Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.

Referenced by enableNormalHSVColorsArray().

◆ ConvertNormalToStrikeAndDip()

void ccNormalVectors::ConvertNormalToStrikeAndDip ( const CCVector3 N,
PointCoordinateType strike_deg,
PointCoordinateType dip_deg 
)
static

Converts a normal vector to geological 'strike & dip' parameters (N[dip]°E - [strike]°)

Parameters
[in]Nnormal (should be normalized!)
[out]strike_degstrike value (in degrees)
[out]dip_degdip value (in degrees)

Definition at line 825 of file ecvNormalVectors.cpp.

References Vector3Tpl< Type >::norm2(), cloudViewer::RadiansToDegrees(), Tuple3Tpl< Type >::x, x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.

◆ ConvertStrikeAndDipToString()

QString ccNormalVectors::ConvertStrikeAndDipToString ( double &  strike_deg,
double &  dip_deg 
)
static

Converts geological 'strike & dip' parameters (N[dip]°E - [strike]°) to a string

Parameters
[in]strike_degstrike value (in degrees)
[in]dip_degdip value (in degrees)
Returns
formatted string "N[strike]°E - [dip]°"

Definition at line 805 of file ecvNormalVectors.cpp.

◆ enableNormalHSVColorsArray()

bool ccNormalVectors::enableNormalHSVColorsArray ( )

Allocates normal HSV colors array.

Mandatory for HSV color related methods (getNormalHSVColor, etc.)

Definition at line 60 of file ecvNormalVectors.cpp.

References ConvertNormalToRGB(), m_theNormalHSVColors, and m_theNormalVectors.

◆ GetNormal()

◆ getNormal() [1/2]

CCVector3& ccNormalVectors::getNormal ( unsigned  normIndex)
inline

Definition at line 54 of file ecvNormalVectors.h.

◆ getNormal() [2/2]

const CCVector3& ccNormalVectors::getNormal ( unsigned  normIndex) const
inline

Returns the precomputed normal corresponding to a given compressed index.

Definition at line 51 of file ecvNormalVectors.h.

Referenced by GetNormal(), GetNormalPtr(), cc2smReader::getPclCloud2(), ccMesh::getTriangleNorm(), ccMesh::getTriangleNormals(), ccMesh::getTriangleNormalsPtr(), and cc2smReader::getVtkPolyDataFromMeshCloud().

◆ getNormalHSVColor()

const ecvColor::Rgb & ccNormalVectors::getNormalHSVColor ( unsigned  index) const

Returns the HSV color equivalent to a given compressed normal index.

Definition at line 85 of file ecvNormalVectors.cpp.

References m_theNormalHSVColors, and m_theNormalVectors.

◆ getNormalHSVColorArray()

const std::vector<ecvColor::Rgb>& ccNormalVectors::getNormalHSVColorArray ( ) const
inline

Returns the HSV color array.

Definition at line 224 of file ecvNormalVectors.h.

Referenced by ccPointCloud::convertNormalToRGB().

◆ GetNormalPtr()

static CCVector3& ccNormalVectors::GetNormalPtr ( unsigned  normIndex)
inlinestatic

◆ GetNormals()

static const std::vector<CCVector3>& ccNormalVectors::GetNormals ( )
inlinestatic

Definition at line 43 of file ecvNormalVectors.h.

References getNormals().

◆ getNormals() [1/2]

std::vector<CCVector3>& ccNormalVectors::getNormals ( )
inline

Definition at line 60 of file ecvNormalVectors.h.

◆ getNormals() [2/2]

const std::vector<CCVector3>& ccNormalVectors::getNormals ( ) const
inline

Definition at line 57 of file ecvNormalVectors.h.

Referenced by GetNormals(), and GetNormalsPtr().

◆ GetNormalsPtr()

static std::vector<CCVector3>& ccNormalVectors::GetNormalsPtr ( )
inlinestatic

Definition at line 46 of file ecvNormalVectors.h.

References getNormals().

◆ GetNormIndex() [1/2]

static CompressedNormType ccNormalVectors::GetNormIndex ( const CCVector3 N)
inlinestatic

Returns the compressed index corresponding to a normal vector (shortcut)

Definition at line 65 of file ecvNormalVectors.h.

References Tuple3Tpl< Type >::u.

◆ GetNormIndex() [2/2]

◆ GetNumberOfVectors()

static unsigned ccNormalVectors::GetNumberOfVectors ( )
inlinestatic

Returns the number of compressed normal vectors.

Definition at line 31 of file ecvNormalVectors.h.

References m_theNormalVectors.

Referenced by ccPointCloud::applyRigidTransformation(), define_ccNormalVectors(), and ccMesh::transformTriNormals().

◆ GetUniqueInstance()

◆ GuessBestRadius()

PointCoordinateType ccNormalVectors::GuessBestRadius ( ccGenericPointCloud cloud,
cloudViewer::DgmOctree cloudOctree = nullptr,
cloudViewer::GenericProgressCallback progressCb = nullptr 
)
static

Tries to guess the best 'local radius' for normals computation (see ComputeCloudNormals)

Parameters
cloudpoint cloud on which to process the normals.
cloudOctreeinput cloud octree (optional)
progressCbprogress notification (optional)
Returns
the best radius (strictly positive value) or 0 if an error occurred

Definition at line 236 of file ecvNormalVectors.cpp.

References cloudViewer::DgmOctree::build(), cloudViewer::DgmOctree::findBestLevelForAGivenNeighbourhoodSizeExtraction(), cloudViewer::GenericIndexedCloud::getPoint(), cloudViewer::DgmOctree::getPointsInSphericalNeighbourhood(), GuessNaiveRadius(), octree, octreeLevel, CVLog::Print(), cloudViewer::GenericCloud::size(), size, and CVLog::Warning().

Referenced by ccNormalComputationDlg::autoEstimateRadius(), and CommandOctreeNormal::process().

◆ GuessNaiveRadius()

PointCoordinateType ccNormalVectors::GuessNaiveRadius ( ccGenericPointCloud cloud)
static

Tries to guess a very naive 'local radius' for normals computation (see ComputeCloudNormals)

Parameters
cloudpoint cloud on which to process the normals.
Returns
naive radius (percentage of the cloud bounding-box)

Definition at line 223 of file ecvNormalVectors.cpp.

References cloudViewer::BoundingBoxTpl< T >::getMaxBoxDim(), ccGenericPointCloud::getOwnBB(), and cloudViewer::GenericCloud::size().

Referenced by ccEntityAction::computeNormals(), and GuessBestRadius().

◆ init()

bool ccNormalVectors::init ( )
protected

Inits internal structures.

Definition at line 90 of file ecvNormalVectors.cpp.

References ccNormalCompressor::Decompress(), m_theNormalVectors, ccNormalCompressor::NULL_NORM_CODE, and CVLog::Warning().

Referenced by ccNormalVectors().

◆ ReleaseUniqueInstance()

void ccNormalVectors::ReleaseUniqueInstance ( )
static

Releases unique instance.

Call to this method is now optional.

Definition at line 47 of file ecvNormalVectors.cpp.

References s_uniqueInstance.

Referenced by define_ccNormalVectors().

◆ UpdateNormalOrientations()

Member Data Documentation

◆ m_theNormalHSVColors

std::vector<ecvColor::Rgb> ccNormalVectors::m_theNormalHSVColors
protected

'HSV' colors corresponding to each compressed normal index

In fact, HSV color has already been converted to RGB here for faster display.

Definition at line 266 of file ecvNormalVectors.h.

Referenced by enableNormalHSVColorsArray(), and getNormalHSVColor().

◆ m_theNormalVectors

std::vector<CCVector3> ccNormalVectors::m_theNormalVectors
protected

Compressed normal vectors.

Definition at line 260 of file ecvNormalVectors.h.

Referenced by enableNormalHSVColorsArray(), getNormalHSVColor(), GetNumberOfVectors(), and init().


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