]> git.uio.no Git - u/mrichter/AliRoot.git/blame - GEANT321/gdraw/gdrawv.F
This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / GEANT321 / gdraw / gdrawv.F
CommitLineData
fe4da5cc 1*
2* $Id$
3*
4* $Log$
5* Revision 1.2 1996/09/30 13:37:24 ravndal
6* Backward compatibility for view banks
7*
8* Revision 1.1.1.1 1995/10/24 10:20:27 cernlib
9* Geant
10*
11*
12#include "geant321/pilot.h"
13*CMZ : 3.21/02 29/03/94 15.41.27 by S.Giani
14*-- Author :
15 SUBROUTINE GDRAWV(U,V,NP)
16C.
17C. ******************************************************************
18C. * *
19C. * GDRAWV stores sparse segments ( NP = 2 ) in a buffer. *
20C. * When the buffer is full it is scanned to collect *
21C. * segments into polylines ( NP > 2 ), that will be *
22C. * drawn by the GDRAWP routine. *
23C. * *
24C. * Variables used in the routine : *
25C. * *
26C. * EPS = Error range of user coordinates until which *
27C. * they are considered as coincident points *
28C. * *
29C. * I0 = Pointer to starting point of polyline (in X,Y) *
30C. * I1 = Pointer to starting point of segment (in X,Y) *
31C. * I2 = Pointer to ending point of segment (in X,Y) *
32C. * INEW = Number of points of polyline (in XNEW,YNEW) *
33C. * *
34C. * NSEG = Current number of segments *
35C. * MAXSEG = Max number of segments *
36C. * MAXNEW = Max length of polyline *
37C. * *
38C. * X = Vector of x-coordinates of input segments *
39C. * Y = Vector of y-coordinates of input segments *
40C. * IEMPTY = Vector to flag empty points; if IEMPTY(I)=1 *
41C. * then X(I),Y(I) has been already linked *
42C. * *
43C. * (X,Y,IEMPTY are dimensioned to MAXSEG*2) *
44C. * *
45C. * IATTL = Vector of attributes of input segments, *
46C. * dimensioned to MAXSEG *
47C. * *
48C. * XNEW = Vector of x-coordinates of output polyline *
49C. * YNEW = Vector of y-coordinates of output polyline *
50C. * *
51C. * (XNEW,YNEW are dimensioned to MAXNEW) *
52C. * *
53C. * LUDEB = If < 0 then no debug printout will be done *
54C. * *
55C. * ISTF = Flag for statistics printout; *
56C. * if ISTF=1 a statistics of polylines length *
57C. * will be done (to be printed interactively) *
58C. * *
59C. * LINBUF = Flag to determine if GDRAWV has to perform *
60C. * line buffering logic (LINBUF=1) or not *
61C. * *
62C. * ==>Called by : <USER>, <GXINT>, GDAHIT, GDARC, GDARR, *
63C. * GDCIRC, GDCIRR, GDCIRY, GDCUT, GDHEAD, *
64C. * GDLINE, GDMAN, GDPRTR, GDRAW, GDRECT, *
65C. * GDSCAL, GDSHOW, GDSURF, GDTREE *
66C. * Author : P.Zanarini S.Giani 1992 ********* *
67C. * *
68C. ******************************************************************
69C.
70#include "geant321/gcbank.inc"
71#include "geant321/gcdraw.inc"
72#include "geant321/gcvolu.inc"
73#include "geant321/gcunit.inc"
74#include "geant321/gcspee.inc"
75 CHARACTER*80 ILINE
76 DIMENSION U(*),V(*)
77 DIMENSION X(160),Y(160),IEMPTY(160)
78 DIMENSION IATTL(80)
79 DIMENSION XNEW(45),YNEW(45)
80 DIMENSION IDBIST(2,20),IDBERR(10)
81 SAVE X,Y,IEMPTY,IATTL,IDBIST,IDBERR,XNEW,YNEW
82 SAVE MAXSEG,MAXNEW,EPS,LUDEB,ISTF,NSEG,INEW
83 DATA MAXSEG/80/
84 DATA MAXNEW/45/
85 DATA EPS/0.00001/
86 DATA LUDEB/-1/
87 DATA ISTF/0/
88 DATA IDBERR,IDBIST/50*0/
89C.
90C. ------------------------------------------------------------------
91C.
92 IF (NP.EQ.-1) THEN
93C
94C Initialize (open) the line buffer
95C
96 LINBUF=1
97 NSEG=0
98 INEW=0
99 GO TO 999
100C
101 ELSE IF (NP.EQ.0) THEN
102C
103C Empties (close) the line buffer
104C
105 LINBUF=0
106 GO TO 10
107C
108 ELSE IF (NP.GT.2) THEN
109C
110C Call directly GDRAWP
111C
112 CALL GDRAWP(U,V,NP)
113 GO TO 999
114C
115C
116 ELSE IF (LINBUF.EQ.0) THEN
117C
118C Call directly GDRAWP
119C
120 CALL GDRAWP(U,V,NP)
121 GO TO 999
122C
123 ENDIF
124C
125 LTY=IBITS(LINATT,10,3)
126 CALL UCTOH('ON ',IFLH,4,4)
127 IF(LTY.NE.6.AND.IHIDEN.EQ.IFLH)THEN
128 CALL GDRAWP(U,V,NP)
129 GO TO 999
130 ENDIF
131C Fill the line buffer
132C
133 NSEG=NSEG+1
134 IATTL(NSEG)=LINATT
135C
136 NPOINT=NSEG*2
137 X(NPOINT-1)=U(1)
138 Y(NPOINT-1)=V(1)
139 X(NPOINT)=U(2)
140 Y(NPOINT)=V(2)
141C
142 IF (NSEG.NE.MAXSEG) GO TO 999
143C
144C Line buffer full : check for joined lines
145C
146C Initialisation phase
147C
148 10 CONTINUE
149C
150 I0=1
151 INEW=0
152 NPOINT=NSEG*2
153C
154 DO 20 I=1,NPOINT
155 IEMPTY(I)=0
156 20 CONTINUE
157C
158C Loop phase
159C
160 30 CONTINUE
161C
162 NPOINT=NSEG*2
163C
164 DO 40 K=I0,NPOINT
165 IF (IEMPTY(K).EQ.0) GO TO 50
166 40 CONTINUE
167C
168C Buffer empty
169C
170 NSEG=0
171 GO TO 999
172C
173 50 CONTINUE
174C
175 KDIV2=(K+1)/2
176 IF (INEW.EQ.0) LINATT=IATTL(KDIV2)
177C
178 I1=K
179 INEW=INEW+1
180 XNEW(INEW)=X(I1)
181 YNEW(INEW)=Y(I1)
182 IEMPTY(I1)=1
183 I0=I1
184C
185 60 CONTINUE
186C
187 IF ((I1/2)*2.EQ.I1) THEN
188 I2=I1-1
189 ELSE
190 I2=I1+1
191 ENDIF
192C
193 I2DIV2=(I2+1)/2
194 IF (INEW.EQ.0) LINATT=IATTL(I2DIV2)
195C
196 INEW=INEW+1
197 XNEW(INEW)=X(I2)
198 YNEW(INEW)=Y(I2)
199 IEMPTY(I2)=1
200C
201 IF (INEW.EQ.MAXNEW) THEN
202 IF (LUDEB.GE.0) THEN
203 WRITE (CHMAIL,10000) NAMES(NLEVEL),INEW
204 CALL GMAIL(0,0)
205 ENDIF
206 IDBERR(1)=IDBERR(1)+1
207 GO TO 70
208 ENDIF
209C
210C Link is closed ?
211C
212 IF ((X(I2).LT.X(I0)-EPS).OR.(X(I2).GT.X(I0)+EPS)) GO TO 140
213 IF ((Y(I2).LT.Y(I0)-EPS).OR.(Y(I2).GT.Y(I0)+EPS)) GO TO 140
214C
215C Link closed
216C
217 70 CONTINUE
218C
219 IF (INEW.GT.3) THEN
220 CALL GDRAWP(XNEW,YNEW,INEW)
221 ELSE
222 IF (INEW.EQ.3) CALL GDRAWP(XNEW,YNEW,INEW)
223 IF (LUDEB.GE.0) THEN
224 WRITE (CHMAIL,10100) NAMES(NLEVEL),INEW
225 CALL GMAIL(0,0)
226 ENDIF
227 IDBERR(2)=IDBERR(2)+1
228 ENDIF
229C
230 80 CONTINUE
231C
232C Do some statistics if in statistics mode
233C
234 IF (ISTF.EQ.1) THEN
235 IF (INEW.LE.3) GO TO 120
236 LENPOL=INEW-1
237 90 CONTINUE
238 DO 100 I=1,20
239 IF (LENPOL.EQ.IDBIST(1,I)) THEN
240 IDBIST(2,I)=IDBIST(2,I)+1
241 GO TO 120
242 ENDIF
243 100 CONTINUE
244 DO 110 I=1,20
245 IF (IDBIST(1,I).EQ.0) THEN
246 IDBIST(1,I)=LENPOL
247 GO TO 90
248 ENDIF
249 110 CONTINUE
250 WRITE (CHMAIL,10800) LENPOL
251 CALL GMAIL(0,0)
252 120 CONTINUE
253 ENDIF
254C
255 IF (LUDEB.LT.0) GO TO 130
256C
257C Do some printout if in debugging mode
258C
259 LENPOL=INEW-1
260 WRITE (CHMAIL,10400) NAMES(NLEVEL),LENPOL
261 CALL GMAIL(0,0)
262 IC0=I0/2
263 IF ((I0/2)*2.NE.I0) IC0=IC0+1
264 IC1=I1/2
265 IF ((I1/2)*2.NE.I1) IC1=IC1+1
266 ILINE=' '
267 ILINE(IC1:IC1)='1'
268 ILINE(IC0:IC0)='0'
269 WRITE (CHMAIL,10500) I0,I1,I2,INEW,NSEG
270 CALL GMAIL(1,0)
271 WRITE (CHMAIL,10600) ILINE(1:NSEG)
272 CALL GMAIL(0,0)
273 NPOINT=NSEG*2
274 NPOIN1=NPOINT-1
275 WRITE (CHMAIL,10700) (IEMPTY(JJ),JJ=1,NPOIN1,2)
276 CALL GMAIL(0,0)
277 WRITE (CHMAIL,10700) (IEMPTY(JJ),JJ=2,NPOINT,2)
278 CALL GMAIL(0,0)
279C
280 130 CONTINUE
281 INEW=0
282 GO TO 30
283C
284 140 CONTINUE
285C
286 NPOINT=NSEG*2
287C
288C Compute starting point of next segment
289C
290 NEXT=0
291C
292 DO 150 K=I0,NPOINT
293 IF (K.EQ.I2) GO TO 150
294 IF ((X(I2).LT.X(K)-EPS).OR.(X(I2).GT.X(K)+EPS)) GO TO 150
295 IF ((Y(I2).LT.Y(K)-EPS).OR.(Y(I2).GT.Y(K)+EPS)) GO TO 150
296 NEXT=K
297 GO TO 160
298 150 CONTINUE
299C
300 160 CONTINUE
301C
302 IF (NEXT.NE.0) THEN
303 I1=NEXT
304 IEMPTY(I1)=1
305 GO TO 60
306 ENDIF
307C
308 IF (I0.EQ.1) THEN
309 CALL GDRAWP(XNEW,YNEW,INEW)
310 IF (LUDEB.GE.0) THEN
311 WRITE (CHMAIL,10200) NAMES(NLEVEL),INEW
312 CALL GMAIL(0,0)
313 ENDIF
314 IDBERR(3)=IDBERR(3)+1
315 GO TO 80
316 ENDIF
317C
318C Reset flag : next call to GDRAWV will re-process
319C the points now forming an open polyline, trying then
320C (with the new points stored) to form a closed polyline
321C
322 DO 170 I=I0,NPOINT
323 IEMPTY(I)=0
324 170 CONTINUE
325C
326 NSEGOL=NSEG
327C
328C Try to see if the buffers can be shifted
329C
330 180 CONTINUE
331C
332 DO 190 NLIN=1,NSEG
333 IF (IEMPTY(NLIN*2).EQ.0) GO TO 210
334 190 CONTINUE
335C
336 IF (NSEG.NE.NSEGOL) THEN
337C
338C The buffers have been shifted enough
339C
340 GO TO 230
341C
342 ELSE
343C
344C The buffers cannot be shifted at all
345C
346 IF (LUDEB.GE.0) THEN
347 WRITE (CHMAIL,10300) NAMES(NLEVEL)
348 CALL GMAIL(0,0)
349 ENDIF
350 IDBERR(4)=IDBERR(4)+1
351 LINATT=IATTL(1)
352 DO 200 I=1,NSEG
353 J=I*2-1
354 CALL GDRAWP(X(J),Y(J),2)
355 200 CONTINUE
356 INEW=0
357 GO TO 30
358C
359 ENDIF
360C
361 210 CONTINUE
362C
363C Shift the buffers
364C
365 IF (NLIN.EQ.1) GO TO 230
366 NSEG=NSEG-NLIN+1
367 N=NSEG*2
368 J=NLIN*2-2
369 DO 220 I=1,N
370 X(I) = X(J+I)
371 Y(I) = Y(J+I)
372 IEMPTY(I) = IEMPTY(J+I)
373 220 CONTINUE
374 CALL UCOPY(IATTL(NLIN),IATTL(1),NSEG)
375C
376 IF (NSEG.GT.0) GO TO 180
377C
378 GO TO 999
379C
380 230 CONTINUE
381C
382C If last call to GDRAWV (NP=0, i.e. close the buffer)
383C and some lines have still to be processed (NSEG>0)
384C then don't RETURN but re-execute the body of GDRAWV
385C
386 IF (NP.EQ.0.AND.NSEG.GT.0) GO TO 10
387C
38810000 FORMAT (' *** GDRAWV: ERROR 1 - NAME = ',A4,' INEW = ',I3)
38910100 FORMAT (' *** GDRAWV: ERROR 2 - NAME = ',A4,' INEW = ',I3)
39010200 FORMAT (' *** GDRAWV: ERROR 3 - NAME = ',A4,' INEW = ',I3)
39110300 FORMAT (' *** GDRAWV: ERROR 4 - NAME = ',A4)
39210400 FORMAT (' *** GDRAWV: GDRAWP called for ',A4,' (',I2,' segments)')
39310500 FORMAT (' LOOP : I0=',I3,' - I1=',I3,' - I2=',I3,
394 + ' - INEW=',I3,' - NSEG=',I3)
39510600 FORMAT (1X,A)
39610700 FORMAT (1X,80I1)
39710800 FORMAT (' *** STATISTICS OVERFLOW *** LENPOL =',I3)
398 999 END