51 #include <OpenMesh/Core/System/config.h> 
   52 #include <OpenMesh/Core/Mesh/Handles.hh> 
   53 #include <OpenMesh/Core/Utils/BaseProperty.hh> 
   58 #include <OpenMesh/Core/IO/SR_store.hh> 
   97   typedef std::vector<T>                          vector_type;
 
   99   typedef typename vector_type::reference         reference;
 
  100   typedef typename vector_type::const_reference   const_reference;
 
  106             const std::string& _name = 
"<unknown>",
 
  107             const std::string& _internal_type_name = 
"<unknown>")
 
  117   virtual void reserve(
size_t _n)
 override { data_.reserve(_n);    }
 
  118   virtual void resize(
size_t _n)
 override  { data_.resize(_n);     }
 
  119   virtual void clear()
 override  { data_.clear(); vector_type().swap(data_);    }
 
  120   virtual void push_back()
 override        { data_.push_back(T()); }
 
  121   virtual void swap(
size_t _i0, 
size_t _i1)
 override 
  122   { std::swap(data_[_i0], data_[_i1]); }
 
  123   virtual void copy(
size_t _i0, 
size_t _i1)
 override 
  124   { data_[_i1] = data_[_i0]; }
 
  129   { check_and_set_persistent<T>( _yn ); }
 
  131   virtual size_t       n_elements()
   const override { 
return data_.size(); }
 
  132   virtual size_t       element_size()
 const override { 
return IO::size_of<T>(); }
 
  134 #ifndef DOXY_IGNORE_THIS 
  136     size_t operator () ( 
size_t _b, 
const T& _v )
 
  137     { 
return _b + IO::size_of<T>(_v); }
 
  145     return std::accumulate(data_.begin(), data_.end(), 
size_t(0), plus());
 
  148   virtual size_t size_of(
size_t _n_elem)
 const override 
  151   virtual size_t store( std::ostream& _ostr, 
bool _swap )
 const override 
  153     if (IO::is_streamable<vector_type>() && 
element_size() != IO::UnknownSize)
 
  154       return IO::store(_ostr, data_, _swap, 
false);   
 
  158       bytes += IO::store( _ostr, data_[i], _swap);
 
  162   virtual size_t restore( std::istream& _istr, 
bool _swap )
 override 
  164     if ( IO::is_streamable<vector_type>() && 
element_size() != IO::UnknownSize)
 
  165       return IO::restore(_istr, data_, _swap, 
false);  
 
  169       bytes += IO::restore( _istr, data_[i], _swap);
 
  197     assert( 
size_t(_idx) < data_.size() );
 
  204     assert( 
size_t(_idx) < data_.size());
 
  237   typedef std::vector<bool>                       vector_type;
 
  238   typedef bool                                    value_type;
 
  239   typedef vector_type::reference                  reference;
 
  240   typedef vector_type::const_reference            const_reference;
 
  244   explicit PropertyT(
const std::string& _name = 
"<unknown>", 
const std::string& _internal_type_name=
"" )
 
  250   virtual void reserve(
size_t _n)
 override { data_.reserve(_n);    }
 
  251   virtual void resize(
size_t _n)
 override  { data_.resize(_n);     }
 
  252   virtual void clear()
 override  { data_.clear(); vector_type().swap(data_);    }
 
  253   virtual void push_back()
 override        { data_.push_back(
bool()); }
 
  254   virtual void swap(
size_t _i0, 
size_t _i1)
 override 
  255   { 
bool t(data_[_i0]); data_[_i0]=data_[_i1]; data_[_i1]=t; }
 
  256   virtual void copy(
size_t _i0, 
size_t _i1)
 override 
  257   { data_[_i1] = data_[_i0]; }
 
  263     check_and_set_persistent<bool>( _yn );
 
  266   virtual size_t       n_elements()
   const override { 
return data_.size();  }
 
  269   virtual size_t       size_of(
size_t _n_elem)
 const override 
  271     return _n_elem / 8 + ((_n_elem % 8)!=0);
 
  274   size_t store( std::ostream& _ostr, 
bool  )
 const override 
  278     size_t N = data_.size() / 8;
 
  279     size_t R = data_.size() % 8;
 
  285     for (bidx=idx=0; idx < N; ++idx, bidx+=8)
 
  287       bits = 
static_cast<unsigned char>(data_[bidx])
 
  288         | (
static_cast<unsigned char>(data_[bidx+1]) << 1)
 
  289         | (
static_cast<unsigned char>(data_[bidx+2]) << 2)
 
  290         | (
static_cast<unsigned char>(data_[bidx+3]) << 3)
 
  291         | (
static_cast<unsigned char>(data_[bidx+4]) << 4)
 
  292         | (
static_cast<unsigned char>(data_[bidx+5]) << 5)
 
  293         | (
static_cast<unsigned char>(data_[bidx+6]) << 6)
 
  294         | (
static_cast<unsigned char>(data_[bidx+7]) << 7);
 
  302       for (idx=0; idx < R; ++idx)
 
  303         bits |= 
static_cast<unsigned char>(data_[bidx+idx]) << idx;
 
  313   size_t restore( std::istream& _istr, 
bool  )
 override 
  317     size_t N = data_.size() / 8;
 
  318     size_t R = data_.size() % 8;
 
  324     for (bidx=idx=0; idx < N; ++idx, bidx+=8)
 
  327       data_[bidx+0] = (bits & 0x01) != 0;
 
  328       data_[bidx+1] = (bits & 0x02) != 0;
 
  329       data_[bidx+2] = (bits & 0x04) != 0;
 
  330       data_[bidx+3] = (bits & 0x08) != 0;
 
  331       data_[bidx+4] = (bits & 0x10) != 0;
 
  332       data_[bidx+5] = (bits & 0x20) != 0;
 
  333       data_[bidx+6] = (bits & 0x40) != 0;
 
  334       data_[bidx+7] = (bits & 0x80) != 0;
 
  341       for (idx=0; idx < R; ++idx)
 
  342         data_[bidx+idx] = (bits & (1<<idx)) != 0;
 
  365     assert( 
size_t(_idx) < data_.size() );
 
  372     assert( 
size_t(_idx) < data_.size());
 
  403   typedef std::vector<T>                          vector_type;
 
  404   typedef T                                       value_type;
 
  405   typedef typename vector_type::reference         reference;
 
  406   typedef typename vector_type::const_reference   const_reference;
 
  419   typedef T                       value_type;
 
  434   typedef T                       value_type;
 
  449   typedef T                       value_type;
 
  464   typedef T                       value_type;
 
  479   typedef T                       value_type;
 
  486 template <
typename HandleT>
 
  491   template <
typename T>
 
  497   template <
typename T>
 
  503   template <
typename T>
 
  509   template <
typename T>
 
  515   template <
typename T>
 
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
 
static std::string type_identifier(void)
A string that identifies the type of T.
Definition: SR_binary.hh:114
 
Base class for all handle types.
Definition: Handles.hh:63
 
Handle for a vertex entity.
Definition: Handles.hh:121
 
Handle for a halfedge entity.
Definition: Handles.hh:128
 
Handle for a edge entity.
Definition: Handles.hh:135
 
Handle for a face entity.
Definition: Handles.hh:142
 
Handle type for meshes to simplify some template programming.
Definition: Handles.hh:149
 
Abstract class defining the basic interface of a dynamic property.
Definition: BaseProperty.hh:61
 
BaseProperty(const std::string &_name="<unknown>", const std::string &_internal_type_name="<unknown>")
Default constructor.
Definition: BaseProperty.hh:84
 
virtual size_t size_of() const
Return size of property in bytes.
Definition: BaseProperty.hh:147
 
static const size_t UnknownSize
Indicates an error when a size is returned by a member.
Definition: BaseProperty.hh:65
 
Default property class for any type T.
Definition: Property.hh:93
 
const T * data() const
Get pointer to array (does not work for T==bool)
Definition: Property.hh:176
 
virtual void push_back() override
Extend the number of elements by one.
Definition: Property.hh:120
 
virtual size_t restore(std::istream &_istr, bool _swap) override
Restore self from a binary block.
Definition: Property.hh:162
 
virtual void copy(size_t _i0, size_t _i1) override
Copy one element to another.
Definition: Property.hh:123
 
virtual void set_persistent(bool _yn) override
Enable or disable persistency.
Definition: Property.hh:128
 
reference operator[](int _idx)
Access the i'th element. No range check is performed!
Definition: Property.hh:195
 
virtual size_t element_size() const override
Size of one element in bytes or UnknownSize if not known.
Definition: Property.hh:132
 
virtual void clear() override
Clear all elements and free memory.
Definition: Property.hh:119
 
virtual void reserve(size_t _n) override
Reserve memory for n elements.
Definition: Property.hh:117
 
PropertyT< T > * clone() const override
Make a copy of self.
Definition: Property.hh:209
 
const vector_type & data_vector() const
Const access to property vector.
Definition: Property.hh:190
 
virtual size_t size_of(void) const override
Return size of property in bytes.
Definition: Property.hh:141
 
virtual void resize(size_t _n) override
Resize storage to hold n elements.
Definition: Property.hh:118
 
virtual void swap(size_t _i0, size_t _i1) override
Let two elements swap their storage place.
Definition: Property.hh:121
 
PropertyT(const PropertyT &_rhs)
Copy constructor.
Definition: Property.hh:112
 
virtual size_t size_of(size_t _n_elem) const override
Estimated size of property if it has _n_elem elements.
Definition: Property.hh:148
 
virtual size_t n_elements() const override
Number of elements in property.
Definition: Property.hh:131
 
vector_type & data_vector()
Get reference to property vector (be careful, improper usage, e.g. resizing, may crash OpenMesh!...
Definition: Property.hh:185
 
PropertyT(const std::string &_name="<unknown>", const std::string &_internal_type_name="<unknown>")
Default constructor.
Definition: Property.hh:105
 
std::string get_storage_name() const override
returns a unique string for the type of the elements
Definition: Property.hh:215
 
virtual size_t store(std::ostream &_ostr, bool _swap) const override
Store self as one binary block.
Definition: Property.hh:151
 
const_reference operator[](int _idx) const
Const access to the i'th element. No range check is performed!
Definition: Property.hh:202
 
Property specialization for bool type.
Definition: Property.hh:234
 
virtual void push_back() override
Extend the number of elements by one.
Definition: Property.hh:253
 
virtual void set_persistent(bool _yn) override
Enable or disable persistency.
Definition: Property.hh:261
 
reference operator[](int _idx)
Access the i'th element. No range check is performed!
Definition: Property.hh:363
 
vector_type & data_vector()
Get reference to property vector (be careful, improper usage, e.g. resizing, may crash OpenMesh!...
Definition: Property.hh:353
 
virtual void copy(size_t _i0, size_t _i1) override
Copy one element to another.
Definition: Property.hh:256
 
const_reference operator[](int _idx) const
Const access to the i'th element. No range check is performed!
Definition: Property.hh:370
 
size_t restore(std::istream &_istr, bool) override
Restore self from a binary block.
Definition: Property.hh:313
 
std::string get_storage_name() const override
returns a unique string for the type of the elements
Definition: Property.hh:383
 
virtual void clear() override
Clear all elements and free memory.
Definition: Property.hh:252
 
virtual size_t size_of() const override
Return size of property in bytes.
Definition: Property.hh:268
 
PropertyT< bool > * clone() const override
Make a copy of self.
Definition: Property.hh:377
 
virtual size_t n_elements() const override
Number of elements in property.
Definition: Property.hh:266
 
virtual size_t size_of(size_t _n_elem) const override
Estimated size of property if it has _n_elem elements.
Definition: Property.hh:269
 
virtual void reserve(size_t _n) override
Reserve memory for n elements.
Definition: Property.hh:250
 
virtual void resize(size_t _n) override
Resize storage to hold n elements.
Definition: Property.hh:251
 
virtual void swap(size_t _i0, size_t _i1) override
Let two elements swap their storage place.
Definition: Property.hh:254
 
const vector_type & data_vector() const
Const access to property vector.
Definition: Property.hh:358
 
size_t store(std::ostream &_ostr, bool) const override
Store self as one binary block.
Definition: Property.hh:274
 
virtual size_t element_size() const override
Size of one element in bytes or UnknownSize if not known.
Definition: Property.hh:267
 
Base property handle.
Definition: Property.hh:401
 
Handle representing a vertex property.
Definition: Property.hh:417
 
Handle representing a halfedge property.
Definition: Property.hh:432
 
Handle representing an edge property.
Definition: Property.hh:447
 
Handle representing a face property.
Definition: Property.hh:462
 
Handle representing a mesh property.
Definition: Property.hh:477
 
Definition: Property.hh:487