This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / GEANT321 / cgpack / cgbrik.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 CGBRIK(DX,DY,DZ,LCG,CG)
13 ************************************************************************
14 *                                                                      *
15 *     Name: CGBRIK                                                     *
16 *     Author: E. Chernyaev                       Date:    24.03.88     *
17 *                                                Revised:              *
18 *                                                                      *
19 *     Function: Create CG-object for BRICK                             *
20 *                                                                      *
21 *     References: CGSIZE                                               *
22 *                                                                      *
23 *     Input:  DX - X-size                                              *
24 *             DY - Y-size                                              *
25 *             DZ - Z-size                                              *
26 *            LCG - max-size of CG-object                               *
27 *                                                                      *
28 *     Output: CG - CG-object                                           *
29 *                  CG(1) - length of CG-object                         *
30 *                        = 0 if error in parameters                    *
31 *                        < 0 if no space                               *
32 *                                                                      *
33 *     Errors: none                                                     *
34 *                                                                      *
35 ************************************************************************
36 #include "geant321/cggpar.inc"
37       REAL      CG(*),XYZ(3,8)
38       INTEGER   IORDER(4,6)
39       SAVE XYZ,IORDER
40       DATA      XYZ/24*0./
41       DATA      IORDER/1,2,3,4,
42      +                 1,5,6,2, 2,6,7,3, 3,7,8,4, 4,8,5,1,
43      +                 8,7,6,5/
44 *-
45       CG(KCGSIZ)  = 0.
46 *           T E S T   P A R A M E T E R S   C O R R E C T N E S S
47       IF (DX.LE.0. .OR. DY.LE.0. .OR. DZ.LE.0.) GOTO 999
48 *           C O M P U T E   S I Z E   O F   C G - O B J E C T
49       NFATYP   = 1
50       NFAC     = 6
51       NEDG     = 4
52       CG(KCGSIZ)  = CGSIZE(LCG,NFATYP,NFAC,NEDG)
53       IF (CG(KCGSIZ) .LE. 0.)        GOTO 999
54 *           P R E P A R E   N O D E S   C O O R D I N A T E S
55       XYZ(2,2) =  DY
56       XYZ(1,3) =  DX
57       XYZ(2,3) =  DY
58       XYZ(1,4) =  DX
59       DO 100 I=1,4
60         XYZ(1,I+4) = XYZ(1,I)
61         XYZ(2,I+4) = XYZ(2,I)
62         XYZ(3,I+4) = DZ
63   100   CONTINUE
64 *           C R E A T E   C G - O B J E C T   F O R   B R I K
65       CG(KCGATT) = 0.
66       CG(KCGNF)  = 6.
67       JCG    = LCGHEA
68       DO 300 NF=1,6
69         CG(JCG+KCGAF) = 0.
70         X1     = XYZ(1,IORDER(2,NF))-XYZ(1,IORDER(1,NF))
71         Y1     = XYZ(2,IORDER(2,NF))-XYZ(2,IORDER(1,NF))
72         Z1     = XYZ(3,IORDER(2,NF))-XYZ(3,IORDER(1,NF))
73         X2     = XYZ(1,IORDER(3,NF))-XYZ(1,IORDER(2,NF))
74         Y2     = XYZ(2,IORDER(3,NF))-XYZ(2,IORDER(2,NF))
75         Z2     = XYZ(3,IORDER(3,NF))-XYZ(3,IORDER(2,NF))
76         A      = Y1*Z2 - Y2*Z1
77         IF (A .GT. 0.)  A = 1.
78         IF (A .LT. 0.)  A =-1.
79         B      = X2*Z1 - X1*Z2
80         IF (B .GT. 0.)  B = 1.
81         IF (B .LT. 0.)  B =-1.
82         C      = X1*Y2 - X2*Y1
83         IF (C .GT. 0.)  C = 1.
84         IF (C .LT. 0.)  C =-1.
85         D      =-(A*XYZ(1,IORDER(1,NF)) +
86      +            B*XYZ(2,IORDER(1,NF)) +
87      +            C*XYZ(3,IORDER(1,NF)) )
88         CG(JCG+KCGAA) = A
89         CG(JCG+KCGBB) = B
90         CG(JCG+KCGCC) = C
91         CG(JCG+KCGDD) = D
92         CG(JCG+KCGNE) = 4.
93         JCG    = JCG + LCGFAC
94         DO 200 NE=1,4
95           NE2    = NE + 1
96           IF (NE .EQ. 4) NE2 = 1
97           CG(JCG+KCGAE) = 0.
98           CG(JCG+KCGX1) = XYZ(1,IORDER(NE,NF))
99           CG(JCG+KCGY1) = XYZ(2,IORDER(NE,NF))
100           CG(JCG+KCGZ1) = XYZ(3,IORDER(NE,NF))
101           CG(JCG+KCGX2) = XYZ(1,IORDER(NE2,NF))
102           CG(JCG+KCGY2) = XYZ(2,IORDER(NE2,NF))
103           CG(JCG+KCGZ2) = XYZ(3,IORDER(NE2,NF))
104           JCG    = JCG + LCGEDG
105   200     CONTINUE
106   300   CONTINUE
107 *
108   999 RETURN
109       END