Commit 232e4774 authored by Philip Trettner's avatar Philip Trettner
Browse files

added mesh copy to

parent dbbc28a6
......@@ -91,6 +91,10 @@ public:
/// copies as much data as possible from the given attribute
void copy_from(attribute<AttrT> const& data);
/// copies all attribute data to another mesh
/// asserts that sizes are correct
attribute<AttrT> copy_to(Mesh const& m) const;
/// Saves ALL data into a vector (includes possibly removed ones)
std::vector<AttrT> to_vector() const;
// TODO: specialized implementation of to_vector(FuncT&&)
......
......@@ -78,6 +78,14 @@ void primitive_attribute<tag, AttrT>::copy_from(attribute<AttrT> const &data)
this->mData[i] = data.mData[i];
}
template <class tag, class AttrT>
auto primitive_attribute<tag, AttrT>::copy_to(Mesh const &m) const -> attribute<AttrT>
{
attribute<AttrT> new_attr(m, this->mDefaultValue);
new_attr.copy_from(this->data(), this->size());
return new_attr;
}
template <class tag, class AttrT>
std::vector<AttrT> primitive_attribute<tag, AttrT>::to_vector() const
{
......@@ -348,9 +356,8 @@ void primitive_attribute<tag, AttrT>::compute(FuncT &&f)
template <class tag, class AttrT>
template <class FuncT>
auto primitive_attribute<tag, AttrT>::view(FuncT &&f) const -> readonly_property<primitive_attribute<tag, AttrT> const&, FuncT>
auto primitive_attribute<tag, AttrT>::view(FuncT &&f) const -> readonly_property<primitive_attribute<tag, AttrT> const &, FuncT>
{
return readonly_property<primitive_attribute<tag, AttrT> const&, FuncT>(*this, f);
return readonly_property<primitive_attribute<tag, AttrT> const &, FuncT>(*this, f);
}
}
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