This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / GEANT321 / cgpack / cgbmmt.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 CGBMMT(A,B,IREP)
13 ************************************************************************
14 *                                                                      *
15 *     Name: CGBMMT                                                     *
16 *     Author: E. Chernyaev                       Date:    23.10.88     *
17 *                                                Revised:              *
18 *                                                                      *
19 *     Function: Mim-max test of two faces                              *
20 *                                                                      *
21 *     References: none                                                 *
22 *                                                                      *
23 *     Input: A(*) - 1-st face                                          *
24 *            B(*) - 2-nd face                                          *
25 *                                                                      *
26 *     Output: IREP - reply (=0 if NO intersection)                     *
27 *                          (=1 if there is intersection)               *
28 *                                                                      *
29 *     Errors: none                                                     *
30 *                                                                      *
31 ************************************************************************
32 #include "geant321/cggpar.inc"
33 #include "geant321/cgdelt.inc"
34       REAL      A(*),B(*),RMNA(3),RMXA(3),RMNB(3),RMXB(3)
35       INTEGER   IND(6)
36       DATA      IND/KCGX1,KCGY1,KCGZ1,KCGX2,KCGY2,KCGZ2/
37 *-
38       JJ     =  LCGFAC
39       DO 100 I=1,3
40         RMNA(I)= A(JJ+IND(I))
41         RMXA(I)= A(JJ+IND(I))
42         RMNB(I)= B(JJ+IND(I))
43         RMXB(I)= B(JJ+IND(I))
44   100   CONTINUE
45 *           C O M P U T E   M I N - M A X   O F   1 - S T   F A C E
46       NEDGE  = A(KCGNE)
47       JJ     = LCGFAC
48       DO 220 NE=1,NEDGE
49         DO 210 J=1,3
50           I      = J
51           IF (J .GT. 3) I = J - 3
52           IF (A(JJ+IND(J)) .LT. RMNA(I)) RMNA(I) = A(JJ+IND(J))
53           IF (A(JJ+IND(J)) .GT. RMXA(I)) RMXA(I) = A(JJ+IND(J))
54   210     CONTINUE
55         JJ     = JJ + LCGEDG
56   220   CONTINUE
57 *           C O M P U T E   M I N - M A X   O F   2 - N D   F A C E
58       NEDGE  = B(KCGNE)
59       JJ     = LCGFAC
60       DO 320 NE=1,NEDGE
61         DO 310 J=1,3
62           I      = J
63           IF (J .GT. 3) I = J - 3
64           IF (B(JJ+IND(J)) .LT. RMNB(I)) RMNB(I) = B(JJ+IND(J))
65           IF (B(JJ+IND(J)) .GT. RMXB(I)) RMXB(I) = B(JJ+IND(J))
66   310     CONTINUE
67         JJ     = JJ + LCGEDG
68   320   CONTINUE
69 *           M I N - M A X   T E S T
70       IREP   = 0
71       IF (RMNA(1) .GT. RMXB(1)+EEWOR)   GOTO 999
72       IF (RMXA(1) .LT. RMNB(1)-EEWOR)   GOTO 999
73       IF (RMNA(2) .GT. RMXB(2)+EEWOR)   GOTO 999
74       IF (RMXA(2) .LT. RMNB(2)-EEWOR)   GOTO 999
75       IF (RMNA(3) .GT. RMXB(3)+EEWOR)   GOTO 999
76       IF (RMXA(3) .LT. RMNB(3)-EEWOR)   GOTO 999
77       IREP   = 1
78 *
79   999 RETURN
80       END