C:/Projekte/InfoVIS/InfoVIS/LogGrid.cpp

00001 #include "LogGrid.h"
00002 
00003 using namespace std;
00004 
00005 
00006 // Create complex logarithmic grid
00007 LogGrid::LogGrid(LinearGrid* _linear, const Texture* _texture):linear(_linear), texture(_texture)
00008 {
00009         // log(z) = ln|z| + i*arg(z) with -pi < arg(z) < pi
00010         double real, imag, absValue;
00011         double lnZ;
00012         double argZ;
00013         TexturedGrid tg;
00014 
00015         // Retrieve const-pointer to linear grid
00016         const ComplexGrid linGrid = linear->GetGrid();
00017 
00018         for(gridIterator = linGrid.begin(); gridIterator != linGrid.end(); ++gridIterator)
00019         {
00020                 for(vectorIterator = gridIterator->begin(); vectorIterator != gridIterator->end(); ++vectorIterator)
00021                 {
00022                         real = vectorIterator->complex.real();
00023                         imag = vectorIterator->complex.imag();
00024 
00025                         absValue = std::abs(vectorIterator->complex);
00026 
00027                         lnZ = std::log(absValue);
00028                         //argZ = std::atan2(real, imag);
00029                         argZ = std::atan2(real, imag);
00030 
00031                         tg.uCoordinate = vectorIterator->uCoordinate;
00032                         tg.vCoordinate = vectorIterator->vCoordinate;
00033                         tg.isCut = vectorIterator->isCut;
00034                         tg.complex.real(lnZ);
00035                         tg.complex.imag(argZ);
00036 
00037                         logVector.push_back(tg);
00038                 }
00039                 logGrid.push_back(logVector);
00040                 logVector.clear();
00041         }
00042 }
00043 
00044 LogGrid::~LogGrid(void)
00045 {
00046 }
00047 
00048 void LogGrid::Draw()
00049 {
00050         glColor3f(0.0, 0.0, 0.0);
00051         glPointSize(5.0f);
00052         glBegin(GL_POINTS);
00053                 glVertex2i(0,0);
00054         glEnd();
00055         glColor3f(1.0, 0.0, 0.0);
00056         glPointSize(1.0f);
00057 
00058         glBindTexture(GL_TEXTURE_2D, texture->GetTextureID());
00059         glEnable(GL_TEXTURE_2D);
00060 
00061         int tmpSize = logGrid.size()/2;
00062         VectorIteratorConst vItrCurrentRow;
00063         VectorIteratorConst vItrUpperRow;
00064 
00065         for(GridIteratorConst gridIterator = logGrid.begin(); gridIterator != logGrid.end() -1; ++gridIterator, tmpSize--)
00066         {
00067 
00068                 vItrCurrentRow = gridIterator->begin();
00069                 vItrUpperRow = (gridIterator+1)->begin();
00070                 DrawHalf(vItrCurrentRow, vItrUpperRow, gridIterator->size()/1);
00071 
00072         } // end outer for
00073 
00074         glDisable(GL_TEXTURE_2D);
00075 }                       
00076 
00077 void LogGrid::DrawHalf(VectorIteratorConst vItrCurrentRow, VectorIteratorConst vItrUpperRow, int size)
00078 {
00079         double x, y, u, v;
00080 
00081                 glBegin(GL_QUAD_STRIP);         
00082                 for (unsigned int i = 0; i < size; i++)
00083                 {
00084 
00085                         if(vItrCurrentRow->isCut)
00086                         {
00087                                 glEnd();
00088                                 glBegin(GL_QUAD_STRIP);
00089                         }
00090 
00091                         // 1st/3rd/5th... Vertex for QUAD_STRIP
00092                         x = vItrCurrentRow->complex.imag()/PI;
00093                         y = (vItrCurrentRow->complex.real() + 1.0)/1.33;
00094 
00095                         v = vItrCurrentRow->uCoordinate;
00096                         u = vItrCurrentRow->vCoordinate;
00097 
00098                         glTexCoord2f(u,v);
00099                         glVertex2d(x,y);
00100 
00102                         x = vItrUpperRow->complex.imag()/PI;
00103                         y = (vItrUpperRow->complex.real() + 1.0)/1.33;
00104 
00105                         v = vItrUpperRow->uCoordinate;
00106                         u = vItrUpperRow->vCoordinate;
00107 
00108                         glTexCoord2f(u,v);
00109                         glVertex2d(x,y);
00110                         
00111                         ++vItrCurrentRow;
00112                         ++vItrUpperRow;
00113 
00114                         
00115                 } // end inner for
00116                 glEnd();
00117 }

Generated on Wed Jun 27 10:14:23 2007 for CLV by  doxygen 1.5.2