| OpenMesh

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Static Public Member Functions | List of all members
OpenMesh::PropertyManager< PROPTYPE, MeshT > Class Template Reference

This class is intended to manage the lifecycle of properties. More...

`#include <OpenMesh/Core/Utils/PropertyManager.hh>`

## Classes
class | Proxy

## Public Member Functions
| PropertyManager (MeshT &mesh, const char *propname, bool existing=false)
| Constructor. More...
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)
PropertyManager & | operator= (Proxy p)
Proxy | duplicate (const char *clone_name)
void | retain (bool doRetain=true)
| Disable lifecycle management for this property. More...
PROPTYPE & | operator* ()
| Access the encapsulated property.
const PROPTYPE & | operator* () const
| Access the encapsulated property.
template<typename HandleType >
PROPTYPE::reference | operator[] (const HandleType &handle)
| Enables convenient access to the encapsulated property. More...
template<typename HandleType >
PROPTYPE::const_reference | operator[] (const HandleType &handle) const
| Enables convenient access to the encapsulated property. More...
template<typename HandleTypeIterator , typename PROP_VALUE >
void | set_range (HandleTypeIterator begin, HandleTypeIterator end, const PROP_VALUE &value)
| Conveniently set the property for an entire range of values. More...
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
| Conveniently transfer the values managed by one property manager onto the values managed by a different property manager. More...
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)
| Create a property manager for the supplied property and mesh. More...
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)
| Copy the values of a property from a source range to a target range. More...

## 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.

For C++11, it is recommended to use the factory functions makePropertyManagerFromNew, makePropertyManagerFromExisting, makePropertyManagerFromExistingOrNew to construct a PropertyManager, e.g.

TriMesh mesh;
auto visited = makePropertyManagerFromNew<VPropHandleT<bool>>(mesh, "visited.plugin-example.i8.informatik.rwth-aachen.de");
for (auto vh : mesh.vertices()) {
if (!visited[vh]) {
visitComponent(mesh, vh, visited);
}
}

For C++98, it is usually more convenient to use the constructor explicitly, i.e.

TriMesh mesh;
PropertyManager<VPropHandleT<bool>, TriMesh> visited(mesh, "visited.plugin-example.i8.informatik.rwth-aachen.de");
for (TriMesh::VertexIter vh_it = mesh.begin(); ... ; ...) {
if (!visited[*vh_it]) {
visitComponent(mesh, *vh_it, visited);
}
}

## Constructor & Destructor Documentation

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

  mesh | The mesh on which to create the property.
  propname | The name of the property.
  existing | If 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

## Member Function Documentation

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
| ) |  |
| inline static

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_name | Name of the property to copy. Must exist on the source mesh. Will be created on the target mesh if it doesn't exist.
  src_mesh | Source mesh from which to copy.
  src_range | Source range which to copy. Must not be smaller than dst_range.
  dst_mesh | Destination mesh on which to copy.
  dst_range | Destination range.

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

  begin | Start iterator. Needs to dereference to HandleType. Will be used with this property manager.
  end | End iterator. (Exclusive.) Will be used with this property manager.
  dst_propmanager | The destination property manager.
  dst_begin | Start iterator. Needs to dereference to the HandleType of dst_propmanager. Will be used with dst_propmanager.
  dst_end | End iterator. (Exclusive.) Will be used with dst_propmanager. Used to double check the bounds.

template<typename PROPTYPE, typename MeshT>

static Proxy OpenMesh::PropertyManager< PROPTYPE, MeshT >::createIfNotExists | ( | MeshT & | mesh,
|  | const char * | propname
| ) |  |
| inline static

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

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

  handle | A handle of the appropriate handle type. (I.e. `VertexHandle` for `VPropHandleT`, etc.)

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

  handle | A handle of the appropriate handle type. (I.e. `VertexHandle` for `VPropHandleT`, etc.)

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.

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

  begin | Start iterator. Needs to dereference to HandleType.
  end | End iterator. (Exclusive.)
  value | The value the range will be set to.

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

- OpenMesh/Core/Utils/PropertyManager.hh