57 #ifndef OPENMESH_BASE_KERNEL_HH
58 #define OPENMESH_BASE_KERNEL_HH
71 #include <OpenMesh/Core/Utils/PropertyContainer.hh>
141 vprops_.resize(n_vertices());
148 hprops_.resize(n_halfedges());
155 eprops_.resize(n_edges());
162 fprops_.resize(n_faces());
187 template <
typename T>
195 template <
typename T>
203 template <
typename T>
211 template <
typename T>
219 template <
typename T>
244 const std::string& _name)
const
251 const std::string& _name)
const
258 const std::string& _name)
const
265 const std::string& _name)
const
272 const std::string& _name)
const
295 return vprops_.property(_ph);
299 return vprops_.property(_ph);
304 return hprops_.property(_ph);
308 return hprops_.property(_ph);
313 return eprops_.property(_ph);
317 return eprops_.property(_ph);
322 return fprops_.property(_ph);
326 return fprops_.property(_ph);
331 return mprops_.property(_ph);
335 return mprops_.property(_ph);
349 typename VPropHandleT<T>::reference
351 return vprops_.property(_ph)[_vh.
idx()];
355 typename VPropHandleT<T>::const_reference
357 return vprops_.property(_ph)[_vh.
idx()];
362 typename HPropHandleT<T>::reference
364 return hprops_.property(_ph)[_hh.
idx()];
368 typename HPropHandleT<T>::const_reference
370 return hprops_.property(_ph)[_hh.
idx()];
375 typename EPropHandleT<T>::reference
377 return eprops_.property(_ph)[_eh.
idx()];
381 typename EPropHandleT<T>::const_reference
383 return eprops_.property(_ph)[_eh.
idx()];
388 typename FPropHandleT<T>::reference
390 return fprops_.property(_ph)[_fh.
idx()];
394 typename FPropHandleT<T>::const_reference
396 return fprops_.property(_ph)[_fh.
idx()];
401 typename MPropHandleT<T>::reference
403 return mprops_.property(_ph)[0];
407 typename MPropHandleT<T>::const_reference
409 return mprops_.property(_ph)[0];
426 vprops_.property(_ph)[_vh_to.
idx()] = vprops_.property(_ph)[_vh_from.
idx()];
438 hprops_.property(_ph)[_hh_to.
idx()] = hprops_.property(_ph)[_hh_from.
idx()];
450 eprops_.property(_ph)[_eh_to.
idx()] = eprops_.property(_ph)[_eh_from.
idx()];
462 fprops_.property(_ph)[_fh_to.
idx()] = fprops_.property(_ph)[_fh_from.
idx()];
478 for( PropertyContainer::iterator p_it = vprops_.begin();
479 p_it != vprops_.end(); ++p_it) {
483 if ( *p_it && ( _copyBuildIn || (*p_it)->name().substr(0,2) !=
"v:" ) )
484 (*p_it)->copy(_vh_from.
idx(), _vh_to.
idx());
497 for( PropertyContainer::iterator p_it = hprops_.begin();
498 p_it != hprops_.end(); ++p_it) {
502 if ( *p_it && ( _copyBuildIn || (*p_it)->name().substr(0,2) !=
"h:") )
503 (*p_it)->copy(_hh_from.
idx(), _hh_to.
idx());
515 for( PropertyContainer::iterator p_it = eprops_.begin();
516 p_it != eprops_.end(); ++p_it) {
520 if ( *p_it && ( _copyBuildIn || (*p_it)->name().substr(0,2) !=
"e:") )
521 (*p_it)->copy(_eh_from.
idx(), _eh_to.
idx());
535 for( PropertyContainer::iterator p_it = fprops_.begin();
536 p_it != fprops_.end(); ++p_it) {
540 if ( *p_it && ( _copyBuildIn || (*p_it)->name().substr(0,2) !=
"f:") )
541 (*p_it)->copy(_fh_from.
idx(), _fh_to.
idx());
550 size_t n_vprops(
void)
const {
return vprops_.size(); }
552 size_t n_eprops(
void)
const {
return eprops_.size(); }
554 size_t n_hprops(
void)
const {
return hprops_.size(); }
556 size_t n_fprops(
void)
const {
return fprops_.size(); }
558 size_t n_mprops(
void)
const {
return mprops_.size(); }
560 BaseProperty* _get_vprop(
const std::string& _name)
561 {
return vprops_.property(_name); }
563 BaseProperty* _get_eprop(
const std::string& _name)
564 {
return eprops_.property(_name); }
566 BaseProperty* _get_hprop(
const std::string& _name)
567 {
return hprops_.property(_name); }
569 BaseProperty* _get_fprop(
const std::string& _name)
570 {
return fprops_.property(_name); }
572 BaseProperty* _get_mprop(
const std::string& _name)
573 {
return mprops_.property(_name); }
575 const BaseProperty* _get_vprop(
const std::string& _name)
const
576 {
return vprops_.property(_name); }
578 const BaseProperty* _get_eprop(
const std::string& _name)
const
579 {
return eprops_.property(_name); }
581 const BaseProperty* _get_hprop(
const std::string& _name)
const
582 {
return hprops_.property(_name); }
584 const BaseProperty* _get_fprop(
const std::string& _name)
const
585 {
return fprops_.property(_name); }
587 const BaseProperty* _get_mprop(
const std::string& _name)
const
588 {
return mprops_.property(_name); }
590 BaseProperty& _vprop(
size_t _idx ) {
return vprops_._property( _idx ); }
591 BaseProperty& _eprop(
size_t _idx ) {
return eprops_._property( _idx ); }
592 BaseProperty& _hprop(
size_t _idx ) {
return hprops_._property( _idx ); }
593 BaseProperty& _fprop(
size_t _idx ) {
return fprops_._property( _idx ); }
594 BaseProperty& _mprop(
size_t _idx ) {
return mprops_._property( _idx ); }
596 const BaseProperty& _vprop(
size_t _idx )
const
597 {
return vprops_._property( _idx ); }
598 const BaseProperty& _eprop(
size_t _idx )
const
599 {
return eprops_._property( _idx ); }
600 const BaseProperty& _hprop(
size_t _idx )
const
601 {
return hprops_._property( _idx ); }
602 const BaseProperty& _fprop(
size_t _idx )
const
603 {
return fprops_._property( _idx ); }
604 const BaseProperty& _mprop(
size_t _idx )
const
605 {
return mprops_._property( _idx ); }
607 size_t _add_vprop( BaseProperty* _bp ) {
return vprops_._add( _bp ); }
608 size_t _add_eprop( BaseProperty* _bp ) {
return eprops_._add( _bp ); }
609 size_t _add_hprop( BaseProperty* _bp ) {
return hprops_._add( _bp ); }
610 size_t _add_fprop( BaseProperty* _bp ) {
return fprops_._add( _bp ); }
611 size_t _add_mprop( BaseProperty* _bp ) {
return mprops_._add( _bp ); }
615 BaseProperty& _vprop( BaseHandle _h )
616 {
return vprops_._property( _h.idx() ); }
617 BaseProperty& _eprop( BaseHandle _h )
618 {
return eprops_._property( _h.idx() ); }
619 BaseProperty& _hprop( BaseHandle _h )
620 {
return hprops_._property( _h.idx() ); }
621 BaseProperty& _fprop( BaseHandle _h )
622 {
return fprops_._property( _h.idx() ); }
623 BaseProperty& _mprop( BaseHandle _h )
624 {
return mprops_._property( _h.idx() ); }
626 const BaseProperty& _vprop( BaseHandle _h )
const
627 {
return vprops_._property( _h.idx() ); }
628 const BaseProperty& _eprop( BaseHandle _h )
const
629 {
return eprops_._property( _h.idx() ); }
630 const BaseProperty& _hprop( BaseHandle _h )
const
631 {
return hprops_._property( _h.idx() ); }
632 const BaseProperty& _fprop( BaseHandle _h )
const
633 {
return fprops_._property( _h.idx() ); }
634 const BaseProperty& _mprop( BaseHandle _h )
const
635 {
return mprops_._property( _h.idx() ); }
641 virtual size_t n_vertices()
const {
return 0; }
642 virtual size_t n_halfedges()
const {
return 0; }
643 virtual size_t n_edges()
const {
return 0; }
644 virtual size_t n_faces()
const {
return 0; }
665 void vprops_clear() {
669 void vprops_swap(
unsigned int _i0,
unsigned int _i1)
const {
670 vprops_.swap(_i0, _i1);
673 void hprops_reserve(
size_t _n)
const { hprops_.reserve(_n); }
674 void hprops_resize(
size_t _n)
const { hprops_.resize(_n); }
675 void hprops_clear() {
678 void hprops_swap(
unsigned int _i0,
unsigned int _i1)
const {
679 hprops_.swap(_i0, _i1);
682 void eprops_reserve(
size_t _n)
const { eprops_.reserve(_n); }
683 void eprops_resize(
size_t _n)
const { eprops_.resize(_n); }
684 void eprops_clear() {
687 void eprops_swap(
unsigned int _i0,
unsigned int _i1)
const {
688 eprops_.swap(_i0, _i1);
691 void fprops_reserve(
size_t _n)
const { fprops_.reserve(_n); }
692 void fprops_resize(
size_t _n)
const { fprops_.resize(_n); }
693 void fprops_clear() {
696 void fprops_swap(
unsigned int _i0,
unsigned int _i1)
const {
697 fprops_.swap(_i0, _i1);
700 void mprops_resize(
size_t _n)
const { mprops_.resize(_n); }
701 void mprops_clear() {
708 void property_stats()
const;
709 void property_stats(std::ostream& _ostr)
const;
711 void vprop_stats( std::string& _string )
const;
712 void hprop_stats( std::string& _string )
const;
713 void eprop_stats( std::string& _string )
const;
714 void fprop_stats( std::string& _string )
const;
715 void mprop_stats( std::string& _string )
const;
718 void vprop_stats()
const;
719 void hprop_stats()
const;
720 void eprop_stats()
const;
721 void fprop_stats()
const;
722 void mprop_stats()
const;
724 void vprop_stats(std::ostream& _ostr)
const;
725 void hprop_stats(std::ostream& _ostr)
const;
726 void eprop_stats(std::ostream& _ostr)
const;
727 void fprop_stats(std::ostream& _ostr)
const;
728 void mprop_stats(std::ostream& _ostr)
const;
732 typedef PropertyContainer::iterator prop_iterator;
733 typedef PropertyContainer::const_iterator const_prop_iterator;
735 prop_iterator vprops_begin() {
return vprops_.begin(); }
736 prop_iterator vprops_end() {
return vprops_.end(); }
737 const_prop_iterator vprops_begin()
const {
return vprops_.begin(); }
738 const_prop_iterator vprops_end()
const {
return vprops_.end(); }
740 prop_iterator eprops_begin() {
return eprops_.begin(); }
741 prop_iterator eprops_end() {
return eprops_.end(); }
742 const_prop_iterator eprops_begin()
const {
return eprops_.begin(); }
743 const_prop_iterator eprops_end()
const {
return eprops_.end(); }
745 prop_iterator hprops_begin() {
return hprops_.begin(); }
746 prop_iterator hprops_end() {
return hprops_.end(); }
747 const_prop_iterator hprops_begin()
const {
return hprops_.begin(); }
748 const_prop_iterator hprops_end()
const {
return hprops_.end(); }
750 prop_iterator fprops_begin() {
return fprops_.begin(); }
751 prop_iterator fprops_end() {
return fprops_.end(); }
752 const_prop_iterator fprops_begin()
const {
return fprops_.begin(); }
753 const_prop_iterator fprops_end()
const {
return fprops_.end(); }
755 prop_iterator mprops_begin() {
return mprops_.begin(); }
756 prop_iterator mprops_end() {
return mprops_.end(); }
757 const_prop_iterator mprops_begin()
const {
return mprops_.begin(); }
758 const_prop_iterator mprops_end()
const {
return mprops_.end(); }
762 PropertyContainer vprops_;
763 PropertyContainer hprops_;
764 PropertyContainer eprops_;
765 PropertyContainer fprops_;
766 PropertyContainer mprops_;
773 #endif // OPENMESH_BASE_KERNEL_HH defined
HPropHandleT< T >::const_reference property(HPropHandleT< T > _ph, HalfedgeHandle _hh) const
void add_property(VPropHandleT< T > &_ph, const std::string &_name="<vprop>")
bool get_property_handle(HPropHandleT< T > &_ph, const std::string &_name) const
VPropHandleT< T >::const_reference property(VPropHandleT< T > _ph, VertexHandle _vh) const
void copy_property(HPropHandleT< T > _ph, HalfedgeHandle _hh_from, HalfedgeHandle _hh_to)
VPropHandleT< T >::reference property(VPropHandleT< T > _ph, VertexHandle _vh)
PropertyT< T > & property(HPropHandleT< T > _ph)
const PropertyT< T > & property(VPropHandleT< T > _ph) const
PropertyT< T > & property(VPropHandleT< T > _ph)
void add_property(FPropHandleT< T > &_ph, const std::string &_name="<fprop>")
const PropertyT< T > & property(FPropHandleT< T > _ph) const
Default property class for any type T.
EPropHandleT< T >::const_reference property(EPropHandleT< T > _ph, EdgeHandle _eh) const
void copy_all_properties(EdgeHandle _eh_from, EdgeHandle _eh_to, bool _copyBuildIn=false)
bool is_valid() const
The handle is valid iff the index is not equal to -1.
void remove_property(MPropHandleT< T > &_ph)
MPropHandleT< T >::reference property(MPropHandleT< T > _ph)
Handle for a halfedge entity.
int idx() const
Get the underlying index of this handle.
void copy_all_properties(VertexHandle _vh_from, VertexHandle _vh_to, bool _copyBuildIn=false)
const PropertyT< T > & mproperty(MPropHandleT< T > _ph) const
void add_property(HPropHandleT< T > &_ph, const std::string &_name="<hprop>")
PropertyT< T > & mproperty(MPropHandleT< T > _ph)
const PropertyT< T > & property(EPropHandleT< T > _ph) const
void remove_property(FPropHandleT< T > &_ph)
void copy_all_properties(FaceHandle _fh_from, FaceHandle _fh_to, bool _copyBuildIn=false)
EPropHandleT< T >::reference property(EPropHandleT< T > _ph, EdgeHandle _eh)
bool get_property_handle(MPropHandleT< T > &_ph, const std::string &_name) const
bool get_property_handle(EPropHandleT< T > &_ph, const std::string &_name) const
void remove_property(HPropHandleT< T > &_ph)
void vprops_reserve(size_t _n) const
Reserves space for _n elements in all vertex property vectors.
void copy_all_properties(HalfedgeHandle _hh_from, HalfedgeHandle _hh_to, bool _copyBuildIn=false)
Handle for a vertex entity.
bool get_property_handle(FPropHandleT< T > &_ph, const std::string &_name) const
Handle for a edge entity.
Handle for a face entity.
void copy_property(VPropHandleT< T > &_ph, VertexHandle _vh_from, VertexHandle _vh_to)
FPropHandleT< T >::const_reference property(FPropHandleT< T > _ph, FaceHandle _fh) const
void remove_property(VPropHandleT< T > &_ph)
void copy_property(FPropHandleT< T > _ph, FaceHandle _fh_from, FaceHandle _fh_to)
bool get_property_handle(VPropHandleT< T > &_ph, const std::string &_name) const
void copy_property(EPropHandleT< T > _ph, EdgeHandle _eh_from, EdgeHandle _eh_to)
HPropHandleT< T >::reference property(HPropHandleT< T > _ph, HalfedgeHandle _hh)
void remove_property(EPropHandleT< T > &_ph)
void add_property(MPropHandleT< T > &_ph, const std::string &_name="<mprop>")
PropertyT< T > & property(FPropHandleT< T > _ph)
PropertyT< T > & property(EPropHandleT< T > _ph)
MPropHandleT< T >::const_reference property(MPropHandleT< T > _ph) const
void add_property(EPropHandleT< T > &_ph, const std::string &_name="<eprop>")
void vprops_resize_if_smaller(size_t _n) const
void reset()
reset handle to be invalid
void vprops_resize(size_t _n) const
Resizes all vertex property vectors to the specified size.
const PropertyT< T > & property(HPropHandleT< T > _ph) const
FPropHandleT< T >::reference property(FPropHandleT< T > _ph, FaceHandle _fh)