shape_doc 0.1
/Users/mourrain/Devel/mmx/shape/include/shape/ssi_lsegment.hpp
Go to the documentation of this file.
00001 #ifndef SYNAPS_SHAPE_GAIA_LSEGMENT_H
00002 #define SYNAPS_SHAPE_GAIA_LSEGMENT_H
00003 
00004 #include <shape/ssi_sample.hpp>
00005 
00006 #define ParametricSurface shape::surface_parametric<double>
00007 
00008 namespace mmx {
00009 
00010 namespace shape_ssi
00011 {
00012   struct mark_t
00013   {
00014     rid_t     head;
00015     coord_t   j;
00016     vcode_t code;
00017     mark_t  * next;
00018     inline coord_t a() { return j;             };
00019     inline coord_t b() { return (this+1)->a(); };
00020   };
00021   
00022   struct lsegment : sample
00023   {
00024     typedef coord_t bounds_t[2];
00025     
00026     struct region_t
00027     {
00028       coord_t _umin, _umax;
00029       vcode_t _code; 
00030       void  * data;
00031       bool operator<( const region_t& b ) const { return _umin < b._umin;         };
00032       coord_t min   ( coord_t u         ) const { return ((bounds_t*)data)[u][0]; };
00033       coord_t max   ( coord_t u         ) const { return ((bounds_t*)data)[u][1]; };
00034       coord_t umin  ()                    const { return _umin; };
00035       coord_t umax  ()                    const { return _umax; };
00036       inline bool inside( coord_t u, coord_t v )
00037       {
00038         if  ( u >= umin() && u < umax() )
00039           if ( v >= min(u) && v < max(u) ) return true;
00040         return false;
00041       };
00042       vcode_t code() const { return _code; };
00043       friend class lsegment_t;
00044     };
00045     
00046     mark_t   *  marks;  
00047     unsigned    _size;  
00048     unsigned *  lines;
00049     
00050     
00051     unsigned nmarks  () const { return _size; };
00052     void lines_changes();
00053   public:
00054     
00055     void rfree( region_t& r )
00056     {
00057       free((void*)(((bounds_t*)(r.data)) + r._umin));
00058     };
00059     
00060     
00061     
00062     mark_t * begin( unsigned i ) { return &(marks[lines[i]]); };
00063     mark_t * end  ( unsigned i ) { return &(marks[lines[i+1]-1]);};
00064     
00065     std::vector< region_t > regions;
00066     graph_t * grp;
00067     void pushm( vcode_t code, coord_t j );
00068     void pushr( coord_t i, mark_t * p );
00069     void addneighbors( mark_t * m0, mark_t * m1 );
00070     void promote( region_t& r );
00071     void convert_regions();
00072     void find_regions();
00073   public:
00074     double _lt;
00075 
00076     lsegment( const ParametricSurface * s , unsigned _w, unsigned _h );
00077     unsigned size() const { return regions.size(); };
00078     region_t& operator[]( unsigned i ) { return regions[i]; };
00079 
00080     ~lsegment();
00081   };
00082 };
00083 } //namespace mmx
00084 
00085 # undef ParametricSurface
00086 # endif