float flutewl() { Tree t; DTYPE totwl; DTYPE x[MAXD], y[MAXD]; float xOffset, yOffset; int i, j, k, r, d; totwl = 0; for (j=1; j<=numNets; j++) { d = netlistIndex[j+1] - netlistIndex[j]; k = netlistIndex[j]; for (r=0; r<d; r++) { i = netlist[k+r]; xOffset = xPinOffset[k+r]; yOffset = yPinOffset[k+r]; x[r] = (DTYPE) xCellCoord[i]+xOffset; y[r] = (DTYPE) yCellCoord[i]+yOffset; } #if ROUTING==1 t = flute(d, x, y, ACCURACY); totwl += t.length; #else totwl += flute_wl(d, x, y, ACCURACY); #endif } return (float) totwl; }
double stwl(const std::vector<geometry::point<double> >&points) { readLUT(); if(points.size() <= 3) return hpwl(points); std::vector<unsigned> X(points.size()); std::vector<unsigned> Y(points.size()); X.resize(0); Y.resize(0); for (auto & p : points) { X.push_back(p.x()); Y.push_back(p.y()); } auto tree = flute(points.size(), X.data(), Y.data(), ACCURACY); delete tree.branch; return tree.length; }
void init() { bancAlto = new BancoAlto(0.6); bancBalc = new BancoBalcao(0.8); bar = Bar(1); copoV=copo_vinho(0.025); copoL=copo_largo(0.025); flt=flute(0.035); mesaQ=new MesaQuadrada(0.5,0.2); mesaR=new MesaRedonda(0.4); sofa=new Sofa(0.7,2); bil=new Bilhar(0.7); cBilhar=new CandeeiroBilhar(2,0.2); balcao=new Balcao(5,0.6,2); cLuz=new CandeeiroLuz(0.1); garr=new GarrafaAgua(0.2); garW=new GarrafaWhisky(0.2); porta=new Plano(0.5,1,10,20); GLfloat fLargest; glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &fLargest); ILuint ima[N_TEX]; ilInit(); ilGenImages(N_TEX,ima); glGenTextures(N_TEX,tex); int imagew,imageh; ilBindImage(ima[MADEIRA_TEX]); ilLoadImage((ILstring)"madeira_tex.jpg"); ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE); imagew=ilGetInteger(IL_IMAGE_WIDTH); imageh=ilGetInteger(IL_IMAGE_HEIGHT); imageData[MADEIRA_TEX]=ilGetData(); glBindTexture(GL_TEXTURE_2D,tex[MADEIRA_TEX]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, imagew, imageh, GL_RGBA, GL_UNSIGNED_BYTE, imageData[MADEIRA_TEX]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_BASE_LEVEL,0); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAX_LEVEL,10); ilBindImage(ima[TECIDO_SOFA_TEX]); ilLoadImage((ILstring)"tecido_sofa_tex.jpg"); ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE); imagew=ilGetInteger(IL_IMAGE_WIDTH); imageh=ilGetInteger(IL_IMAGE_HEIGHT); imageData[TECIDO_SOFA_TEX]=ilGetData(); glBindTexture(GL_TEXTURE_2D,tex[TECIDO_SOFA_TEX]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, imagew, imageh, GL_RGBA, GL_UNSIGNED_BYTE, imageData[TECIDO_SOFA_TEX]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_BASE_LEVEL,0); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAX_LEVEL,10); ilBindImage(ima[CHAO_TEX]); ilLoadImage((ILstring)"madeira_tex_alt.jpg"); ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE); imagew=ilGetInteger(IL_IMAGE_WIDTH); imageh=ilGetInteger(IL_IMAGE_HEIGHT); imageData[CHAO_TEX]=ilGetData(); glBindTexture(GL_TEXTURE_2D,tex[CHAO_TEX]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, imagew, imageh, GL_RGBA, GL_UNSIGNED_BYTE, imageData[CHAO_TEX]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_BASE_LEVEL,0); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAX_LEVEL,10); ilBindImage(ima[PAREDES_TEX]); ilLoadImage((ILstring)"parede_tex.jpg"); ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE); imagew=ilGetInteger(IL_IMAGE_WIDTH); imageh=ilGetInteger(IL_IMAGE_HEIGHT); imageData[PAREDES_TEX]=ilGetData(); glBindTexture(GL_TEXTURE_2D,tex[PAREDES_TEX]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, imagew, imageh, GL_RGBA, GL_UNSIGNED_BYTE, imageData[PAREDES_TEX]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_BASE_LEVEL,0); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAX_LEVEL,10); ilBindImage(ima[BALCAO_TAMPO_TEX]); ilLoadImage((ILstring)"balcao_tampo_tex.jpg"); ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE); imagew=ilGetInteger(IL_IMAGE_WIDTH); imageh=ilGetInteger(IL_IMAGE_HEIGHT); imageData[BALCAO_TAMPO_TEX]=ilGetData(); glBindTexture(GL_TEXTURE_2D,tex[BALCAO_TAMPO_TEX]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, imagew, imageh, GL_RGBA, GL_UNSIGNED_BYTE, imageData[BALCAO_TAMPO_TEX]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_BASE_LEVEL,0); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAX_LEVEL,10); ilBindImage(ima[BANCO_TAMPO_TEX]); ilLoadImage((ILstring)"banco_tampo_tex.png"); ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE); imagew=ilGetInteger(IL_IMAGE_WIDTH); imageh=ilGetInteger(IL_IMAGE_HEIGHT); imageData[BANCO_TAMPO_TEX]=ilGetData(); glBindTexture(GL_TEXTURE_2D,tex[BANCO_TAMPO_TEX]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, imagew, imageh, GL_RGBA, GL_UNSIGNED_BYTE, imageData[BANCO_TAMPO_TEX]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_BASE_LEVEL,0); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAX_LEVEL,10); ilBindImage(ima[PORTA_TEX]); ilLoadImage((ILstring)"porta_tex.jpg"); ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE); imagew=ilGetInteger(IL_IMAGE_WIDTH); imageh=ilGetInteger(IL_IMAGE_HEIGHT); imageData[PORTA_TEX]=ilGetData(); glBindTexture(GL_TEXTURE_2D,tex[PORTA_TEX]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, imagew, imageh, GL_RGBA, GL_UNSIGNED_BYTE, imageData[PORTA_TEX]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_BASE_LEVEL,0); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAX_LEVEL,10); //Create the shadow map texture glGenTextures(1, &shadowMapTexture); glBindTexture(GL_TEXTURE_2D, shadowMapTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); //Enable shadow comparison glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE); //Shadow comparison should be true (ie not in shadow) if r<=texture glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, shadowMapSize, shadowMapSize, 0,GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL); //Load identity modelview glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //Shading states glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glGenFramebuffers(1,&mFBO); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mFBO); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, shadowMapTexture, 0); glGenTextures(2, aaTexture); glBindTexture(GL_TEXTURE_2D, aaTexture[0]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, AA_LEVEL*wWidth, AA_LEVEL*wHeight, 0,GL_RGBA, GL_UNSIGNED_BYTE, NULL); glBindTexture(GL_TEXTURE_2D, aaTexture[1]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, AA_LEVEL*wWidth, AA_LEVEL*wHeight, 0,GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL); glGenFramebuffers(1,&aaFBO); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, aaFBO); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, aaTexture[0], 0); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D, aaTexture[1],0); glGenTextures(1, &aaAuxTexture); glBindTexture(GL_TEXTURE_2D, aaAuxTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, AA_LEVEL*wWidth/2, AA_LEVEL*wHeight/2, 0,GL_RGBA, GL_UNSIGNED_BYTE, NULL); glGenFramebuffers(1,&aaAuxFBO); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, aaAuxFBO); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, aaAuxTexture, 0); // Disable writes to the color buffer glDrawBuffer(GL_NONE); //Depth states glClearDepth(1.0f); glDepthFunc(GL_LEQUAL); //We use glScale when drawing the scene glEnable(GL_NORMALIZE); // alguns settings para OpenGL glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,0); }