bbox2.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 static char const Id[] = "$Id: bbox2.c 2962 2010-02-04 19:50:44Z scholz $\n\n";
00025 static char const Td[] = "$Today: " __FILE__ " " __DATE__ " " __TIME__ " $\n\n";
00026
00027 #include "util.h"
00028
00029 int bbox2(GridData *gdata,PetscReal *vertxyz2,int n_prop,int *propid,PetscReal *bbox,int *pix)
00030 {
00031 MagparFunctionLogBegin;
00032
00033 ierr = calcbbox(gdata->ln_ele,gdata->elevert,gdata->eleprop,vertxyz2,n_prop,propid,bbox);
00034
00035
00036 PetscReal maxedge=0;
00037 for (int i=0;i<ND-1;i++) {
00038 maxedge=PetscMax(maxedge,bbox[ND+i]-bbox[i]);
00039 }
00040
00041 int res;
00042 res=pix[0];
00043
00044
00045 for (int i=0;i<ND;i++) {
00046 bbox[i] -= 1.0*maxedge/(res-2);
00047 bbox[ND+i] += 1.0*maxedge/(res-2);
00048 }
00049
00050
00051 for (int i=0;i<ND;i++) {
00052 bbox[i] += 0.1*maxedge/(res-2);
00053 bbox[ND+i] += 0.1*maxedge/(res-2);
00054 }
00055
00056 maxedge = maxedge*res/(res-2);
00057
00058 PetscPrintf(PETSC_COMM_WORLD,
00059 "enlarged bbox: (%g,%g,%g) (%g,%g,%g) (%g,%g,%g)\nmaxedge: %g\n",
00060 bbox[0],bbox[1],bbox[2],bbox[ND+0],bbox[ND+1],bbox[ND+2],
00061 bbox[ND+0]-bbox[0],bbox[ND+1]-bbox[1],bbox[ND+2]-bbox[2],
00062 maxedge
00063 );
00064
00065
00066 if (pix!=PETSC_NULL) {
00067 for (int i=0;i<ND;i++) {
00068 pix[i]=(int) ceil(res*(bbox[ND+i]-bbox[i])/maxedge);
00069 }
00070
00071 PetscPrintf(PETSC_COMM_WORLD,
00072 "pixels: %i x %i x %i\n",
00073 pix[0],pix[1],pix[2]
00074 );
00075 PetscPrintf(PETSC_COMM_WORLD,
00076 "pixellength: %g x %g x %g = %g * (%g x %g x %g)\n",
00077 (bbox[ND+0]-bbox[0])/pix[0],
00078 (bbox[ND+1]-bbox[1])/pix[1],
00079 (bbox[ND+2]-bbox[2])/pix[2],
00080 (bbox[ND+0]-bbox[0])/pix[0],
00081 1.0,
00082 (bbox[ND+1]-bbox[1])/pix[1]/((bbox[ND+0]-bbox[0])/pix[0]),
00083 (bbox[ND+2]-bbox[2])/pix[2]/((bbox[ND+0]-bbox[0])/pix[0])
00084 );
00085 }
00086
00087 MagparFunctionLogReturn(0);
00088 }
00089