FILE* PlumedMain::fopen(const char *path, const char *mode){ std::string mmode(mode); std::string ppath(path); std::string suffix(getSuffix()); std::string ppathsuf=ppath+suffix; FILE*fp=std::fopen(const_cast<char*>(ppathsuf.c_str()),const_cast<char*>(mmode.c_str())); if(!fp) fp=std::fopen(const_cast<char*>(ppath.c_str()),const_cast<char*>(mmode.c_str())); plumed_massert(fp,"file " + ppath + " cannot be found"); return fp; }
/* * Draw a volumetric rendering of the grid for timestep it and variable ip. * Input: it - timestep * ip - variable */ void draw_volume( Context ctx, int it, int ip, unsigned int *ctable ) { float *data; static int prev_it[VIS5D_MAX_CONTEXTS]; static int prev_ip[VIS5D_MAX_CONTEXTS]; static int do_once = 1; int dir; float x, y, z, ax, ay, az; MATRIX ctm, proj; Display_Context dtx; dtx = ctx->dpy_ctx; if (do_once){ int yo; for (yo=0; yo<VIS5D_MAX_CONTEXTS; yo++){ prev_it[yo] = -1; prev_ip[yo] = -1; } do_once = 0; } /* Get 3rd column values from transformation matrix */ #if defined (HAVE_SGI_GL) || defined (DENALI) /* Compute orientation of 3-D box with respect to current matrices */ /* with no assumptions about the location of the camera. This was */ /* done for the CAVE. */ mmode( MPROJECTION ); getmatrix( proj ); mmode( MVIEWING ); getmatrix( ctm ); #endif #if defined(HAVE_OPENGL) glGetFloatv( GL_PROJECTION_MATRIX, (GLfloat *) proj ); glGetFloatv( GL_MODELVIEW_MATRIX, (GLfloat *) ctm ); check_gl_error( "draw_volume" ); #endif /* compute third column values in the product of ctm*proj */ x = ctm[0][0]*proj[0][2] + ctm[0][1]*proj[1][2] + ctm[0][2]*proj[2][2] + ctm[0][3]*proj[3][2]; y = ctm[1][0]*proj[0][2] + ctm[1][1]*proj[1][2] + ctm[1][2]*proj[2][2] + ctm[1][3]*proj[3][2]; z = ctm[2][0]*proj[0][2] + ctm[2][1]*proj[1][2] + ctm[2][2]*proj[2][2] + ctm[2][3]*proj[3][2]; /* examine values to determine how to draw slices */ ax = ABS(x); ay = ABS(y); az = ABS(z); if (ax>=ay && ax>=az) { /* draw x-axis slices */ dir = (x<0.0) ? WEST_TO_EAST : EAST_TO_WEST; } else if (ay>=ax && ay>=az) { /* draw y-axis slices */ dir = (y<0.0) ? SOUTH_TO_NORTH : NORTH_TO_SOUTH; } else { /* draw z-axis slices */ dir = (z<0.0) ? BOTTOM_TO_TOP : TOP_TO_BOTTOM; } /* If this is a new time step or variable then invalidate old volumes */ if (it!=prev_it[ctx->context_index] || ip!=prev_ip[ctx->context_index]) { ctx->Volume->valid = 0; prev_it[ctx->context_index] = it; prev_ip[ctx->context_index] = ip; } /* Determine if we have to compute a set of slices for the direction. */ if (ctx->Volume->dir!=dir || ctx->Volume->valid==0) { data = get_grid( ctx, it, ip ); if (data) { if (ctx->GridSameAsGridPRIME){ compute_volume( ctx, data, it, ip, ctx->Nr, ctx->Nc, ctx->Nl[ip], ctx->Variable[ip]->LowLev, ctx->Variable[ip]->MinVal, ctx->Variable[ip]->MaxVal, dir, ctx->Volume ); } else{ compute_volumePRIME( ctx, data, it, ip, dtx->Nr, dtx->Nc, dtx->Nl, dtx->LowLev, ctx->Variable[ip]->MinVal, ctx->Variable[ip]->MaxVal, dir, ctx->Volume ); } release_grid( ctx, it, ip, data ); } } render_volume( ctx, ctx->Volume, ctable ); }
main() { float ship[XY]; long org[XY]; long size[XY]; Device dev; short val; Device mdev[XY]; short mval[XY]; long nhits; short buffer[BUFSIZE]; Boolean run; prefsize(400, 400); winopen("select1"); getorigin(&org[X], &org[Y]); getsize(&size[X], &size[Y]); mmode(MVIEWING); ortho2(-0.5, size[X] - 0.5, -0.5, size[Y] - 0.5); qdevice(LEFTMOUSE); qdevice(ESCKEY); color(BLACK); clear(); mdev[X] = MOUSEX; mdev[Y] = MOUSEY; drawplanet(); run = TRUE; while (run) { dev = qread(&val); if (val == 0) { /* on upstroke */ switch (dev) { case LEFTMOUSE: getdev(XY, mdev, mval); ship[X] = mval[X] - org[X]; ship[Y] = mval[Y] - org[Y]; color(BLUE); sbox(ship[X], ship[Y], ship[X] + SHIPWIDTH, ship[Y] + SHIPHEIGHT); /* * specify the selecting region to be a box surrounding the * rocket ship */ ortho2(ship[X], ship[X] + SHIPWIDTH, ship[Y], ship[Y] + SHIPHEIGHT); initnames(); gselect(buffer, BUFSIZE); loadname(PLANET); /* no actual drawing takes place */ drawplanet(); nhits = endselect(buffer); /* * restore the Projection matrix; NB. can't use push/popmatrix * since they only work for the ModelView matrix stack * when in MVIEWING mode */ ortho2(-0.5, size[X] - 0.5, -0.5, size[Y] - 0.5); /* * check to see if PLANET was selected; NB. nhits is NOT the * number of buffer elements written */ if (nhits < 0) { fprintf(stderr, "gselect buffer overflow\n"); run = FALSE; } else if (nhits >= 1 && buffer[0] == 1 && buffer[1] == PLANET) ringbell(); break; case ESCKEY: run = FALSE; break; } } } gexit(); return 0; }