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