CGAL 4.12.2 - 3D Point Set
|
#include <CGAL/Point_set_3.h>
A collection of points with dynamically associated properties.
An instance of this class stores a set of indices of type Index
, each representing a point. Properties can be associated to each point and can be retrieved using the index of the point. There are two particular properties that are hard coded by this class: the coordinates of the points and the normal vectors.
The coordinates of a point can be access using the index of the point and the member function point()
. This property is always present. The normal vector of a point can be accessed using the index of the point and the normal()
function. This property must be explicitly created.
All properties can be accessed as a range using the functions points()
, normals()
, and range()
for points coordinates, normal vectors, and other properties respectively.
Removing a point with properties is achieved by moving its Index
at the end of the container and keeping track of the number of removed elements. A garbage collection method must be called to really remove it from memory.
For convenience, all functions of the package Point Set Processing Reference are provided with an overload that takes a Point_set_3 object as an argument.
Point | Point type. |
Vector | Normal vector type. |
Classes | |
class | Index |
This represents a point with associated properties. More... | |
Public Types | |
typedef unspecified_type | iterator |
Iterator type of the point set with value type Index More... | |
typedef unspecified_type | const_iterator |
Constant iterator type of the point set with value type Index More... | |
typedef Property_map< Point > | Point_map |
Property map of points. | |
typedef Property_map< Vector > | Vector_map |
Property map of vectors. | |
typedef Property_range< Point > | Point_range |
Constant range of points. | |
typedef Property_range< Vector > | Vector_range |
Constant range of vectors. | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename Point , typename Vector > | |
std::istream & | operator>> (std::istream &is, CGAL::Point_set_3< Point, Vector > &ps) |
Reads the point set from an input stream that can be either: More... | |
template<typename Point , typename Vector > | |
std::ostream & | operator<< (std::ostream &os, const CGAL::Point_set_3< Point, Vector > &ps) |
Inserts the point set in an output stream in ASCII PLY format. More... | |
template<typename Point , typename Vector > | |
Point_set_3< Point, Vector > & | operator+= (Point_set_3< Point, Vector > &ps, Point_set_3< Point, Vector > &other) |
Append other at the end of ps . More... | |
Construction, Destruction, Assignment | |
Point_set_3 (bool with_normal_map=false) | |
Creates an empty point set with no additional property. More... | |
Point_set_3 & | operator= (const Point_set_3 &ps) |
Assignment operator, all properties with their content are copied. | |
Memory Management | |
bool | is_empty () const |
Returns true if the number of elements not marked as removed is 0, false otherwise. More... | |
std::size_t | number_of_points () const |
Returns the number of elements (not counting elements marked as removed). More... | |
bool | join (Point_set_3 &other) |
Merges other in the point set. More... | |
void | clear () |
Clears the point set properties and content. More... | |
void | clear_properties () |
Clears all properties created. More... | |
void | reserve (std::size_t s) |
Increases the capacity of internal containers to be able to efficiently accommodate at least s elements. More... | |
void | resize (std::size_t s) |
Changes size of the point set. More... | |
Adding Points and Normals | |
iterator | insert () |
Inserts a new element with default property values. More... | |
iterator | insert (const Point &p) |
Inserts new point with default property values. More... | |
iterator | insert (const Point &p, const Vector &n) |
Convenience function to add a point with a normal vector. More... | |
Accessors and Iterators | |
iterator | begin () |
Returns the begin iterator. | |
iterator | end () |
Returns the past-the-end iterator. More... | |
const_iterator | begin () const |
Returns the begin constant iterator. | |
const_iterator | end () const |
Returns the past-the-end constant iterator. More... | |
Point & | point (const Index &index) |
Returns a reference to the point corresponding to index . | |
const Point & | point (const Index &index) const |
Returns a constant reference to the point corresponding to index . | |
Vector & | normal (const Index &index) |
Returns a reference to the normal corresponding to index . More... | |
const Vector & | normal (const Index &index) const |
Returns a constant reference to the normal corresponding to index . More... | |
Removal Functions | |
void | remove (iterator first, iterator last) |
Marks all elements between first and last as removed. More... | |
void | remove (iterator it) |
Marks element specified by iterator as removed. More... | |
void | remove (const Index &index) |
Marks element specified by Index as removed. More... | |
Garbage Management | |
bool | is_removed (const_iterator it) const |
Returns true if the element is marked as removed, false otherwise. More... | |
const_iterator | garbage_begin () const |
Returns the constant iterator to the first element marked as removed (equal to garbage_end() if no elements are marked as removed. | |
const_iterator | garbage_end () const |
Returns the past-the-end constant iterator of the elements marked as removed. | |
std::size_t | number_of_removed_points () const |
Number of removed points. | |
bool | has_garbage () const |
Returns true if there are elements marked as removed, false otherwise. | |
void | collect_garbage () |
Erases from memory the elements marked as removed. | |
Property Handling | |
A property Properties can be added, looked up with a string and removed at runtime. | |
template<class Type > | |
using | Property_map = unspecified_type |
Model of LvaluePropertyMap with Index as a key type and Type as value type. More... | |
template<typename T > | |
bool | has_property_map (const std::string &name) const |
Tests whether property name of type T already exists. More... | |
template<class T > | |
std::pair< Property_map< T >, bool > | add_property_map (const std::string &name, const T t=T()) |
Adds a new property name of type T with given default value. More... | |
template<class T > | |
std::pair< Property_map< T >, bool > | property_map (const std::string &name) const |
Returns the property name of type T . More... | |
template<class T > | |
bool | remove_property_map (Property_map< T > &prop) |
Removes the specified property. More... | |
bool | has_normal_map () const |
Convenience method that tests whether the point set has normals. More... | |
bool | add_normal_map (const Vector &default_value=Vector(0., 0., 0.)) |
Convenience method that adds a normal property. More... | |
Vector_map | normal_map () |
Returns the property map of the normal property. More... | |
const Vector_map | normal_map () const |
Returns the property map of the normal property (constant version). More... | |
bool | remove_normal_map () |
Convenience method that removes the normal property. More... | |
Point_map | point_map () |
Returns the property map of the point property. | |
const Point_map | point_map () const |
Returns the property map of the point property (constant version). | |
std::vector< std::string > | properties () const |
Returns a vector with all strings that describe properties. | |
unspecified_type | parameters () const |
Returns a sequence of Named Parameters for Point Set Processing algorithms. More... | |
Ranges | |
template<class Type > | |
using | Property_range = unspecified_type |
Model of ConstRange that handles constant ranges for property maps with value type Type . More... | |
template<class T > | |
Property_range< T > | range (const Property_map< T > &pmap) const |
Returns a property as a range. | |
Point_range | points () const |
Returns a constant range of points. | |
Vector_range | normals () const |
Returns a constant range of normals. | |
Push Property Maps and Inserters (Advanced) | |
Advanced
The following method are specifically designed to make
| |
template<class Property > | |
using | Property_back_inserter = unspecified_type |
This is an advanced type. More... | |
template<class Property > | |
using | Push_property_map = unspecified_type |
This is an advanced type. More... | |
typedef Property_back_inserter< Index_map > | Index_back_inserter |
This is an advanced type. More... | |
typedef Property_back_inserter< Point_map > | Point_back_inserter |
This is an advanced type. More... | |
typedef Push_property_map< Point_map > | Point_push_map |
This is an advanced type. More... | |
typedef Push_property_map< Vector_map > | Vector_push_map |
This is an advanced type. More... | |
template<class T > | |
Push_property_map< Property_map< T > > | push_property_map (Property_map< T > &prop) |
This is an advanced function. More... | |
Point_push_map | point_push_map () |
This is an advanced function. More... | |
Vector_push_map | normal_push_map () |
This is an advanced function. More... | |
Index_back_inserter | index_back_inserter () |
This is an advanced function. More... | |
Point_back_inserter | point_back_inserter () |
This is an advanced function. More... | |
typedef unspecified_type CGAL::Point_set_3< Point, Vector >::const_iterator |
Constant iterator type of the point set with value type Index
typedef Property_back_inserter<Index_map> CGAL::Point_set_3< Point, Vector >::Index_back_inserter |
This is an advanced type.
Back inserter on indices
typedef unspecified_type CGAL::Point_set_3< Point, Vector >::iterator |
typedef Property_back_inserter<Point_map> CGAL::Point_set_3< Point, Vector >::Point_back_inserter |
This is an advanced type.
Back inserter on points
typedef Push_property_map<Point_map> CGAL::Point_set_3< Point, Vector >::Point_push_map |
This is an advanced type.
Property map for pushing new points
using CGAL::Point_set_3< Point, Vector >::Property_back_inserter = unspecified_type |
This is an advanced type.
Model of OutputIterator
used to insert elements by defining the value of the property Property
.
using CGAL::Point_set_3< Point, Vector >::Property_map = unspecified_type |
Model of LvaluePropertyMap
with Index
as a key type and Type
as value type.
using CGAL::Point_set_3< Point, Vector >::Property_range = unspecified_type |
Model of ConstRange
that handles constant ranges for property maps with value type Type
.
using CGAL::Point_set_3< Point, Vector >::Push_property_map = unspecified_type |
This is an advanced type.
Model of WritablePropertyMap
based on Property
and that is allowed to push new items to the point set if needed.
typedef Push_property_map<Vector_map> CGAL::Point_set_3< Point, Vector >::Vector_push_map |
This is an advanced type.
Property map for pushing new vectors
CGAL::Point_set_3< Point, Vector >::Point_set_3 | ( | bool | with_normal_map = false | ) |
Creates an empty point set with no additional property.
with_normal_map | true if the normal map should be added. If false (default value), the normal map can still be added later on (see add_normal_map() ). |
bool CGAL::Point_set_3< Point, Vector >::add_normal_map | ( | const Vector & | default_value = Vector(0., 0., 0.) | ) |
Convenience method that adds a normal property.
This method adds a property of type Vector
and named normal
.
true
if the property was added, false
if it already existed. std::pair<Property_map<T>, bool> CGAL::Point_set_3< Point, Vector >::add_property_map | ( | const std::string & | name, |
const T | t = T() |
||
) |
Adds a new property name
of type T
with given default value.
T | type of the property. |
name | Name of the property. |
t | Value taken by the property on already created elements. |
true
if the property was added and false
if it already exists (and was therefore not added but only returned). void CGAL::Point_set_3< Point, Vector >::clear | ( | ) |
Clears the point set properties and content.
After calling this function, the object is the same as a newly constructed object. The additional properties (such as normal vectors) are also removed and must thus be re-added if needed.
void CGAL::Point_set_3< Point, Vector >::clear_properties | ( | ) |
Clears all properties created.
After calling this function, all properties are removed. The points are left unchanged.
iterator CGAL::Point_set_3< Point, Vector >::end | ( | ) |
Returns the past-the-end iterator.
garbage_begin()
. const_iterator CGAL::Point_set_3< Point, Vector >::end | ( | ) | const |
Returns the past-the-end constant iterator.
garbage_begin()
. bool CGAL::Point_set_3< Point, Vector >::has_normal_map | ( | ) | const |
Convenience method that tests whether the point set has normals.
This method tests whether a property of type Vector
and named normal
exists.
bool CGAL::Point_set_3< Point, Vector >::has_property_map | ( | const std::string & | name | ) | const |
Tests whether property name
of type T
already exists.
T | type of the property. |
name | Name of the property. |
Index_back_inserter CGAL::Point_set_3< Point, Vector >::index_back_inserter | ( | ) |
This is an advanced function.
Returns the back inserter on the index property.
iterator CGAL::Point_set_3< Point, Vector >::insert | ( | ) |
Inserts a new element with default property values.
iterator CGAL::Point_set_3< Point, Vector >::insert | ( | const Point & | p | ) |
Inserts new point with default property values.
p | Point to insert |
iterator CGAL::Point_set_3< Point, Vector >::insert | ( | const Point & | p, |
const Vector & | n | ||
) |
Convenience function to add a point with a normal vector.
p | Point to insert |
n | Associated normal vector |
bool CGAL::Point_set_3< Point, Vector >::is_empty | ( | ) | const |
Returns true
if the number of elements not marked as removed is 0, false
otherwise.
empty()
is also available (see Range
) and does the same thing. bool CGAL::Point_set_3< Point, Vector >::is_removed | ( | const_iterator | it | ) | const |
bool CGAL::Point_set_3< Point, Vector >::join | ( | Point_set_3< Point, Vector > & | other | ) |
Merges other
in the point set.
Shifts the indices of points of other
by number_of_points() + other.number_of_points()
.
Copies entries of all property maps which have the same name in the point set and other
. Property maps which are only in other
are ignored.
Vector& CGAL::Point_set_3< Point, Vector >::normal | ( | const Index & | index | ) |
Returns a reference to the normal corresponding to index
.
add_normal_map()
). const Vector& CGAL::Point_set_3< Point, Vector >::normal | ( | const Index & | index | ) | const |
Returns a constant reference to the normal corresponding to index
.
add_normal_map()
). Vector_map CGAL::Point_set_3< Point, Vector >::normal_map | ( | ) |
Returns the property map of the normal property.
add_normal_map()
). const Vector_map CGAL::Point_set_3< Point, Vector >::normal_map | ( | ) | const |
Returns the property map of the normal property (constant version).
add_normal_map()
). Vector_push_map CGAL::Point_set_3< Point, Vector >::normal_push_map | ( | ) |
This is an advanced function.
Returns the push property map of the normal property.
add_normal_map()
). std::size_t CGAL::Point_set_3< Point, Vector >::number_of_points | ( | ) | const |
Returns the number of elements (not counting elements marked as removed).
number_of_removed_points()
for getting the number of elements marked as removed.size()
is also available (see Range
) and does the same thing. unspecified_type CGAL::Point_set_3< Point, Vector >::parameters | ( | ) | const |
Returns a sequence of Named Parameters for Point Set Processing algorithms.
point_map | contains the point map (see point_map() ) |
normal_map | contains the normal map (see normal_map() ) |
geom_traits | contains the kernel typename Kernel_traits<Point> ::Kernel |
Point_back_inserter CGAL::Point_set_3< Point, Vector >::point_back_inserter | ( | ) |
This is an advanced function.
Returns the back inserter on the point property.
Point_push_map CGAL::Point_set_3< Point, Vector >::point_push_map | ( | ) |
This is an advanced function.
Returns the push property map of the point property.
std::pair<Property_map<T>,bool> CGAL::Point_set_3< Point, Vector >::property_map | ( | const std::string & | name | ) | const |
Returns the property name
of type T
.
T | type of the property. |
name | Name of the property. |
true
or an empty property map and a Boolean set to false
(if the property was not found). Push_property_map<Property_map<T> > CGAL::Point_set_3< Point, Vector >::push_property_map | ( | Property_map< T > & | prop | ) |
This is an advanced function.
Returns the push property map of the given property.
T | type of the property. |
prop | The property map. |
true
or an empty property map and a Boolean set to false
(if the property was not found). void CGAL::Point_set_3< Point, Vector >::remove | ( | iterator | first, |
iterator | last | ||
) |
Marks all elements between first
and last
as removed.
collect_garbage()
should be called if the memory needs to be disallocated.void CGAL::Point_set_3< Point, Vector >::remove | ( | iterator | it | ) |
Marks element specified by iterator as removed.
collect_garbage()
should be called if the memory needs to be freed.void CGAL::Point_set_3< Point, Vector >::remove | ( | const Index & | index | ) |
Marks element specified by Index
as removed.
collect_garbage()
should be called if the memory needs to be freed.bool CGAL::Point_set_3< Point, Vector >::remove_normal_map | ( | ) |
Convenience method that removes the normal property.
true
if the property was removed and false
if the property was not found. bool CGAL::Point_set_3< Point, Vector >::remove_property_map | ( | Property_map< T > & | prop | ) |
Removes the specified property.
T | type of the property. |
prop | The property. |
true
if the property was removed and false
if the property was not found. void CGAL::Point_set_3< Point, Vector >::reserve | ( | std::size_t | s | ) |
Increases the capacity of internal containers to be able to efficiently accommodate at least s
elements.
s | Expected final number of elements. |
void CGAL::Point_set_3< Point, Vector >::resize | ( | std::size_t | s | ) |
Changes size of the point set.
s | Target size of the point set. |
|
related |
Append other
at the end of ps
.
Shifts the indices of points of other
by ps.number_of_points() + other.number_of_points()
.
Copies entries of all property maps which have the same name in ps
and other
. Property maps which are only in other
are ignored.