43 #ifndef OPENVOLUMEMESHPROPERTY_HH
44 #define OPENVOLUMEMESHPROPERTY_HH
55 #include "OpenVolumeMeshBaseProperty.hh"
56 #include "OpenVolumeMeshHandle.hh"
58 namespace OpenVolumeMesh {
73 template <
class PropT,
class HandleT>
friend class PropertyPtr;
76 typedef std::vector<T> vector_type;
78 typedef typename vector_type::reference reference;
79 typedef typename vector_type::const_reference const_reference;
102 data_.resize(_n, def_);
106 vector_type().swap(data_);
109 data_.push_back(def_);
111 virtual void swap(
size_t _i0,
size_t _i1) {
116 data_.erase(data_.begin() + _idx);
128 #ifndef DOXY_IGNORE_THIS
130 size_t operator ()(
size_t _b,
const T& ) {
131 return _b +
sizeof(T);
139 return std::accumulate(data_.begin(), data_.end(), 0,
plus());
142 virtual size_t size_of(
size_t _n_elem)
const {
147 virtual void serialize(std::ostream& _ostr)
const {
148 OpenVolumeMeshBaseProperty::serialize(_ostr);
149 for(
typename vector_type::const_iterator it = data_.begin();
150 it != data_.end(); ++it) {
151 _ostr << *it << std::endl;
156 virtual void deserialize(std::istream& _istr) {
157 for(
unsigned int i = 0; i <
n_elements(); ++i) {
184 assert(
size_t(_idx) < data_.size());
190 assert(
size_t(_idx) < data_.size());
200 typename vector_type::const_iterator begin()
const {
return data_.begin(); }
202 typename vector_type::iterator begin() {
return data_.begin(); }
204 typename vector_type::const_iterator end()
const {
return data_.end(); }
206 typename vector_type::iterator end() {
return data_.end(); }
213 assert(_tags.size() == data_.size());
214 vector_type new_data;
215 typename vector_type::iterator d_it = data_.begin();
216 std::vector<bool>::const_iterator t_it = _tags.begin();
217 std::vector<bool>::const_iterator t_end = _tags.end();
218 for(; t_it != t_end; ++t_it, ++d_it) {
220 new_data.push_back(*d_it);
223 data_.swap(new_data);
243 template <
class PropT,
class HandleT>
friend class PropertyPtr;
245 typedef std::vector<bool> vector_type;
246 typedef bool value_type;
247 typedef vector_type::reference reference;
248 typedef vector_type::const_reference const_reference;
264 data_.resize(_n, def_);
268 vector_type().swap(data_);
271 data_.push_back(def_);
273 virtual void swap(
size_t _i0,
size_t _i1) {
275 data_[_i0] = data_[_i1];
280 data_.erase(data_.begin() + _idx);
294 virtual size_t size_of(
size_t _n_elem)
const {
295 return _n_elem / 8 + ((_n_elem % 8) != 0);
302 assert(
size_t(_idx) < data_.size());
308 assert(
size_t(_idx) < data_.size());
319 vector_type::const_iterator begin()
const {
return data_.begin(); }
321 vector_type::iterator begin() {
return data_.begin(); }
323 vector_type::const_iterator end()
const {
return data_.end(); }
325 vector_type::iterator end() {
return data_.end(); }
332 assert(_tags.size() == data_.size());
333 vector_type new_data;
334 vector_type::iterator d_it = data_.begin();
335 std::vector<bool>::const_iterator t_it = _tags.begin();
336 std::vector<bool>::const_iterator t_end = _tags.end();
337 for(; t_it != t_end; ++t_it, ++d_it) {
339 new_data.push_back(*d_it);
342 data_.swap(new_data);
362 template <
class PropT,
class HandleT>
friend class PropertyPtr;
364 typedef std::string Value;
365 typedef std::vector<std::string> vector_type;
366 typedef std::string value_type;
367 typedef vector_type::reference reference;
368 typedef vector_type::const_reference const_reference;
384 data_.resize(_n, def_);
388 vector_type().swap(data_);
391 data_.push_back(def_);
393 virtual void swap(
size_t _i0,
size_t _i1) {
398 data_.erase(data_.begin() + _idx);
410 return sizeof(data_);
417 virtual void stats(std::ostream& _ostr)
const {
418 for(vector_type::const_iterator it = data_.begin();
419 it != data_.end(); ++it) {
426 const value_type*
data()
const {
430 return (value_type*) &data_[0];
435 assert(
size_t(_idx) < data_.size());
436 return ((value_type*) &data_[0])[_idx];
441 assert(
size_t(_idx) < data_.size());
442 return ((value_type*) &data_[0])[_idx];
451 vector_type::const_iterator begin()
const {
return data_.begin(); }
453 vector_type::iterator begin() {
return data_.begin(); }
455 vector_type::const_iterator end()
const {
return data_.end(); }
457 vector_type::iterator end() {
return data_.end(); }
464 assert(_tags.size() == data_.size());
465 vector_type new_data;
466 vector_type::iterator d_it = data_.begin();
467 std::vector<bool>::const_iterator t_it = _tags.begin();
468 std::vector<bool>::const_iterator t_end = _tags.end();
469 for(; t_it != t_end; ++t_it, ++d_it) {
471 new_data.push_back(*d_it);
474 data_.swap(new_data);
481 const std::string def_;
487 #endif // OPENVOLUMEMESHPROPERTY_HH defined