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

A very simple point cloud (no point duplication) More...

#include <ReferenceCloud.h>

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

Public Member Functions

 ReferenceCloud (GenericIndexedCloudPersist *associatedCloud)
 Default constructor.
 
 ReferenceCloud (const ReferenceCloud &refCloud)
 Copy constructor.
 
 ~ReferenceCloud () override=default
 Destructor.
 
unsigned size () const override
 Returns the number of points. More...
 
void forEach (genericPointAction action) override
 Fast iteration mechanism. More...
 
void getBoundingBox (CCVector3 &bbMin, CCVector3 &bbMax) override
 Returns the cloud bounding box. More...
 
unsigned char testVisibility (const CCVector3 &P) const override
 Returns a given point visibility state (relatively to a sensor for instance) More...
 
void placeIteratorAtBeginning () override
 Sets the cloud iterator at the beginning. More...
 
const CCVector3getNextPoint () override
 Returns the next point (relatively to the global iterator position) More...
 
bool enableScalarField () override
 Enables the scalar field associated to the cloud. More...
 
bool isScalarFieldEnabled () const override
 Returns true if the scalar field is enabled, false otherwise. More...
 
void setPointScalarValue (unsigned pointIndex, ScalarType value) override
 Sets the ith point associated scalar value. More...
 
ScalarType getPointScalarValue (unsigned pointIndex) const override
 Returns the ith point associated scalar value. More...
 
const CCVector3getPoint (unsigned index) const override
 Returns the ith point. More...
 
void getPoint (unsigned index, CCVector3 &P) const override
 Returns the ith point. More...
 
bool normalsAvailable () const override
 Returns whether normals are available. More...
 
const CCVector3getNormal (unsigned index) const override
 If per-point normals are available, returns the one at a specific index. More...
 
const CCVector3getPointPersistentPtr (unsigned index) const override
 Returns the ith point as a persistent pointer. More...
 
virtual unsigned getPointGlobalIndex (unsigned localIndex) const
 Returns global index (i.e. relative to the associated cloud) of a given element. More...
 
virtual const CCVector3getCurrentPointCoordinates () const
 Returns the coordinates of the point pointed by the current element. More...
 
virtual unsigned getCurrentPointGlobalIndex () const
 Returns the global index of the point pointed by the current element.
 
virtual ScalarType getCurrentPointScalarValue () const
 Returns the current point associated scalar value.
 
virtual void setCurrentPointScalarValue (ScalarType value)
 Sets the current point associated scalar value.
 
virtual void forwardIterator ()
 Forwards the local element iterator.
 
virtual void clear (bool releaseMemory=false)
 Clears the cloud. More...
 
virtual bool addPointIndex (unsigned globalIndex)
 Point global index insertion mechanism. More...
 
virtual bool addPointIndex (unsigned firstIndex, unsigned lastIndex)
 Point global index insertion mechanism (range) More...
 
virtual void setPointIndex (unsigned localIndex, unsigned globalIndex)
 Sets global index for a given element. More...
 
virtual bool reserve (unsigned n)
 Reserves some memory for hosting the point references. More...
 
virtual bool resize (unsigned n)
 Presets the size of the vector used to store point references. More...
 
virtual unsigned capacity () const
 Returns max capacity.
 
virtual void swap (unsigned i, unsigned j)
 Swaps two point references. More...
 
virtual void removeCurrentPointGlobalIndex ()
 Removes current element. More...
 
virtual void removePointGlobalIndex (unsigned localIndex)
 Removes a given element. More...
 
virtual GenericIndexedCloudPersistgetAssociatedCloud ()
 Returns the associated (source) cloud.
 
virtual const GenericIndexedCloudPersistgetAssociatedCloud () const
 Returns the associated (source) cloud (const version)
 
virtual void setAssociatedCloud (GenericIndexedCloudPersist *cloud)
 Sets the associated (source) cloud.
 
bool add (const ReferenceCloud &cloud)
 Add another reference cloud. More...
 
void invalidateBoundingBox ()
 Invalidates the bounding-box.
 
- Public Member Functions inherited from CCCoreLib::GenericIndexedCloudPersist
 GenericIndexedCloudPersist ()=default
 Default constructor.
 
 GenericIndexedCloudPersist (const char *name, unsigned ID)
 Mock constructor for compatibility with the PointCloudTpl interface. More...
 
 ~GenericIndexedCloudPersist () override=default
 Default destructor.
 
virtual const CCVector3getPointPersistentPtr (unsigned index) const =0
 Returns the ith point as a persistent pointer. More...
 
- Public Member Functions inherited from CCCoreLib::GenericIndexedCloud
 GenericIndexedCloud ()=default
 Default constructor.
 
 ~GenericIndexedCloud () override=default
 Default destructor.
 
virtual const CCVector3getPoint (unsigned index) const =0
 Returns the ith point. More...
 
virtual void getPoint (unsigned index, CCVector3 &P) const =0
 Returns the ith point. More...
 
virtual bool normalsAvailable () const
 Returns whether normals are available. More...
 
virtual const CCVector3getNormal (unsigned index) const
 If per-point normals are available, returns the one at a specific index. More...
 
- Public Member Functions inherited from CCCoreLib::GenericCloud
 GenericCloud ()=default
 Default constructor.
 
virtual ~GenericCloud ()=default
 Default destructor.
 
virtual unsigned size () const =0
 Returns the number of points. More...
 
virtual void forEach (genericPointAction action)=0
 Fast iteration mechanism. More...
 
virtual void getBoundingBox (CCVector3 &bbMin, CCVector3 &bbMax)=0
 Returns the cloud bounding box. More...
 
virtual unsigned char testVisibility (const CCVector3 &P) const
 Returns a given point visibility state (relatively to a sensor for instance) More...
 
virtual void placeIteratorAtBeginning ()=0
 Sets the cloud iterator at the beginning. More...
 
virtual const CCVector3getNextPoint ()=0
 Returns the next point (relatively to the global iterator position) More...
 
virtual bool enableScalarField ()=0
 Enables the scalar field associated to the cloud. More...
 
virtual bool isScalarFieldEnabled () const =0
 Returns true if the scalar field is enabled, false otherwise. More...
 
virtual void setPointScalarValue (unsigned pointIndex, ScalarType value)=0
 Sets the ith point associated scalar value. More...
 
virtual ScalarType getPointScalarValue (unsigned pointIndex) const =0
 Returns the ith point associated scalar value. More...
 

Protected Types

using ReferencesContainer = std::vector< unsigned int >
 Container of 3D point indexes.
 

Protected Attributes

ReferencesContainer m_theIndexes
 Indexes of (some of) the associated cloud points.
 
std::atomic< unsigned > m_globalIterator
 Iterator on the point references container.
 
BoundingBox m_bbox
 Bounding-box.
 
GenericIndexedCloudPersistm_theAssociatedCloud
 Associated cloud. More...
 
std::mutex m_mutex
 For concurrent access.
 

Additional Inherited Members

- Public Types inherited from CCCoreLib::GenericCloud
using genericPointAction = std::function< void(const CCVector3 &, ScalarType &)>
 Generic function applied to a point (used by foreach)
 

Detailed Description

A very simple point cloud (no point duplication)

Implements the GenericIndexedCloudPersist interface. A simple point cloud that stores references to Generic3dPoint instances in a vector.

Partial thread safety for all methods that can change the size of the cloud or that change or rely on point ordering.

Member Function Documentation

◆ add()

bool ReferenceCloud::add ( const ReferenceCloud cloud)

Add another reference cloud.

Warning
Both clouds should have the same reference cloud!
No verification for duplicates! Thread safe.

◆ addPointIndex() [1/2]

bool ReferenceCloud::addPointIndex ( unsigned  firstIndex,
unsigned  lastIndex 
)
virtual

Point global index insertion mechanism (range)

Parameters
firstIndexfirst point global index of range
lastIndexlast point global index of range (excluded)
Returns
false if not enough memory Thread safe.

◆ addPointIndex() [2/2]

bool ReferenceCloud::addPointIndex ( unsigned  globalIndex)
virtual

Point global index insertion mechanism.

Parameters
globalIndexa point global index
Returns
false if not enough memory Thread safe.

◆ clear()

void ReferenceCloud::clear ( bool  releaseMemory = false)
virtual

Clears the cloud.

Thread safe.

Reimplemented in CCCoreLib::Polyline.

◆ enableScalarField()

bool CCCoreLib::ReferenceCloud::enableScalarField ( )
inlineoverridevirtual

Enables the scalar field associated to the cloud.

If the scalar field structure is not yet initialized/allocated, this method gives the signal for its creation. Otherwise, if possible the structure size should be pre-reserved with the same number of elements as the point cloud.

Warning
If the cloud is empty, the scalar field will be empty as well. The scalar field will be reserved with the same capacity as the cloud.

Implements CCCoreLib::GenericCloud.

◆ forEach()

void ReferenceCloud::forEach ( genericPointAction  action)
overridevirtual

Fast iteration mechanism.

Virtual method to apply a function to the whole cloud

Parameters
actionthe function to apply (see GenericCloud::genericPointAction)

Implements CCCoreLib::GenericCloud.

◆ getBoundingBox()

void ReferenceCloud::getBoundingBox ( CCVector3 bbMin,
CCVector3 bbMax 
)
overridevirtual

Returns the cloud bounding box.

Virtual method to request the cloud bounding box limits

Parameters
bbMinlower bounding-box limits (Xmin,Ymin,Zmin)
bbMaxhigher bounding-box limits (Xmax,Ymax,Zmax)

Implements CCCoreLib::GenericCloud.

◆ getCurrentPointCoordinates()

const CCVector3 * ReferenceCloud::getCurrentPointCoordinates ( ) const
virtual

Returns the coordinates of the point pointed by the current element.

Returns a persistent pointer.

◆ getNextPoint()

const CCVector3 * CCCoreLib::ReferenceCloud::getNextPoint ( )
inlineoverridevirtual

Returns the next point (relatively to the global iterator position)

Virtual method to handle the cloud global iterator. Global iterator position should be increased by one each time this method is called. Warning:

  • the returned object may not be persistent!
  • THIS METHOD MAY NOT BE COMPATIBLE WITH PARALLEL STRATEGIES (see the DgmOctree::executeFunctionForAllCellsAtLevel_MT and DgmOctree::executeFunctionForAllCellsAtStartingLevel_MT methods).
    Returns
    pointer on next point (or 0 if no more)

Implements CCCoreLib::GenericCloud.

◆ getNormal()

const CCVector3 * CCCoreLib::ReferenceCloud::getNormal ( unsigned  index) const
inlineoverridevirtual

If per-point normals are available, returns the one at a specific index.

Warning
If overriden, this method should return a valid normal for all points

Reimplemented from CCCoreLib::GenericIndexedCloud.

◆ getPoint() [1/2]

const CCVector3 * CCCoreLib::ReferenceCloud::getPoint ( unsigned  index) const
inlineoverridevirtual

Returns the ith point.

Virtual method to request a point with a specific index. WARNINGS:

  • the returned object may not be persistent!
  • THIS METHOD MAY NOT BE COMPATIBLE WITH PARALLEL STRATEGIES (see the DgmOctree::executeFunctionForAllCellsAtLevel_MT and DgmOctree::executeFunctionForAllCellsAtStartingLevel_MT methods). Consider the other version of getPoint instead or the GenericIndexedCloudPersist class.
    Parameters
    indexof the requested point (between 0 and the cloud size minus 1)
    Returns
    the requested point (undefined behavior if index is invalid)

Implements CCCoreLib::GenericIndexedCloud.

◆ getPoint() [2/2]

void CCCoreLib::ReferenceCloud::getPoint ( unsigned  index,
CCVector3 P 
) const
inlineoverridevirtual

Returns the ith point.

Virtual method to request a point with a specific index. Index must be valid (undefined behavior if index is invalid)

Parameters
indexof the requested point (between 0 and the cloud size minus 1)
Poutput point

Implements CCCoreLib::GenericIndexedCloud.

◆ getPointGlobalIndex()

virtual unsigned CCCoreLib::ReferenceCloud::getPointGlobalIndex ( unsigned  localIndex) const
inlinevirtual

Returns global index (i.e. relative to the associated cloud) of a given element.

Parameters
localIndexlocal index (i.e. relative to the internal index container)

◆ getPointPersistentPtr()

const CCVector3 * CCCoreLib::ReferenceCloud::getPointPersistentPtr ( unsigned  index) const
inlineoverridevirtual

Returns the ith point as a persistent pointer.

Virtual method to request a point with a specific index. WARNING: the returned object MUST be persistent in order to be compatible with parallel strategies!

Parameters
indexof the requested point (between 0 and the cloud size minus 1)
Returns
the requested point (or 0 if index is invalid)

Implements CCCoreLib::GenericIndexedCloudPersist.

◆ getPointScalarValue()

ScalarType CCCoreLib::ReferenceCloud::getPointScalarValue ( unsigned  pointIndex) const
inlineoverridevirtual

Returns the ith point associated scalar value.

Implements CCCoreLib::GenericCloud.

◆ isScalarFieldEnabled()

bool CCCoreLib::ReferenceCloud::isScalarFieldEnabled ( ) const
inlineoverridevirtual

Returns true if the scalar field is enabled, false otherwise.

Implements CCCoreLib::GenericCloud.

◆ normalsAvailable()

bool CCCoreLib::ReferenceCloud::normalsAvailable ( ) const
inlineoverridevirtual

Returns whether normals are available.

Reimplemented from CCCoreLib::GenericIndexedCloud.

◆ placeIteratorAtBeginning()

void CCCoreLib::ReferenceCloud::placeIteratorAtBeginning ( )
inlineoverridevirtual

Sets the cloud iterator at the beginning.

Virtual method to handle the cloud global iterator

Implements CCCoreLib::GenericCloud.

◆ removeCurrentPointGlobalIndex()

virtual void CCCoreLib::ReferenceCloud::removeCurrentPointGlobalIndex ( )
inlinevirtual

Removes current element.

WARNING: this method changes the cloud size! Thread safe.

◆ removePointGlobalIndex()

void ReferenceCloud::removePointGlobalIndex ( unsigned  localIndex)
virtual

Removes a given element.

WARNING: this method changes the cloud size! Thread safe.

◆ reserve()

bool ReferenceCloud::reserve ( unsigned  n)
virtual

Reserves some memory for hosting the point references.

Parameters
nthe number of points (references) Thread safe.

◆ resize()

bool ReferenceCloud::resize ( unsigned  n)
virtual

Presets the size of the vector used to store point references.

Parameters
nthe number of points (references) Thread safe.

◆ setPointIndex()

void ReferenceCloud::setPointIndex ( unsigned  localIndex,
unsigned  globalIndex 
)
virtual

Sets global index for a given element.

Parameters
localIndexlocal index
globalIndexglobal index

◆ setPointScalarValue()

void CCCoreLib::ReferenceCloud::setPointScalarValue ( unsigned  pointIndex,
ScalarType  value 
)
inlineoverridevirtual

Sets the ith point associated scalar value.

Implements CCCoreLib::GenericCloud.

◆ size()

unsigned CCCoreLib::ReferenceCloud::size ( ) const
inlineoverridevirtual

Returns the number of points.

Virtual method to request the cloud size

Returns
the cloud size

Implements CCCoreLib::GenericCloud.

◆ swap()

virtual void CCCoreLib::ReferenceCloud::swap ( unsigned  i,
unsigned  j 
)
inlinevirtual

Swaps two point references.

the point references indexes should be smaller than the total number of "reserved" points (see ReferenceCloud::reserve).

Parameters
ithe first point index
jthe second point index Thread safe.

◆ testVisibility()

unsigned char CCCoreLib::ReferenceCloud::testVisibility ( const CCVector3 P) const
inlineoverridevirtual

Returns a given point visibility state (relatively to a sensor for instance)

Generic method to request a point visibility (should be overloaded if this functionality is required). The point visibility is such as defined in Daniel Girardeau-Montaut's PhD manuscript (see Chapter 2, section 2-3-3). In this case, a ground based laser sensor model should be used to determine it. This method is called before performing any point-to-cloud comparison. If the result is not POINT_VISIBLE, then the comparison won't be performed and the scalar field value associated to this point will be this visibility value.

Parameters
Pthe 3D point to test
Returns
visibility (default: POINT_VISIBLE)

Reimplemented from CCCoreLib::GenericCloud.

Member Data Documentation

◆ m_theAssociatedCloud

GenericIndexedCloudPersist* CCCoreLib::ReferenceCloud::m_theAssociatedCloud
protected

Associated cloud.

The cloud from which references are referring to. WARNING: do not use the inner iterator as it is used to 'implement' the ReferenceCloud one.


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