Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/solids/Boolean/src/G4DisplacedSolid.cc

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

Diff markup

Differences between /geometry/solids/Boolean/src/G4DisplacedSolid.cc (Version 11.3.0) and /geometry/solids/Boolean/src/G4DisplacedSolid.cc (Version 10.5.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // Implementation of G4DisplacedSolid class fo <<  26 //
                                                   >>  27 //
                                                   >>  28 // Implementation for G4DisplacedSolid class for boolean 
 27 // operations between other solids                 29 // operations between other solids
 28 //                                                 30 //
                                                   >>  31 // History:
                                                   >>  32 //
 29 // 28.10.98 V.Grichine: created                    33 // 28.10.98 V.Grichine: created
                                                   >>  34 // 14.11.99 V.Grichine: modifications in CalculateExtent(...) method
                                                   >>  35 // 22.11.00 V.Grichine: new set methods for matrix/vectors
 30 // 28.02.18 E.Tcherniaev: improved contruction     36 // 28.02.18 E.Tcherniaev: improved contruction from G4DisplacedSolid
                                                   >>  37 //
 31 // -------------------------------------------     38 // --------------------------------------------------------------------
 32                                                    39 
 33 #include "G4DisplacedSolid.hh"                     40 #include "G4DisplacedSolid.hh"
 34                                                    41 
 35 #include "G4VoxelLimits.hh"                        42 #include "G4VoxelLimits.hh"
 36                                                    43 
 37 #include "G4VPVParameterisation.hh"                44 #include "G4VPVParameterisation.hh"
 38                                                    45 
 39 #include "G4VGraphicsScene.hh"                     46 #include "G4VGraphicsScene.hh"
 40 #include "G4Polyhedron.hh"                         47 #include "G4Polyhedron.hh"
 41                                                    48 
 42 //////////////////////////////////////////////     49 ////////////////////////////////////////////////////////////////
 43 //                                                 50 //
 44 // Constructor for transformation like rotatio     51 // Constructor for transformation like rotation of frame then translation 
 45 // in new frame. It is similar to 1st constrac     52 // in new frame. It is similar to 1st constractor in G4PVPlacement
 46                                                    53 
 47 G4DisplacedSolid::G4DisplacedSolid( const G4St     54 G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
 48                                           G4VS     55                                           G4VSolid* pSolid ,
 49                                           G4Ro     56                                           G4RotationMatrix* rotMatrix,
 50                                     const G4Th     57                                     const G4ThreeVector& transVector    )
 51   : G4VSolid(pName)                            <<  58   : G4VSolid(pName), fRebuildPolyhedron(false), fpPolyhedron(0)
 52 {                                                  59 {
 53   if (pSolid->GetEntityType() == "G4DisplacedS     60   if (pSolid->GetEntityType() == "G4DisplacedSolid")
 54   {                                                61   {
 55     fPtrSolid = ((G4DisplacedSolid*)pSolid)->G     62     fPtrSolid = ((G4DisplacedSolid*)pSolid)->GetConstituentMovedSolid();
 56     G4AffineTransform t1 = ((G4DisplacedSolid*     63     G4AffineTransform t1 = ((G4DisplacedSolid*)pSolid)->GetDirectTransform();
 57     G4AffineTransform t2 = G4AffineTransform(r     64     G4AffineTransform t2 = G4AffineTransform(rotMatrix,transVector);
 58     fDirectTransform = new G4AffineTransform(t     65     fDirectTransform = new G4AffineTransform(t1*t2);
 59   }                                                66   }
 60   else                                             67   else
 61   {                                                68   { 
 62     fPtrSolid = pSolid;                            69     fPtrSolid = pSolid;
 63     fDirectTransform = new G4AffineTransform(r     70     fDirectTransform = new G4AffineTransform(rotMatrix,transVector);
 64   }                                                71   }
 65   fPtrTransform = new G4AffineTransform(fDirec     72   fPtrTransform = new G4AffineTransform(fDirectTransform->Inverse());
 66 }                                                  73 }
 67                                                    74 
 68 //////////////////////////////////////////////     75 /////////////////////////////////////////////////////////////////////////////////
 69 //                                                 76 //
 70 // Constructor                                     77 // Constructor
 71                                                    78 
 72 G4DisplacedSolid::G4DisplacedSolid( const G4St     79 G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
 73                                           G4VS     80                                           G4VSolid* pSolid ,
 74                                     const G4Tr     81                                     const G4Transform3D& transform  )
 75   : G4VSolid(pName)                            <<  82   : G4VSolid(pName), fRebuildPolyhedron(false), fpPolyhedron(0)
 76 {                                                  83 {
 77   if (pSolid->GetEntityType() == "G4DisplacedS     84   if (pSolid->GetEntityType() == "G4DisplacedSolid")
 78   {                                                85   {
 79     fPtrSolid = ((G4DisplacedSolid*)pSolid)->G     86     fPtrSolid = ((G4DisplacedSolid*)pSolid)->GetConstituentMovedSolid();
 80     G4AffineTransform t1 = ((G4DisplacedSolid*     87     G4AffineTransform t1 = ((G4DisplacedSolid*)pSolid)->GetDirectTransform();
 81     G4AffineTransform t2 = G4AffineTransform(t     88     G4AffineTransform t2 = G4AffineTransform(transform.getRotation().inverse(),
 82                                              t     89                                              transform.getTranslation());
 83     fDirectTransform = new G4AffineTransform(t     90     fDirectTransform = new G4AffineTransform(t1*t2);
 84   }                                                91   }
 85   else                                             92   else
 86   {                                                93   { 
 87     fPtrSolid = pSolid;                            94     fPtrSolid = pSolid;
 88     fDirectTransform = new G4AffineTransform(t     95     fDirectTransform = new G4AffineTransform(transform.getRotation().inverse(),
 89                                              t     96                                              transform.getTranslation()) ;
 90   }                                                97   }
 91   fPtrTransform = new G4AffineTransform(fDirec     98   fPtrTransform = new G4AffineTransform(fDirectTransform->Inverse());
 92 }                                                  99 }
 93                                                   100 
 94 //////////////////////////////////////////////    101 ///////////////////////////////////////////////////////////////////
 95 //                                                102 //
 96 // Constructor for use with creation of Transi    103 // Constructor for use with creation of Transient object
 97 // from Persistent object                         104 // from Persistent object
 98                                                   105 
 99 G4DisplacedSolid::G4DisplacedSolid( const G4St    106 G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
100                                           G4VS    107                                           G4VSolid* pSolid ,
101                                     const G4Af    108                                     const G4AffineTransform directTransform )
102   : G4VSolid(pName)                            << 109   : G4VSolid(pName), fRebuildPolyhedron(false), fpPolyhedron(0)
103 {                                                 110 {
104   if (pSolid->GetEntityType() == "G4DisplacedS    111   if (pSolid->GetEntityType() == "G4DisplacedSolid")
105   {                                               112   {
106     fPtrSolid = ((G4DisplacedSolid*)pSolid)->G    113     fPtrSolid = ((G4DisplacedSolid*)pSolid)->GetConstituentMovedSolid();
107     G4AffineTransform t1 = ((G4DisplacedSolid*    114     G4AffineTransform t1 = ((G4DisplacedSolid*)pSolid)->GetDirectTransform();
108     auto  t2 = G4AffineTransform(directTransfo << 115     G4AffineTransform t2 = G4AffineTransform(directTransform);
109     fDirectTransform = new G4AffineTransform(t    116     fDirectTransform = new G4AffineTransform(t1*t2);
110   }                                               117   }
111   else                                            118   else
112   {                                               119   { 
113     fPtrSolid = pSolid;                           120     fPtrSolid = pSolid;
114     fDirectTransform = new G4AffineTransform(d    121     fDirectTransform = new G4AffineTransform(directTransform);
115   }                                               122   }
116   fPtrTransform = new G4AffineTransform(fDirec    123   fPtrTransform = new G4AffineTransform(fDirectTransform->Inverse());
117 }                                                 124 }
118                                                   125 
119 //////////////////////////////////////////////    126 ///////////////////////////////////////////////////////////////////
120 //                                                127 //
121 // Fake default constructor - sets only member    128 // Fake default constructor - sets only member data and allocates memory
122 //                            for usage restri    129 //                            for usage restricted to object persistency.
123                                                   130 
124 G4DisplacedSolid::G4DisplacedSolid( __void__&     131 G4DisplacedSolid::G4DisplacedSolid( __void__& a )
125   : G4VSolid(a)                                << 132   : G4VSolid(a), fPtrSolid(0), fPtrTransform(0),
                                                   >> 133     fDirectTransform(0), fRebuildPolyhedron(false), fpPolyhedron(0)
126 {                                                 134 {
127 }                                                 135 }
128                                                   136 
129 //////////////////////////////////////////////    137 ///////////////////////////////////////////////////////////////////
130 //                                                138 //
131 // Destructor                                     139 // Destructor
132                                                   140 
133 G4DisplacedSolid::~G4DisplacedSolid()             141 G4DisplacedSolid::~G4DisplacedSolid() 
134 {                                                 142 {
135   CleanTransformations();                         143   CleanTransformations();
136   delete fpPolyhedron; fpPolyhedron = nullptr; << 144   delete fpPolyhedron; fpPolyhedron = 0;
137 }                                                 145 }
138                                                   146 
139 //////////////////////////////////////////////    147 ///////////////////////////////////////////////////////////////
140 //                                                148 //
141 // Copy constructor                               149 // Copy constructor
142                                                   150 
143 G4DisplacedSolid::G4DisplacedSolid(const G4Dis    151 G4DisplacedSolid::G4DisplacedSolid(const G4DisplacedSolid& rhs)
144   : G4VSolid (rhs), fPtrSolid(rhs.fPtrSolid)   << 152   : G4VSolid (rhs), fPtrSolid(rhs.fPtrSolid),
                                                   >> 153     fRebuildPolyhedron(false), fpPolyhedron(0)
145 {                                                 154 {
146   fPtrTransform = new G4AffineTransform(*(rhs.    155   fPtrTransform = new G4AffineTransform(*(rhs.fPtrTransform));
147   fDirectTransform = new G4AffineTransform(*(r    156   fDirectTransform = new G4AffineTransform(*(rhs.fDirectTransform));
148 }                                                 157 }
149                                                   158 
150 //////////////////////////////////////////////    159 ///////////////////////////////////////////////////////////////
151 //                                                160 //
152 // Assignment operator                            161 // Assignment operator
153                                                   162 
154 G4DisplacedSolid& G4DisplacedSolid::operator =    163 G4DisplacedSolid& G4DisplacedSolid::operator = (const G4DisplacedSolid& rhs) 
155 {                                                 164 {
156   // Check assignment to self                     165   // Check assignment to self
157   //                                              166   //
158   if (this == &rhs)  { return *this; }            167   if (this == &rhs)  { return *this; }
159                                                   168 
160   // Copy base class data                         169   // Copy base class data
161   //                                              170   //
162   G4VSolid::operator=(rhs);                       171   G4VSolid::operator=(rhs);
163                                                   172 
164   // Copy data                                    173   // Copy data
165   //                                              174   //
166   fPtrSolid = rhs.fPtrSolid;                      175   fPtrSolid = rhs.fPtrSolid;
167   delete fPtrTransform; delete fDirectTransfor    176   delete fPtrTransform; delete fDirectTransform;
168   fPtrTransform = new G4AffineTransform(*(rhs.    177   fPtrTransform = new G4AffineTransform(*(rhs.fPtrTransform));
169   fDirectTransform = new G4AffineTransform(*(r    178   fDirectTransform = new G4AffineTransform(*(rhs.fDirectTransform));
170   fRebuildPolyhedron = false;                     179   fRebuildPolyhedron = false;
171   delete fpPolyhedron; fpPolyhedron = nullptr; << 180   delete fpPolyhedron; fpPolyhedron= 0;
172                                                   181 
173   return *this;                                   182   return *this;
174 }                                                 183 }  
175                                                   184 
176 void G4DisplacedSolid::CleanTransformations()     185 void G4DisplacedSolid::CleanTransformations()
177 {                                                 186 {
178   if(fPtrTransform != nullptr)                 << 187   if(fPtrTransform)
179   {                                               188   {
180     delete fPtrTransform; fPtrTransform = null << 189     delete fPtrTransform;  fPtrTransform=0;
181     delete fDirectTransform; fDirectTransform  << 190     delete fDirectTransform;  fDirectTransform=0;
182   }                                               191   }
183 }                                                 192 }
184                                                   193 
185 const G4DisplacedSolid* G4DisplacedSolid::GetD    194 const G4DisplacedSolid* G4DisplacedSolid::GetDisplacedSolidPtr() const   
186 {                                                 195 {
187   return this;                                    196   return this;
188 }                                                 197 }
189                                                   198 
190 G4DisplacedSolid* G4DisplacedSolid::GetDisplac    199 G4DisplacedSolid* G4DisplacedSolid::GetDisplacedSolidPtr() 
191 {                                                 200 {
192   return this;                                    201   return this;
193 }                                                 202 }
194                                                   203 
195 G4VSolid* G4DisplacedSolid::GetConstituentMove    204 G4VSolid* G4DisplacedSolid::GetConstituentMovedSolid() const
196 {                                                 205 { 
197   return fPtrSolid;                               206   return fPtrSolid; 
198 }                                                 207 } 
199                                                   208 
200 //////////////////////////////////////////////    209 /////////////////////////////////////////////////////////////////////////////
201                                                   210 
202 G4AffineTransform  G4DisplacedSolid::GetTransf    211 G4AffineTransform  G4DisplacedSolid::GetTransform() const
203 {                                                 212 {
204   G4AffineTransform aTransform = *fPtrTransfor    213   G4AffineTransform aTransform = *fPtrTransform;
205   return aTransform;                              214   return aTransform;
206 }                                                 215 }
207                                                   216 
208 void G4DisplacedSolid::SetTransform(G4AffineTr    217 void G4DisplacedSolid::SetTransform(G4AffineTransform& transform) 
209 {                                                 218 {
210   fPtrTransform = &transform ;                    219   fPtrTransform = &transform ;
211   fRebuildPolyhedron = true;                      220   fRebuildPolyhedron = true;
212 }                                                 221 }
213                                                   222 
214 //////////////////////////////////////////////    223 //////////////////////////////////////////////////////////////////////////////
215                                                   224 
216 G4AffineTransform  G4DisplacedSolid::GetDirect    225 G4AffineTransform  G4DisplacedSolid::GetDirectTransform() const
217 {                                                 226 {
218   G4AffineTransform aTransform= *fDirectTransf    227   G4AffineTransform aTransform= *fDirectTransform;
219   return aTransform;                              228   return aTransform;
220 }                                                 229 }
221                                                   230 
222 void G4DisplacedSolid::SetDirectTransform(G4Af    231 void G4DisplacedSolid::SetDirectTransform(G4AffineTransform& transform) 
223 {                                                 232 {
224   fDirectTransform = &transform ;                 233   fDirectTransform = &transform ;
225   fRebuildPolyhedron = true;                      234   fRebuildPolyhedron = true;
226 }                                                 235 }
227                                                   236 
228 //////////////////////////////////////////////    237 /////////////////////////////////////////////////////////////////////////////
229                                                   238 
230 G4RotationMatrix G4DisplacedSolid::GetFrameRot    239 G4RotationMatrix G4DisplacedSolid::GetFrameRotation() const
231 {                                                 240 {
232   G4RotationMatrix InvRotation = fDirectTransf << 241   G4RotationMatrix InvRotation= fDirectTransform->NetRotation();
233   return InvRotation;                             242   return InvRotation;
234 }                                                 243 }
235                                                   244 
236 void G4DisplacedSolid::SetFrameRotation(const     245 void G4DisplacedSolid::SetFrameRotation(const G4RotationMatrix& matrix)
237 {                                                 246 {
238   fDirectTransform->SetNetRotation(matrix);       247   fDirectTransform->SetNetRotation(matrix);
239   fRebuildPolyhedron = true;                      248   fRebuildPolyhedron = true;
240 }                                                 249 }
241                                                   250 
242 //////////////////////////////////////////////    251 /////////////////////////////////////////////////////////////////////////////
243                                                   252 
244 G4ThreeVector  G4DisplacedSolid::GetFrameTrans    253 G4ThreeVector  G4DisplacedSolid::GetFrameTranslation() const
245 {                                                 254 {
246   return fPtrTransform->NetTranslation();         255   return fPtrTransform->NetTranslation();
247 }                                                 256 }
248                                                   257 
249 void G4DisplacedSolid::SetFrameTranslation(con    258 void G4DisplacedSolid::SetFrameTranslation(const G4ThreeVector& vector)
250 {                                                 259 {
251   fPtrTransform->SetNetTranslation(vector);       260   fPtrTransform->SetNetTranslation(vector);
252   fRebuildPolyhedron = true;                      261   fRebuildPolyhedron = true;
253 }                                                 262 }
254                                                   263 
255 //////////////////////////////////////////////    264 ///////////////////////////////////////////////////////////////
256                                                   265 
257 G4RotationMatrix G4DisplacedSolid::GetObjectRo    266 G4RotationMatrix G4DisplacedSolid::GetObjectRotation() const
258 {                                                 267 {
259   G4RotationMatrix Rotation = fPtrTransform->N << 268   G4RotationMatrix Rotation= fPtrTransform->NetRotation();
260   return Rotation;                                269   return Rotation;
261 }                                                 270 }
262                                                   271 
263 void G4DisplacedSolid::SetObjectRotation(const    272 void G4DisplacedSolid::SetObjectRotation(const G4RotationMatrix& matrix)
264 {                                                 273 {
265   fPtrTransform->SetNetRotation(matrix);          274   fPtrTransform->SetNetRotation(matrix);
266   fRebuildPolyhedron = true;                      275   fRebuildPolyhedron = true;
267 }                                                 276 }
268                                                   277 
269 //////////////////////////////////////////////    278 ///////////////////////////////////////////////////////////////////////
270                                                   279 
271 G4ThreeVector  G4DisplacedSolid::GetObjectTran    280 G4ThreeVector  G4DisplacedSolid::GetObjectTranslation() const
272 {                                                 281 {
273   return fDirectTransform->NetTranslation();      282   return fDirectTransform->NetTranslation();
274 }                                                 283 }
275                                                   284 
276 void G4DisplacedSolid::SetObjectTranslation(co    285 void G4DisplacedSolid::SetObjectTranslation(const G4ThreeVector& vector)
277 {                                                 286 {
278   fDirectTransform->SetNetTranslation(vector);    287   fDirectTransform->SetNetTranslation(vector);
279   fRebuildPolyhedron = true;                      288   fRebuildPolyhedron = true;
280 }                                                 289 }
281                                                   290 
282 //////////////////////////////////////////////    291 //////////////////////////////////////////////////////////////////////////
283 //                                                292 //
284 // Get bounding box                               293 // Get bounding box
285                                                   294 
286 void G4DisplacedSolid::BoundingLimits(G4ThreeV    295 void G4DisplacedSolid::BoundingLimits(G4ThreeVector& pMin,
287                                       G4ThreeV    296                                       G4ThreeVector& pMax) const
288 {                                                 297 {
289   if (!fDirectTransform->IsRotated())             298   if (!fDirectTransform->IsRotated())
290   {                                               299   {
291     // Special case of pure translation           300     // Special case of pure translation
292     //                                            301     //
293     fPtrSolid->BoundingLimits(pMin,pMax);         302     fPtrSolid->BoundingLimits(pMin,pMax);
294     G4ThreeVector offset = fDirectTransform->N    303     G4ThreeVector offset = fDirectTransform->NetTranslation();
295     pMin += offset;                               304     pMin += offset;
296     pMax += offset;                               305     pMax += offset;
297   }                                               306   }
298   else                                            307   else
299   {                                               308   {
300     // General case, use CalculateExtent() to     309     // General case, use CalculateExtent() to find bounding box
301     //                                            310     //
302     G4VoxelLimits unLimit;                        311     G4VoxelLimits unLimit;
303     G4double xmin,xmax,ymin,ymax,zmin,zmax;       312     G4double xmin,xmax,ymin,ymax,zmin,zmax;
304     fPtrSolid->CalculateExtent(kXAxis,unLimit,    313     fPtrSolid->CalculateExtent(kXAxis,unLimit,*fDirectTransform,xmin,xmax);
305     fPtrSolid->CalculateExtent(kYAxis,unLimit,    314     fPtrSolid->CalculateExtent(kYAxis,unLimit,*fDirectTransform,ymin,ymax);
306     fPtrSolid->CalculateExtent(kZAxis,unLimit,    315     fPtrSolid->CalculateExtent(kZAxis,unLimit,*fDirectTransform,zmin,zmax);
307     pMin.set(xmin,ymin,zmin);                     316     pMin.set(xmin,ymin,zmin);
308     pMax.set(xmax,ymax,zmax);                     317     pMax.set(xmax,ymax,zmax);
309   }                                               318   }
310                                                   319   
311   // Check correctness of the bounding box        320   // Check correctness of the bounding box
312   //                                              321   //
313   if (pMin.x() >= pMax.x() || pMin.y() >= pMax    322   if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
314   {                                               323   {
315     std::ostringstream message;                   324     std::ostringstream message;
316     message << "Bad bounding box (min >= max)     325     message << "Bad bounding box (min >= max) for solid: "
317             << GetName() << " !"                  326             << GetName() << " !"
318             << "\npMin = " << pMin                327             << "\npMin = " << pMin
319             << "\npMax = " << pMax;               328             << "\npMax = " << pMax;
320     G4Exception("G4DisplacedSolid::BoundingLim    329     G4Exception("G4DisplacedSolid::BoundingLimits()", "GeomMgt0001",
321                JustWarning, message);             330                JustWarning, message);
322     DumpInfo();                                   331     DumpInfo();
323   }                                               332   }
324 }                                                 333 }
325                                                   334 
326 //////////////////////////////////////////////    335 //////////////////////////////////////////////////////////////////////////
327 //                                                336 //
328 // Calculate extent under transform and specif    337 // Calculate extent under transform and specified limit
329                                                   338      
330 G4bool                                            339 G4bool 
331 G4DisplacedSolid::CalculateExtent( const EAxis    340 G4DisplacedSolid::CalculateExtent( const EAxis pAxis,
332                                    const G4Vox    341                                    const G4VoxelLimits& pVoxelLimit,
333                                    const G4Aff    342                                    const G4AffineTransform& pTransform,
334                                          G4dou    343                                          G4double& pMin, 
335                                          G4dou    344                                          G4double& pMax           ) const 
336 {                                                 345 {
337   G4AffineTransform sumTransform ;                346   G4AffineTransform sumTransform ;
338   sumTransform.Product(*fDirectTransform,pTran    347   sumTransform.Product(*fDirectTransform,pTransform) ;
339   return fPtrSolid->CalculateExtent(pAxis,pVox    348   return fPtrSolid->CalculateExtent(pAxis,pVoxelLimit,sumTransform,pMin,pMax) ;
340 }                                                 349 }
341                                                   350  
342 //////////////////////////////////////////////    351 /////////////////////////////////////////////////////
343 //                                                352 //
344 // SurfaceNormal                               << 353 // 
345                                                   354 
346 EInside G4DisplacedSolid::Inside(const G4Three    355 EInside G4DisplacedSolid::Inside(const G4ThreeVector& p) const
347 {                                                 356 {
348   G4ThreeVector newPoint = fPtrTransform->Tran    357   G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
349   return fPtrSolid->Inside(newPoint) ;            358   return fPtrSolid->Inside(newPoint) ; 
350 }                                                 359 }
351                                                   360 
352 //////////////////////////////////////////////    361 //////////////////////////////////////////////////////////////
353 //                                                362 //
354 //                                                363 //
355                                                   364 
356 G4ThreeVector                                     365 G4ThreeVector 
357 G4DisplacedSolid::SurfaceNormal( const G4Three    366 G4DisplacedSolid::SurfaceNormal( const G4ThreeVector& p ) const 
358 {                                                 367 {
359   G4ThreeVector newPoint = fPtrTransform->Tran    368   G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
360   G4ThreeVector normal = fPtrSolid->SurfaceNor    369   G4ThreeVector normal = fPtrSolid->SurfaceNormal(newPoint) ; 
361   return fDirectTransform->TransformAxis(norma    370   return fDirectTransform->TransformAxis(normal) ;
362 }                                                 371 }
363                                                   372 
364 //////////////////////////////////////////////    373 /////////////////////////////////////////////////////////////
365 //                                                374 //
366 // The same algorithm as in DistanceToIn(p)       375 // The same algorithm as in DistanceToIn(p)
367                                                   376 
368 G4double                                          377 G4double 
369 G4DisplacedSolid::DistanceToIn( const G4ThreeV    378 G4DisplacedSolid::DistanceToIn( const G4ThreeVector& p,
370                                 const G4ThreeV    379                                 const G4ThreeVector& v  ) const 
371 {                                                 380 {    
372   G4ThreeVector newPoint = fPtrTransform->Tran    381   G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
373   G4ThreeVector newDirection = fPtrTransform->    382   G4ThreeVector newDirection = fPtrTransform->TransformAxis(v) ;
374   return fPtrSolid->DistanceToIn(newPoint,newD    383   return fPtrSolid->DistanceToIn(newPoint,newDirection) ;   
375 }                                                 384 }
376                                                   385 
377 //////////////////////////////////////////////    386 ////////////////////////////////////////////////////////
378 //                                                387 //
379 // Approximate nearest distance from the point    388 // Approximate nearest distance from the point p to the intersection of
380 // two solids                                     389 // two solids
381                                                   390 
382 G4double                                          391 G4double 
383 G4DisplacedSolid::DistanceToIn( const G4ThreeV    392 G4DisplacedSolid::DistanceToIn( const G4ThreeVector& p ) const 
384 {                                                 393 {
385   G4ThreeVector newPoint = fPtrTransform->Tran    394   G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
386   return fPtrSolid->DistanceToIn(newPoint) ;      395   return fPtrSolid->DistanceToIn(newPoint) ;   
387 }                                                 396 }
388                                                   397 
389 //////////////////////////////////////////////    398 //////////////////////////////////////////////////////////
390 //                                                399 //
391 // The same algorithm as DistanceToOut(p)         400 // The same algorithm as DistanceToOut(p)
392                                                   401 
393 G4double                                          402 G4double 
394 G4DisplacedSolid::DistanceToOut( const G4Three    403 G4DisplacedSolid::DistanceToOut( const G4ThreeVector& p,
395                                  const G4Three    404                                  const G4ThreeVector& v,
396                                  const G4bool     405                                  const G4bool calcNorm,
397                                        G4bool     406                                        G4bool *validNorm,
398                                        G4Three    407                                        G4ThreeVector *n   ) const 
399 {                                                 408 {
400   G4ThreeVector solNorm ;                         409   G4ThreeVector solNorm ; 
401   G4ThreeVector newPoint = fPtrTransform->Tran    410   G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
402   G4ThreeVector newDirection = fPtrTransform->    411   G4ThreeVector newDirection = fPtrTransform->TransformAxis(v) ;
403   G4double dist = fPtrSolid->DistanceToOut(new    412   G4double dist = fPtrSolid->DistanceToOut(newPoint,newDirection,
404                                            cal    413                                            calcNorm,validNorm,&solNorm) ;
405   if(calcNorm)                                    414   if(calcNorm)
406   {                                               415   { 
407     *n = fDirectTransform->TransformAxis(solNo    416     *n = fDirectTransform->TransformAxis(solNorm) ;
408   }                                               417   }
409   return dist ;                                   418   return dist ;  
410 }                                                 419 }
411                                                   420 
412 //////////////////////////////////////////////    421 //////////////////////////////////////////////////////////////
413 //                                                422 //
414 // Inverted algorithm of DistanceToIn(p)          423 // Inverted algorithm of DistanceToIn(p)
415                                                   424 
416 G4double                                          425 G4double 
417 G4DisplacedSolid::DistanceToOut( const G4Three    426 G4DisplacedSolid::DistanceToOut( const G4ThreeVector& p ) const 
418 {                                                 427 {
419   G4ThreeVector newPoint = fPtrTransform->Tran    428   G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
420   return fPtrSolid->DistanceToOut(newPoint) ;     429   return fPtrSolid->DistanceToOut(newPoint) ;   
421 }                                                 430 }
422                                                   431 
423 //////////////////////////////////////////////    432 //////////////////////////////////////////////////////////////
424 //                                                433 //
425 // ComputeDimensions                           << 434 //
426                                                   435 
427 void                                              436 void 
428 G4DisplacedSolid::ComputeDimensions(       G4V    437 G4DisplacedSolid::ComputeDimensions(       G4VPVParameterisation*,
429                                      const G4i    438                                      const G4int,
430                                      const G4V    439                                      const G4VPhysicalVolume* ) 
431 {                                                 440 {
432   DumpInfo();                                     441   DumpInfo();
433   G4Exception("G4DisplacedSolid::ComputeDimens    442   G4Exception("G4DisplacedSolid::ComputeDimensions()",
434               "GeomSolids0001", FatalException    443               "GeomSolids0001", FatalException,
435               "Method not applicable in this c    444               "Method not applicable in this context!");
436 }                                                 445 }
437                                                   446 
438 ////////////////////////////////////////////// << 
439 //                                             << 
440 // Return volume                               << 
441                                                << 
442 G4double G4DisplacedSolid::GetCubicVolume()    << 
443 {                                              << 
444   return fPtrSolid->GetCubicVolume();          << 
445 }                                              << 
446                                                << 
447 ////////////////////////////////////////////// << 
448 //                                             << 
449 // Return surface area                         << 
450                                                << 
451 G4double G4DisplacedSolid::GetSurfaceArea()    << 
452 {                                              << 
453   return fPtrSolid->GetSurfaceArea();          << 
454 }                                              << 
455                                                << 
456 //////////////////////////////////////////////    447 //////////////////////////////////////////////////////////////////////////
457 //                                                448 //
458 // Returns a point (G4ThreeVector) randomly an    449 // Returns a point (G4ThreeVector) randomly and uniformly selected
459 // on the solid surface                           450 // on the solid surface
460 //                                                451 //
461                                                   452 
462 G4ThreeVector G4DisplacedSolid::GetPointOnSurf    453 G4ThreeVector G4DisplacedSolid::GetPointOnSurface() const
463 {                                                 454 {
464   G4ThreeVector p = fPtrSolid->GetPointOnSurfa << 455   G4ThreeVector p =  fPtrSolid->GetPointOnSurface();
465   return fDirectTransform->TransformPoint(p);     456   return fDirectTransform->TransformPoint(p);
466 }                                                 457 }
467                                                   458 
468 //////////////////////////////////////////////    459 //////////////////////////////////////////////////////////////////////////
469 //                                                460 //
470 // Return the number of constituents used for  << 
471                                                << 
472 G4int G4DisplacedSolid::GetNumOfConstituents() << 
473 {                                              << 
474   return fPtrSolid->GetNumOfConstituents();    << 
475 }                                              << 
476                                                << 
477 ////////////////////////////////////////////// << 
478 //                                             << 
479 // Return true if the solid has only planar fa << 
480                                                << 
481 G4bool G4DisplacedSolid::IsFaceted() const     << 
482 {                                              << 
483   return fPtrSolid->IsFaceted();               << 
484 }                                              << 
485                                                << 
486 ////////////////////////////////////////////// << 
487 //                                             << 
488 // Return object type name                        461 // Return object type name
489                                                   462 
490 G4GeometryType G4DisplacedSolid::GetEntityType    463 G4GeometryType G4DisplacedSolid::GetEntityType() const 
491 {                                                 464 {
492   return {"G4DisplacedSolid"};                 << 465   return G4String("G4DisplacedSolid");
493 }                                                 466 }
494                                                   467 
495 //////////////////////////////////////////////    468 //////////////////////////////////////////////////////////////////////////
496 //                                                469 //
497 // Make a clone of the object                     470 // Make a clone of the object
498 //                                                471 //
499 G4VSolid* G4DisplacedSolid::Clone() const         472 G4VSolid* G4DisplacedSolid::Clone() const
500 {                                                 473 {
501   return new G4DisplacedSolid(*this);             474   return new G4DisplacedSolid(*this);
502 }                                                 475 }
503                                                   476 
504 //////////////////////////////////////////////    477 //////////////////////////////////////////////////////////////////////////
505 //                                                478 //
506 // Stream object contents to an output stream     479 // Stream object contents to an output stream
507                                                   480 
508 std::ostream& G4DisplacedSolid::StreamInfo(std    481 std::ostream& G4DisplacedSolid::StreamInfo(std::ostream& os) const
509 {                                                 482 {
510   os << "-------------------------------------    483   os << "-----------------------------------------------------------\n"
511      << "    *** Dump for Displaced solid - "     484      << "    *** Dump for Displaced solid - " << GetName() << " ***\n"
512      << "    =================================    485      << "    ===================================================\n"
513      << " Solid type: " << GetEntityType() <<     486      << " Solid type: " << GetEntityType() << "\n"
514      << " Parameters of constituent solid: \n"    487      << " Parameters of constituent solid: \n"
515      << "=====================================    488      << "===========================================================\n";
516   fPtrSolid->StreamInfo(os);                      489   fPtrSolid->StreamInfo(os);
517   os << "=====================================    490   os << "===========================================================\n"
518      << " Transformations: \n"                    491      << " Transformations: \n"
519      << "    Direct transformation - translati    492      << "    Direct transformation - translation : \n"
520      << "           " << fDirectTransform->Net    493      << "           " << fDirectTransform->NetTranslation() << "\n"
521      << "                          - rotation     494      << "                          - rotation    : \n"
522      << "           ";                            495      << "           ";
523   fDirectTransform->NetRotation().print(os);      496   fDirectTransform->NetRotation().print(os);
524   os << "\n"                                      497   os << "\n"
525      << "=====================================    498      << "===========================================================\n";
526                                                   499 
527   return os;                                      500   return os;
528 }                                                 501 }
529                                                   502 
530 //////////////////////////////////////////////    503 //////////////////////////////////////////////////////////////////////////
531 //                                                504 //
532 // DescribeYourselfTo                          << 505 //                    
533                                                   506 
534 void                                              507 void 
535 G4DisplacedSolid::DescribeYourselfTo ( G4VGrap    508 G4DisplacedSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const 
536 {                                                 509 {
537   scene.AddSolid (*this);                         510   scene.AddSolid (*this);
538 }                                                 511 }
539                                                   512 
540 //////////////////////////////////////////////    513 //////////////////////////////////////////////////////////////////////////
541 //                                                514 //
542 // CreatePolyhedron                            << 515 //
543                                                   516 
544 G4Polyhedron*                                     517 G4Polyhedron* 
545 G4DisplacedSolid::CreatePolyhedron () const       518 G4DisplacedSolid::CreatePolyhedron () const 
546 {                                                 519 {
547   G4Polyhedron* polyhedron = fPtrSolid->Create    520   G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron();
548   if (polyhedron != nullptr)                   << 521   if (polyhedron)
549   {                                               522   {
550     polyhedron                                    523     polyhedron
551     ->Transform(G4Transform3D(GetObjectRotatio    524     ->Transform(G4Transform3D(GetObjectRotation(),GetObjectTranslation()));
552   }                                               525   }
553   else                                            526   else
554   {                                               527   {
555     DumpInfo();                                   528     DumpInfo();
556     G4Exception("G4DisplacedSolid::CreatePolyh    529     G4Exception("G4DisplacedSolid::CreatePolyhedron()",
557                 "GeomSolids2002", JustWarning,    530                 "GeomSolids2002", JustWarning,
558                 "No G4Polyhedron for displaced    531                 "No G4Polyhedron for displaced solid");
559   }                                               532   }
560   return polyhedron;                              533   return polyhedron;
561 }                                                 534 }
562                                                   535 
563 //////////////////////////////////////////////    536 //////////////////////////////////////////////////////////////////////////
564 //                                                537 //
565 // GetPolyhedron                               << 538 //
566                                                   539 
567 G4Polyhedron* G4DisplacedSolid::GetPolyhedron     540 G4Polyhedron* G4DisplacedSolid::GetPolyhedron () const
568 {                                                 541 {
569   if (fpPolyhedron == nullptr ||               << 542   if (!fpPolyhedron ||
570       fRebuildPolyhedron ||                       543       fRebuildPolyhedron ||
571       fpPolyhedron->GetNumberOfRotationStepsAt    544       fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
572       fpPolyhedron->GetNumberOfRotationSteps()    545       fpPolyhedron->GetNumberOfRotationSteps())
573     {                                             546     {
574       fpPolyhedron = CreatePolyhedron();          547       fpPolyhedron = CreatePolyhedron();
575       fRebuildPolyhedron = false;                 548       fRebuildPolyhedron = false;
576     }                                             549     }
577   return fpPolyhedron;                            550   return fpPolyhedron;
578 }                                                 551 }
579                                                   552