shape_doc 0.1
lsegment Struct Reference

#include <ssi_lsegment.hpp>

Inheritance diagram for lsegment:
sample qsegment dsearch

List of all members.

Classes

Public Types

Public Member Functions

Public Attributes


Detailed Description

Definition at line 22 of file ssi_lsegment.hpp.


Member Typedef Documentation

typedef coord_t bounds_t[2]

Definition at line 24 of file ssi_lsegment.hpp.


Constructor & Destructor Documentation

lsegment ( const shape::surface_parametric< double > *  s,
unsigned  _w,
unsigned  _h 
)

Definition at line 130 of file ssi_lsegment.cpp.

References lsegment::_size, lsegment::convert_regions(), lsegment::find_regions(), lsegment::grp, lsegment::lines, lsegment::lines_changes(), and lsegment::marks.

                                                                             : sample(s,_w,_h)
  {
    //_st = time();
    _size = 0;
    lines_changes  ();
    grp = new graph_t();
    find_regions   ();
    convert_regions();
    delete[] marks;
    delete[] lines;
    //    std::cout << "l = " << (time()-_st) << std::endl;
  };
~lsegment ( )

Definition at line 143 of file ssi_lsegment.cpp.

References lsegment::grp, lsegment::regions, and lsegment::rfree().

  {
    delete grp;
    for ( unsigned i = 0; i < regions.size(); i++ )
      rfree(regions[i]);
  };

Member Function Documentation

void addneighbors ( mark_t m0,
mark_t m1 
)

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]

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 ( )

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]

Definition at line 63 of file ssi_lsegment.hpp.

Referenced by lsegment::find_regions().

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

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 ( )

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());
  };
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]

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; };
region_t& operator[] ( unsigned  i) [inline]

Reimplemented in qsegment.

Definition at line 78 of file ssi_lsegment.hpp.

References lsegment::regions.

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

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 
)

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 
)

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]

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));
    };
unsigned size ( void  ) const [inline]

Reimplemented in qsegment.

Definition at line 77 of file ssi_lsegment.hpp.

References lsegment::regions.

{ return regions.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

Definition at line 74 of file ssi_lsegment.hpp.

unsigned _size

Definition at line 47 of file ssi_lsegment.hpp.

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

unsigned* lines

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().


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