shape_doc 0.1
|
00001 #ifndef SYNAPS_SHAPE_GAIA_QNODE_H 00002 #define SYNAPS_SHAPE_GAIA_QNODE_H 00003 00004 #include <shape/ssi_def.hpp> 00005 #include <shape/ssi_sample.hpp> 00006 00007 namespace mmx { 00008 00009 namespace shape_ssi 00010 { 00011 struct qnode 00012 { 00013 aabb3 box; 00014 coord_t umin,umax,vmin,vmax; 00015 qnode * l, *r; 00016 qnode * father; 00017 bool leaf() const { return (l == 0); }; 00018 qnode(): l(0), r(0) {}; 00019 void split_u(); 00020 void split_v(); 00021 void fill( vector3 ** qp, sample * s ) const; 00022 void fill( vector3 * qp, sample * s ) const; 00023 void convert( vector2 *v, sample * s, int n ) const ; 00024 void mbox( sample * s ); 00025 void split( sample * s ); 00026 ~qnode(); 00027 }; 00028 std::ostream& operator<<( std::ostream& o, const qnode& ); 00029 inline coord_t du ( const qnode * q ) { return q->umax-q->umin; }; 00030 inline coord_t dv ( const qnode * q ) { return q->vmax - q->vmin; }; 00031 inline coord_t umin( const qnode * q ) { return q->umin; }; 00032 inline coord_t umax( const qnode * q ) { return q->umax; }; 00033 inline coord_t vmin( const qnode * q ) { return q->vmin; }; 00034 inline coord_t vmax( const qnode * q ) { return q->vmax; }; 00035 inline bool leaf( qnode const * const q ) { return (q->l == 0); }; 00036 inline bool unit( const qnode * q ) { return du(q)==1 && dv(q) == 1; }; 00037 inline bool inside( coord_t u, coord_t v, qnode * q ) 00038 { 00039 if ( q->umin > u ) return false; 00040 if ( q->umax <= u ) return false; 00041 if ( q->vmin > v ) return false; 00042 if ( q->vmax <= v ) return false; 00043 return true; 00044 }; 00045 qnode * search( coord_t u, coord_t v, qnode * start ); 00046 inline qnode * up ( qnode * q ) { return search( q->umin + 1, q->vmin, q ); }; 00047 inline qnode * down( qnode * q ) { return search( q->umin - 1, q->vmin, q ); }; 00048 inline qnode * left( qnode * q ) { return search( q->umin, q->vmin - 1, q ); }; 00049 inline qnode * right( qnode * q ) { return search( q->umin, q->vmin + 1, q ); }; 00050 }; 00051 00052 } //namespace mmx 00053 #endif