CCCoreLib 31 May 2022
CloudCompare Core algorithms
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CCCoreLib::PointCloudTpl< BaseClass, StringType > Class Template Reference

A storage-efficient point cloud structure that can also handle an unlimited number of scalar fields. More...

#include <PointCloudTpl.h>

Inheritance diagram for CCCoreLib::PointCloudTpl< BaseClass, StringType >:
Inheritance graph
[legend]
Collaboration diagram for CCCoreLib::PointCloudTpl< BaseClass, StringType >:
Collaboration graph
[legend]

Public Member Functions

 PointCloudTpl ()
 Default constructor.
 
 PointCloudTpl (StringType name, unsigned ID)
 Alternate constructor with a name and ID.
 
 PointCloudTpl (const PointCloudTpl &rhs)
 Copy Constructor.
 
virtual ~PointCloudTpl ()
 Default destructor.
 
PointCloudTploperator= (const PointCloudTpl &rhs)
 Copy Assignment.
 
unsigned size () const override
 
void forEach (GenericCloud::genericPointAction action) override
 
void getBoundingBox (CCVector3 &bbMin, CCVector3 &bbMax) override
 
void placeIteratorAtBeginning () override
 
const CCVector3getNextPoint () override
 
bool enableScalarField () override
 
bool isScalarFieldEnabled () const override
 
void setPointScalarValue (unsigned pointIndex, ScalarType value) override
 
ScalarType getPointScalarValue (unsigned pointIndex) const override
 
const CCVector3getPoint (unsigned index) const override
 
void getPoint (unsigned index, CCVector3 &P) const override
 
const CCVector3getPointPersistentPtr (unsigned index) const override
 
void addPointScalarValue (ScalarType value)
 Adds a scalar values to the active 'in' scalar field. More...
 
virtual bool resize (unsigned newNumberOfPoints)
 Resizes the point database. More...
 
virtual bool reserve (unsigned newCapacity)
 Reserves memory for the point database. More...
 
void reset ()
 Clears the cloud database. More...
 
void addPoint (const CCVector3 &P)
 Adds a 3D point to the database. More...
 
virtual void invalidateBoundingBox ()
 Invalidates bounding box. More...
 
unsigned getNumberOfScalarFields () const
 Returns the number of associated (and active) scalar fields. More...
 
ScalarFieldgetScalarField (int index) const
 Returns a pointer to a specific scalar field. More...
 
const char * getScalarFieldName (int index) const
 Returns the name of a specific scalar field. More...
 
int getScalarFieldIndexByName (const char *name) const
 Returns the index of a scalar field represented by its name. More...
 
ScalarFieldgetCurrentInScalarField () const
 Returns the scalar field currently associated to the cloud input. More...
 
ScalarFieldgetCurrentOutScalarField () const
 Returns the scalar field currently associated to the cloud output. More...
 
void setCurrentInScalarField (int index)
 Sets the INPUT scalar field. More...
 
int getCurrentInScalarFieldIndex ()
 Returns current INPUT scalar field index (or -1 if none)
 
void setCurrentOutScalarField (int index)
 Sets the OUTPUT scalar field. More...
 
int getCurrentOutScalarFieldIndex ()
 Returns current OUTPUT scalar field index (or -1 if none)
 
void setCurrentScalarField (int index)
 Sets both the INPUT & OUTPUT scalar field. More...
 
virtual int addScalarField (const char *uniqueName)
 Creates a new scalar field and registers it. More...
 
bool renameScalarField (int index, const char *newName)
 Renames a specific scalar field. More...
 
virtual void deleteScalarField (int index)
 Deletes a specific scalar field. More...
 
virtual void deleteAllScalarFields ()
 Deletes all scalar fields associated to this cloud.
 
unsigned capacity () const
 Returns cloud capacity (i.e. reserved size)
 

Protected Member Functions

virtual void swapPoints (unsigned firstIndex, unsigned secondIndex)
 Swaps two points (and their associated scalar values!)
 
CCVector3point (unsigned index)
 Returns non const access to a given point. More...
 
const CCVector3point (unsigned index) const
 Returns const access to a given point. More...
 

Protected Attributes

std::vector< CCVector3m_points
 3D Points database
 
BoundingBox m_bbox
 Bounding-box.
 
unsigned m_currentPointIndex
 'Iterator' on the points db
 
std::vector< ScalarField * > m_scalarFields
 Associated scalar fields.
 
int m_currentInScalarFieldIndex
 Index of current scalar field used for input.
 
int m_currentOutScalarFieldIndex
 Index of current scalar field used for output.
 

Detailed Description

template<class BaseClass, typename StringType = const char*>
class CCCoreLib::PointCloudTpl< BaseClass, StringType >

A storage-efficient point cloud structure that can also handle an unlimited number of scalar fields.

Member Function Documentation

◆ addPoint()

template<class BaseClass , typename StringType = const char*>
void CCCoreLib::PointCloudTpl< BaseClass, StringType >::addPoint ( const CCVector3 P)
inline

Adds a 3D point to the database.

To ensure the best efficiency, the database memory must have already been reserved (with PointCloud::reserve). Otherwise nothing happens.

Parameters
Pa 3D point

◆ addPointScalarValue()

template<class BaseClass , typename StringType = const char*>
void CCCoreLib::PointCloudTpl< BaseClass, StringType >::addPointScalarValue ( ScalarType  value)
inline

Adds a scalar values to the active 'in' scalar field.

Parameters
valuea scalar value

◆ addScalarField()

template<class BaseClass , typename StringType = const char*>
virtual int CCCoreLib::PointCloudTpl< BaseClass, StringType >::addScalarField ( const char *  uniqueName)
inlinevirtual

Creates a new scalar field and registers it.

Warnings:

  • the name must be unique (the method will fail if a SF with the same name already exists)
  • this method DOES resize the scalar field to match the current cloud size
    Parameters
    uniqueNamescalar field name (must be unique)
    Returns
    index of this new scalar field (or -1 if an error occurred)

◆ deleteScalarField()

template<class BaseClass , typename StringType = const char*>
virtual void CCCoreLib::PointCloudTpl< BaseClass, StringType >::deleteScalarField ( int  index)
inlinevirtual

Deletes a specific scalar field.

WARNING: this operation may modify the scalar fields order (especially if the deleted SF is not the last one). However current IN & OUT scalar fields will stay up-to-date (while their index may change).

Parameters
indexindex of scalar field to be deleted

◆ getCurrentInScalarField()

template<class BaseClass , typename StringType = const char*>
ScalarField * CCCoreLib::PointCloudTpl< BaseClass, StringType >::getCurrentInScalarField ( ) const
inline

Returns the scalar field currently associated to the cloud input.

See PointCloud::setPointScalarValue.

Returns
a pointer to the currently defined INPUT scalar field (or 0 if none)

◆ getCurrentOutScalarField()

template<class BaseClass , typename StringType = const char*>
ScalarField * CCCoreLib::PointCloudTpl< BaseClass, StringType >::getCurrentOutScalarField ( ) const
inline

Returns the scalar field currently associated to the cloud output.

See PointCloud::getPointScalarValue.

Returns
a pointer to the currently defined OUTPUT scalar field (or 0 if none)

◆ getNumberOfScalarFields()

template<class BaseClass , typename StringType = const char*>
unsigned CCCoreLib::PointCloudTpl< BaseClass, StringType >::getNumberOfScalarFields ( ) const
inline

Returns the number of associated (and active) scalar fields.

Returns
the number of active scalar fields

◆ getScalarField()

template<class BaseClass , typename StringType = const char*>
ScalarField * CCCoreLib::PointCloudTpl< BaseClass, StringType >::getScalarField ( int  index) const
inline

Returns a pointer to a specific scalar field.

Parameters
indexa scalar field index
Returns
a pointer to a ScalarField structure, or 0 if the index is invalid.

◆ getScalarFieldIndexByName()

template<class BaseClass , typename StringType = const char*>
int CCCoreLib::PointCloudTpl< BaseClass, StringType >::getScalarFieldIndexByName ( const char *  name) const
inline

Returns the index of a scalar field represented by its name.

Parameters
namea scalar field name
Returns
an index (-1 if the scalar field couldn't be found)

◆ getScalarFieldName()

template<class BaseClass , typename StringType = const char*>
const char * CCCoreLib::PointCloudTpl< BaseClass, StringType >::getScalarFieldName ( int  index) const
inline

Returns the name of a specific scalar field.

Parameters
indexa scalar field index
Returns
a pointer to a string structure (null-terminated array of characters), or 0 if the index is invalid.

◆ invalidateBoundingBox()

template<class BaseClass , typename StringType = const char*>
virtual void CCCoreLib::PointCloudTpl< BaseClass, StringType >::invalidateBoundingBox ( )
inlinevirtual

Invalidates bounding box.

Bounding box will be recomputed next time a request is made to 'getBoundingBox'.

◆ point() [1/2]

template<class BaseClass , typename StringType = const char*>
CCVector3 * CCCoreLib::PointCloudTpl< BaseClass, StringType >::point ( unsigned  index)
inlineprotected

Returns non const access to a given point.

WARNING: index must be valid

Parameters
indexpoint index
Returns
pointer on point stored data

◆ point() [2/2]

template<class BaseClass , typename StringType = const char*>
const CCVector3 * CCCoreLib::PointCloudTpl< BaseClass, StringType >::point ( unsigned  index) const
inlineprotected

Returns const access to a given point.

WARNING: index must be valid

Parameters
indexpoint index
Returns
pointer on point stored data

◆ renameScalarField()

template<class BaseClass , typename StringType = const char*>
bool CCCoreLib::PointCloudTpl< BaseClass, StringType >::renameScalarField ( int  index,
const char *  newName 
)
inline

Renames a specific scalar field.

Warning: name must not be already given to another SF!

Parameters
indexscalar field index
newNamenew name
Returns
success

◆ reserve()

template<class BaseClass , typename StringType = const char*>
virtual bool CCCoreLib::PointCloudTpl< BaseClass, StringType >::reserve ( unsigned  newCapacity)
inlinevirtual

Reserves memory for the point database.

This method tries to reserve some memory to store points that will be inserted later (with PointCloud::addPoint). If the new number of points is smaller than the actual one, nothing happens.

Parameters
newCapacitythe new capacity
Returns
true if the method succeeds, false otherwise

◆ reset()

template<class BaseClass , typename StringType = const char*>
void CCCoreLib::PointCloudTpl< BaseClass, StringType >::reset ( )
inline

Clears the cloud database.

Equivalent to resize(0).

◆ resize()

template<class BaseClass , typename StringType = const char*>
virtual bool CCCoreLib::PointCloudTpl< BaseClass, StringType >::resize ( unsigned  newNumberOfPoints)
inlinevirtual

Resizes the point database.

The cloud database is resized with the specified size. If the new size is smaller, the overflooding points will be deleted. If its greater, the database is filled with blank points (warning, the PointCloud::addPoint method will insert points after those ones).

Parameters
newNumberOfPointsthe new number of points
Returns
true if the method succeeds, false otherwise

Reimplemented in CCCoreLib::PointCloud.

◆ setCurrentInScalarField()

template<class BaseClass , typename StringType = const char*>
void CCCoreLib::PointCloudTpl< BaseClass, StringType >::setCurrentInScalarField ( int  index)
inline

Sets the INPUT scalar field.

This scalar field will be used by the PointCloud::setPointScalarValue method.

Parameters
indexa scalar field index (or -1 if none)

◆ setCurrentOutScalarField()

template<class BaseClass , typename StringType = const char*>
void CCCoreLib::PointCloudTpl< BaseClass, StringType >::setCurrentOutScalarField ( int  index)
inline

Sets the OUTPUT scalar field.

This scalar field will be used by the PointCloud::getPointScalarValue method.

Parameters
indexa scalar field index (or -1 if none)

◆ setCurrentScalarField()

template<class BaseClass , typename StringType = const char*>
void CCCoreLib::PointCloudTpl< BaseClass, StringType >::setCurrentScalarField ( int  index)
inline

Sets both the INPUT & OUTPUT scalar field.

This scalar field will be used by both PointCloud::getPointScalarValue and PointCloud::setPointScalarValue methods.

Parameters
indexa scalar field index

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