test-cube-with-hole.cc

Construct a topological cube with a through hole using Euler operators. Geometrically, the constructed cube collapses to a single point, because All vertices are assigned to the same coords(1,1,1); to form a real cube, assign different pnt apropriately at each operation.

construct-cube-with-hole.jpg

Author:
Xianming Chen
Computer Science Department
University of Utah
Date:
16 Aug 2006
Copyright (c) 2006, University of Utah
00001 /**
00002  *\file       test-cube-with-hole.cc
00003  *
00004  *\brief      Construct a topological cube with a through hole directly using Euler operators.  
00005  *
00006  *\example    test-cube-with-hole.cc
00007  *
00008  *            Construct a topological cube with a through hole using Euler operators.  
00009  *            Geometrically, the constructed cube collapses to a single point, because 
00010  *            All vertices are assigned to the same coords(1,1,1);                       
00011  *            to form a real cube, assign different pnt apropriately at each operation.
00012  *              
00013  *
00014  *\image        html construct-cube-with-hole.jpg
00015  *
00016  *\author       Xianming Chen\n
00017  *              Computer Science Department\n
00018  *              University of Utah
00019  *
00020  *\date          16 Aug 2006\n
00021  *              Copyright (c) 2006, University of Utah
00022  */
00023 
00024 
00025 #include "print.h"
00026 using namespace std;
00027 using namespace euler;
00028 
00029 
00030 int main()
00031 {
00032   point_t p(1.,1.,1.);  // geometrically collapsed to one pnt.
00033 
00034   /* 
00035    * intialize to skeletal cube: 
00036    * topology = 1 0d-cell + 1 2d-cells
00037    */
00038   solid_t *s = solid_t :: mvfs(p);
00039   loop_t *l = s->f->l;   // singular loop: 0
00040   cout << s << endl;
00041   
00042   /* 
00043    * add 3 consecutive dangling edges to form an open square:
00044    * topology = 4 0d-cell + 3 1d-cells + 1 2d-cell          
00045    */
00046   l->mev( l->mev( l->mev( l->f->l->e, p ), p ), p );
00047   l->del_single_vertex_edge_pair();      // loop = 0 1 2 3 2 1
00048   cout << l << endl;   
00049   
00050 
00051   /*
00052    * close the open square by splitting the loop
00053    * topology = 2 2d-cells (faces) + 4 1d-cells (edges) + 4 0d-cells (vertices)
00054    */
00055   s->mef(l->e, l->e->nxt->nxt->nxt);    // new loop: 3 0 1 2  (top cube face), old loop l= 0 3 2 1
00056   cout << s << endl;                   
00057   cout << l << endl;                   
00058 
00059   
00060   /*
00061    * next, add a dangling edge to each vertex of the square
00062    */
00063   edge_t
00064     *e03 = l->e,
00065     *e10 = e03->pre,
00066     *e21 = e10->pre,
00067     *e32 = e21->pre;
00068 
00069   l->mev(e03, p);
00070 
00071   l->mev(e10, p);
00072 
00073   l->mev(e21, p);
00074   l->mev(e32, p);   // now: 0 3 7 3 2 6 2 1 5 1 0 4
00075   cout << s << endl;
00076   cout << l << endl;
00077 
00078   /*
00079    * close the 4 opening squares to form the cube
00080    */
00081   edge_t
00082     *e40 = l->e->pre,
00083     *e73 = l->e->nxt->nxt,
00084     *e62 = e73->nxt->nxt->nxt,
00085     *e51 = e62->nxt->nxt->nxt;
00086     
00087   s->mef(e40, e73);
00088   s->mef(e73, e62);
00089   s->mef(e62, e51);
00090   s->mef(e51, e51->nxt->nxt->nxt);
00091 
00092   cout << s << endl;
00093     
00094   
00095   /*
00096    * contruct the "inner cube"
00097    */
00098 
00099   /*
00100    * make inner top face  
00101    */
00102   face_t* top = s->f->nxt->nxt->nxt->nxt;  // 3 0 1 2
00103   face_t* btm = s->f->nxt->nxt->nxt->nxt->nxt;  // 5 4 7 6
00104   
00105   l = top->kemr( top->l->mev(top->l->e->nxt, p)->o ); // singular: 8
00106     
00107   l->mev( l->mev( l->mev(l->e,p), p ), p ); 
00108   l->del_single_vertex_edge_pair();        // 8 9 A B A 9 
00109 
00110   //now top face has 2 loops, with the inner one zero area.
00111   cout << s << endl;
00112   cout << l << endl;
00113 
00114   //cut top face into two
00115   face_t* inner_top = s->mef(l->e, l->e->nxt->nxt->nxt)->f;
00116   cout << s << endl;
00117 
00118 
00119   /*
00120    * make inner bottom face  
00121    */
00122   l = btm->kemr( btm->l->mev(btm->l->e->nxt, p)->o ); // singular: 12
00123   
00124   l->mev( l->mev( l->mev(l->e,p), p ), p ); 
00125   l->del_single_vertex_edge_pair();        // 8 9 A B A 9  (all +4)
00126 
00127   //now btm face has 2 loops, with the inner one zero area.
00128   cout << s << endl;
00129   cout << l << endl;     
00130   
00131   //cut btm face into two
00132   face_t* inner_btm = s->mef(l->e->nxt->nxt->nxt, l->e)->f;
00133   cout << s << endl;
00134 
00135   cout << "inner_top = " << inner_top << endl;
00136   cout << "inner_btm = " << inner_btm << endl;
00137   
00138 
00139   s->kfmrh(inner_top, inner_btm);
00140 
00141   face_t* hole = inner_top;
00142   //now the vertical hole is annulus (or cynliner)
00143   cout << s << endl;
00144   cout << "...hole = \n" << hole << endl;
00145 
00146   edge_t
00147     *e89 = hole->l->e->nxt,     *eDC = hole->l->nxt->e->pre,
00148     *e9A = e89->nxt,            *eED = eDC->pre,                
00149     *eAB = e9A->nxt,            *eFE = eED->pre,                
00150     *eB8 = eAB->nxt,            *eCF = eFE->pre;                
00151 
00152 //   cout << e89 << endl;
00153 //   cout << e9A << endl;
00154 //   cout << eAB << endl;
00155 //   cout << eB8 << endl;
00156 
00157 //   cout << eDC << endl;
00158 //   cout << eED << endl;
00159 //   cout << eFE << endl;
00160 //   cout << eCF << endl;
00161 
00162   hole->mekr(e89, eCF);
00163   cout << s << endl;
00164 
00165   cout << "hole = \n" << hole << endl;
00166   //  exit(0);
00167   
00168   cout << "e9A=" << e9A << endl;
00169   cout << "eDC=" << eDC << endl;
00170   s->mef(e9A, eDC);
00171   cout << "hole = \n" << hole << endl;
00172 
00173 
00174   s->mef(eAB, eED);
00175 
00176   cout << eFE << endl << endl;
00177   cout << eB8 << endl;
00178   cout << eB8->nxt << endl;
00179   cout << eB8->nxt->nxt << endl;
00180   cout << eB8->nxt->nxt->nxt << endl;
00181   cout << eB8->nxt->nxt->nxt->nxt << endl;
00182   //  exit(0);
00183   
00184   s->mef(eB8, eFE);
00185   
00186   cout << s << endl;
00187   
00188     
00189   return 0;
00190 }
00191 
00192 
00193 
00194 

Generated on Wed Aug 30 16:27:58 2006 for euler by  doxygen 1.4.6