// We are out of the right zone // Nous sommes en dehors de la partition void Root::out_of_the_zone(int const & p_ray, int &black_ray, bool &black_ray_buff, vector<int> &vect_rays, vector<int> &vect_rays_op, Vect<float> &v) { if (!mat_frame.PIXEL_COLOR_RED_VECT(v)) { mat_frame_draw->PIXEL_COLOR_GREEN_VECT(v) = 255; ++black_ray; // the ray(j) is turning more heavy // le rayon(j) devient plus lours vect_rays.at(p_ray) += 1; } else draw_rays(p_ray, black_ray_buff, vect_rays_op, v); }
void display(void){ glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glPushMatrix(); // --- Positioning the cam on azimuthal installation glRotatef(cam.elevation, 1.0, 0.0, 0.0); glRotatef(cam.azimut, 0.0, 1.0, 0.0); glTranslatef(-cam.pos.x, -cam.pos.y, -cam.pos.z); glRotatef(-90, 1.0, 0.0, 0.0); // --- Axes glPushMatrix(); glScalef(1.0, 1.0, 1.0); draw_reference_frame(); glPopMatrix(); // --- Draw plane if(!mesh_loaded) { glColor3f (1.0, 1.0, 0.0); draw_plane(10,10); } else draw_model(); // --- Draw tx antennas for(size_t i = 0; i < txs.size(); i++) draw_tx(txs[i]); // --- Draw rx antennas for(size_t i = 0; i < rxs.size(); i++) draw_rx(rxs[i]); draw_rays(); glPopMatrix(); glutSwapBuffers(); }
static int draw_ball_1 (ModeInfo *mi) { ball_configuration *bp = &bps[MI_SCREEN(mi)]; int wire = MI_IS_WIREFRAME(mi); int polys = 0; tile *t; GLfloat m[4][4]; glGetFloatv (GL_MODELVIEW_MATRIX, &m[0][0]); glFrontFace (GL_CW); #if 0 /* Draw the back rays. */ if (! wire) { glPushMatrix(); glLoadIdentity(); glMultMatrixf (&m[0][0]); glTranslatef(0, 0, -4.1); glRotatef (bp->th, 0, 0, 1); polys += draw_rays (mi); glPopMatrix(); } glClear(GL_DEPTH_BUFFER_BIT); #endif /* Instead of rendering polygons for the foam ball substrate, let's just billboard a quad down the middle to mask out the back-facing tiles. */ { glPushMatrix(); m[0][0] = 1; m[1][0] = 0; m[2][0] = 0; m[0][1] = 0; m[1][1] = 1; m[2][1] = 0; m[0][2] = 0; m[1][2] = 0; m[2][2] = 1; glLoadIdentity(); glMultMatrixf (&m[0][0]); glScalef (40, 40, 40); glTranslatef (-0.5, -0.5, -0.01); if (! wire) glDisable (GL_LIGHTING); /* Draw into the depth buffer but not the frame buffer */ glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glColor3f (0, 0, 0); glBegin (GL_QUADS); glVertex3f (0, 0, 0); glVertex3f (0, 1, 0); glVertex3f (1, 1, 0); glVertex3f (1, 0, 0); glEnd(); polys++; glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); if (! wire) glEnable (GL_LIGHTING); glPopMatrix(); glColor3f (1, 1, 1); } /* Draw all the tiles. */ for (t = bp->tiles; t; t = t->next) { GLfloat x = t->normal.x; GLfloat y = t->normal.y; GLfloat z = t->normal.z; GLfloat s = t->size / 2; glPushMatrix(); /* Move to location of tile. */ glTranslatef (t->position.x, t->position.y, t->position.z); /* Orient to direction tile is facing. */ glRotatef (-atan2 (x, y) * (180 / M_PI), 0, 0, 1); glRotatef ( atan2 (z, sqrt(x*x + y*y)) * (180 / M_PI), 1, 0, 0); glRotatef (t->tilt, 0, 1, 0); glScalef (s, s, s); glNormal3f (0, 1, 0); glBegin (wire ? GL_LINE_LOOP : GL_QUADS); glVertex3f (-1, 0, -1); glVertex3f ( 1, 0, -1); glVertex3f ( 1, 0, 1); glVertex3f (-1, 0, 1); glEnd(); polys++; if (! wire) { GLfloat d = 0.2; glNormal3f (0, 0, -1); glBegin (wire ? GL_LINE_LOOP : GL_QUADS); glVertex3f (-1, 0, -1); glVertex3f (-1, -d, -1); glVertex3f ( 1, -d, -1); glVertex3f ( 1, 0, -1); glEnd(); polys++; glNormal3f (0, 0, 1); glBegin (wire ? GL_LINE_LOOP : GL_QUADS); glVertex3f ( 1, 0, 1); glVertex3f ( 1, -d, 1); glVertex3f (-1, -d, 1); glVertex3f (-1, 0, 1); glEnd(); polys++; glNormal3f (1, 0, 0); glBegin (wire ? GL_LINE_LOOP : GL_QUADS); glVertex3f ( 1, 0, -1); glVertex3f ( 1, -d, -1); glVertex3f ( 1, -d, 1); glVertex3f ( 1, 0, 1); glEnd(); polys++; glNormal3f (-1, 0, 0); glBegin (wire ? GL_LINE_LOOP : GL_QUADS); glVertex3f (-1, 0, 1); glVertex3f (-1, -d, 1); glVertex3f (-1, -d, -1); glVertex3f (-1, 0, -1); glEnd(); polys++; } glPopMatrix(); } /* Draw the front rays. */ if (! wire) { glPushMatrix(); glLoadIdentity(); glMultMatrixf (&m[0][0]); glTranslatef(0, 0, 4.1); glRotatef (-bp->th, 0, 0, 1); polys += draw_rays (mi); glPopMatrix(); } return polys; }
int main(int argc, char* argv[]) { int nang, N; float dx, dz; int nx, nz; float ox, oz; int gnx, gnz; float gdx, gdz, gox, goz; struct point length; int inter; float TETAMAX, alpha2; FILE *outfile; int ii; int rays, wfront, gap; int lomx, first; int nr, nrmax, nt; int prcube, pr, ste; int ns, nou; float DSmax, dt, T, freq; float *vel; float ds, os, goox; float xmin, xmax, zmin, zmax; float depth; struct point *pos; struct heptagon *cube; struct grid *out; sf_file inp, ampl, time; sf_init(argc,argv); inp = sf_input("in"); /* GET MODEL PARAMETERS */ if (!sf_histint(inp,"n1",&nz)) sf_error("No n1= in input"); if (!sf_histint(inp,"n2",&nx)) sf_error("No n2= in input"); if (!sf_histfloat(inp,"d1",&dz)) sf_error("No d1= in input"); if (!sf_histfloat(inp,"d2",&dx)) sf_error("No d2= in input"); if (!sf_histfloat(inp,"o1",&oz)) sf_error("No o1= in input"); if (!sf_histfloat(inp,"o2",&ox)) sf_error("No o2= in input"); /* GET TRACING PARAMETERS */ if(!sf_getint("nang",&nang)) nang = 10; /* Number of take-off angles */ if(!sf_getint("rays",&rays)) rays = 0; /* If draw rays */ if(!sf_getint("wfront",&wfront)) wfront = 0; /* If draw wavefronts */ if(!sf_getint("gap",&gap)) gap = 1; /* Draw wavefronts every gap intervals */ if(!sf_getint("inter",&inter)) inter = 1; /* If use linear interpolation */ if(!sf_getfloat("DSmax",&DSmax)) DSmax = 5; /* Maximum distance between contiguos points of a wavefront */ if(!sf_getfloat("dt",&dt)) dt = 0.0005; /* time step */ if(!sf_getint("nt",&nt)) nt = 5; /* Number of time steps between wavefronts */ if(!sf_getint("nrmax",&nrmax)) nrmax = 2000; /* Maximum number of points that define a wavefront */ if(!sf_getint("lomx",&lomx)) lomx = 1; /* Use Lomax's waveray method */ if(!sf_getint("first",&first)) first = 1; /* Obtain first arrivals only */ if(!sf_getint("nou",&nou)) nou = 6; /* GET GRIDDING PARAMETERS */ if(!sf_getint("gnx",&gnx)) gnx = nx; /* Coordinates of output grid */ if(!sf_getint("gnz",&gnz)) gnz = nz; if(!sf_getfloat("gdx",&gdx)) gdx = dx; if(!sf_getfloat("gdz",&gdz)) gdz = dz; if(!sf_getfloat("gox",&goox)) goox = ox; if(!sf_getfloat("goz",&goz)) goz = oz; /* GET LOMAX SPECIFIC PARAMETERS */ if(!sf_getint("N",&N)) N = 3; /* Number of control points */ if(!sf_getfloat("TETAMAX",&TETAMAX)) TETAMAX = 1.5; /* Truncation parameter */ if(!sf_getfloat("alpha2",&alpha2)) alpha2 = 4.0; /* Width of gaussian weighting function */ if(!sf_getfloat("freq",&freq)) freq = 100.; /* Pseudo-frequency of waverays */ /* GET DEBUGGING INFO */ if(!sf_getint("prcube",&prcube)) prcube=0; /* For debugging porpouses */ if(!sf_getint("pr",&pr)) pr=0; /* For debugging porpouses */ /* GET SOURCE LOCATIONS */ if(!sf_getint("ns",&ns) || ns==0) ns=1; /* Number of source locations */ if(!sf_getfloat("ds",&ds)) ds=1.; /* interval between sources */ if(!sf_getfloat("os",&os)) os=0.; /* first source location */ if(!sf_getfloat("depth",&depth)) depth=dz; /* Depth location of sources */ pos = (struct point *) sf_alloc (ns,sizeof(struct point)); for(ii=0;ii<ns;ii++) { pos[ii] = makepoint(ii*ds + os, depth); } /* PREPARE OUTPUT */ ampl = sf_output("ampl"); sf_putint(ampl,"n1",gnz); sf_putint(ampl,"n2",gnx); sf_putint(ampl,"n3",ns); sf_putfloat(ampl,"d1",gdz); sf_putfloat(ampl,"d2",gdx); sf_putfloat(ampl,"d3",ds); sf_putfloat(ampl,"o1",goz); sf_putfloat(ampl,"o2",goox); sf_putfloat(ampl,"o3",os); time = sf_output("time"); sf_putint(time,"n1",gnz); sf_putint(time,"n2",gnx); sf_putint(time,"n3",ns); sf_putfloat(time,"d1",gdz); sf_putfloat(time,"d2",gdx); sf_putfloat(time,"d3",ds); sf_putfloat(time,"o1",goz); sf_putfloat(time,"o2",goox); sf_putfloat(time,"o3",os); /* READ VELOCITY MODEL */ vel = sf_floatalloc(nx*nz+2); sf_floatread(vel,nx*nz,inp); /* ALLOCATE MEMORY FOR OUTPUT */ out = (struct grid *) sf_alloc (1,sizeof(struct grid)); out->time = sf_floatalloc (gnx*gnz); out->ampl = sf_floatalloc (gnx*gnz); out->flag = sf_intalloc (gnx*gnz); T = 1. / freq; length = makepoint((nx-1)*dx,(nz-1)*dz); cube = (struct heptagon *) sf_alloc (nrmax,sizeof(struct heptagon)); /* FOR DEBUGGING PORPOUSES, PRINT TO FILE */ if(pr||prcube) { outfile = fopen("junk","w"); } else { outfile = NULL; } /* SET DISPLAY IN ORDER TO SHOW RAYS ON SCREEN */ /* NOTE: THIS PROGRAM USES DIRECT CALLS TO LIB_VPLOT * TO DRAW THE RAYS AND THE WAVEFRONTS */ if(rays || wfront) { setgraphics(ox, oz, length.x, length.z); /* vp_color(BLUE); for(ii=0;ii<gnx;ii++) { vp_umove(ii*gdx+gox, goz); vp_udraw(ii*gdx+gox, (gnz-1)*gdz+goz); } for(ii=0;ii<gnz;ii++) { vp_umove(gox, ii*gdz+goz); vp_udraw((gnx-1)*gdx+gox, ii*gdz+goz); } */ } norsar_init(gnx,gnz, TETAMAX,N,alpha2,inter, nx,nz,ox,oz,dx,dz,length); /* ALGORITHM: * For every source: */ for(ii=0;ii<ns;ii++) { ste = 0; gox = goox + pos[ii].x; sf_warning("\nSource #%d\n", ii); /* 1.- Construct the inital wavefront */ nr = nang; initial (pos[ii], cube, vel, dt, nt, T, lomx, nr, out); gridding_init(gnx,gnz, gdx,gdz,gox,goz, outfile); /* run while the wavefront is not too small */ while (nr > 4) { ste++; /* 2.- Propagate wavefront */ wavefront (cube, nr, vel, dt, nt, T, lomx); if(prcube || pr) { fprintf(outfile,"\n\nwavefront"); printcube(cube, nr, outfile); } /* 3.- Get rid of caustics */ if(first) { if(ste%2==1) { caustics_up (cube, 0, nr); } else { caustics_down (cube, nr-1, nr); } if(prcube || pr) { fprintf(outfile,"\n\ncaustics"); printcube(cube, nr, outfile); } } /* 4.- Eliminate rays that cross boundaries, defined by xmin, xmax, zmin, zmax. Note that the computational grid is a little bigger than the ouput grid. */ xmin = gox-nou*gdx; xmax = 2*pos[ii].x-gox+nou*gdx; zmin = oz-nou*gdz; zmax = length.z+oz+nou*gdz; mark_pts_outofbounds (cube, nr, xmin, xmax, zmin, zmax); if(prcube) { fprintf(outfile, "\n\nboundaries"); printcube(cube, nr, outfile); } /* 5.- Rearrange cube */ makeup(cube, &nr); if(nr<4) break; if(prcube || pr) { fprintf(outfile, "\n\nmakeup"); printcube(cube, nr, outfile); } /* 6.- Calculate amplitudes for new wavefront */ amplitudes (cube, nr); if(prcube) { fprintf(outfile, "\n\namplitudes"); printcube(cube, nr, outfile); } /* 7.- Draw rays */ if(rays) draw_rays (cube, nr); /* 8.- Draw wavefront */ if(wfront && (ste%gap==0)) draw_wavefronts (cube, nr, DSmax); /* 9.- Parameter estimation at receivers */ gridding (cube, nr, out, DSmax, (ste-1)*nt*dt, vel, first); /* pos[ii]); */ /* 10.- Interpolate new points of wavefront */ interpolation (cube, &nr, nrmax, DSmax); /* 0); */ if(prcube) { fprintf(outfile,"\n\ninterpolation"); printcube(cube, nr, outfile); } /* 11.- Prepare to trace new wavefront */ movwavf (cube, nr); if(prcube) { fprintf(outfile,"\n\nmovwavf"); printcube(cube, nr, outfile); } if((wfront || rays) && (ste%gap==0)) vp_erase(); } /* Finally interpolate amplitude and traveltime values to receivers that has not being covered. */ TwoD_interp (out, gnx, gnz); sf_floatwrite(out->time, gnx * gnz, time); sf_floatwrite(out->ampl, gnx * gnz, ampl); } if(pr||prcube) fclose(outfile); exit(0); }