Mapper
contour_isoh.c
Go to the documentation of this file.
1 
2 #include "prototypes.h"
3 
4 void contour_isoh(Pixmap pixm,int h, int display_flag)
5 
6 {
7 
8 extern int isom;
9 extern Font font[10];
10 extern Display *display;
11 extern int npoint[2],zoom;
12 extern GC gc;
13 extern unsigned long imap[16];
14 extern Widget drawing_area;
15 extern struct display_set display_set[4];
16 extern struct isoh *isoh;
17 int i,j,k,m,l;
18 int color,MY=10;
19 float xrat,yrat,mult,dmult,cmult;
20 long nx[4],ny[4];
21 Dimension width,height;
22 Arg args[10];
23 unsigned long XSIZE,YSIZE;
24 XPoint point[5];
26 signed long xcen,ycen;
27 int di[5],dj[5],dy,dx,pnum,kk,mm;
28 float value[5];
29 float x[5],y[5],xx[5],yy[5];
30 int line_style,cap_style,join_style;
31 unsigned line_width;
32 int xint,yint,dup_flag[5];
33 int telim;
34 int maxtop,mintop;
35 extern int iscale;
36 float fm;
37 
38 if(iscale==0)
39  fm=.5;
40 else
41  fm=pow(2,(double)(iscale-1));
42 
43 fm=fm*25.3;
44 
45 dx=1;dy=1;
46 
47 di[0]=0;dj[0]=0;
48 di[1]=1;dj[1]=0;
49 di[2]=1;dj[2]=1;
50 di[3]=0;dj[3]=1;
51 di[4]=0;dj[4]=0;
52 
53 XSetFont(display,gc,font[0]);
54 
62 
63 XtSetArg(args[0],XtNwidth,&width);
64 XtSetArg(args[1],XtNheight,&height);
65 XtGetValues(drawing_area,args,2);
66 
67 XSIZE=(long)width*10L;
68 YSIZE=(long)height*10L;
69 
70 xrat=(float)XSIZE/(float)12800;
71 yrat=(float)YSIZE/(float)9600;
72 
73 if(xrat < yrat)
74  mult=xrat;
75 
76 else
77  mult=yrat;
78 
80 lint1=(long)npoint[0]*(long)MY;
81 lint2=(long)npoint[1]*(long)MY;
82 
83 line_width=0;
84 line_style=LineSolid;
85 cap_style=CapButt;
86 join_style=JoinMiter;
87 
88 XSetLineAttributes(display,gc,line_width,line_style,cap_style,join_style);
89 
90 for(i=0;i<isoh->maxi-1;i++) {
91 
92 for(j=0;j<isoh->maxj-1;j++) {
93 
94  value[0]=(float)isoh->value[isom][i][j];
95  value[1]=(float)isoh->value[isom][i+1][j];
96  value[2]=(float)isoh->value[isom][i+1][j+1];
97  value[3]=(float)isoh->value[isom][i][j+1];
98 
99  maxtop=0;
100  mintop=9999;
101  for(mm=0;mm<4;mm++) {
102 
103  if(value[mm] < mintop)
104  mintop=value[mm];
105 
106  if(value[mm] > maxtop)
107  maxtop=value[mm];
108 
109  }
110 
111  value[4]=value[0];
112 
113  for(l=1;l<16;l++) {
114 
115  telim=l*fm;
116 
117  if(telim < mintop || telim > maxtop)
118  continue;
119 
120  pnum=0;
121 
122  for(m=0;m<4;m++) {
123 
124  if((telim >= value[m] &&
125  telim < value[m+1]) ||
126  (telim < value[m] &&
127  telim >= value[m+1])) {
128 
129  if(value[m]==value[m+1])
130  continue;
131 
132  x[pnum]=(float)isoh->coord[i+di[m+1]][j+dj[m+1]].x +
133  (float)(isoh->coord[i+di[m]][j+dj[m]].x-
134  isoh->coord[i+di[m+1]][j+dj[m+1]].x)/
135  (value[m]-value[m+1])*
136  (telim-value[m+1]);
137 
138  y[pnum]=(float)isoh->coord[i+di[m+1]][j+dj[m+1]].y +
139  (float)(isoh->coord[i+di[m]][j+dj[m]].y-
140  isoh->coord[i+di[m+1]][j+dj[m+1]].y)/
141  (value[m]-value[m+1])*
142  (telim-value[m+1]);
143 
144  for(h=0;h<pnum;h++){
145 
146  if(x[h]==x[pnum] && y[h]==y[pnum])
147  goto hop;
148 
149  }
150 
151  if(pnum==2) {
152 
153  for(kk=0;kk<3;kk++) {
154 
155  dup_flag[kk]=0;
156 
157  for(mm=0;mm<4;mm++) {
158 
159  xint=(int)x[kk];
160  yint=(int)y[kk];
161 
162  if(xint/10==isoh->coord[i+di[mm]][j+dj[mm]].x/10 &&
163  yint/10==isoh->coord[i+di[mm]][j+dj[mm]].y/10)
164  dup_flag[kk]=1;
165 
166 
167  }
168  }
169  }
170  pnum++;
171 
172  hop:
173 
174  pnum=pnum;
175 
176  }
177 
178  }
179 
180 if(pnum==3) {
181 
182  mm=0;
183  for(kk=0;kk<3;kk++){
184 
185  if(dup_flag[kk]==0) {
186  xx[mm]=x[kk];
187  yy[mm++]=y[kk];
188 
189 
190  }
191 
192  }
193 
194  for(kk=0;kk<2;kk++){
195 
196  x[kk]=xx[kk];
197  y[kk]=yy[kk];
198 
199  }
200  pnum=mm;
201 
202  }
203 
204 if(pnum != 2 && pnum != 4)
205  continue;
206 
207  color=imap[l];
208  XSetForeground(display,gc,color);
209 
210  if(zoom <= 1) {
211 
212  for(k=0;k<pnum;k++) {
213 
214  nx[k]=xmin+x[k]*cmult;
215  ny[k]=ymin+y[k]*cmult;
216 
217  }
218  }
219 
220  else {
221 
222  for(k=0;k<pnum;k++) {
223 
224  nx[k]=xmin+(x[k]*cmult-lint1)*zoom + xcen;
225  ny[k]=ymin+(y[k]*cmult-lint2)*zoom + ycen;
226 
227  }
228 
229  }
230  for(k=0;k<pnum;k++) {
231 
232  point[k].x=(nx[k]+5)/MY;
233  point[k].y=(ny[k]+5)/MY;
234 
235 
236  }
237 
238 
239 
240  if(pnum==2)
241  XDrawLine(display,pixm,gc,point[0].x,point[0].y,point[1].x,point[1].y);
242 
243  else {
244 
245  if(telim < value[1]) {
246 
247  XDrawLine(display,pixm,gc,point[1].x,point[1].y,point[2].x,point[2].y);
248  XDrawLine(display,pixm,gc,point[3].x,point[3].y,point[0].x,point[0].y);
249 
250  }
251 
252  else {
253 
254  XDrawLine(display,pixm,gc,point[0].x,point[0].y,point[1].x,point[1].y);
255  XDrawLine(display,pixm,gc,point[2].x,point[2].y,point[3].x,point[3].y);
256 
257  }
258 
259  }
260  }
261 
262  }
263 }
264 
265 
266 line_width=0;
267 line_style=LineSolid;
268 cap_style=CapButt;
269 join_style=JoinMiter;
270 
271 XSetLineAttributes(display,gc,line_width,line_style,cap_style,join_style);
272 
273 
274 return;
275 
276 }
277 
278 
279 
280 
281 
282 
283 
284 
285 
286 
287 
288 
289 
290 
291 
292 
293 
294 
295 
296 
297 
298 
299 
300 
301 
302 
303 
304 
305 
306 
307 
308 
309 
310 
311 
312 
313 
314 
315 
316 
317 
318 
319 
320 
321 
322 
323 
324 
325 
326 
327 
328 
329 
330 
331 
332 
333 
334 
335 
336 
337 
338 
339 
340 
static int i
void contour_isoh(Pixmap pixm, int h, int display_flag)
Definition: contour_isoh.c:4
Display * display
Definition: mapper.c:159
Font font[10]
Definition: mapper.c:161
float mult
Definition: edit_stations.c:6
double yy
Definition: mapp2h.h:41
int j
Definition: mapp2h.h:48
int k
Definition: mapp2h.h:48
double xx
Definition: mapp2h.h:41
int iscale
Definition: mapper.c:101
struct isoh * isoh
Definition: mapper.c:144
unsigned long imap[16]
Definition: mapper.c:116
int display_flag
Definition: mapper.c:100
float xrat
long xmax
int dj[4]
int color
float value
float yrat
long ny[4]
long ymax
int dy
long lint1
GC gc
Definition: mapper.c:163
int dx
float cmult
signed long xcen
Dimension height
signed long ycen
Dimension width
long lint2
Arg args[10]
long xmin
unsigned long XSIZE
int MY
int zoom
long nx[4]
float dmult
Widget drawing_area
Definition: mapper.c:185
int npoint[2]
Definition: mapper.c:105
long ymin
unsigned long YSIZE
int di[4]
short int y
Definition: misc.h:498
short int x
Definition: misc.h:497
float dmult[4]
Definition: misc.h:613
long xmin[4]
Definition: misc.h:607
long xmax[4]
Definition: misc.h:609
long ymax[4]
Definition: misc.h:610
long ymin[4]
Definition: misc.h:608
long ycen[4]
Definition: misc.h:612
long xcen[4]
Definition: misc.h:611
Definition: misc.h:538
struct coord ** coord
Definition: misc.h:540
int maxi
Definition: misc.h:542
short int *** value
Definition: misc.h:541
int maxj
Definition: misc.h:543
Definition: mapp2h.h:29
int y
Definition: mapp2h.h:30
int x
Definition: mapp2h.h:30