a48  2.0.2
include/vertext.hh
Go to the documentation of this file.
00001 
00008 #ifndef A48_VERTEXT_HH
00009 #define A48_VERTEXT_HH
00010 
00011 //== NAMESPACES ===============================================================
00012 
00013 namespace a48 {
00014 
00015 //== CLASS DEFINITION =========================================================
00016 
00022 template< class Traits >
00023 class VertexT {
00024 
00025 public:
00026 
00027     typedef typename Traits::halfedge_type halfedge_type; 
00028     typedef typename Traits::face_type face_type; 
00029 
00031     VertexT() : h(0) { }
00032 
00036     VertexT( halfedge_type *_h ) : h(_h) { }
00037 
00041     bool is_boundary( void ) const {
00042         const halfedge_type *hcurr = h;
00043         if( !hcurr ) return true;
00044         do {
00045             if( hcurr->next()->is_boundary() ) return true;
00046             hcurr = hcurr->next()->opposite();
00047         } while (hcurr != h);
00048         return false;
00049     }
00050 
00054     bool on_manifold( void ) const { return (bool)h; }
00055 
00056     // @name Get functions
00058 
00062     const halfedge_type* halfedge( void ) const { return h; }
00066     halfedge_type* halfedge( void ) { return h; }
00067 
00072     const halfedge_type* star_next( const halfedge_type *_h ) const {
00073         if( !_h ) return 0;
00074         if( _h->next()->is_boundary() ) return 0;
00075         const halfedge_type *hnext = _h->next()->opposite();
00076         return (hnext == h) ? 0 : hnext;
00077     }
00082     halfedge_type* star_next( halfedge_type *_h ) {
00083         if( !_h ) return 0;
00084         if( _h->next()->is_boundary() ) return 0;
00085         halfedge_type *hnext = _h->next()->opposite();
00086         return (hnext == h) ? 0 : hnext;
00087     }
00088 
00092     unsigned int degree( void ) const {
00093         unsigned int d = 0;
00094         const halfedge_type *hcurr = h;
00095         if( !hcurr ) return d;
00096         do {
00097             ++d;
00098             if( hcurr->next()->is_boundary() ) return d+1;
00099             hcurr = hcurr->next()->opposite();
00100         } while (hcurr != h);
00101         return d;
00102     }
00103 
00107     unsigned int incident_faces( void ) const {
00108         unsigned int n = 0;
00109         for (const halfedge_type *hcurr = this->halfedge();
00110              hcurr != 0; hcurr = this->star_next(hcurr), ++n) { }
00111         return n;
00112     }
00113 
00117     bool is_flip_ok( void ) const {
00118         unsigned int d = this->degree();
00119         return (d > 3) or (d == 3 and this->is_boundary());
00120     }
00121 
00125     bool is_weld_ok( void ) const {
00126         unsigned int d = this->degree();
00127         return (d == 3) or (d == 4 and !this->is_boundary());
00128     }
00129 
00131 
00135     void set_halfedge( halfedge_type *_h ) { h = _h; }
00136 
00137 private:
00138 
00139     halfedge_type *h; 
00140 
00141 };
00142 
00143 //== CLASS DEFINITION =========================================================
00144 
00150 template< class Traits >
00151 class AdaptiveVertexT : public VertexT< Traits > {
00152 
00153 public:
00154 
00155     typedef typename Traits::halfedge_type halfedge_type; 
00156     typedef typename Traits::face_type face_type; 
00157 
00159     AdaptiveVertexT() : VertexT< Traits >(), l(0) { }
00160 
00165     AdaptiveVertexT( halfedge_type *_h,
00166                      const unsigned int& _l = 0 ) : VertexT< Traits >(_h), l(_l) { }
00167 
00176     bool is_weld( void ) const {
00177         bool w = true;
00178         for (const halfedge_type *hcurr = this->halfedge();
00179              hcurr != 0; hcurr = this->star_next(hcurr))
00180             w &= (hcurr->face()->weld_vertex() == this);
00181         return w;
00182     }
00183 
00187     unsigned int level( void ) const { return l; }
00188 
00192     void set_level( const unsigned int& _l ) { l = _l; }
00193 
00194 private:
00195 
00196     unsigned int l; 
00197 
00198 };
00199 
00200 //=============================================================================
00201 } // namespace a48
00202 //=============================================================================
00203 #endif // A48_VERTEXT_HH
00204 //=============================================================================
 All Classes Namespaces Files Functions Typedefs