Geant4 Cross Reference

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


  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 // G4PVDivision Implementation file            << 
 27 //                                                 26 //
 28 // 26.05.03 - P.Arce, Initial version          <<  27 // $Id: G4PVDivision.cc 66356 2012-12-18 09:02:32Z gcosmo $
                                                   >>  28 //
                                                   >>  29 // class G4PVDivision Implementation file
                                                   >>  30 //
                                                   >>  31 // 26.05.03 - P.Arce Initial version
 29 // -------------------------------------------     32 // --------------------------------------------------------------------
 30                                                    33 
 31 #include "G4PVDivision.hh"                         34 #include "G4PVDivision.hh"
 32 #include "G4LogicalVolume.hh"                      35 #include "G4LogicalVolume.hh"
 33 #include "G4VSolid.hh"                             36 #include "G4VSolid.hh"
 34 #include "G4ReflectedSolid.hh"                     37 #include "G4ReflectedSolid.hh"
 35 #include "G4ParameterisationBox.hh"                38 #include "G4ParameterisationBox.hh"
 36 #include "G4ParameterisationTubs.hh"               39 #include "G4ParameterisationTubs.hh"
 37 #include "G4ParameterisationCons.hh"               40 #include "G4ParameterisationCons.hh"
 38 #include "G4ParameterisationTrd.hh"                41 #include "G4ParameterisationTrd.hh"
 39 #include "G4ParameterisationPara.hh"               42 #include "G4ParameterisationPara.hh"
 40 #include "G4ParameterisationPolycone.hh"           43 #include "G4ParameterisationPolycone.hh"
 41 #include "G4ParameterisationPolyhedra.hh"          44 #include "G4ParameterisationPolyhedra.hh"
 42                                                    45 
 43 //--------------------------------------------     46 //--------------------------------------------------------------------------
 44 G4PVDivision::G4PVDivision(const G4String& pNa     47 G4PVDivision::G4PVDivision(const G4String& pName,
 45                                  G4LogicalVolu     48                                  G4LogicalVolume* pLogical,
 46                                  G4LogicalVolu     49                                  G4LogicalVolume* pMotherLogical,
 47                            const EAxis pAxis,      50                            const EAxis pAxis,
 48                            const G4int nDivs,      51                            const G4int nDivs,
 49                            const G4double widt     52                            const G4double width,
 50                            const G4double offs     53                            const G4double offset )
 51   : G4PVReplica(pName, nDivs, pAxis, pLogical, <<  54   : G4VPhysicalVolume(0,G4ThreeVector(),pName,pLogical,0),
                                                   >>  55     fcopyNo(-1)
 52 {                                                  56 {
 53   if (pMotherLogical == nullptr)               <<  57   if (!pMotherLogical)
 54   {                                                58   {
 55     std::ostringstream message;                    59     std::ostringstream message;
 56     message << "Invalid setup." << G4endl          60     message << "Invalid setup." << G4endl
 57             << "NULL pointer specified as moth     61             << "NULL pointer specified as mother for volume: " << pName;
 58     G4Exception("G4PVDivision::G4PVDivision()"     62     G4Exception("G4PVDivision::G4PVDivision()", "GeomDiv0002",
 59                 FatalException, message);          63                 FatalException, message);
 60     return;                                        64     return;
 61   }                                                65   }
 62   if (pLogical == pMotherLogical)                  66   if (pLogical == pMotherLogical)
 63   {                                                67   {
 64     std::ostringstream message;                    68     std::ostringstream message;
 65     message << "Invalid setup." << G4endl          69     message << "Invalid setup." << G4endl
 66             << "Cannot place a volume inside i     70             << "Cannot place a volume inside itself! Volume: " << pName;
 67     G4Exception("G4PVDivision::G4PVDivision()"     71     G4Exception("G4PVDivision::G4PVDivision()", "GeomDiv0002",
 68                 FatalException, message);          72                 FatalException, message);
 69   }                                                73   }
 70   pMotherLogical->AddDaughter(this);               74   pMotherLogical->AddDaughter(this);
 71   SetMotherLogical(pMotherLogical);                75   SetMotherLogical(pMotherLogical);
 72   SetParameterisation(pMotherLogical, pAxis, n     76   SetParameterisation(pMotherLogical, pAxis, nDivs,
 73                       width, offset, DivNDIVan     77                       width, offset, DivNDIVandWIDTH);
 74   CheckAndSetParameters (pAxis, nDivs, width,      78   CheckAndSetParameters (pAxis, nDivs, width, offset,
 75                          DivNDIVandWIDTH, pMot     79                          DivNDIVandWIDTH, pMotherLogical);
 76 }                                                  80 }
 77                                                    81 
 78 //--------------------------------------------     82 //--------------------------------------------------------------------------
 79 G4PVDivision::G4PVDivision(const G4String& pNa     83 G4PVDivision::G4PVDivision(const G4String& pName,
 80                                  G4LogicalVolu     84                                  G4LogicalVolume* pLogical,
 81                                  G4LogicalVolu     85                                  G4LogicalVolume* pMotherLogical,
 82                            const EAxis pAxis,      86                            const EAxis pAxis,
 83                            const G4int nDivs,      87                            const G4int nDivs,
 84                            const G4double offs     88                            const G4double offset )
 85   : G4PVReplica(pName, nDivs, pAxis, pLogical, <<  89   : G4VPhysicalVolume(0,G4ThreeVector(),pName,pLogical,0),
                                                   >>  90     fcopyNo(-1)
 86 {                                                  91 {
 87   if (pMotherLogical == nullptr)               <<  92   if (!pMotherLogical)
 88   {                                                93   {
 89     std::ostringstream message;                    94     std::ostringstream message;
 90     message << "Invalid setup." << G4endl          95     message << "Invalid setup." << G4endl
 91             << "NULL pointer specified as moth     96             << "NULL pointer specified as mother! Volume: " << pName;
 92     G4Exception("G4PVDivision::G4PVDivision()"     97     G4Exception("G4PVDivision::G4PVDivision()", "GeomDiv0002",
 93                 FatalException, message);          98                 FatalException, message);
 94     return;                                        99     return;
 95   }                                               100   }
 96   if (pLogical == pMotherLogical)                 101   if (pLogical == pMotherLogical)
 97   {                                               102   {
 98     std::ostringstream message;                   103     std::ostringstream message;
 99     message << "Invalid setup." << G4endl         104     message << "Invalid setup." << G4endl
100             << "Cannot place a volume inside i    105             << "Cannot place a volume inside itself! Volume: " << pName;
101     G4Exception("G4PVDivision::G4PVDivision()"    106     G4Exception("G4PVDivision::G4PVDivision()", "GeomDiv0002",
102                 FatalException, message);         107                 FatalException, message);
103   }                                               108   }
104   pMotherLogical->AddDaughter(this);              109   pMotherLogical->AddDaughter(this);
105   SetMotherLogical(pMotherLogical);               110   SetMotherLogical(pMotherLogical);
106   SetParameterisation(pMotherLogical, pAxis, n    111   SetParameterisation(pMotherLogical, pAxis, nDivs, 0., offset, DivNDIV);
107   CheckAndSetParameters (pAxis, nDivs, 0., off    112   CheckAndSetParameters (pAxis, nDivs, 0., offset, DivNDIV, pMotherLogical);
108 }                                                 113 }
109                                                   114 
110 //--------------------------------------------    115 //--------------------------------------------------------------------------
111 G4PVDivision::G4PVDivision(const G4String& pNa    116 G4PVDivision::G4PVDivision(const G4String& pName,
112                                  G4LogicalVolu    117                                  G4LogicalVolume* pLogical,
113                                  G4LogicalVolu    118                                  G4LogicalVolume* pMotherLogical,
114                            const EAxis pAxis,     119                            const EAxis pAxis,
115                            const G4double widt    120                            const G4double width,
116                            const G4double offs    121                            const G4double offset )
117   : G4PVReplica(pName, 0, pAxis, pLogical, pMo << 122   : G4VPhysicalVolume(0,G4ThreeVector(),pName,pLogical,0),
                                                   >> 123     fcopyNo(-1)
118 {                                                 124 {
119   if (pMotherLogical == nullptr)               << 125   if (!pMotherLogical)
120   {                                               126   {
121     std::ostringstream message;                   127     std::ostringstream message;
122     message << "Invalid setup." << G4endl         128     message << "Invalid setup." << G4endl
123             << "NULL pointer specified as moth    129             << "NULL pointer specified as mother! Volume: " + pName;
124     G4Exception("G4PVDivision::G4PVDivision()"    130     G4Exception("G4PVDivision::G4PVDivision()", "GeomDiv0002",
125                 FatalException, message);         131                 FatalException, message);
126     return;                                       132     return;
127   }                                               133   }
128   if (pLogical == pMotherLogical)                 134   if (pLogical == pMotherLogical)
129   {                                               135   {
130     std::ostringstream message;                   136     std::ostringstream message;
131     message << "Invalid setup." << G4endl         137     message << "Invalid setup." << G4endl
132             << "Cannot place a volume inside i    138             << "Cannot place a volume inside itself! Volume: "+ pName;
133     G4Exception("G4PVDivision::G4PVDivision()"    139     G4Exception("G4PVDivision::G4PVDivision()", "GeomDiv0002",
134                 FatalException, message);         140                 FatalException, message);
135   }                                               141   }
136   pMotherLogical->AddDaughter(this);              142   pMotherLogical->AddDaughter(this);
137   SetMotherLogical(pMotherLogical);               143   SetMotherLogical(pMotherLogical);
138   SetParameterisation(pMotherLogical, pAxis, 0    144   SetParameterisation(pMotherLogical, pAxis, 0, width, offset, DivWIDTH);
139   CheckAndSetParameters (pAxis, 0, width, offs    145   CheckAndSetParameters (pAxis, 0, width, offset, DivWIDTH, pMotherLogical);
140 }                                                 146 }
141                                                   147 
142 //--------------------------------------------    148 //--------------------------------------------------------------------------
143 G4PVDivision::G4PVDivision(const G4String& pNa << 
144                                  G4LogicalVolu << 
145                                  G4VPhysicalVo << 
146                            const EAxis pAxis,  << 
147                            const G4int nDivs,  << 
148                            const G4double widt << 
149                            const G4double offs << 
150   : G4PVReplica(pName, nDivs, pAxis, pLogical, << 
151                 pMotherPhysical != nullptr ? p << 
152 {                                              << 
153   if (pMotherPhysical == nullptr)              << 
154   {                                            << 
155     std::ostringstream message;                << 
156     message << "Invalid setup." << G4endl      << 
157             << "NULL pointer specified as moth << 
158     G4Exception("G4PVDivision::G4PVDivision()" << 
159                 FatalException, message);      << 
160     return;                                    << 
161   }                                            << 
162   G4LogicalVolume* pMotherLogical = pMotherPhy << 
163   if (pLogical == pMotherLogical)              << 
164   {                                            << 
165     std::ostringstream message;                << 
166     message << "Invalid setup." << G4endl      << 
167             << "Cannot place a volume inside i << 
168     G4Exception("G4PVDivision::G4PVDivision()" << 
169                 FatalException, message);      << 
170   }                                            << 
171   pMotherLogical->AddDaughter(this);           << 
172   SetMotherLogical(pMotherLogical);            << 
173   SetParameterisation(pMotherLogical, pAxis, n << 
174                       width, offset, DivNDIVan << 
175   CheckAndSetParameters (pAxis, nDivs, width,  << 
176                          DivNDIVandWIDTH, pMot << 
177 }                                              << 
178                                                << 
179 //-------------------------------------------- << 
180 void                                              149 void
181 G4PVDivision::CheckAndSetParameters( const EAx    150 G4PVDivision::CheckAndSetParameters( const EAxis pAxis,
182                                      const G4i    151                                      const G4int nDivs,
183                                      const G4d    152                                      const G4double width,
184                                      const G4d    153                                      const G4double offset, 
185                                            Div    154                                            DivisionType divType,
186                                      const G4L    155                                      const G4LogicalVolume* pMotherLogical )
187 {                                                 156 {
188   if( divType == DivWIDTH )                       157   if( divType == DivWIDTH )
189   {                                               158   {
190     fnReplicas = fparam->GetNoDiv();              159     fnReplicas = fparam->GetNoDiv();
191   }                                               160   }
192   else                                            161   else
193   {                                               162   {
194     fnReplicas = nDivs;                           163     fnReplicas = nDivs;
195   }                                               164   }
196   if (fnReplicas < 1 )                            165   if (fnReplicas < 1 )
197   {                                               166   {
198     G4Exception("G4PVDivision::CheckAndSetPara    167     G4Exception("G4PVDivision::CheckAndSetParameters()", "GeomDiv0002",
199                 FatalException, "Illegal numbe    168                 FatalException, "Illegal number of replicas!");
200   }                                               169   }
201                                                   170 
202   if( divType != DivNDIV)                         171   if( divType != DivNDIV)
203   {                                               172   {
204     fwidth = fparam->GetWidth();                  173     fwidth = fparam->GetWidth();
205   }                                               174   }
206   else                                            175   else
207   {                                               176   {
208     fwidth = width;                               177     fwidth = width;
209   }                                               178   }
210   if( fwidth < 0 )                                179   if( fwidth < 0 )
211   {                                               180   {
212     G4Exception("G4PVDivision::CheckAndSetPara    181     G4Exception("G4PVDivision::CheckAndSetParameters()", "GeomDiv0002",
213                 FatalException, "Width must be    182                 FatalException, "Width must be positive!");
214   }                                               183   }
215                                                   184   
216   foffset = offset;                               185   foffset = offset;
217   fdivAxis = pAxis;                               186   fdivAxis = pAxis;
218                                                   187 
219   //!!!!! axis has to be x/y/z in G4VoxelLimit    188   //!!!!! axis has to be x/y/z in G4VoxelLimits::GetMinExtent
220   //                                              189   //
221   if( pAxis == kRho || pAxis == kRadial3D || p    190   if( pAxis == kRho || pAxis == kRadial3D || pAxis == kPhi )
222   {                                               191   {
223     faxis = kZAxis;                               192     faxis = kZAxis;
224   }                                               193   }
225   else                                            194   else
226   {                                               195   {
227     faxis = pAxis;                                196     faxis = pAxis;
228   }                                               197   }
229                                                   198   
230   // Create rotation matrix: for phi axis it w    199   // Create rotation matrix: for phi axis it will be changed
231   // in G4VPVParameterisation::ComputeTransfor    200   // in G4VPVParameterisation::ComputeTransformation, for others
232   // it will stay the unity                       201   // it will stay the unity
233   //                                              202   //
234   auto  pRMat = new G4RotationMatrix();        << 203   G4RotationMatrix *pRMat = new G4RotationMatrix();
235   SetRotation(pRMat);                             204   SetRotation(pRMat);
236                                                   205   
237   switch (faxis)                                  206   switch (faxis)
238   {                                               207   {
239     case kPhi:                                    208     case kPhi:
240       break;                                      209       break;
241     case kRho:                                    210     case kRho:
242     case kXAxis:                                  211     case kXAxis:
243     case kYAxis:                                  212     case kYAxis:
244     case kZAxis:                                  213     case kZAxis:
245       break;                                      214       break;
246     default:                                      215     default:
247       G4Exception("G4PVDivision::CheckAndSetPa    216       G4Exception("G4PVDivision::CheckAndSetParameters()", "GeomDiv0002",
248                   FatalException, "Unknown axi    217                   FatalException, "Unknown axis of replication.");
249       break;                                      218       break;
250   }                                               219   }
251                                                   220 
252                                                   221 
253   //----- Check that mother solid is of the sa    222   //----- Check that mother solid is of the same type than
254   //      daughter solid (otherwise, the corre    223   //      daughter solid (otherwise, the corresponding
255   //      Parameterisation::ComputeDimension()    224   //      Parameterisation::ComputeDimension() will not be called)
256   //                                              225   //
257   G4String msolType = pMotherLogical->GetSolid    226   G4String msolType = pMotherLogical->GetSolid()->GetEntityType();
258   G4String dsolType = GetLogicalVolume()->GetS    227   G4String dsolType = GetLogicalVolume()->GetSolid()->GetEntityType();
259   if( msolType != dsolType && ( msolType != "G    228   if( msolType != dsolType && ( msolType != "G4Trd" || dsolType != "G4Trap" ) )
260   {                                               229   {
261     std::ostringstream message;                   230     std::ostringstream message;
262     message << "Incorrect solid type for divis    231     message << "Incorrect solid type for division of volume "
263             << GetName() << "." << G4endl         232             << GetName() << "." << G4endl
264             << "It is: " << msolType              233             << "It is: " << msolType
265             << ", while it should be: " << dso    234             << ", while it should be: " << dsolType << "!";
266     G4Exception("G4PVDivision::CheckAndSetPara    235     G4Exception("G4PVDivision::CheckAndSetParameters()",
267                 "GeomDiv0002", FatalException,    236                 "GeomDiv0002", FatalException, message );
268   }                                               237   }
269 }                                                 238 }
270                                                   239 
271 //--------------------------------------------    240 //--------------------------------------------------------------------------
272 G4PVDivision::~G4PVDivision() = default;       << 241 G4PVDivision::~G4PVDivision()
                                                   >> 242 {
                                                   >> 243   delete GetRotation();
                                                   >> 244 }
273                                                   245 
274 //--------------------------------------------    246 //--------------------------------------------------------------------------
275 EAxis G4PVDivision::GetDivisionAxis() const       247 EAxis G4PVDivision::GetDivisionAxis() const
276 {                                                 248 {
277   return fdivAxis;                                249   return fdivAxis;
278 }                                                 250 }
279                                                   251 
280 //--------------------------------------------    252 //--------------------------------------------------------------------------
281 G4bool G4PVDivision::IsParameterised() const      253 G4bool G4PVDivision::IsParameterised() const
282 {                                                 254 { 
283   return true;                                    255   return true;
284 }                                                 256 }
285                                                   257 
286 //--------------------------------------------    258 //--------------------------------------------------------------------------
287 G4bool G4PVDivision::IsMany() const               259 G4bool G4PVDivision::IsMany() const
288 {                                                 260 {
289   return false;                                   261   return false; 
290 }                                                 262 }
291                                                   263 
292 //--------------------------------------------    264 //--------------------------------------------------------------------------
293 G4bool G4PVDivision::IsReplicated() const      << 265 G4int G4PVDivision::GetCopyNo() const
294 {                                                 266 {
295   return true;                                 << 267   return fcopyNo;
296 }                                                 268 }
297                                                   269 
298 //--------------------------------------------    270 //--------------------------------------------------------------------------
299 G4int G4PVDivision::GetMultiplicity() const    << 271 void  G4PVDivision::SetCopyNo(G4int newCopyNo)
300 {                                                 272 {
301   return fnReplicas;                           << 273   fcopyNo= newCopyNo;
                                                   >> 274 }
                                                   >> 275 
                                                   >> 276 //--------------------------------------------------------------------------
                                                   >> 277 G4bool G4PVDivision::IsReplicated() const
                                                   >> 278 {
                                                   >> 279   return true;
302 }                                                 280 }
303                                                   281 
304 //--------------------------------------------    282 //--------------------------------------------------------------------------
305 G4VPVParameterisation* G4PVDivision::GetParame    283 G4VPVParameterisation* G4PVDivision::GetParameterisation() const
306 {                                                 284 {
307   return fparam;                                  285   return fparam;
308 }                                                 286 }
309                                                   287 
310 //--------------------------------------------    288 //--------------------------------------------------------------------------
311 void G4PVDivision::GetReplicationData(EAxis& a    289 void G4PVDivision::GetReplicationData(EAxis& axis,
312                                       G4int& n    290                                       G4int& nDivs,
313                                       G4double    291                                       G4double& width,
314                                       G4double    292                                       G4double& offset,
315                                       G4bool&     293                                       G4bool& consuming ) const
316 {                                                 294 {
317   axis = faxis;                                << 295   axis=faxis;
318   nDivs = fnReplicas;                          << 296   nDivs=fnReplicas;
319   width = fwidth;                              << 297   width=fwidth;
320   offset = foffset;                            << 298   offset=foffset;
321   consuming = false;                           << 299   consuming=false;
322 }                                                 300 }
323                                                   301 
324 //-------------------------------------------- << 
325 EVolume G4PVDivision::VolumeType() const       << 
326 {                                              << 
327   return kParameterised;                       << 
328 }                                              << 
329                                                   302 
330 //--------------------------------------------    303 //--------------------------------------------------------------------------
331 // TODO: this method should check that the chi << 304 //TODO: this method should check that the child lv is of the correct type,
332 //       else the ComputeDimensions will never << 305 //      else the ComputeDimensions will never be called
333 //                                             << 
334 void G4PVDivision::SetParameterisation( G4Logi    306 void G4PVDivision::SetParameterisation( G4LogicalVolume* motherLogical,
335                                   const EAxis     307                                   const EAxis axis,
336                                   const G4int     308                                   const G4int nDivs,
337                                   const G4doub    309                                   const G4double width,
338                                   const G4doub    310                                   const G4double offset,
339                                         Divisi    311                                         DivisionType divType )
340 {                                                 312 {
341   // Check that solid is compatible with mothe    313   // Check that solid is compatible with mother solid and axis of division   
342   // CheckSolid( solid, motherSolid );            314   // CheckSolid( solid, motherSolid );
343   // G4cout << " Axis " << axis << G4endl;        315   // G4cout << " Axis " << axis << G4endl;
344                                                   316 
345   G4VSolid* mSolid = motherLogical->GetSolid()    317   G4VSolid* mSolid = motherLogical->GetSolid();
346   G4String mSolidType = mSolid->GetEntityType(    318   G4String mSolidType = mSolid->GetEntityType();
347                                                   319 
348   // If the solid is a reflected one, update t    320   // If the solid is a reflected one, update type to its
349   // real constituent solid.                      321   // real constituent solid.
350   //                                              322   // 
351   if (mSolidType == "G4ReflectedSolid")           323   if (mSolidType == "G4ReflectedSolid")
352   {                                               324   {
353       mSolidType = ((G4ReflectedSolid*)mSolid)    325       mSolidType = ((G4ReflectedSolid*)mSolid)->GetConstituentMovedSolid()
354                  ->GetEntityType();               326                  ->GetEntityType(); 
355   }                                               327   }    
356                                                   328 
357   // Parameterisation type depend of mother so    329   // Parameterisation type depend of mother solid type and axis of division
358   //                                              330   //
359   if( mSolidType == "G4Box" )                     331   if( mSolidType == "G4Box" )
360   {                                               332   {
361     switch( axis )                                333     switch( axis )
362     {                                             334     {
363       case kXAxis:                                335       case kXAxis:
364         fparam = new G4ParameterisationBoxX( a    336         fparam = new G4ParameterisationBoxX( axis, nDivs, width,
365                                              o    337                                              offset, mSolid, divType );
366         break;                                    338         break;
367       case kYAxis:                                339       case kYAxis:
368         fparam = new G4ParameterisationBoxY( a    340         fparam = new G4ParameterisationBoxY( axis, nDivs, width,
369                                              o    341                                              offset, mSolid, divType );
370         break;                                    342         break;
371       case kZAxis:                                343       case kZAxis:
372         fparam = new G4ParameterisationBoxZ( a    344         fparam = new G4ParameterisationBoxZ( axis, nDivs, width,
373                                              o    345                                              offset, mSolid, divType );
374         break;                                    346         break;
375       default:                                    347       default:
376         ErrorInAxis( axis, mSolid );              348         ErrorInAxis( axis, mSolid );
377         break;                                    349         break;
378     }                                             350     }
379   }                                               351   }
380   else if( mSolidType == "G4Tubs" )               352   else if( mSolidType == "G4Tubs" )
381   {                                               353   {
382     switch( axis )                                354     switch( axis )
383     {                                             355     {
384       case kRho:                                  356       case kRho:
385         fparam = new G4ParameterisationTubsRho    357         fparam = new G4ParameterisationTubsRho( axis, nDivs, width,
386                                                   358                                                 offset, mSolid, divType );
387         break;                                    359         break;
388       case kPhi:                                  360       case kPhi:
389         fparam = new G4ParameterisationTubsPhi    361         fparam = new G4ParameterisationTubsPhi( axis, nDivs, width,
390                                                   362                                                 offset, mSolid, divType );
391         break;                                    363         break;
392       case kZAxis:                                364       case kZAxis:
393         fparam = new G4ParameterisationTubsZ(     365         fparam = new G4ParameterisationTubsZ( axis, nDivs, width,
394                                                   366                                               offset, mSolid, divType );
395         break;                                    367         break;
396       default:                                    368       default:
397         ErrorInAxis( axis, mSolid );              369         ErrorInAxis( axis, mSolid );
398         break;                                    370         break;
399     }                                             371     }
400   }                                               372   }
401   else if( mSolidType == "G4Cons" )               373   else if( mSolidType == "G4Cons" )
402   {                                               374   {
403     switch( axis )                                375     switch( axis )
404     {                                             376     {
405       case kRho:                                  377       case kRho:
406         fparam = new G4ParameterisationConsRho    378         fparam = new G4ParameterisationConsRho( axis, nDivs, width,
407                                                   379                                                 offset, mSolid, divType );
408         break;                                    380         break;
409       case kPhi:                                  381       case kPhi:
410         fparam = new G4ParameterisationConsPhi    382         fparam = new G4ParameterisationConsPhi( axis, nDivs, width,
411                                                   383                                                 offset, mSolid, divType );
412         break;                                    384         break;
413       case kZAxis:                                385       case kZAxis:
414         fparam = new G4ParameterisationConsZ(     386         fparam = new G4ParameterisationConsZ( axis, nDivs, width,
415                                                   387                                               offset, mSolid, divType );
416         break;                                    388         break;
417       default:                                    389       default:
418         ErrorInAxis( axis, mSolid );              390         ErrorInAxis( axis, mSolid );
419         break;                                    391         break;
420     }                                             392     }
421   }                                               393   }
422   else if( mSolidType == "G4Trd" )                394   else if( mSolidType == "G4Trd" )
423   {                                               395   { 
424     switch( axis )                                396     switch( axis )
425     {                                             397     {
426       case kXAxis:                                398       case kXAxis:
427         fparam = new G4ParameterisationTrdX( a    399         fparam = new G4ParameterisationTrdX( axis, nDivs, width,
428                                              o    400                                              offset, mSolid, divType );
429         break;                                    401         break;
430       case kYAxis:                                402       case kYAxis:
431         fparam = new G4ParameterisationTrdY( a    403         fparam = new G4ParameterisationTrdY( axis, nDivs, width,
432                                              o    404                                              offset, mSolid, divType );
433         break;                                    405         break;
434       case kZAxis:                                406       case kZAxis:
435         fparam = new G4ParameterisationTrdZ( a    407         fparam = new G4ParameterisationTrdZ( axis, nDivs, width,
436                                              o    408                                              offset, mSolid, divType );
437         break;                                    409         break;
438       default:                                    410       default:
439         ErrorInAxis( axis, mSolid );              411         ErrorInAxis( axis, mSolid );
440         break;                                    412         break;
441     }                                             413     }
442   }                                               414   }
443   else if( mSolidType == "G4Para" )               415   else if( mSolidType == "G4Para" )
444   {                                               416   { 
445     switch( axis )                                417     switch( axis )
446     {                                             418     {
447       case kXAxis:                                419       case kXAxis:
448         fparam = new G4ParameterisationParaX(     420         fparam = new G4ParameterisationParaX( axis, nDivs, width,
449                                              o    421                                              offset, mSolid, divType );
450         break;                                    422         break;
451       case kYAxis:                                423       case kYAxis:
452         fparam = new G4ParameterisationParaY(     424         fparam = new G4ParameterisationParaY( axis, nDivs, width,
453                                              o    425                                              offset, mSolid, divType );
454         break;                                    426         break;
455       case kZAxis:                                427       case kZAxis:
456         fparam = new G4ParameterisationParaZ(     428         fparam = new G4ParameterisationParaZ( axis, nDivs, width,
457                                              o    429                                              offset, mSolid, divType );
458         break;                                    430         break;
459       default:                                    431       default:
460         ErrorInAxis( axis, mSolid );              432         ErrorInAxis( axis, mSolid );
461         break;                                    433         break;
462     }                                             434     }
463   }                                               435   }
464 //  else if( mSolidType == "G4Trap" )             436 //  else if( mSolidType == "G4Trap" )
465 //  {                                             437 //  {
466 //  }                                             438 //  }
467   else if( mSolidType == "G4Polycone" )           439   else if( mSolidType == "G4Polycone" )
468   {                                               440   {
469     switch( axis )                                441     switch( axis )
470     {                                             442     {
471       case kRho:                                  443       case kRho:
472         fparam = new G4ParameterisationPolycon    444         fparam = new G4ParameterisationPolyconeRho( axis, nDivs, width,
473                                                   445                                                     offset, mSolid, divType );
474         break;                                    446         break;
475       case kPhi:                                  447       case kPhi:
476         fparam = new G4ParameterisationPolycon    448         fparam = new G4ParameterisationPolyconePhi( axis, nDivs, width,
477                                                   449                                                     offset, mSolid, divType );
478         break;                                    450         break;
479       case kZAxis:                                451       case kZAxis:
480         fparam = new G4ParameterisationPolycon    452         fparam = new G4ParameterisationPolyconeZ( axis, nDivs, width,
481                                                   453                                                   offset, mSolid, divType );
482         break;                                    454         break;
483       default:                                    455       default:
484         ErrorInAxis( axis, mSolid );              456         ErrorInAxis( axis, mSolid );
485       break;                                      457       break;
486     }                                             458     }
487   }                                               459   }
488   else if( mSolidType == "G4Polyhedra" )          460   else if( mSolidType == "G4Polyhedra" )
489   {                                               461   {
490     switch( axis )                                462     switch( axis )
491     {                                             463     {
492       case kRho:                                  464       case kRho:
493         fparam = new G4ParameterisationPolyhed    465         fparam = new G4ParameterisationPolyhedraRho( axis, nDivs, width,
494                                                   466                                                     offset, mSolid, divType );
495         break;                                    467         break;
496       case kPhi:                                  468       case kPhi:
497         fparam = new G4ParameterisationPolyhed    469         fparam = new G4ParameterisationPolyhedraPhi( axis, nDivs, width,
498                                                   470                                                     offset, mSolid, divType );
499         break;                                    471         break;
500       case kZAxis:                                472       case kZAxis:
501         fparam = new G4ParameterisationPolyhed    473         fparam = new G4ParameterisationPolyhedraZ( axis, nDivs, width,
502                                                   474                                                   offset, mSolid, divType );
503         break;                                    475         break;
504       default:                                    476       default:
505         ErrorInAxis( axis, mSolid );              477         ErrorInAxis( axis, mSolid );
506       break;                                      478       break;
507     }                                             479     }
508   }                                               480   }
509   else                                            481   else
510   {                                               482   {
511     std::ostringstream message;                   483     std::ostringstream message;
512     message << "Solid type " << mSolidType <<     484     message << "Solid type " << mSolidType << " not supported!"  << G4endl
513             << "Divisions for " << mSolidType     485             << "Divisions for " << mSolidType << " are not implemented.";
514     G4Exception("G4PVDivision::SetParameterisa    486     G4Exception("G4PVDivision::SetParameterisation()", "GeomDiv0001",
515                 FatalException, message);         487                 FatalException, message);
516   }                                               488   }
517 }                                                 489 }
518                                                   490 
519 //--------------------------------------------    491 //--------------------------------------------------------------------------
520 void G4PVDivision::ErrorInAxis( EAxis axis, G4    492 void G4PVDivision::ErrorInAxis( EAxis axis, G4VSolid* solid )
521 {                                                 493 {
522   G4String error = "Trying to divide solid " +    494   G4String error = "Trying to divide solid " + solid->GetName()
523                  + " of type " + solid->GetEnt    495                  + " of type " + solid->GetEntityType() + " along axis ";
524   switch( axis )                                  496   switch( axis )
525   {                                               497   {
526     case kXAxis:                                  498     case kXAxis:
527       error += "X.";                              499       error += "X.";
528       break;                                      500       break;
529     case kYAxis:                                  501     case kYAxis:
530       error += "Y.";                              502       error += "Y.";
531       break;                                      503       break;
532     case kZAxis:                                  504     case kZAxis:
533       error += "Z.";                              505       error += "Z.";
534       break;                                      506       break;
535     case kRho:                                    507     case kRho:
536       error += "Rho.";                            508       error += "Rho.";
537       break;                                      509       break;
538     case kRadial3D:                               510     case kRadial3D:
539       error += "Radial3D.";                       511       error += "Radial3D.";
540       break;                                      512       break;
541     case kPhi:                                    513     case kPhi:
542       error += "Phi.";                            514       error += "Phi.";
543       break;                                      515       break;
544     default:                                      516     default:
545       break;                                      517       break;
546   }                                               518   }
547   G4Exception("G4PVDivision::ErrorInAxis()", "    519   G4Exception("G4PVDivision::ErrorInAxis()", "GeomDiv0002",
548               FatalException, error);             520               FatalException, error);
549 }                                                 521 }
550                                                << 522 // The next methods are for specialised repeated volumes 
551 // The next methods are for specialised repeat << 523 //     (replicas, parameterised vol.) which are completely regular.
552 // parameterised vol.) which are completely re << 
553 // Currently this is not applicable to divisio    524 // Currently this is not applicable to divisions  ( J.A. Nov 2005 )
554                                                << 
555 // -------------------------------------------    525 // ----------------------------------------------------------------------
556 // IsRegularStructure()                        << 526 // IsRegularRepeatedStructure()
557 //                                                527 //
558 G4bool G4PVDivision::IsRegularStructure() cons    528 G4bool G4PVDivision::IsRegularStructure() const
559 {                                                 529 {
560   return false;                                   530   return false;
561 }                                                 531 }           
562                                                   532 
563 // -------------------------------------------    533 // ----------------------------------------------------------------------
564 // GetRegularStructureId()                     << 534 // IsRegularRepeatedStructure()
565 //                                                535 //
566 G4int G4PVDivision::GetRegularStructureId() co    536 G4int G4PVDivision::GetRegularStructureId() const
567 {                                                 537 {
568   return 0;                                       538   return 0;  
569 }                                                 539 }           
                                                   >> 540 // This is for specialised repeated volumes (replicas, parameterised vol.)
570                                                   541