static int contourI(ptr_level_f func, double *x, double *y, double *z, double *zCont, int *N, int *style, int *err) { int check = 1; char *F = NULL; int n1 = 0, n2 = 0, ncont = 0, i = 0, c = 0, j = 0, k = 0, n5 = 0; int stylec = 0; n1 = N[0]; n2 = N[1]; ncont = N[2]; F = getFPF(); if ( F[0] == '\0') { ChoixFormatE1(ContNumFormat, zCont, N[2]); } InitValues(x, y, z, n1, n2); n5 = 2 * (n1) + 2 * (n2) - 3; /* Allocation */ Gcont_size = 0; /** initialize the array indices for storing contours **/ xbd_cont = MALLOC( n5 * sizeof(int) ) ; ybd_cont = MALLOC( n5 * sizeof(int) ) ; itg_cont = MALLOC( n1 * n2 * sizeof(int) ) ; if ( (xbd_cont == NULL) && n5 != 0) { check = 0; } if ( (ybd_cont == NULL) && n5 != 0) { check = 0; } if ( (itg_cont == NULL) && n1 * n2 != 0) { check = 0; } if ( check == 0) { FREE( xbd_cont ) ; FREE( ybd_cont ) ; FREE( itg_cont ) ; Scierror(999, _("%s: No more memory.\n"), "contourI"); return -1; } /* just a parametrization of the boundary points */ for ( i = 0 ; i < n2 ; i++) { ybd_cont[i] = i ; xbd_cont[i] = 0 ; } for ( i = 1 ; i < n1 ; i++) { ybd_cont[n2 + i - 1] = n2 - 1 ; xbd_cont[n2 + i - 1] = i ; } for ( i = n2 - 2; i >= 0 ; i--) { ybd_cont[2 * n2 + n1 - 3 - i] = i ; xbd_cont[2 * n2 + n1 - 3 - i] = n1 - 1 ; } for ( i = n1 - 2 ; i >= 0 ; i--) { ybd_cont[2 * n2 + 2 * n1 - 4 - i] = 0 ; xbd_cont[2 * n2 + 2 * n1 - 4 - i] = i ; } for ( c = 0 ; c < ncont ; c++) { stylec = ( style != (int *) 0) ? style[c] : c; /** itg-cont is a flag array to memorize checked parts of the grid **/ for ( i = 0 ; i < n1; i++) for ( j = 0 ; j < n2 ; j++) { itg_cont[i + n1 * j] = 0 ; } /** all the boundary segments **/ for ( k = 1 ; k < n5 ; k++) { int ib, jb; i = xbd_cont[k] ; j = ybd_cont[k]; ib = xbd_cont[k - 1] ; jb = ybd_cont[k - 1]; if (not_same_sign (phi_cont(i, j) - zCont[c] , phi_cont(ib, jb) - zCont[c])) { look(func, i, j, ib, jb, 1L, zCont[c], stylec); } } /** inside segments **/ for ( i = 1 ; i < n1 - 1; i++) for ( j = 1 ; j < n2 - 1 ; j++) if (not_same_sign ( phi_cont(i, j) - zCont[c] , phi_cont(i, j - 1) - zCont[c])) { look(func, i, j, i, j - 1, 2L, zCont[c], stylec); } } FREE( xbd_cont ) ; FREE( ybd_cont ) ; FREE( itg_cont ) ; return 0; }
/* * This function has been adapted to the MVC framework (property get calls) * in order to be able to provide a valid format string when computing * default labels for the Axis object. The algorithm is left untouched. * Its code ought to be put within the Java part of the Model. */ int ComputeC_format(int iObjUID, char * c_format) { int i = 0, j = 0; int pos = 0; int* piPos = &pos; int xy_type = 0; int* piXy_type = &xy_type; int nx = 0; int* piNx = &nx; int ny = 0; int* piNy = &ny; double *x = NULL; double *y = NULL; double* tmpx = NULL; double* tmpy = NULL; int iType = -1; int *piType = &iType; int xpassed = 0, ypassed = 0, Nx = 0, Ny = 0, x3, y3; int parentAxesID; int * piParentAxesID = &parentAxesID; int logFlag = 0; int* piLogFlag = &logFlag; getGraphicObjectProperty(iObjUID, __GO_TYPE__, jni_int, (void **)&piType); if (iType != __GO_AXIS__) { Scierror(999, _("Error: ComputeFormat must be used with AXIS objects\n")); return -1; } getGraphicObjectProperty(iObjUID, __GO_PARENT_AXES__, jni_int, (void **)&piParentAxesID); getGraphicObjectProperty(iObjUID, __GO_TICKS_DIRECTION__, jni_int, (void **)&piPos); getGraphicObjectProperty(iObjUID, __GO_TICKS_STYLE__, jni_int, (void **)&piXy_type); getGraphicObjectProperty(iObjUID, __GO_X_NUMBER_TICKS__, jni_int, (void **)&piNx); getGraphicObjectProperty(iObjUID, __GO_Y_NUMBER_TICKS__, jni_int, (void **)&piNy); /* Allocating space before re-copying values to not pollute the good values that will be used inside Axes.c */ if ((x = MALLOC(nx * sizeof(double))) == NULL) { Scierror(999, _("%s: No more memory.\n"), "ComputeC_format"); return -1; } if ((y = MALLOC(ny * sizeof(double))) == NULL) { Scierror(999, _("%s: No more memory.\n"), "ComputeC_format"); FREE(x); return -1; } getGraphicObjectProperty(iObjUID, __GO_X_TICKS_COORDS__, jni_double_vector, (void **)&tmpx); getGraphicObjectProperty(iObjUID, __GO_Y_TICKS_COORDS__, jni_double_vector, (void **)&tmpy); for (i = 0; i < nx; i++) { x[i] = tmpx[i]; } for (i = 0; i < ny; i++) { y[i] = tmpy[i]; } /* Algo. here */ if (xy_type == 2) { if (pos == 0 || pos == 1) { getGraphicObjectProperty(iObjUID, __GO_X_AXIS_LOG_FLAG__, jni_int, (void **)&piLogFlag); if (logFlag == 0) { while (x[3] > 10) { x[3] = floor(x[3] / 2); } } else { if (x[3] > 12) { /* F.Leray arbitrary value=12 for the moment */ x3 = (int)x[3]; /* if x[3]>12 algo is triggered to search a divisor */ for (j = x3 - 1; j > 1; j--) { if (x3 % j == 0) { x[3] = j; xpassed = 1; } } if (xpassed != 1) { x[3] = 1; } } } } else if (pos == 2 || pos == 3) { getGraphicObjectProperty(iObjUID, __GO_Y_AXIS_LOG_FLAG__, jni_int, (void **)&piLogFlag); if (logFlag == 0) { while (y[3] > 10) { y[3] = floor(y[3] / 2); } } else { if (y[3] > 12) { y3 = (int)y[3]; for (j = y3 - 1; j > 1; j--) { if (y3 % j == 0) { y[3] = j; ypassed = 1; } } if (ypassed != 1) { y[3] = 1; } } } } } /** Real to Pixel values **/ if (xy_type == 0) { Nx = nx; Ny = ny; } else if (xy_type == 1) { if (pos == 0 || pos == 1) { Nx = (int) x[2] + 1; } else if (pos == 2 || pos == 3) { Ny = (int) y[2] + 1; } } else if (xy_type == 2) { if (pos == 0 || pos == 1) { Nx = (int) x[3] + 1; } else if (pos == 2 || pos == 3) { Ny = (int) y[3] + 1; } } else { Scierror(999, _("%s: Wrong type argument %s.\n"), "Sci_Axis", "xy_type"); FREE(x); x = NULL; FREE(y); y = NULL; return -1; } if (pos == 0 || pos == 1) { /** Horizontal axes **/ /** compute a format **/ if (xy_type == 0) { ChoixFormatE1(c_format, x, Nx); } else if (xy_type == 1) { ChoixFormatE (c_format, x[0], x[1], (x[1] - x[0]) / x[2]); } else if (xy_type == 2) { ChoixFormatE (c_format, (x[0] * exp10(x[2])), (x[1] * exp10(x[2])), ((x[1] * exp10(x[2])) - (x[0] * exp10(x[2]))) / x[3]); /* Adding F.Leray 06.05.04 */ } /** the horizontal segment **/ } else if (pos == 2 || pos == 3) { /** Vertical axes **/ if (xy_type == 0) { ChoixFormatE1(c_format, y, Ny); } else if (xy_type == 1) { ChoixFormatE(c_format, y[0], y[1], (y[1] - y[0]) / y[2]); } else if (xy_type == 2) { ChoixFormatE (c_format, (y[0] * exp10(y[2])), (y[1] * exp10(y[2])), ((y[1] * exp10(y[2])) - (y[0] * exp10(y[2]))) / y[3]); /* Adding F.Leray 06.05.04 */ } /** the vertical segment **/ } /* c_format should be filled now */ FREE(x); x = NULL; FREE(y); y = NULL; return 0; }