mirror of https://github.com/CGAL/cgal
Cleanup of the properties API
This commit is contained in:
parent
c01176760c
commit
1fc44743cf
|
|
@ -29,13 +29,28 @@ int main()
|
|||
// give each vertex a name, the default is empty
|
||||
Mesh::Property_map<vertex_descriptor,std::string> name;
|
||||
bool created;
|
||||
boost::tie(name, created) = m.property_map<vertex_descriptor,std::string>("v:name", "noname");
|
||||
boost::tie(name, created) = m.add_property_map<vertex_descriptor,std::string>("v:name", "noname");
|
||||
assert(created);
|
||||
// add some names to the vertices
|
||||
name[v0] = "hello";
|
||||
name[v2] = "world";
|
||||
|
||||
// retrieve the point property
|
||||
{
|
||||
// You can't add a property if it already exists
|
||||
Mesh::Property_map<vertex_descriptor,std::string> name;
|
||||
bool created;
|
||||
boost::tie(name, created) = m.add_property_map<vertex_descriptor,std::string>("v:name", "noname");
|
||||
assert(! created);
|
||||
}
|
||||
|
||||
// You can't get a property that does not exist
|
||||
Mesh::Property_map<face_descriptor,std::string> gnus;
|
||||
bool found;
|
||||
boost::tie(gnus, found) = m.property_map<face_descriptor,std::string>("v:gnus");
|
||||
assert(! found);
|
||||
|
||||
|
||||
// retrieve the point property for which exists a convenience function
|
||||
Mesh::Property_map<vertex_descriptor, K::Point_3> location = m.points();
|
||||
BOOST_FOREACH( vertex_descriptor vd, m.vertices()) {
|
||||
std::cout << name[vd] << " @ " << location[vd] << std::endl;
|
||||
|
|
|
|||
|
|
@ -1897,25 +1897,27 @@ private: //--------------------------------------------------- property handling
|
|||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/// adds a property map named `name` with value type `T` and default `t`
|
||||
/// for index type `I`. Returns an invalid property map if a property
|
||||
/// map named `name` already exists.
|
||||
/// for index type `I`. Returns the property map together with a Boolean
|
||||
/// that is `true` if a new map was created. In case it already exists
|
||||
/// the existing map together with `false` is returned.
|
||||
|
||||
|
||||
template<class I, class T>
|
||||
Property_map<I, T>
|
||||
std::pair<Property_map<I, T>, bool>
|
||||
add_property_map(const std::string& name, const T t=T()) {
|
||||
return (this->*boost::fusion::at_key<I>(pmap_)).template add<T>(name, t);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// returns a property map named `name` with key type `I` and value type `T`, and a Boolean
|
||||
/// that is `true` if the property map gets newly created.
|
||||
|
||||
/// returns a property map named `name` with key type `I` and value type `T`,
|
||||
/// and a Boolean that is `true` if the property exists.
|
||||
/// In case it does not exist the Boolean is `false` and the behavior of
|
||||
/// the property map is undefined.
|
||||
template <class I, class T>
|
||||
std::pair<Property_map<I, T>,bool> property_map(const std::string& name, const T& t=T()) const
|
||||
std::pair<Property_map<I, T>,bool> property_map(const std::string& name) const
|
||||
{
|
||||
return (this->*boost::fusion::at_key<I>(pmap_)).template get<T>(name, t);
|
||||
return (this->*boost::fusion::at_key<I>(pmap_)).template get<T>(name);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue