shape_doc 0.1
topology2d< C, V > Class Template Reference

#include <topology2d.hpp>

Inheritance diagram for topology2d< C, V >:
topology< C, V > SHAPE_OFV arrangement2d< C, V > semialgebraic2d< C, V >

List of all members.

Public Types

Public Member Functions

Public Attributes

Protected Member Functions

Protected Attributes


Detailed Description

template<class C, class V = default_env>
class mmx::shape::topology2d< C, V >

Definition at line 83 of file topology2d.hpp.


Member Typedef Documentation

Reimplemented from topology< C, V >.

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 89 of file topology2d.hpp.

typedef cell<C,V> Cell

Reimplemented from topology< C, V >.

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 90 of file topology2d.hpp.

typedef cell2d<C, REF_OF(V) > Cell2d

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 91 of file topology2d.hpp.

typedef curve< REF_OF(V) > Curve

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 92 of file topology2d.hpp.

typedef topology<C,V>::Edge Edge

Reimplemented from topology< C, V >.

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 87 of file topology2d.hpp.

typedef topology<C,V>::Face Face

Reimplemented from topology< C, V >.

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 88 of file topology2d.hpp.

typedef kdtree<Curve*, Cell*> Kdtree

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 95 of file topology2d.hpp.

typedef node<Curve*, Cell*> Node

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 94 of file topology2d.hpp.

typedef topology<C,V>::Point Point

Reimplemented from topology< C, V >.

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 86 of file topology2d.hpp.

typedef topology<C,V> Topology

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 85 of file topology2d.hpp.

typedef with_idx<V> W [inherited]

Definition at line 58 of file topology.hpp.


Constructor & Destructor Documentation

topology2d ( const BoundingBox bx)

Definition at line 253 of file topology2d.hpp.

                                      : Topology(bx) {
  m_tree = new Kdtree ;
}
topology2d ( Curve curve)

Definition at line 258 of file topology2d.hpp.

References topology< C, V >::m_objects.

                               : Topology(object->boundingBox()) {
  this->m_objects.push_back(object);
  m_tree = new Kdtree ;
}
~topology2d ( void  )

Definition at line 264 of file topology2d.hpp.

                      {
  delete m_tree ;
}

Member Function Documentation

unsigned count ( void  ) [inline, inherited]

Definition at line 84 of file topology.hpp.

References topology< C, V >::m_objects.

{ return m_objects.size(); }
Seq<Edge*> edges ( void  ) const [inline]

Definition at line 149 of file topology2d.hpp.

References topology2d< C, V >::m_edges.

{ return m_edges ; }
Edge* edges ( int  i) const [inline]

Definition at line 150 of file topology2d.hpp.

References topology2d< C, V >::m_edges.

{ return m_edges[i] ; }
void insert ( BoundingBox bx,
bool  cross = false 
) [virtual, inherited]

Definition at line 111 of file topology.hpp.

References Edge, mmx::shape::insert(), bounding_box< C, V >::xmax(), bounding_box< C, V >::xmin(), bounding_box< C, V >::ymax(), bounding_box< C, V >::ymin(), bounding_box< C, V >::zmax(), and bounding_box< C, V >::zmin().

                                                        {
  Point 
    *p0= new Point(bx->xmin(),bx->ymin(),bx->zmin()),
    *p1= new Point(bx->xmin(),bx->ymax(),bx->zmin()),
    *p2= new Point(bx->xmax(),bx->ymax(),bx->zmin()),
    *p3= new Point(bx->xmax(),bx->ymin(),bx->zmin());
  
  this->insert(p0);this->insert(p1); this->insert(new Edge(p0,p1));
  this->insert(p1);this->insert(p2); this->insert(new Edge(p1,p2));
  this->insert(p2);this->insert(p3); this->insert(new Edge(p2,p3));
  this->insert(p3);this->insert(p0); this->insert(new Edge(p3,p0));
      
  Point 
    *q0= new Point(bx->xmin(),bx->ymin(),bx->zmax()),
    *q1= new Point(bx->xmin(),bx->ymax(),bx->zmax()),
    *q2= new Point(bx->xmax(),bx->ymax(),bx->zmax()),
    *q3= new Point(bx->xmax(),bx->ymin(),bx->zmax());
  
  this->insert(q0);this->insert(q1); this->insert(new Edge(q0,q1));
  this->insert(q1);this->insert(q2); this->insert(new Edge(q1,q2));
  this->insert(q2);this->insert(q3); this->insert(new Edge(q2,q3));
  this->insert(q3);this->insert(q0); this->insert(new Edge(q3,q0));
  
  this->insert(p0);this->insert(q0);this->insert(new Edge(p0,q0));
  this->insert(p1);this->insert(q1);this->insert(new Edge(p1,q1));
  this->insert(p2);this->insert(q2);this->insert(new Edge(p2,q2));
  this->insert(p3);this->insert(q3);this->insert(new Edge(p3,q3));

  if(cross) {
    Point 
      *r0= new Point(bx->xmin(),bx->ymin(),bx->zmax()),
      *r1= new Point(bx->xmin(),bx->ymax(),bx->zmax()),
      *r2= new Point(bx->xmax(),bx->ymax(),bx->zmax()),
      *r3= new Point(bx->xmax(),bx->ymin(),bx->zmax());

    this->insert(r0);this->insert(r2);this->insert(new Edge(r0,r2));
    this->insert(r1);this->insert(r3);this->insert(new Edge(r1,r3));
  }
}
void insert ( Point p1,
Point p2 
) [virtual]

Definition at line 414 of file topology2d.hpp.

References Edge.

                                           { 
  this->m_edges << new Edge(p1,p2); 
  this->m_graph.push_uedge(p1,p2); 
}
void insert ( Edge e) [virtual]

Implements topology< C, V >.

Definition at line 409 of file topology2d.hpp.

                                { 
  this->m_edges    << e;
  this->m_graph.push_uedge(e->source(), e->destination() ); 
}
void insert ( Point p) [virtual]

Implements topology< C, V >.

Definition at line 401 of file topology2d.hpp.

References vertex< C, V, N >::index(), and vertex< C, V, N >::set_index().

Referenced by cell2d_algebraic_curve< C, V >::insert_regular(), and cell2d_algebraic_curve< C, V >::insert_singular().

                                  { 
    if(p->index()<0) {
      p->set_index(this->m_vertices.size());
      this->m_vertices << p; 
      this->m_graph.push_vertex(p);
    }
  }
bool insert_regular ( Cell cell) [protected]

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 372 of file topology2d.hpp.

References cell< C, V >::insert_regular().

                              {
  return cl->insert_regular(this);
}
void insert_singular ( Point p) [virtual]

Implements topology< C, V >.

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 382 of file topology2d.hpp.

                               {
  m_specials<<p;
}
bool is_regular ( Cell cell) [protected]

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 367 of file topology2d.hpp.

References cell< C, V >::is_regular().

                          {
  return cl->is_regular();
}
int nbe ( ) const [inline]

Definition at line 146 of file topology2d.hpp.

References topology2d< C, V >::m_edges.

{ return m_edges.size();}
int nbv ( void  ) const [inline]

Definition at line 145 of file topology2d.hpp.

References topology2d< C, V >::m_vertices.

{ return m_vertices.size();}
void operator<< ( Shape s) [inline, inherited]

Definition at line 82 of file topology.hpp.

References topology< C, V >::m_objects.

{ m_objects.push_back(s); }
void push_back ( Shape s) [inline, inherited]

Definition at line 81 of file topology.hpp.

References topology< C, V >::m_objects.

{ m_objects.push_back(s); }
void run ( void  )

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 269 of file topology2d.hpp.

References cell2d< C, V >::e_neighbors, node< _Object, _CELL >::get_cell(), cell< C, V >::is_active(), cell2d< C, V >::is_border(), cell2d< C, V >::m_gnode, cell2d< C, V >::n_neighbors, cell2d< C, V >::s_neighbors, node< _Object, _CELL >::set_cell(), bounding_box< C, V >::size(), and cell2d< C, V >::w_neighbors.

Referenced by semialgebraic2d< C, V >::run(), and arrangement2d< C, V >::run().

          {
  
  Node* root = m_tree->root() ;

  std::cout<<"Running, objs="<<this->m_objects.size() << std::endl;

  Cell* cl = Cell2dFactory::instance()->create(this->m_objects,this->m_bbx);

  root->set_cell( (Cell*)cl ) ;
  this->m_nodes.push_back(root) ;

  //std::cout<<"RUNing "<< cl <<std::endl;

  // double maxsz = this->m_maxprec*m_tree->root()->get_cell()->size();
  // double minsz = this->m_minprec*m_tree->root()->get_cell()->size();
  double maxsz = this->m_maxprec;
  double minsz = this->m_minprec;

  while(!m_nodes.empty()  ) {   //      
    Node * node = m_nodes.front() ;
    Cell   * cl = node->get_cell() ;
    Cell2d * cl2= dynamic_cast<Cell2d*>(cl);

    //std::cout<<"node "<<cl <<std::endl;

    if(cl->is_active()) {

      //std::cout<<"active.. "<<std::endl;

      if(cl->size() > maxsz) 
        { 
          this->subdivide(cl, node) ;
        }
      else if(this->is_regular(cl) )// && cl->is_intersected())
      { 
        //std::cout<<"ins regular "<<std::endl;
        this->insert_regular(cl) ;
        //std::cout<<"ok "<<std::endl;
        cl2->m_gnode= 
          this->m_leaves.push_vertex(cl2);
        if (  cl2->is_border() )
          this->b_leaves.push_vertex(cl2);       
      }
      else if(cl->size() > minsz)
      { 
        //std::cout<<"subdivide "<<std::endl;
        this->subdivide(cl, node) ;
      }
      else
      { 
        //std::cout<<"singularity "<<std::endl;
        this->singularity(cl) ;
        cl2->m_gnode= 
          this->m_leaves.push_vertex(cl2);
        if (  cl2->is_border() )
          this->b_leaves.push_vertex(cl2);       
      }
    } 
    else    //inactive leaf -- end if
    {
      // cl2->m_gnode= 
      // this->m_leaves.push_vertex(cl2);
        if (  cl2->is_border() )
            this->b_leaves.push_vertex(cl2);       
    }
    this->m_nodes.pop_front() ;
  }

  /* add edges */
  Seq<Cell2d*> nlist;

  std::cout<<"border " << std::endl;
  // Border graph
  this->b_leaves.dfs(nlist);
  foreach(Cell2d* cl2, nlist)
  {
    if (cl2->s_neighbors.size()==0)
      foreach(Cell2d* nb, cl2->e_neighbors )
        if (nlist.member(nb) && nb->s_neighbors.size()==0)
          this->b_leaves.push_edge( cl2,nb ) ;
    if (cl2->e_neighbors.size()==0)
      foreach(Cell2d* nb, cl2->n_neighbors )
        if (nlist.member(nb) && nb->e_neighbors.size()==0)
          this->b_leaves.push_edge( cl2,nb ) ;
    if (cl2->n_neighbors.size()==0)
      foreach(Cell2d* nb, cl2->w_neighbors )
        if (nlist.member(nb)&& nb->n_neighbors.size()==0)
          this->b_leaves.push_edge( cl2,nb ) ;
    if (cl2->w_neighbors.size()==0)
             foreach(Cell2d* nb, cl2->s_neighbors )
               if (nlist.member(nb)&& nb->w_neighbors.size()==0)
                 this->b_leaves.push_edge( cl2,nb ) ;
  }
  nlist.clear();
}
void set_precision ( double  eps) [inherited]

Reimplemented in subdivision< C, with_tpl3d< V >, SURFACE, CELL >.

Definition at line 107 of file topology.hpp.

                                        {
  m_minprec = eps;
}
void set_smoothness ( double  eps) [inherited]

Reimplemented in subdivision< C, with_tpl3d< V >, SURFACE, CELL >.

Definition at line 103 of file topology.hpp.

                                         {
  m_maxprec = eps;
}
typedef SHAPE_OF ( ) [inherited]
bool singularity ( Cell cell) [protected]

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 377 of file topology2d.hpp.

References cell< C, V >::insert_singular().

                           {
  return cl->insert_singular(this) ;
}
bool subdivide ( Cell cell,
Node node 
) [protected]

Reimplemented in arrangement2d< C, V >, and semialgebraic2d< C, V >.

Definition at line 387 of file topology2d.hpp.

References mmx::shape_ssi::left(), node< _Object, _CELL >::m_left, node< _Object, _CELL >::m_right, Node, mmx::shape_ssi::right(), and cell< C, V >::subdivide().

                                      {
  int v=0;
  
  Cell* left, * right;
  v = cl->subdivide(left, right) ;
  
  node->m_left  = new Node(node, left,  Node::LEFT,  v); 
  m_nodes << node->m_left ;
  node->m_right = new Node(node, right, Node::RIGHT, v); 
  m_nodes << node->m_right;

  return true ;
}
Point* vertices ( int  i) const [inline]

Definition at line 148 of file topology2d.hpp.

References topology2d< C, V >::m_vertices.

{ return m_vertices[i] ; }

Member Data Documentation

Definition at line 143 of file topology2d.hpp.

BoundingBox m_bbx [inherited]

Definition at line 91 of file topology.hpp.

Seq<Edge *> m_edges

Definition at line 137 of file topology2d.hpp.

Referenced by topology2d< C, V >::edges(), and topology2d< C, V >::nbe().

Seq<Face *> m_faces

Definition at line 138 of file topology2d.hpp.

Definition at line 140 of file topology2d.hpp.

Definition at line 142 of file topology2d.hpp.

double m_maxprec [inherited]

Definition at line 88 of file topology.hpp.

double m_minprec [inherited]

Definition at line 89 of file topology.hpp.

std::list<Node *> m_nodes [protected]

Definition at line 118 of file topology2d.hpp.

Definition at line 136 of file topology2d.hpp.

Referenced by topology2d< C, V >::nbv(), and topology2d< C, V >::vertices().


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