This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / GEANT321 / cgpack / cgvhed.F
1 *
2 * $Id$
3 *
4 * $Log$
5 * Revision 1.1.1.1  1995/10/24 10:19:45  cernlib
6 * Geant
7 *
8 *
9 #include "geant321/pilot.h"
10 *CMZ :  3.21/02 29/03/94  15.41.32  by  S.Giani
11 *-- Author :
12       SUBROUTINE CGVHED(XYZ,IFACE,IPF,DFACE,ITREE,ISTACK,ALEFT,ARIGHT)
13 ************************************************************************
14 *                                                                      *
15 *     Name: CGVHED                                                     *
16 *     Author: E. Chernyaev                       Date:    08.08.88     *
17 *                                                Revised:              *
18 *                                                                      *
19 *     Function: Hidden line removal algorithm                          *
20 *               (tree search is used for min-max test)                 *
21 *                                                                      *
22 *     References: CGVEDG, CGVTEF                                       *
23 *                                                                      *
24 *     Input: XYZ(3,*) - nodes coordinates                              *
25 *         IFACE(*) - faces                                             *
26 *           IPF(*) - pointers to faces beginings                       *
27 *       DFACE(6,*) - faces min-max                                     *
28 *       ITREE(4,*) - tree of faces min-max                             *
29 *        ISTACK(*) - stack for tree search                             *
30 *         ALEFT(*) - min-max of left subtrees                          *
31 *        ARIGHT(*) - min-max of rigth subtrees                         *
32 *                                                                      *
33 *     Output: none                                                     *
34 *                                                                      *
35 *     Errors: none                                                     *
36 *                                                                      *
37 ************************************************************************
38 #include "geant321/cgcedg.inc"
39       REAL            XYZ(3,*),DFACE(6,*),ALEFT(*),ARIGHT(*)
40 *SG
41       INTEGER         IPF(*)
42       INTEGER         IFACE(*)
43       INTEGER         ISTACK(*),ITREE(4,*)
44       INTEGER         INDLFT(5),INDRGT(5)
45 *SG
46       DATA            INDLFT/3,4,5,1,2/,INDRGT/3,4,1,2,1/
47 *-
48       JS     = 0
49       JT     = 1
50 *           T R E E   S E A R C H
51   200 NF     = ITREE(1,JT)
52       IND    = ITREE(4,JT)
53       IF (DEDGE(IND) .GT. DFACE(IND,NF))      GOTO 300
54       DO 210 I=1,5
55         IF (DEDGE(I) .GT. DFACE(I,NF))        GOTO 220
56   210   CONTINUE
57       NIPF=IPF(NF)
58       CALL CGVTEF(IFACE(NIPF),XYZ,IVIS)
59       IF (IVIS .LT. 0)                        GOTO 900
60 *           S T O R E   L E F T   L I N K   I N   S T A C K  (IF NEED)
61   220 IF (DEDGE(INDLFT(IND)) .GT. ALEFT(JT))  GOTO 300
62       JS     = JS + 1
63       ISTACK(JS) = ITREE(2,JT)
64 *           S T E P   T O   R I G H T
65   300 IF (DEDGE(INDRGT(IND)) .GT. ARIGHT(JT)) GOTO 400
66       JT     = ITREE(3,JT)
67       GOTO 200
68 *           R E S T O R E   L E F T   L I N K   F R O M   S T A C K
69   400 IF (JS .EQ. 0)                          GOTO 999
70       JT     = ISTACK(JS)
71       JS     = JS - 1
72       GOTO 200
73 *
74   900 NPART = -1
75   999 RETURN
76       END