shape_doc 0.1
qsegment Struct Reference

#include <ssi_qsegment.hpp>

Inheritance diagram for qsegment:
lsegment sample dsearch

List of all members.

Public Types

Public Member Functions

Public Attributes


Detailed Description

Definition at line 23 of file ssi_qsegment.hpp.


Member Typedef Documentation

typedef coord_t bounds_t[2] [inherited]

Definition at line 24 of file ssi_lsegment.hpp.


Constructor & Destructor Documentation

qsegment ( const shape::surface_parametric< double > *  s,
unsigned  w,
unsigned  h 
)

Definition at line 178 of file ssi_qsegment.cpp.

References mmx::alloc(), qnode::father, lrnode::lmax, lrnode::lmin, lrnode::ls, qsegment::make(), lsegment::regions, lrnode::rmax, lrnode::rmin, lrnode::rs, qsegment::trees, mmx::shape_ssi::umax(), lrnode::umax, lrnode::umin, and mmx::shape_ssi::umin().

                                                                           : lsegment( s, w, h )
  {
    //    _qt = time();
    lrnode * lr_chunk   = lrnode::alloc(h);
    for ( unsigned i = 0; i < this->regions.size(); i++ )
      {
        lr_chunk -= this->regions[i].umin();
        for ( coord_t u = this->regions[i].umin(); u < this->regions[i].umax(); u++  )
          {
            lr_chunk[u].umin =  u;
            lr_chunk[u].umax =  u+1;
            lr_chunk[u].lmax = (lr_chunk[u].lmin = this->regions[i].min(u));
            lr_chunk[u].rmax = (lr_chunk[u].rmin = this->regions[i].max(u));
            lr_chunk[u].ls   =  lr_chunk[u].rs   = 0; 
          };

        lr_chunk += this->regions[i].umin();
        
        lrnode * lrt = lrnode::make(lr_chunk,
                                    this->regions[i].umax()-this->regions[i].umin());
        qtree tmp = make( i, lrt->lmin, lrt->rmax, lrt );
        tmp->father = 0;
        trees.push_back( tmp  );
        
      };
    delete[] lr_chunk;
    //    std::cout << "q = " << (time()-_qt) << std::endl;
  };
~qsegment ( )

Definition at line 207 of file ssi_qsegment.cpp.

References qsegment::size(), and qsegment::trees.

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

Member Function Documentation

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

Definition at line 18 of file ssi_lsegment.cpp.

References igraph::add_link(), mark_t::code, coherent_code(), lsegment::grp, and mark_t::head.

Referenced by lsegment::find_regions().

  {
    if ( coherent_code( m0->code, m1->code )  )
      {
        grp->add_link(m0->head,m1->head);
        grp->add_link(m1->head,m0->head);
      };
  };
vector3* base ( ) const [inline, inherited]

Definition at line 23 of file ssi_sample.hpp.

References sample::m_svals.

Referenced by qnode::fill(), and lsegment::lines_changes().

{ return m_svals; };
mark_t* begin ( unsigned  i) [inline, inherited]

Definition at line 62 of file ssi_lsegment.hpp.

References lsegment::lines, and lsegment::marks.

Referenced by lsegment::find_regions().

{ return &(marks[lines[i]]); };
void convert_regions ( ) [inherited]

Definition at line 123 of file ssi_lsegment.cpp.

References lsegment::promote(), and lsegment::regions.

Referenced by lsegment::lsegment().

    {
      for ( unsigned i = 0; i < regions.size(); i++ )
        promote( regions[i] );
    };
mark_t* end ( unsigned  i) [inline, inherited]

Definition at line 63 of file ssi_lsegment.hpp.

Referenced by lsegment::find_regions().

{ return &(marks[lines[i+1]-1]);};
void find_regions ( ) [inherited]

Definition at line 65 of file ssi_lsegment.cpp.

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

Referenced by lsegment::lsegment().

  {
    mark_t * p;
    for ( p = begin(0); p != end(0); p++ )
      pushr(0,p);
    for ( p = begin(0)+1; p != end(0); p++ )
      addneighbors(p,p-1);
    
    mark_t * neighbors[ncols()];
    unsigned n_neigh;
    coord_t i;
#define INTERVALTEST ( std::abs(std::min(down->b(),up->b())-std::max(down->a(),up->a())) > 1 )
    for ( i = 0; i < nrows()-2; i++ )
      {
        mark_t * startup = begin(i);
        for ( mark_t * down = begin(i+1); down != end(i+1); down++ )
          {
            while ( startup->b() <= down->a() ) startup++;
            mark_t * up = startup;
            n_neigh = 0;
            while( down->b() > up->a() )
              if ( (up->next == 0) && ( up->code == down->code ) && INTERVALTEST)
                { 
                  regions[up->head]._umax++;
                  up->next = down;
                  down->head = up->head, up++; 
                  break; 
                }
              else 
                neighbors[n_neigh++] = up, up++;
            
              if ( down->head == -1 ) pushr( i+1, down );
            
              for ( unsigned k = 0; k < n_neigh; k ++ ) addneighbors(down,neighbors[k]);
              while( down->b() > up->a() ) addneighbors(down,up), up++;
          };
      };
  };
void lines_changes ( ) [inherited]

Definition at line 39 of file ssi_lsegment.cpp.

References sample::base(), lsegment::lines, lsegment::marks, sample::ncols(), lsegment::nmarks(), sample::nrows(), lsegment::pushm(), and vcode().

Referenced by lsegment::lsegment().

  {
    int i,j;
    lines = (unsigned*)(malloc(sizeof(unsigned)*nrows()));
    unsigned max_marks = nrows()*ncols();
    while ( !(marks = (mark_t*)(malloc(sizeof(mark_t)*max_marks))) ) max_marks >>= 1;
    vector3 * ptr  = base();
    for ( i = 0; i < this->nrows()-1; i++ )
      {
        lines[i] = nmarks();
        vcode_t code = vcode(*ptr,*(ptr+ncols()),*(ptr+1));
        pushm(code,0);
        for (  j = 0; j < ncols()-1; j++, ptr++ )
          {
            vcode_t tmp = vcode(*ptr,*(ptr+ncols()),*(ptr+1));
            if ( tmp != code )
              { code = tmp; pushm(code,j); };
          };
        pushm(code,ncols()-1);
        ptr++;
      };
    lines[nrows()-1] = nmarks();
    marks = (mark_t*)realloc(marks,sizeof(mark_t)*nmarks());
  };
qnode * make ( rid_t  id,
coord_t  vmin,
coord_t  vmax,
lrnode lr 
)

Definition at line 124 of file ssi_qsegment.cpp.

References qnode::box, qnode::father, mmx::hull(), qnode::l, mmx::lmax(), mmx::lmin(), lrnode::ls, qnode::mbox(), qnode::r, lrnode::rmax, lrnode::rmin, lrnode::rs, qnode::umax, lrnode::umax, qnode::umin, lrnode::umin, qnode::vmax, mmx::shape_ssi::vmax(), mmx::shape_ssi::vmin(), and qnode::vmin.

Referenced by qsegment::qsegment().

  { 
    qnode * curr, * l, * r;
    curr = l = r = 0;
    
    if (  vmax  <=  lr->lmin || vmin >=  lr->rmax ) return 0; 
    if (  vmin  <   lr->lmax || vmax >  lr->rmin  )
      {
        if ( lr->umax-lr->umin > vmax-vmin)
          {
            l = make( id, vmin, vmax, lr->ls );
            r = make( id, vmin, vmax, lr->rs );
          }
        else 
          {
            unsigned m = (vmin + vmax)/2;
            l = make( id, vmin, m, lr );
            r = make( id, m, vmax, lr );
          };
        
        if ( l && r ) 
          { 
            curr = new qnode();
            curr->umin = lr->umin;
            curr->umax = lr->umax;
            curr->vmin = vmin;
            curr->vmax = vmax;
            hull(curr->box,l->box,r->box);
            curr->l = l;
            curr->r = r;
            l->father = curr;
            r->father = curr;
            return curr;
          };
        
        if ( l ) { return l; };
        if ( r ) { return r; };
      }
    else 
      {
        curr = new qnode();
        curr->l    = 0;
        curr->r    = 0;
        curr->umin = lr->umin;
        curr->umax = lr->umax;
        curr->vmin = vmin;
        curr->vmax = vmax;
        curr->mbox(this);

        return curr;
      };
    return curr;
  };
void make_box ( rid_t  id,
qnode q 
)
int ncols ( ) const [inline, inherited]

Definition at line 25 of file ssi_sample.hpp.

References sample::m_ncols.

Referenced by lsegment::find_regions(), and lsegment::lines_changes().

{ return m_ncols; };
unsigned nmarks ( ) const [inline, inherited]

Definition at line 51 of file ssi_lsegment.hpp.

References lsegment::_size.

Referenced by lsegment::lines_changes().

{ return _size; };
int nrows ( ) const [inline, inherited]

Definition at line 24 of file ssi_sample.hpp.

References sample::m_nrows.

Referenced by lsegment::find_regions(), and lsegment::lines_changes().

{ return m_nrows; };
qtree operator[] ( unsigned  i) [inline]

Reimplemented from lsegment.

Definition at line 30 of file ssi_qsegment.hpp.

References qsegment::trees.

{ return trees[i]; };
void promote ( region_t r) [inherited]

Definition at line 104 of file ssi_lsegment.cpp.

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

Referenced by lsegment::convert_regions().

  {
    mark_t     * mpointer;
    bounds_t * bpointer; 
    mpointer = (mark_t*)(r.data);
    r.data   = (void*)(malloc(sizeof(bounds_t)*(r._umax)));
    bpointer = (bounds_t*)(r.data);
    
    for ( unsigned i = 0; i < r._umax; i++ )
      {
        bpointer[i][0] = mpointer->a();
        bpointer[i][1] = mpointer->b();
        mpointer = mpointer->next;
      };
    
    r._umax += r._umin;
    r.data  = (void*)(((bounds_t*)(r.data))-r._umin);
  };
void pushm ( vcode_t  code,
coord_t  j 
) [inherited]

Definition at line 9 of file ssi_lsegment.cpp.

References lsegment::_size, mark_t::code, mark_t::head, mark_t::j, lsegment::marks, and mark_t::next.

Referenced by lsegment::lines_changes().

  {
    marks[_size].code = code;
    marks[_size].j    = j;
    marks[_size].head =-1;
    marks[_size].next = 0;
    _size++;
  }
void pushr ( coord_t  i,
mark_t p 
) [inherited]

Definition at line 27 of file ssi_lsegment.cpp.

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

Referenced by lsegment::find_regions().

  {
    p->head =  regions.size();
    regions.push_back( region_t() );
    region_t * r =&(regions.back());
    r->_umin = i;
    r->_umax = 1;
    r->data = (void*)p;
    r->_code = p->code;
    grp->add_node();
  };
void rfree ( region_t r) [inline, inherited]

Definition at line 55 of file ssi_lsegment.hpp.

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

Referenced by lsegment::~lsegment().

    {
      free((void*)(((bounds_t*)(r.data)) + r._umin));
    };
void scale_conflict ( vector3  a[4],
vector3  b[4],
qtree  qa,
qtree  qb 
)

Definition at line 104 of file ssi_qsegment.cpp.

References qnode::box, qnode::fill(), mmx::hull(), mmx::lmax(), mmx::shape_ssi::scale(), and mmx::shape_ssi::shiftm().

Referenced by dsearch::push().

  {

    aabb3 h;
    hull(h,qa->box,qb->box);
    double s = 1.0/lmax(h);
    qa->fill(a,this);
    qb->fill(b,this);
    shiftm(a,4,h);
    shiftm(b,4,h);
    scale(a,s);
    scale(b,s);
  };
unsigned size ( void  ) const [inline]

Reimplemented from lsegment.

Definition at line 29 of file ssi_qsegment.hpp.

References qsegment::trees.

Referenced by qsegment::~qsegment().

{ return trees.size(); };
const double& uvalue ( int  i) const [inline, inherited]

Definition at line 26 of file ssi_sample.hpp.

References sample::m_uvals.

Referenced by qnode::convert().

{ return m_uvals[i]; };
const double& vvalue ( int  i) const [inline, inherited]

Definition at line 27 of file ssi_sample.hpp.

References sample::m_vvals.

Referenced by qnode::convert().

{ return m_vvals[i]; };

Member Data Documentation

double _lt [inherited]

Definition at line 74 of file ssi_lsegment.hpp.

double _qt

Definition at line 30 of file ssi_qsegment.hpp.

unsigned _size [inherited]

Definition at line 47 of file ssi_lsegment.hpp.

Referenced by lsegment::lsegment(), lsegment::nmarks(), and lsegment::pushm().

unsigned* lines [inherited]

Definition at line 48 of file ssi_lsegment.hpp.

Referenced by lsegment::begin(), lsegment::lines_changes(), and lsegment::lsegment().

coord_t m_ncols [inherited]

Definition at line 19 of file ssi_sample.hpp.

Referenced by qnode::fill(), sample::ncols(), and sample::sample().

coord_t m_nrows [inherited]

Definition at line 18 of file ssi_sample.hpp.

Referenced by sample::nrows(), and sample::sample().

const shape::surface_parametric<double>* m_psurf [inherited]

Definition at line 15 of file ssi_sample.hpp.

Referenced by sample::sample().

vector3* m_svals [inherited]

Definition at line 20 of file ssi_sample.hpp.

Referenced by sample::base(), and sample::sample().

double* m_uvals [inherited]

Definition at line 16 of file ssi_sample.hpp.

Referenced by sample::sample(), sample::uvalue(), and sample::~sample().

double* m_vvals [inherited]

Definition at line 17 of file ssi_sample.hpp.

Referenced by sample::sample(), and sample::vvalue().

mark_t* marks [inherited]

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