Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/solids/CSG/src/G4UPara.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/solids/CSG/src/G4UPara.cc (Version 11.3.0) and /geometry/solids/CSG/src/G4UPara.cc (Version 10.4.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
                                                   >>  25 //
                                                   >>  26 //
                                                   >>  27 // $Id:$
                                                   >>  28 //
 25 //                                                 29 // 
 26 // Implementation for G4UPara wrapper class        30 // Implementation for G4UPara wrapper class
 27 //                                             << 
 28 // 13.09.13 G.Cosmo, CERN/PH                   << 
 29 // -------------------------------------------     31 // --------------------------------------------------------------------
 30                                                    32 
 31 #include "G4Para.hh"                               33 #include "G4Para.hh"
 32 #include "G4UPara.hh"                              34 #include "G4UPara.hh"
 33                                                    35 
 34 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G     36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
 35                                                    37 
 36 #include "G4AffineTransform.hh"                    38 #include "G4AffineTransform.hh"
 37 #include "G4VPVParameterisation.hh"                39 #include "G4VPVParameterisation.hh"
 38 #include "G4BoundingEnvelope.hh"                   40 #include "G4BoundingEnvelope.hh"
 39                                                    41 
 40 using namespace CLHEP;                             42 using namespace CLHEP;
 41                                                    43 
 42 //////////////////////////////////////////////     44 //////////////////////////////////////////////////////////////////////////
 43 //                                                 45 //
 44 //  Constructor - set & check half widths          46 //  Constructor - set & check half widths
 45                                                    47 
 46 G4UPara::G4UPara(const G4String& pName,            48 G4UPara::G4UPara(const G4String& pName,
 47                        G4double pDx, G4double      49                        G4double pDx, G4double pDy, G4double pDz,
 48                        G4double pAlpha, G4doub     50                        G4double pAlpha, G4double pTheta, G4double pPhi)
 49   : Base_t(pName, pDx, pDy, pDz, pAlpha, pThet     51   : Base_t(pName, pDx, pDy, pDz, pAlpha, pTheta, pPhi)
 50 {                                                  52 {
 51   fTalpha = std::tan(pAlpha);                      53   fTalpha = std::tan(pAlpha);
 52   fTthetaCphi = std::tan(pTheta)*std::cos(pPhi     54   fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
 53   fTthetaSphi = std::tan(pTheta)*std::sin(pPhi     55   fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
 54   CheckParameters();                               56   CheckParameters();
 55   MakePlanes();                                    57   MakePlanes();
 56 }                                                  58 }
 57                                                    59 
 58 //////////////////////////////////////////////     60 //////////////////////////////////////////////////////////////////////////
 59 //                                                 61 //
 60 // Constructor - design of trapezoid based on      62 // Constructor - design of trapezoid based on 8 vertices
 61                                                    63 
 62 G4UPara::G4UPara( const G4String& pName,           64 G4UPara::G4UPara( const G4String& pName,
 63                   const G4ThreeVector pt[8] )      65                   const G4ThreeVector pt[8] )
 64   : Base_t(pName)                                  66   : Base_t(pName)
 65 {                                                  67 {
 66   // Find dimensions and trigonometric values      68   // Find dimensions and trigonometric values
 67   //                                               69   //
 68   G4double fDx = (pt[3].x() - pt[2].x())*0.5;      70   G4double fDx = (pt[3].x() - pt[2].x())*0.5;
 69   G4double fDy = (pt[2].y() - pt[1].y())*0.5;      71   G4double fDy = (pt[2].y() - pt[1].y())*0.5;
 70   G4double fDz = pt[7].z();                        72   G4double fDz = pt[7].z();
 71   SetDimensions(fDx, fDy, fDz);                    73   SetDimensions(fDx, fDy, fDz);
 72   CheckParameters(); // check dimensions           74   CheckParameters(); // check dimensions
 73                                                    75 
 74   fTalpha = (pt[2].x() + pt[3].x() - pt[1].x()     76   fTalpha = (pt[2].x() + pt[3].x() - pt[1].x() - pt[0].x())*0.25/fDy;
 75   fTthetaCphi = (pt[4].x() + fDy*fTalpha + fDx     77   fTthetaCphi = (pt[4].x() + fDy*fTalpha + fDx)/fDz;
 76   fTthetaSphi = (pt[4].y() + fDy)/fDz;             78   fTthetaSphi = (pt[4].y() + fDy)/fDz;
 77   SetAlpha(std::atan(fTalpha));                    79   SetAlpha(std::atan(fTalpha));
 78   SetTheta(std::atan(std::sqrt(fTthetaSphi*fTt     80   SetTheta(std::atan(std::sqrt(fTthetaSphi*fTthetaSphi
 79                               + fTthetaCphi*fT     81                               + fTthetaCphi*fTthetaCphi)));
 80   SetPhi (std::atan2(fTthetaSphi, fTthetaCphi)     82   SetPhi (std::atan2(fTthetaSphi, fTthetaCphi));
 81   MakePlanes();                                    83   MakePlanes();
 82                                                    84 
 83   // Recompute vertices                            85   // Recompute vertices
 84   //                                               86   //
 85   G4ThreeVector v[8];                              87   G4ThreeVector v[8];
 86   G4double DyTalpha = fDy*fTalpha;                 88   G4double DyTalpha = fDy*fTalpha;
 87   G4double DzTthetaSphi = fDz*fTthetaSphi;         89   G4double DzTthetaSphi = fDz*fTthetaSphi;
 88   G4double DzTthetaCphi = fDz*fTthetaCphi;         90   G4double DzTthetaCphi = fDz*fTthetaCphi;
 89   v[0].set(-DzTthetaCphi-DyTalpha-fDx, -DzTthe     91   v[0].set(-DzTthetaCphi-DyTalpha-fDx, -DzTthetaSphi-fDy, -fDz);
 90   v[1].set(-DzTthetaCphi-DyTalpha+fDx, -DzTthe     92   v[1].set(-DzTthetaCphi-DyTalpha+fDx, -DzTthetaSphi-fDy, -fDz);
 91   v[2].set(-DzTthetaCphi+DyTalpha-fDx, -DzTthe     93   v[2].set(-DzTthetaCphi+DyTalpha-fDx, -DzTthetaSphi+fDy, -fDz);
 92   v[3].set(-DzTthetaCphi+DyTalpha+fDx, -DzTthe     94   v[3].set(-DzTthetaCphi+DyTalpha+fDx, -DzTthetaSphi+fDy, -fDz);
 93   v[4].set( DzTthetaCphi-DyTalpha-fDx,  DzTthe     95   v[4].set( DzTthetaCphi-DyTalpha-fDx,  DzTthetaSphi-fDy,  fDz);
 94   v[5].set( DzTthetaCphi-DyTalpha+fDx,  DzTthe     96   v[5].set( DzTthetaCphi-DyTalpha+fDx,  DzTthetaSphi-fDy,  fDz);
 95   v[6].set( DzTthetaCphi+DyTalpha-fDx,  DzTthe     97   v[6].set( DzTthetaCphi+DyTalpha-fDx,  DzTthetaSphi+fDy,  fDz);
 96   v[7].set( DzTthetaCphi+DyTalpha+fDx,  DzTthe     98   v[7].set( DzTthetaCphi+DyTalpha+fDx,  DzTthetaSphi+fDy,  fDz);
 97                                                    99 
 98   // Compare with original vertices               100   // Compare with original vertices
 99   //                                              101   //
100   for (G4int i=0; i<8; ++i)                       102   for (G4int i=0; i<8; ++i)
101   {                                               103   {
102     G4double delx = std::abs(pt[i].x() - v[i].    104     G4double delx = std::abs(pt[i].x() - v[i].x());
103     G4double dely = std::abs(pt[i].y() - v[i].    105     G4double dely = std::abs(pt[i].y() - v[i].y());
104     G4double delz = std::abs(pt[i].z() - v[i].    106     G4double delz = std::abs(pt[i].z() - v[i].z());
105     G4double discrepancy = std::max(std::max(d    107     G4double discrepancy = std::max(std::max(delx,dely),delz);
106     if (discrepancy > 0.1*kCarTolerance)          108     if (discrepancy > 0.1*kCarTolerance)
107     {                                             109     {
108       std::ostringstream message;                 110       std::ostringstream message;
109       G4long oldprc = message.precision(16);   << 111       G4int oldprc = message.precision(16);
110       message << "Invalid vertice coordinates     112       message << "Invalid vertice coordinates for Solid: " << GetName()
111               << "\nVertix #" << i << ", discr    113               << "\nVertix #" << i << ", discrepancy = " << discrepancy
112               << "\n  original   : " << pt[i]     114               << "\n  original   : " << pt[i]
113               << "\n  recomputed : " << v[i];     115               << "\n  recomputed : " << v[i];
114       G4cout.precision(oldprc);                   116       G4cout.precision(oldprc);
115       G4Exception("G4UPara::G4UPara()", "GeomS    117       G4Exception("G4UPara::G4UPara()", "GeomSolids0002",
116                   FatalException, message);       118                   FatalException, message);
117                                                   119 
118     }                                             120     }
119   }                                               121   }
120 }                                                 122 }
121                                                   123 
122 //////////////////////////////////////////////    124 //////////////////////////////////////////////////////////////////////////
123 //                                                125 //
124 // Fake default constructor - sets only member    126 // Fake default constructor - sets only member data and allocates memory
125 //                            for usage restri    127 //                            for usage restricted to object persistency
126                                                   128 
127 G4UPara::G4UPara( __void__& a )                   129 G4UPara::G4UPara( __void__& a )
128   : Base_t(a)                                     130   : Base_t(a)
129 {                                                 131 {
130   SetAllParameters(1., 1., 1., 0., 0., 0.);       132   SetAllParameters(1., 1., 1., 0., 0., 0.);
131   fRebuildPolyhedron = false;                     133   fRebuildPolyhedron = false;
132 }                                                 134 }
133                                                   135 
134 //////////////////////////////////////////////    136 //////////////////////////////////////////////////////////////////////////
135 //                                                137 //
136 // Destructor                                     138 // Destructor
137                                                   139 
138 G4UPara::~G4UPara() = default;                 << 140 G4UPara::~G4UPara()
                                                   >> 141 {
                                                   >> 142 }
139                                                   143 
140 //////////////////////////////////////////////    144 //////////////////////////////////////////////////////////////////////////
141 //                                                145 //
142 // Copy constructor                               146 // Copy constructor
143                                                   147 
144 G4UPara::G4UPara(const G4UPara& rhs)              148 G4UPara::G4UPara(const G4UPara& rhs)
145   : Base_t(rhs), fTalpha(rhs.fTalpha),            149   : Base_t(rhs), fTalpha(rhs.fTalpha),
146     fTthetaCphi(rhs.fTthetaCphi),fTthetaSphi(r    150     fTthetaCphi(rhs.fTthetaCphi),fTthetaSphi(rhs.fTthetaSphi)
147 {                                                 151 {
148   for (G4int i=0; i<4; ++i) { fPlanes[i] = rhs    152   for (G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
149 }                                                 153 }
150                                                   154 
151 //////////////////////////////////////////////    155 //////////////////////////////////////////////////////////////////////////
152 //                                                156 //
153 // Assignment operator                            157 // Assignment operator
154                                                   158 
155 G4UPara& G4UPara::operator = (const G4UPara& r    159 G4UPara& G4UPara::operator = (const G4UPara& rhs)
156 {                                                 160 {
157    // Check assignment to self                    161    // Check assignment to self
158    //                                             162    //
159    if (this == &rhs)  { return *this; }           163    if (this == &rhs)  { return *this; }
160                                                   164 
161    // Copy base class data                        165    // Copy base class data
162    //                                             166    //
163    Base_t::operator=(rhs);                        167    Base_t::operator=(rhs);
164                                                   168 
165    // Copy data                                   169    // Copy data
166    //                                             170    //
167    fTalpha = rhs.fTalpha;                         171    fTalpha = rhs.fTalpha;
168    fTthetaCphi = rhs.fTthetaCphi;                 172    fTthetaCphi = rhs.fTthetaCphi;
169    fTthetaSphi = rhs.fTthetaSphi;                 173    fTthetaSphi = rhs.fTthetaSphi;
170    for (G4int i=0; i<4; ++i) { fPlanes[i] = rh    174    for (G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
171                                                   175 
172    return *this;                                  176    return *this;
173 }                                                 177 }
174                                                   178 
175 //////////////////////////////////////////////    179 //////////////////////////////////////////////////////////////////////////
176 //                                                180 //
177 // Accessors & modifiers                          181 // Accessors & modifiers
178                                                   182 
179 G4double G4UPara::GetZHalfLength() const          183 G4double G4UPara::GetZHalfLength() const
180 {                                                 184 {
181   return GetZ();                                  185   return GetZ();
182 }                                                 186 }
183 G4double G4UPara::GetYHalfLength() const          187 G4double G4UPara::GetYHalfLength() const
184 {                                                 188 {
185   return GetY();                                  189   return GetY();
186 }                                                 190 }
187 G4double G4UPara::GetXHalfLength() const          191 G4double G4UPara::GetXHalfLength() const
188 {                                                 192 {
189   return GetX();                               << 193   return GetZ();
190 }                                                 194 }
191 G4ThreeVector G4UPara::GetSymAxis() const         195 G4ThreeVector G4UPara::GetSymAxis() const
192 {                                                 196 {
193   return G4ThreeVector(fTthetaCphi,fTthetaSphi    197   return G4ThreeVector(fTthetaCphi,fTthetaSphi,1.).unit();
194 }                                                 198 }
195 G4double G4UPara::GetTanAlpha() const             199 G4double G4UPara::GetTanAlpha() const
196 {                                                 200 {
197   return fTalpha;                                 201   return fTalpha;
198 }                                                 202 }
199                                                   203 
200 G4double G4UPara::GetPhi() const               << 
201 {                                              << 
202    return std::atan2(fTthetaSphi,fTthetaCphi); << 
203 }                                              << 
204                                                << 
205 G4double G4UPara::GetTheta() const             << 
206 {                                              << 
207    return std::atan(std::sqrt(fTthetaCphi*fTth << 
208                               +fTthetaSphi*fTt << 
209 }                                              << 
210                                                << 
211 G4double G4UPara::GetAlpha() const             << 
212 {                                              << 
213   return std::atan(fTalpha);                   << 
214 }                                              << 
215                                                << 
216 void G4UPara::SetXHalfLength(G4double val)        204 void G4UPara::SetXHalfLength(G4double val)
217 {                                                 205 {
218   SetDimensions(val, GetY(), GetZ());             206   SetDimensions(val, GetY(), GetZ());
219   fRebuildPolyhedron = true;                      207   fRebuildPolyhedron = true;
220                                                   208 
221   CheckParameters();                              209   CheckParameters();
222   MakePlanes();                                   210   MakePlanes();
223 }                                                 211 }
224 void G4UPara::SetYHalfLength(G4double val)        212 void G4UPara::SetYHalfLength(G4double val)
225 {                                                 213 {
226   SetDimensions(GetX(), val, GetZ());             214   SetDimensions(GetX(), val, GetZ());
227   fRebuildPolyhedron = true;                      215   fRebuildPolyhedron = true;
228                                                   216 
229   CheckParameters();                              217   CheckParameters();
230   MakePlanes();                                   218   MakePlanes();
231 }                                                 219 }
232 void G4UPara::SetZHalfLength(G4double val)        220 void G4UPara::SetZHalfLength(G4double val)
233 {                                                 221 {
234   SetDimensions(GetX(), GetY(), val);             222   SetDimensions(GetX(), GetY(), val);
235   fRebuildPolyhedron = true;                      223   fRebuildPolyhedron = true;
236                                                   224 
237   CheckParameters();                              225   CheckParameters();
238   MakePlanes();                                   226   MakePlanes();
239 }                                                 227 }
240 void G4UPara::SetAlpha(G4double alpha)            228 void G4UPara::SetAlpha(G4double alpha)
241 {                                                 229 {
242   Base_t::SetAlpha(alpha);                        230   Base_t::SetAlpha(alpha);
243   fTalpha = std::tan(alpha);                      231   fTalpha = std::tan(alpha);
244   fRebuildPolyhedron = true;                      232   fRebuildPolyhedron = true;
245                                                   233 
246   MakePlanes();                                   234   MakePlanes();
247 }                                                 235 }
248 void G4UPara::SetTanAlpha(G4double val)           236 void G4UPara::SetTanAlpha(G4double val)
249 {                                                 237 {
250   fTalpha = val;                                  238   fTalpha = val;
251   fRebuildPolyhedron = true;                      239   fRebuildPolyhedron = true;
252                                                   240 
253   MakePlanes();                                   241   MakePlanes();
254 }                                                 242 }
255 void G4UPara::SetThetaAndPhi(double pTheta, do    243 void G4UPara::SetThetaAndPhi(double pTheta, double pPhi)
256 {                                                 244 {
257   Base_t::SetThetaAndPhi(pTheta, pPhi);           245   Base_t::SetThetaAndPhi(pTheta, pPhi);
258   G4double tanTheta = std::tan(pTheta);           246   G4double tanTheta = std::tan(pTheta);
259   fTthetaCphi = tanTheta*std::cos(pPhi);          247   fTthetaCphi = tanTheta*std::cos(pPhi);
260   fTthetaSphi = tanTheta*std::sin(pPhi);          248   fTthetaSphi = tanTheta*std::sin(pPhi);
261   fRebuildPolyhedron = true;                      249   fRebuildPolyhedron = true;
262                                                   250 
263   MakePlanes();                                   251   MakePlanes();
264 }                                                 252 }
265                                                   253 
266 //////////////////////////////////////////////    254 //////////////////////////////////////////////////////////////////////////
267 //                                                255 //
268 // Set all parameters, as for constructor - se    256 // Set all parameters, as for constructor - set and check half-widths
269                                                   257 
270 void G4UPara::SetAllParameters(G4double pDx, G    258 void G4UPara::SetAllParameters(G4double pDx, G4double pDy, G4double pDz,
271                                G4double pAlpha    259                                G4double pAlpha, G4double pTheta, G4double pPhi)
272 {                                                 260 {
273   // Reset data of the base class                 261   // Reset data of the base class
274   fRebuildPolyhedron = true;                      262   fRebuildPolyhedron = true;
275                                                   263 
276   // Set parameters                               264   // Set parameters
277   SetDimensions(pDx, pDy, pDz);                   265   SetDimensions(pDx, pDy, pDz);
278   Base_t::SetAlpha(pAlpha);                       266   Base_t::SetAlpha(pAlpha);
279   Base_t::SetThetaAndPhi(pTheta, pPhi);           267   Base_t::SetThetaAndPhi(pTheta, pPhi);
280   fTalpha = std::tan(pAlpha);                     268   fTalpha = std::tan(pAlpha);
281   fTthetaCphi = std::tan(pTheta)*std::cos(pPhi    269   fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
282   fTthetaSphi = std::tan(pTheta)*std::sin(pPhi    270   fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
283                                                   271 
284   CheckParameters();                              272   CheckParameters();
285   MakePlanes();                                   273   MakePlanes();
286 }                                                 274 }
287                                                   275 
288 //////////////////////////////////////////////    276 //////////////////////////////////////////////////////////////////////////
289 //                                                277 //
290 // Check dimensions                               278 // Check dimensions
291                                                   279 
292 void G4UPara::CheckParameters()                   280 void G4UPara::CheckParameters()
293 {                                                 281 {
294   if (GetX() < 2*kCarTolerance ||                 282   if (GetX() < 2*kCarTolerance ||
295       GetY() < 2*kCarTolerance ||                 283       GetY() < 2*kCarTolerance ||
296       GetZ() < 2*kCarTolerance)                   284       GetZ() < 2*kCarTolerance)
297   {                                               285   {
298     std::ostringstream message;                   286     std::ostringstream message;
299     message << "Invalid (too small or negative    287     message << "Invalid (too small or negative) dimensions for Solid: "
300             << GetName()                          288             << GetName()
301             << "\n  X - " << GetX()               289             << "\n  X - " << GetX()
302             << "\n  Y - " << GetY()               290             << "\n  Y - " << GetY()
303             << "\n  Z - " << GetZ();              291             << "\n  Z - " << GetZ();
304     G4Exception("G4UPara::CheckParameters()",     292     G4Exception("G4UPara::CheckParameters()", "GeomSolids0002",
305                 FatalException, message);         293                 FatalException, message);
306   }                                               294   }
307 }                                                 295 }
308                                                   296 
309 //////////////////////////////////////////////    297 //////////////////////////////////////////////////////////////////////////
310 //                                                298 //
311 // Set side planes                                299 // Set side planes
312                                                   300 
313 void G4UPara::MakePlanes()                        301 void G4UPara::MakePlanes()
314 {                                                 302 {
315   G4ThreeVector vx(1, 0, 0);                      303   G4ThreeVector vx(1, 0, 0);
316   G4ThreeVector vy(fTalpha, 1, 0);                304   G4ThreeVector vy(fTalpha, 1, 0);
317   G4ThreeVector vz(fTthetaCphi, fTthetaSphi, 1    305   G4ThreeVector vz(fTthetaCphi, fTthetaSphi, 1);
318                                                   306 
319   // Set -Y & +Y planes                           307   // Set -Y & +Y planes
320   //                                              308   //
321   G4ThreeVector ynorm = (vx.cross(vz)).unit();    309   G4ThreeVector ynorm = (vx.cross(vz)).unit();
322                                                   310 
323   fPlanes[0].a = 0.;                              311   fPlanes[0].a = 0.;
324   fPlanes[0].b = ynorm.y();                       312   fPlanes[0].b = ynorm.y();
325   fPlanes[0].c = ynorm.z();                       313   fPlanes[0].c = ynorm.z();
326   fPlanes[0].d = fPlanes[0].b*GetY(); // point    314   fPlanes[0].d = fPlanes[0].b*GetY(); // point (0,fDy,0) is on plane
327                                                   315 
328   fPlanes[1].a =  0.;                             316   fPlanes[1].a =  0.;
329   fPlanes[1].b = -fPlanes[0].b;                   317   fPlanes[1].b = -fPlanes[0].b;
330   fPlanes[1].c = -fPlanes[0].c;                   318   fPlanes[1].c = -fPlanes[0].c;
331   fPlanes[1].d =  fPlanes[0].d;                   319   fPlanes[1].d =  fPlanes[0].d;
332                                                   320 
333   // Set -X & +X planes                           321   // Set -X & +X planes
334   //                                              322   //
335   G4ThreeVector xnorm = (vz.cross(vy)).unit();    323   G4ThreeVector xnorm = (vz.cross(vy)).unit();
336                                                   324 
337   fPlanes[2].a = xnorm.x();                       325   fPlanes[2].a = xnorm.x();
338   fPlanes[2].b = xnorm.y();                       326   fPlanes[2].b = xnorm.y();
339   fPlanes[2].c = xnorm.z();                       327   fPlanes[2].c = xnorm.z();
340   fPlanes[2].d = fPlanes[2].a*GetZ(); // point    328   fPlanes[2].d = fPlanes[2].a*GetZ(); // point (fDx,0,0) is on plane
341                                                   329 
342   fPlanes[3].a = -fPlanes[2].a;                   330   fPlanes[3].a = -fPlanes[2].a;
343   fPlanes[3].b = -fPlanes[2].b;                   331   fPlanes[3].b = -fPlanes[2].b;
344   fPlanes[3].c = -fPlanes[2].c;                   332   fPlanes[3].c = -fPlanes[2].c;
345   fPlanes[3].d =  fPlanes[2].d;                   333   fPlanes[3].d =  fPlanes[2].d;
346 }                                                 334 }
347                                                   335 
348 //////////////////////////////////////////////    336 //////////////////////////////////////////////////////////////////////////
349 //                                                337 //
350 // Dispatch to parameterisation for replicatio    338 // Dispatch to parameterisation for replication mechanism dimension
351 // computation & modification                     339 // computation & modification
352                                                   340 
353 void G4UPara::ComputeDimensions(      G4VPVPar    341 void G4UPara::ComputeDimensions(      G4VPVParameterisation* p,
354                                 const G4int n,    342                                 const G4int n,
355                                 const G4VPhysi    343                                 const G4VPhysicalVolume* pRep )
356 {                                                 344 {
357   p->ComputeDimensions(*(G4Para*)this,n,pRep);    345   p->ComputeDimensions(*(G4Para*)this,n,pRep);
358 }                                                 346 }
359                                                   347 
360 //////////////////////////////////////////////    348 //////////////////////////////////////////////////////////////////////////
361 //                                                349 //
362 // Get bounding box                               350 // Get bounding box
363                                                   351 
364 void G4UPara::BoundingLimits(G4ThreeVector& pM    352 void G4UPara::BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const
365 {                                                 353 {
366   G4double dz = GetZHalfLength();                 354   G4double dz = GetZHalfLength();
367   G4double dx = GetXHalfLength();                 355   G4double dx = GetXHalfLength();
368   G4double dy = GetYHalfLength();                 356   G4double dy = GetYHalfLength();
369                                                   357 
370   G4double x0 = dz*fTthetaCphi;                   358   G4double x0 = dz*fTthetaCphi;
371   G4double x1 = dy*GetTanAlpha();                 359   G4double x1 = dy*GetTanAlpha();
372   G4double xmin =                                 360   G4double xmin =
373     std::min(                                     361     std::min(
374     std::min(                                     362     std::min(
375     std::min(-x0-x1-dx,-x0+x1-dx),x0-x1-dx),x0    363     std::min(-x0-x1-dx,-x0+x1-dx),x0-x1-dx),x0+x1-dx);
376   G4double xmax =                                 364   G4double xmax =
377     std::max(                                     365     std::max(
378     std::max(                                     366     std::max(
379     std::max(-x0-x1+dx,-x0+x1+dx),x0-x1+dx),x0    367     std::max(-x0-x1+dx,-x0+x1+dx),x0-x1+dx),x0+x1+dx);
380                                                   368 
381   G4double y0 = dz*fTthetaSphi;                   369   G4double y0 = dz*fTthetaSphi;
382   G4double ymin = std::min(-y0-dy,y0-dy);         370   G4double ymin = std::min(-y0-dy,y0-dy);
383   G4double ymax = std::max(-y0+dy,y0+dy);         371   G4double ymax = std::max(-y0+dy,y0+dy);
384                                                   372 
385   pMin.set(xmin,ymin,-dz);                        373   pMin.set(xmin,ymin,-dz);
386   pMax.set(xmax,ymax, dz);                        374   pMax.set(xmax,ymax, dz);
387                                                   375 
388   // Check correctness of the bounding box        376   // Check correctness of the bounding box
389   //                                              377   //
390   if (pMin.x() >= pMax.x() || pMin.y() >= pMax    378   if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
391   {                                               379   {
392     std::ostringstream message;                   380     std::ostringstream message;
393     message << "Bad bounding box (min >= max)     381     message << "Bad bounding box (min >= max) for solid: "
394             << GetName() << " !"                  382             << GetName() << " !"
395             << "\npMin = " << pMin                383             << "\npMin = " << pMin
396             << "\npMax = " << pMax;               384             << "\npMax = " << pMax;
397     G4Exception("G4UPara::BoundingLimits()", "    385     G4Exception("G4UPara::BoundingLimits()", "GeomMgt0001",
398                 JustWarning, message);            386                 JustWarning, message);
399     StreamInfo(G4cout);                           387     StreamInfo(G4cout);
400   }                                               388   }
401 }                                                 389 }
402                                                   390 
403 //////////////////////////////////////////////    391 //////////////////////////////////////////////////////////////////////////
404 //                                                392 //
405 // Calculate extent under transform and specif    393 // Calculate extent under transform and specified limit
406                                                   394 
407 G4bool G4UPara::CalculateExtent( const EAxis p    395 G4bool G4UPara::CalculateExtent( const EAxis pAxis,
408                                  const G4Voxel    396                                  const G4VoxelLimits& pVoxelLimit,
409                                  const G4Affin    397                                  const G4AffineTransform& pTransform,
410                                        G4doubl    398                                        G4double& pMin, G4double& pMax ) const
411 {                                                 399 {
412   G4ThreeVector bmin, bmax;                       400   G4ThreeVector bmin, bmax;
413   G4bool exist;                                   401   G4bool exist;
414                                                   402 
415   // Check bounding box (bbox)                    403   // Check bounding box (bbox)
416   //                                              404   //
417   BoundingLimits(bmin,bmax);                      405   BoundingLimits(bmin,bmax);
418   G4BoundingEnvelope bbox(bmin,bmax);             406   G4BoundingEnvelope bbox(bmin,bmax);
419 #ifdef G4BBOX_EXTENT                              407 #ifdef G4BBOX_EXTENT
420   if (true) return bbox.CalculateExtent(pAxis,    408   if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
421 #endif                                            409 #endif
422   if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVox    410   if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
423   {                                               411   {
424     return exist = pMin < pMax;                << 412     return exist = (pMin < pMax) ? true : false;
425   }                                               413   }
426                                                   414 
427   // Set bounding envelope (benv) and calculat    415   // Set bounding envelope (benv) and calculate extent
428   //                                              416   //
429   G4double dz = GetZHalfLength();                 417   G4double dz = GetZHalfLength();
430   G4double dx = GetXHalfLength();                 418   G4double dx = GetXHalfLength();
431   G4double dy = GetYHalfLength();                 419   G4double dy = GetYHalfLength();
432                                                   420 
433   G4double x0 = dz*fTthetaCphi;                   421   G4double x0 = dz*fTthetaCphi;
434   G4double x1 = dy*GetTanAlpha();                 422   G4double x1 = dy*GetTanAlpha();
435   G4double y0 = dz*fTthetaSphi;                   423   G4double y0 = dz*fTthetaSphi;
436                                                   424 
437   G4ThreeVectorList baseA(4), baseB(4);           425   G4ThreeVectorList baseA(4), baseB(4);
438   baseA[0].set(-x0-x1-dx,-y0-dy,-dz);             426   baseA[0].set(-x0-x1-dx,-y0-dy,-dz);
439   baseA[1].set(-x0-x1+dx,-y0-dy,-dz);             427   baseA[1].set(-x0-x1+dx,-y0-dy,-dz);
440   baseA[2].set(-x0+x1+dx,-y0+dy,-dz);             428   baseA[2].set(-x0+x1+dx,-y0+dy,-dz);
441   baseA[3].set(-x0+x1-dx,-y0+dy,-dz);             429   baseA[3].set(-x0+x1-dx,-y0+dy,-dz);
442                                                   430 
443   baseB[0].set(+x0-x1-dx, y0-dy, dz);             431   baseB[0].set(+x0-x1-dx, y0-dy, dz);
444   baseB[1].set(+x0-x1+dx, y0-dy, dz);             432   baseB[1].set(+x0-x1+dx, y0-dy, dz);
445   baseB[2].set(+x0+x1+dx, y0+dy, dz);             433   baseB[2].set(+x0+x1+dx, y0+dy, dz);
446   baseB[3].set(+x0+x1-dx, y0+dy, dz);             434   baseB[3].set(+x0+x1-dx, y0+dy, dz);
447                                                   435 
448   std::vector<const G4ThreeVectorList *> polyg    436   std::vector<const G4ThreeVectorList *> polygons(2);
449   polygons[0] = &baseA;                           437   polygons[0] = &baseA;
450   polygons[1] = &baseB;                           438   polygons[1] = &baseB;
451                                                   439 
452   G4BoundingEnvelope benv(bmin,bmax,polygons);    440   G4BoundingEnvelope benv(bmin,bmax,polygons);
453   exist = benv.CalculateExtent(pAxis,pVoxelLim    441   exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
454   return exist;                                   442   return exist;
455 }                                                 443 }
456                                                   444 
457 //////////////////////////////////////////////    445 //////////////////////////////////////////////////////////////////////////
458 //                                                446 //
459 // Make a clone of the object                     447 // Make a clone of the object
460 //                                                448 //
461 G4VSolid* G4UPara::Clone() const                  449 G4VSolid* G4UPara::Clone() const
462 {                                                 450 {
463   return new G4UPara(*this);                      451   return new G4UPara(*this);
464 }                                                 452 }
465                                                   453 
466 //////////////////////////////////////////////    454 //////////////////////////////////////////////////////////////////////////
467 //                                                455 //
468 // Methods for visualisation                      456 // Methods for visualisation
469                                                   457 
470 G4Polyhedron* G4UPara::CreatePolyhedron () con    458 G4Polyhedron* G4UPara::CreatePolyhedron () const
471 {                                                 459 {
472   return new G4PolyhedronPara(GetX(), GetY(),     460   return new G4PolyhedronPara(GetX(), GetY(), GetZ(),
473                               GetAlpha(), GetT    461                               GetAlpha(), GetTheta(), GetPhi());
474 }                                                 462 }
475                                                   463 
476 #endif  // G4GEOM_USE_USOLIDS                     464 #endif  // G4GEOM_USE_USOLIDS
477                                                   465