44
61
* first and last color of the colormap (Bruno.Pincon@iecn.u-nancy.fr)
45
62
---------------------------------------------------------------*/
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[];
51
double brect[], zminmax[];
52
integer aaint[], colminmax[];
53
char legend[],strflag[];
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)
57
integer i, *xm,*ym,n1=1,j,k;
59
/** Boundaries of the frame **/
60
update_frame_bounds(0,"gnn",x,y,&n1,Nnode,aaint,strflag,brect);
62
/* Storing values if using the Record driver */
64
/* added zminmax and colminmax (bruno) */
65
StoreFec("fec_n",x,y,triangles,func,Nnode,Ntr,strflag,legend,brect,aaint,zminmax,colminmax);
69
xm = graphic_alloc(0,*Nnode,sizeof(int));
70
ym = graphic_alloc(1,*Nnode,sizeof(int));
71
if ( xm == 0 || ym == 0)
73
sciprint("Running out of memory \n");
77
C2F(echelle2d)(x,y,xm,ym,Nnode,&n1,"f2i",3L);
79
/** Draw Axis or only rectangle **/
66
integer *xm,*ym,n1=1,i;
71
if (version_flag() == 0){
74
sciPointObj *pptabofpointobj;
78
if (!(sciGetGraphicMode (sciGetSelectedSubWin (sciGetCurrentFigure ())))->addplot) {
82
psubwin = sciGetSelectedSubWin (sciGetCurrentFigure ()); /* F.Leray 25.02.04*/
84
psubwin = sciGetSelectedSubWin (sciGetCurrentFigure ());
86
/* Force psubwin->is3d to FALSE: we are in 2D mode */
87
if (sciGetSurface(psubwin) == (sciPointObj *) NULL)
89
pSUBWIN_FEATURE (psubwin)->is3d = FALSE;
90
pSUBWIN_FEATURE (psubwin)->project[2]= 0;
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;
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];
100
/* Force "cligrf" clipping */
101
sciSetIsClipping (psubwin,0);
103
/* Force axes_visible property */
104
/* pSUBWIN_FEATURE (psubwin)->isaxes = TRUE;*/
106
if (sciGetGraphicMode (psubwin)->autoscaling) {
107
/* compute and merge new specified bounds with psubwin->Srect */
108
switch (strflag[1]) {
110
/* do not change psubwin->Srect */
112
case '1' : case '3' : case '5' : case '7':
113
/* Force psubwin->Srect=brect */
114
re_index_brect(brect, drect);
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);
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*/
129
if (strflag[1] != '0') update_specification_bounds(psubwin, drect,2);
132
strflag2axes_properties(psubwin, strflag);
134
sciDrawObj(sciGetSelectedSubWin (sciGetCurrentFigure ()));/* ???? */
136
sciSetCurrentObj (ConstructFec
138
sciGetSelectedSubWin (sciGetCurrentFigure ()),
139
x,y,triangles,func,*Nnode,*Ntr,zminmax,colminmax));
140
pptabofpointobj = sciGetCurrentObj();
141
hdltab[cmpt]=sciGetHandle(pptabofpointobj);
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 ());
156
sciSetCurrentObj(ConstructAgregation (hdltab, cmpt)); /** construct agregation **/
159
/** Boundaries of the frame **/
160
update_frame_bounds(0,"gnn",x,y,&n1,Nnode,aaint,strflag,brect);
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);
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;}
173
C2F(echelle2d)(x,y,xm,ym,Nnode,&n1,"f2i",3L);
175
newfec(xm,ym,triangles,func,Nnode,Ntr,zminmax,colminmax);
178
/** Drawing the Legends **/
179
if ((int)strlen(strflag) >=1 && strflag[0] == '1')
181
integer styl[2] = {-1,0};
183
Legends(styl,&n1,legend);
185
} /** version_flag ***/
191
void newfec(integer *xm,integer *ym,double *triangles,double *func,integer *Nnode,integer *Ntr,double *zminmax,integer *colminmax)
193
/*************************************
194
* code modified by Bruno 01/02/2001
195
*************************************/
198
integer verbose=0,whiteid,narg;
200
double *zlevel, dz, zmin, zmax, fxy[3], sx[3], sy[3];
201
int *zone, *fill, kp, perm[3], zxy[3], color_min;
204
/* pour le pre-cliping */
206
double Fxmin, Fxmax, Fymin, Fymax;
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
84
/********************************************************************
85
* beginning of the code modified by Bruno 01/02/2001
86
********************************************************************/
89
integer verbose=0,whiteid,narg;
91
double *zlevel, dz, zmin, zmax, fxy[3], sx[3], sy[3];
92
int *zone, *fill, kp, perm[3], zxy[3], color_min;
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
100
if ( zminmax[0]==zminmax[1] ) {
101
zmin=(double) Mini(func,*Nnode);
102
zmax=(double) Maxi(func,*Nnode);
105
zmin = Min( zminmax[0] , zminmax[1] );
106
zmax = Max( zminmax[0] , zminmax[1] );
109
C2F(dr)("xget","lastpattern",&verbose,&whiteid,&narg,
110
PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
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
118
if ( colminmax[0] == colminmax[1] ) /* automatic choice (see matdes.c) */
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 ! ");
126
color_min = colminmax[0];
127
nz = colminmax[1] - colminmax[0] + 1;
131
* 1/ the purpose of the first part is to to compute the "zone" of each point :
133
* - the array zlevel are the boundaries between the differents zones :
135
* zlevel[0] = zmin, zlevel[nz] = zmax
136
* and zlevel[i] = zmin + i*(zmax-zmin)/nz
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] --/
214
if ( zminmax[0]==zminmax[1] ) {
215
zmin=(double) Mini(func,*Nnode);
216
zmax=(double) Maxi(func,*Nnode);
219
zmin = Min( zminmax[0] , zminmax[1] );
220
zmax = Max( zminmax[0] , zminmax[1] );
223
C2F(dr)("xget","lastpattern",&verbose,&whiteid,&narg,
224
PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L);
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
232
if ( colminmax[0] == colminmax[1] ) /* automatic choice (see matdes.c) */
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 ! ");
240
color_min = colminmax[0];
241
nz = colminmax[1] - colminmax[0] + 1;
245
* 1/ the purpose of the first part is to to compute the "zone" of each point :
247
* - the array zlevel are the boundaries between the differents zones :
249
* zlevel[0] = zmin, zlevel[nz] = zmax
250
* and zlevel[i] = zmin + i*(zmax-zmin)/nz
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] --/
147
/* allocations for some arrays ... */
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))
154
Scistring("fec: malloc No more Place\n");
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];
162
/* compute the zlevels */
163
dz = (zmax - zmin)/nz;
164
for (i = 0 ; i < nz ; i++) zlevel[i] = zmin + i*dz;
167
/* finaly compute the zone of each point */
168
for ( i = 0 ; i < (*Nnode) ; i++ ) {
169
if ( func[i] > zmax )
171
else if ( func[i] < zmin )
174
zone[i] = floor( (func[i] - zmin)/dz ) + 1;
261
/* allocations for some arrays ... */
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))
268
Scistring("fec: malloc No more Place\n");
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];
276
/* compute the zlevels */
277
dz = (zmax - zmin)/nz;
278
for (i = 0 ; i < nz ; i++) zlevel[i] = zmin + i*dz;
281
/* finaly compute the zone of each point */
282
for ( i = 0 ; i < (*Nnode) ; i++ ) {
283
if ( func[i] > zmax )
285
else if ( func[i] < zmin )
288
zone[i] = (int) (floor( (func[i] - zmin)/dz ) + 1);
291
2/ loop of the triangles : each triangle is finally decomposed
292
into its differents zones (polygons) by the function PaintTriangle
295
get_frame_in_pixel(WIRect);
296
Fxmin = (double) WIRect[0]; Fymin = (double) WIRect[1];
297
Fxmax = (double) WIRect[2]; Fymax = (double) WIRect[3];
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]];
307
/* get the permutation perm so as zxy[perm] is sorted */
308
PermutOfSort(zxy, perm);
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++ ) {
314
sx[k] = xm[ii[kp]]; sy[k] = ym[ii[kp]];
315
fxy[k] = func[ii[kp]]; zxy[k] = zone[ii[kp]];
177
2/ loop of the triangles : each triangle is finally decomposed
178
into its differents zones (polygons) by the function PaintTriangle
180
for ( j = 0 ; j < *Ntr ; j++) {
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]];
188
/* get the permutation perm so as zxy[perm] is sorted */
189
PermutOfSort(zxy, perm);
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++ ) {
195
sx[k] = xm[ii[kp]]; sy[k] = ym[ii[kp]];
196
fxy[k] = func[ii[kp]]; zxy[k] = zone[ii[kp]];
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];
323
xmin = Min(xmin,sx[1]); xmax = Max(xmax,sx[2]);
327
xmin = Min(xmin,sx[2]); xmax = Max(xmax,sx[1]);
331
ymin = Min(ymin,sy[1]); ymax = Max(ymax,sy[2]);
335
ymin = Min(ymin,sy[2]); ymax = Max(ymax,sy[1]);
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);
205
/********************************************************************
206
* end of the modified code
207
********************************************************************/
209
342
frame_clip_off();
210
/** Drawing the Legends **/
211
if ((int)strlen(strflag) >=1 && strflag[0] == '1')
215
Legends(&style,&n1,legend);
220
346
/********************************************************************
221
347
* functions used by the modified code (Bruno 01/02/2001)
222
348
********************************************************************/
224
static void PermutOfSort (tab,perm)
225
int tab[]; int perm[];
350
static void PermutOfSort (int *tab, int *perm)
228
353
* get the permutation perm[3] which sort the array tab[3] in increasing order