Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/divisions/src/G4ReplicatedSlice.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/divisions/src/G4ReplicatedSlice.cc (Version 11.3.0) and /geometry/divisions/src/G4ReplicatedSlice.cc (Version 9.5.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4ReplicatedSlice implementation            << 
 27 //                                                 26 //
 28 // Author: M.Asai (SLAC), 20/04/2010 - Extende <<  27 // $Id: G4ReplicatedSlice.cc,v 1.2 2010-11-10 09:16:18 gcosmo Exp $
                                                   >>  28 // GEANT4 tag $Name: not supported by cvs2svn $
                                                   >>  29 //
 29 // -------------------------------------------     30 // --------------------------------------------------------------------
 30                                                    31 
 31 #include "G4ReplicatedSlice.hh"                    32 #include "G4ReplicatedSlice.hh"
 32 #include "G4LogicalVolume.hh"                      33 #include "G4LogicalVolume.hh"
 33 #include "G4VSolid.hh"                             34 #include "G4VSolid.hh"
 34 #include "G4ReflectedSolid.hh"                     35 #include "G4ReflectedSolid.hh"
 35 #include "G4ParameterisationBox.hh"                36 #include "G4ParameterisationBox.hh"
 36 #include "G4ParameterisationTubs.hh"               37 #include "G4ParameterisationTubs.hh"
 37 #include "G4ParameterisationCons.hh"               38 #include "G4ParameterisationCons.hh"
 38 #include "G4ParameterisationTrd.hh"                39 #include "G4ParameterisationTrd.hh"
 39 #include "G4ParameterisationPara.hh"               40 #include "G4ParameterisationPara.hh"
 40 #include "G4ParameterisationPolycone.hh"           41 #include "G4ParameterisationPolycone.hh"
 41 #include "G4ParameterisationPolyhedra.hh"          42 #include "G4ParameterisationPolyhedra.hh"
 42                                                    43 
 43 //--------------------------------------------     44 //--------------------------------------------------------------------------
 44 G4ReplicatedSlice::G4ReplicatedSlice(const G4S     45 G4ReplicatedSlice::G4ReplicatedSlice(const G4String& pName,
 45                                            G4L     46                                            G4LogicalVolume* pLogical,
 46                                            G4L     47                                            G4LogicalVolume* pMotherLogical,
 47                                      const EAx     48                                      const EAxis pAxis,
 48                                      const G4i     49                                      const G4int nDivs,
 49                                      const G4d     50                                      const G4double width,
 50                                      const G4d     51                                      const G4double half_gap,
 51                                      const G4d     52                                      const G4double offset )
 52   : G4PVReplica(pName, nDivs, pAxis, pLogical, <<  53   : G4VPhysicalVolume(0,G4ThreeVector(),pName,pLogical,0), fcopyNo(-1)
 53 {                                                  54 {
 54   CheckAndSetParameters(pAxis, nDivs, width, h     55   CheckAndSetParameters(pAxis, nDivs, width, half_gap, offset,
 55                         DivNDIVandWIDTH, pMoth     56                         DivNDIVandWIDTH, pMotherLogical, pLogical);
 56 }                                                  57 }
 57                                                    58 
 58 //--------------------------------------------     59 //--------------------------------------------------------------------------
 59 G4ReplicatedSlice::G4ReplicatedSlice(const G4S     60 G4ReplicatedSlice::G4ReplicatedSlice(const G4String& pName,
 60                                            G4L     61                                            G4LogicalVolume* pLogical,
 61                                            G4L     62                                            G4LogicalVolume* pMotherLogical,
 62                                      const EAx     63                                      const EAxis pAxis,
 63                                      const G4i     64                                      const G4int nDivs,
 64                                      const G4d     65                                      const G4double half_gap,
 65                                      const G4d     66                                      const G4double offset )
 66   : G4PVReplica(pName, nDivs, pAxis, pLogical, <<  67   : G4VPhysicalVolume(0,G4ThreeVector(),pName,pLogical,0), fcopyNo(-1)
 67 {                                                  68 {
 68   CheckAndSetParameters(pAxis, nDivs, 0., half     69   CheckAndSetParameters(pAxis, nDivs, 0., half_gap, offset,
 69                         DivNDIV, pMotherLogica     70                         DivNDIV, pMotherLogical, pLogical);
 70 }                                                  71 }
 71                                                    72 
 72 //--------------------------------------------     73 //--------------------------------------------------------------------------
 73 G4ReplicatedSlice::G4ReplicatedSlice(const G4S     74 G4ReplicatedSlice::G4ReplicatedSlice(const G4String& pName,
 74                                            G4L     75                                            G4LogicalVolume* pLogical,
 75                                            G4L     76                                            G4LogicalVolume* pMotherLogical,
 76                                      const EAx     77                                      const EAxis pAxis,
 77                                      const G4d     78                                      const G4double width,
 78                                      const G4d     79                                      const G4double half_gap,
 79                                      const G4d     80                                      const G4double offset )
 80   : G4PVReplica(pName, 0, pAxis, pLogical, pMo <<  81   : G4VPhysicalVolume(0,G4ThreeVector(),pName,pLogical,0), fcopyNo(-1)
 81 {                                                  82 {
 82   CheckAndSetParameters(pAxis, 0, width, half_     83   CheckAndSetParameters(pAxis, 0, width, half_gap, offset,
 83                         DivWIDTH, pMotherLogic     84                         DivWIDTH, pMotherLogical, pLogical);
 84 }                                                  85 }
 85                                                    86 
 86 //--------------------------------------------     87 //--------------------------------------------------------------------------
 87 G4ReplicatedSlice::G4ReplicatedSlice(const G4S     88 G4ReplicatedSlice::G4ReplicatedSlice(const G4String& pName,
 88                                            G4L     89                                            G4LogicalVolume* pLogical,
 89                                            G4V     90                                            G4VPhysicalVolume* pMotherPhysical,
 90                                      const EAx     91                                      const EAxis pAxis,
 91                                      const G4i     92                                      const G4int nDivs,
 92                                      const G4d     93                                      const G4double width,
 93                                      const G4d     94                                      const G4double half_gap,
 94                                      const G4d     95                                      const G4double offset )
 95   : G4PVReplica(pName, nDivs, pAxis, pLogical, <<  96   : G4VPhysicalVolume(0,G4ThreeVector(),pName,pLogical,0), fcopyNo(-1)
 96                 pMotherPhysical != nullptr ? p << 
 97 {                                                  97 {
 98   if (pMotherPhysical == nullptr)              << 
 99   {                                            << 
100     std::ostringstream message;                << 
101     message << "Invalid setup." << G4endl      << 
102             << "NULL pointer specified as moth << 
103     G4Exception("G4ReplicatedSlice::G4Replicat << 
104                 FatalException, message);      << 
105     return;                                    << 
106   }                                            << 
107   CheckAndSetParameters(pAxis, nDivs, width, h     98   CheckAndSetParameters(pAxis, nDivs, width, half_gap, offset,
108       DivNDIVandWIDTH, pMotherPhysical->GetLog     99       DivNDIVandWIDTH, pMotherPhysical->GetLogicalVolume(), pLogical);
109 }                                                 100 }
110                                                   101 
111 //--------------------------------------------    102 //--------------------------------------------------------------------------
112 G4ReplicatedSlice::G4ReplicatedSlice(const G4S    103 G4ReplicatedSlice::G4ReplicatedSlice(const G4String& pName,
113                                            G4L    104                                            G4LogicalVolume* pLogical,
114                                            G4V    105                                            G4VPhysicalVolume* pMotherPhysical,
115                                      const EAx    106                                      const EAxis pAxis,
116                                      const G4i    107                                      const G4int nDivs,
117                                      const G4d    108                                      const G4double half_gap,
118                                      const G4d    109                                      const G4double offset )
119   : G4PVReplica(pName, nDivs, pAxis, pLogical, << 110   : G4VPhysicalVolume(0,G4ThreeVector(),pName,pLogical,0), fcopyNo(-1)
120                 pMotherPhysical != nullptr ? p << 
121 {                                                 111 {
122   if (pMotherPhysical == nullptr)              << 
123   {                                            << 
124     std::ostringstream message;                << 
125     message << "Invalid setup." << G4endl      << 
126             << "NULL pointer specified as moth << 
127     G4Exception("G4ReplicatedSlice::G4Replicat << 
128                 FatalException, message);      << 
129     return;                                    << 
130   }                                            << 
131   CheckAndSetParameters(pAxis, nDivs, 0., half    112   CheckAndSetParameters(pAxis, nDivs, 0., half_gap, offset,
132       DivNDIV, pMotherPhysical->GetLogicalVolu    113       DivNDIV, pMotherPhysical->GetLogicalVolume(), pLogical);
133 }                                                 114 }
134                                                   115 
135 //--------------------------------------------    116 //--------------------------------------------------------------------------
136 G4ReplicatedSlice::G4ReplicatedSlice(const G4S    117 G4ReplicatedSlice::G4ReplicatedSlice(const G4String& pName,
137                                            G4L    118                                            G4LogicalVolume* pLogical,
138                                            G4V    119                                            G4VPhysicalVolume* pMotherPhysical,
139                                      const EAx    120                                      const EAxis pAxis,
140                                      const G4d    121                                      const G4double width,
141                                      const G4d    122                                      const G4double half_gap,
142                                      const G4d    123                                      const G4double offset )
143   : G4PVReplica(pName, 0, pAxis, pLogical,     << 124   : G4VPhysicalVolume(0,G4ThreeVector(),pName,pLogical,0), fcopyNo(-1)
144                 pMotherPhysical != nullptr ? p << 
145 {                                                 125 {
146   if (pMotherPhysical == nullptr)              << 
147   {                                            << 
148     std::ostringstream message;                << 
149     message << "Invalid setup." << G4endl      << 
150             << "NULL pointer specified as moth << 
151     G4Exception("G4ReplicatedSlice::G4Replicat << 
152                 FatalException, message);      << 
153     return;                                    << 
154   }                                            << 
155   CheckAndSetParameters(pAxis, 0, width, half_    126   CheckAndSetParameters(pAxis, 0, width, half_gap, offset,
156       DivWIDTH, pMotherPhysical->GetLogicalVol    127       DivWIDTH, pMotherPhysical->GetLogicalVolume(), pLogical);
157 }                                                 128 }
158                                                   129 
159 //--------------------------------------------    130 //--------------------------------------------------------------------------
160 void                                              131 void
161 G4ReplicatedSlice::CheckAndSetParameters( cons    132 G4ReplicatedSlice::CheckAndSetParameters( const EAxis pAxis,
162                                           cons    133                                           const G4int nDivs,
163                                           cons    134                                           const G4double width,
164                                           cons    135                                           const G4double half_gap,
165                                           cons    136                                           const G4double offset, 
166                                                   137                                                 DivisionType divType,
167                                                   138                                                 G4LogicalVolume* pMotherLogical,
168                                           cons    139                                           const G4LogicalVolume* pLogical )
169 {                                                 140 {
170   if(pMotherLogical == nullptr)                << 141   if(!pMotherLogical)
171   {                                               142   {
172     std::ostringstream message;                   143     std::ostringstream message;
173     message << "Invalid setup." << G4endl         144     message << "Invalid setup." << G4endl
174             << "NULL pointer specified as moth    145             << "NULL pointer specified as mother! Volume: " << GetName();
175     G4Exception("G4ReplicatedSlice::CheckAndSe    146     G4Exception("G4ReplicatedSlice::CheckAndSetParameters()", "GeomDiv0002",
176                 FatalException, message);         147                 FatalException, message);
177   }                                               148   }
178   if(pLogical == pMotherLogical)                  149   if(pLogical == pMotherLogical)
179   {                                               150   {
180     std::ostringstream message;                   151     std::ostringstream message;
181     message << "Invalid setup." << G4endl         152     message << "Invalid setup." << G4endl
182             << "Cannot place a volume inside i    153             << "Cannot place a volume inside itself! Volume: " << GetName();
183     G4Exception("G4ReplicatedSlice::CheckAndSe    154     G4Exception("G4ReplicatedSlice::CheckAndSetParameters()", "GeomDiv0002",
184                 FatalException, message);         155                 FatalException, message);
185   }                                               156   }
186                                                   157 
187   //----- Check that mother solid is of the sa    158   //----- Check that mother solid is of the same type as
188   //      daughter solid (otherwise, the corre    159   //      daughter solid (otherwise, the corresponding
189   //      Parameterisation::ComputeDimension()    160   //      Parameterisation::ComputeDimension() will not be called)
190   //                                              161   //
191   G4String msolType = pMotherLogical->GetSolid    162   G4String msolType = pMotherLogical->GetSolid()->GetEntityType();
192   G4String dsolType = pLogical->GetSolid()->Ge    163   G4String dsolType = pLogical->GetSolid()->GetEntityType();
193   if( msolType != dsolType && ( msolType != "G    164   if( msolType != dsolType && ( msolType != "G4Trd" || dsolType != "G4Trap" ) )
194   {                                               165   {
195     std::ostringstream message;                   166     std::ostringstream message;
196     message << "Invalid setup." << G4endl         167     message << "Invalid setup." << G4endl
197             << "Incorrect solid type for divis    168             << "Incorrect solid type for division of volume: "
198             << GetName() << G4endl                169             << GetName() << G4endl
199             << "    It is: " << msolType          170             << "    It is: " << msolType
200             << ", while it should be: " << dso    171             << ", while it should be: " << dsolType;
201     G4Exception("G4ReplicatedSlice::CheckAndSe    172     G4Exception("G4ReplicatedSlice::CheckAndSetParameters()",
202                 "GeomDiv0002", FatalException,    173                 "GeomDiv0002", FatalException, message);
203   }                                               174   }
204                                                   175 
205   pMotherLogical->AddDaughter(this);              176   pMotherLogical->AddDaughter(this);
206   SetMotherLogical(pMotherLogical);               177   SetMotherLogical(pMotherLogical);
207   SetParameterisation(pMotherLogical, pAxis, n    178   SetParameterisation(pMotherLogical, pAxis, nDivs,
208                       width, half_gap, offset,    179                       width, half_gap, offset, divType);
209                                                   180 
210   if( divType == DivWIDTH )                       181   if( divType == DivWIDTH )
211   {                                               182   {
212     fnReplicas = fparam->GetNoDiv();              183     fnReplicas = fparam->GetNoDiv();
213   }                                               184   }
214   else                                            185   else
215   {                                               186   {
216     fnReplicas = nDivs;                           187     fnReplicas = nDivs;
217   }                                               188   }
218   if (fnReplicas < 1 )                            189   if (fnReplicas < 1 )
219   {                                               190   {
220     G4Exception("G4ReplicatedSlice::CheckAndSe    191     G4Exception("G4ReplicatedSlice::CheckAndSetParameters()", "GeomDiv0002",
221                 FatalException, "Illegal numbe    192                 FatalException, "Illegal number of replicas!");
222   }                                               193   }
223   if( divType != DivNDIV)                         194   if( divType != DivNDIV)
224   {                                               195   {
225     fwidth = fparam->GetWidth();                  196     fwidth = fparam->GetWidth();
226   }                                               197   }
227   else                                            198   else
228   {                                               199   {
229     fwidth = width;                               200     fwidth = width;
230   }                                               201   }
231   if( fwidth < 0 )                                202   if( fwidth < 0 )
232   {                                               203   {
233     G4Exception("G4ReplicatedSlice::CheckAndSe    204     G4Exception("G4ReplicatedSlice::CheckAndSetParameters()", "GeomDiv0002",
234                 FatalException, "Width must be    205                 FatalException, "Width must be positive!");
235   }                                               206   }
236   if( fwidth < 2.*half_gap )                      207   if( fwidth < 2.*half_gap )
237   {                                               208   {
238     G4Exception("G4ReplicatedSlice::CheckAndSe    209     G4Exception("G4ReplicatedSlice::CheckAndSetParameters()", "GeomDiv0002",
239                 FatalException, "Half_gap is t    210                 FatalException, "Half_gap is too large!");
240   }                                               211   }
241                                                   212   
242   foffset = offset;                               213   foffset = offset;
243   fdivAxis = pAxis;                               214   fdivAxis = pAxis;
244                                                   215 
245   //!!!!! axis has to be x/y/z in G4VoxelLimit    216   //!!!!! axis has to be x/y/z in G4VoxelLimits::GetMinExtent
246   //                                              217   //
247   if( pAxis == kRho || pAxis == kRadial3D || p    218   if( pAxis == kRho || pAxis == kRadial3D || pAxis == kPhi )
248   {                                               219   {
249     faxis = kZAxis;                               220     faxis = kZAxis;
250   }                                               221   }
251   else                                            222   else
252   {                                               223   {
253     faxis = pAxis;                                224     faxis = pAxis;
254   }                                               225   }
255                                                   226   
256   switch (faxis)                                  227   switch (faxis)
257   {                                               228   {
258     case kPhi:                                    229     case kPhi:
259     case kRho:                                    230     case kRho:
260     case kXAxis:                                  231     case kXAxis:
261     case kYAxis:                                  232     case kYAxis:
262     case kZAxis:                                  233     case kZAxis:
263       break;                                      234       break;
264     default:                                      235     default:
265       G4Exception("G4ReplicatedSlice::CheckAnd    236       G4Exception("G4ReplicatedSlice::CheckAndSetParameters()", "GeomDiv0002",
266                   FatalException, "Unknown axi    237                   FatalException, "Unknown axis of replication.");
267       break;                                      238       break;
268   }                                               239   }
269                                                   240 
270   // Create rotation matrix: for phi axis it w    241   // Create rotation matrix: for phi axis it will be changed
271   // in G4VPVParameterisation::ComputeTransfor    242   // in G4VPVParameterisation::ComputeTransformation, for others
272   // it will stay the unity                       243   // it will stay the unity
273   //                                              244   //
274   auto  pRMat = new G4RotationMatrix();        << 245   G4RotationMatrix *pRMat = new G4RotationMatrix();
275   SetRotation(pRMat);                             246   SetRotation(pRMat);
276 }                                                 247 }
277                                                   248 
278 //--------------------------------------------    249 //--------------------------------------------------------------------------
279 G4ReplicatedSlice::~G4ReplicatedSlice()           250 G4ReplicatedSlice::~G4ReplicatedSlice()
280 {                                                 251 {
281   delete GetRotation();                           252   delete GetRotation();
282 }                                                 253 }
283                                                   254 
284 //--------------------------------------------    255 //--------------------------------------------------------------------------
285 EAxis G4ReplicatedSlice::GetDivisionAxis() con    256 EAxis G4ReplicatedSlice::GetDivisionAxis() const
286 {                                                 257 {
287   return fdivAxis;                                258   return fdivAxis;
288 }                                                 259 }
289                                                   260 
290 //--------------------------------------------    261 //--------------------------------------------------------------------------
291 G4bool G4ReplicatedSlice::IsParameterised() co    262 G4bool G4ReplicatedSlice::IsParameterised() const
292 {                                                 263 { 
293   return true;                                    264   return true;
294 }                                                 265 }
295                                                   266 
296 //--------------------------------------------    267 //--------------------------------------------------------------------------
297 G4bool G4ReplicatedSlice::IsMany() const          268 G4bool G4ReplicatedSlice::IsMany() const
298 {                                                 269 {
299   return false;                                   270   return false; 
300 }                                                 271 }
301                                                   272 
302 //--------------------------------------------    273 //--------------------------------------------------------------------------
303 G4bool G4ReplicatedSlice::IsReplicated() const << 274 G4int G4ReplicatedSlice::GetCopyNo() const
304 {                                                 275 {
305   return true;                                 << 276   return fcopyNo;
306 }                                                 277 }
307                                                   278 
308 //--------------------------------------------    279 //--------------------------------------------------------------------------
309 G4int G4ReplicatedSlice::GetMultiplicity() con << 280 void  G4ReplicatedSlice::SetCopyNo(G4int newCopyNo)
310 {                                                 281 {
311   return fnReplicas;                           << 282   fcopyNo= newCopyNo;
312 }                                                 283 }
313                                                   284 
314 //--------------------------------------------    285 //--------------------------------------------------------------------------
315 G4VPVParameterisation* G4ReplicatedSlice::GetP << 286 G4bool G4ReplicatedSlice::IsReplicated() const
316 {                                                 287 {
317   return fparam;                               << 288   return true;
318 }                                                 289 }
319                                                   290 
320 //--------------------------------------------    291 //--------------------------------------------------------------------------
321 EVolume G4ReplicatedSlice::VolumeType() const  << 292 G4VPVParameterisation* G4ReplicatedSlice::GetParameterisation() const
322 {                                                 293 {
323   return kParameterised;                       << 294   return fparam;
324 }                                                 295 }
325                                                   296 
326 //--------------------------------------------    297 //--------------------------------------------------------------------------
327 void G4ReplicatedSlice::GetReplicationData(EAx    298 void G4ReplicatedSlice::GetReplicationData(EAxis& axis,
328                                            G4i    299                                            G4int& nDivs,
329                                            G4d    300                                            G4double& width,
330                                            G4d    301                                            G4double& offset,
331                                            G4b    302                                            G4bool& consuming ) const
332 {                                                 303 {
333   axis = faxis;                                << 304   axis=faxis;
334   nDivs = fnReplicas;                          << 305   nDivs=fnReplicas;
335   width = fwidth;                              << 306   width=fwidth;
336   offset = foffset;                            << 307   offset=foffset;
337   consuming = false;                           << 308   consuming=false;
338 }                                                 309 }
339                                                   310 
340                                                   311 
341 //--------------------------------------------    312 //--------------------------------------------------------------------------
342 void G4ReplicatedSlice::SetParameterisation( G    313 void G4ReplicatedSlice::SetParameterisation( G4LogicalVolume* motherLogical,
343                                        const E    314                                        const EAxis axis,
344                                        const G    315                                        const G4int nDivs,
345                                        const G    316                                        const G4double width,
346                                        const G    317                                        const G4double half_gap,
347                                        const G    318                                        const G4double offset,
348                                              D    319                                              DivisionType divType )
349 {                                                 320 {
350   G4VSolid* mSolid = motherLogical->GetSolid()    321   G4VSolid* mSolid = motherLogical->GetSolid();
351   G4String mSolidType = mSolid->GetEntityType(    322   G4String mSolidType = mSolid->GetEntityType();
352   fparam = nullptr;                            << 
353                                                   323 
354   // If the solid is a reflected one, update t    324   // If the solid is a reflected one, update type to its
355   // real constituent solid.                      325   // real constituent solid.
356   //                                              326   // 
357   if (mSolidType == "G4ReflectedSolid")           327   if (mSolidType == "G4ReflectedSolid")
358   {                                               328   {
359       mSolidType = ((G4ReflectedSolid*)mSolid)    329       mSolidType = ((G4ReflectedSolid*)mSolid)->GetConstituentMovedSolid()
360                  ->GetEntityType();               330                  ->GetEntityType(); 
361   }                                               331   }    
362                                                   332 
363   // Parameterisation type depend of mother so    333   // Parameterisation type depend of mother solid type and axis of division
364   //                                              334   //
365   if( mSolidType == "G4Box" )                     335   if( mSolidType == "G4Box" )
366   {                                               336   {
367     switch( axis )                                337     switch( axis )
368     {                                             338     {
369       case kXAxis:                                339       case kXAxis:
370         fparam = new G4ParameterisationBoxX( a    340         fparam = new G4ParameterisationBoxX( axis, nDivs, width,
371                                              o    341                                              offset, mSolid, divType );
372         break;                                    342         break;
373       case kYAxis:                                343       case kYAxis:
374         fparam = new G4ParameterisationBoxY( a    344         fparam = new G4ParameterisationBoxY( axis, nDivs, width,
375                                              o    345                                              offset, mSolid, divType );
376         break;                                    346         break;
377       case kZAxis:                                347       case kZAxis:
378         fparam = new G4ParameterisationBoxZ( a    348         fparam = new G4ParameterisationBoxZ( axis, nDivs, width,
379                                              o    349                                              offset, mSolid, divType );
380         break;                                    350         break;
381       default:                                    351       default:
382         ErrorInAxis( axis, mSolid );              352         ErrorInAxis( axis, mSolid );
383         break;                                    353         break;
384     }                                             354     }
385   }                                               355   }
386   else if( mSolidType == "G4Tubs" )               356   else if( mSolidType == "G4Tubs" )
387   {                                               357   {
388     switch( axis )                                358     switch( axis )
389     {                                             359     {
390       case kRho:                                  360       case kRho:
391         fparam = new G4ParameterisationTubsRho    361         fparam = new G4ParameterisationTubsRho( axis, nDivs, width,
392                                                   362                                                 offset, mSolid, divType );
393         break;                                    363         break;
394       case kPhi:                                  364       case kPhi:
395         fparam = new G4ParameterisationTubsPhi    365         fparam = new G4ParameterisationTubsPhi( axis, nDivs, width,
396                                                   366                                                 offset, mSolid, divType );
397         break;                                    367         break;
398       case kZAxis:                                368       case kZAxis:
399         fparam = new G4ParameterisationTubsZ(     369         fparam = new G4ParameterisationTubsZ( axis, nDivs, width,
400                                                   370                                               offset, mSolid, divType );
401         break;                                    371         break;
402       default:                                    372       default:
403         ErrorInAxis( axis, mSolid );              373         ErrorInAxis( axis, mSolid );
404         break;                                    374         break;
405     }                                             375     }
406   }                                               376   }
407   else if( mSolidType == "G4Cons" )               377   else if( mSolidType == "G4Cons" )
408   {                                               378   {
409     switch( axis )                                379     switch( axis )
410     {                                             380     {
411       case kRho:                                  381       case kRho:
412         fparam = new G4ParameterisationConsRho    382         fparam = new G4ParameterisationConsRho( axis, nDivs, width,
413                                                   383                                                 offset, mSolid, divType );
414         break;                                    384         break;
415       case kPhi:                                  385       case kPhi:
416         fparam = new G4ParameterisationConsPhi    386         fparam = new G4ParameterisationConsPhi( axis, nDivs, width,
417                                                   387                                                 offset, mSolid, divType );
418         break;                                    388         break;
419       case kZAxis:                                389       case kZAxis:
420         fparam = new G4ParameterisationConsZ(     390         fparam = new G4ParameterisationConsZ( axis, nDivs, width,
421                                                   391                                               offset, mSolid, divType );
422         break;                                    392         break;
423       default:                                    393       default:
424         ErrorInAxis( axis, mSolid );              394         ErrorInAxis( axis, mSolid );
425         break;                                    395         break;
426     }                                             396     }
427   }                                               397   }
428   else if( mSolidType == "G4Trd" )                398   else if( mSolidType == "G4Trd" )
429   {                                               399   { 
430     switch( axis )                                400     switch( axis )
431     {                                             401     {
432       case kXAxis:                                402       case kXAxis:
433         fparam = new G4ParameterisationTrdX( a    403         fparam = new G4ParameterisationTrdX( axis, nDivs, width,
434                                              o    404                                              offset, mSolid, divType );
435         break;                                    405         break;
436       case kYAxis:                                406       case kYAxis:
437         fparam = new G4ParameterisationTrdY( a    407         fparam = new G4ParameterisationTrdY( axis, nDivs, width,
438                                              o    408                                              offset, mSolid, divType );
439         break;                                    409         break;
440       case kZAxis:                                410       case kZAxis:
441         fparam = new G4ParameterisationTrdZ( a    411         fparam = new G4ParameterisationTrdZ( axis, nDivs, width,
442                                              o    412                                              offset, mSolid, divType );
443         break;                                    413         break;
444       default:                                    414       default:
445         ErrorInAxis( axis, mSolid );              415         ErrorInAxis( axis, mSolid );
446         break;                                    416         break;
447     }                                             417     }
448   }                                               418   }
449   else if( mSolidType == "G4Para" )               419   else if( mSolidType == "G4Para" )
450   {                                               420   { 
451     switch( axis )                                421     switch( axis )
452     {                                             422     {
453       case kXAxis:                                423       case kXAxis:
454         fparam = new G4ParameterisationParaX(     424         fparam = new G4ParameterisationParaX( axis, nDivs, width,
455                                              o    425                                              offset, mSolid, divType );
456         break;                                    426         break;
457       case kYAxis:                                427       case kYAxis:
458         fparam = new G4ParameterisationParaY(     428         fparam = new G4ParameterisationParaY( axis, nDivs, width,
459                                              o    429                                              offset, mSolid, divType );
460         break;                                    430         break;
461       case kZAxis:                                431       case kZAxis:
462         fparam = new G4ParameterisationParaZ(     432         fparam = new G4ParameterisationParaZ( axis, nDivs, width,
463                                              o    433                                              offset, mSolid, divType );
464         break;                                    434         break;
465       default:                                    435       default:
466         ErrorInAxis( axis, mSolid );              436         ErrorInAxis( axis, mSolid );
467         break;                                    437         break;
468     }                                             438     }
469   }                                               439   }
470 //  else if( mSolidType == "G4Trap" )             440 //  else if( mSolidType == "G4Trap" )
471 //  {                                             441 //  {
472 //  }                                             442 //  }
473 //  else if( mSolidType == "G4Polycone" )         443 //  else if( mSolidType == "G4Polycone" )
474 //  {                                             444 //  {
475 //    switch( axis )                              445 //    switch( axis )
476 //    {                                           446 //    {
477 //      case kRho:                                447 //      case kRho:
478 //        fparam = new G4ParameterisationPolyc    448 //        fparam = new G4ParameterisationPolyconeRho( axis, nDivs, width,
479 //                                                449 //                                                    offset, mSolid, divType );
480 //        break;                                  450 //        break;
481 //      case kPhi:                                451 //      case kPhi:
482 //        fparam = new G4ParameterisationPolyc    452 //        fparam = new G4ParameterisationPolyconePhi( axis, nDivs, width,
483 //                                                453 //                                                    offset, mSolid, divType );
484 //        break;                                  454 //        break;
485 //      case kZAxis:                              455 //      case kZAxis:
486 //        fparam = new G4ParameterisationPolyc    456 //        fparam = new G4ParameterisationPolyconeZ( axis, nDivs, width,
487 //                                                457 //                                                  offset, mSolid, divType );
488 //        break;                                  458 //        break;
489 //      default:                                  459 //      default:
490 //        ErrorInAxis( axis, mSolid );            460 //        ErrorInAxis( axis, mSolid );
491 //      break;                                    461 //      break;
492 //    }                                           462 //    }
493 //  }                                             463 //  }
494 //  else if( mSolidType == "G4Polyhedra" )        464 //  else if( mSolidType == "G4Polyhedra" )
495 //  {                                             465 //  {
496 //    switch( axis )                              466 //    switch( axis )
497 //    {                                           467 //    {
498 //      case kRho:                                468 //      case kRho:
499 //        fparam = new G4ParameterisationPolyh    469 //        fparam = new G4ParameterisationPolyhedraRho( axis, nDivs, width,
500 //                                                470 //                                                    offset, mSolid, divType );
501 //        break;                                  471 //        break;
502 //      case kPhi:                                472 //      case kPhi:
503 //        fparam = new G4ParameterisationPolyh    473 //        fparam = new G4ParameterisationPolyhedraPhi( axis, nDivs, width,
504 //                                                474 //                                                    offset, mSolid, divType );
505 //        break;                                  475 //        break;
506 //      case kZAxis:                              476 //      case kZAxis:
507 //        fparam = new G4ParameterisationPolyh    477 //        fparam = new G4ParameterisationPolyhedraZ( axis, nDivs, width,
508 //                                                478 //                                                  offset, mSolid, divType );
509 //        break;                                  479 //        break;
510 //      default:                                  480 //      default:
511 //        ErrorInAxis( axis, mSolid );            481 //        ErrorInAxis( axis, mSolid );
512 //      break;                                    482 //      break;
513 //    }                                           483 //    }
514 //  }                                             484 //  }
515   else                                            485   else
516   {                                               486   {
517     std::ostringstream message;                   487     std::ostringstream message;
518     message << "Solid type not supported: " <<    488     message << "Solid type not supported: " << mSolidType << "." << G4endl
519             << "Divisions for " << mSolidType     489             << "Divisions for " << mSolidType << " not implemented.";
520     G4Exception("G4ReplicatedSlice::SetParamet    490     G4Exception("G4ReplicatedSlice::SetParameterisation()", "GeomDiv0001",
521                 FatalException, message);         491                 FatalException, message);
522   }                                               492   }
523                                                   493 
524   fparam->SetHalfGap(half_gap);                   494   fparam->SetHalfGap(half_gap);
525 }                                                 495 }
526                                                   496 
527 //--------------------------------------------    497 //--------------------------------------------------------------------------
528 void G4ReplicatedSlice::ErrorInAxis( EAxis axi    498 void G4ReplicatedSlice::ErrorInAxis( EAxis axis, G4VSolid* solid )
529 {                                                 499 {
530   G4String error = "Trying to divide solid " +    500   G4String error = "Trying to divide solid " + solid->GetName()
531                  + " of type " + solid->GetEnt    501                  + " of type " + solid->GetEntityType() + " along axis ";
532   switch( axis )                                  502   switch( axis )
533   {                                               503   {
534     case kXAxis:                                  504     case kXAxis:
535       error += "X.";                              505       error += "X.";
536       break;                                      506       break;
537     case kYAxis:                                  507     case kYAxis:
538       error += "Y.";                              508       error += "Y.";
539       break;                                      509       break;
540     case kZAxis:                                  510     case kZAxis:
541       error += "Z.";                              511       error += "Z.";
542       break;                                      512       break;
543     case kRho:                                    513     case kRho:
544       error += "Rho.";                            514       error += "Rho.";
545       break;                                      515       break;
546     case kRadial3D:                               516     case kRadial3D:
547       error += "Radial3D.";                       517       error += "Radial3D.";
548       break;                                      518       break;
549     case kPhi:                                    519     case kPhi:
550       error += "Phi.";                            520       error += "Phi.";
551       break;                                      521       break;
552     default:                                      522     default:
553       break;                                      523       break;
554   }                                               524   }
555   G4Exception("G4ReplicatedSlice::ErrorInAxis(    525   G4Exception("G4ReplicatedSlice::ErrorInAxis()", "GeomDiv0002",
556               FatalException, error);             526               FatalException, error);
557 }                                                 527 }
558                                                   528 
559 // The next methods are for specialised repeat    529 // The next methods are for specialised repeated volumes 
560 // (replicas, parameterised vol.) which are co << 530 //     (replicas, parameterised vol.) which are completely regular.
561 // Currently this is not applicable to divisio    531 // Currently this is not applicable to divisions  ( J.A. Nov 2005 )
562                                                << 
563 // -------------------------------------------    532 // ----------------------------------------------------------------------
564 // IsRegularStructure()                        << 533 // IsRegularRepeatedStructure()
565 //                                                534 //
566 G4bool G4ReplicatedSlice::IsRegularStructure()    535 G4bool G4ReplicatedSlice::IsRegularStructure() const
567 {                                                 536 {
568   return false;                                   537   return false;
569 }                                                 538 }           
570                                                   539 
571 // -------------------------------------------    540 // ----------------------------------------------------------------------
572 // GetRegularStructureId()                     << 541 // IsRegularRepeatedStructure()
573 //                                                542 //
574 G4int G4ReplicatedSlice::GetRegularStructureId    543 G4int G4ReplicatedSlice::GetRegularStructureId() const
575 {                                                 544 {
576   return 0;                                       545   return 0;  
577 }                                                 546 }           
578                                                   547