bool AGILECountsT::WritePhotonList(string outfile) { ofstream mapText(outfile.c_str(), std::ofstream::app); streamsize prec = mapText.precision(); for(long i=0; i< evtfilter->time.size(); i++) { mapText.setf(ios::fixed); mapText << setprecision(5) << evtfilter->time[i]; mapText.unsetf(ios::floatfield); mapText.unsetf(ios::fixed); mapText <<" "<< setprecision(prec) <<" "<< evtfilter->ra[i] <<" "<< evtfilter->dec[i] <<" "<< (int) evtfilter->theta[i] <<" "; mapText << (int) evtfilter->energy[i] <<" "<< (int) evtfilter->ph_earth[i] <<" "<< (int) evtfilter->evstatus[i] << endl; } mapText.close(); }
void processNode(Object* object){ //Transformacoes glPushMatrix(); glMultMatrixf(object->m_object); //Material if(object->material->id == "null"){ if(materials.empty()) cout << "Erro! Não há materiais na stack!" << endl; else{ Material* mat = materials.top(); mat->setMaterial(); } } else{ object->material->setMaterial(); materials.push(object->material); } if(object->type == "simple"){ //Desenhar os poligonos Simple* simple = (Simple*)object; //Texturas if(object->texture->id != "null") textures.push(object->texture); if((object->texture->id != "clear") && (textures.top()->id != "clear")){ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, textures.top()->number); } //Triangulo if(simple->polygon->type == "triangle"){ Triangle* triangle = (Triangle*)simple->polygon; float* n = newell(triangle); float length_A = sqrt((triangle->x2-triangle->x1)*(triangle->x2-triangle->x1) + (triangle->y2-triangle->y1)*(triangle->y2-triangle->y1) + (triangle->z2-triangle->z1)*(triangle->z2-triangle->z1)); float length_B = sqrt((triangle->x3-triangle->x1)*(triangle->x3-triangle->x1) + (triangle->y3-triangle->y1)*(triangle->y3-triangle->y1) + (triangle->z3-triangle->z1)*(triangle->z3-triangle->z1)); float length_N = sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]); double height = length_N / length_A; double width = sqrt(length_B*length_B - height*height); glBegin(GL_POLYGON); glNormal3f(n[0],n[1],n[2]); glTexCoord2d(triangle->x1/textures.top()->length_s, triangle->y1/textures.top()->length_t); glVertex3d(triangle->x1, triangle->y1, triangle->z1); glTexCoord2d((triangle->x1 + length_A)/textures.top()->length_s, triangle->y1/textures.top()->length_t); glVertex3d(triangle->x2, triangle->y2, triangle->z2); glTexCoord2d((triangle->x1 + width)/textures.top()->length_s, (triangle->y1 + height)/textures.top()->length_t);glVertex3d(triangle->x3, triangle->y3, triangle->z3); glEnd(); } //Rectangulo if(simple->polygon->type == "rectangle"){ Rectangle* rect = (Rectangle*)simple->polygon; float s = mapText(rect->x1, rect->x2, textures.top()->length_s); float t = mapText(rect->y1, rect->y2, textures.top()->length_t); glBegin(GL_POLYGON); glNormal3d(0.0,0.0,1.0); glTexCoord2f(0.0,0.0);glVertex2d(rect->x1, rect->y1); glTexCoord2f(s ,0.0);glVertex2d(rect->x2, rect->y1); glTexCoord2f(s ,t );glVertex2d(rect->x2, rect->y2); glTexCoord2f(0.0,t );glVertex2d(rect->x1, rect->y2); glEnd(); } if(simple->polygon->type == "cylinder"){ Cylinder* cyl = (Cylinder*)simple->polygon; gluCylinder(glQ, cyl->base, cyl->top, cyl->height, cyl->slices, cyl->stacks); } if(simple->polygon->type == "sphere"){ Sphere* sphere = (Sphere*)simple->polygon; gluSphere(glQ, sphere->radius, sphere->slices, sphere->stacks); } if(simple->polygon->type == "disk"){ Disk* disk = (Disk*)simple->polygon; gluDisk(glQ, disk->inner, disk->outer, disk->slices, disk->loops); } glDisable(GL_TEXTURE_2D); }else if(object->type == "compound"){ if(object->texture->id != "null"){ textures.push(object->texture); } Compound* compound = (Compound*)object; vector<Object*>::iterator it = compound->childrenObj.begin(); for( ; it != compound->childrenObj.end(); it++){ processNode(*it); } } if(object->material->id != "null") materials.pop(); if(object->texture->id != "null") textures.pop(); glPopMatrix(); }