Easy3D 2.6.1
Loading...
Searching...
No Matches
PointCloud Class Reference

A data structure for point clouds. More...

#include <easy3d/core/point_cloud.h>

Inheritance diagram for PointCloud:
Model

Classes

class  BaseHandle
 Base class for topology types (internally it is basically an index). More...
 
class  ModelProperty
 Cloud property of type T. More...
 
class  Vertex
 This type represents a vertex (internally it is basically an index). More...
 
class  VertexContainer
 This helper class is a container for iterating through all vertices using C++11 range-based for-loops. More...
 
class  VertexIterator
 This class iterates linearly over all vertices. More...
 
class  VertexProperty
 Vertex property of type T. More...
 

Public Member Functions

Construct, destruct, assignment
 PointCloud ()
 Default constructor.
 
 ~PointCloud () override=default
 Destructor (is virtual, since we inherit from Model).
 
 PointCloud (const PointCloud &rhs)
 Copy constructor: copies rhs to *this. Performs a deep copy of all properties.
 
PointCloudoperator= (const PointCloud &rhs)
 Assign rhs to *this. Performs a deep copy of all properties.
 
PointCloudoperator+= (const PointCloud &other)
 Merges another point cloud into the current one.
 
PointCloudjoin (const PointCloud &other)
 Merges another point cloud into the current one.
 
PointCloudassign (const PointCloud &rhs)
 Assign rhs to *this. Does not copy custom properties.
 
Add new elements by hand
Vertex add_vertex (const vec3 &p)
 Add a new vertex with position p.
 
Memory Management
unsigned int vertices_size () const
 Returns number of (deleted and valid) vertices in the cloud.
 
unsigned int n_vertices () const
 Returns number of vertices in the cloud.
 
void clear ()
 Clear cloud: remove all vertices.
 
void resize (unsigned int nv)
 Resize space for vertices and their currently associated properties.
 
bool has_garbage () const
 Are there deleted vertices?
 
void collect_garbage ()
 Remove deleted vertices.
 
void delete_vertex (Vertex v)
 Deletes the vertex v from the cloud.
 
bool is_deleted (Vertex v) const
 Returns whether vertex v is deleted.
 
bool is_valid (Vertex v) const
 Return whether vertex v is valid, i.e. the index is stores it within the array bounds.
 
Property handling
template<class T>
VertexProperty< T > add_vertex_property (const std::string &name, const T t=T())
 Add a vertex property of type T with name name and default value t.
 
template<class T>
ModelProperty< T > add_model_property (const std::string &name, const T t=T())
 Add a vertex property of type T with name name and default value t.
 
template<class T>
VertexProperty< T > get_vertex_property (const std::string &name) const
 Get the vertex property named name of type T.
 
template<class T>
ModelProperty< T > get_model_property (const std::string &name) const
 Gets the model property named name of type T.
 
template<class T>
VertexProperty< T > vertex_property (const std::string &name, const T t=T())
 Gets or adds a vertex property of type T with name name.
 
template<class T>
ModelProperty< T > model_property (const std::string &name, const T t=T())
 Gets or adds a model property of type T with name name.
 
template<class T>
bool remove_vertex_property (VertexProperty< T > &p)
 Remove the vertex property p.
 
bool remove_vertex_property (const std::string &n)
 Remove the vertex property named n.
 
template<class T>
bool remove_model_property (ModelProperty< T > &p)
 Remove the model property p.
 
bool remove_model_property (const std::string &n)
 Remove the model property named n.
 
bool rename_vertex_property (const std::string &old_name, const std::string &new_name)
 Rename a vertex property given its name.
 
bool rename_model_property (const std::string &old_name, const std::string &new_name)
 Rename a model property given its name.
 
const std::type_info & get_vertex_property_type (const std::string &name) const
 Get the type_info T of vertex property name.
 
const std::type_info & get_model_property_type (const std::string &name) const
 Get the type_info T of model property name.
 
std::vector< std::string > vertex_properties () const
 Returns the names of all vertex properties.
 
std::vector< std::string > model_properties () const
 Returns the names of all model properties.
 
void property_stats (std::ostream &output) const override
 Prints the names of all properties to an output stream (e.g., std::cout).
 
Iterators
VertexIterator vertices_begin () const
 Returns start iterator for vertices.
 
VertexIterator vertices_end () const
 Returns end iterator for vertices.
 
VertexContainer vertices () const
 Returns vertex container for C++11 range-based for-loops.
 
- Public Member Functions inherited from Model
 Model (const std::string &name="unknown")
 Default constructor. The parameter name is optional, but it is useful for handling multiple models with the same viewer.
 
void set_name (const std::string &n)
 Sets/Changes the name of a model. Assigning a name to a model is optional, but it is useful for handling multiple models with the same viewer.
 
const std::string & name () const
 The name of a model.
 
const Box3bounding_box (bool recompute=false) const
 The bounding box of the model.
 
void invalidate_bounding_box ()
 Invalidates the bounding box of the model. So when bounding_box() is called, the bounding box will be re-computed. This function is typically called when the geometry of a model is changed.
 
bool empty () const
 Tests if the model is empty.
 
void set_renderer (std::shared_ptr< Renderer > r)
 Sets the renderer of this model.
 
Rendererrenderer ()
 Gets the renderer of this model.
 
const Rendererrenderer () const
 Gets the constant renderer of this model.
 
void set_manipulator (std::shared_ptr< Manipulator > manip)
 Attaches a manipulator to this model.
 
Manipulatormanipulator ()
 Gets the manipulator attached to this model.
 
const Manipulatormanipulator () const
 Gets the manipulator attached to this model.
 

Geometry-related Functions

const vec3position (Vertex v) const
 Gets the position of a vertex (read only).
 
vec3position (Vertex v)
 Gets the position of a vertex.
 
const std::vector< vec3 > & points () const override
 Returns the vector of vertex positions (read only).
 
std::vector< vec3 > & points () override
 Returns the vector of vertex positions.
 

Detailed Description

Constructor & Destructor Documentation

◆ PointCloud()

PointCloud ( const PointCloud & rhs)
inline

Copy constructor: copies rhs to *this. Performs a deep copy of all properties.

Parameters
rhsThe other point cloud.

Member Function Documentation

◆ add_model_property()

template<class T>
ModelProperty< T > add_model_property ( const std::string & name,
const T t = T() )
inline

Add a vertex property of type T with name name and default value t.

Parameters
nameThe name of the property.
tThe default value of the property.
Returns
The added vertex property. The operation fails if a property with the same name already exists, since the name has to be unique. In this case, it returns an invalid property. Example:
auto trans = cloud->add_model_property<mat4>("transformation", mat4::identity());
trans[0] = mat4::translation(-x0, -y0, -z0);
static Mat4< float > translation(const Vec< 3, float > &t)
static Mat< N, M, T > identity()
Returns an identity matrix.
Definition mat.h:697
Mat4< float > mat4
A 4 by 4 matrix of float type.
Definition types.h:67

◆ add_vertex()

PointCloud::Vertex add_vertex ( const vec3 & p)

Add a new vertex with position p.

Parameters
pThe position of the new vertex.
Returns
The added vertex.
Examples
Tutorial_312_MultiThread/main.cpp, and Tutorial_404_VirtualScanner/main.cpp.

◆ add_vertex_property()

template<class T>
VertexProperty< T > add_vertex_property ( const std::string & name,
const T t = T() )
inline

Add a vertex property of type T with name name and default value t.

Parameters
nameThe name of the property.
tThe default value of the property.
Returns
The added vertex property. The operation fails if a property with the same name already exists, since the name has to be unique. In this case, it returns an invalid property.
Examples
Tutorial_312_MultiThread/main.cpp.

◆ assign()

PointCloud & assign ( const PointCloud & rhs)

Assign rhs to *this. Does not copy custom properties.

Parameters
rhsThe other point cloud.
Returns
The assigned point cloud.

◆ collect_garbage()

void collect_garbage ( )

Remove deleted vertices.

See also
delete_vertex(), is_deleted(), and has_garbage().

◆ delete_vertex()

void delete_vertex ( Vertex v)

Deletes the vertex v from the cloud.

Parameters
vThe vertex to delete.
See also
collect_garbage(), is_deleted(), and has_garbage().

◆ get_model_property()

template<class T>
ModelProperty< T > get_model_property ( const std::string & name) const
inline

Gets the model property named name of type T.

Parameters
nameThe name of the property.
Returns
The model property. An invalid ModelProperty will be returned if the property does not exist or if the type does not match. Example:
auto T = cloud->get_model_property<mat4>("transformation");
T[0] = mat4::translation(-x0, -y0, -z0);

◆ get_model_property_type()

const std::type_info & get_model_property_type ( const std::string & name) const
inline

Get the type_info T of model property name.

Parameters
nameThe name of the property.
Returns
The type_info of the property. A typeid(void) is returned if the property does not exist or if the type does not match.

◆ get_vertex_property()

template<class T>
VertexProperty< T > get_vertex_property ( const std::string & name) const
inline

Get the vertex property named name of type T.

Parameters
nameThe name of the property.
Returns
The vertex property. An invalid VertexProperty will be returned if the property does not exist or if the type does not match.
Examples
Tutorial_103_PointCloud_IO/main.cpp, Tutorial_701_Cloud_NormalEstimation/main.cpp, Tutorial_702_Cloud_SurfaceReconstruction/main.cpp, and Tutorial_703_Cloud_PlaneExtraction/main.cpp.

◆ get_vertex_property_type()

const std::type_info & get_vertex_property_type ( const std::string & name) const
inline

Get the type_info T of vertex property name.

Parameters
nameThe name of the property.
Returns
The type_info of the property. A typeid(void) is returned if the property does not exist or if the type does not match.

◆ has_garbage()

bool has_garbage ( ) const
inline

Are there deleted vertices?

Returns
True if there are deleted vertices, false otherwise.
See also
delete_vertex(), is_deleted(), and collect_garbage().

◆ is_deleted()

bool is_deleted ( Vertex v) const
inline

Returns whether vertex v is deleted.

Parameters
vThe vertex to check.
Returns
True if the vertex is deleted, false otherwise.
See also
collect_garbage(), delete_vertex(), and has_garbage().

◆ is_valid()

bool is_valid ( Vertex v) const
inline

Return whether vertex v is valid, i.e. the index is stores it within the array bounds.

Parameters
vThe vertex to check.
Returns
True if the vertex is valid, false otherwise.

◆ join()

PointCloud & join ( const PointCloud & other)

Merges another point cloud into the current one.

Shifts the indices of vertices of the other point cloud by number_of_vertices() + number_of_removed_vertices(). Copies entries of all property maps which have the same name in both point clouds. That is, property maps which are only in other are ignored. Also copies elements which are marked as removed, and concatenates the freelists of both point clouds.

Parameters
otherThe other point cloud to merge.
Returns
The merged point cloud.

◆ model_properties()

std::vector< std::string > model_properties ( ) const
inline

Returns the names of all model properties.

Returns
A vector of names of all model properties.

◆ model_property()

template<class T>
ModelProperty< T > model_property ( const std::string & name,
const T t = T() )
inline

Gets or adds a model property of type T with name name.

Parameters
nameThe name of the property.
tThe default value of the property.
Returns
The model property. If a model property of type T with name name exists, it is returned. otherwise this property is added (with default value t) and then returned.

◆ n_vertices()

unsigned int n_vertices ( ) const
inline

Returns number of vertices in the cloud.

Returns
The number of valid vertices in the cloud.
Examples
Tutorial_101_PointCloud/main.cpp, Tutorial_102_PointCloud_Property/main.cpp, Tutorial_103_PointCloud_IO/main.cpp, and Tutorial_312_MultiThread/main.cpp.

◆ operator+=()

PointCloud & operator+= ( const PointCloud & other)
inline

Merges another point cloud into the current one.

Shifts the indices of vertices of the other point cloud by number_of_vertices() + number_of_removed_vertices(). Copies entries of all property maps which have the same name in both point clouds. That is, property maps which are only in other are ignored. Also copies elements which are marked as removed, and concatenates the freelists of both point clouds.

Parameters
otherThe other point cloud to merge.
Returns
The merged point cloud.

◆ operator=()

PointCloud & operator= ( const PointCloud & rhs)

Assign rhs to *this. Performs a deep copy of all properties.

Parameters
rhsThe other point cloud.
Returns
The assigned point cloud.

◆ points() [1/2]

const std::vector< vec3 > & points ( ) const
inlineoverridevirtual

Returns the vector of vertex positions (read only).

Returns
A const reference to the vector of vertex positions.

Implements Model.

◆ points() [2/2]

std::vector< vec3 > & points ( )
inlineoverridevirtual

Returns the vector of vertex positions.

Returns
A reference to the vector of vertex positions.

Implements Model.

◆ position() [1/2]

vec3 & position ( Vertex v)
inline

Gets the position of a vertex.

Parameters
vThe vertex to get the position of.
Returns
A reference to the position of the vertex.

◆ position() [2/2]

const vec3 & position ( Vertex v) const
inline

Gets the position of a vertex (read only).

Parameters
vThe vertex to get the position of.
Returns
A const reference to the position of the vertex.

◆ property_stats()

void property_stats ( std::ostream & output) const
overridevirtual

Prints the names of all properties to an output stream (e.g., std::cout).

Parameters
outputThe output stream to print to.

Reimplemented from Model.

◆ remove_model_property() [1/2]

bool remove_model_property ( const std::string & n)
inline

Remove the model property named n.

Parameters
nThe name of the model property to remove.
Returns
True if the property was removed, false otherwise.

◆ remove_model_property() [2/2]

template<class T>
bool remove_model_property ( ModelProperty< T > & p)
inline

Remove the model property p.

Parameters
pThe model property to remove.
Returns
True if the property was removed, false otherwise.

◆ remove_vertex_property() [1/2]

bool remove_vertex_property ( const std::string & n)
inline

Remove the vertex property named n.

Parameters
nThe name of the vertex property to remove.
Returns
True if the property was removed, false otherwise.

◆ remove_vertex_property() [2/2]

template<class T>
bool remove_vertex_property ( VertexProperty< T > & p)
inline

Remove the vertex property p.

Parameters
pThe vertex property to remove.
Returns
True if the property was removed, false otherwise.

◆ rename_model_property()

bool rename_model_property ( const std::string & old_name,
const std::string & new_name )
inline

Rename a model property given its name.

Parameters
old_nameThe old name of the property.
new_nameThe new name of the property.
Returns
True if the property was renamed, false otherwise.

◆ rename_vertex_property()

bool rename_vertex_property ( const std::string & old_name,
const std::string & new_name )
inline

Rename a vertex property given its name.

Parameters
old_nameThe old name of the property.
new_nameThe new name of the property.
Returns
True if the property was renamed, false otherwise.

◆ resize()

void resize ( unsigned int nv)
inline

Resize space for vertices and their currently associated properties.

Parameters
nvThe new size for the vertices.

◆ vertex_properties()

std::vector< std::string > vertex_properties ( ) const
inline

Returns the names of all vertex properties.

Returns
A vector of names of all vertex properties.

◆ vertex_property()

template<class T>
VertexProperty< T > vertex_property ( const std::string & name,
const T t = T() )
inline

Gets or adds a vertex property of type T with name name.

Parameters
nameThe name of the property.
tThe default value of the property.
Returns
The vertex property. If a vertex property of type T with name name exists, it is returned. otherwise this property is added (with default value t) and then returned.
Examples
Tutorial_312_MultiThread/main.cpp, and Tutorial_403_PointSelection/main.cpp.

◆ vertices()

VertexContainer vertices ( ) const
inline

Returns vertex container for C++11 range-based for-loops.

Returns
The vertex container for range-based for-loops.
Examples
Tutorial_103_PointCloud_IO/main.cpp, and Tutorial_403_PointSelection/main.cpp.

◆ vertices_begin()

VertexIterator vertices_begin ( ) const
inline

Returns start iterator for vertices.

Returns
The start iterator for vertices.

◆ vertices_end()

VertexIterator vertices_end ( ) const
inline

Returns end iterator for vertices.

Returns
The end iterator for vertices.

◆ vertices_size()

unsigned int vertices_size ( ) const
inline

Returns number of (deleted and valid) vertices in the cloud.

Returns
The number of vertices in the cloud.

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