diff --git a/src/OpenMesh/Core/Mesh/BaseKernel.hh b/src/OpenMesh/Core/Mesh/BaseKernel.hh index 53d60ddf..35f1cab2 100644 --- a/src/OpenMesh/Core/Mesh/BaseKernel.hh +++ b/src/OpenMesh/Core/Mesh/BaseKernel.hh @@ -439,6 +439,46 @@ public: //------------------------------------------------ copy property } //@} + + +public: + //------------------------------------------------ copy all properties + //@{ + + /** Copies all properties from one mesh element to another (of the same type) + * + * \param _vh_from A vertex handle - source + * \param _vh_to A vertex handle - target + * + */ + void copy_all_properties(VertexHandle _vh_from, VertexHandle _vh_to) { + for( PropertyContainer::iterator p_it = vprops_.begin(); + p_it != vprops_.end(); ++p_it) { + (*p_it)->copy(_vh_from.idx(), _vh_to.idx()); + } + } + + void copy_all_properties(HalfedgeHandle _hh_from, HalfedgeHandle _hh_to) { + for( PropertyContainer::iterator p_it = hprops_.begin(); + p_it != hprops_.end(); ++p_it) { + (*p_it)->copy(_hh_from.idx(), _hh_to.idx()); + } + } + + void copy_all_properties(EdgeHandle _eh_from, EdgeHandle _eh_to) { + for( PropertyContainer::iterator p_it = eprops_.begin(); + p_it != eprops_.end(); ++p_it) { + (*p_it)->copy(_eh_from.idx(), _eh_to.idx()); + } + } + + void copy_all_properties(FaceHandle _fh_from, FaceHandle _fh_to) { + for( PropertyContainer::iterator p_it = fprops_.begin(); + p_it != fprops_.end(); ++p_it) { + (*p_it)->copy(_fh_from.idx(), _fh_to.idx()); + } + } + //@} protected: //------------------------------------------------- low-level access diff --git a/src/OpenMesh/Core/Utils/BaseProperty.hh b/src/OpenMesh/Core/Utils/BaseProperty.hh index ae2b7d58..e2b385f3 100644 --- a/src/OpenMesh/Core/Utils/BaseProperty.hh +++ b/src/OpenMesh/Core/Utils/BaseProperty.hh @@ -106,6 +106,9 @@ public: // synchronized array interface /// Let two elements swap their storage place. virtual void swap(size_t _i0, size_t _i1) = 0; + /// Copy one element to another + virtual void copy(size_t _io, size_t _i1) = 0; + /// Return a deep copy of self. virtual BaseProperty* clone () const = 0; diff --git a/src/OpenMesh/Core/Utils/Property.hh b/src/OpenMesh/Core/Utils/Property.hh index 6fb27360..5aff1d11 100644 --- a/src/OpenMesh/Core/Utils/Property.hh +++ b/src/OpenMesh/Core/Utils/Property.hh @@ -113,6 +113,8 @@ public: // inherited from BaseProperty virtual void push_back() { data_.push_back(T()); } virtual void swap(size_t _i0, size_t _i1) { std::swap(data_[_i0], data_[_i1]); } + virtual void copy(size_t _i0, size_t _i1) + { data_[_i1] = data_[_i0]; } public: @@ -234,6 +236,8 @@ public: // inherited from BaseProperty virtual void push_back() { data_.push_back(bool()); } virtual void swap(size_t _i0, size_t _i1) { bool t(data_[_i0]); data_[_i0]=data_[_i1]; data_[_i1]=t; } + virtual void copy(size_t _i0, size_t _i1) + { data_[_i1] = data_[_i0]; } public: @@ -397,6 +401,8 @@ public: // inherited from BaseProperty virtual void swap(size_t _i0, size_t _i1) { std::swap(data_[_i0], data_[_i1]); } + virtual void copy(size_t _i0, size_t _i1) + { data_[_i1] = data_[_i0]; } public: @@ -443,8 +449,6 @@ public: PropertyT* p = new PropertyT( *this ); return p; } - - private: vector_type data_;