proj home

Files   Classes   Functions   Hierarchy  

mazedisp01.cpp

Go to the documentation of this file.
00001 #include <cassert>
00002 using namespace std;
00003 
00004 #include <gobj.h>
00005 #include <mazedisp01.h>
00006 #include <typedefs.h>
00007 
00008 
00009 mazedisp01::mazedisp01
00010 (
00011   doublec dx_, 
00012   uintc mazeorigin_,
00013   mazematrixD2<uint> const & mz_
00014 )
00015   : mazeorigin(mazeorigin_), mz(mz_), mmap(mz,1,1), 
00016   dx(dx_), color(gobjglColor3f(0.0,0.0,1.0))
00017 {
00018 }
00019 
00020 void mazedisp01::draw()
00021 {
00022   assert(mz.valid());
00023   assert(mazeorigin!=0);
00024   assert(mazeorigin<mz.vi.size());
00025 
00026   mmap.relativeto(mazeorigin);
00027   mmap.eval();
00028 
00029   gobjpush(new gobjglDisable(GL_LIGHTING));
00030   gobjpush(new gobjglBegin(GL_LINES));
00031   gobjpush(new gobjglColor3f(color));
00032 
00033   uint id;
00034   point2<int> pos1;
00035   point2<double> pos2;
00036   for (mmap.reset(); !mmap; ++mmap)
00037   {
00038     id=mmap.currentIndex();
00039     pos1=mmap.currentPosition();
00040     pos2.x = dx*pos1.x;
00041     pos2.y = dx*pos1.y;
00042     celldraw(mz.vi[id],pos2);
00043   }
00044 
00045   gobjpush(new gobjglEnd()); 
00046 }
00047 
00048 
00049 void mazedisp01::celldraw
00050 ( 
00051   cellD2<uint> const & x,
00052   point2<double> const & p00
00053 )
00054 {
00055   point2<double> p10 = p00;
00056   p10.x += dx;
00057   point2<double> p01 = p00;
00058   p01.y += dx;
00059   point2<double> p11 = p00;
00060   p11.x += dx;
00061   p11.y += dx;
00062 
00063   if (x.ni[1]==0)
00064   {
00065     gobjpush(new gobjglVertex2d(p10));
00066     gobjpush(new gobjglVertex2d(p11));
00067   }
00068 
00069   if (x.ni[3]==0)
00070   {
00071     gobjpush(new gobjglVertex2d(p01));
00072     gobjpush(new gobjglVertex2d(p00));
00073   }
00074 
00075   
00076   if (x.ni[0]==0)
00077   {
00078     gobjpush(new gobjglVertex2d(p01));
00079     gobjpush(new gobjglVertex2d(p11));
00080   }
00081   
00082   if (x.ni[2]==0)
00083   {
00084     gobjpush(new gobjglVertex2d(p00));
00085     gobjpush(new gobjglVertex2d(p10));
00086   }
00087 }
00088 

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