a48  2.0.2
include/facet.hh
Go to the documentation of this file.
00001 
00008 #ifndef A48_FACET_HH
00009 #define A48_FACET_HH
00010 
00011 //== NAMESPACES ===============================================================
00012 
00013 namespace a48 {
00014 
00015 //== CLASS DEFINITION =========================================================
00016 
00022 template< class Traits >
00023 class FaceT {
00024 
00025 public:
00026 
00027     typedef typename Traits::halfedge_type halfedge_type; 
00028 
00030     FaceT() : h(0) { }
00031 
00035     FaceT( halfedge_type *_h ) : h(_h) { }
00036 
00040     bool is_boundary( void ) const {
00041         const halfedge_type *hcurr = h;
00042         do {
00043             if( hcurr->is_boundary() ) return true;
00044             hcurr = hcurr->next();
00045         } while (hcurr != h);
00046         return false;
00047     }
00048 
00052     bool is_triangle( void ) const { return this->sides() == 3; }
00053 
00054     // @name Get functions
00056 
00060     const halfedge_type* halfedge( void ) const { return h; }
00064     halfedge_type* halfedge( void ) { return h; }
00065 
00069     unsigned int sides( void ) const {
00070         unsigned int n = 0;
00071         const halfedge_type *hcurr = this->halfedge();
00072         do { ++n; hcurr = hcurr->next(); } while (hcurr != this->halfedge());
00073         return n;
00074     }
00075 
00079     unsigned int non_boundary_sides( void ) const {
00080         unsigned int n = 0;
00081         const halfedge_type *hcurr = this->halfedge();
00082         do { if( !hcurr->is_boundary() ) ++n; hcurr = hcurr->next(); } while (hcurr != this->halfedge());
00083         return n;
00084     }
00085 
00087 
00091     void set_halfedge( halfedge_type *_h ) { h = _h; }
00092 
00093 private:
00094 
00095     halfedge_type *h; 
00096 
00097 };
00098 
00099 //== CLASS DEFINITION =========================================================
00100 
00106 template< class Traits >
00107 class AdaptiveFaceT : public FaceT< Traits > {
00108 
00109 public:
00110 
00111     typedef typename Traits::vertex_type vertex_type; 
00112     typedef typename Traits::halfedge_type halfedge_type; 
00113 
00115     AdaptiveFaceT() : FaceT< Traits >() { }
00116 
00120     AdaptiveFaceT( halfedge_type *_h ) : FaceT< Traits >(_h) { }
00121 
00122     // @name Get functions
00124 
00128     const halfedge_type* split_halfedge( void ) const { return this->halfedge(); }
00129 
00138     halfedge_type* split_halfedge( void ) { return this->halfedge(); }
00139 
00143     const vertex_type* weld_vertex( void ) const { return this->halfedge()->next()->vertex(); }
00144 
00153     vertex_type* weld_vertex( void ) { return this->halfedge()->next()->vertex(); }
00154 
00158     unsigned int level( void ) const {
00159         return std::max( std::max( this->halfedge()->vertex()->level(),
00160                        this->halfedge()->next()->vertex()->level() ),
00161                  this->halfedge()->previous()->vertex()->level() );
00162     }
00163 
00165 
00166 };
00167 
00168 //=============================================================================
00169 } // namespace a48
00170 //=============================================================================
00171 #endif // A48_FACET_HH
00172 //=============================================================================
 All Classes Namespaces Files Functions Typedefs