add support for initializing property managers of mesh properties
This commit is contained in:
@@ -85,14 +85,17 @@ class PropertyManager {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Mesh properties (MPropHandleT<...>) are stored differently than the other properties.
|
// Mesh properties (MPropHandleT<...>) are stored differently than the other properties.
|
||||||
// This class implements different behavior when copying or swapping data from one
|
// This class implements different behavior when initializing a property or when
|
||||||
// property manager to a another one.
|
// copying or swapping data from one property manager to a another one.
|
||||||
template <typename PropertyManager2, typename PropHandleT>
|
template <typename PropertyManager2, typename PropHandleT>
|
||||||
struct StorageT;
|
struct StorageT;
|
||||||
|
|
||||||
// specialization for Mesh Properties
|
// specialization for Mesh Properties
|
||||||
template <typename PropertyManager2>
|
template <typename PropertyManager2>
|
||||||
struct StorageT<PropertyManager2, MPropHandleT<Value>> {
|
struct StorageT<PropertyManager2, MPropHandleT<Value>> {
|
||||||
|
static void initialize(PropertyManager<PROPTYPE, MeshT>& pm, const Value& initial_value ) {
|
||||||
|
pm() = initial_value;
|
||||||
|
}
|
||||||
static void copy(const PropertyManager<PROPTYPE, MeshT>& from, PropertyManager2& to) {
|
static void copy(const PropertyManager<PROPTYPE, MeshT>& from, PropertyManager2& to) {
|
||||||
*to = *from;
|
*to = *from;
|
||||||
}
|
}
|
||||||
@@ -110,6 +113,9 @@ class PropertyManager {
|
|||||||
// definition for other Mesh Properties
|
// definition for other Mesh Properties
|
||||||
template <typename PropertyManager2, typename PropHandleT>
|
template <typename PropertyManager2, typename PropHandleT>
|
||||||
struct StorageT {
|
struct StorageT {
|
||||||
|
static void initialize(PropertyManager<PROPTYPE, MeshT>& pm, const Value& initial_value ) {
|
||||||
|
pm.set_range(pm.mesh_.template all_elements<Handle>(), initial_value);
|
||||||
|
}
|
||||||
static void copy(const PropertyManager& from, PropertyManager2& to) {
|
static void copy(const PropertyManager& from, PropertyManager2& to) {
|
||||||
from.copy_to(from.mesh_.template all_elements<Handle>(), to, to.mesh_.template all_elements<Handle>());
|
from.copy_to(from.mesh_.template all_elements<Handle>(), to, to.mesh_.template all_elements<Handle>());
|
||||||
}
|
}
|
||||||
@@ -190,7 +196,7 @@ class PropertyManager {
|
|||||||
PropertyManager(const Value& initial_value, PolyConnectivity& mesh, const char *propname) : mesh_(mesh), retain_(true), name_(propname) {
|
PropertyManager(const Value& initial_value, PolyConnectivity& mesh, const char *propname) : mesh_(mesh), retain_(true), name_(propname) {
|
||||||
if (!mesh_.get_property_handle(prop_, propname)) {
|
if (!mesh_.get_property_handle(prop_, propname)) {
|
||||||
PropertyManager::mesh().add_property(prop_, propname);
|
PropertyManager::mesh().add_property(prop_, propname);
|
||||||
set_range(mesh_.all_elements<Handle>(), initial_value);
|
Storage::initialize(*this, initial_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +221,7 @@ class PropertyManager {
|
|||||||
*/
|
*/
|
||||||
PropertyManager(const Value& initial_value, const PolyConnectivity& mesh) : mesh_(mesh), retain_(false), name_("") {
|
PropertyManager(const Value& initial_value, const PolyConnectivity& mesh) : mesh_(mesh), retain_(false), name_("") {
|
||||||
PropertyManager::mesh().add_property(prop_, name_);
|
PropertyManager::mesh().add_property(prop_, name_);
|
||||||
set_range(mesh_.all_elements<Handle>(), initial_value);
|
Storage::initialize(*this, initial_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user