qsegment< C, V > Struct Template Reference

#include <ssi_qsegment.hpp>

Inheritance diagram for qsegment< C, V >:
lsegment< C, V > sample< C, V > dsearch< C, V >

List of all members.

Public Types

Public Member Functions

Public Attributes


Detailed Description

template<class C, class V>
struct mmx::ssi::qsegment< C, V >

Definition at line 112 of file ssi_qsegment.hpp.


Member Typedef Documentation

typedef coord_t bounds_t[2] [inherited]

Definition at line 26 of file ssi_lsegment.hpp.

typedef lrnode<C,V>* lrtree

Definition at line 116 of file ssi_qsegment.hpp.

Reimplemented from lsegment< C, V >.

Reimplemented in dsearch< C, V >.

Definition at line 114 of file ssi_qsegment.hpp.

typedef qnode<C,V>* qtree

Reimplemented in dsearch< C, V >.

Definition at line 115 of file ssi_qsegment.hpp.


Constructor & Destructor Documentation

qsegment ( const ParametricSurface s,
unsigned  w,
unsigned  h 
) [inline]

Definition at line 210 of file ssi_qsegment.hpp.

References qnode< C, V >::father, lrnode< C, V >::lmax, lrnode< C, V >::lmin, lrnode< C, V >::ls, qsegment< C, V >::make(), lsegment< C, V >::regions, lrnode< C, V >::rmax, lrnode< C, V >::rmin, lrnode< C, V >::rs, qsegment< C, V >::trees, mmx::ssi::umax(), lrnode< C, V >::umax, lrnode< C, V >::umin, and mmx::ssi::umin().

00210                                                                               : lsegment<C,V>( s, w, h )
00211 {
00212     //    _qt = time();
00213     lrnode<C,V> * lr_chunk   = lrnode<C,V>::alloc(h);
00214     std::cout<<"QSegment "<<this->regions.size()<<std::endl;
00215     for ( unsigned i = 0; i < this->regions.size(); i++ )
00216     {
00217         lr_chunk -= this->regions[i].umin();
00218         for ( coord_t u = this->regions[i].umin(); u < this->regions[i].umax(); u++  )
00219         {
00220             lr_chunk[u].umin = u;
00221             lr_chunk[u].umax = u+1;
00222             lr_chunk[u].lmax = (lr_chunk[u].lmin = this->regions[i].min(u));
00223             lr_chunk[u].rmax = (lr_chunk[u].rmin = this->regions[i].max(u));
00224             lr_chunk[u].ls   = lr_chunk[u].rs = 0;
00225         };
00226 
00227         lr_chunk += this->regions[i].umin();
00228 
00229         lrnode<C,V> * lrt = lrnode<C,V>::make(lr_chunk,
00230                                     this->regions[i].umax()-this->regions[i].umin());
00231         //std::cout<<"Qsegment make "<<i<<std::endl;
00232         qtree tmp = make( i, lrt->lmin, lrt->rmax, lrt );
00233         tmp->father = 0;
00234         trees.push_back( tmp  );
00235     };
00236     //std::cout<<"QSegment"<<std::endl;
00237     delete[] lr_chunk;
00238     //    std::cout << "q = " << (time()-_qt) << std::endl;
00239 };

~qsegment (  )  [inline]

Definition at line 242 of file ssi_qsegment.hpp.

References qsegment< C, V >::size(), and qsegment< C, V >::trees.

00243 {
00244     for ( unsigned i = 0; i < size(); delete trees[i], i++ );
00245 };


Member Function Documentation

void addneighbors ( mark_t m0,
mark_t m1 
) [inline, inherited]

Definition at line 96 of file ssi_lsegment.hpp.

References igraph::add_link(), mark_t::code, coherent_code(), lsegment< C, V >::grp, and mark_t::head.

Referenced by lsegment< C, V >::find_regions().

00097   {
00098     if ( coherent_code( m0->code, m1->code )  )
00099       {
00100         grp->add_link(m0->head,m1->head);
00101         grp->add_link(m1->head,m0->head);
00102       };
00103   };

vector3* base (  )  const [inline, inherited]

Definition at line 25 of file ssi_sample.hpp.

References sample< C, V >::m_svals.

Referenced by qnode< C, V >::fill(), and lsegment< C, V >::lines_changes().

00025 { return m_svals; };

mark_t* begin ( unsigned  i  )  [inline, inherited]

Definition at line 64 of file ssi_lsegment.hpp.

References lsegment< C, V >::lines, and lsegment< C, V >::marks.

Referenced by lsegment< C, V >::find_regions().

00064 { return &(marks[lines[i]]); };

void convert_regions (  )  [inline, inherited]

Definition at line 206 of file ssi_lsegment.hpp.

References lsegment< C, V >::promote(), and lsegment< C, V >::regions.

Referenced by lsegment< C, V >::lsegment().

00207     {
00208       for ( unsigned i = 0; i < regions.size(); i++ )
00209         promote( regions[i] );
00210     };

mark_t* end ( unsigned  i  )  [inline, inherited]

Definition at line 65 of file ssi_lsegment.hpp.

Referenced by lsegment< C, V >::find_regions().

00065 { return &(marks[lines[i+1]-1]);};

void find_regions (  )  [inline, inherited]

Definition at line 145 of file ssi_lsegment.hpp.

References mark_t::a(), lsegment< C, V >::addneighbors(), mark_t::b(), lsegment< C, V >::begin(), mark_t::code, mmx::ssi::down(), lsegment< C, V >::end(), mark_t::head, INTERVALTEST, sample< C, V >::ncols(), mark_t::next, sample< C, V >::nrows(), lsegment< C, V >::pushr(), lsegment< C, V >::regions, and mmx::ssi::up().

Referenced by lsegment< C, V >::lsegment().

00146   {
00147     mark_t * p;
00148     for ( p = begin(0); p != end(0); p++ )
00149       pushr(0,p);
00150     for ( p = begin(0)+1; p != end(0); p++ )
00151       addneighbors(p,p-1);
00152 
00153     int ncolsTemp = this->ncols();
00154     mark_t * neighbors[ncolsTemp];
00155     unsigned n_neigh;
00156     coord_t i;
00157 #define INTERVALTEST ( std::abs(std::min(down->b(),up->b())-std::max(down->a(),up->a())) > 1 )
00158     for ( i = 0; i < this->nrows()-2; i++ )
00159       {
00160         mark_t * startup = begin(i);
00161         for ( mark_t * down = begin(i+1); down != end(i+1); down++ )
00162           {
00163             while ( startup->b() <= down->a() ) startup++;
00164             mark_t * up = startup;
00165             n_neigh = 0;
00166             while( down->b() > up->a() )
00167               if ( (up->next == 0) && ( up->code == down->code ) && INTERVALTEST)
00168                 {
00169                   regions[up->head]._umax++;
00170                   up->next = down;
00171                   down->head = up->head, up++;
00172                   break;
00173                 }
00174               else
00175                 neighbors[n_neigh++] = up, up++;
00176 
00177               if ( down->head == -1 ) pushr( i+1, down );
00178 
00179               for ( unsigned k = 0; k < n_neigh; k ++ ) addneighbors(down,neighbors[k]);
00180               while( down->b() > up->a() ) addneighbors(down,up), up++;
00181           };
00182       };
00183   };

void lines_changes (  )  [inline, inherited]

Definition at line 119 of file ssi_lsegment.hpp.

References sample< C, V >::base(), lsegment< C, V >::lines, lsegment< C, V >::marks, sample< C, V >::ncols(), lsegment< C, V >::nmarks(), sample< C, V >::nrows(), lsegment< C, V >::pushm(), realloc(), and vcode().

Referenced by lsegment< C, V >::lsegment().

00120   {
00121     int i,j;
00122     lines = (unsigned*)(malloc(sizeof(unsigned)*this->nrows()));
00123     unsigned max_marks = this->nrows()*this->ncols();
00124     while ( !(marks = (mark_t*)(malloc(sizeof(mark_t)*max_marks))) ) max_marks >>= 1;
00125     vector3 * ptr  = this->base();
00126     for ( i = 0; i < this->nrows()-1; i++ )
00127       {
00128         lines[i] = this->nmarks();
00129         vcode_t code = vcode(*ptr,*(ptr+this->ncols()),*(ptr+1));
00130         pushm(code,0);
00131         for (  j = 0; j < this->ncols()-1; j++, ptr++ )
00132           {
00133             vcode_t tmp = vcode(*ptr,*(ptr+this->ncols()),*(ptr+1));
00134             if ( tmp != code )
00135               { code = tmp; this->pushm(code,j); };
00136           };
00137         pushm(code,this->ncols()-1);
00138         ptr++;
00139       };
00140     lines[this->nrows()-1] = nmarks();
00141     marks = (mark_t*)realloc(marks,sizeof(mark_t)*nmarks());
00142   };

qnode< C, V > * make ( rid_t  id,
coord_t  vmin,
coord_t  vmax,
lrnode< C, V > *  lr 
) [inline]

Definition at line 155 of file ssi_qsegment.hpp.

References qnode< C, V >::box, qnode< C, V >::father, mmx::hull(), qnode< C, V >::l, lrnode< C, V >::ls, qnode< C, V >::mbox(), qnode< C, V >::r, lrnode< C, V >::rmax, lrnode< C, V >::rmin, lrnode< C, V >::rs, qnode< C, V >::umax, lrnode< C, V >::umax, qnode< C, V >::umin, lrnode< C, V >::umin, qnode< C, V >::vmax, and qnode< C, V >::vmin.

Referenced by qsegment< C, V >::qsegment().

00156 {
00157     qnode<C,V> * curr, * l, * r;
00158     curr = l = r = 0;
00159 
00160     if (  vmax  <=  lr->lmin || vmin >=  lr->rmax ) return 0;
00161     if (  vmin  <   lr->lmax || vmax >  lr->rmin  )
00162     {
00163         if ( lr->umax-lr->umin > vmax-vmin)
00164         {
00165             l = make( id, vmin, vmax, lr->ls );
00166             r = make( id, vmin, vmax, lr->rs );
00167         }
00168         else
00169         {
00170             unsigned m = (vmin + vmax)/2;
00171             l = make( id, vmin, m, lr );
00172             r = make( id, m, vmax, lr );
00173         };
00174 
00175         if ( l && r )
00176         {
00177             curr = new qnode<C,V>();
00178             curr->umin = lr->umin;
00179             curr->umax = lr->umax;
00180             curr->vmin = vmin;
00181             curr->vmax = vmax;
00182             hull(curr->box,l->box,r->box);
00183             curr->l = l;
00184             curr->r = r;
00185             l->father = curr;
00186             r->father = curr;
00187             return curr;
00188         };
00189 
00190         if ( l ) { return l; };
00191         if ( r ) { return r; };
00192     }
00193     else
00194     {
00195         curr = new qnode<C,V>();
00196         curr->l    = 0;
00197         curr->r    = 0;
00198         curr->umin = lr->umin;
00199         curr->umax = lr->umax;
00200         curr->vmin = vmin;
00201         curr->vmax = vmax;
00202         curr->mbox(this);
00203 
00204         return curr;
00205     };
00206     return curr;
00207 };

void make_box ( rid_t  id,
qnode< C, V > *  q 
)
int ncols (  )  const [inline, inherited]

Definition at line 27 of file ssi_sample.hpp.

References sample< C, V >::m_ncols.

Referenced by lsegment< C, V >::find_regions(), and lsegment< C, V >::lines_changes().

00027 { return m_ncols; };

unsigned nmarks (  )  const [inline, inherited]

Definition at line 53 of file ssi_lsegment.hpp.

References lsegment< C, V >::_size.

Referenced by lsegment< C, V >::lines_changes().

00053 { return _size; };

int nrows (  )  const [inline, inherited]

Definition at line 26 of file ssi_sample.hpp.

References sample< C, V >::m_nrows.

Referenced by lsegment< C, V >::find_regions(), and lsegment< C, V >::lines_changes().

00026 { return m_nrows; };

qtree operator[] ( unsigned  i  )  [inline]

Reimplemented from lsegment< C, V >.

Definition at line 123 of file ssi_qsegment.hpp.

References qsegment< C, V >::trees.

00123 { return trees[i]; };

void promote ( region_t r  )  [inline, inherited]

Definition at line 186 of file ssi_lsegment.hpp.

References region_t::_umax, region_t::_umin, mark_t::a(), mark_t::b(), region_t::data, and mark_t::next.

Referenced by lsegment< C, V >::convert_regions().

00187   {
00188     mark_t     * mpointer;
00189     bounds_t * bpointer;
00190     mpointer = (mark_t*)(r.data);
00191     r.data   = (void*)(malloc(sizeof(bounds_t)*(r._umax)));
00192     bpointer = (bounds_t*)(r.data);
00193 
00194     for ( unsigned i = 0; i < r._umax; i++ )
00195       {
00196         bpointer[i][0] = mpointer->a();
00197         bpointer[i][1] = mpointer->b();
00198         mpointer = mpointer->next;
00199       };
00200 
00201     r._umax += r._umin;
00202     r.data  = (void*)(((bounds_t*)(r.data))-r._umin);
00203   };

void pushm ( vcode_t  code,
coord_t  j 
) [inline, inherited]

Definition at line 86 of file ssi_lsegment.hpp.

References lsegment< C, V >::_size, mark_t::code, mark_t::head, mark_t::j, lsegment< C, V >::marks, and mark_t::next.

Referenced by lsegment< C, V >::lines_changes().

00087   {
00088     marks[_size].code = code;
00089     marks[_size].j    = j;
00090     marks[_size].head =-1;
00091     marks[_size].next = 0;
00092     _size++;
00093   }

void pushr ( coord_t  i,
mark_t p 
) [inline, inherited]

Definition at line 106 of file ssi_lsegment.hpp.

References region_t::_code, region_t::_umax, region_t::_umin, igraph::add_node(), mark_t::code, region_t::data, lsegment< C, V >::grp, mark_t::head, and lsegment< C, V >::regions.

Referenced by lsegment< C, V >::find_regions().

00107   {
00108     p->head =  regions.size();
00109     regions.push_back( region_t() );
00110     region_t * r =&(regions.back());
00111     r->_umin = i;
00112     r->_umax = 1;
00113     r->data = (void*)p;
00114     r->_code = p->code;
00115     grp->add_node();
00116   };

void rfree ( region_t r  )  [inline, inherited]

Definition at line 57 of file ssi_lsegment.hpp.

References region_t::_umin, and region_t::data.

Referenced by lsegment< C, V >::~lsegment().

00058     {
00059       free((void*)(((bounds_t*)(r.data)) + r._umin));
00060     };

void scale_conflict ( vector3  a[4],
vector3  b[4],
qtree  qa,
qtree  qb 
)

Referenced by dsearch< C, V >::push().

unsigned size ( void   )  const [inline]

Reimplemented from lsegment< C, V >.

Definition at line 122 of file ssi_qsegment.hpp.

References qsegment< C, V >::trees.

Referenced by qsegment< C, V >::~qsegment().

00122 { return trees.size(); };

const double& uvalue ( int  i  )  const [inline, inherited]

Definition at line 28 of file ssi_sample.hpp.

References sample< C, V >::m_uvals.

Referenced by qnode< C, V >::convert().

00028 { return m_uvals[i]; };

const double& vvalue ( int  i  )  const [inline, inherited]

Definition at line 29 of file ssi_sample.hpp.

References sample< C, V >::m_vvals.

Referenced by qnode< C, V >::convert().

00029 { return m_vvals[i]; };


Member Data Documentation

double _lt [inherited]

Definition at line 76 of file ssi_lsegment.hpp.

double _qt

Definition at line 123 of file ssi_qsegment.hpp.

unsigned _size [inherited]
graph_t* grp [inherited]
unsigned* lines [inherited]
coord_t m_ncols [inherited]
coord_t m_nrows [inherited]

Definition at line 20 of file ssi_sample.hpp.

Referenced by sample< C, V >::nrows(), and sample< C, V >::sample().

const ParametricSurface* m_psurf [inherited]

Definition at line 17 of file ssi_sample.hpp.

Referenced by sample< C, V >::sample().

vector3* m_svals [inherited]

Definition at line 22 of file ssi_sample.hpp.

Referenced by sample< C, V >::base(), and sample< C, V >::sample().

double* m_uvals [inherited]
double* m_vvals [inherited]

Definition at line 19 of file ssi_sample.hpp.

Referenced by sample< C, V >::sample(), and sample< C, V >::vvalue().

mark_t* marks [inherited]
std::vector< region_t > regions [inherited]
std::vector<qtree> trees

The documentation for this struct was generated from the following file:

Generated on 6 Dec 2012 for shape by  doxygen 1.6.1