Mapper
contour_topo.c
Go to the documentation of this file.
1 
2 #include "prototypes.h"
3 
4 void contour_topo(Pixmap pixm,int h, int display_flag)
5 
6 {
7 extern int topo_buf[10];
8 extern Font font[10];
9 extern Display *display;
10 extern int npoint[2],zoom;
11 extern GC gc;
12 extern unsigned long tmap[50];
13 extern Widget drawing_area;
14 extern struct display_set display_set[4];
15 extern struct topo *topo;
16 int i,j,k,m,l;
17 int color,MY=10;
18 float xrat,yrat,mult,dmult,cmult;
19 long nx[4],ny[4];
20 Dimension width,height;
21 Arg args[10];
22 unsigned long XSIZE,YSIZE;
23 XPoint point[5];
25 signed long xcen,ycen;
26 int di[5],dj[5],dy,dx,pnum,kk,mm;
27 float value[5];
28 float x[5],y[5],xx[5],yy[5];
29 int line_style,cap_style,join_style;
30 unsigned line_width;
31 int xint,yint,dup_flag[5];
32 int telim[10];
33 int maxtop,mintop;
34 telim[1]=topo_buf[0];
35 telim[2]=topo_buf[1];
36 telim[3]=topo_buf[2];
37 telim[4]=topo_buf[3];
38 telim[5]=topo_buf[4];
39 
40 dx=1;dy=1;
41 
42 di[0]=0;dj[0]=0;
43 di[1]=1;dj[1]=0;
44 di[2]=1;dj[2]=1;
45 di[3]=0;dj[3]=1;
46 di[4]=0;dj[4]=0;
47 
48 XSetFont(display,gc,font[0]);
49 
57 
58 XtSetArg(args[0],XtNwidth,&width);
59 XtSetArg(args[1],XtNheight,&height);
60 XtGetValues(drawing_area,args,2);
61 
62 XSIZE=(long)width*10L;
63 YSIZE=(long)height*10L;
64 
65 xrat=(float)XSIZE/(float)12800;
66 yrat=(float)YSIZE/(float)9600;
67 
68 if(xrat < yrat)
69  mult=xrat;
70 
71 else
72  mult=yrat;
73 
75 lint1=(long)npoint[0]*(long)MY;
76 lint2=(long)npoint[1]*(long)MY;
77 
78 line_width=0;
79 line_style=LineSolid;
80 cap_style=CapButt;
81 join_style=JoinMiter;
82 
83 XSetLineAttributes(display,gc,line_width,line_style,cap_style,join_style);
84 
85 for(i=0;i<topo->maxi-1;i++) {
86 
87 for(j=0;j<topo->maxj-1;j++) {
88 
89  value[0]=(float)topo->value[i][j];
90  value[1]=(float)topo->value[i+1][j];
91  value[2]=(float)topo->value[i+1][j+1];
92  value[3]=(float)topo->value[i][j+1];
93 
94  if(value[0] < 0 ||
95  value[1] < 0 ||
96  value[2] < 0 ||
97  value[3] < 0)
98  continue;
99 
100  maxtop=0;
101  mintop=9999;
102  for(mm=0;mm<4;mm++) {
103 
104  if(value[mm] < mintop)
105  mintop=value[mm];
106 
107  if(value[mm] > maxtop)
108  maxtop=value[mm];
109 
110  }
111 
112  value[4]=value[0];
113 
114  for(l=1;l<6;l++) {
115  if(tmap[3+7*l]==0)
116  continue;
117 
118 
119  if(telim[l] < mintop || telim[l] > maxtop)
120  continue;
121 
122  pnum=0;
123 
124  for(m=0;m<4;m++) {
125 
126  if((telim[l] >= value[m] &&
127  telim[l] < value[m+1]) ||
128  (telim[l] < value[m] &&
129  telim[l] >= value[m+1])) {
130 
131  if(value[m]==value[m+1])
132  continue;
133 
134  x[pnum]=(float)topo->coord[i+di[m+1]][j+dj[m+1]].x +
135  (float)(topo->coord[i+di[m]][j+dj[m]].x-
136  topo->coord[i+di[m+1]][j+dj[m+1]].x)/
137  (value[m]-value[m+1])*
138  (telim[l]-value[m+1]);
139 
140  y[pnum]=(float)topo->coord[i+di[m+1]][j+dj[m+1]].y +
141  (float)(topo->coord[i+di[m]][j+dj[m]].y-
142  topo->coord[i+di[m+1]][j+dj[m+1]].y)/
143  (value[m]-value[m+1])*
144  (telim[l]-value[m+1]);
145 
146  for(h=0;h<pnum;h++){
147 
148  if(x[h]==x[pnum] && y[h]==y[pnum])
149  goto hop;
150 
151  }
152 
153  if(pnum==2) {
154 
155  for(kk=0;kk<3;kk++) {
156 
157  dup_flag[kk]=0;
158 
159  for(mm=0;mm<4;mm++) {
160 
161  xint=(int)x[kk];
162  yint=(int)y[kk];
163 
164  if(xint/10==topo->coord[i+di[mm]][j+dj[mm]].x/10 &&
165  yint/10==topo->coord[i+di[mm]][j+dj[mm]].y/10)
166  dup_flag[kk]=1;
167 
168 
169  }
170  }
171  }
172  pnum++;
173 
174  hop:
175 
176  pnum=pnum;
177 
178  }
179 
180  }
181 
182 if(pnum==3) {
183 
184  mm=0;
185  for(kk=0;kk<3;kk++){
186 
187  if(dup_flag[kk]==0) {
188  xx[mm]=x[kk];
189  yy[mm++]=y[kk];
190 
191 
192  }
193 
194  }
195 
196  for(kk=0;kk<2;kk++){
197 
198  x[kk]=xx[kk];
199  y[kk]=yy[kk];
200 
201  }
202  pnum=mm;
203 
204  }
205 
206 if(pnum != 2 && pnum != 4)
207  continue;
208 
209  color=tmap[6+7*l];
210  XSetForeground(display,gc,color);
211 
212  if(zoom <= 1) {
213 
214  for(k=0;k<pnum;k++) {
215 
216  nx[k]=xmin+x[k]*cmult;
217  ny[k]=ymin+y[k]*cmult;
218 
219  }
220  }
221 
222  else {
223 
224  for(k=0;k<pnum;k++) {
225 
226  nx[k]=xmin+(x[k]*cmult-lint1)*zoom + xcen;
227  ny[k]=ymin+(y[k]*cmult-lint2)*zoom + ycen;
228 
229  }
230 
231 }
232  for(k=0;k<pnum;k++) {
233 
234  point[k].x=(nx[k]+5)/MY;
235  point[k].y=(ny[k]+5)/MY;
236 
237 
238  }
239 
240 
241 
242  if(pnum==2)
243  XDrawLine(display,pixm,gc,point[0].x,point[0].y,point[1].x,point[1].y);
244 
245  else {
246 
247  if(telim[l] < value[1]) {
248 
249  XDrawLine(display,pixm,gc,point[1].x,point[1].y,point[2].x,point[2].y);
250  XDrawLine(display,pixm,gc,point[3].x,point[3].y,point[0].x,point[0].y);
251 
252  }
253 
254  else {
255 
256  XDrawLine(display,pixm,gc,point[0].x,point[0].y,point[1].x,point[1].y);
257  XDrawLine(display,pixm,gc,point[2].x,point[2].y,point[3].x,point[3].y);
258 
259  }
260 
261  }
262  }
263 
264  }
265 }
266 
267 
268 line_width=0;
269 line_style=LineSolid;
270 cap_style=CapButt;
271 join_style=JoinMiter;
272 
273 XSetLineAttributes(display,gc,line_width,line_style,cap_style,join_style);
274 
275 
276 return;
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 
341 
342 
struct top * topo
Definition: build_hrap.c:3
static int i
void contour_topo(Pixmap pixm, int h, int display_flag)
Definition: contour_topo.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
unsigned long tmap[50]
Definition: mapper.c:116
int display_flag
Definition: mapper.c:100
int topo_buf[10]
Definition: mapper.c:38
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: mapp2h.h:29
int y
Definition: mapp2h.h:30
int x
Definition: mapp2h.h:30
Definition: misc.h:523
struct coord ** coord
Definition: misc.h:525
int maxi
Definition: misc.h:527
short int ** value
Definition: misc.h:526
int maxj
Definition: misc.h:528