Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/management/src/G4ReflectedSolid.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/management/src/G4ReflectedSolid.cc (Version 11.3.0) and /geometry/management/src/G4ReflectedSolid.cc (Version 10.6)


  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 for G4ReflectedSolid class       26 // Implementation for G4ReflectedSolid class
 27 //                                                 27 //
 28 // Author: Vladimir Grichine, 23.07.01  (Vladi     28 // Author: Vladimir Grichine, 23.07.01  (Vladimir.Grichine@cern.ch)
 29 // -------------------------------------------     29 // --------------------------------------------------------------------
 30                                                    30 
 31 #include "G4ReflectedSolid.hh"                     31 #include "G4ReflectedSolid.hh"
 32                                                    32 
 33 #include <sstream>                                 33 #include <sstream>
 34                                                    34 
 35 #include "G4Point3D.hh"                            35 #include "G4Point3D.hh"
 36 #include "G4Vector3D.hh"                           36 #include "G4Vector3D.hh"
 37                                                    37 
 38 #include "G4AffineTransform.hh"                    38 #include "G4AffineTransform.hh"
 39 #include "G4Transform3D.hh"                        39 #include "G4Transform3D.hh"
 40 #include "G4VoxelLimits.hh"                        40 #include "G4VoxelLimits.hh"
 41                                                    41 
 42 #include "G4VPVParameterisation.hh"                42 #include "G4VPVParameterisation.hh"
 43                                                    43 
 44 #include "G4VGraphicsScene.hh"                     44 #include "G4VGraphicsScene.hh"
 45 #include "G4Polyhedron.hh"                         45 #include "G4Polyhedron.hh"
 46                                                    46 
 47 //////////////////////////////////////////////     47 /////////////////////////////////////////////////////////////////
 48 //                                                 48 //
 49 // Constructor using HepTransform3D, in fact H     49 // Constructor using HepTransform3D, in fact HepReflect3D
 50                                                    50 
 51 G4ReflectedSolid::G4ReflectedSolid( const G4St     51 G4ReflectedSolid::G4ReflectedSolid( const G4String& pName,
 52                                           G4VS     52                                           G4VSolid* pSolid ,
 53                                     const G4Tr     53                                     const G4Transform3D& transform )
 54   : G4VSolid(pName)                                54   : G4VSolid(pName)
 55 {                                                  55 {
 56   fPtrSolid = pSolid;                              56   fPtrSolid = pSolid;
 57   fDirectTransform3D = new G4Transform3D(trans     57   fDirectTransform3D = new G4Transform3D(transform);
 58 }                                                  58 }
 59                                                    59 
 60 //////////////////////////////////////////////     60 ///////////////////////////////////////////////////////////////////
 61 //                                                 61 //
 62                                                    62 
 63 G4ReflectedSolid::~G4ReflectedSolid()              63 G4ReflectedSolid::~G4ReflectedSolid() 
 64 {                                                  64 {
 65   delete fDirectTransform3D; fDirectTransform3     65   delete fDirectTransform3D; fDirectTransform3D = nullptr;
 66   delete fpPolyhedron; fpPolyhedron = nullptr;     66   delete fpPolyhedron; fpPolyhedron = nullptr;
 67 }                                                  67 }
 68                                                    68 
 69 //////////////////////////////////////////////     69 ///////////////////////////////////////////////////////////////////
 70 //                                                 70 //
 71                                                    71 
 72 G4ReflectedSolid::G4ReflectedSolid(const G4Ref     72 G4ReflectedSolid::G4ReflectedSolid(const G4ReflectedSolid& rhs)
 73   : G4VSolid(rhs), fPtrSolid(rhs.fPtrSolid)        73   : G4VSolid(rhs), fPtrSolid(rhs.fPtrSolid)
 74 {                                                  74 {
 75   fDirectTransform3D = new G4Transform3D(*rhs.     75   fDirectTransform3D = new G4Transform3D(*rhs.fDirectTransform3D);
 76 }                                                  76 }
 77                                                    77 
 78 //////////////////////////////////////////////     78 ///////////////////////////////////////////////////////////////////
 79 //                                                 79 //
 80                                                    80 
 81 G4ReflectedSolid& G4ReflectedSolid::operator=(     81 G4ReflectedSolid& G4ReflectedSolid::operator=(const G4ReflectedSolid& rhs)
 82 {                                                  82 {
 83   // Check assignment to self                      83   // Check assignment to self
 84   //                                               84   //
 85   if (this == &rhs)  { return *this; }             85   if (this == &rhs)  { return *this; }
 86                                                    86 
 87   // Copy base class data                          87   // Copy base class data
 88   //                                               88   //
 89   G4VSolid::operator=(rhs);                        89   G4VSolid::operator=(rhs);
 90                                                    90 
 91   // Copy data                                     91   // Copy data
 92   //                                               92   //
 93   fPtrSolid = rhs.fPtrSolid;                       93   fPtrSolid = rhs.fPtrSolid;
 94   delete fDirectTransform3D;                       94   delete fDirectTransform3D;
 95   fDirectTransform3D = new G4Transform3D(*rhs.     95   fDirectTransform3D = new G4Transform3D(*rhs.fDirectTransform3D);
 96   fRebuildPolyhedron = false;                      96   fRebuildPolyhedron = false;
 97   delete fpPolyhedron; fpPolyhedron = nullptr;     97   delete fpPolyhedron; fpPolyhedron = nullptr;
 98                                                    98 
 99   return *this;                                    99   return *this;
100 }                                                 100 }
101                                                   101 
102 //////////////////////////////////////////////    102 ///////////////////////////////////////////////////////////////////
103 //                                                103 //
104                                                   104 
105 G4GeometryType G4ReflectedSolid::GetEntityType    105 G4GeometryType G4ReflectedSolid::GetEntityType() const 
106 {                                                 106 {
107   return {"G4ReflectedSolid"};                 << 107   return G4String("G4ReflectedSolid");
108 }                                                 108 }
109                                                   109 
110 const G4ReflectedSolid* G4ReflectedSolid::GetR    110 const G4ReflectedSolid* G4ReflectedSolid::GetReflectedSolidPtr() const   
111 {                                                 111 {
112   return this;                                    112   return this;
113 }                                                 113 }
114                                                   114 
115 G4ReflectedSolid* G4ReflectedSolid::GetReflect    115 G4ReflectedSolid* G4ReflectedSolid::GetReflectedSolidPtr() 
116 {                                                 116 {
117   return this;                                    117   return this;
118 }                                                 118 }
119                                                   119 
120 G4VSolid* G4ReflectedSolid::GetConstituentMove    120 G4VSolid* G4ReflectedSolid::GetConstituentMovedSolid() const
121 {                                                 121 { 
122   return fPtrSolid;                               122   return fPtrSolid; 
123 }                                                 123 } 
124                                                   124 
125 //////////////////////////////////////////////    125 /////////////////////////////////////////////////////////////////////////////
126 //                                                126 //
127                                                   127 
128 G4Transform3D  G4ReflectedSolid::GetTransform3    128 G4Transform3D  G4ReflectedSolid::GetTransform3D() const
129 {                                                 129 {
130   return fDirectTransform3D->inverse();           130   return fDirectTransform3D->inverse();
131 }                                                 131 }
132                                                   132 
133 G4Transform3D  G4ReflectedSolid::GetDirectTran    133 G4Transform3D  G4ReflectedSolid::GetDirectTransform3D() const
134 {                                                 134 {
135   G4Transform3D aTransform = *fDirectTransform    135   G4Transform3D aTransform = *fDirectTransform3D;
136   return aTransform;                              136   return aTransform;
137 }                                                 137 }
138                                                   138 
139 void G4ReflectedSolid::SetDirectTransform3D(G4    139 void G4ReflectedSolid::SetDirectTransform3D(G4Transform3D& transform) 
140 {                                                 140 {
141   fDirectTransform3D = &transform;                141   fDirectTransform3D = &transform;
142   fRebuildPolyhedron = true;                      142   fRebuildPolyhedron = true;
143 }                                                 143 }
144                                                   144 
145 //////////////////////////////////////////////    145 //////////////////////////////////////////////////////////////////////////
146 //                                                146 //
147 // Get bounding box                               147 // Get bounding box
148                                                   148 
149 void G4ReflectedSolid::BoundingLimits(G4ThreeV    149 void G4ReflectedSolid::BoundingLimits(G4ThreeVector& pMin,
150                                       G4ThreeV    150                                       G4ThreeVector& pMax) const
151 {                                                 151 {
152   fPtrSolid->BoundingLimits(pMin,pMax);           152   fPtrSolid->BoundingLimits(pMin,pMax);
153   G4double xmin = pMin.x(), ymin = pMin.y(), z    153   G4double xmin = pMin.x(), ymin = pMin.y(), zmin = pMin.z();
154   G4double xmax = pMax.x(), ymax = pMax.y(), z    154   G4double xmax = pMax.x(), ymax = pMax.y(), zmax = pMax.z();
155   G4double xx = fDirectTransform3D->xx();         155   G4double xx = fDirectTransform3D->xx();
156   G4double yy = fDirectTransform3D->yy();         156   G4double yy = fDirectTransform3D->yy();
157   G4double zz = fDirectTransform3D->zz();         157   G4double zz = fDirectTransform3D->zz();
158                                                   158 
159   if (std::abs(xx) == 1 && std::abs(yy) == 1 &    159   if (std::abs(xx) == 1 && std::abs(yy) == 1 && std::abs(zz) == 1)
160   {                                               160   {
161     // Special case of reflection in axis and     161     // Special case of reflection in axis and pure translation
162     //                                            162     //
163     if (xx == -1) { G4double tmp = -xmin; xmin    163     if (xx == -1) { G4double tmp = -xmin; xmin = -xmax; xmax = tmp; }
164     if (yy == -1) { G4double tmp = -ymin; ymin    164     if (yy == -1) { G4double tmp = -ymin; ymin = -ymax; ymax = tmp; }
165     if (zz == -1) { G4double tmp = -zmin; zmin    165     if (zz == -1) { G4double tmp = -zmin; zmin = -zmax; zmax = tmp; }
166     xmin += fDirectTransform3D->dx();             166     xmin += fDirectTransform3D->dx();
167     xmax += fDirectTransform3D->dx();             167     xmax += fDirectTransform3D->dx();
168     ymin += fDirectTransform3D->dy();             168     ymin += fDirectTransform3D->dy();
169     ymax += fDirectTransform3D->dy();             169     ymax += fDirectTransform3D->dy();
170     zmin += fDirectTransform3D->dz();             170     zmin += fDirectTransform3D->dz();
171     zmax += fDirectTransform3D->dz();             171     zmax += fDirectTransform3D->dz();
172   }                                               172   }
173   else                                            173   else
174   {                                               174   {
175     // Use additional reflection in Z to set u    175     // Use additional reflection in Z to set up affine transformation
176     //                                            176     //
177     G4Transform3D transform3D = G4ReflectZ3D()    177     G4Transform3D transform3D = G4ReflectZ3D()*(*fDirectTransform3D);
178     G4AffineTransform transform(transform3D.ge    178     G4AffineTransform transform(transform3D.getRotation().inverse(),
179                                 transform3D.ge    179                                 transform3D.getTranslation());
180                                                   180   
181     // Find bounding box                          181     // Find bounding box
182     //                                            182     //
183     G4VoxelLimits unLimit;                        183     G4VoxelLimits unLimit;
184     fPtrSolid->CalculateExtent(kXAxis,unLimit,    184     fPtrSolid->CalculateExtent(kXAxis,unLimit,transform,xmin,xmax);
185     fPtrSolid->CalculateExtent(kYAxis,unLimit,    185     fPtrSolid->CalculateExtent(kYAxis,unLimit,transform,ymin,ymax);
186     fPtrSolid->CalculateExtent(kZAxis,unLimit,    186     fPtrSolid->CalculateExtent(kZAxis,unLimit,transform,zmin,zmax); 
187   }                                               187   }
188                                                   188 
189   pMin.set(xmin,ymin,-zmax);                      189   pMin.set(xmin,ymin,-zmax);
190   pMax.set(xmax,ymax,-zmin);                      190   pMax.set(xmax,ymax,-zmin);
191                                                   191 
192   // Check correctness of the bounding box        192   // Check correctness of the bounding box
193   //                                              193   //
194   if (pMin.x() >= pMax.x() || pMin.y() >= pMax    194   if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
195   {                                               195   {
196     std::ostringstream message;                   196     std::ostringstream message;
197     message << "Bad bounding box (min >= max)     197     message << "Bad bounding box (min >= max) for solid: "
198             << GetName() << " !"                  198             << GetName() << " !"
199             << "\npMin = " << pMin                199             << "\npMin = " << pMin
200             << "\npMax = " << pMax;               200             << "\npMax = " << pMax;
201     G4Exception("G4ReflectedSolid::BoundingLim    201     G4Exception("G4ReflectedSolid::BoundingLimits()", "GeomMgt0001",
202                 JustWarning, message);            202                 JustWarning, message);
203     DumpInfo();                                   203     DumpInfo();
204   }                                               204   }
205 }                                                 205 }
206                                                   206 
207 //////////////////////////////////////////////    207 //////////////////////////////////////////////////////////////////////////
208 //                                                208 //
209 // Calculate extent under transform and specif    209 // Calculate extent under transform and specified limit
210                                                   210 
211 G4bool                                            211 G4bool 
212 G4ReflectedSolid::CalculateExtent( const EAxis    212 G4ReflectedSolid::CalculateExtent( const EAxis pAxis,
213                                    const G4Vox    213                                    const G4VoxelLimits& pVoxelLimits,
214                                    const G4Aff    214                                    const G4AffineTransform& pTransform,
215                                          G4dou    215                                          G4double& pMin, 
216                                          G4dou    216                                          G4double& pMax ) const 
217 {                                                 217 {
218   // Separation of transformations. Calculatio    218   // Separation of transformations. Calculation of the extent is done
219   // in a reflection of the global space. In s    219   // in a reflection of the global space. In such way, the voxel is
220   // reflected, but the solid is transformed j    220   // reflected, but the solid is transformed just by G4AffineTransform.
221   // It allows one to use CalculateExtent() of << 221   // It allows to use CalculateExtent() of the solid.
222                                                   222 
223   // Reflect voxel limits in Z                    223   // Reflect voxel limits in Z
224   //                                              224   //
225   G4VoxelLimits limits;                           225   G4VoxelLimits limits;
226   limits.AddLimit(kXAxis, pVoxelLimits.GetMinX    226   limits.AddLimit(kXAxis, pVoxelLimits.GetMinXExtent(),
227                           pVoxelLimits.GetMaxX    227                           pVoxelLimits.GetMaxXExtent());
228   limits.AddLimit(kYAxis, pVoxelLimits.GetMinY    228   limits.AddLimit(kYAxis, pVoxelLimits.GetMinYExtent(),
229                           pVoxelLimits.GetMaxY    229                           pVoxelLimits.GetMaxYExtent());
230   limits.AddLimit(kZAxis,-pVoxelLimits.GetMaxZ    230   limits.AddLimit(kZAxis,-pVoxelLimits.GetMaxZExtent(),
231                          -pVoxelLimits.GetMinZ    231                          -pVoxelLimits.GetMinZExtent());
232                                                   232 
233   // Set affine transformation                    233   // Set affine transformation
234   //                                              234   //
235   G4Transform3D transform3D = G4ReflectZ3D()*p    235   G4Transform3D transform3D = G4ReflectZ3D()*pTransform*(*fDirectTransform3D);
236   G4AffineTransform transform(transform3D.getR    236   G4AffineTransform transform(transform3D.getRotation().inverse(),
237                               transform3D.getT    237                               transform3D.getTranslation());
238                                                   238 
239   // Find extent                                  239   // Find extent
240   //                                              240   //
241   if (!fPtrSolid->CalculateExtent(pAxis, limit    241   if (!fPtrSolid->CalculateExtent(pAxis, limits, transform, pMin, pMax))
242   {                                               242   {
243     return false;                                 243     return false;
244   }                                               244   }
245   if (pAxis == kZAxis)                            245   if (pAxis == kZAxis)
246   {                                               246   {
247     G4double tmp= -pMin; pMin= -pMax; pMax= tm    247     G4double tmp= -pMin; pMin= -pMax; pMax= tmp;
248   }                                               248   }
249                                                   249 
250   return true;                                    250   return true;
251 }                                                 251 }
252                                                   252 
253 //////////////////////////////////////////////    253 //////////////////////////////////////////////////////////////
254 //                                                254 //
255 //                                                255 // 
256                                                   256 
257 EInside G4ReflectedSolid::Inside(const G4Three    257 EInside G4ReflectedSolid::Inside(const G4ThreeVector& p ) const
258 {                                                 258 {
259   G4ThreeVector newPoint = (*fDirectTransform3    259   G4ThreeVector newPoint = (*fDirectTransform3D)*G4Point3D(p);
260   return fPtrSolid->Inside(newPoint);             260   return fPtrSolid->Inside(newPoint); 
261 }                                                 261 }
262                                                   262 
263 //////////////////////////////////////////////    263 //////////////////////////////////////////////////////////////
264 //                                                264 //
265 //                                                265 //
266                                                   266 
267 G4ThreeVector                                     267 G4ThreeVector 
268 G4ReflectedSolid::SurfaceNormal( const G4Three    268 G4ReflectedSolid::SurfaceNormal( const G4ThreeVector& p ) const 
269 {                                                 269 {
270   G4ThreeVector newPoint = (*fDirectTransform3    270   G4ThreeVector newPoint = (*fDirectTransform3D)*G4Point3D(p);
271   G4Vector3D normal = fPtrSolid->SurfaceNormal    271   G4Vector3D normal = fPtrSolid->SurfaceNormal(newPoint);
272   return (*fDirectTransform3D)*normal;            272   return (*fDirectTransform3D)*normal;    
273 }                                                 273 }
274                                                   274 
275 //////////////////////////////////////////////    275 /////////////////////////////////////////////////////////////
276 //                                                276 //
277 // The same algorithm as in DistanceToIn(p)       277 // The same algorithm as in DistanceToIn(p)
278                                                   278 
279 G4double                                          279 G4double 
280 G4ReflectedSolid::DistanceToIn( const G4ThreeV    280 G4ReflectedSolid::DistanceToIn( const G4ThreeVector& p,
281                                 const G4ThreeV    281                                 const G4ThreeVector& v ) const 
282 {                                                 282 {    
283   G4ThreeVector newPoint     = (*fDirectTransf    283   G4ThreeVector newPoint     = (*fDirectTransform3D)*G4Point3D(p);
284   G4ThreeVector newDirection = (*fDirectTransf    284   G4ThreeVector newDirection = (*fDirectTransform3D)*G4Vector3D(v);
285   return fPtrSolid->DistanceToIn(newPoint,newD    285   return fPtrSolid->DistanceToIn(newPoint,newDirection);   
286 }                                                 286 }
287                                                   287 
288 //////////////////////////////////////////////    288 ////////////////////////////////////////////////////////
289 //                                                289 //
290 // Approximate nearest distance from the point    290 // Approximate nearest distance from the point p to the intersection of
291 // two solids                                     291 // two solids
292                                                   292 
293 G4double                                          293 G4double 
294 G4ReflectedSolid::DistanceToIn( const G4ThreeV    294 G4ReflectedSolid::DistanceToIn( const G4ThreeVector& p ) const 
295 {                                                 295 {
296   G4ThreeVector newPoint = (*fDirectTransform3    296   G4ThreeVector newPoint = (*fDirectTransform3D)*G4Point3D(p);
297   return fPtrSolid->DistanceToIn(newPoint);       297   return fPtrSolid->DistanceToIn(newPoint);   
298 }                                                 298 }
299                                                   299 
300 //////////////////////////////////////////////    300 //////////////////////////////////////////////////////////
301 //                                                301 //
302 // The same algorithm as DistanceToOut(p)         302 // The same algorithm as DistanceToOut(p)
303                                                   303 
304 G4double                                          304 G4double 
305 G4ReflectedSolid::DistanceToOut( const G4Three    305 G4ReflectedSolid::DistanceToOut( const G4ThreeVector& p,
306                                  const G4Three    306                                  const G4ThreeVector& v,
307                                  const G4bool     307                                  const G4bool calcNorm,
308                                        G4bool*    308                                        G4bool* validNorm,
309                                        G4Three    309                                        G4ThreeVector* n ) const 
310 {                                                 310 {
311   G4ThreeVector solNorm;                          311   G4ThreeVector solNorm; 
312                                                   312 
313   G4ThreeVector newPoint     = (*fDirectTransf    313   G4ThreeVector newPoint     = (*fDirectTransform3D)*G4Point3D(p);
314   G4ThreeVector newDirection = (*fDirectTransf    314   G4ThreeVector newDirection = (*fDirectTransform3D)*G4Vector3D(v);
315                                                   315 
316   G4double dist = fPtrSolid->DistanceToOut(new    316   G4double dist = fPtrSolid->DistanceToOut(newPoint, newDirection,
317                                            cal    317                                            calcNorm, validNorm, &solNorm);
318   if(calcNorm)                                    318   if(calcNorm)
319   {                                               319   { 
320     *n = (*fDirectTransform3D)*G4Vector3D(solN    320     *n = (*fDirectTransform3D)*G4Vector3D(solNorm);
321   }                                               321   }
322   return dist;                                    322   return dist;  
323 }                                                 323 }
324                                                   324 
325 //////////////////////////////////////////////    325 //////////////////////////////////////////////////////////////
326 //                                                326 //
327 // Inverted algorithm of DistanceToIn(p)          327 // Inverted algorithm of DistanceToIn(p)
328                                                   328 
329 G4double                                          329 G4double 
330 G4ReflectedSolid::DistanceToOut( const G4Three    330 G4ReflectedSolid::DistanceToOut( const G4ThreeVector& p ) const 
331 {                                                 331 {
332   G4ThreeVector newPoint = (*fDirectTransform3    332   G4ThreeVector newPoint = (*fDirectTransform3D)*G4Point3D(p);
333   return fPtrSolid->DistanceToOut(newPoint);      333   return fPtrSolid->DistanceToOut(newPoint);   
334 }                                                 334 }
335                                                   335 
336 //////////////////////////////////////////////    336 //////////////////////////////////////////////////////////////
337 //                                                337 //
338 //                                                338 //
339                                                   339 
340 void                                              340 void 
341 G4ReflectedSolid::ComputeDimensions(       G4V    341 G4ReflectedSolid::ComputeDimensions(       G4VPVParameterisation*,
342                                      const G4i    342                                      const G4int,
343                                      const G4V    343                                      const G4VPhysicalVolume* ) 
344 {                                                 344 {
345   DumpInfo();                                     345   DumpInfo();
346   G4Exception("G4ReflectedSolid::ComputeDimens    346   G4Exception("G4ReflectedSolid::ComputeDimensions()",
347                "GeomMgt0001", FatalException,     347                "GeomMgt0001", FatalException,
348                "Method not applicable in this     348                "Method not applicable in this context!");
349 }                                                 349 }
350                                                   350 
351 //////////////////////////////////////////////    351 //////////////////////////////////////////////////////////////
352 //                                                352 //
353 // Return volume                               << 
354                                                << 
355 G4double G4ReflectedSolid::GetCubicVolume()    << 
356 {                                              << 
357   return fPtrSolid->GetCubicVolume();          << 
358 }                                              << 
359                                                << 
360 ////////////////////////////////////////////// << 
361 //                                             << 
362 // Return surface area                         << 
363                                                << 
364 G4double G4ReflectedSolid::GetSurfaceArea()    << 
365 {                                              << 
366   return fPtrSolid->GetSurfaceArea();          << 
367 }                                              << 
368                                                << 
369 ////////////////////////////////////////////// << 
370 //                                             << 
371 // Return a point (G4ThreeVector) randomly and    353 // Return a point (G4ThreeVector) randomly and uniformly selected
372 // on the solid surface                           354 // on the solid surface
373                                                   355 
374 G4ThreeVector G4ReflectedSolid::GetPointOnSurf    356 G4ThreeVector G4ReflectedSolid::GetPointOnSurface() const
375 {                                                 357 {
376   G4ThreeVector p  =  fPtrSolid->GetPointOnSur    358   G4ThreeVector p  =  fPtrSolid->GetPointOnSurface();
377   return (*fDirectTransform3D)*G4Point3D(p);      359   return (*fDirectTransform3D)*G4Point3D(p);
378 }                                                 360 }
379                                                   361 
380 ////////////////////////////////////////////// << 
381 //                                             << 
382 // Return the number of constituents used for  << 
383 // of the solid                                << 
384                                                << 
385 G4int G4ReflectedSolid::GetNumOfConstituents() << 
386 {                                              << 
387   return fPtrSolid->GetNumOfConstituents();    << 
388 }                                              << 
389                                                << 
390 ////////////////////////////////////////////// << 
391 //                                             << 
392 // Return true if the reflected solid has only << 
393                                                << 
394 G4bool G4ReflectedSolid::IsFaceted() const     << 
395 {                                              << 
396   return fPtrSolid->IsFaceted();               << 
397 }                                              << 
398                                                << 
399 //////////////////////////////////////////////    362 //////////////////////////////////////////////////////////////////////////
400 //                                                363 //
401 // Make a clone of this object                    364 // Make a clone of this object
402                                                   365 
403 G4VSolid* G4ReflectedSolid::Clone() const         366 G4VSolid* G4ReflectedSolid::Clone() const
404 {                                                 367 {
405   return new G4ReflectedSolid(*this);             368   return new G4ReflectedSolid(*this);
406 }                                                 369 }
                                                   >> 370 
407                                                   371 
408 //////////////////////////////////////////////    372 //////////////////////////////////////////////////////////////////////////
409 //                                                373 //
410 // Stream object contents to an output stream     374 // Stream object contents to an output stream
411                                                   375 
412 std::ostream& G4ReflectedSolid::StreamInfo(std    376 std::ostream& G4ReflectedSolid::StreamInfo(std::ostream& os) const
413 {                                                 377 {
414   os << "-------------------------------------    378   os << "-----------------------------------------------------------\n"
415      << "    *** Dump for Reflected solid - "     379      << "    *** Dump for Reflected solid - " << GetName() << " ***\n"
416      << "    =================================    380      << "    ===================================================\n"
417      << " Solid type: " << GetEntityType() <<     381      << " Solid type: " << GetEntityType() << "\n"
418      << " Parameters of constituent solid: \n"    382      << " Parameters of constituent solid: \n"
419      << "=====================================    383      << "===========================================================\n";
420   fPtrSolid->StreamInfo(os);                      384   fPtrSolid->StreamInfo(os);
421   os << "=====================================    385   os << "===========================================================\n"
422      << " Transformations: \n"                    386      << " Transformations: \n"
423      << "    Direct transformation - translati    387      << "    Direct transformation - translation : \n"
424      << "           " << fDirectTransform3D->g    388      << "           " << fDirectTransform3D->getTranslation() << "\n"
425      << "                          - rotation     389      << "                          - rotation    : \n"
426      << "           ";                            390      << "           ";
427   fDirectTransform3D->getRotation().print(os);    391   fDirectTransform3D->getRotation().print(os);
428   os << "\n"                                      392   os << "\n"
429      << "=====================================    393      << "===========================================================\n";
430                                                   394 
431   return os;                                      395   return os;
432 }                                                 396 }
433                                                   397 
434 //////////////////////////////////////////////    398 /////////////////////////////////////////////////
435 //                                                399 //
436 //                                                400 //                    
437                                                   401 
438 void                                              402 void 
439 G4ReflectedSolid::DescribeYourselfTo ( G4VGrap    403 G4ReflectedSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const 
440 {                                                 404 {
441   scene.AddSolid (*this);                         405   scene.AddSolid (*this);
442 }                                                 406 }
443                                                   407 
444 //////////////////////////////////////////////    408 ////////////////////////////////////////////////////
445 //                                                409 //
446 //                                                410 //
447                                                   411 
448 G4Polyhedron*                                     412 G4Polyhedron* 
449 G4ReflectedSolid::CreatePolyhedron () const       413 G4ReflectedSolid::CreatePolyhedron () const 
450 {                                                 414 {
451   G4Polyhedron* polyhedron = fPtrSolid->Create    415   G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron();
452   if (polyhedron != nullptr)                      416   if (polyhedron != nullptr)
453   {                                               417   {
454     polyhedron->Transform(*fDirectTransform3D)    418     polyhedron->Transform(*fDirectTransform3D);
455     return polyhedron;                            419     return polyhedron;
456   }                                               420   }
457   else                                            421   else
458   {                                               422   {
459     std::ostringstream message;                   423     std::ostringstream message;
460     message << "Solid - " << GetName()            424     message << "Solid - " << GetName()
461             << " - original solid has no" << G    425             << " - original solid has no" << G4endl
462             << "corresponding polyhedron. Retu    426             << "corresponding polyhedron. Returning NULL!";
463     G4Exception("G4ReflectedSolid::CreatePolyh    427     G4Exception("G4ReflectedSolid::CreatePolyhedron()",
464                 "GeomMgt1001", JustWarning, me    428                 "GeomMgt1001", JustWarning, message);
465     return nullptr;                               429     return nullptr;
466   }                                               430   }
467 }                                                 431 }
468                                                   432 
469 //////////////////////////////////////////////    433 /////////////////////////////////////////////////////////
470 //                                                434 //
471 //                                                435 //
472                                                   436 
473 G4Polyhedron*                                     437 G4Polyhedron*
474 G4ReflectedSolid::GetPolyhedron () const          438 G4ReflectedSolid::GetPolyhedron () const
475 {                                                 439 {
476   if ((fpPolyhedron == nullptr) || fRebuildPol    440   if ((fpPolyhedron == nullptr) || fRebuildPolyhedron ||
477       (fpPolyhedron->GetNumberOfRotationStepsA    441       (fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
478        fpPolyhedron->GetNumberOfRotationSteps(    442        fpPolyhedron->GetNumberOfRotationSteps()))
479     {                                             443     {
480       fpPolyhedron = CreatePolyhedron();          444       fpPolyhedron = CreatePolyhedron();
481       fRebuildPolyhedron = false;                 445       fRebuildPolyhedron = false;
482     }                                             446     }
483   return fpPolyhedron;                            447   return fpPolyhedron;
484 }                                                 448 }
485                                                   449