~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to routines/graphics/FeC.c

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *    Graphic library
3
3
 *    Copyright (C) 1998-2001 Enpc/Jean-Philippe Chancelier
4
4
 *    jpc@cermics.enpc.fr 
 
5
 *
5
6
 *    modified by Bruno Pincon 01/02/2001 for gain in speed and added 
6
7
 *    possibilities to set zmin, zmax by the user and also to set the 
7
8
 *    first and last color of the colormap (Bruno.Pincon@iecn.u-nancy.fr)
 
9
 *
 
10
for entities handling
8
11
 --------------------------------------------------------------------------*/
9
12
 
10
13
#include <stdio.h>
11
14
#include <math.h>
12
15
#include <string.h>
13
 
#include "Math.h"
 
16
#include "Math.h" 
 
17
#include "Graphics.h"
 
18
#include "Entities.h" /* NG */
 
19
extern int version_flag(void); /* NG */
 
20
 
14
21
 
15
22
/* functions used by the modified version : */
16
23
static void PaintTriangle __PARAMS((double sx[], double sy[], double fxy[], 
20
27
static void FindIntersection __PARAMS((double sx[], double sy[], double fxy[],
21
28
                                       double z, int inda, int indb, 
22
29
                                       integer *xint, integer *yint));
 
30
void newfec __PARAMS((integer *xm,integer *ym,double *triangles,double *func,integer *Nnode,
 
31
                      integer *Ntr,double *zminmax,integer *colminmax));
 
32
extern void initsubwin();
 
33
/*extern void compute_data_bounds(int cflag,char dataflag,double *x,double *y,int n1,int n2,double *drect);*/
 
34
extern void compute_data_bounds2(int cflag,char dataflag,char *logflags,double *x,double *y,int n1,int n2,double *drect);
 
35
extern void update_specification_bounds(sciPointObj *psubwin, double *rect,int flag);
 
36
extern int re_index_brect(double * brect, double * drect);
 
37
extern void strflag2axes_properties(sciPointObj * psubwin, char * strflag);
 
38
 
 
39
void get_frame_in_pixel(integer WIRect[]);
23
40
 
24
41
/*------------------------------------------------------------
25
42
 *  Iso contour with grey level or colors 
44
61
 *  first and last color of the colormap (Bruno.Pincon@iecn.u-nancy.fr)
45
62
---------------------------------------------------------------*/
46
63
 
47
 
int C2F(fec)(x,y,triangles,func,Nnode,Ntr,strflag,legend,brect,aaint,zminmax, 
48
 
             colminmax, lstr1,lstr2)
49
 
     double x[],y[],triangles[],func[];
50
 
     integer *Nnode,*Ntr;
51
 
     double brect[], zminmax[];
52
 
     integer  aaint[], colminmax[];
53
 
     char legend[],strflag[];
54
 
     integer lstr1,lstr2;
55
 
 
 
64
int C2F(fec)(double *x, double *y, double *triangles, double *func, integer *Nnode, integer *Ntr, char *strflag, char *legend, double *brect, integer *aaint, double *zminmax, integer *colminmax, integer lstr1, integer lstr2)
56
65
{
57
 
  integer i, *xm,*ym,n1=1,j,k;
58
 
 
59
 
  /** Boundaries of the frame **/
60
 
  update_frame_bounds(0,"gnn",x,y,&n1,Nnode,aaint,strflag,brect);
61
 
 
62
 
  /* Storing values if using the Record driver */
63
 
  if (GetDriver()=='R') 
64
 
    /* added zminmax and colminmax (bruno) */
65
 
    StoreFec("fec_n",x,y,triangles,func,Nnode,Ntr,strflag,legend,brect,aaint,zminmax,colminmax);
66
 
 
67
 
 
68
 
  /** Allocation **/
69
 
  xm = graphic_alloc(0,*Nnode,sizeof(int));
70
 
  ym = graphic_alloc(1,*Nnode,sizeof(int));
71
 
  if ( xm == 0 || ym == 0) 
72
 
    {
73
 
      sciprint("Running out of memory \n");
74
 
      return 0;
75
 
    }      
76
 
  
77
 
  C2F(echelle2d)(x,y,xm,ym,Nnode,&n1,"f2i",3L);
78
 
 
79
 
  /** Draw Axis or only rectangle **/
80
 
  axis_draw(strflag);
 
66
  integer *xm,*ym,n1=1,i;
 
67
 
81
68
  /* Fec code */
 
69
 
 
70
  /* NG  beg */
 
71
   if (version_flag() == 0){
 
72
     long hdltab[2];
 
73
     int cmpt=0,styl[2];
 
74
     sciPointObj *pptabofpointobj;
 
75
     sciPointObj  *psubwin;
 
76
     double drect[6];
 
77
 
 
78
     if (!(sciGetGraphicMode (sciGetSelectedSubWin (sciGetCurrentFigure ())))->addplot) { 
 
79
       sciXbasc(); 
 
80
       initsubwin();
 
81
       sciRedrawFigure();
 
82
       psubwin = sciGetSelectedSubWin (sciGetCurrentFigure ());  /* F.Leray 25.02.04*/
 
83
     } 
 
84
     psubwin = sciGetSelectedSubWin (sciGetCurrentFigure ());
 
85
     
 
86
     /* Force psubwin->is3d to FALSE: we are in 2D mode */
 
87
     if (sciGetSurface(psubwin) == (sciPointObj *) NULL)
 
88
       {
 
89
         pSUBWIN_FEATURE (psubwin)->is3d = FALSE;
 
90
         pSUBWIN_FEATURE (psubwin)->project[2]= 0;
 
91
       }
 
92
     pSUBWIN_FEATURE (psubwin)->theta_kp=pSUBWIN_FEATURE (psubwin)->theta;
 
93
     pSUBWIN_FEATURE (psubwin)->alpha_kp=pSUBWIN_FEATURE (psubwin)->alpha;  
 
94
     pSUBWIN_FEATURE (psubwin)->alpha  = 0.0;
 
95
     pSUBWIN_FEATURE (psubwin)->theta  = 270.0;
 
96
          
 
97
     /* Force psubwin->axes.aaint to those given by argument aaint*/
 
98
     for (i=0;i<4;i++) pSUBWIN_FEATURE(psubwin)->axes.aaint[i] = aaint[i];
 
99
 
 
100
     /* Force "cligrf" clipping */
 
101
     sciSetIsClipping (psubwin,0); 
 
102
 
 
103
     /* Force  axes_visible property */
 
104
     /* pSUBWIN_FEATURE (psubwin)->isaxes  = TRUE;*/
 
105
 
 
106
     if (sciGetGraphicMode (psubwin)->autoscaling) {
 
107
       /* compute and merge new specified bounds with psubwin->Srect */
 
108
       switch (strflag[1])  {
 
109
       case '0': 
 
110
         /* do not change psubwin->Srect */
 
111
         break;
 
112
       case '1' : case '3' : case '5' : case '7':
 
113
         /* Force psubwin->Srect=brect */
 
114
         re_index_brect(brect, drect);
 
115
         break;
 
116
       case '2' : case '4' : case '6' : case '8':case '9':
 
117
         /* Force psubwin->Srect to the x and y bounds */
 
118
         /* compute_data_bounds(0,'g',x,y,n1,*Nnode,drect); */
 
119
         compute_data_bounds2(0,'g',pSUBWIN_FEATURE(psubwin)->logflags,x,y,n1,*Nnode,drect);
 
120
         break;
 
121
       }
 
122
       if (!pSUBWIN_FEATURE(psubwin)->FirstPlot &&
 
123
           (strflag[1] == '7' || strflag[1] == '8' || strflag[1] == '9')) { /* merge psubwin->Srect and drect */
 
124
         drect[0] = Min(pSUBWIN_FEATURE(psubwin)->SRect[0],drect[0]); /*xmin*/
 
125
         drect[2] = Min(pSUBWIN_FEATURE(psubwin)->SRect[2],drect[2]); /*ymin*/
 
126
         drect[1] = Max(pSUBWIN_FEATURE(psubwin)->SRect[1],drect[1]); /*xmax*/
 
127
         drect[3] = Max(pSUBWIN_FEATURE(psubwin)->SRect[3],drect[3]); /*ymax*/
 
128
       }
 
129
       if (strflag[1] != '0') update_specification_bounds(psubwin, drect,2);
 
130
 
 
131
     } 
 
132
     strflag2axes_properties(psubwin, strflag);
 
133
 
 
134
     sciDrawObj(sciGetSelectedSubWin (sciGetCurrentFigure ()));/* ???? */
 
135
     
 
136
     sciSetCurrentObj (ConstructFec 
 
137
                       ((sciPointObj *)
 
138
                        sciGetSelectedSubWin (sciGetCurrentFigure ()),
 
139
                        x,y,triangles,func,*Nnode,*Ntr,zminmax,colminmax)); 
 
140
     pptabofpointobj = sciGetCurrentObj();
 
141
     hdltab[cmpt]=sciGetHandle(pptabofpointobj);   
 
142
     cmpt++;   
 
143
     sciDrawObj(sciGetCurrentObj ());  
 
144
     /** Drawing the Legends **/
 
145
     if ((int)strlen(strflag) >=1  && strflag[0] == '1'){
 
146
       n1=1; styl[0]=1;styl[1]=0;
 
147
       sciSetCurrentObj (ConstructLegend
 
148
                         ((sciPointObj *) sciGetSelectedSubWin (sciGetCurrentFigure ()),
 
149
                          legend, strlen(legend), n1, styl, &pptabofpointobj)); 
 
150
       sciSetIsMark(pptabofpointobj, TRUE);
 
151
       sciSetMarkStyle (pptabofpointobj, *styl);
 
152
       sciDrawObj(sciGetCurrentObj ()); 
 
153
       hdltab[cmpt]=sciGetHandle(sciGetCurrentObj ()); 
 
154
       cmpt++;
 
155
     } 
 
156
     sciSetCurrentObj(ConstructAgregation (hdltab, cmpt));  /** construct agregation **/
 
157
   }
 
158
   else { /* NG end */
 
159
     /** Boundaries of the frame **/
 
160
     update_frame_bounds(0,"gnn",x,y,&n1,Nnode,aaint,strflag,brect);
 
161
 
 
162
     /* Storing values if using the Record driver */
 
163
     if ((GetDriver()=='R') && (version_flag() != 0)) /* NG */
 
164
       /* added zminmax and colminmax (bruno) */
 
165
       StoreFec("fec_n",x,y,triangles,func,Nnode,Ntr,strflag,legend,brect,aaint,zminmax,colminmax);
 
166
 
 
167
     /** Allocation **/
 
168
     xm = graphic_alloc(0,*Nnode,sizeof(int));
 
169
     ym = graphic_alloc(1,*Nnode,sizeof(int));
 
170
     if ( xm == 0 || ym == 0) {
 
171
       sciprint("Running out of memory \n"); return 0;}      
 
172
  
 
173
     C2F(echelle2d)(x,y,xm,ym,Nnode,&n1,"f2i",3L);
 
174
 
 
175
     newfec(xm,ym,triangles,func,Nnode,Ntr,zminmax,colminmax);
 
176
     axis_draw(strflag); 
 
177
 
 
178
     /** Drawing the Legends **/
 
179
     if ((int)strlen(strflag) >=1  && strflag[0] == '1')
 
180
       {
 
181
         integer styl[2] = {-1,0}; 
 
182
         n1=1;
 
183
         Legends(styl,&n1,legend);
 
184
       }        
 
185
   } /** version_flag ***/
 
186
   
 
187
   return(0);
 
188
   
 
189
}
 
190
 
 
191
void newfec(integer *xm,integer *ym,double *triangles,double *func,integer *Nnode,integer *Ntr,double *zminmax,integer *colminmax)
 
192
{
 
193
  /*************************************
 
194
   *     code modified by Bruno 01/02/2001  
 
195
   *************************************/
 
196
    
 
197
  integer nz,i,j,k;
 
198
  integer verbose=0,whiteid,narg;
 
199
    
 
200
  double *zlevel, dz, zmin, zmax, fxy[3], sx[3], sy[3];
 
201
  int *zone, *fill, kp, perm[3], zxy[3], color_min;
 
202
  integer ii[3];
 
203
 
 
204
  /* pour le pre-cliping */
 
205
  integer WIRect[4];
 
206
  double Fxmin, Fxmax, Fymin, Fymax;
 
207
 
 
208
  /* choice between zmin and zmax given by the user or computed
 
209
   *   with the min and max z values. In matdes.c I have put 
 
210
   * zminmax[0]= zminmax[1]=0 if the user don't give this argument 
 
211
   */
 
212
 
82
213
  frame_clip_on();
83
 
  {
84
 
    /********************************************************************
85
 
     *   beginning of the code modified by Bruno 01/02/2001  
86
 
     ********************************************************************/
87
 
    
88
 
    integer nz;
89
 
    integer verbose=0,whiteid,narg;
90
 
    
91
 
    double *zlevel, dz, zmin, zmax, fxy[3], sx[3], sy[3];
92
 
    int *zone, *fill, kp, perm[3], zxy[3], color_min;
93
 
    integer ii[3];
94
 
 
95
 
    /* choice between zmin and zmax given by the user or computed
96
 
     *   with the min and max z values. In matdes.c I have put 
97
 
     * zminmax[0]= zminmax[1]=0 if the user don't give this argument 
98
 
     */
99
 
 
100
 
    if ( zminmax[0]==zminmax[1] ) { 
101
 
      zmin=(double) Mini(func,*Nnode); 
102
 
      zmax=(double) Maxi(func,*Nnode);
103
 
    } 
104
 
    else {
105
 
      zmin = Min( zminmax[0] , zminmax[1] );
106
 
      zmax = Max( zminmax[0] , zminmax[1] );
107
 
    };
108
 
      
109
 
    C2F(dr)("xget","lastpattern",&verbose,&whiteid,&narg,
110
 
            PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
111
 
    nz=whiteid;
112
 
    
113
 
    /* choice for the colormap (in case of a user 's choice 
114
 
     *   verify the parameter). For the automatic choice I have
115
 
     * put colminmax[0]=colominmax[1]=1 in matdes.c  
116
 
     */
117
 
 
118
 
    if ( colminmax[0] == colminmax[1] )  /* automatic choice (see matdes.c) */
119
 
      color_min=1; 
120
 
    else if ( colminmax[0] < 1 || colminmax[1] > nz || colminmax[0] > colminmax[1] ) {
121
 
      /* ici on pourrait plutot forcer les choses en imposant 1<= colmin < colmax <= nz */
122
 
      sciprint("\n\r fec : colminmax badly choosen ! ");
123
 
      return ( 0 );
124
 
    } 
125
 
    else {
126
 
      color_min = colminmax[0];
127
 
      nz = colminmax[1] - colminmax[0] + 1;
128
 
    };
129
 
      
130
 
    /* 
131
 
     *  1/ the purpose of the first part is to to compute the "zone" of each point :
132
 
     *    
133
 
     *    - the array zlevel are the boundaries between the differents zones :
134
 
     *
135
 
     *        zlevel[0] = zmin, zlevel[nz] = zmax 
136
 
     *     and zlevel[i] = zmin + i*(zmax-zmin)/nz
137
 
     *  
138
 
     *     - if  zlevel[j-1] <= func[i] < zlevel[j]  then zone[i] = j
139
 
     *       if func[i] > zmax  then zone[i] = nz+1
140
 
     *       if func[i] < zmin  then zone[i] = 0
141
 
     *     - the zone j is filled with color fill[j] with
142
 
     *       fill[j] = -(j-1 + color_min) if 1 <= j <= nz
143
 
     *       fill[0] = color attributed for fill[1]     ---> this behavior may be changed ...
144
 
     *       fill[nz+1] = color attributed for fill[nz] --/
145
 
     */
 
214
  if ( zminmax[0]==zminmax[1] ) {  
 
215
    zmin=(double) Mini(func,*Nnode); 
 
216
    zmax=(double) Maxi(func,*Nnode);
 
217
  } 
 
218
  else {
 
219
    zmin = Min( zminmax[0] , zminmax[1] );
 
220
    zmax = Max( zminmax[0] , zminmax[1] );
 
221
  };
 
222
  
 
223
  C2F(dr)("xget","lastpattern",&verbose,&whiteid,&narg,
 
224
          PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
 
225
  nz=whiteid;
 
226
    
 
227
  /* choice for the colormap (in case of a user 's choice 
 
228
   *   verify the parameter). For the automatic choice I have
 
229
   * put colminmax[0]=colominmax[1]=1 in matdes.c  
 
230
   */
 
231
 
 
232
  if ( colminmax[0] == colminmax[1] )  /* automatic choice (see matdes.c) */
 
233
    color_min=1; 
 
234
  else if ( colminmax[0] < 1 || colminmax[1] > nz || colminmax[0] > colminmax[1] ) {
 
235
    /* ici on pourrait plutot forcer les choses en imposant 1<= colmin < colmax <= nz */
 
236
    sciprint("\n\r fec : colminmax badly choosen ! ");
 
237
    return;
 
238
  } 
 
239
  else {
 
240
    color_min = colminmax[0];
 
241
    nz = colminmax[1] - colminmax[0] + 1;
 
242
  };
 
243
      
 
244
  /* 
 
245
   *  1/ the purpose of the first part is to to compute the "zone" of each point :
 
246
   *    
 
247
   *    - the array zlevel are the boundaries between the differents zones :
 
248
   *
 
249
   *        zlevel[0] = zmin, zlevel[nz] = zmax 
 
250
   *     and zlevel[i] = zmin + i*(zmax-zmin)/nz
 
251
   *  
 
252
   *     - if  zlevel[j-1] <= func[i] < zlevel[j]  then zone[i] = j
 
253
   *       if func[i] > zmax  then zone[i] = nz+1
 
254
   *       if func[i] < zmin  then zone[i] = 0
 
255
   *     - the zone j is filled with color fill[j] with
 
256
   *       fill[j] = -(j-1 + color_min) if 1 <= j <= nz
 
257
   *       fill[0] = color attributed for fill[1]     ---> this behavior may be changed ...
 
258
   *       fill[nz+1] = color attributed for fill[nz] --/
 
259
   */
146
260
 
147
 
    /* allocations for some arrays ... */
148
 
 
149
 
    zone = graphic_alloc(2,(*Nnode),sizeof(int));
150
 
    zlevel = graphic_alloc(3,nz+1,sizeof(double));
151
 
    fill  = graphic_alloc(4,nz+2,sizeof(int));
152
 
    if ( (zone == NULL) || (zlevel == NULL) || (fill  == NULL)) 
153
 
      {
154
 
        Scistring("fec: malloc No more Place\n");
155
 
        return;
156
 
      }
157
 
    /* compute the fill array (fill = - num color) */
158
 
    fill[1] = - color_min;
159
 
    for ( i = 2 ; i <= nz ; i++ ) fill[i] = fill[i-1] - 1;
160
 
    fill[0] = fill[1] ; fill[nz+1] = fill[nz];
161
 
 
162
 
    /* compute the zlevels */
163
 
    dz = (zmax - zmin)/nz;
164
 
    for (i = 0 ; i < nz ; i++) zlevel[i] = zmin + i*dz;
165
 
    zlevel[nz] = zmax;
166
 
 
167
 
    /* finaly compute the zone of each point */
168
 
    for ( i = 0 ; i < (*Nnode) ; i++ ) {
169
 
      if ( func[i] > zmax )
170
 
        zone[i] = nz+1;
171
 
      else if ( func[i] < zmin )
172
 
        zone[i] = 0;
173
 
      else
174
 
        zone[i] = floor( (func[i] - zmin)/dz ) + 1;
 
261
  /* allocations for some arrays ... */
 
262
 
 
263
  zone = graphic_alloc(2,(*Nnode),sizeof(int));
 
264
  zlevel = graphic_alloc(3,nz+1,sizeof(double));
 
265
  fill  = graphic_alloc(4,nz+2,sizeof(int));
 
266
  if ( (zone == NULL) || (zlevel == NULL) || (fill  == NULL)) 
 
267
    {
 
268
      Scistring("fec: malloc No more Place\n");
 
269
      return;
 
270
    }
 
271
  /* compute the fill array (fill = - num color) */
 
272
  fill[1] = - color_min;
 
273
  for ( i = 2 ; i <= nz ; i++ ) fill[i] = fill[i-1] - 1;
 
274
  fill[0] = fill[1] ; fill[nz+1] = fill[nz];
 
275
 
 
276
  /* compute the zlevels */
 
277
  dz = (zmax - zmin)/nz;
 
278
  for (i = 0 ; i < nz ; i++) zlevel[i] = zmin + i*dz;
 
279
  zlevel[nz] = zmax;
 
280
 
 
281
  /* finaly compute the zone of each point */
 
282
  for ( i = 0 ; i < (*Nnode) ; i++ ) {
 
283
    if ( func[i] > zmax )
 
284
      zone[i] = nz+1;
 
285
    else if ( func[i] < zmin )
 
286
      zone[i] = 0;
 
287
    else
 
288
      zone[i] = (int) (floor( (func[i] - zmin)/dz ) + 1);
 
289
  };
 
290
  /* 
 
291
     2/ loop of the triangles : each triangle is finally decomposed 
 
292
     into its differents zones (polygons) by the function PaintTriangle   
 
293
  */
 
294
 
 
295
  get_frame_in_pixel(WIRect);
 
296
  Fxmin = (double) WIRect[0];  Fymin = (double) WIRect[1];
 
297
  Fxmax = (double) WIRect[2];  Fymax = (double) WIRect[3];
 
298
 
 
299
  for ( j = 0 ; j < *Ntr ; j++) {
 
300
    double xmin, xmax, ymin, ymax;
 
301
    /* retrieve node numbers and functions values */
 
302
    for ( k = 0 ; k < 3 ; k++ ) {
 
303
      ii[k] = (integer) triangles[j+(*Ntr)*(k+1)] - 1;      
 
304
      zxy[k] = zone[ii[k]];  
 
305
    }
 
306
 
 
307
    /* get the permutation perm so as zxy[perm] is sorted */
 
308
    PermutOfSort(zxy, perm); 
 
309
 
 
310
    /* apply the permutation to get the triangle 's vertices
 
311
       in increasing zone (zxy[0] <= zxy[1] <= zxy[2]) */
 
312
    for ( k = 0 ; k < 3 ; k++ ) {
 
313
      kp = perm[k];
 
314
      sx[k]  = xm[ii[kp]];   sy[k]  = ym[ii[kp]];
 
315
      fxy[k] = func[ii[kp]]; zxy[k] = zone[ii[kp]];
175
316
    };
176
 
    /* 
177
 
       2/ loop of the triangles : each triangle is finally decomposed 
178
 
          into its differents zones (polygons) by the function PaintTriangle   
179
 
    */
180
 
    for ( j = 0 ; j < *Ntr ; j++) {
181
 
 
182
 
      /* retrieve node numbers and functions values */
183
 
      for ( k = 0 ; k < 3 ; k++ ) {
184
 
        ii[k] = (integer) triangles[j+(*Ntr)*(k+1)] - 1;
185
 
        zxy[k] = zone[ii[k]];
186
 
      }
187
 
 
188
 
      /* get the permutation perm so as zxy[perm] is sorted */
189
 
      PermutOfSort(zxy, perm); 
190
 
 
191
 
      /* apply the permutation to get the triangle 's vertices
192
 
         in increasing zone (zxy[0] <= zxy[1] <= zxy[2]) */
193
 
      for ( k = 0 ; k < 3 ; k++ ) {
194
 
        kp = perm[k];
195
 
        sx[k]  = xm[ii[kp]];   sy[k]  = ym[ii[kp]];
196
 
        fxy[k] = func[ii[kp]]; zxy[k] = zone[ii[kp]];
197
 
      };
198
 
 
 
317
 
 
318
  /* essai de pre-clipping tous les triangles en dehors de la zone
 
319
     d'affichage ne seront pas trait�s */
 
320
    xmin = xmax = sx[0]; ymin = ymax = sy[0];
 
321
    if ( sx[1] < sx[2] ) 
 
322
      { 
 
323
        xmin = Min(xmin,sx[1]); xmax = Max(xmax,sx[2]);
 
324
      } 
 
325
    else 
 
326
      {
 
327
        xmin = Min(xmin,sx[2]); xmax = Max(xmax,sx[1]);
 
328
      }
 
329
    if ( sy[1] < sy[2] )
 
330
      { 
 
331
        ymin = Min(ymin,sy[1]); ymax = Max(ymax,sy[2]);
 
332
      }
 
333
    else
 
334
      {
 
335
        ymin = Min(ymin,sy[2]); ymax = Max(ymax,sy[1]);
 
336
      }
 
337
 
 
338
    if ( xmax > Fxmin  &&  ymax > Fymin  &&  xmin < Fxmax  &&  ymin < Fymax )  
199
339
      /* call the "painting" function */
200
340
      PaintTriangle(sx, sy, fxy, zxy, zlevel, fill);
201
 
 
202
 
    };
203
341
  }
204
 
 
205
 
  /********************************************************************
206
 
   *                     end of the modified code
207
 
   ********************************************************************/
208
 
 
209
342
  frame_clip_off();
210
 
  /** Drawing the Legends **/
211
 
  if ((int)strlen(strflag) >=1  && strflag[0] == '1')
212
 
    {
213
 
      integer style = -1;
214
 
      n1=1;
215
 
      Legends(&style,&n1,legend);
216
 
    }
217
 
  return(0);
218
343
}
219
344
 
 
345
 
220
346
/********************************************************************
221
347
 * functions used by the modified code (Bruno 01/02/2001)
222
348
 ********************************************************************/
223
349
 
224
 
static void PermutOfSort (tab,perm) 
225
 
     int tab[]; int perm[];
 
350
static void PermutOfSort (int *tab, int *perm)
226
351
{
227
352
  /* 
228
353
   * get the permutation perm[3] which sort the array tab[3] in increasing order 
242
367
}
243
368
 
244
369
 
245
 
static void PaintTriangle (sx,sy,fxy,zxy,zlevel,fill)
246
 
     double sx[]; double sy[]; double fxy[]; int zxy[]; 
247
 
     double zlevel[]; int fill[];
 
370
static void PaintTriangle (double *sx, double *sy, double *fxy, int *zxy, double *zlevel, int *fill)
248
371
{
249
372
  /* 
250
373
     arguments :
358
481
          PI0,PD0,PD0,PD0,PD0,0L,0L);
359
482
}
360
483
 
361
 
static void FindIntersection(sx,sy,fxy,z,inda,indb,xint,yint)
362
 
     double sx[]; double sy[]; double fxy[]; double z;
363
 
     int inda; int indb; integer *xint; integer *yint;
 
484
static void FindIntersection(double *sx, double *sy, double *fxy, double z, 
 
485
                             int inda, int indb, integer *xint, integer *yint)
364
486
{
365
487
  double alpha;
366
488
  alpha = (z - fxy[inda])/(fxy[indb] - fxy[inda]);
376
498
 
377
499
 
378
500
 
 
501