28#ifndef EASY3D_CORE_POINT_CLOUD_H
29#define EASY3D_CORE_POINT_CLOUD_H
31#include <easy3d/core/model.h>
32#include <easy3d/core/types.h>
33#include <easy3d/core/property.h>
60 int idx()
const {
return idx_; }
70 return idx_ == _rhs.idx_;
75 return idx_ != _rhs.idx_;
80 return idx_ < _rhs.idx_;
85 std::size_t operator()(
const BaseHandle& h)
const {
return h.
idx(); }
99 std::ostream& operator<<(std::ostream& os)
const {
return os <<
'v' <<
idx(); }
145 typename Property<T>::const_reference
operator[](
size_t idx)
const
173 return (hnd_==rhs.hnd_);
276 unsigned int vertices_size()
const {
return (
unsigned int) vprops_.size(); }
285 void resize(
unsigned int nv) { vprops_.resize(nv); }
388 return vprops_.rename(old_name, new_name);
393 return mprops_.rename(old_name, new_name);
400 return vprops_.get_type(
name);
406 return mprops_.get_type(
name);
412 return vprops_.properties();
417 return mprops_.properties();
463 const std::vector<vec3>&
points()
const override {
return vpoint_.vector(); }
466 std::vector<vec3>&
points()
override {
return vpoint_.vector(); }
482 PropertyContainer vprops_;
483 PropertyContainer mprops_;
485 VertexProperty<bool> vdeleted_;
486 VertexProperty<vec3> vpoint_;
488 unsigned int deleted_vertices_;
498 return (os <<
'v' << v.
idx());
The base class of renderable 3D models.
Definition: model.h:49
const std::string & name() const
The name of a model.
Definition: model.h:60
Base class for topology types (internally it is basically an index)
Definition: point_cloud.h:53
bool operator!=(const BaseHandle &_rhs) const
are two handles different?
Definition: point_cloud.h:74
bool is_valid() const
return whether the handle is valid, i.e., the index is not equal to -1.
Definition: point_cloud.h:66
int idx() const
Get the underlying index of this handle.
Definition: point_cloud.h:60
bool operator<(const BaseHandle &_rhs) const
compare operator useful for sorting handles
Definition: point_cloud.h:79
bool operator==(const BaseHandle &_rhs) const
are two handles equal?
Definition: point_cloud.h:69
void reset()
reset handle to be invalid (index=-1)
Definition: point_cloud.h:63
BaseHandle(int _idx=-1)
constructor
Definition: point_cloud.h:57
Cloud property of type T.
Definition: point_cloud.h:131
ModelProperty()=default
default constructor
Property< T >::const_reference operator[](size_t idx) const
access the data stored for the cloud
Definition: point_cloud.h:145
Property< T >::reference operator[](size_t idx)
access the data stored for the cloud
Definition: point_cloud.h:139
this helper class is a container for iterating through all vertices using C++11 range-based for-loops...
Definition: point_cloud.h:212
this class iterates linearly over all vertices
Definition: point_cloud.h:158
VertexIterator(Vertex v=Vertex(), const PointCloud *m=nullptr)
Default constructor.
Definition: point_cloud.h:162
Vertex operator*() const
get the vertex the iterator refers to
Definition: point_cloud.h:168
bool operator==(const VertexIterator &rhs) const
are two iterators equal?
Definition: point_cloud.h:171
VertexIterator & operator--()
pre-decrement iterator
Definition: point_cloud.h:192
bool operator!=(const VertexIterator &rhs) const
are two iterators different?
Definition: point_cloud.h:177
VertexIterator & operator++()
pre-increment iterator
Definition: point_cloud.h:183
Vertex property of type T.
Definition: point_cloud.h:107
Property< T >::const_reference operator[](Vertex v) const
access the data stored for vertex v
Definition: point_cloud.h:121
Property< T >::reference operator[](Vertex v)
access the data stored for vertex v
Definition: point_cloud.h:115
VertexProperty()=default
default constructor
A data structure for point clouds.
Definition: point_cloud.h:45
const vec3 & position(Vertex v) const
position of a vertex (read only)
Definition: point_cloud.h:457
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 o...
Definition: point_cloud.h:398
PointCloud()
default constructor
Definition: point_cloud.cpp:32
bool remove_vertex_property(const std::string &n)
remove the vertex property named n
Definition: point_cloud.h:377
PointCloud & operator+=(const PointCloud &other)
Merges another point cloud into the current one. Shifts the indices of vertices of the other point cl...
Definition: point_cloud.h:244
bool rename_vertex_property(const std::string &old_name, const std::string &new_name)
rename a vertex property given its name
Definition: point_cloud.h:387
VertexContainer vertices() const
returns vertex container for C++11 range-based for-loops
Definition: point_cloud.h:444
PointCloud & operator=(const PointCloud &rhs)
assign rhs to *this. performs a deep copy of all properties.
Definition: point_cloud.cpp:49
bool has_garbage() const
are there deleted vertices?
Definition: point_cloud.h:288
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 adde...
Definition: point_cloud.h:361
ModelProperty< T > get_model_property(const std::string &name) const
Gets the model property named name of type T.
Definition: point_cloud.h:354
std::vector< std::string > vertex_properties() const
returns the names of all vertex properties
Definition: point_cloud.h:410
PointCloud & assign(const PointCloud &rhs)
assign rhs to *this. does not copy custom properties.
Definition: point_cloud.cpp:90
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 ...
Definition: point_cloud.h:340
bool is_deleted(Vertex v) const
returns whether vertex v is deleted
Definition: point_cloud.h:298
std::vector< std::string > model_properties() const
returns the names of all model properties
Definition: point_cloud.h:415
void collect_garbage()
remove deleted vertices
Definition: point_cloud.cpp:202
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...
Definition: point_cloud.h:404
std::vector< vec3 > & points() override
vector of vertex positions
Definition: point_cloud.h:466
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...
Definition: point_cloud.h:367
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 ex...
Definition: point_cloud.h:319
bool remove_model_property(ModelProperty< T > &p)
remove the model property p
Definition: point_cloud.h:381
bool rename_model_property(const std::string &old_name, const std::string &new_name)
rename a model property given its name
Definition: point_cloud.h:392
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.
Definition: point_cloud.h:333
void property_stats(std::ostream &output) const override
prints the names of all properties to an output stream (e.g., std::cout)
Definition: point_cloud.cpp:144
void clear()
clear cloud: remove all vertices
Definition: point_cloud.cpp:122
void resize(unsigned int nv)
resize space for vertices and their currently associated properties.
Definition: point_cloud.h:285
PointCloud(const PointCloud &rhs)
copy constructor: copies rhs to *this. performs a deep copy of all properties.
Definition: point_cloud.h:234
PointCloud & join(const PointCloud &other)
Merges another point cloud into the current one. Shifts the indices of vertices of the other point cl...
Definition: point_cloud.cpp:73
~PointCloud() override=default
destructor (is virtual, since we inherit from Geometry_representation)
vec3 & position(Vertex v)
position of a vertex
Definition: point_cloud.h:460
unsigned int vertices_size() const
returns number of (deleted and valid) vertices in the cloud
Definition: point_cloud.h:276
bool remove_model_property(const std::string &n)
remove the model property named n
Definition: point_cloud.h:384
void delete_vertex(Vertex v)
deletes the vertex v from the cloud
Definition: point_cloud.cpp:188
VertexIterator vertices_begin() const
returns start iterator for vertices
Definition: point_cloud.h:432
bool remove_vertex_property(VertexProperty< T > &p)
remove the vertex property p
Definition: point_cloud.h:374
VertexIterator vertices_end() const
returns end iterator for vertices
Definition: point_cloud.h:438
bool is_valid(Vertex v) const
return whether vertex v is valid, i.e. the index is stores it within the array bounds.
Definition: point_cloud.h:304
const std::vector< vec3 > & points() const override
vector of vertex positions (read only)
Definition: point_cloud.h:463
unsigned int n_vertices() const
returns number of vertices in the cloud
Definition: point_cloud.h:279
Vertex add_vertex(const vec3 &p)
add a new vertex with position p
Definition: point_cloud.cpp:177
Implementation of a generic property.
Definition: property.h:253
Definition: collider.cpp:182
std::ostream & operator<<(std::ostream &os, Graph::Vertex v)
Definition: graph.h:920
helper structure to be able to use std::unordered_map
Definition: point_cloud.h:84
this type represents a vertex (internally it is basically an index)
Definition: point_cloud.h:96
Vertex(int _idx=-1)
default constructor (with invalid index)
Definition: point_cloud.h:98