Developer Documentation
OpenMesh::PropertyManager< PROPTYPE, MeshT > Class Template Reference

#include <OpenFlipper/libs_required/OpenMesh/src/OpenMesh/Core/Utils/PropertyManager.hh>

Classes

class  Proxy
 

Public Member Functions

 PropertyManager (MeshT &mesh, const char *propname, bool existing=false)
 
void swap (PropertyManager &rhs)
 
bool isValid () const
 
 operator bool () const
 
const PROPTYPE & getRawProperty () const
 
const std::string & getName () const
 
MeshT & getMesh () const
 
 operator Proxy ()
 
Proxy move ()
 
 PropertyManager (Proxy p)
 
PropertyManageroperator= (Proxy p)
 
Proxy duplicate (const char *clone_name)
 
void retain (bool doRetain=true)
 Disable lifecycle management for this property. More...
 
PROPTYPE & operator* ()
 
const PROPTYPE & operator* () const
 
template<typename HandleType >
PROPTYPE::reference operator[] (const HandleType &handle)
 
template<typename HandleType >
PROPTYPE::const_reference operator[] (const HandleType &handle) const
 
template<typename HandleTypeIterator , typename PROP_VALUE >
void set_range (HandleTypeIterator begin, HandleTypeIterator end, const PROP_VALUE &value)
 
template<typename HandleTypeIterator , typename PROPTYPE_2 , typename MeshT_2 , typename HandleTypeIterator_2 >
void copy_to (HandleTypeIterator begin, HandleTypeIterator end, PropertyManager< PROPTYPE_2, MeshT_2 > &dst_propmanager, HandleTypeIterator_2 dst_begin, HandleTypeIterator_2 dst_end) const
 
template<typename RangeType , typename PROPTYPE_2 , typename MeshT_2 , typename RangeType_2 >
void copy_to (const RangeType &range, PropertyManager< PROPTYPE_2, MeshT_2 > &dst_propmanager, const RangeType_2 &dst_range) const
 

Static Public Member Functions

static bool propertyExists (MeshT &mesh, const char *propname)
 
static Proxy createIfNotExists (MeshT &mesh, const char *propname)
 
template<typename PROP_VALUE , typename ITERATOR_TYPE >
static Proxy createIfNotExists (MeshT &mesh, const char *propname, const ITERATOR_TYPE &begin, const ITERATOR_TYPE &end, const PROP_VALUE &init_value)
 
template<typename RangeType , typename MeshT_2 , typename RangeType_2 >
static void copy (const char *prop_name, MeshT &src_mesh, const RangeType &src_range, MeshT_2 &dst_mesh, const RangeType_2 &dst_range)
 

Private Member Functions

 PropertyManager (const PropertyManager &)
 
PropertyManageroperator= (const PropertyManager &)
 
void deleteProperty ()
 

Private Attributes

MeshT * mesh_
 
PROPTYPE prop_
 
bool retain_
 
std::string name_
 

Related Functions

(Note that these are not member functions.)

template<typename ElementT , typename T , typename MeshT >
PropertyManager< typename HandleToPropHandle< ElementT, T >::type, MeshT > makeTemporaryProperty (MeshT &mesh, const char *propname="")
 
template<typename ElementT , typename T , typename MeshT >
PropertyManager< typename HandleToPropHandle< ElementT, T >::type, MeshT > getProperty (MeshT &mesh, const char *propname)
 
template<typename ElementT , typename T , typename MeshT >
PropertyManager< typename HandleToPropHandle< ElementT, T >::type, MeshT > getOrMakeProperty (MeshT &mesh, const char *propname)
 
template<typename PROPTYPE , typename MeshT >
PropertyManager< PROPTYPE, MeshT > makePropertyManagerFromNew (MeshT &mesh, const char *propname)
 
template<typename PROPTYPE , typename MeshT >
PropertyManager< PROPTYPE, MeshT > makePropertyManagerFromExisting (MeshT &mesh, const char *propname)
 
template<typename PROPTYPE , typename MeshT >
PropertyManager< PROPTYPE, MeshT > makePropertyManagerFromExistingOrNew (MeshT &mesh, const char *propname)
 
template<typename PROPTYPE , typename MeshT , typename ITERATOR_TYPE , typename PROP_VALUE >
PropertyManager< PROPTYPE, MeshT > makePropertyManagerFromExistingOrNew (MeshT &mesh, const char *propname, const ITERATOR_TYPE &begin, const ITERATOR_TYPE &end, const PROP_VALUE &init_value)
 
template<typename PROPTYPE , typename MeshT , typename ITERATOR_RANGE , typename PROP_VALUE >
PropertyManager< PROPTYPE, MeshT > makePropertyManagerFromExistingOrNew (MeshT &mesh, const char *propname, const ITERATOR_RANGE &range, const PROP_VALUE &init_value)
 

Detailed Description

template<typename PROPTYPE, typename MeshT>
class OpenMesh::PropertyManager< PROPTYPE, MeshT >

This class is intended to manage the lifecycle of properties. It also defines convenience operators to access the encapsulated property's value.

It is recommended to use the factory functions makeTemporaryProperty(), getProperty(), and getOrMakeProperty() to construct a PropertyManager, e.g.

{
TriMesh mesh;
auto visited = makeTemporaryProperty<VertexHandle, bool>(mesh);
for (auto vh : mesh.vertices()) {
if (!visited[vh]) {
visitComponent(mesh, vh, visited);
}
}
// The property is automatically removed at the end of the scope
}

Definition at line 77 of file PropertyManager.hh.

Constructor & Destructor Documentation

◆ PropertyManager() [1/2]

template<typename PROPTYPE, typename MeshT>
OpenMesh::PropertyManager< PROPTYPE, MeshT >::PropertyManager ( const PropertyManager< PROPTYPE, MeshT > &  )
private

Noncopyable because there aren't no straightforward copy semantics.

◆ PropertyManager() [2/2]

template<typename PROPTYPE, typename MeshT>
OpenMesh::PropertyManager< PROPTYPE, MeshT >::PropertyManager ( MeshT &  mesh,
const char *  propname,
bool  existing = false 
)
inline

Constructor.

Throws an std::runtime_error if existing is true and no property named propname of the appropriate property type exists.

Parameters
meshThe mesh on which to create the property.
propnameThe name of the property.
existingIf false, a new property is created and its lifecycle is managed (i.e. the property is deleted upon destruction of the PropertyManager instance). If true, the instance merely acts as a convenience wrapper around an existing property with no lifecycle management whatsoever.
See also
PropertyManager::createIfNotExists, makePropertyManagerFromNew, makePropertyManagerFromExisting, makePropertyManagerFromExistingOrNew

Definition at line 113 of file PropertyManager.hh.

Member Function Documentation

◆ copy()

template<typename PROPTYPE, typename MeshT>
template<typename RangeType , typename MeshT_2 , typename RangeType_2 >
static void OpenMesh::PropertyManager< PROPTYPE, MeshT >::copy ( const char *  prop_name,
MeshT &  src_mesh,
const RangeType &  src_range,
MeshT_2 &  dst_mesh,
const RangeType_2 &  dst_range 
)
inlinestatic

Copy the values of a property from a source range to a target range. The source range must not be smaller than the target range.

Parameters
prop_nameName of the property to copy. Must exist on the source mesh. Will be created on the target mesh if it doesn't exist.
src_meshSource mesh from which to copy.
src_rangeSource range which to copy. Must not be smaller than dst_range.
dst_meshDestination mesh on which to copy.
dst_rangeDestination range.

Definition at line 453 of file PropertyManager.hh.

◆ copy_to()

template<typename PROPTYPE, typename MeshT>
template<typename HandleTypeIterator , typename PROPTYPE_2 , typename MeshT_2 , typename HandleTypeIterator_2 >
void OpenMesh::PropertyManager< PROPTYPE, MeshT >::copy_to ( HandleTypeIterator  begin,
HandleTypeIterator  end,
PropertyManager< PROPTYPE_2, MeshT_2 > &  dst_propmanager,
HandleTypeIterator_2  dst_begin,
HandleTypeIterator_2  dst_end 
) const
inline

Conveniently transfer the values managed by one property manager onto the values managed by a different property manager.

Parameters
beginStart iterator. Needs to dereference to HandleType. Will be used with this property manager.
endEnd iterator. (Exclusive.) Will be used with this property manager.
dst_propmanagerThe destination property manager.
dst_beginStart iterator. Needs to dereference to the HandleType of dst_propmanager. Will be used with dst_propmanager.
dst_endEnd iterator. (Exclusive.) Will be used with dst_propmanager. Used to double check the bounds.

Definition at line 420 of file PropertyManager.hh.

◆ createIfNotExists() [1/2]

template<typename PROPTYPE, typename MeshT>
static Proxy OpenMesh::PropertyManager< PROPTYPE, MeshT >::createIfNotExists ( MeshT &  mesh,
const char *  propname 
)
inlinestatic

Create a property manager for the supplied property and mesh. If the property doesn't exist, it is created. In any case, lifecycle management is disabled.

See also
makePropertyManagerFromExistingOrNew

Definition at line 282 of file PropertyManager.hh.

◆ createIfNotExists() [2/2]

template<typename PROPTYPE, typename MeshT>
template<typename PROP_VALUE , typename ITERATOR_TYPE >
static Proxy OpenMesh::PropertyManager< PROPTYPE, MeshT >::createIfNotExists ( MeshT &  mesh,
const char *  propname,
const ITERATOR_TYPE &  begin,
const ITERATOR_TYPE &  end,
const PROP_VALUE &  init_value 
)
inlinestatic

Like createIfNotExists() with two parameters except, if the property doesn't exist, it is initialized with the supplied value over the supplied range after creation. If the property already exists, this method has the exact same effect as the two parameter version. Lifecycle management is disabled in any case.

See also
makePropertyManagerFromExistingOrNew

Definition at line 299 of file PropertyManager.hh.

◆ operator*() [1/2]

template<typename PROPTYPE, typename MeshT>
PROPTYPE& OpenMesh::PropertyManager< PROPTYPE, MeshT >::operator* ( )
inline

Access the encapsulated property.

Definition at line 330 of file PropertyManager.hh.

◆ operator*() [2/2]

template<typename PROPTYPE, typename MeshT>
const PROPTYPE& OpenMesh::PropertyManager< PROPTYPE, MeshT >::operator* ( ) const
inline

Access the encapsulated property.

Definition at line 337 of file PropertyManager.hh.

◆ operator=()

template<typename PROPTYPE, typename MeshT>
PropertyManager& OpenMesh::PropertyManager< PROPTYPE, MeshT >::operator= ( const PropertyManager< PROPTYPE, MeshT > &  )
private

Noncopyable because there aren't no straightforward copy semantics.

◆ operator[]() [1/2]

template<typename PROPTYPE, typename MeshT>
template<typename HandleType >
PROPTYPE::reference OpenMesh::PropertyManager< PROPTYPE, MeshT >::operator[] ( const HandleType &  handle)
inline

Enables convenient access to the encapsulated property.

For a usage example see this class' documentation.

Parameters
handleA handle of the appropriate handle type. (I.e. VertexHandle for VPropHandleT, etc.)

Definition at line 349 of file PropertyManager.hh.

◆ operator[]() [2/2]

template<typename PROPTYPE, typename MeshT>
template<typename HandleType >
PROPTYPE::const_reference OpenMesh::PropertyManager< PROPTYPE, MeshT >::operator[] ( const HandleType &  handle) const
inline

Enables convenient access to the encapsulated property.

For a usage example see this class' documentation.

Parameters
handleA handle of the appropriate handle type. (I.e. VertexHandle for VPropHandleT, etc.)

Definition at line 361 of file PropertyManager.hh.

◆ retain()

template<typename PROPTYPE, typename MeshT>
void OpenMesh::PropertyManager< PROPTYPE, MeshT >::retain ( bool  doRetain = true)
inline

Disable lifecycle management for this property.

If this method is called, the encapsulated property will not be deleted upon destruction of the PropertyManager instance.

Definition at line 323 of file PropertyManager.hh.

◆ set_range()

template<typename PROPTYPE, typename MeshT>
template<typename HandleTypeIterator , typename PROP_VALUE >
void OpenMesh::PropertyManager< PROPTYPE, MeshT >::set_range ( HandleTypeIterator  begin,
HandleTypeIterator  end,
const PROP_VALUE &  value 
)
inline

Conveniently set the property for an entire range of values.

Examples:

MeshT mesh;
PropertyManager<VPropHandleT<double>, MeshT> distance(
mesh, "distance.plugin-example.i8.informatik.rwth-aachen.de");
distance.set_range(
mesh.vertices_begin(), mesh.vertices_end(),
std::numeric_limits<double>::infinity());

or

MeshT::VertexHandle vh;
distance.set_range(
mesh.vv_begin(vh), mesh.vv_end(vh),
std::numeric_limits<double>::infinity());
Parameters
beginStart iterator. Needs to dereference to HandleType.
endEnd iterator. (Exclusive.)
valueThe value the range will be set to.

Definition at line 390 of file PropertyManager.hh.

Friends And Related Function Documentation

◆ getOrMakeProperty()

template<typename ElementT , typename T , typename MeshT >
PropertyManager< typename HandleToPropHandle< ElementT, T >::type, MeshT > getOrMakeProperty ( MeshT &  mesh,
const char *  propname 
)
related

Obtains a handle to a named property if it exists or creates a new one otherwise.

Used for creating or accessing permanent properties.

Example:

PolyMesh m;
{
auto is_quad = getOrMakeProperty<FaceHandle, bool>(m, "is_quad");
for (auto& fh : m.faces()) {
is_quad[fh] = (m.valence(fh) == 4);
}
// The property remains on the mesh after the end of the scope.
}
{
// Retrieve the property from the previous scope.
auto is_quad = getOrMakeProperty<FaceHandle, bool>(m, "is_quad");
// Use is_quad here.
}
Parameters
meshThe mesh on which the property is created
propnameThe name of the created property
Template Parameters
ElementTElement type of the created property, e.g. VertexHandle, HalfedgeHandle, etc.
TValue type of the created property, e.g., double, int, etc.
MeshTType of the mesh. Can often be inferred from mesh
Returns
A PropertyManager wrapping the property

Definition at line 577 of file PropertyManager.hh.

◆ getProperty()

template<typename ElementT , typename T , typename MeshT >
PropertyManager< typename HandleToPropHandle< ElementT, T >::type, MeshT > getProperty ( MeshT &  mesh,
const char *  propname 
)
related

Obtains a handle to a named property.

Example:

PolyMesh m;
{
try {
auto is_quad = getProperty<FaceHandle, bool>(m, "is_quad");
// Use is_quad here.
}
catch (const std::runtime_error& e) {
// There is no is_quad face property on the mesh.
}
}
Precondition
Property with the name propname of matching type exists.
Exceptions
std::runtime_errorif no property with the name propname of matching type exists.
Parameters
meshThe mesh on which the property is created
propnameThe name of the created property
Template Parameters
ElementTElement type of the created property, e.g. VertexHandle, HalfedgeHandle, etc.
TValue type of the created property, e.g., double, int, etc.
MeshTType of the mesh. Can often be inferred from mesh
Returns
A PropertyManager wrapping the property

Definition at line 541 of file PropertyManager.hh.

◆ makePropertyManagerFromExisting()

template<typename PROPTYPE , typename MeshT >
PropertyManager< PROPTYPE, MeshT > makePropertyManagerFromExisting ( MeshT &  mesh,
const char *  propname 
)
related
Deprecated:
Use getProperty() instead.

Creates a non-owning wrapper for an existing mesh property (no lifecycle management).

Intended for convenient access.

Precondition
Property with the name propname of matching type exists.
Exceptions
std::runtime_errorif no property with the name propname of matching type exists.

Definition at line 611 of file PropertyManager.hh.

◆ makePropertyManagerFromExistingOrNew() [1/3]

template<typename PROPTYPE , typename MeshT >
PropertyManager< PROPTYPE, MeshT > makePropertyManagerFromExistingOrNew ( MeshT &  mesh,
const char *  propname 
)
related
Deprecated:
Use getOrMakeProperty() instead.

Creates a non-owning wrapper for a mesh property (no lifecycle management). If the given property does not exist, it is created.

Intended for creating or accessing persistent properties.

Definition at line 626 of file PropertyManager.hh.

◆ makePropertyManagerFromExistingOrNew() [2/3]

template<typename PROPTYPE , typename MeshT , typename ITERATOR_TYPE , typename PROP_VALUE >
PropertyManager< PROPTYPE, MeshT > makePropertyManagerFromExistingOrNew ( MeshT &  mesh,
const char *  propname,
const ITERATOR_TYPE &  begin,
const ITERATOR_TYPE &  end,
const PROP_VALUE &  init_value 
)
related

Like the two parameter version of makePropertyManagerFromExistingOrNew() except it initializes the property with the specified value over the specified range if it needs to be created. If the property already exists, this function has the exact same effect as the two parameter version.

Creates a non-owning wrapper for a mesh property (no lifecycle management). If the given property does not exist, it is created.

Intended for creating or accessing persistent properties.

Definition at line 644 of file PropertyManager.hh.

◆ makePropertyManagerFromExistingOrNew() [3/3]

template<typename PROPTYPE , typename MeshT , typename ITERATOR_RANGE , typename PROP_VALUE >
PropertyManager< PROPTYPE, MeshT > makePropertyManagerFromExistingOrNew ( MeshT &  mesh,
const char *  propname,
const ITERATOR_RANGE &  range,
const PROP_VALUE &  init_value 
)
related

Like the two parameter version of makePropertyManagerFromExistingOrNew() except it initializes the property with the specified value over the specified range if it needs to be created. If the property already exists, this function has the exact same effect as the two parameter version.

Creates a non-owning wrapper for a mesh property (no lifecycle management). If the given property does not exist, it is created.

Intended for creating or accessing persistent properties.

Definition at line 665 of file PropertyManager.hh.

◆ makePropertyManagerFromNew()

template<typename PROPTYPE , typename MeshT >
PropertyManager< PROPTYPE, MeshT > makePropertyManagerFromNew ( MeshT &  mesh,
const char *  propname 
)
related
Deprecated:
Use makeTemporaryProperty() instead.

Creates a new property whose lifecycle is managed by the returned PropertyManager.

Intended for temporary properties. Shadows any existing properties of matching name and type.

Definition at line 592 of file PropertyManager.hh.

◆ makeTemporaryProperty()

template<typename ElementT , typename T , typename MeshT >
PropertyManager< typename HandleToPropHandle< ElementT, T >::type, MeshT > makeTemporaryProperty ( MeshT &  mesh,
const char *  propname = "" 
)
related

Creates a new property whose lifetime is limited to the current scope.

Used for temporary properties. Shadows any existing properties of matching name and type.

Example:

PolyMesh m;
{
auto is_quad = makeTemporaryProperty<FaceHandle, bool>(m);
for (auto& fh : m.faces()) {
is_quad[fh] = (m.valence(fh) == 4);
}
// The property is automatically removed from the mesh at the end of the scope.
}
Parameters
meshThe mesh on which the property is created
propname(optional) The name of the created property
Template Parameters
ElementTElement type of the created property, e.g. VertexHandle, HalfedgeHandle, etc.
TValue type of the created property, e.g., double, int, etc.
MeshTType of the mesh. Can often be inferred from mesh
Returns
A PropertyManager handling the lifecycle of the property

Definition at line 507 of file PropertyManager.hh.


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