Added functions to copy all properties between entities. (Thanks to Duncan Paterson for the patch)
refs #990 git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@675 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -440,6 +440,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
|
||||
|
||||
public: // used by non-native kernel and MeshIO, should be protected
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<value_type>* p = new PropertyT<value_type>( *this );
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
vector_type data_;
|
||||
|
||||
Reference in New Issue
Block a user