proj home

Files   Classes   Functions   Hierarchy  

d3fan2.cpp

Go to the documentation of this file.
00001 #include <cassert>
00002 using namespace std;
00003 
00004 #include <print.h>
00005 
00006 #include <simplexface.h>
00007 #include <d3tess.h>
00008 #include <d3fan2.h>
00009 
00010 d3fan2::d3fan2( d3tess & _tess )
00011   : tess(_tess)
00012 {
00013 }
00014 
00015 
00016 void d3fan2::addspike()
00017 {
00018   uint index = tess.vi.size();
00019   tess.vi.push_back( simplexD2linked() );
00020   simplexD2linked & ti(tess.vi[index]);
00021   simplexD2linked const & x(tess.cpsimplex());
00022 
00023   virtualtriangle const & vs(tess.vs);
00024 
00025   simplexface cpf = tess.cpsimplexfaceget();
00026 
00027   ti.pi[0] = x.pi[ vs.v[1] ];
00028   ti.pi[1] = x.pi[ vs.v[0] ];
00029   ti.pi[2] = w;
00030   ti.ni[2] = cpf.id;
00031 
00032   vft.push_back(cpf);
00033 
00034 }
00035 
00036 void d3fan2::traverseleft(simplexface const prev)
00037 {
00038   tess.surfaceleft();
00039   if (tess.surfaceviewable(w)==false)
00040     return;
00041 
00042   // k refers to the newely constructed triangle.
00043   uintc k = tess.vi.size();
00044 
00045   addspike();
00046   tess.vi[k].ni[1] = prev.id;
00047   tess.vi[prev.id].ni[prev.face] = k;
00048   
00049   traverseleft(simplexface(k,0));
00050 }
00051 
00052 void d3fan2::traverseright(simplexface const prev)
00053 {
00054   tess.surfaceright();
00055   if (tess.surfaceviewable(w)==false)
00056     return;
00057 
00058   // k refers to the newely constructed triangle.
00059   uintc k = tess.vi.size();
00060 
00061   addspike();
00062   tess.vi[k].ni[0] = prev.id;
00063   tess.vi[prev.id].ni[prev.face] = k;
00064   
00065   traverseright(simplexface(k,1));
00066 }
00067 
00068 void d3fan2::eval(uintc _w )
00069 {
00070   w = _w;
00071 
00072 //  {
00073 //    MessageGlobal mg;
00074 //    mg() << "SHOW(w)" << endl;
00075 //    mg() << tess << endl << endl;
00076 //  }
00077 
00078   tess.debugcheck();
00079 
00080   assert(tess.surfaceviewable(w));
00081 
00082   vft.clear();
00083 
00084   vk = tess.vi.size();
00085 
00086   addspike();
00087 
00088   //Preserve the virtual triangle
00089   virtualtriangle vs0 = tess.vs;
00090   uint cp0 = tess.cp;
00091 
00092   traverseleft(simplexface(vk,0));
00093 
00094   // Restore starting position.
00095   tess.vs = vs0;
00096   tess.cp = cp0;
00097 
00098   traverseright(simplexface(vk,1));
00099 
00100   // Reconnect triangles.
00101   uint sz = vft.size();
00102   for (uint i=0; i<sz; ++i)
00103     tess.vi[vft[i].id].ni[vft[i].face] = vk + i;
00104 
00105   // Minimize
00106   for (uint i=0; i<sz; ++i)
00107     tess.minimizer->eval(vft[i].id,vk+i);
00108 
00109   assert(sz == tess.vi.size()-vk);
00110   tess.debugcheck();
00111   
00112 }
00113 
00114 
00115 
00116 

Generated on Fri Mar 4 00:49:26 2011 for Chelton Evans Source by  doxygen 1.5.8