Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/solids/CSG/src/G4UCons.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/G4UCons.cc (Version 11.3.0) and /geometry/solids/CSG/src/G4UCons.cc (Version 10.3.p2)


  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 //                                                 25 //
 26 // Implementation for G4UCons wrapper class    << 
 27 //                                                 26 //
 28 // 30.10.13 G.Cosmo, CERN/PH                   <<  27 // $Id:$
                                                   >>  28 //
                                                   >>  29 //
                                                   >>  30 // Implementation for G4UCons wrapper class
 29 // -------------------------------------------     31 // --------------------------------------------------------------------
 30                                                    32 
 31 #include "G4Cons.hh"                               33 #include "G4Cons.hh"
 32 #include "G4UCons.hh"                              34 #include "G4UCons.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 "G4GeomTools.hh"                          38 #include "G4GeomTools.hh"
 37 #include "G4AffineTransform.hh"                    39 #include "G4AffineTransform.hh"
 38 #include "G4VPVParameterisation.hh"                40 #include "G4VPVParameterisation.hh"
 39 #include "G4BoundingEnvelope.hh"                   41 #include "G4BoundingEnvelope.hh"
 40                                                    42 
 41 using namespace CLHEP;                             43 using namespace CLHEP;
 42                                                    44 
 43 //////////////////////////////////////////////     45 //////////////////////////////////////////////////////////////////////////
 44 //                                                 46 //
 45 // constructor - check parameters, convert ang     47 // constructor - check parameters, convert angles so 0<sphi+dpshi<=2_PI
 46 //               - note if pDPhi>2PI then rese     48 //               - note if pDPhi>2PI then reset to 2PI
 47                                                    49 
 48 G4UCons::G4UCons( const G4String& pName,           50 G4UCons::G4UCons( const G4String& pName,
 49                         G4double  pRmin1, G4do     51                         G4double  pRmin1, G4double pRmax1,
 50                         G4double  pRmin2, G4do     52                         G4double  pRmin2, G4double pRmax2,
 51                         G4double pDz,              53                         G4double pDz,
 52                         G4double pSPhi, G4doub     54                         G4double pSPhi, G4double pDPhi)
 53   : Base_t(pName, pRmin1, pRmax1, pRmin2, pRma <<  55   : G4USolid(pName, new UCons(pName, pRmin1, pRmax1, pRmin2, pRmax2,
                                                   >>  56                                      pDz, pSPhi, pDPhi))
 54 {                                                  57 {
 55 }                                                  58 }
 56                                                    59 
 57 //////////////////////////////////////////////     60 ///////////////////////////////////////////////////////////////////////
 58 //                                                 61 //
 59 // Fake default constructor - sets only member     62 // Fake default constructor - sets only member data and allocates memory
 60 //                            for usage restri     63 //                            for usage restricted to object persistency.
 61 //                                                 64 //
 62 G4UCons::G4UCons( __void__& a )                    65 G4UCons::G4UCons( __void__& a )
 63   : Base_t(a)                                  <<  66   : G4USolid(a)
 64 {                                                  67 {
 65 }                                                  68 }
 66                                                    69 
 67 //////////////////////////////////////////////     70 ///////////////////////////////////////////////////////////////////////
 68 //                                                 71 //
 69 // Destructor                                      72 // Destructor
 70                                                    73 
 71 G4UCons::~G4UCons() = default;                 <<  74 G4UCons::~G4UCons()
                                                   >>  75 {
                                                   >>  76 }
 72                                                    77 
 73 //////////////////////////////////////////////     78 //////////////////////////////////////////////////////////////////////////
 74 //                                                 79 //
 75 // Copy constructor                                80 // Copy constructor
 76                                                    81 
 77 G4UCons::G4UCons(const G4UCons& rhs)               82 G4UCons::G4UCons(const G4UCons& rhs)
 78   : Base_t(rhs)                                <<  83   : G4USolid(rhs)
 79 {                                                  84 {
 80 }                                                  85 }
 81                                                    86 
 82 //////////////////////////////////////////////     87 //////////////////////////////////////////////////////////////////////////
 83 //                                                 88 //
 84 // Assignment operator                             89 // Assignment operator
 85                                                    90 
 86 G4UCons& G4UCons::operator = (const G4UCons& r     91 G4UCons& G4UCons::operator = (const G4UCons& rhs) 
 87 {                                                  92 {
 88    // Check assignment to self                     93    // Check assignment to self
 89    //                                              94    //
 90    if (this == &rhs)  { return *this; }            95    if (this == &rhs)  { return *this; }
 91                                                    96 
 92    // Copy base class data                         97    // Copy base class data
 93    //                                              98    //
 94    Base_t::operator=(rhs);                     <<  99    G4USolid::operator=(rhs);
 95                                                   100 
 96    return *this;                                  101    return *this;
 97 }                                                 102 }
 98                                                   103 
 99 //////////////////////////////////////////////    104 /////////////////////////////////////////////////////////////////////////
100 //                                                105 //
101 // Accessors and modifiers                        106 // Accessors and modifiers
102                                                   107 
103 G4double G4UCons::GetInnerRadiusMinusZ() const    108 G4double G4UCons::GetInnerRadiusMinusZ() const
104 {                                                 109 {
105   return GetRmin1();                           << 110   return GetShape()->GetInnerRadiusMinusZ();
106 }                                                 111 }
107 G4double G4UCons::GetOuterRadiusMinusZ() const    112 G4double G4UCons::GetOuterRadiusMinusZ() const
108 {                                                 113 {
109   return GetRmax1();                           << 114   return GetShape()->GetOuterRadiusMinusZ();
110 }                                                 115 }
111 G4double G4UCons::GetInnerRadiusPlusZ() const     116 G4double G4UCons::GetInnerRadiusPlusZ() const
112 {                                                 117 {
113   return GetRmin2();                           << 118   return GetShape()->GetInnerRadiusPlusZ();
114 }                                                 119 }
115 G4double G4UCons::GetOuterRadiusPlusZ() const     120 G4double G4UCons::GetOuterRadiusPlusZ() const
116 {                                                 121 {
117   return GetRmax2();                           << 122   return GetShape()->GetOuterRadiusPlusZ();
118 }                                                 123 }
119 G4double G4UCons::GetZHalfLength() const          124 G4double G4UCons::GetZHalfLength() const
120 {                                                 125 {
121   return GetDz();                              << 126   return GetShape()->GetZHalfLength();
122 }                                                 127 }
123 G4double G4UCons::GetStartPhiAngle() const        128 G4double G4UCons::GetStartPhiAngle() const
124 {                                                 129 {
125   return GetSPhi();                            << 130   return GetShape()->GetStartPhiAngle();
126 }                                                 131 }
127 G4double G4UCons::GetDeltaPhiAngle() const        132 G4double G4UCons::GetDeltaPhiAngle() const
128 {                                                 133 {
129   return GetDPhi();                            << 134   return GetShape()->GetDeltaPhiAngle();
130 }                                                 135 }
131 G4double G4UCons::GetSinStartPhi() const          136 G4double G4UCons::GetSinStartPhi() const
132 {                                                 137 {
133   G4double phi = GetStartPhiAngle();           << 138   G4double phi = GetShape()->GetStartPhiAngle();
134   return std::sin(phi);                           139   return std::sin(phi);
135 }                                                 140 }
136 G4double G4UCons::GetCosStartPhi() const          141 G4double G4UCons::GetCosStartPhi() const
137 {                                                 142 {
138   G4double phi = GetStartPhiAngle();           << 143   G4double phi = GetShape()->GetStartPhiAngle();
139   return std::cos(phi);                           144   return std::cos(phi);
140 }                                                 145 }
141 G4double G4UCons::GetSinEndPhi() const            146 G4double G4UCons::GetSinEndPhi() const
142 {                                                 147 {
143   G4double phi = GetStartPhiAngle() + GetDelta << 148   G4double phi = GetShape()->GetStartPhiAngle() +
                                                   >> 149     GetShape()->GetDeltaPhiAngle();
144   return std::sin(phi);                           150   return std::sin(phi);
145 }                                                 151 }
146 G4double G4UCons::GetCosEndPhi() const            152 G4double G4UCons::GetCosEndPhi() const
147 {                                                 153 {
148   G4double phi = GetStartPhiAngle() + GetDelta << 154   G4double phi = GetShape()->GetStartPhiAngle() +
                                                   >> 155     GetShape()->GetDeltaPhiAngle();
149   return std::cos(phi);                           156   return std::cos(phi);
150 }                                                 157 }
151                                                   158   
152 void G4UCons::SetInnerRadiusMinusZ(G4double Rm    159 void G4UCons::SetInnerRadiusMinusZ(G4double Rmin1)
153 {                                                 160 {
154   SetRmin1(Rmin1);                             << 161   GetShape()->SetInnerRadiusMinusZ(Rmin1);
155   fRebuildPolyhedron = true;                      162   fRebuildPolyhedron = true;
156 }                                                 163 }
157 void G4UCons::SetOuterRadiusMinusZ(G4double Rm    164 void G4UCons::SetOuterRadiusMinusZ(G4double Rmax1)
158 {                                                 165 {
159   SetRmax1(Rmax1);                             << 166   GetShape()->SetOuterRadiusMinusZ(Rmax1);
160   fRebuildPolyhedron = true;                      167   fRebuildPolyhedron = true;
161 }                                                 168 }
162 void G4UCons::SetInnerRadiusPlusZ(G4double Rmi    169 void G4UCons::SetInnerRadiusPlusZ(G4double Rmin2)
163 {                                                 170 {
164   SetRmin2(Rmin2);                             << 171   GetShape()->SetInnerRadiusPlusZ(Rmin2);
165   fRebuildPolyhedron = true;                      172   fRebuildPolyhedron = true;
166 }                                                 173 }
167 void G4UCons::SetOuterRadiusPlusZ(G4double Rma    174 void G4UCons::SetOuterRadiusPlusZ(G4double Rmax2)
168 {                                                 175 {
169   SetRmax2(Rmax2);                             << 176   GetShape()->SetOuterRadiusPlusZ(Rmax2);
170   fRebuildPolyhedron = true;                      177   fRebuildPolyhedron = true;
171 }                                                 178 }
172 void G4UCons::SetZHalfLength(G4double newDz)      179 void G4UCons::SetZHalfLength(G4double newDz)
173 {                                                 180 {
174   SetDz(newDz);                                << 181   GetShape()->SetZHalfLength(newDz);
175   fRebuildPolyhedron = true;                      182   fRebuildPolyhedron = true;
176 }                                                 183 }
177 void G4UCons::SetStartPhiAngle(G4double newSPh << 184 void G4UCons::SetStartPhiAngle(G4double newSPhi, G4bool trig)
178 {                                                 185 {
179   SetSPhi(newSPhi);                            << 186   GetShape()->SetStartPhiAngle(newSPhi, trig);
180   fRebuildPolyhedron = true;                      187   fRebuildPolyhedron = true;
181 }                                                 188 }
182 void G4UCons::SetDeltaPhiAngle(G4double newDPh    189 void G4UCons::SetDeltaPhiAngle(G4double newDPhi)
183 {                                                 190 {
184   SetDPhi(newDPhi);                            << 191   GetShape()->SetDeltaPhiAngle(newDPhi);
185   fRebuildPolyhedron = true;                      192   fRebuildPolyhedron = true;
186 }                                                 193 }
187                                                   194 
188 //////////////////////////////////////////////    195 /////////////////////////////////////////////////////////////////////////
189 //                                                196 //
190 // Dispatch to parameterisation for replicatio    197 // Dispatch to parameterisation for replication mechanism dimension
191 // computation & modification.                    198 // computation & modification.
192                                                   199 
193 void G4UCons::ComputeDimensions(      G4VPVPar    200 void G4UCons::ComputeDimensions(      G4VPVParameterisation* p,
194                                 const G4int       201                                 const G4int                  n,
195                                 const G4VPhysi    202                                 const G4VPhysicalVolume*     pRep    )
196 {                                                 203 {
197   p->ComputeDimensions(*(G4Cons*)this,n,pRep);    204   p->ComputeDimensions(*(G4Cons*)this,n,pRep);
198 }                                                 205 }
199                                                   206 
200 //////////////////////////////////////////////    207 //////////////////////////////////////////////////////////////////////////
201 //                                                208 //
202 // Make a clone of the object                     209 // Make a clone of the object
203                                                   210 
204 G4VSolid* G4UCons::Clone() const                  211 G4VSolid* G4UCons::Clone() const
205 {                                                 212 {
206   return new G4UCons(*this);                      213   return new G4UCons(*this);
207 }                                                 214 }
208                                                   215 
209 //////////////////////////////////////////////    216 //////////////////////////////////////////////////////////////////////////
210 //                                                217 //
211 // Get bounding box                               218 // Get bounding box
212                                                   219 
213 void G4UCons::BoundingLimits(G4ThreeVector& pM << 220 void G4UCons::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
214 {                                                 221 {
215   static G4bool checkBBox = true;                 222   static G4bool checkBBox = true;
216                                                   223 
217   G4double rmin = std::min(GetInnerRadiusMinus    224   G4double rmin = std::min(GetInnerRadiusMinusZ(),GetInnerRadiusPlusZ());
218   G4double rmax = std::max(GetOuterRadiusMinus    225   G4double rmax = std::max(GetOuterRadiusMinusZ(),GetOuterRadiusPlusZ());
219   G4double dz   = GetZHalfLength();               226   G4double dz   = GetZHalfLength();
220                                                   227 
221   // Find bounding box                            228   // Find bounding box
222   //                                              229   //
223   if (GetDeltaPhiAngle() < twopi)                 230   if (GetDeltaPhiAngle() < twopi)
224   {                                               231   {
225     G4TwoVector vmin,vmax;                        232     G4TwoVector vmin,vmax;
226     G4GeomTools::DiskExtent(rmin,rmax,            233     G4GeomTools::DiskExtent(rmin,rmax,
227                             GetSinStartPhi(),G    234                             GetSinStartPhi(),GetCosStartPhi(),
228                             GetSinEndPhi(),Get    235                             GetSinEndPhi(),GetCosEndPhi(),
229                             vmin,vmax);           236                             vmin,vmax);
230     pMin.set(vmin.x(),vmin.y(),-dz);              237     pMin.set(vmin.x(),vmin.y(),-dz);
231     pMax.set(vmax.x(),vmax.y(), dz);              238     pMax.set(vmax.x(),vmax.y(), dz);
232   }                                               239   }
233   else                                            240   else
234   {                                               241   {
235     pMin.set(-rmax,-rmax,-dz);                    242     pMin.set(-rmax,-rmax,-dz);
236     pMax.set( rmax, rmax, dz);                    243     pMax.set( rmax, rmax, dz);
237   }                                               244   }
238                                                   245 
239   // Check correctness of the bounding box        246   // Check correctness of the bounding box
240   //                                              247   //
241   if (pMin.x() >= pMax.x() || pMin.y() >= pMax    248   if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
242   {                                               249   {
243     std::ostringstream message;                   250     std::ostringstream message;
244     message << "Bad bounding box (min >= max)     251     message << "Bad bounding box (min >= max) for solid: "
245             << GetName() << " !"                  252             << GetName() << " !"
246             << "\npMin = " << pMin                253             << "\npMin = " << pMin
247             << "\npMax = " << pMax;               254             << "\npMax = " << pMax;
248     G4Exception("G4UCons::BoundingLimits()", " << 255     G4Exception("G4UCons::Extent()", "GeomMgt0001", JustWarning, message);
249                 JustWarning, message);         << 
250     StreamInfo(G4cout);                           256     StreamInfo(G4cout);
251   }                                               257   }
252                                                   258 
253   // Check consistency of bounding boxes          259   // Check consistency of bounding boxes
254   //                                              260   //
255   if (checkBBox)                                  261   if (checkBBox)
256   {                                               262   {
257     U3Vector vmin, vmax;                       << 263     UVector3 vmin, vmax;
258     Extent(vmin,vmax);                         << 264     GetShape()->Extent(vmin,vmax);
259     if (std::abs(pMin.x()-vmin.x()) > kCarTole    265     if (std::abs(pMin.x()-vmin.x()) > kCarTolerance ||
260         std::abs(pMin.y()-vmin.y()) > kCarTole    266         std::abs(pMin.y()-vmin.y()) > kCarTolerance ||
261         std::abs(pMin.z()-vmin.z()) > kCarTole    267         std::abs(pMin.z()-vmin.z()) > kCarTolerance ||
262         std::abs(pMax.x()-vmax.x()) > kCarTole    268         std::abs(pMax.x()-vmax.x()) > kCarTolerance ||
263         std::abs(pMax.y()-vmax.y()) > kCarTole    269         std::abs(pMax.y()-vmax.y()) > kCarTolerance ||
264         std::abs(pMax.z()-vmax.z()) > kCarTole    270         std::abs(pMax.z()-vmax.z()) > kCarTolerance)
265     {                                             271     {
266       std::ostringstream message;                 272       std::ostringstream message;
267       message << "Inconsistency in bounding bo    273       message << "Inconsistency in bounding boxes for solid: "
268               << GetName() << " !"                274               << GetName() << " !"
269               << "\nBBox min: wrapper = " << p    275               << "\nBBox min: wrapper = " << pMin << " solid = " << vmin
270               << "\nBBox max: wrapper = " << p    276               << "\nBBox max: wrapper = " << pMax << " solid = " << vmax;
271       G4Exception("G4UCons::BoundingLimits()", << 277       G4Exception("G4UCons::Extent()", "GeomMgt0001", JustWarning, message);
272                   JustWarning, message);       << 
273       checkBBox = false;                          278       checkBBox = false;
274     }                                             279     }
275   }                                               280   }
276 }                                                 281 }
277                                                   282 
278 //////////////////////////////////////////////    283 /////////////////////////////////////////////////////////////////////////
279 //                                                284 //
280 // Calculate extent under transform and specif    285 // Calculate extent under transform and specified limit
281                                                   286 
282 G4bool                                            287 G4bool
283 G4UCons::CalculateExtent(const EAxis pAxis,       288 G4UCons::CalculateExtent(const EAxis pAxis,
284                          const G4VoxelLimits&     289                          const G4VoxelLimits& pVoxelLimit,
285                          const G4AffineTransfo    290                          const G4AffineTransform& pTransform,
286                                G4double& pMin,    291                                G4double& pMin, G4double& pMax) const
287 {                                                 292 {
288   G4ThreeVector bmin, bmax;                       293   G4ThreeVector bmin, bmax;
289   G4bool exist;                                   294   G4bool exist;
290                                                   295 
291   // Get bounding box                             296   // Get bounding box
292   BoundingLimits(bmin,bmax);                   << 297   Extent(bmin,bmax);
293                                                   298 
294   // Check bounding box                           299   // Check bounding box
295   G4BoundingEnvelope bbox(bmin,bmax);             300   G4BoundingEnvelope bbox(bmin,bmax);
296 #ifdef G4BBOX_EXTENT                              301 #ifdef G4BBOX_EXTENT
297   if (true) return bbox.CalculateExtent(pAxis,    302   if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
298 #endif                                            303 #endif
299   if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVox    304   if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
300   {                                               305   {
301     return exist = pMin < pMax;                << 306     return exist = (pMin < pMax) ? true : false;
302   }                                               307   }
303                                                   308 
304   // Get parameters of the solid                  309   // Get parameters of the solid
305   G4double rmin1 = GetInnerRadiusMinusZ();        310   G4double rmin1 = GetInnerRadiusMinusZ();
306   G4double rmax1 = GetOuterRadiusMinusZ();        311   G4double rmax1 = GetOuterRadiusMinusZ();
307   G4double rmin2 = GetInnerRadiusPlusZ();         312   G4double rmin2 = GetInnerRadiusPlusZ();
308   G4double rmax2 = GetOuterRadiusPlusZ();         313   G4double rmax2 = GetOuterRadiusPlusZ();
309   G4double dz    = GetZHalfLength();              314   G4double dz    = GetZHalfLength();
310   G4double dphi  = GetDeltaPhiAngle();            315   G4double dphi  = GetDeltaPhiAngle();
311                                                   316 
312   // Find bounding envelope and calculate exte    317   // Find bounding envelope and calculate extent
313   //                                              318   //
314   const G4int NSTEPS = 24;            // numbe    319   const G4int NSTEPS = 24;            // number of steps for whole circle
315   G4double astep  = twopi/NSTEPS;     // max a    320   G4double astep  = twopi/NSTEPS;     // max angle for one step
316   G4int    ksteps = (dphi <= astep) ? 1 : (G4i    321   G4int    ksteps = (dphi <= astep) ? 1 : (G4int)((dphi-deg)/astep) + 1;
317   G4double ang    = dphi/ksteps;                  322   G4double ang    = dphi/ksteps;
318                                                   323 
319   G4double sinHalf = std::sin(0.5*ang);           324   G4double sinHalf = std::sin(0.5*ang);
320   G4double cosHalf = std::cos(0.5*ang);           325   G4double cosHalf = std::cos(0.5*ang);
321   G4double sinStep = 2.*sinHalf*cosHalf;          326   G4double sinStep = 2.*sinHalf*cosHalf;
322   G4double cosStep = 1. - 2.*sinHalf*sinHalf;     327   G4double cosStep = 1. - 2.*sinHalf*sinHalf;
323   G4double rext1   = rmax1/cosHalf;               328   G4double rext1   = rmax1/cosHalf;
324   G4double rext2   = rmax2/cosHalf;               329   G4double rext2   = rmax2/cosHalf;
325                                                   330 
326   // bounding envelope for full cone without h    331   // bounding envelope for full cone without hole consists of two polygons,
327   // in other cases it is a sequence of quadri    332   // in other cases it is a sequence of quadrilaterals
328   if (rmin1 == 0 && rmin2 == 0 && dphi == twop    333   if (rmin1 == 0 && rmin2 == 0 && dphi == twopi)
329   {                                               334   {
330     G4double sinCur = sinHalf;                    335     G4double sinCur = sinHalf;
331     G4double cosCur = cosHalf;                    336     G4double cosCur = cosHalf;
332                                                   337 
333     G4ThreeVectorList baseA(NSTEPS),baseB(NSTE    338     G4ThreeVectorList baseA(NSTEPS),baseB(NSTEPS);
334     for (G4int k=0; k<NSTEPS; ++k)                339     for (G4int k=0; k<NSTEPS; ++k)
335     {                                             340     {
336       baseA[k].set(rext1*cosCur,rext1*sinCur,-    341       baseA[k].set(rext1*cosCur,rext1*sinCur,-dz);
337       baseB[k].set(rext2*cosCur,rext2*sinCur,     342       baseB[k].set(rext2*cosCur,rext2*sinCur, dz);
338                                                   343 
339       G4double sinTmp = sinCur;                   344       G4double sinTmp = sinCur;
340       sinCur = sinCur*cosStep + cosCur*sinStep    345       sinCur = sinCur*cosStep + cosCur*sinStep;
341       cosCur = cosCur*cosStep - sinTmp*sinStep    346       cosCur = cosCur*cosStep - sinTmp*sinStep;
342     }                                             347     }
343     std::vector<const G4ThreeVectorList *> pol    348     std::vector<const G4ThreeVectorList *> polygons(2);
344     polygons[0] = &baseA;                         349     polygons[0] = &baseA;
345     polygons[1] = &baseB;                         350     polygons[1] = &baseB;
346     G4BoundingEnvelope benv(bmin,bmax,polygons    351     G4BoundingEnvelope benv(bmin,bmax,polygons);
347     exist = benv.CalculateExtent(pAxis,pVoxelL    352     exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
348   }                                               353   }
349   else                                            354   else
350   {                                               355   {
351     G4double sinStart = GetSinStartPhi();         356     G4double sinStart = GetSinStartPhi();
352     G4double cosStart = GetCosStartPhi();         357     G4double cosStart = GetCosStartPhi();
353     G4double sinEnd   = GetSinEndPhi();           358     G4double sinEnd   = GetSinEndPhi();
354     G4double cosEnd   = GetCosEndPhi();           359     G4double cosEnd   = GetCosEndPhi();
355     G4double sinCur   = sinStart*cosHalf + cos    360     G4double sinCur   = sinStart*cosHalf + cosStart*sinHalf;
356     G4double cosCur   = cosStart*cosHalf - sin    361     G4double cosCur   = cosStart*cosHalf - sinStart*sinHalf;
357                                                   362 
358     // set quadrilaterals                         363     // set quadrilaterals
359     G4ThreeVectorList pols[NSTEPS+2];             364     G4ThreeVectorList pols[NSTEPS+2];
360     for (G4int k=0; k<ksteps+2; ++k) pols[k].r    365     for (G4int k=0; k<ksteps+2; ++k) pols[k].resize(4);
361     pols[0][0].set(rmin2*cosStart,rmin2*sinSta    366     pols[0][0].set(rmin2*cosStart,rmin2*sinStart, dz);
362     pols[0][1].set(rmin1*cosStart,rmin1*sinSta    367     pols[0][1].set(rmin1*cosStart,rmin1*sinStart,-dz);
363     pols[0][2].set(rmax1*cosStart,rmax1*sinSta    368     pols[0][2].set(rmax1*cosStart,rmax1*sinStart,-dz);
364     pols[0][3].set(rmax2*cosStart,rmax2*sinSta    369     pols[0][3].set(rmax2*cosStart,rmax2*sinStart, dz);
365     for (G4int k=1; k<ksteps+1; ++k)              370     for (G4int k=1; k<ksteps+1; ++k)
366     {                                             371     {
367       pols[k][0].set(rmin2*cosCur,rmin2*sinCur    372       pols[k][0].set(rmin2*cosCur,rmin2*sinCur, dz);
368       pols[k][1].set(rmin1*cosCur,rmin1*sinCur    373       pols[k][1].set(rmin1*cosCur,rmin1*sinCur,-dz);
369       pols[k][2].set(rext1*cosCur,rext1*sinCur    374       pols[k][2].set(rext1*cosCur,rext1*sinCur,-dz);
370       pols[k][3].set(rext2*cosCur,rext2*sinCur    375       pols[k][3].set(rext2*cosCur,rext2*sinCur, dz);
371                                                   376 
372       G4double sinTmp = sinCur;                   377       G4double sinTmp = sinCur;
373       sinCur = sinCur*cosStep + cosCur*sinStep    378       sinCur = sinCur*cosStep + cosCur*sinStep;
374       cosCur = cosCur*cosStep - sinTmp*sinStep    379       cosCur = cosCur*cosStep - sinTmp*sinStep;
375     }                                             380     }
376     pols[ksteps+1][0].set(rmin2*cosEnd,rmin2*s    381     pols[ksteps+1][0].set(rmin2*cosEnd,rmin2*sinEnd, dz);
377     pols[ksteps+1][1].set(rmin1*cosEnd,rmin1*s    382     pols[ksteps+1][1].set(rmin1*cosEnd,rmin1*sinEnd,-dz);
378     pols[ksteps+1][2].set(rmax1*cosEnd,rmax1*s    383     pols[ksteps+1][2].set(rmax1*cosEnd,rmax1*sinEnd,-dz);
379     pols[ksteps+1][3].set(rmax2*cosEnd,rmax2*s    384     pols[ksteps+1][3].set(rmax2*cosEnd,rmax2*sinEnd, dz);
380                                                   385 
381     // set envelope and calculate extent          386     // set envelope and calculate extent
382     std::vector<const G4ThreeVectorList *> pol    387     std::vector<const G4ThreeVectorList *> polygons;
383     polygons.resize(ksteps+2);                    388     polygons.resize(ksteps+2);
384     for (G4int k=0; k<ksteps+2; ++k) polygons[    389     for (G4int k=0; k<ksteps+2; ++k) polygons[k] = &pols[k];
385     G4BoundingEnvelope benv(bmin,bmax,polygons    390     G4BoundingEnvelope benv(bmin,bmax,polygons);
386     exist = benv.CalculateExtent(pAxis,pVoxelL    391     exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
387   }                                               392   }
388   return exist;                                   393   return exist;
389 }                                                 394 }
390                                                   395 
391 //////////////////////////////////////////////    396 //////////////////////////////////////////////////////////////////////////
392 //                                                397 //
393 // Create polyhedron for visualization            398 // Create polyhedron for visualization
394                                                   399 
395 G4Polyhedron* G4UCons::CreatePolyhedron() cons    400 G4Polyhedron* G4UCons::CreatePolyhedron() const
396 {                                                 401 {
397   return new G4PolyhedronCons(GetInnerRadiusMi    402   return new G4PolyhedronCons(GetInnerRadiusMinusZ(),
398                               GetOuterRadiusMi    403                               GetOuterRadiusMinusZ(),
399                               GetInnerRadiusPl    404                               GetInnerRadiusPlusZ(),
400                               GetOuterRadiusPl    405                               GetOuterRadiusPlusZ(),
401                               GetZHalfLength()    406                               GetZHalfLength(),
402                               GetStartPhiAngle    407                               GetStartPhiAngle(),
403                               GetDeltaPhiAngle    408                               GetDeltaPhiAngle());
404 }                                                 409 }
405                                                   410 
406 #endif  // G4GEOM_USE_USOLIDS                     411 #endif  // G4GEOM_USE_USOLIDS
407                                                   412