Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/solids/specific/src/G4Polyhedra.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/specific/src/G4Polyhedra.cc (Version 11.3.0) and /geometry/solids/specific/src/G4Polyhedra.cc (Version 6.1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 // Implementation of G4Polyhedra, a CSG polyhe <<  23 //
 27 // as an inherited class of G4VCSGfaceted.     <<  24 // $Id: G4Polyhedra.cc,v 1.17 2003/11/22 10:11:41 gcosmo Exp $
                                                   >>  25 // GEANT4 tag $Name: geant4-06-00-patch-01 $
                                                   >>  26 //
                                                   >>  27 // 
                                                   >>  28 // --------------------------------------------------------------------
                                                   >>  29 // GEANT 4 class source file
                                                   >>  30 //
                                                   >>  31 //
                                                   >>  32 // G4Polyhedra.cc
                                                   >>  33 //
                                                   >>  34 // Implementation of a CSG polyhedra, as an inherited class of G4VCSGfaceted.
                                                   >>  35 //
                                                   >>  36 // To be done:
                                                   >>  37 //    * Cracks: there are probably small cracks in the seams between the
                                                   >>  38 //      phi face (G4PolyPhiFace) and sides (G4PolyhedraSide) that are not
                                                   >>  39 //      entirely leakproof. Also, I am not sure all vertices are leak proof.
                                                   >>  40 //    * Many optimizations are possible, but not implemented.
                                                   >>  41 //    * Visualization needs to be updated outside of this routine.
 28 //                                                 42 //
 29 // Utility classes:                                43 // Utility classes:
 30 //    * G4EnclosingCylinder: decided a quick c <<  44 //    * G4EnclosingCylinder: I decided a quick check of geometry would be a
 31 //      good idea (for CPU speed). If the quic     45 //      good idea (for CPU speed). If the quick check fails, the regular
 32 //      full-blown G4VCSGfaceted version is in     46 //      full-blown G4VCSGfaceted version is invoked.
 33 //    * G4ReduciblePolygon: Really meant as a      47 //    * G4ReduciblePolygon: Really meant as a check of input parameters,
 34 //      this utility class also "converts" the     48 //      this utility class also "converts" the GEANT3-like PGON/PCON
 35 //      arguments into the newer ones.             49 //      arguments into the newer ones.
 36 // Both these classes are implemented outside      50 // Both these classes are implemented outside this file because they are
 37 // shared with G4Polycone.                         51 // shared with G4Polycone.
 38 //                                                 52 //
 39 // Author: David C. Williams (davidw@scipp.ucs << 
 40 // -------------------------------------------     53 // --------------------------------------------------------------------
 41                                                    54 
 42 #include "G4Polyhedra.hh"                          55 #include "G4Polyhedra.hh"
 43                                                    56 
 44 #if !defined(G4GEOM_USE_UPOLYHEDRA)            << 
 45                                                << 
 46 #include "G4PolyhedraSide.hh"                      57 #include "G4PolyhedraSide.hh"
 47 #include "G4PolyPhiFace.hh"                        58 #include "G4PolyPhiFace.hh"
 48                                                    59 
 49 #include "G4GeomTools.hh"                      <<  60 #include "G4Polyhedron.hh"
 50 #include "G4VoxelLimits.hh"                    << 
 51 #include "G4AffineTransform.hh"                << 
 52 #include "G4BoundingEnvelope.hh"               << 
 53                                                << 
 54 #include "G4QuickRand.hh"                      << 
 55                                                << 
 56 #include "G4EnclosingCylinder.hh"                  61 #include "G4EnclosingCylinder.hh"
 57 #include "G4ReduciblePolygon.hh"                   62 #include "G4ReduciblePolygon.hh"
 58 #include "G4VPVParameterisation.hh"                63 #include "G4VPVParameterisation.hh"
 59                                                    64 
 60 namespace                                      <<  65 //
 61 {                                              << 
 62   G4Mutex surface_elementsMutex = G4MUTEX_INIT << 
 63 }                                              << 
 64                                                << 
 65 using namespace CLHEP;                         << 
 66                                                << 
 67 // Constructor (GEANT3 style parameters)           66 // Constructor (GEANT3 style parameters)
 68 //                                                 67 //
 69 // GEANT3 PGON radii are specified in the dist     68 // GEANT3 PGON radii are specified in the distance to the norm of each face.
 70 //                                             <<  69 //  
 71 G4Polyhedra::G4Polyhedra( const G4String& name <<  70 G4Polyhedra::G4Polyhedra( const G4String& name, 
 72                                 G4double phiSt     71                                 G4double phiStart,
 73                                 G4double thePh     72                                 G4double thePhiTotal,
 74                                 G4int theNumSi <<  73                                 G4int theNumSide,  
 75                                 G4int numZPlan     74                                 G4int numZPlanes,
 76                           const G4double zPlan     75                           const G4double zPlane[],
 77                           const G4double rInne     76                           const G4double rInner[],
 78                           const G4double rOute     77                           const G4double rOuter[]  )
 79   : G4VCSGfaceted( name )                          78   : G4VCSGfaceted( name )
 80 {                                                  79 {
 81   if (theNumSide <= 0)                             80   if (theNumSide <= 0)
 82   {                                                81   {
 83     std::ostringstream message;                <<  82     G4cerr << "ERROR - G4Polyhedra::G4Polyhedra(): " << GetName() << G4endl
 84     message << "Solid must have at least one s <<  83            << "        No sides specified !"
 85             << "        No sides specified !"; <<  84            << G4endl;
 86     G4Exception("G4Polyhedra::G4Polyhedra()",  <<  85     G4Exception("G4Polyhedra::G4Polyhedra()", "InvalidSetup",
 87                 FatalErrorInArgument, message) <<  86                 FatalException, "Solid must have at least one side.");
 88   }                                                87   }
 89                                                    88 
 90   //                                               89   //
 91   // Calculate conversion factor from G3 radiu     90   // Calculate conversion factor from G3 radius to G4 radius
 92   //                                               91   //
 93   G4double phiTotal = thePhiTotal;                 92   G4double phiTotal = thePhiTotal;
 94   if ( (phiTotal <=0) || (phiTotal >= twopi*(1 <<  93   if ( (phiTotal <=0) || (phiTotal >= 2*M_PI*(1-DBL_EPSILON)) )
 95     { phiTotal = twopi; }                      <<  94     phiTotal = 2*M_PI;
 96   G4double convertRad = std::cos(0.5*phiTotal/ <<  95   G4double convertRad = cos(0.5*phiTotal/theNumSide);
 97                                                    96 
 98   //                                               97   //
 99   // Some historical stuff                         98   // Some historical stuff
100   //                                               99   //
101   original_parameters = new G4PolyhedraHistori    100   original_parameters = new G4PolyhedraHistorical;
102                                                << 101   
103   original_parameters->numSide = theNumSide;      102   original_parameters->numSide = theNumSide;
104   original_parameters->Start_angle = phiStart;    103   original_parameters->Start_angle = phiStart;
105   original_parameters->Opening_angle = phiTota    104   original_parameters->Opening_angle = phiTotal;
106   original_parameters->Num_z_planes = numZPlan    105   original_parameters->Num_z_planes = numZPlanes;
107   original_parameters->Z_values = new G4double    106   original_parameters->Z_values = new G4double[numZPlanes];
108   original_parameters->Rmin = new G4double[num    107   original_parameters->Rmin = new G4double[numZPlanes];
109   original_parameters->Rmax = new G4double[num    108   original_parameters->Rmax = new G4double[numZPlanes];
110                                                   109 
111   for (G4int i=0; i<numZPlanes; ++i)           << 110   G4int i;
                                                   >> 111   for (i=0; i<numZPlanes; i++)
112   {                                               112   {
113     if (( i < numZPlanes-1) && ( zPlane[i] ==     113     if (( i < numZPlanes-1) && ( zPlane[i] == zPlane[i+1] ))
114     {                                             114     {
115       if( (rInner[i]   > rOuter[i+1])             115       if( (rInner[i]   > rOuter[i+1])
116         ||(rInner[i+1] > rOuter[i])   )           116         ||(rInner[i+1] > rOuter[i])   )
117       {                                           117       {
118         DumpInfo();                               118         DumpInfo();
119         std::ostringstream message;            << 119         G4cerr << "ERROR - G4Polyhedra::G4Polyhedra()"
120         message << "Cannot create a Polyhedra  << 120                << G4endl
121                 << G4endl                      << 121                << "        Segments are not contiguous !" << G4endl
122                 << "        Segments are not c << 122                << "        rMin[" << i << "] = " << rInner[i]
123                 << "        rMin[" << i << "]  << 123                << " -- rMax[" << i+1 << "] = " << rOuter[i+1] << G4endl
124                 << " -- rMax[" << i+1 << "] =  << 124                << "        rMin[" << i+1 << "] = " << rInner[i+1]
125                 << "        rMin[" << i+1 << " << 125                << " -- rMax[" << i << "] = " << rOuter[i] << G4endl;
126                 << " -- rMax[" << i << "] = "  << 126         G4Exception("G4Polyhedra::G4Polyhedra()","InvalidSetup",FatalException, 
127         G4Exception("G4Polyhedra::G4Polyhedra( << 127                     "Cannot create a Polyhedra with no contiguous segments.");
128                     FatalErrorInArgument, mess << 
129       }                                           128       }
130     }                                             129     }
131     original_parameters->Z_values[i] = zPlane[    130     original_parameters->Z_values[i] = zPlane[i];
132     original_parameters->Rmin[i] = rInner[i]/c    131     original_parameters->Rmin[i] = rInner[i]/convertRad;
133     original_parameters->Rmax[i] = rOuter[i]/c    132     original_parameters->Rmax[i] = rOuter[i]/convertRad;
134   }                                               133   }
135                                                << 134   
136                                                << 135   
137   //                                              136   //
138   // Build RZ polygon using special PCON/PGON     137   // Build RZ polygon using special PCON/PGON GEANT3 constructor
139   //                                              138   //
140   auto rz = new G4ReduciblePolygon( rInner, rO << 139   G4ReduciblePolygon *rz =
                                                   >> 140     new G4ReduciblePolygon( rInner, rOuter, zPlane, numZPlanes );
141   rz->ScaleA( 1/convertRad );                     141   rz->ScaleA( 1/convertRad );
142                                                << 142   
143   //                                              143   //
144   // Do the real work                             144   // Do the real work
145   //                                              145   //
146   Create( phiStart, phiTotal, theNumSide, rz )    146   Create( phiStart, phiTotal, theNumSide, rz );
147                                                << 147   
148   delete rz;                                      148   delete rz;
149 }                                                 149 }
150                                                   150 
                                                   >> 151 
                                                   >> 152 //
151 // Constructor (generic parameters)               153 // Constructor (generic parameters)
152 //                                                154 //
153 G4Polyhedra::G4Polyhedra( const G4String& name << 155 G4Polyhedra::G4Polyhedra( const G4String& name, 
154                                 G4double phiSt    156                                 G4double phiStart,
155                                 G4double phiTo    157                                 G4double phiTotal,
156                                 G4int    theNu << 158                                 G4int    theNumSide,  
157                                 G4int    numRZ    159                                 G4int    numRZ,
158                           const G4double r[],     160                           const G4double r[],
159                           const G4double z[]      161                           const G4double z[]   )
160   : G4VCSGfaceted( name ), genericPgon(true)   << 162   : G4VCSGfaceted( name )
161 {                                                 163 {
162   if (theNumSide <= 0)                         << 164   original_parameters = 0;
163   {                                            << 165   
164     std::ostringstream message;                << 166   G4ReduciblePolygon *rz = new G4ReduciblePolygon( r, z, numRZ );
165     message << "Solid must have at least one s << 167   
166             << "        No sides specified !"; << 
167     G4Exception("G4Polyhedra::G4Polyhedra()",  << 
168                 FatalErrorInArgument, message) << 
169   }                                            << 
170                                                << 
171   auto rz = new G4ReduciblePolygon( r, z, numR << 
172                                                << 
173   Create( phiStart, phiTotal, theNumSide, rz )    168   Create( phiStart, phiTotal, theNumSide, rz );
174                                                << 169   
175   // Set original_parameters struct for consis << 
176   //                                           << 
177   SetOriginalParameters(rz);                   << 
178                                                << 
179   delete rz;                                      170   delete rz;
180 }                                                 171 }
181                                                   172 
                                                   >> 173 
                                                   >> 174 //
182 // Create                                         175 // Create
183 //                                                176 //
184 // Generic create routine, called by each cons    177 // Generic create routine, called by each constructor
185 // after conversion of arguments                  178 // after conversion of arguments
186 //                                                179 //
187 void G4Polyhedra::Create( G4double phiStart,      180 void G4Polyhedra::Create( G4double phiStart,
188                           G4double phiTotal,      181                           G4double phiTotal,
189                           G4int    theNumSide, << 182                           G4int    theNumSide,  
190                           G4ReduciblePolygon*  << 183                           G4ReduciblePolygon *rz  )
191 {                                                 184 {
192   //                                              185   //
193   // Perform checks of rz values                  186   // Perform checks of rz values
194   //                                              187   //
195   if (rz->Amin() < 0.0)                           188   if (rz->Amin() < 0.0)
196   {                                               189   {
197     std::ostringstream message;                << 190     G4cerr << "ERROR - G4Polyhedra::Create() " << GetName() << G4endl
198     message << "Illegal input parameters - " < << 191            << "        All R values must be >= 0 !"
199             << "        All R values must be > << 192            << G4endl;
200     G4Exception("G4Polyhedra::Create()", "Geom << 193     G4Exception("G4Polyhedra::Create()", "InvalidSetup",
201                 FatalErrorInArgument, message) << 194                 FatalException, "Illegal input parameters.");
202   }                                               195   }
203                                                   196 
204   G4double rzArea = rz->Area();                   197   G4double rzArea = rz->Area();
205   if (rzArea < -kCarTolerance)                    198   if (rzArea < -kCarTolerance)
206   {                                            << 
207     rz->ReverseOrder();                           199     rz->ReverseOrder();
208   }                                            << 
209   else if (rzArea < kCarTolerance)             << 
210   {                                            << 
211     std::ostringstream message;                << 
212     message << "Illegal input parameters - " < << 
213             << "        R/Z cross section is z << 
214     G4Exception("G4Polyhedra::Create()", "Geom << 
215                 FatalErrorInArgument, message) << 
216   }                                            << 
217                                                   200 
218   if ( (!rz->RemoveDuplicateVertices( kCarTole << 201   else if (rzArea < -kCarTolerance)
219     || (!rz->RemoveRedundantVertices( kCarTole << 
220   {                                               202   {
221     std::ostringstream message;                << 203     G4cerr << "ERROR - G4Polyhedra::Create() " << GetName() << G4endl
222     message << "Illegal input parameters - " < << 204            << "        R/Z cross section is zero or near zero: "
223             << "        Too few unique R/Z val << 205            << rzArea << G4endl;
224     G4Exception("G4Polyhedra::Create()", "Geom << 206     G4Exception("G4Polyhedra::Create()", "InvalidSetup",
225                 FatalErrorInArgument, message) << 207                 FatalException, "Illegal input parameters.");
226   }                                               208   }
227                                                << 209     
228   if (rz->CrossesItself( 1/kInfinity ))        << 210   if ( (!rz->RemoveDuplicateVertices( kCarTolerance ))
                                                   >> 211     || (!rz->RemoveRedundantVertices( kCarTolerance )) ) 
229   {                                               212   {
230     std::ostringstream message;                << 213     G4cerr << "ERROR - G4Polyhedra::Create() " << GetName() << G4endl
231     message << "Illegal input parameters - " < << 214            << "        Too few unique R/Z values !"
232             << "        R/Z segments cross !"; << 215            << G4endl;
233     G4Exception("G4Polyhedra::Create()", "Geom << 216     G4Exception("G4Polyhedra::Create()", "InvalidSetup",
234                 FatalErrorInArgument, message) << 217                 FatalException, "Illegal input parameters.");
                                                   >> 218   }
                                                   >> 219 
                                                   >> 220   if (rz->CrossesItself( 1/kInfinity )) 
                                                   >> 221   {
                                                   >> 222     G4cerr << "ERROR - G4Polyhedra::Create() " << GetName() << G4endl
                                                   >> 223            << "        R/Z segments cross !"
                                                   >> 224            << G4endl;
                                                   >> 225     G4Exception("G4Polyhedra::Create()", "InvalidSetup",
                                                   >> 226                 FatalException, "Illegal input parameters.");
235   }                                               227   }
236                                                   228 
237   numCorner = rz->NumVertices();                  229   numCorner = rz->NumVertices();
238                                                   230 
239                                                   231 
240   startPhi = phiStart;                            232   startPhi = phiStart;
241   while( startPhi < 0 )    // Loop checking, 1 << 233   while( startPhi < 0 ) startPhi += 2*M_PI;
242     startPhi += twopi;                         << 
243   //                                              234   //
244   // Phi opening? Account for some possible ro    235   // Phi opening? Account for some possible roundoff, and interpret
245   // nonsense value as representing no phi ope    236   // nonsense value as representing no phi opening
246   //                                              237   //
247   if ( (phiTotal <= 0) || (phiTotal > twopi*(1 << 238   if ( (phiTotal <= 0) || (phiTotal > 2.0*M_PI*(1-DBL_EPSILON)) )
248   {                                               239   {
249     phiIsOpen = false;                            240     phiIsOpen = false;
250     endPhi = startPhi + twopi;                 << 241     endPhi = phiStart+2*M_PI;
251   }                                               242   }
252   else                                            243   else
253   {                                               244   {
254     phiIsOpen = true;                             245     phiIsOpen = true;
255     endPhi = startPhi + phiTotal;              << 246     
                                                   >> 247     //
                                                   >> 248     // Convert phi into our convention
                                                   >> 249     //
                                                   >> 250     endPhi = phiStart+phiTotal;
                                                   >> 251     while( endPhi < startPhi ) endPhi += 2*M_PI;
256   }                                               252   }
257                                                << 253   
258   //                                              254   //
259   // Save number sides                            255   // Save number sides
260   //                                              256   //
261   numSide = theNumSide;                           257   numSide = theNumSide;
262                                                << 258   
263   //                                              259   //
264   // Allocate corner array.                    << 260   // Allocate corner array. 
265   //                                              261   //
266   corners = new G4PolyhedraSideRZ[numCorner];     262   corners = new G4PolyhedraSideRZ[numCorner];
267                                                   263 
268   //                                              264   //
269   // Copy corners                                 265   // Copy corners
270   //                                              266   //
271   G4ReduciblePolygonIterator iterRZ(rz);          267   G4ReduciblePolygonIterator iterRZ(rz);
272                                                << 268   
273   G4PolyhedraSideRZ *next = corners;              269   G4PolyhedraSideRZ *next = corners;
274   iterRZ.Begin();                                 270   iterRZ.Begin();
275   do    // Loop checking, 13.08.2015, G.Cosmo  << 271   do
276   {                                               272   {
277     next->r = iterRZ.GetA();                      273     next->r = iterRZ.GetA();
278     next->z = iterRZ.GetB();                      274     next->z = iterRZ.GetB();
279   } while( ++next, iterRZ.Next() );               275   } while( ++next, iterRZ.Next() );
280                                                << 276   
281   //                                              277   //
282   // Allocate face pointer array                  278   // Allocate face pointer array
283   //                                              279   //
284   numFace = phiIsOpen ? numCorner+2 : numCorne    280   numFace = phiIsOpen ? numCorner+2 : numCorner;
285   faces = new G4VCSGface*[numFace];               281   faces = new G4VCSGface*[numFace];
286                                                << 282   
287   //                                              283   //
288   // Construct side faces                         284   // Construct side faces
289   //                                              285   //
290   // To do so properly, we need to keep track     286   // To do so properly, we need to keep track of four successive RZ
291   // corners.                                     287   // corners.
292   //                                              288   //
293   // But! Don't construct a face if both point    289   // But! Don't construct a face if both points are at zero radius!
294   //                                              290   //
295   G4PolyhedraSideRZ* corner = corners,         << 291   G4PolyhedraSideRZ *corner = corners,
296                    * prev = corners + numCorne << 292                     *prev = corners + numCorner-1,
297                    * nextNext;                 << 293                     *nextNext;
298   G4VCSGface** face = faces;                   << 294   G4VCSGface   **face = faces;
299   do    // Loop checking, 13.08.2015, G.Cosmo  << 295   do
300   {                                               296   {
301     next = corner+1;                              297     next = corner+1;
302     if (next >= corners+numCorner) next = corn    298     if (next >= corners+numCorner) next = corners;
303     nextNext = next+1;                            299     nextNext = next+1;
304     if (nextNext >= corners+numCorner) nextNex    300     if (nextNext >= corners+numCorner) nextNext = corners;
305                                                << 301     
306     if (corner->r < 1/kInfinity && next->r < 1    302     if (corner->r < 1/kInfinity && next->r < 1/kInfinity) continue;
307 /*                                             << 303 
                                                   >> 304     //
308     // We must decide here if we can dare decl    305     // We must decide here if we can dare declare one of our faces
309     // as having a "valid" normal (i.e. allBeh    306     // as having a "valid" normal (i.e. allBehind = true). This
310     // is never possible if the face faces "in    307     // is never possible if the face faces "inward" in r *unless*
311     // we have only one side                      308     // we have only one side
312     //                                            309     //
313     G4bool allBehind;                             310     G4bool allBehind;
314     if ((corner->z > next->z) && (numSide > 1)    311     if ((corner->z > next->z) && (numSide > 1))
315     {                                             312     {
316       allBehind = false;                          313       allBehind = false;
317     }                                             314     }
318     else                                          315     else
319     {                                             316     {
320       //                                          317       //
321       // Otherwise, it is only true if the lin    318       // Otherwise, it is only true if the line passing
322       // through the two points of the segment    319       // through the two points of the segment do not
323       // split the r/z cross section              320       // split the r/z cross section
324       //                                          321       //
325       allBehind = !rz->BisectedBy( corner->r,     322       allBehind = !rz->BisectedBy( corner->r, corner->z,
326                                    next->r, ne    323                                    next->r, next->z, kCarTolerance );
327     }                                             324     }
328 */                                             << 325     
329     *face++ = new G4PolyhedraSide( prev, corne    326     *face++ = new G4PolyhedraSide( prev, corner, next, nextNext,
330                  numSide, startPhi, endPhi-sta    327                  numSide, startPhi, endPhi-startPhi, phiIsOpen );
331   } while( prev=corner, corner=next, corner >     328   } while( prev=corner, corner=next, corner > corners );
332                                                << 329   
333   if (phiIsOpen)                                  330   if (phiIsOpen)
334   {                                               331   {
335     //                                            332     //
336     // Construct phi open edges                   333     // Construct phi open edges
337     //                                            334     //
338     *face++ = new G4PolyPhiFace( rz, startPhi,    335     *face++ = new G4PolyPhiFace( rz, startPhi, phiTotal/numSide, endPhi );
339     *face++ = new G4PolyPhiFace( rz, endPhi,      336     *face++ = new G4PolyPhiFace( rz, endPhi,   phiTotal/numSide, startPhi );
340   }                                               337   }
341                                                << 338   
342   //                                              339   //
343   // We might have dropped a face or two: reca    340   // We might have dropped a face or two: recalculate numFace
344   //                                              341   //
345   numFace = (G4int)(face-faces);               << 342   numFace = face-faces;
346                                                << 343   
347   //                                              344   //
348   // Make enclosingCylinder                       345   // Make enclosingCylinder
349   //                                              346   //
350   enclosingCylinder =                             347   enclosingCylinder =
351     new G4EnclosingCylinder( rz, phiIsOpen, ph    348     new G4EnclosingCylinder( rz, phiIsOpen, phiStart, phiTotal );
352 }                                                 349 }
353                                                   350 
354 // Fake default constructor - sets only member << 
355 //                            for usage restri << 
356 //                                             << 
357 G4Polyhedra::G4Polyhedra( __void__& a )        << 
358   : G4VCSGfaceted(a), startPhi(0.), endPhi(0.) << 
359 {                                              << 
360 }                                              << 
361                                                   351 
                                                   >> 352 //
362 // Destructor                                     353 // Destructor
363 //                                                354 //
364 G4Polyhedra::~G4Polyhedra()                       355 G4Polyhedra::~G4Polyhedra()
365 {                                                 356 {
366   delete [] corners;                              357   delete [] corners;
367   delete original_parameters;                  << 358   if (original_parameters) delete original_parameters;
                                                   >> 359   
368   delete enclosingCylinder;                       360   delete enclosingCylinder;
369   delete fElements;                            << 
370   delete fpPolyhedron;                         << 
371   corners = nullptr;                           << 
372   original_parameters = nullptr;               << 
373   enclosingCylinder = nullptr;                 << 
374   fElements = nullptr;                         << 
375   fpPolyhedron = nullptr;                      << 
376 }                                                 361 }
377                                                   362 
                                                   >> 363 
                                                   >> 364 //
378 // Copy constructor                               365 // Copy constructor
379 //                                                366 //
380 G4Polyhedra::G4Polyhedra( const G4Polyhedra& s << 367 G4Polyhedra::G4Polyhedra( const G4Polyhedra &source )
381   : G4VCSGfaceted( source )                       368   : G4VCSGfaceted( source )
382 {                                                 369 {
383   CopyStuff( source );                            370   CopyStuff( source );
384 }                                                 371 }
385                                                   372 
                                                   >> 373 
                                                   >> 374 //
386 // Assignment operator                            375 // Assignment operator
387 //                                                376 //
388 G4Polyhedra &G4Polyhedra::operator=( const G4P << 377 const G4Polyhedra &G4Polyhedra::operator=( const G4Polyhedra &source )
389 {                                                 378 {
390   if (this == &source) return *this;              379   if (this == &source) return *this;
391                                                   380 
392   G4VCSGfaceted::operator=( source );             381   G4VCSGfaceted::operator=( source );
393                                                << 382   
394   delete [] corners;                              383   delete [] corners;
395   delete original_parameters;                  << 384   if (original_parameters) delete original_parameters;
                                                   >> 385   
396   delete enclosingCylinder;                       386   delete enclosingCylinder;
397                                                << 387   
398   CopyStuff( source );                            388   CopyStuff( source );
399                                                << 389   
400   return *this;                                   390   return *this;
401 }                                                 391 }
402                                                   392 
                                                   >> 393 
                                                   >> 394 //
403 // CopyStuff                                      395 // CopyStuff
404 //                                                396 //
405 void G4Polyhedra::CopyStuff( const G4Polyhedra << 397 void G4Polyhedra::CopyStuff( const G4Polyhedra &source )
406 {                                                 398 {
407   //                                              399   //
408   // Simple stuff                                 400   // Simple stuff
409   //                                              401   //
410   numSide    = source.numSide;                    402   numSide    = source.numSide;
411   startPhi   = source.startPhi;                << 403   startPhi  = source.startPhi;
412   endPhi     = source.endPhi;                  << 404   endPhi    = source.endPhi;
413   phiIsOpen  = source.phiIsOpen;                  405   phiIsOpen  = source.phiIsOpen;
414   numCorner  = source.numCorner;                  406   numCorner  = source.numCorner;
415   genericPgon= source.genericPgon;             << 
416                                                   407 
417   //                                              408   //
418   // The corner array                             409   // The corner array
419   //                                              410   //
420   corners = new G4PolyhedraSideRZ[numCorner];     411   corners = new G4PolyhedraSideRZ[numCorner];
421                                                << 412   
422   G4PolyhedraSideRZ* corn = corners,           << 413   G4PolyhedraSideRZ  *corn = corners,
423                    * sourceCorn = source.corne << 414         *sourceCorn = source.corners;
424   do    // Loop checking, 13.08.2015, G.Cosmo  << 415   do
425   {                                               416   {
426     *corn = *sourceCorn;                          417     *corn = *sourceCorn;
427   } while( ++sourceCorn, ++corn < corners+numC    418   } while( ++sourceCorn, ++corn < corners+numCorner );
428                                                << 419   
429   //                                              420   //
430   // Original parameters                          421   // Original parameters
431   //                                              422   //
432   if (source.original_parameters != nullptr)   << 423   if (source.original_parameters)
433   {                                               424   {
434     original_parameters =                         425     original_parameters =
435       new G4PolyhedraHistorical( *source.origi    426       new G4PolyhedraHistorical( *source.original_parameters );
436   }                                               427   }
437                                                << 428   
438   //                                              429   //
439   // Enclosing cylinder                           430   // Enclosing cylinder
440   //                                              431   //
441   enclosingCylinder = new G4EnclosingCylinder(    432   enclosingCylinder = new G4EnclosingCylinder( *source.enclosingCylinder );
442                                                << 
443   //                                           << 
444   // Surface elements                          << 
445   //                                           << 
446   delete fElements;                            << 
447   fElements = nullptr;                         << 
448                                                << 
449   //                                           << 
450   // Polyhedron                                << 
451   //                                           << 
452   fRebuildPolyhedron = false;                  << 
453   delete fpPolyhedron;                         << 
454   fpPolyhedron = nullptr;                      << 
455 }                                                 433 }
456                                                   434 
                                                   >> 435 
                                                   >> 436 //
457 // Reset                                          437 // Reset
458 //                                                438 //
459 // Recalculates and reshapes the solid, given  << 439 // Recalculates and reshapes the solid, given pre-assigned
460 // original_parameters.                           440 // original_parameters.
461 //                                                441 //
462 G4bool G4Polyhedra::Reset()                       442 G4bool G4Polyhedra::Reset()
463 {                                                 443 {
464   if (genericPgon)                             << 444   if (!original_parameters)
465   {                                               445   {
466     std::ostringstream message;                << 446     G4Exception("G4Polyhedra::Reset()", "NotApplicableConstruct",
467     message << "Solid " << GetName() << " buil << 447                 JustWarning, "Parameters NOT resetted.");
468             << G4endl << "Not applicable to th << 448     G4cerr << "Solid " << GetName() << " built using generic construct."
469     G4Exception("G4Polyhedra::Reset()", "GeomS << 449            << G4endl << "Specify original parameters first !" << G4endl;
470                 JustWarning, message, "Paramet << 450     return 1;
471     return true;                               << 
472   }                                               451   }
473                                                   452 
474   //                                              453   //
475   // Clear old setup                              454   // Clear old setup
476   //                                              455   //
477   G4VCSGfaceted::DeleteStuff();                   456   G4VCSGfaceted::DeleteStuff();
478   delete [] corners;                              457   delete [] corners;
479   delete enclosingCylinder;                       458   delete enclosingCylinder;
480   delete fElements;                            << 
481   corners = nullptr;                           << 
482   fElements = nullptr;                         << 
483   enclosingCylinder = nullptr;                 << 
484                                                   459 
485   //                                              460   //
486   // Rebuild polyhedra                            461   // Rebuild polyhedra
487   //                                              462   //
488   auto rz = new G4ReduciblePolygon( original_p << 463   G4ReduciblePolygon *rz =
489                                     original_p << 464     new G4ReduciblePolygon( original_parameters->Rmin,
490                                     original_p << 465                             original_parameters->Rmax,
491                                     original_p << 466                             original_parameters->Z_values,
492   Create( original_parameters->Start_angle,    << 467                             original_parameters->Num_z_planes );
493           original_parameters->Opening_angle,  << 468   //
                                                   >> 469   // Calculate conversion factor
                                                   >> 470   //
                                                   >> 471   G4double phiTotal = original_parameters->Opening_angle;
                                                   >> 472   if ( (phiTotal <=0) || (phiTotal >= 2*M_PI*(1-DBL_EPSILON)) )
                                                   >> 473     phiTotal = 2*M_PI;
                                                   >> 474   G4double convertRad = cos(0.5*phiTotal/original_parameters->numSide);
                                                   >> 475   rz->ScaleA( 1/convertRad );
                                                   >> 476 
                                                   >> 477   Create( original_parameters->Start_angle, phiTotal,
494           original_parameters->numSide, rz );     478           original_parameters->numSide, rz );
495   delete rz;                                      479   delete rz;
496                                                   480 
497   return false;                                << 481   return 0;
498 }                                                 482 }
499                                                   483 
                                                   >> 484 
                                                   >> 485 //
500 // Inside                                         486 // Inside
501 //                                                487 //
502 // This is an override of G4VCSGfaceted::Insid    488 // This is an override of G4VCSGfaceted::Inside, created in order
503 // to speed things up by first checking with G    489 // to speed things up by first checking with G4EnclosingCylinder.
504 //                                                490 //
505 EInside G4Polyhedra::Inside( const G4ThreeVect << 491 EInside G4Polyhedra::Inside( const G4ThreeVector &p ) const
506 {                                                 492 {
507   //                                              493   //
508   // Quick test                                   494   // Quick test
509   //                                              495   //
510   if (enclosingCylinder->MustBeOutside(p)) ret    496   if (enclosingCylinder->MustBeOutside(p)) return kOutside;
511                                                   497 
512   //                                              498   //
513   // Long answer                                  499   // Long answer
514   //                                              500   //
515   return G4VCSGfaceted::Inside(p);                501   return G4VCSGfaceted::Inside(p);
516 }                                                 502 }
517                                                   503 
                                                   >> 504 
                                                   >> 505 //
518 // DistanceToIn                                   506 // DistanceToIn
519 //                                                507 //
520 // This is an override of G4VCSGfaceted::Insid    508 // This is an override of G4VCSGfaceted::Inside, created in order
521 // to speed things up by first checking with G    509 // to speed things up by first checking with G4EnclosingCylinder.
522 //                                                510 //
523 G4double G4Polyhedra::DistanceToIn( const G4Th << 511 G4double G4Polyhedra::DistanceToIn( const G4ThreeVector &p,
524                                     const G4Th << 512                                     const G4ThreeVector &v ) const
525 {                                                 513 {
526   //                                              514   //
527   // Quick test                                   515   // Quick test
528   //                                              516   //
529   if (enclosingCylinder->ShouldMiss(p,v))         517   if (enclosingCylinder->ShouldMiss(p,v))
530     return kInfinity;                             518     return kInfinity;
531                                                << 519   
532   //                                              520   //
533   // Long answer                                  521   // Long answer
534   //                                              522   //
535   return G4VCSGfaceted::DistanceToIn( p, v );     523   return G4VCSGfaceted::DistanceToIn( p, v );
536 }                                                 524 }
537                                                   525 
                                                   >> 526 
                                                   >> 527 //
538 // DistanceToIn                                   528 // DistanceToIn
539 //                                                529 //
540 G4double G4Polyhedra::DistanceToIn( const G4Th << 530 G4double G4Polyhedra::DistanceToIn( const G4ThreeVector &p ) const
541 {                                                 531 {
542   return G4VCSGfaceted::DistanceToIn(p);          532   return G4VCSGfaceted::DistanceToIn(p);
543 }                                                 533 }
544                                                   534 
545 // Get bounding box                            << 
546 //                                             << 
547 void G4Polyhedra::BoundingLimits(G4ThreeVector << 
548                                  G4ThreeVector << 
549 {                                              << 
550   G4double rmin = kInfinity, rmax = -kInfinity << 
551   G4double zmin = kInfinity, zmax = -kInfinity << 
552   for (G4int i=0; i<GetNumRZCorner(); ++i)     << 
553   {                                            << 
554     G4PolyhedraSideRZ corner = GetCorner(i);   << 
555     if (corner.r < rmin) rmin = corner.r;      << 
556     if (corner.r > rmax) rmax = corner.r;      << 
557     if (corner.z < zmin) zmin = corner.z;      << 
558     if (corner.z > zmax) zmax = corner.z;      << 
559   }                                            << 
560                                                << 
561   G4double sphi    = GetStartPhi();            << 
562   G4double ephi    = GetEndPhi();              << 
563   G4double dphi    = IsOpen() ? ephi-sphi : tw << 
564   G4int    ksteps  = GetNumSide();             << 
565   G4double astep   = dphi/ksteps;              << 
566   G4double sinStep = std::sin(astep);          << 
567   G4double cosStep = std::cos(astep);          << 
568                                                << 
569   G4double sinCur = GetSinStartPhi();          << 
570   G4double cosCur = GetCosStartPhi();          << 
571   if (!IsOpen()) rmin = 0.;                    << 
572   G4double xmin = rmin*cosCur, xmax = xmin;    << 
573   G4double ymin = rmin*sinCur, ymax = ymin;    << 
574   for (G4int k=0; k<ksteps+1; ++k)             << 
575   {                                            << 
576     G4double x = rmax*cosCur;                  << 
577     if (x < xmin) xmin = x;                    << 
578     if (x > xmax) xmax = x;                    << 
579     G4double y = rmax*sinCur;                  << 
580     if (y < ymin) ymin = y;                    << 
581     if (y > ymax) ymax = y;                    << 
582     if (rmin > 0)                              << 
583     {                                          << 
584       G4double xx = rmin*cosCur;               << 
585       if (xx < xmin) xmin = xx;                << 
586       if (xx > xmax) xmax = xx;                << 
587       G4double yy = rmin*sinCur;               << 
588       if (yy < ymin) ymin = yy;                << 
589       if (yy > ymax) ymax = yy;                << 
590     }                                          << 
591     G4double sinTmp = sinCur;                  << 
592     sinCur = sinCur*cosStep + cosCur*sinStep;  << 
593     cosCur = cosCur*cosStep - sinTmp*sinStep;  << 
594   }                                            << 
595   pMin.set(xmin,ymin,zmin);                    << 
596   pMax.set(xmax,ymax,zmax);                    << 
597                                                   535 
598   // Check correctness of the bounding box     << 
599   //                                           << 
600   if (pMin.x() >= pMax.x() || pMin.y() >= pMax << 
601   {                                            << 
602     std::ostringstream message;                << 
603     message << "Bad bounding box (min >= max)  << 
604             << GetName() << " !"               << 
605             << "\npMin = " << pMin             << 
606             << "\npMax = " << pMax;            << 
607     G4Exception("G4Polyhedra::BoundingLimits() << 
608                 JustWarning, message);         << 
609     DumpInfo();                                << 
610   }                                            << 
611 }                                              << 
612                                                << 
613 // Calculate extent under transform and specif << 
614 //                                                536 //
615 G4bool G4Polyhedra::CalculateExtent(const EAxi << 
616                                     const G4Vo << 
617                                     const G4Af << 
618                                     G4double&  << 
619 {                                              << 
620   G4ThreeVector bmin, bmax;                    << 
621   G4bool exist;                                << 
622                                                << 
623   // Check bounding box (bbox)                 << 
624   //                                           << 
625   BoundingLimits(bmin,bmax);                   << 
626   G4BoundingEnvelope bbox(bmin,bmax);          << 
627 #ifdef G4BBOX_EXTENT                           << 
628   return bbox.CalculateExtent(pAxis,pVoxelLimi << 
629 #endif                                         << 
630   if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVox << 
631   {                                            << 
632     return exist = pMin < pMax;                << 
633   }                                            << 
634                                                << 
635   // To find the extent, RZ contour of the pol << 
636   // in triangles. The extent is calculated as << 
637   // all sub-polycones formed by rotation of t << 
638   //                                           << 
639   G4TwoVectorList contourRZ;                   << 
640   G4TwoVectorList triangles;                   << 
641   std::vector<G4int> iout;                     << 
642   G4double eminlim = pVoxelLimit.GetMinExtent( << 
643   G4double emaxlim = pVoxelLimit.GetMaxExtent( << 
644                                                << 
645   // get RZ contour, ensure anticlockwise orde << 
646   for (G4int i=0; i<GetNumRZCorner(); ++i)     << 
647   {                                            << 
648     G4PolyhedraSideRZ corner = GetCorner(i);   << 
649     contourRZ.emplace_back(corner.r,corner.z); << 
650   }                                            << 
651   G4GeomTools::RemoveRedundantVertices(contour << 
652   G4double area = G4GeomTools::PolygonArea(con << 
653   if (area < 0.) std::reverse(contourRZ.begin( << 
654                                                << 
655   // triangulate RZ countour                   << 
656   if (!G4GeomTools::TriangulatePolygon(contour << 
657   {                                            << 
658     std::ostringstream message;                << 
659     message << "Triangulation of RZ contour ha << 
660             << GetName() << " !"               << 
661             << "\nExtent has been calculated u << 
662     G4Exception("G4Polyhedra::CalculateExtent( << 
663                 "GeomMgt1002",JustWarning,mess << 
664     return bbox.CalculateExtent(pAxis,pVoxelLi << 
665   }                                            << 
666                                                << 
667   // set trigonometric values                  << 
668   G4double sphi     = GetStartPhi();           << 
669   G4double ephi     = GetEndPhi();             << 
670   G4double dphi     = IsOpen() ? ephi-sphi : t << 
671   G4int    ksteps   = GetNumSide();            << 
672   G4double astep    = dphi/ksteps;             << 
673   G4double sinStep  = std::sin(astep);         << 
674   G4double cosStep  = std::cos(astep);         << 
675   G4double sinStart = GetSinStartPhi();        << 
676   G4double cosStart = GetCosStartPhi();        << 
677                                                << 
678   // allocate vector lists                     << 
679   std::vector<const G4ThreeVectorList *> polyg << 
680   polygons.resize(ksteps+1);                   << 
681   for (G4int k=0; k<ksteps+1; ++k)             << 
682   {                                            << 
683     polygons[k] = new G4ThreeVectorList(3);    << 
684   }                                            << 
685                                                << 
686   // main loop along triangles                 << 
687   pMin =  kInfinity;                           << 
688   pMax = -kInfinity;                           << 
689   G4int ntria = (G4int)triangles.size()/3;     << 
690   for (G4int i=0; i<ntria; ++i)                << 
691   {                                            << 
692     G4double sinCur = sinStart;                << 
693     G4double cosCur = cosStart;                << 
694     G4int i3 = i*3;                            << 
695     for (G4int k=0; k<ksteps+1; ++k) // rotate << 
696     {                                          << 
697       auto ptr = const_cast<G4ThreeVectorList* << 
698       auto iter = ptr->begin();                << 
699       iter->set(triangles[i3+0].x()*cosCur,    << 
700                 triangles[i3+0].x()*sinCur,    << 
701                 triangles[i3+0].y());          << 
702       iter++;                                  << 
703       iter->set(triangles[i3+1].x()*cosCur,    << 
704                 triangles[i3+1].x()*sinCur,    << 
705                 triangles[i3+1].y());          << 
706       iter++;                                  << 
707       iter->set(triangles[i3+2].x()*cosCur,    << 
708                 triangles[i3+2].x()*sinCur,    << 
709                 triangles[i3+2].y());          << 
710                                                << 
711       G4double sinTmp = sinCur;                << 
712       sinCur = sinCur*cosStep + cosCur*sinStep << 
713       cosCur = cosCur*cosStep - sinTmp*sinStep << 
714     }                                          << 
715                                                << 
716     // set sub-envelope and adjust extent      << 
717     G4double emin,emax;                        << 
718     G4BoundingEnvelope benv(polygons);         << 
719     if (!benv.CalculateExtent(pAxis,pVoxelLimi << 
720     if (emin < pMin) pMin = emin;              << 
721     if (emax > pMax) pMax = emax;              << 
722     if (eminlim > pMin && emaxlim < pMax) brea << 
723   }                                            << 
724   // free memory                               << 
725   for (G4int k=0; k<ksteps+1; ++k) { delete po << 
726   return (pMin < pMax);                        << 
727 }                                              << 
728                                                << 
729 // ComputeDimensions                              537 // ComputeDimensions
730 //                                                538 //
731 void G4Polyhedra::ComputeDimensions(       G4V    539 void G4Polyhedra::ComputeDimensions(       G4VPVParameterisation* p,
732                                      const G4i    540                                      const G4int n,
733                                      const G4V    541                                      const G4VPhysicalVolume* pRep )
734 {                                                 542 {
735   p->ComputeDimensions(*this,n,pRep);             543   p->ComputeDimensions(*this,n,pRep);
736 }                                                 544 }
737                                                   545 
                                                   >> 546 
                                                   >> 547 //
738 // GetEntityType                                  548 // GetEntityType
739 //                                                549 //
740 G4GeometryType G4Polyhedra::GetEntityType() co    550 G4GeometryType G4Polyhedra::GetEntityType() const
741 {                                                 551 {
742   return {"G4Polyhedra"};                      << 552   return G4String("G4Polyhedra");
743 }                                                 553 }
744                                                   554 
745 // IsFaceted                                   << 
746 //                                             << 
747 G4bool G4Polyhedra::IsFaceted() const          << 
748 {                                              << 
749   return true;                                 << 
750 }                                              << 
751                                                   555 
752 // Make a clone of the object                  << 
753 //                                                556 //
754 G4VSolid* G4Polyhedra::Clone() const           << 
755 {                                              << 
756   return new G4Polyhedra(*this);               << 
757 }                                              << 
758                                                << 
759 // Stream object contents to an output stream     557 // Stream object contents to an output stream
760 //                                                558 //
761 std::ostream& G4Polyhedra::StreamInfo( std::os    559 std::ostream& G4Polyhedra::StreamInfo( std::ostream& os ) const
762 {                                                 560 {
763   G4long oldprc = os.precision(16);            << 
764   os << "-------------------------------------    561   os << "-----------------------------------------------------------\n"
765      << "    *** Dump for solid - " << GetName    562      << "    *** Dump for solid - " << GetName() << " ***\n"
766      << "    =================================    563      << "    ===================================================\n"
767      << " Solid type: G4Polyhedra\n"              564      << " Solid type: G4Polyhedra\n"
768      << " Parameters: \n"                         565      << " Parameters: \n"
769      << "    starting phi angle : " << startPh    566      << "    starting phi angle : " << startPhi/degree << " degrees \n"
770      << "    ending phi angle   : " << endPhi/ << 567      << "    ending phi angle   : " << endPhi/degree << " degrees \n";
771      << "    number of sides    : " << numSide << 
772   G4int i=0;                                      568   G4int i=0;
773   if (!genericPgon)                            << 569   if (original_parameters)
774   {                                               570   {
775     G4int numPlanes = original_parameters->Num    571     G4int numPlanes = original_parameters->Num_z_planes;
776     os << "    number of Z planes: " << numPla    572     os << "    number of Z planes: " << numPlanes << "\n"
777        << "              Z values: \n";           573        << "              Z values: \n";
778     for (i=0; i<numPlanes; ++i)                << 574     for (i=0; i<numPlanes; i++)
779     {                                             575     {
780       os << "              Z plane " << i << "    576       os << "              Z plane " << i << ": "
781          << original_parameters->Z_values[i] <    577          << original_parameters->Z_values[i] << "\n";
782     }                                             578     }
783     os << "              Tangent distances to     579     os << "              Tangent distances to inner surface (Rmin): \n";
784     for (i=0; i<numPlanes; ++i)                << 580     for (i=0; i<numPlanes; i++)
785     {                                             581     {
786       os << "              Z plane " << i << "    582       os << "              Z plane " << i << ": "
787          << original_parameters->Rmin[i] << "\    583          << original_parameters->Rmin[i] << "\n";
788     }                                             584     }
789     os << "              Tangent distances to     585     os << "              Tangent distances to outer surface (Rmax): \n";
790     for (i=0; i<numPlanes; ++i)                << 586     for (i=0; i<numPlanes; i++)
791     {                                             587     {
792       os << "              Z plane " << i << "    588       os << "              Z plane " << i << ": "
793          << original_parameters->Rmax[i] << "\    589          << original_parameters->Rmax[i] << "\n";
794     }                                             590     }
795   }                                               591   }
796   os << "    number of RZ points: " << numCorn    592   os << "    number of RZ points: " << numCorner << "\n"
797      << "              RZ values (corners): \n    593      << "              RZ values (corners): \n";
798      for (i=0; i<numCorner; ++i)               << 594      for (i=0; i<numCorner; i++)
799      {                                            595      {
800        os << "                         "          596        os << "                         "
801           << corners[i].r << ", " << corners[i    597           << corners[i].r << ", " << corners[i].z << "\n";
802      }                                            598      }
803   os << "-------------------------------------    599   os << "-----------------------------------------------------------\n";
804   os.precision(oldprc);                        << 
805                                                   600 
806   return os;                                      601   return os;
807 }                                                 602 }
808                                                   603 
809 ////////////////////////////////////////////// << 
810 //                                             << 
811 // Return volume                               << 
812                                                << 
813 G4double G4Polyhedra::GetCubicVolume()         << 
814 {                                              << 
815   if (fCubicVolume == 0.)                      << 
816   {                                            << 
817     G4double total = 0.;                       << 
818     G4int nrz = GetNumRZCorner();              << 
819     G4PolyhedraSideRZ a = GetCorner(nrz - 1);  << 
820     for (G4int i=0; i<nrz; ++i)                << 
821     {                                          << 
822       G4PolyhedraSideRZ b = GetCorner(i);      << 
823       total += (b.r*b.r + b.r*a.r + a.r*a.r)*( << 
824       a = b;                                   << 
825     }                                          << 
826     fCubicVolume = std::abs(total)*            << 
827       std::sin((GetEndPhi() - GetStartPhi())/G << 
828   }                                            << 
829   return fCubicVolume;                         << 
830 }                                              << 
831                                                   604 
832 ////////////////////////////////////////////// << 
833 //                                                605 //
834 // Return surface area                         << 606 // CreatePolyhedron
835                                                << 
836 G4double G4Polyhedra::GetSurfaceArea()         << 
837 {                                              << 
838   if (fSurfaceArea == 0.)                      << 
839   {                                            << 
840     G4double total = 0.;                       << 
841     G4int nrz = GetNumRZCorner();              << 
842     if (IsOpen())                              << 
843     {                                          << 
844       G4PolyhedraSideRZ a = GetCorner(nrz - 1) << 
845       for (G4int i=0; i<nrz; ++i)              << 
846       {                                        << 
847         G4PolyhedraSideRZ b = GetCorner(i);    << 
848         total += a.r*b.z - a.z*b.r;            << 
849         a = b;                                 << 
850       }                                        << 
851       total = std::abs(total);                 << 
852     }                                          << 
853     G4double alp = (GetEndPhi() - GetStartPhi( << 
854     G4double cosa = std::cos(alp);             << 
855     G4double sina = std::sin(alp);             << 
856     G4PolyhedraSideRZ a = GetCorner(nrz - 1);  << 
857     for (G4int i=0; i<nrz; ++i)                << 
858     {                                          << 
859       G4PolyhedraSideRZ b = GetCorner(i);      << 
860       G4ThreeVector p1(a.r, 0, a.z);           << 
861       G4ThreeVector p2(a.r*cosa, a.r*sina, a.z << 
862       G4ThreeVector p3(b.r*cosa, b.r*sina, b.z << 
863       G4ThreeVector p4(b.r, 0, b.z);           << 
864       total += GetNumSide()*(G4GeomTools::Quad << 
865       a = b;                                   << 
866     }                                          << 
867     fSurfaceArea = total;                      << 
868   }                                            << 
869   return fSurfaceArea;                         << 
870 }                                              << 
871                                                << 
872 ////////////////////////////////////////////// << 
873 //                                                607 //
874 // Set vector of surface elements, auxiliary m << 608 G4Polyhedron* G4Polyhedra::CreatePolyhedron() const
875 // random points on surface                    << 609 { 
876                                                << 610   //
877 void G4Polyhedra::SetSurfaceElements() const   << 611   // This has to be fixed in visualization. Fake it for the moment.
878 {                                              << 612   // 
879   fElements = new std::vector<G4Polyhedra::sur << 613   if (original_parameters)
880   G4double total = 0.;                         << 614   { 
881   G4int nrz = GetNumRZCorner();                << 615     return new G4PolyhedronPgon( original_parameters->Start_angle,
882                                                << 616                                  original_parameters->Opening_angle,
883   // set lateral surface elements              << 617                                  original_parameters->numSide,
884   G4double dphi = (GetEndPhi() - GetStartPhi() << 618                                  original_parameters->Num_z_planes,
885   G4double cosa = std::cos(dphi);              << 619                                  original_parameters->Z_values,
886   G4double sina = std::sin(dphi);              << 620                                  original_parameters->Rmin,
887   G4int ia = nrz - 1;                          << 621                                  original_parameters->Rmax);
888   for (G4int ib=0; ib<nrz; ++ib)               << 
889   {                                            << 
890     G4PolyhedraSideRZ a = GetCorner(ia);       << 
891     G4PolyhedraSideRZ b = GetCorner(ib);       << 
892     G4Polyhedra::surface_element selem;        << 
893     selem.i0 = ia;                             << 
894     selem.i1 = ib;                             << 
895     ia = ib;                                   << 
896     if (a.r == 0. && b.r == 0.) continue;      << 
897     G4ThreeVector p1(a.r, 0, a.z);             << 
898     G4ThreeVector p2(a.r*cosa, a.r*sina, a.z); << 
899     G4ThreeVector p3(b.r*cosa, b.r*sina, b.z); << 
900     G4ThreeVector p4(b.r, 0, b.z);             << 
901     if (a.r > 0.)                              << 
902     {                                          << 
903       selem.i2 = -1;                           << 
904       total += GetNumSide()*(G4GeomTools::Tria << 
905       selem.area = total;                      << 
906       fElements->push_back(selem);             << 
907     }                                          << 
908     if (b.r > 0.)                              << 
909     {                                          << 
910       selem.i2 = -2;                           << 
911       total += GetNumSide()*(G4GeomTools::Tria << 
912       selem.area = total;                      << 
913       fElements->push_back(selem);             << 
914     }                                          << 
915   }                                               622   }
916                                                << 623   else
917   // set elements for phi cuts                 << 
918   if (IsOpen())                                << 
919   {                                               624   {
920     G4TwoVectorList contourRZ;                 << 625     G4cerr << "ERROR - G4Polyhedra::CreatePolyhedron() " << GetName() << G4endl
921     std::vector<G4int> triangles;              << 626            << "        Visualization of this type of G4Polycone" << G4endl
922     for (G4int i=0; i<nrz; ++i)                << 627            << "        is not supported at this time !" << G4endl;
923     {                                          << 628     return 0;
924       G4PolyhedraSideRZ corner = GetCorner(i); << 
925       contourRZ.emplace_back(corner.r, corner. << 
926     }                                          << 
927     G4GeomTools::TriangulatePolygon(contourRZ, << 
928     auto ntria = (G4int)triangles.size();      << 
929     for (G4int i=0; i<ntria; i+=3)             << 
930     {                                          << 
931       G4Polyhedra::surface_element selem;      << 
932       selem.i0 = triangles[i];                 << 
933       selem.i1 = triangles[i+1];               << 
934       selem.i2 = triangles[i+2];               << 
935       G4PolyhedraSideRZ a = GetCorner(selem.i0 << 
936       G4PolyhedraSideRZ b = GetCorner(selem.i1 << 
937       G4PolyhedraSideRZ c = GetCorner(selem.i2 << 
938       G4double stria =                         << 
939         std::abs(G4GeomTools::TriangleArea(a.r << 
940       total += stria;                          << 
941       selem.area = total;                      << 
942       fElements->push_back(selem); // start ph << 
943       total += stria;                          << 
944       selem.area = total;                      << 
945       selem.i0 += nrz;                         << 
946       fElements->push_back(selem); // end phi  << 
947     }                                          << 
948   }                                               629   }
949 }                                              << 630 }  
950                                                   631 
951 ////////////////////////////////////////////// << 
952 //                                             << 
953 // Generate random point on surface            << 
954                                                   632 
955 G4ThreeVector G4Polyhedra::GetPointOnSurface() << 633 //
                                                   >> 634 // CreateNURBS
                                                   >> 635 //
                                                   >> 636 G4NURBS *G4Polyhedra::CreateNURBS() const
956 {                                                 637 {
957   // Set surface elements                      << 638   return 0;
958   if (fElements == nullptr)                    << 
959   {                                            << 
960     G4AutoLock l(&surface_elementsMutex);      << 
961     SetSurfaceElements();                      << 
962     l.unlock();                                << 
963   }                                            << 
964                                                << 
965   // Select surface element                    << 
966   G4Polyhedra::surface_element selem;          << 
967   selem = fElements->back();                   << 
968   G4double select = selem.area*G4QuickRand();  << 
969   auto it = std::lower_bound(fElements->begin( << 
970                              [](const G4Polyhe << 
971                              -> G4bool { retur << 
972                                                << 
973   // Generate random point                     << 
974   G4double x = 0, y = 0, z = 0;                << 
975   G4double u = G4QuickRand();                  << 
976   G4double v = G4QuickRand();                  << 
977   if (u + v > 1.) { u = 1. - u; v = 1. - v; }  << 
978   G4int i0 = (*it).i0;                         << 
979   G4int i1 = (*it).i1;                         << 
980   G4int i2 = (*it).i2;                         << 
981   if (i2 < 0) // lateral surface               << 
982   {                                            << 
983     // sample point                            << 
984     G4int nside = GetNumSide();                << 
985     G4double dphi = (GetEndPhi() - GetStartPhi << 
986     G4double cosa = std::cos(dphi);            << 
987     G4double sina = std::sin(dphi);            << 
988     G4PolyhedraSideRZ a = GetCorner(i0);       << 
989     G4PolyhedraSideRZ b = GetCorner(i1);       << 
990     G4ThreeVector p0(a.r, 0, a.z);             << 
991     G4ThreeVector p1(b.r, 0, b.z);             << 
992     G4ThreeVector p2(b.r*cosa, b.r*sina, b.z); << 
993     if (i2 == -1) p1.set(a.r*cosa, a.r*sina, a << 
994     p0 += (p1 - p0)*u + (p2 - p0)*v;           << 
995     // find selected side and rotate point     << 
996     G4double scurr = (*it).area;               << 
997     G4double sprev = (it == fElements->begin() << 
998     G4int iside = nside*(select - sprev)/(scur << 
999     if (iside == 0 && GetStartPhi() == 0.)     << 
1000     {                                         << 
1001       x = p0.x();                             << 
1002       y = p0.y();                             << 
1003       z = p0.z();                             << 
1004     }                                         << 
1005     else                                      << 
1006     {                                         << 
1007       if (iside == nside) --iside; // iside m << 
1008       G4double phi = iside*dphi + GetStartPhi << 
1009       G4double cosphi = std::cos(phi);        << 
1010       G4double sinphi = std::sin(phi);        << 
1011       x = p0.x()*cosphi - p0.y()*sinphi;      << 
1012       y = p0.x()*sinphi + p0.y()*cosphi;      << 
1013       z = p0.z();                             << 
1014     }                                         << 
1015   }                                           << 
1016   else // phi cut                             << 
1017   {                                           << 
1018     G4int nrz = GetNumRZCorner();             << 
1019     G4double phi = (i0 < nrz) ? GetStartPhi() << 
1020     if (i0 >= nrz) { i0 -= nrz; }             << 
1021     G4PolyhedraSideRZ p0 = GetCorner(i0);     << 
1022     G4PolyhedraSideRZ p1 = GetCorner(i1);     << 
1023     G4PolyhedraSideRZ p2 = GetCorner(i2);     << 
1024     G4double r = (p1.r - p0.r)*u + (p2.r - p0 << 
1025     x = r*std::cos(phi);                      << 
1026     y = r*std::sin(phi);                      << 
1027     z = (p1.z - p0.z)*u + (p2.z - p0.z)*v + p << 
1028   }                                           << 
1029   return {x, y, z};                           << 
1030 }                                                639 }
1031                                                  640 
1032 ///////////////////////////////////////////// << 641 
1033 //                                               642 //
1034 // CreatePolyhedron                           << 643 // G4PolyhedraHistorical stuff
                                                   >> 644 //
                                                   >> 645 G4PolyhedraHistorical::G4PolyhedraHistorical()
                                                   >> 646 {
                                                   >> 647 }
1035                                                  648 
1036 G4Polyhedron* G4Polyhedra::CreatePolyhedron() << 649 G4PolyhedraHistorical::~G4PolyhedraHistorical()
1037 {                                                650 {
1038   std::vector<G4TwoVector> rz(numCorner);     << 651   delete [] Z_values;
1039   for (G4int i = 0; i < numCorner; ++i)       << 652   delete [] Rmin;
1040     rz[i].set(corners[i].r, corners[i].z);    << 653   delete [] Rmax;
1041   return new G4PolyhedronPgon(startPhi, endPh << 
1042 }                                                654 }
1043                                                  655 
1044 // SetOriginalParameters                      << 656 G4PolyhedraHistorical::
1045 //                                            << 657 G4PolyhedraHistorical( const G4PolyhedraHistorical& source )
1046 void G4Polyhedra::SetOriginalParameters(G4Red << 
1047 {                                                658 {
1048   G4int numPlanes = numCorner;                << 659   Start_angle   = source.Start_angle;
1049   G4bool isConvertible = true;                << 660   Opening_angle = source.Opening_angle;
1050   G4double Zmax=rz->Bmax();                   << 661   numSide       = source.numSide;
1051   rz->StartWithZMin();                        << 662   Num_z_planes  = source.Num_z_planes;
1052                                               << 663   
1053   // Prepare vectors for storage              << 664   Z_values = new G4double[Num_z_planes];
1054   //                                          << 665   Rmin     = new G4double[Num_z_planes];
1055   std::vector<G4double> Z;                    << 666   Rmax     = new G4double[Num_z_planes];
1056   std::vector<G4double> Rmin;                 << 667   
1057   std::vector<G4double> Rmax;                 << 668   for( G4int i = 0; i < Num_z_planes; i++)
1058                                               << 
1059   G4int countPlanes=1;                        << 
1060   G4int icurr=0;                              << 
1061   G4int icurl=0;                              << 
1062                                               << 
1063   // first plane Z=Z[0]                       << 
1064   //                                          << 
1065   Z.push_back(corners[0].z);                  << 
1066   G4double Zprev=Z[0];                        << 
1067   if (Zprev == corners[1].z)                  << 
1068   {                                           << 
1069     Rmin.push_back(corners[0].r);             << 
1070     Rmax.push_back (corners[1].r);icurr=1;    << 
1071   }                                           << 
1072   else if (Zprev == corners[numPlanes-1].z)   << 
1073   {                                              669   {
1074     Rmin.push_back(corners[numPlanes-1].r);   << 670     Z_values[i] = source.Z_values[i];
1075     Rmax.push_back (corners[0].r);            << 671     Rmin[i]     = source.Rmin[i];
1076     icurl=numPlanes-1;                        << 672     Rmax[i]     = source.Rmax[i];
1077   }                                              673   }
1078   else                                        << 674 }
1079   {                                           << 
1080     Rmin.push_back(corners[0].r);             << 
1081     Rmax.push_back (corners[0].r);            << 
1082   }                                           << 
1083                                               << 
1084   // next planes until last                   << 
1085   //                                          << 
1086   G4int inextr=0, inextl=0;                   << 
1087   for (G4int i=0; i < numPlanes-2; ++i)       << 
1088   {                                           << 
1089     inextr=1+icurr;                           << 
1090     inextl=(icurl <= 0)? numPlanes-1 : icurl- << 
1091                                               << 
1092     if((corners[inextr].z >= Zmax) & (corners << 
1093                                               << 
1094     G4double Zleft = corners[inextl].z;       << 
1095     G4double Zright = corners[inextr].z;      << 
1096     if(Zright>Zleft)                          << 
1097     {                                         << 
1098       Z.push_back(Zleft);                     << 
1099       countPlanes++;                          << 
1100       G4double difZr=corners[inextr].z - corn << 
1101       G4double difZl=corners[inextl].z - corn << 
1102                                               << 
1103       if(std::fabs(difZl) < kCarTolerance)    << 
1104       {                                       << 
1105         if(std::fabs(difZr) < kCarTolerance)  << 
1106         {                                     << 
1107           Rmin.push_back(corners[inextl].r);  << 
1108           Rmax.push_back(corners[icurr].r);   << 
1109         }                                     << 
1110         else                                  << 
1111         {                                     << 
1112           Rmin.push_back(corners[inextl].r);  << 
1113           Rmax.push_back(corners[icurr].r + ( << 
1114                                 *(corners[ine << 
1115         }                                     << 
1116       }                                       << 
1117       else if (difZl >= kCarTolerance)        << 
1118       {                                       << 
1119         if(std::fabs(difZr) < kCarTolerance)  << 
1120         {                                     << 
1121           Rmin.push_back(corners[icurl].r);   << 
1122           Rmax.push_back(corners[icurr].r);   << 
1123         }                                     << 
1124         else                                  << 
1125         {                                     << 
1126           Rmin.push_back(corners[icurl].r);   << 
1127           Rmax.push_back(corners[icurr].r + ( << 
1128                                 *(corners[ine << 
1129         }                                     << 
1130       }                                       << 
1131       else                                    << 
1132       {                                       << 
1133         isConvertible=false; break;           << 
1134       }                                       << 
1135       icurl=(icurl == 0)? numPlanes-1 : icurl << 
1136     }                                         << 
1137     else if(std::fabs(Zright-Zleft)<kCarToler << 
1138     {                                         << 
1139       Z.push_back(Zleft);                     << 
1140       ++countPlanes;                          << 
1141       ++icurr;                                << 
1142                                               << 
1143       icurl=(icurl == 0)? numPlanes-1 : icurl << 
1144                                               << 
1145       Rmin.push_back(corners[inextl].r);      << 
1146       Rmax.push_back (corners[inextr].r);     << 
1147     }                                         << 
1148     else  // Zright<Zleft                     << 
1149     {                                         << 
1150       Z.push_back(Zright);                    << 
1151       ++countPlanes;                          << 
1152                                               << 
1153       G4double difZr=corners[inextr].z - corn << 
1154       G4double difZl=corners[inextl].z - corn << 
1155       if(std::fabs(difZr) < kCarTolerance)    << 
1156       {                                       << 
1157         if(std::fabs(difZl) < kCarTolerance)  << 
1158         {                                     << 
1159           Rmax.push_back(corners[inextr].r);  << 
1160           Rmin.push_back(corners[icurr].r);   << 
1161         }                                     << 
1162         else                                  << 
1163         {                                     << 
1164           Rmin.push_back(corners[icurl].r + ( << 
1165                                 * (corners[in << 
1166           Rmax.push_back(corners[inextr].r);  << 
1167         }                                     << 
1168         ++icurr;                              << 
1169       }           // plate                    << 
1170       else if (difZr >= kCarTolerance)        << 
1171       {                                       << 
1172         if(std::fabs(difZl) < kCarTolerance)  << 
1173         {                                     << 
1174           Rmax.push_back(corners[inextr].r);  << 
1175           Rmin.push_back (corners[icurr].r);  << 
1176         }                                     << 
1177         else                                  << 
1178         {                                     << 
1179           Rmax.push_back(corners[inextr].r);  << 
1180           Rmin.push_back (corners[icurl].r+(Z << 
1181                                   * (corners[ << 
1182         }                                     << 
1183         ++icurr;                              << 
1184       }                                       << 
1185       else                                    << 
1186       {                                       << 
1187         isConvertible=false; break;           << 
1188       }                                       << 
1189     }                                         << 
1190   }   // end for loop                         << 
1191                                               << 
1192   // last plane Z=Zmax                        << 
1193   //                                          << 
1194   Z.push_back(Zmax);                          << 
1195   ++countPlanes;                              << 
1196   inextr=1+icurr;                             << 
1197   inextl=(icurl <= 0)? numPlanes-1 : icurl-1; << 
1198                                               << 
1199   Rmax.push_back(corners[inextr].r);          << 
1200   Rmin.push_back(corners[inextl].r);          << 
1201                                                  675 
1202   // Set original parameters Rmin,Rmax,Z      << 676 G4PolyhedraHistorical&
1203   //                                          << 677 G4PolyhedraHistorical::operator=( const G4PolyhedraHistorical& right )
1204   if(isConvertible)                           << 678 {
1205   {                                           << 679   if ( &right == this ) return *this;
1206    original_parameters = new G4PolyhedraHisto << 
1207    original_parameters->numSide = numSide;    << 
1208    original_parameters->Z_values = new G4doub << 
1209    original_parameters->Rmin = new G4double[c << 
1210    original_parameters->Rmax = new G4double[c << 
1211                                               << 
1212    for(G4int j=0; j < countPlanes; ++j)       << 
1213    {                                          << 
1214      original_parameters->Z_values[j] = Z[j]; << 
1215      original_parameters->Rmax[j] = Rmax[j];  << 
1216      original_parameters->Rmin[j] = Rmin[j];  << 
1217    }                                          << 
1218    original_parameters->Start_angle = startPh << 
1219    original_parameters->Opening_angle = endPh << 
1220    original_parameters->Num_z_planes = countP << 
1221                                                  680 
1222   }                                           << 681   if (&right)
1223   else  // Set parameters(r,z) with Rmin==0 a << 
1224   {                                              682   {
1225 #ifdef G4SPECSDEBUG                           << 683     Start_angle   = right.Start_angle;
1226     std::ostringstream message;               << 684     Opening_angle = right.Opening_angle;
1227     message << "Polyhedra " << GetName() << G << 685     numSide       = right.numSide;
1228       << "cannot be converted to Polyhedra wi << 686     Num_z_planes  = right.Num_z_planes;
1229     G4Exception("G4Polyhedra::SetOriginalPara << 687   
1230                 "GeomSolids0002", JustWarning << 688     delete [] Z_values;
1231 #endif                                        << 689     delete [] Rmin;
1232     original_parameters = new G4PolyhedraHist << 690     delete [] Rmax;
1233     original_parameters->numSide = numSide;   << 691     Z_values = new G4double[Num_z_planes];
1234     original_parameters->Z_values = new G4dou << 692     Rmin     = new G4double[Num_z_planes];
1235     original_parameters->Rmin = new G4double[ << 693     Rmax     = new G4double[Num_z_planes];
1236     original_parameters->Rmax = new G4double[ << 694   
1237                                               << 695     for( G4int i = 0; i < Num_z_planes; i++)
1238     for(G4int j=0; j < numPlanes; ++j)        << 
1239     {                                            696     {
1240       original_parameters->Z_values[j] = corn << 697       Z_values[i] = right.Z_values[i];
1241       original_parameters->Rmax[j] = corners[ << 698       Rmin[i]     = right.Rmin[i];
1242       original_parameters->Rmin[j] = 0.0;     << 699       Rmax[i]     = right.Rmax[i];
1243     }                                            700     }
1244     original_parameters->Start_angle = startP << 
1245     original_parameters->Opening_angle = endP << 
1246     original_parameters->Num_z_planes = numPl << 
1247   }                                              701   }
                                                   >> 702   return *this;
1248 }                                                703 }
1249                                               << 
1250 #endif                                        << 
1251                                                  704