50 #ifndef OPENMESH_BASE_KERNEL_HH
51 #define OPENMESH_BASE_KERNEL_HH
57 #include <OpenMesh/Core/System/config.h>
63 #include <OpenMesh/Core/Utils/PropertyContainer.hh>
133 vprops_.resize(n_vertices());
140 hprops_.resize(n_halfedges());
147 eprops_.resize(n_edges());
154 fprops_.resize(n_faces());
179 template <
typename T>
187 template <
typename T>
195 template <
typename T>
203 template <
typename T>
211 template <
typename T>
236 const std::string& _name)
const
243 const std::string& _name)
const
250 const std::string& _name)
const
257 const std::string& _name)
const
264 const std::string& _name)
const
287 return vprops_.property(_ph);
291 return vprops_.property(_ph);
296 return hprops_.property(_ph);
300 return hprops_.property(_ph);
305 return eprops_.property(_ph);
309 return eprops_.property(_ph);
314 return fprops_.property(_ph);
318 return fprops_.property(_ph);
323 return mprops_.property(_ph);
327 return mprops_.property(_ph);
341 typename VPropHandleT<T>::reference
343 return vprops_.property(_ph)[_vh.
idx()];
347 typename VPropHandleT<T>::const_reference
349 return vprops_.property(_ph)[_vh.
idx()];
354 typename HPropHandleT<T>::reference
356 return hprops_.property(_ph)[_hh.
idx()];
360 typename HPropHandleT<T>::const_reference
362 return hprops_.property(_ph)[_hh.
idx()];
367 typename EPropHandleT<T>::reference
369 return eprops_.property(_ph)[_eh.
idx()];
373 typename EPropHandleT<T>::const_reference
375 return eprops_.property(_ph)[_eh.
idx()];
380 typename FPropHandleT<T>::reference
382 return fprops_.property(_ph)[_fh.
idx()];
386 typename FPropHandleT<T>::const_reference
388 return fprops_.property(_ph)[_fh.
idx()];
393 typename MPropHandleT<T>::reference
395 return mprops_.property(_ph)[0];
399 typename MPropHandleT<T>::const_reference
401 return mprops_.property(_ph)[0];
418 vprops_.property(_ph)[_vh_to.
idx()] = vprops_.property(_ph)[_vh_from.
idx()];
430 hprops_.property(_ph)[_hh_to.
idx()] = hprops_.property(_ph)[_hh_from.
idx()];
442 eprops_.property(_ph)[_eh_to.
idx()] = eprops_.property(_ph)[_eh_from.
idx()];
454 fprops_.property(_ph)[_fh_to.
idx()] = fprops_.property(_ph)[_fh_from.
idx()];
470 for( PropertyContainer::iterator p_it = vprops_.begin();
471 p_it != vprops_.end(); ++p_it) {
475 if ( *p_it && ( _copyBuildIn || (*p_it)->name().substr(0,2) !=
"v:" ) )
476 (*p_it)->copy(_vh_from.
idx(), _vh_to.
idx());
489 for( PropertyContainer::iterator p_it = hprops_.begin();
490 p_it != hprops_.end(); ++p_it) {
494 if ( *p_it && ( _copyBuildIn || (*p_it)->name().substr(0,2) !=
"h:") )
495 (*p_it)->copy(_hh_from.
idx(), _hh_to.
idx());
507 for( PropertyContainer::iterator p_it = eprops_.begin();
508 p_it != eprops_.end(); ++p_it) {
512 if ( *p_it && ( _copyBuildIn || (*p_it)->name().substr(0,2) !=
"e:") )
513 (*p_it)->copy(_eh_from.
idx(), _eh_to.
idx());
527 for( PropertyContainer::iterator p_it = fprops_.begin();
528 p_it != fprops_.end(); ++p_it) {
532 if ( *p_it && ( _copyBuildIn || (*p_it)->name().substr(0,2) !=
"f:") )
533 (*p_it)->copy(_fh_from.
idx(), _fh_to.
idx());
542 size_t n_vprops(
void)
const {
return vprops_.size(); }
544 size_t n_eprops(
void)
const {
return eprops_.size(); }
546 size_t n_hprops(
void)
const {
return hprops_.size(); }
548 size_t n_fprops(
void)
const {
return fprops_.size(); }
550 size_t n_mprops(
void)
const {
return mprops_.size(); }
552 BaseProperty* _get_vprop(
const std::string& _name)
553 {
return vprops_.property(_name); }
555 BaseProperty* _get_eprop(
const std::string& _name)
556 {
return eprops_.property(_name); }
558 BaseProperty* _get_hprop(
const std::string& _name)
559 {
return hprops_.property(_name); }
561 BaseProperty* _get_fprop(
const std::string& _name)
562 {
return fprops_.property(_name); }
564 BaseProperty* _get_mprop(
const std::string& _name)
565 {
return mprops_.property(_name); }
567 const BaseProperty* _get_vprop(
const std::string& _name)
const
568 {
return vprops_.property(_name); }
570 const BaseProperty* _get_eprop(
const std::string& _name)
const
571 {
return eprops_.property(_name); }
573 const BaseProperty* _get_hprop(
const std::string& _name)
const
574 {
return hprops_.property(_name); }
576 const BaseProperty* _get_fprop(
const std::string& _name)
const
577 {
return fprops_.property(_name); }
579 const BaseProperty* _get_mprop(
const std::string& _name)
const
580 {
return mprops_.property(_name); }
582 BaseProperty& _vprop(
size_t _idx ) {
return vprops_._property( _idx ); }
583 BaseProperty& _eprop(
size_t _idx ) {
return eprops_._property( _idx ); }
584 BaseProperty& _hprop(
size_t _idx ) {
return hprops_._property( _idx ); }
585 BaseProperty& _fprop(
size_t _idx ) {
return fprops_._property( _idx ); }
586 BaseProperty& _mprop(
size_t _idx ) {
return mprops_._property( _idx ); }
588 const BaseProperty& _vprop(
size_t _idx )
const
589 {
return vprops_._property( _idx ); }
590 const BaseProperty& _eprop(
size_t _idx )
const
591 {
return eprops_._property( _idx ); }
592 const BaseProperty& _hprop(
size_t _idx )
const
593 {
return hprops_._property( _idx ); }
594 const BaseProperty& _fprop(
size_t _idx )
const
595 {
return fprops_._property( _idx ); }
596 const BaseProperty& _mprop(
size_t _idx )
const
597 {
return mprops_._property( _idx ); }
599 size_t _add_vprop( BaseProperty* _bp ) {
return vprops_._add( _bp ); }
600 size_t _add_eprop( BaseProperty* _bp ) {
return eprops_._add( _bp ); }
601 size_t _add_hprop( BaseProperty* _bp ) {
return hprops_._add( _bp ); }
602 size_t _add_fprop( BaseProperty* _bp ) {
return fprops_._add( _bp ); }
603 size_t _add_mprop( BaseProperty* _bp ) {
return mprops_._add( _bp ); }
607 BaseProperty& _vprop( BaseHandle _h )
608 {
return vprops_._property( _h.idx() ); }
609 BaseProperty& _eprop( BaseHandle _h )
610 {
return eprops_._property( _h.idx() ); }
611 BaseProperty& _hprop( BaseHandle _h )
612 {
return hprops_._property( _h.idx() ); }
613 BaseProperty& _fprop( BaseHandle _h )
614 {
return fprops_._property( _h.idx() ); }
615 BaseProperty& _mprop( BaseHandle _h )
616 {
return mprops_._property( _h.idx() ); }
618 const BaseProperty& _vprop( BaseHandle _h )
const
619 {
return vprops_._property( _h.idx() ); }
620 const BaseProperty& _eprop( BaseHandle _h )
const
621 {
return eprops_._property( _h.idx() ); }
622 const BaseProperty& _hprop( BaseHandle _h )
const
623 {
return hprops_._property( _h.idx() ); }
624 const BaseProperty& _fprop( BaseHandle _h )
const
625 {
return fprops_._property( _h.idx() ); }
626 const BaseProperty& _mprop( BaseHandle _h )
const
627 {
return mprops_._property( _h.idx() ); }
633 virtual size_t n_vertices()
const {
return 0; }
634 virtual size_t n_halfedges()
const {
return 0; }
635 virtual size_t n_edges()
const {
return 0; }
636 virtual size_t n_faces()
const {
return 0; }
641 void vprops_reserve(
size_t _n)
const { vprops_.reserve(_n); }
642 void vprops_resize(
size_t _n)
const { vprops_.resize(_n); }
643 void vprops_clear() {
646 void vprops_swap(
unsigned int _i0,
unsigned int _i1)
const {
647 vprops_.swap(_i0, _i1);
650 void hprops_reserve(
size_t _n)
const { hprops_.reserve(_n); }
651 void hprops_resize(
size_t _n)
const { hprops_.resize(_n); }
652 void hprops_clear() {
655 void hprops_swap(
unsigned int _i0,
unsigned int _i1)
const {
656 hprops_.swap(_i0, _i1);
659 void eprops_reserve(
size_t _n)
const { eprops_.reserve(_n); }
660 void eprops_resize(
size_t _n)
const { eprops_.resize(_n); }
661 void eprops_clear() {
664 void eprops_swap(
unsigned int _i0,
unsigned int _i1)
const {
665 eprops_.swap(_i0, _i1);
668 void fprops_reserve(
size_t _n)
const { fprops_.reserve(_n); }
669 void fprops_resize(
size_t _n)
const { fprops_.resize(_n); }
670 void fprops_clear() {
673 void fprops_swap(
unsigned int _i0,
unsigned int _i1)
const {
674 fprops_.swap(_i0, _i1);
677 void mprops_resize(
size_t _n)
const { mprops_.resize(_n); }
678 void mprops_clear() {
684 void property_stats(std::ostream& _ostr = std::clog)
const;
686 void vprop_stats( std::string& _string )
const;
687 void hprop_stats( std::string& _string )
const;
688 void eprop_stats( std::string& _string )
const;
689 void fprop_stats( std::string& _string )
const;
690 void mprop_stats( std::string& _string )
const;
692 void vprop_stats(std::ostream& _ostr = std::clog)
const;
693 void hprop_stats(std::ostream& _ostr = std::clog)
const;
694 void eprop_stats(std::ostream& _ostr = std::clog)
const;
695 void fprop_stats(std::ostream& _ostr = std::clog)
const;
696 void mprop_stats(std::ostream& _ostr = std::clog)
const;
700 typedef PropertyContainer::iterator prop_iterator;
701 typedef PropertyContainer::const_iterator const_prop_iterator;
703 prop_iterator vprops_begin() {
return vprops_.begin(); }
704 prop_iterator vprops_end() {
return vprops_.end(); }
705 const_prop_iterator vprops_begin()
const {
return vprops_.begin(); }
706 const_prop_iterator vprops_end()
const {
return vprops_.end(); }
708 prop_iterator eprops_begin() {
return eprops_.begin(); }
709 prop_iterator eprops_end() {
return eprops_.end(); }
710 const_prop_iterator eprops_begin()
const {
return eprops_.begin(); }
711 const_prop_iterator eprops_end()
const {
return eprops_.end(); }
713 prop_iterator hprops_begin() {
return hprops_.begin(); }
714 prop_iterator hprops_end() {
return hprops_.end(); }
715 const_prop_iterator hprops_begin()
const {
return hprops_.begin(); }
716 const_prop_iterator hprops_end()
const {
return hprops_.end(); }
718 prop_iterator fprops_begin() {
return fprops_.begin(); }
719 prop_iterator fprops_end() {
return fprops_.end(); }
720 const_prop_iterator fprops_begin()
const {
return fprops_.begin(); }
721 const_prop_iterator fprops_end()
const {
return fprops_.end(); }
723 prop_iterator mprops_begin() {
return mprops_.begin(); }
724 prop_iterator mprops_end() {
return mprops_.end(); }
725 const_prop_iterator mprops_begin()
const {
return mprops_.begin(); }
726 const_prop_iterator mprops_end()
const {
return mprops_.end(); }
730 PropertyContainer vprops_;
731 PropertyContainer hprops_;
732 PropertyContainer eprops_;
733 PropertyContainer fprops_;
734 PropertyContainer mprops_;
741 #endif // OPENMESH_BASE_KERNEL_HH defined
void copy_all_properties(VertexHandle _vh_from, VertexHandle _vh_to, bool _copyBuildIn=false)
Copies all properties from one mesh element to another (of the same type)
Definition: BaseKernel.hh:468
void copy_all_properties(EdgeHandle _eh_from, EdgeHandle _eh_to, bool _copyBuildIn=false)
Copies all properties from one mesh element to another (of the same type)
Definition: BaseKernel.hh:506
PropertyT< T > & property(FPropHandleT< T > _ph)
Access a property.
Definition: BaseKernel.hh:313
void remove_property(HPropHandleT< T > &_ph)
Remove a property.
Definition: BaseKernel.hh:188
FPropHandleT< T >::reference property(FPropHandleT< T > _ph, FaceHandle _fh)
Return value of property for an item.
Definition: BaseKernel.hh:381
const PropertyT< T > & property(EPropHandleT< T > _ph) const
Access a property.
Definition: BaseKernel.hh:308
int idx() const
Get the underlying index of this handle.
Definition: Handles.hh:67
const PropertyT< T > & property(HPropHandleT< T > _ph) const
Access a property.
Definition: BaseKernel.hh:299
bool get_property_handle(VPropHandleT< T > &_ph, const std::string &_name) const
Retrieves the handle to a named property by it's name.
Definition: BaseKernel.hh:235
bool get_property_handle(FPropHandleT< T > &_ph, const std::string &_name) const
Retrieves the handle to a named property by it's name.
Definition: BaseKernel.hh:256
bool is_valid() const
The handle is valid iff the index is not equal to -1.
Definition: Handles.hh:70
VPropHandleT< T >::const_reference property(VPropHandleT< T > _ph, VertexHandle _vh) const
Return value of property for an item.
Definition: BaseKernel.hh:348
void add_property(EPropHandleT< T > &_ph, const std::string &_name="<eprop>")
Adds a property.
Definition: BaseKernel.hh:144
void add_property(VPropHandleT< T > &_ph, const std::string &_name="<vprop>")
Adds a property.
Definition: BaseKernel.hh:130
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:56
Handle for a halfedge entity.
Definition: Handles.hh:121
void remove_property(EPropHandleT< T > &_ph)
Remove a property.
Definition: BaseKernel.hh:196
void reset()
reset handle to be invalid
Definition: Handles.hh:73
const PropertyT< T > & property(FPropHandleT< T > _ph) const
Access a property.
Definition: BaseKernel.hh:317
HPropHandleT< T >::reference property(HPropHandleT< T > _ph, HalfedgeHandle _hh)
Return value of property for an item.
Definition: BaseKernel.hh:355
void remove_property(VPropHandleT< T > &_ph)
Remove a property.
Definition: BaseKernel.hh:180
MPropHandleT< T >::const_reference property(MPropHandleT< T > _ph) const
Return value of property for an item.
Definition: BaseKernel.hh:400
void copy_property(HPropHandleT< T > _ph, HalfedgeHandle _hh_from, HalfedgeHandle _hh_to)
Copies a single property from one mesh element to another (of the same type)
Definition: BaseKernel.hh:428
MPropHandleT< T >::reference property(MPropHandleT< T > _ph)
Return value of property for an item.
Definition: BaseKernel.hh:394
Handle for a edge entity.
Definition: Handles.hh:128
const PropertyT< T > & mproperty(MPropHandleT< T > _ph) const
Access a property.
Definition: BaseKernel.hh:326
Handle representing a mesh property.
Definition: Property.hh:532
void copy_all_properties(HalfedgeHandle _hh_from, HalfedgeHandle _hh_to, bool _copyBuildIn=false)
Copies all properties from one mesh element to another (of the same type)
Definition: BaseKernel.hh:487
void add_property(FPropHandleT< T > &_ph, const std::string &_name="<fprop>")
Adds a property.
Definition: BaseKernel.hh:151
Default property class for any type T.
Definition: Property.hh:87
Handle representing an edge property.
Definition: Property.hh:504
bool get_property_handle(HPropHandleT< T > &_ph, const std::string &_name) const
Retrieves the handle to a named property by it's name.
Definition: BaseKernel.hh:242
EPropHandleT< T >::const_reference property(EPropHandleT< T > _ph, EdgeHandle _eh) const
Return value of property for an item.
Definition: BaseKernel.hh:374
PropertyT< T > & mproperty(MPropHandleT< T > _ph)
Access a property.
Definition: BaseKernel.hh:322
void add_property(MPropHandleT< T > &_ph, const std::string &_name="<mprop>")
Adds a property.
Definition: BaseKernel.hh:158
Handle representing a face property.
Definition: Property.hh:518
bool get_property_handle(EPropHandleT< T > &_ph, const std::string &_name) const
Retrieves the handle to a named property by it's name.
Definition: BaseKernel.hh:249
void remove_property(FPropHandleT< T > &_ph)
Remove a property.
Definition: BaseKernel.hh:204
void copy_all_properties(FaceHandle _fh_from, FaceHandle _fh_to, bool _copyBuildIn=false)
Copies all properties from one mesh element to another (of the same type)
Definition: BaseKernel.hh:525
PropertyT< T > & property(HPropHandleT< T > _ph)
Access a property.
Definition: BaseKernel.hh:295
Handle for a face entity.
Definition: Handles.hh:135
bool get_property_handle(MPropHandleT< T > &_ph, const std::string &_name) const
Retrieves the handle to a named property by it's name.
Definition: BaseKernel.hh:263
FPropHandleT< T >::const_reference property(FPropHandleT< T > _ph, FaceHandle _fh) const
Return value of property for an item.
Definition: BaseKernel.hh:387
Handle representing a halfedge property.
Definition: Property.hh:490
PropertyT< T > & property(EPropHandleT< T > _ph)
Access a property.
Definition: BaseKernel.hh:304
Handle representing a vertex property.
Definition: Property.hh:476
void add_property(HPropHandleT< T > &_ph, const std::string &_name="<hprop>")
Adds a property.
Definition: BaseKernel.hh:137
This class provides the basic property management like adding/removing properties and access to prope...
Definition: BaseKernel.hh:91
const PropertyT< T > & property(VPropHandleT< T > _ph) const
Access a property.
Definition: BaseKernel.hh:290
void copy_property(EPropHandleT< T > _ph, EdgeHandle _eh_from, EdgeHandle _eh_to)
Copies a single property from one mesh element to another (of the same type)
Definition: BaseKernel.hh:440
void copy_property(VPropHandleT< T > &_ph, VertexHandle _vh_from, VertexHandle _vh_to)
Copies a single property from one mesh element to another (of the same type)
Definition: BaseKernel.hh:416
void remove_property(MPropHandleT< T > &_ph)
Remove a property.
Definition: BaseKernel.hh:212
Handle for a vertex entity.
Definition: Handles.hh:114
void copy_property(FPropHandleT< T > _ph, FaceHandle _fh_from, FaceHandle _fh_to)
Copies a single property from one mesh element to another (of the same type)
Definition: BaseKernel.hh:452
HPropHandleT< T >::const_reference property(HPropHandleT< T > _ph, HalfedgeHandle _hh) const
Return value of property for an item.
Definition: BaseKernel.hh:361
PropertyT< T > & property(VPropHandleT< T > _ph)
Access a property.
Definition: BaseKernel.hh:286
VPropHandleT< T >::reference property(VPropHandleT< T > _ph, VertexHandle _vh)
Return value of property for an item.
Definition: BaseKernel.hh:342
EPropHandleT< T >::reference property(EPropHandleT< T > _ph, EdgeHandle _eh)
Return value of property for an item.
Definition: BaseKernel.hh:368