Bugfix in AliPoints2Memory
[u/mrichter/AliRoot.git] / GEANT321 / cgpack / cgbint.F
1 *
2 * $Id$
3 *
4 * $Log$
5 * Revision 1.1.1.1  1995/10/24 10:19:42  cernlib
6 * Geant
7 *
8 *
9 #include "geant321/pilot.h"
10 *CMZ :  3.21/02 29/03/94  15.41.31  by  S.Giani
11 *-- Author :
12       SUBROUTINE CGBINT(A,B,NMAX,C,IREP)
13 ************************************************************************
14 *                                                                      *
15 *     Name: CGBINT                                                     *
16 *     Author: E. Chernyaev                       Date:    23.10.88     *
17 *                                                Revised:              *
18 *                                                                      *
19 *     Function: Intersection of two faces                              *
20 *                                                                      *
21 *     References: CGBMMT,CGBTEF,CGBSOR                                 *
22 *                                                                      *
23 *     Input: A(*) - 1-st face                                          *
24 *            B(*) - 2-nd face                                          *
25 *            NMAX - max length C array                                 *
26 *                                                                      *
27 *     Output: C(*) - resulting face                                    *
28 *             IREP - reply (legth of resulting face)                   *
29 *                          (-1 if no space)                            *
30 *     Errors: none                                                     *
31 *                                                                      *
32 ************************************************************************
33 #include "geant321/cggpar.inc"
34       REAL      A(*),B(*),C(*)
35 *-
36       IF (NMAX .LT. LCGFAC)     GOTO 998
37 *           M I N - M A X   T E S T   O F   T W O   F A C E S
38       CALL CGBMMT(A,B,IREP)
39       IF (IREP .EQ. 0)          GOTO 999
40 *           T E S T   1 - S T   F A C E   A G A I N S T   2 - N D
41       C(KCGAF) = NMAX
42       C(KCGNE) = 0.
43       NEDGE  = A(KCGNE)
44       J      = LCGFAC
45       INTRNL = -1
46       IVAR   = 2
47       DO 100 NE=1,NEDGE
48         CALL CGBTEF(INTRNL,IVAR,A(J+1),B,C)
49         IF (C(KCGAF) .LT. 0.)   GOTO 998
50         J      = J + LCGEDG
51   100   CONTINUE
52 *           T E S T   2 - N D   F A C E   A G A I N S T   1 - S T
53       NEDGE  = B(KCGNE)
54       J      = LCGFAC
55       DO 200 NE=1,NEDGE
56         CALL CGBTEF(INTRNL,IVAR,B(J+1),A,C)
57         IF (C(KCGAF) .LT. 0.)   GOTO 998
58         J      = J + LCGEDG
59   200   CONTINUE
60 *           P R E P A R E   N E W   F A C E
61       NEDGE = C(KCGNE)
62       IF (NEDGE .EQ. 0)         GOTO 997
63       CALL CGBSOR(NEDGE,C(LCGFAC+1))
64       C(KCGNE) = NEDGE
65       IF (NEDGE .EQ. 0)         GOTO 997
66       IF (NEDGE .LT. 3) PRINT *,' CGBINT: NEDGE .LT. 3 - face ignored'
67       IF (NEDGE .LT. 3)         GOTO 997
68       C(KCGAF) = A(KCGAF)
69       IF (B(KCGAF) .GT. A(KCGAF)) C(KCGAF) = B(KCGAF)
70       C(KCGAA) = A(KCGAA)
71       C(KCGBB) = A(KCGBB)
72       C(KCGCC) = A(KCGCC)
73       C(KCGDD) = A(KCGDD)
74       IREP  = LCGFAC + NEDGE*LCGEDG
75       GOTO 999
76 *
77   997 IREP   = 0
78       GOTO 999
79   998 IREP = -1
80   999 RETURN
81       END