Easy3D 2.5.3
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...
 
struct  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 Geometry_representation)
 
 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. 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.
 
PointCloudjoin (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 cloud. 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 cloud.
 
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 More...
 
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. fails if a property named name exists already, since the name has to be unique. in this case it returns an invalid property
 
template<class T >
ModelProperty< T > add_model_property (const std::string &name, const T t=T())
 Adds a model property of type T with name name and default value t. More...
 
template<class T >
VertexProperty< T > get_vertex_property (const std::string &name) const
 get the vertex property named name of type T. returns an invalid VertexProperty if the property does not exist or if the type does not match.
 
template<class T >
ModelProperty< T > get_model_property (const std::string &name) const
 Gets the model property named name of type T. More...
 
template<class T >
VertexProperty< T > vertex_property (const std::string &name, const T t=T())
 if a vertex property of type T with name name exists, it is returned. otherwise this property is added (with default value t)
 
template<class T >
ModelProperty< T > model_property (const std::string &name, const T t=T())
 if a model property of type T with name name exists, it is returned. otherwise this property is added (with default value t)
 
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. returns an typeid(void) if the property does not exist or if the type does not match.
 
const std::type_info & get_model_property_type (const std::string &name) const
 get the type_info T of model property name. returns an typeid(void) if the property does not exist or if the type does not match.
 
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) More...
 
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. More...
 
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.
 
virtual std::vector< vec3 > & points ()=0
 The vertices of the model. More...
 
virtual const std::vector< vec3 > & points () const =0
 The vertices of the model. More...
 
bool empty () const
 Tests if the model is empty.
 
virtual void property_stats (std::ostream &output) const
 Prints the names of all properties to an output stream (e.g., std::cout). More...
 
void set_renderer (Renderer *r)
 Sets the renderer of this model. More...
 
Rendererrenderer ()
 Gets the renderer of this model.
 
const Rendererrenderer () const
 Gets the constant renderer of this model.
 
void set_manipulator (Manipulator *manip)
 Attaches a manipulator to this model. More...
 
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
 position of a vertex (read only)
 
vec3position (Vertex v)
 position of a vertex
 
const std::vector< vec3 > & points () const override
 vector of vertex positions (read only) More...
 
std::vector< vec3 > & points () override
 vector of vertex positions More...
 

Detailed Description

Member Function Documentation

◆ add_model_property()

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

Adds a model property of type T with name name and default value t.

Fails if a property named name exists already, 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 constructor return a 3D translation matrix (as a 4D affine transformation).
Definition: mat.h:2280
static Mat< N, M, float > identity()
Static constructor return an N x M identity matrix. see also load_identity()
Definition: mat.h:483
Mat4< float > mat4
A 4 by 4 matrix of float type.
Definition: types.h:68

◆ get_model_property()

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

Gets the model property named name of type T.

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);

◆ is_deleted()

bool is_deleted ( Vertex  v) const
inline

returns whether vertex v is deleted

See also
collect_garbage()

◆ points() [1/2]

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

vector of vertex positions (read only)

Implements Model.

◆ points() [2/2]

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

vector of vertex positions

Implements Model.

◆ property_stats()

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

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

Reimplemented from Model.


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