arrangement2d< C, V > Class Template Reference

#include <arrangement2d.hpp>

Inheritance diagram for arrangement2d< C, V >:
mesher2d< C, V >

List of all members.

Public Types

Public Member Functions

Public Attributes

Protected Member Functions


Detailed Description

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

Definition at line 38 of file arrangement2d.hpp.


Member Typedef Documentation

Reimplemented from mesher2d< C, V >.

Definition at line 46 of file arrangement2d.hpp.

typedef mesher2d<C,V>::Cell Cell

Reimplemented from mesher2d< C, V >.

Definition at line 48 of file arrangement2d.hpp.

typedef mesher2d<C,V>::Cell2d Cell2d

Reimplemented from mesher2d< C, V >.

Definition at line 49 of file arrangement2d.hpp.

typedef mesher2d<C,V>::Curve Curve

Reimplemented from mesher2d< C, V >.

Definition at line 50 of file arrangement2d.hpp.

typedef mesher2d<C,V>::Edge Edge

Reimplemented from mesher2d< C, V >.

Definition at line 43 of file arrangement2d.hpp.

typedef mesher2d<C,V>::Face Face

Reimplemented from mesher2d< C, V >.

Definition at line 44 of file arrangement2d.hpp.

typedef kdtree<Cell*> Kdtree

Reimplemented from mesher2d< C, V >.

Definition at line 53 of file arrangement2d.hpp.

typedef node<Cell*> Node

Reimplemented from mesher2d< C, V >.

Definition at line 52 of file arrangement2d.hpp.

typedef tpl3d<C,V> Output [inherited]

Definition at line 73 of file mesher2d.hpp.

typedef mesher2d<C,V>::Point Point

Reimplemented from mesher2d< C, V >.

Definition at line 42 of file arrangement2d.hpp.

typedef topology<C,V> Topology

Reimplemented from mesher2d< C, V >.

Definition at line 54 of file arrangement2d.hpp.


Constructor & Destructor Documentation

arrangement2d (  )  [inline]

Definition at line 58 of file arrangement2d.hpp.

00058 : mesher2d<C,V>(){ };

arrangement2d ( Curve curve  ) 
~arrangement2d ( void   )  [inline]

Definition at line 61 of file arrangement2d.hpp.

00061 {   delete this->m_tree ;  };


Member Function Documentation

void add_input ( Shape s  )  [inline, inherited]

Definition at line 177 of file mesher2d.hpp.

References Seq< C, R >::push_back().

00177                               {
00178     this->m_input_objects.push_back(object);
00179 }

bcell< C, V > * get_input_cell (  )  [inline, inherited]

Definition at line 183 of file mesher2d.hpp.

References Seq< C, R >::size().

Referenced by mesher2d< C, V >::run().

00183                      {
00184     if(this->m_input_objects.size() == 1)
00185         return Cell2dFactory::instance()->create(this->m_input_objects[0],this->m_input_bbx);
00186     else
00187         return Cell2dFactory::instance()->create(this->m_input_objects,this->m_input_bbx);
00188 }

Output* get_output ( void   )  [inline, inherited]
double get_precision ( void   )  [inline, inherited]

Definition at line 86 of file mesher2d.hpp.

Referenced by mesher2d< C, V >::run().

00086 { return m_prec;   }

double get_smoothness ( void   )  [inline, inherited]

Definition at line 85 of file mesher2d.hpp.

Referenced by mesher2d< C, V >::run().

00085 { return m_smooth; }

bool insert_regular ( Cell bcell  )  [inline, protected]

Reimplemented from mesher2d< C, V >.

Definition at line 303 of file arrangement2d.hpp.

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

00303                               {
00304   return cl->insert_regular(this);
00305 }

bool insert_singular ( Cell bcell  )  [inline, protected, inherited]

Definition at line 299 of file mesher2d.hpp.

References mesher2d< C, V >::get_output(), and bcell< C, V >::insert_singular().

00299                                {
00300     return cl->insert_singular(this->get_output()) ;
00301 }

void insert_singular ( Point p  )  [inline, virtual]

Reimplemented from mesher2d< C, V >.

Definition at line 313 of file arrangement2d.hpp.

References mesher2d< C, V >::m_specials.

00313                                {
00314   this->m_specials<<p;
00315 }

bool is_regular ( Cell bcell  )  [inline, protected]

Reimplemented from mesher2d< C, V >.

Definition at line 298 of file arrangement2d.hpp.

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

00298                           {
00299   return cl->is_regular();
00300 }

void run ( void   )  [inline]

Reimplemented from mesher2d< C, V >.

Definition at line 99 of file arrangement2d.hpp.

References assert, mesher2d< C, V >::b_leaves, Seq< C, R >::clear(), Graph< T >::delete_vertex(), Graph< T >::dfs(), bcell2d< C, V >::e_neighbors, mesher2d< C, V >::get_output(), face< C, V, POINT >::insert(), bcell2d< C, V >::intersections(), cell< C, V >::is_active(), bcell2d< C, V >::is_border(), bcell2d< C, V >::is_corner(), cell< C, V >::is_regular(), tpl3d< C, V >::m_faces, mesher2d< C, V >::m_leaves, Graph< T >::member(), bcell2d< C, V >::n_neighbors, bcell2d< C, V >::nb_intersect(), bcell2d< C, V >::neighbors(), Graph< T >::next(), Graph< T >::push_edge(), bcell2d< C, V >::s_neighbors, sgn(), Seq< C, R >::size(), STACK, and bcell2d< C, V >::w_neighbors.

00099           {
00100 //
00101     mesher2d<C,V>::run();
00102 
00103 
00104     std::cout<<"Computing arrangement." <<std::endl;
00105 
00106     Seq<Cell2d*> nlist;
00107     this->b_leaves.dfs(nlist);// remove empty border bcells
00108     Cell2d* pr;
00109     pr= nlist[nlist.size()-1];
00110     //if (0)
00111     foreach(Cell2d* cl2, nlist)
00112      {
00113          if ( cl2->is_corner() )
00114              pr=cl2;
00115          else {
00116              if ( (cl2->s_neighbors.size()==0 && 
00117                    cl2->intersections(0).size()==0 ) ||
00118                   (cl2->e_neighbors.size()==0 && 
00119                    cl2->intersections(1).size()==0 ) ||
00120                   (cl2->n_neighbors.size()==0 && 
00121                    cl2->intersections(2).size()==0 ) ||
00122                   (cl2->w_neighbors.size()==0 && 
00123                    cl2->intersections(3).size()==0 )  )
00124              {
00125                  this->b_leaves.push_edge(pr, this->b_leaves.next(cl2) ) ;
00126                  this->b_leaves.delete_vertex( cl2 ) ;
00127              }
00128              else
00129                  pr=cl2;
00130          }
00131      }
00132 
00133 std::cout<<"Border Ok." <<std::endl;
00134 
00135       // Leaf graph
00136       nlist.clear();
00137       this->m_leaves.dfs(nlist);
00138       foreach(Cell2d* cl2, nlist)
00139       {
00140           //Cell * cl= dynamic_cast<Cell*>(cl);
00141           foreach(Cell2d* nb, cl2->neighbors() )
00142               this->m_leaves.push_edge( cl2,nb ) ;
00143       }
00144       //remove interior bcells
00145       if (0)//done at subdivision time
00146       foreach(Cell2d* cl, nlist) {
00147         if (!cl->is_active() )//|| !cl->is_touching() ) 
00148         {  
00149           this->m_leaves.delete_vertex(cl);
00150         }
00151       }
00152       
00153       
00154  std::cout<<"Leaf graph Ok." <<std::endl;
00155 
00157 
00158 //Remove inactive bcells OK ..
00159 // AND misleading edges 
00160 //Recover connected components .. ( for all regular bcells and sign +,-)
00161 // FOR ALL CC's:
00162 //1. check if CC is actually SCC .. 
00163 //2. walk on boundry and output face
00164 
00165    Point *p= NULL;
00166    Face * f= NULL;
00167    int aux;
00168    int sgn(1);
00169    assert( nlist.size()>1);
00170 
00171    Cell2d *s= NULL,
00172           *t= NULL,
00173           *b= NULL;
00174    STACK stack;
00175 
00176    // Start exploration
00177   foreach(Cell2d* cl, nlist)
00178     if ( 
00179         cl->is_regular() && 
00180         cl->nb_intersect()==2 && 
00181         !cl->is_border() )
00182       stack.push(cl);  
00183 
00184 //if (0)
00185 while ( !stack.empty() )
00186    {
00187    s= stack.top();
00188    aux=s->m_gnode->aux();
00189    //std::cout<<"-Aux="<<aux<<std::endl;
00190 
00191    //-- all faces --
00192    switch ( aux )
00193    { 
00194    case (0): sgn=1; //+ face
00195    break;
00196    case (2): sgn=-1;//- face
00197    break;
00198    case (-1):sgn=1;//+ face
00199    break;
00200    default:  stack.pop();
00201    continue;
00202    }
00203 
00204 
00205    //Recovering face (s,sgn)
00206    f= new Face();
00207 
00208    // Get starting point (CCW)
00209    p= s->starting_point(sgn);
00210    std::cout<<"Getting ("<<(sgn==1 ? "+": "-")
00211      <<") face starting at "<< *s<<  std::endl;
00212 
00213    // Walking on CCW face
00214    p= s->pair(p,sgn);
00215    f->insert(p);
00216    b=s;
00217 
00218    
00219 //int c(0); 
00220    do  {
00221 //if (++c>120) {while(!stack.empty()) stack.pop(); exit(0);break;}
00222 //     std::cout<<"Next "<< *b <<std::endl;
00223 //       if ( !b->is_corner())
00224 //         std::cout<< *b<<", aux="<<b->m_gnode->aux()<<std::endl;
00225 
00226       if( this->m_leaves.member(b) ) {
00227       aux=b->m_gnode->aux();
00228       b->m_gnode->aux(aux + (sgn==1 ? 2:-1) );}
00229 
00230       t= b->neighbor(p);
00231 
00232       if ( t==NULL)
00233       { // border bcell reached
00234 
00235           //check meeting corner
00236           if          (b->s_neighbors.size()==0 &&
00237                        b->e_neighbors.size()==0 && b->intersections(1).size()==0)
00238            f->insert(new Point(b->xmax(),b->ymin(),0.0) );
00239            else if    (b->e_neighbors.size()==0 &&
00240                        b->n_neighbors.size()==0 && b->intersections(2).size()==0)
00241            f->insert(new Point(b->xmax(),b->ymax(),0.0) );
00242            else if   (b->n_neighbors.size()==0 &&
00243                        b->w_neighbors.size()==0 && b->intersections(3).size()==0)
00244            f->insert(new Point(b->xmin(),b->ymax(),0.0) );
00245            else if   (b->w_neighbors.size()==0 &&
00246                        b->s_neighbors.size()==0 && b->intersections(0).size()==0)
00247              f->insert(new Point(b->xmin(),b->ymin(),0.0) );
00248 
00249           b=this->b_leaves.next(b);
00250 
00251           //check leaving corner
00252           if          (b->s_neighbors.size()==0 &&
00253                        b->e_neighbors.size()==0 && b->intersections(0).size()==0 )
00254           { f->insert(new Point(b->xmax(),b->ymin(),0.0) );
00255           } else if   (b->e_neighbors.size()==0 &&
00256                        b->n_neighbors.size()==0 && b->intersections(1).size()==0)
00257           { f->insert(new Point(b->xmax(),b->ymax(),0.0) );
00258           } else if   (b->n_neighbors.size()==0 &&
00259                        b->w_neighbors.size()==0 && b->intersections(2).size()==0)
00260           { f->insert(new Point(b->xmin(),b->ymax(),0.0) );
00261           } else if   (b->w_neighbors.size()==0 &&
00262                        b->s_neighbors.size()==0 && b->intersections(3).size()==0)
00263           {   f->insert(new Point(b->xmin(),b->ymin(),0.0) );
00264           }//end check corner
00265 
00266           if (  this->m_leaves.member(b) ) 
00267           {   //entering point
00268               p= b->starting_point(sgn);
00269               f->insert(p);
00270               p= b->pair(p,sgn);
00271               f->insert(p);
00272           }
00273       }
00274       else
00275       { // next normal bcell
00276           b=t;
00277           if ( b->m_singular.size()==1 )
00278               f->insert(b->m_singular[0]);
00279           p= b->pair(p,sgn);
00280           f->insert(p);
00281       }
00282 
00283    } while (b!=s); 
00284    //(b->m_gnode->aux()==1 || b->m_gnode->aux()==-1 || b->m_gnode->aux()==2) );
00285 
00286   //std::cout<<"Face Added" << std::endl;
00287   this->get_output()->m_faces<< f;
00288 
00289   //if (this->m_faces.size()==2)  break;
00290 
00291    }// End exploration
00292 
00293   std::cout<<" # faces= "<< this->get_output()->m_faces.size() << std::endl;
00294 
00295 }

void set_input_bbox ( const BoundingBox bx  )  [inline, inherited]

Definition at line 170 of file mesher2d.hpp.

References bounding_box< C, V >::set_zmax(), and bounding_box< C, V >::set_zmin().

00170                                            {
00171     m_input_bbx=box;
00172     m_input_bbx.set_zmin(0);
00173     m_input_bbx.set_zmax(0);
00174 }

void set_precision ( double  e  )  [inline, inherited]

Definition at line 83 of file mesher2d.hpp.

00083 { m_prec   = e; }

void set_smoothness ( double  e  )  [inline, inherited]

Definition at line 82 of file mesher2d.hpp.

00082 { m_smooth = e; }

typedef SHAPE_OF (  )  [inherited]
bool singularity ( Cell bcell  )  [inline, protected]

Definition at line 308 of file arrangement2d.hpp.

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

00308                            {
00309   return cl->insert_singular(this) ;
00310 }

bool subdivide ( Cell bcell,
Node node 
) [inline, protected]

Reimplemented from mesher2d< C, V >.

Definition at line 318 of file arrangement2d.hpp.

References node< _CELL >::LEFT, mmx::ssi::left(), node< _CELL >::m_left, node< _CELL >::m_right, node< _CELL >::RIGHT, mmx::ssi::right(), and bcell< C, V >::subdivide().

00318                                       {
00319   int v=0;
00320   
00321   Cell* left, * right;
00322   v = cl->subdivide(left, right) ;
00323   
00324   node->m_left  = new Node(node, left,  Node::LEFT,  v); 
00325   m_nodes << node->m_left ;
00326   node->m_right = new Node(node, right, Node::RIGHT, v); 
00327   m_nodes << node->m_right;
00328 
00329   return true ;
00330 }


Member Data Documentation

Graph<Cell2d*> b_leaves [inherited]
Graph<Point*> m_graph [inherited]

Definition at line 128 of file mesher2d.hpp.

Graph<Cell2d*> m_leaves [inherited]
Seq<Point*> m_specials [inherited]

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

Generated on 6 Dec 2012 for shape by  doxygen 1.6.1