Commit 4ac81ca0 authored by Martin Heistermann's avatar Martin Heistermann

Implement Property copy(src_idx, dst_idx) analogue of OpenMesh properties.

This allows assigning property values even if the property type is
unknown, e.g. when iterating over mesh properties.
parent 8ef9b0bb
......@@ -69,6 +69,8 @@ public:
virtual void swap_elements(size_t _idx0, size_t _idx1) = 0;
virtual void copy(size_t _src_idx, size_t _dst_idx) = 0;
virtual void serialize(std::ostream& _ostr) const = 0;
virtual void deserialize(std::istream& _istr) = 0;
......
......@@ -112,10 +112,12 @@ public:
virtual void swap(size_t _i0, size_t _i1) {
std::swap(data_[_i0], data_[_i1]);
}
void delete_element(size_t _idx) {
data_.erase(data_.begin() + _idx);
}
virtual void copy(size_t _src_idx, size_t _dst_idx) {
data_[_dst_idx] = data_[_src_idx];
}
void delete_element(size_t _idx) {
data_.erase(data_.begin() + _idx);
}
public:
......@@ -273,6 +275,9 @@ public:
data_[_i0] = data_[_i1];
data_[_i1] = t;
}
virtual void copy(size_t _src_idx, size_t _dst_idx) {
data_[_dst_idx] = data_[_src_idx];
}
void delete_element(size_t _idx) {
data_.erase(data_.begin() + _idx);
......@@ -408,7 +413,9 @@ public:
virtual void swap(size_t _i0, size_t _i1) {
std::swap(data_[_i0], data_[_i1]);
}
virtual void copy(size_t _src_idx, size_t _dst_idx) {
data_[_dst_idx] = data_[_src_idx];
}
virtual void delete_element(size_t _idx) {
data_.erase(data_.begin() + _idx);
}
......
......@@ -85,6 +85,8 @@ public:
virtual void swap_elements(size_t _idx0, size_t _idx1);
virtual void copy(size_t _src_idx, size_t _dst_idx);
const_iterator begin() const { return ptr::shared_ptr<PropT>::get()->begin(); }
iterator begin() { return ptr::shared_ptr<PropT>::get()->begin(); }
......
......@@ -88,6 +88,11 @@ void PropertyPtr<PropT,HandleT>::swap_elements(size_t _idx0, size_t _idx1) {
ptr::shared_ptr<PropT>::get()->swap(_idx0, _idx1);
}
template <class PropT, class HandleT>
void PropertyPtr<PropT,HandleT>::copy(size_t _src_idx, size_t _dst_idx) {
ptr::shared_ptr<PropT>::get()->copy(_src_idx, _dst_idx);
}
template <class PropT, class HandleT>
void PropertyPtr<PropT,HandleT>::set_handle(const OpenVolumeMeshHandle& _handle) {
return ptr::shared_ptr<PropT>::get()->set_handle(_handle);
......
......@@ -161,3 +161,12 @@ TEST_F(PolyhedralMeshBase, StatusTest) {
StatusAttrib status(mesh_);
}
TEST_F(PolyhedralMeshBase, PropValueCopyTest) {
generatePolyhedralMesh(mesh_);
VertexPropertyT<int> prop = mesh_.request_vertex_property<int>();
prop[0] = 1234;
prop[1] = 2345;
prop.copy(0, 1);
EXPECT_EQ(prop[1], 1234);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment