Example #1
0
static void do_pgcon_bs (double *blank, int *nc_sign)
{
   unsigned int idim, jdim;
   float *a;
   int i_1, i_2, j_1, j_2;
   SLang_Array_Type *tr, *c, *at;

   at = NULL;

   if (-1 == pop_tr_vector (&tr))
     return;

   if (-1 == pop_float_vector (&c))
     goto return_error;

   if (-1 == pop_4_ints (&j_1, &j_2, &i_1, &i_2))
     goto return_error;

   if (NULL == (at = pop_2d_float_array (&a, &jdim, &idim)))
     goto return_error;

   /* Convert to FORTRAN indexing */
   i_1++; j_1++; i_2++; j_2++;

   if (blank != NULL)
     cpgconb (a, idim, jdim, i_1, i_2, j_1, j_2,
              (float *)c->data, c->num_elements,
              (float *)tr->data, *blank);
   else if (nc_sign != NULL)
     cpgcont (a, idim, jdim, i_1, i_2, j_1, j_2,
              (float *)c->data, *nc_sign * (int)c->num_elements,
              (float *)tr->data);
   else
     cpgcons (a, idim, jdim, i_1, i_2, j_1, j_2,
              (float *)c->data, c->num_elements,
              (float *)tr->data);

return_error:

   free_arrays (tr, c, at, NULL);
}
Example #2
0
static PyObject *
genContours_s (enum pp_contour_funcs ft, PyObject *args)
{
    PyObject *oa=NULL, *oc=NULL;
    PyArrayObject *aa=NULL, *ac=NULL;
    float *a = NULL, *c = NULL, tr[6],
		x1=0.0,y1=0.0,x2=0.0,y2=0.0,blank=0.0,
		mn = 0.0, mx = 0.0;
    int rd=0, cd=0, csz=0, nc=0, ncont=0;

    if (!PyArg_ParseTuple(args,"Oi|Offfff:contour_s",
						  &oa,&nc,&oc,&x1,&y1,&x2,&y2,&blank))
		return(NULL);

    if (abs(nc)<1) {
		PyErr_SetString(PpgTYPEErr,"_ppgplot.error: Number of contours is 0");
		return(NULL);
    }
    if (!(aa = (PyArrayObject *)tofloatmat(oa, &a, &rd, &cd)))
		goto fail;
    if (oc) {
		if (!(ac = (PyArrayObject *)tofloatvector(oc, &c, &csz)))
			goto fail;
    } else {
		if (!(c = malloc(abs(nc)*sizeof(*c)))) {
			PyErr_SetString(PpgTYPEErr,"_ppgplot.error: Out of mem!");
			goto fail;
		}
		ncont = abs(nc);
    }

    /* Perform autocalibrations as nesecairy. */
    autocal2d(a, rd, cd, &mx, &mn, ncont, c, &x1, &x2, &y1, &y2, tr);

#ifdef DEBUG_CONT_S
    {
		int i;
		fprintf(stderr,"ncontours = %d = %d\n",nc,ncont);
		fprintf(stderr,"Contours:\n");
		for (i=0; i<abs(nc); i++)
			fprintf(stderr,"   cont[%d] = %f\n",i,c[i]);
		fprintf(stderr,"blank = %f\n",blank);
    }
#endif


    switch (ft) {
    case FUN_PGCONB:
		cpgconb(a,cd,rd,0+1,cd,0+1,rd,c,nc,tr,blank);
		break;
    case FUN_PGCONS:
		cpgcons(a,cd,rd,0+1,cd,0+1,rd,c,nc,tr);
		break;
    case FUN_PGCONT:
		cpgcont(a,cd,rd,0+1,cd,0+1,rd,c,nc,tr);
		break;
    default:
		assert(0);
		break;
    }

    Py_DECREF(aa);
    if (ac)
		Py_DECREF(ac);
    else if (c)
		free(c);
    PYRN;

fail:
    if (aa) { Py_DECREF(aa); }
    if (ac) { 
		Py_DECREF(ac);
    } else if (c) {
		free(c);
	}

    return(NULL);
}
Example #3
0
static PyObject *
genContours (enum pp_contour_funcs ft, PyObject *args)
{
    PyObject
		*oa=NULL, *oc=NULL, *otr=NULL;
    PyArrayObject 
		*aa=NULL, *ac=NULL, *atr=NULL;
    float *a=NULL, *c=NULL, *tr=NULL, blank=0.0;
    int cd=0 ,rd=0,
		c1=0,c2=0,r1=0,r2=0, 
		csz=0, trsz=0,
		nc=0;

    if (!PyArg_ParseTuple(args,"OiiiiiiOiO|f:contour",
						  &oa, &cd, &rd, &c1, &c2, &r1, &r2,
						  &oc, &nc, &otr, &blank))
		return(NULL);
    
    if (!(aa = (PyArrayObject *)tofloatmat(oa, &a, &rd, &cd)))
		goto fail;
    if (!(ac = (PyArrayObject *)tofloatvector(oc, &c, &csz)))
		goto fail;
    if (!(atr = (PyArrayObject *)tofloatvector(otr, &tr, &trsz)))
		goto fail;

    if (abs(nc) > csz) {
		PyErr_SetString(PpgTYPEErr,"contour: size of cont vec < than the "
						"req. contours number");
		goto fail;
    }
    if (trsz < 6) {
		PyErr_SetString(PpgTYPEErr,"contour: invalid transform. vector");
		goto fail;
    }

    switch (ft) {
    case FUN_PGCONB:
		cpgconb(a,cd,rd,c1+1,c2+1,r1+1,r2+1,c,nc,tr,blank);
		break;
    case FUN_PGCONS:
		cpgcons(a,cd,rd,c1+1,c2+1,r1+1,r2+1,c,nc,tr);
		break;
    case FUN_PGCONT:
		cpgcont(a,cd,rd,c1+1,c2+1,r1+1,r2+1,c,nc,tr);
		break;
    default:
		assert(0);
		break;
    }

    Py_DECREF(aa);
    Py_DECREF(ac);
    Py_DECREF(atr);
    PYRN;

fail:
    if (aa) { Py_DECREF(aa); }
    if (ac) { Py_DECREF(ac); }
    if (atr) { Py_DECREF(atr); }
    return(NULL);
}