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.0.p4)


  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 //
                                                   >>  27 // $Id: G4ReflectedSolid.cc 66356 2012-12-18 09:02:32Z gcosmo $
                                                   >>  28 //
                                                   >>  29 //
                                                   >>  30 // Implementation for G4ReflectedSolid class for boolean 
                                                   >>  31 // operations between other solids
 27 //                                                 32 //
 28 // Author: Vladimir Grichine, 23.07.01  (Vladi     33 // Author: Vladimir Grichine, 23.07.01  (Vladimir.Grichine@cern.ch)
                                                   >>  34 //
 29 // -------------------------------------------     35 // --------------------------------------------------------------------
 30                                                    36 
 31 #include "G4ReflectedSolid.hh"                     37 #include "G4ReflectedSolid.hh"
 32                                                    38 
 33 #include <sstream>                                 39 #include <sstream>
 34                                                    40 
 35 #include "G4Point3D.hh"                            41 #include "G4Point3D.hh"
 36 #include "G4Vector3D.hh"                       <<  42 #include "G4Normal3D.hh"
 37                                                    43 
 38 #include "G4AffineTransform.hh"                << 
 39 #include "G4Transform3D.hh"                    << 
 40 #include "G4VoxelLimits.hh"                        44 #include "G4VoxelLimits.hh"
 41                                                    45 
 42 #include "G4VPVParameterisation.hh"                46 #include "G4VPVParameterisation.hh"
 43                                                    47 
 44 #include "G4VGraphicsScene.hh"                     48 #include "G4VGraphicsScene.hh"
 45 #include "G4Polyhedron.hh"                         49 #include "G4Polyhedron.hh"
 46                                                    50 
                                                   >>  51 
 47 //////////////////////////////////////////////     52 /////////////////////////////////////////////////////////////////
 48 //                                                 53 //
 49 // Constructor using HepTransform3D, in fact H     54 // Constructor using HepTransform3D, in fact HepReflect3D
 50                                                    55 
 51 G4ReflectedSolid::G4ReflectedSolid( const G4St     56 G4ReflectedSolid::G4ReflectedSolid( const G4String& pName,
 52                                           G4VS     57                                           G4VSolid* pSolid ,
 53                                     const G4Tr <<  58                                     const G4Transform3D& transform  )
 54   : G4VSolid(pName)                            <<  59   : G4VSolid(pName), fpPolyhedron(0)
 55 {                                                  60 {
 56   fPtrSolid = pSolid;                          <<  61   fPtrSolid = pSolid ;
 57   fDirectTransform3D = new G4Transform3D(trans <<  62   G4RotationMatrix rotMatrix ;
                                                   >>  63   
                                                   >>  64   fDirectTransform =
                                                   >>  65      new G4AffineTransform(rotMatrix, transform.getTranslation()) ;  
                                                   >>  66   fPtrTransform    =
                                                   >>  67      new G4AffineTransform(rotMatrix, transform.getTranslation()) ; 
                                                   >>  68   fPtrTransform->Invert() ;
                                                   >>  69 
                                                   >>  70   fDirectTransform3D = new G4Transform3D(transform) ;
                                                   >>  71   fPtrTransform3D    = new G4Transform3D(transform.inverse()) ;   
 58 }                                                  72 }
 59                                                    73 
 60 //////////////////////////////////////////////     74 ///////////////////////////////////////////////////////////////////
 61 //                                                 75 //
 62                                                    76 
 63 G4ReflectedSolid::~G4ReflectedSolid()              77 G4ReflectedSolid::~G4ReflectedSolid() 
 64 {                                                  78 {
 65   delete fDirectTransform3D; fDirectTransform3 <<  79   if(fPtrTransform)
 66   delete fpPolyhedron; fpPolyhedron = nullptr; <<  80   {
                                                   >>  81     delete fPtrTransform; fPtrTransform=0;
                                                   >>  82     delete fDirectTransform; fDirectTransform=0;
                                                   >>  83   }
                                                   >>  84   if(fPtrTransform3D)
                                                   >>  85   {
                                                   >>  86     delete fPtrTransform3D; fPtrTransform3D=0;
                                                   >>  87     delete fDirectTransform3D; fDirectTransform3D=0;
                                                   >>  88   }
                                                   >>  89   delete fpPolyhedron;
 67 }                                                  90 }
 68                                                    91 
 69 //////////////////////////////////////////////     92 ///////////////////////////////////////////////////////////////////
 70 //                                                 93 //
 71                                                    94 
 72 G4ReflectedSolid::G4ReflectedSolid(const G4Ref     95 G4ReflectedSolid::G4ReflectedSolid(const G4ReflectedSolid& rhs)
 73   : G4VSolid(rhs), fPtrSolid(rhs.fPtrSolid)    <<  96   : G4VSolid(rhs), fPtrSolid(rhs.fPtrSolid), fpPolyhedron(0)
 74 {                                                  97 {
                                                   >>  98   fPtrTransform      = new G4AffineTransform(*rhs.fPtrTransform);
                                                   >>  99   fDirectTransform   = new G4AffineTransform(*rhs.fDirectTransform);
                                                   >> 100   fPtrTransform3D    = new G4Transform3D(*rhs.fPtrTransform3D);
 75   fDirectTransform3D = new G4Transform3D(*rhs.    101   fDirectTransform3D = new G4Transform3D(*rhs.fDirectTransform3D);
 76 }                                                 102 }
 77                                                   103 
 78 //////////////////////////////////////////////    104 ///////////////////////////////////////////////////////////////////
 79 //                                                105 //
 80                                                   106 
 81 G4ReflectedSolid& G4ReflectedSolid::operator=(    107 G4ReflectedSolid& G4ReflectedSolid::operator=(const G4ReflectedSolid& rhs)
 82 {                                                 108 {
 83   // Check assignment to self                     109   // Check assignment to self
 84   //                                              110   //
 85   if (this == &rhs)  { return *this; }            111   if (this == &rhs)  { return *this; }
 86                                                   112 
 87   // Copy base class data                         113   // Copy base class data
 88   //                                              114   //
 89   G4VSolid::operator=(rhs);                       115   G4VSolid::operator=(rhs);
 90                                                   116 
 91   // Copy data                                    117   // Copy data
 92   //                                              118   //
 93   fPtrSolid = rhs.fPtrSolid;                   << 119   fPtrSolid= rhs.fPtrSolid; fpPolyhedron= 0;
                                                   >> 120   delete fPtrTransform;
                                                   >> 121   fPtrTransform= new G4AffineTransform(*rhs.fPtrTransform);
                                                   >> 122   delete fDirectTransform;
                                                   >> 123   fDirectTransform= new G4AffineTransform(*rhs.fDirectTransform);
                                                   >> 124   delete fPtrTransform3D;
                                                   >> 125   fPtrTransform3D= new G4Transform3D(*rhs.fPtrTransform3D);
 94   delete fDirectTransform3D;                      126   delete fDirectTransform3D;
 95   fDirectTransform3D = new G4Transform3D(*rhs. << 127   fDirectTransform3D= new G4Transform3D(*rhs.fDirectTransform3D);
 96   fRebuildPolyhedron = false;                  << 
 97   delete fpPolyhedron; fpPolyhedron = nullptr; << 
 98                                                   128 
 99   return *this;                                   129   return *this;
100 }                                                 130 }
101                                                   131 
102 //////////////////////////////////////////////    132 ///////////////////////////////////////////////////////////////////
103 //                                                133 //
104                                                   134 
105 G4GeometryType G4ReflectedSolid::GetEntityType    135 G4GeometryType G4ReflectedSolid::GetEntityType() const 
106 {                                                 136 {
107   return {"G4ReflectedSolid"};                 << 137   return G4String("G4ReflectedSolid");
108 }                                                 138 }
109                                                   139 
110 const G4ReflectedSolid* G4ReflectedSolid::GetR    140 const G4ReflectedSolid* G4ReflectedSolid::GetReflectedSolidPtr() const   
111 {                                                 141 {
112   return this;                                    142   return this;
113 }                                                 143 }
114                                                   144 
115 G4ReflectedSolid* G4ReflectedSolid::GetReflect    145 G4ReflectedSolid* G4ReflectedSolid::GetReflectedSolidPtr() 
116 {                                                 146 {
117   return this;                                    147   return this;
118 }                                                 148 }
119                                                   149 
120 G4VSolid* G4ReflectedSolid::GetConstituentMove    150 G4VSolid* G4ReflectedSolid::GetConstituentMovedSolid() const
121 {                                                 151 { 
122   return fPtrSolid;                               152   return fPtrSolid; 
123 }                                                 153 } 
124                                                   154 
125 //////////////////////////////////////////////    155 /////////////////////////////////////////////////////////////////////////////
126 //                                             << 156 
                                                   >> 157 G4AffineTransform  G4ReflectedSolid::GetTransform() const
                                                   >> 158 {
                                                   >> 159    G4AffineTransform aTransform = *fPtrTransform;
                                                   >> 160    return aTransform;
                                                   >> 161 }
                                                   >> 162 
                                                   >> 163 void G4ReflectedSolid::SetTransform(G4AffineTransform& transform) 
                                                   >> 164 {
                                                   >> 165    fPtrTransform = &transform ;
                                                   >> 166    fpPolyhedron = 0;
                                                   >> 167 }
                                                   >> 168 
                                                   >> 169 //////////////////////////////////////////////////////////////////////////////
                                                   >> 170 
                                                   >> 171 G4AffineTransform  G4ReflectedSolid::GetDirectTransform() const
                                                   >> 172 {
                                                   >> 173   G4AffineTransform aTransform= *fDirectTransform;
                                                   >> 174   return aTransform;
                                                   >> 175 }
                                                   >> 176 
                                                   >> 177 void G4ReflectedSolid::SetDirectTransform(G4AffineTransform& transform) 
                                                   >> 178 {
                                                   >> 179   fDirectTransform = &transform ;
                                                   >> 180   fpPolyhedron = 0;
                                                   >> 181 }
                                                   >> 182 
                                                   >> 183 /////////////////////////////////////////////////////////////////////////////
127                                                   184 
128 G4Transform3D  G4ReflectedSolid::GetTransform3    185 G4Transform3D  G4ReflectedSolid::GetTransform3D() const
129 {                                                 186 {
130   return fDirectTransform3D->inverse();        << 187   G4Transform3D aTransform = *fPtrTransform3D;
                                                   >> 188   return aTransform;
131 }                                                 189 }
132                                                   190 
                                                   >> 191 void G4ReflectedSolid::SetTransform3D(G4Transform3D& transform) 
                                                   >> 192 {
                                                   >> 193   fPtrTransform3D = &transform ;
                                                   >> 194   fpPolyhedron = 0;
                                                   >> 195 }
                                                   >> 196 
                                                   >> 197 //////////////////////////////////////////////////////////////////////////////
                                                   >> 198 
133 G4Transform3D  G4ReflectedSolid::GetDirectTran    199 G4Transform3D  G4ReflectedSolid::GetDirectTransform3D() const
134 {                                                 200 {
135   G4Transform3D aTransform = *fDirectTransform << 201   G4Transform3D aTransform= *fDirectTransform3D;
136   return aTransform;                              202   return aTransform;
137 }                                                 203 }
138                                                   204 
139 void G4ReflectedSolid::SetDirectTransform3D(G4    205 void G4ReflectedSolid::SetDirectTransform3D(G4Transform3D& transform) 
140 {                                                 206 {
141   fDirectTransform3D = &transform;             << 207   fDirectTransform3D = &transform ;
142   fRebuildPolyhedron = true;                   << 208   fpPolyhedron = 0;
143 }                                                 209 }
144                                                   210 
145 ////////////////////////////////////////////// << 211 /////////////////////////////////////////////////////////////////////////////
146 //                                             << 
147 // Get bounding box                            << 
148                                                   212 
149 void G4ReflectedSolid::BoundingLimits(G4ThreeV << 213 G4RotationMatrix G4ReflectedSolid::GetFrameRotation() const
150                                       G4ThreeV << 
151 {                                                 214 {
152   fPtrSolid->BoundingLimits(pMin,pMax);        << 215   G4RotationMatrix InvRotation= fDirectTransform->NetRotation();
153   G4double xmin = pMin.x(), ymin = pMin.y(), z << 216   return InvRotation;
154   G4double xmax = pMax.x(), ymax = pMax.y(), z << 217 }
155   G4double xx = fDirectTransform3D->xx();      << 
156   G4double yy = fDirectTransform3D->yy();      << 
157   G4double zz = fDirectTransform3D->zz();      << 
158                                                   218 
159   if (std::abs(xx) == 1 && std::abs(yy) == 1 & << 219 void G4ReflectedSolid::SetFrameRotation(const G4RotationMatrix& matrix)
160   {                                            << 220 {
161     // Special case of reflection in axis and  << 221   fDirectTransform->SetNetRotation(matrix);
162     //                                         << 222 }
163     if (xx == -1) { G4double tmp = -xmin; xmin << 
164     if (yy == -1) { G4double tmp = -ymin; ymin << 
165     if (zz == -1) { G4double tmp = -zmin; zmin << 
166     xmin += fDirectTransform3D->dx();          << 
167     xmax += fDirectTransform3D->dx();          << 
168     ymin += fDirectTransform3D->dy();          << 
169     ymax += fDirectTransform3D->dy();          << 
170     zmin += fDirectTransform3D->dz();          << 
171     zmax += fDirectTransform3D->dz();          << 
172   }                                            << 
173   else                                         << 
174   {                                            << 
175     // Use additional reflection in Z to set u << 
176     //                                         << 
177     G4Transform3D transform3D = G4ReflectZ3D() << 
178     G4AffineTransform transform(transform3D.ge << 
179                                 transform3D.ge << 
180                                                << 
181     // Find bounding box                       << 
182     //                                         << 
183     G4VoxelLimits unLimit;                     << 
184     fPtrSolid->CalculateExtent(kXAxis,unLimit, << 
185     fPtrSolid->CalculateExtent(kYAxis,unLimit, << 
186     fPtrSolid->CalculateExtent(kZAxis,unLimit, << 
187   }                                            << 
188                                                   223 
189   pMin.set(xmin,ymin,-zmax);                   << 224 /////////////////////////////////////////////////////////////////////////////
190   pMax.set(xmax,ymax,-zmin);                   << 
191                                                   225 
192   // Check correctness of the bounding box     << 226 G4ThreeVector  G4ReflectedSolid::GetFrameTranslation() const
193   //                                           << 227 {
194   if (pMin.x() >= pMax.x() || pMin.y() >= pMax << 228   return fPtrTransform->NetTranslation();
195   {                                            << 
196     std::ostringstream message;                << 
197     message << "Bad bounding box (min >= max)  << 
198             << GetName() << " !"               << 
199             << "\npMin = " << pMin             << 
200             << "\npMax = " << pMax;            << 
201     G4Exception("G4ReflectedSolid::BoundingLim << 
202                 JustWarning, message);         << 
203     DumpInfo();                                << 
204   }                                            << 
205 }                                                 229 }
206                                                   230 
207 ////////////////////////////////////////////// << 231 void G4ReflectedSolid::SetFrameTranslation(const G4ThreeVector& vector)
208 //                                             << 232 {
209 // Calculate extent under transform and specif << 233   fPtrTransform->SetNetTranslation(vector);
                                                   >> 234 }
                                                   >> 235 
                                                   >> 236 ///////////////////////////////////////////////////////////////
                                                   >> 237 
                                                   >> 238 G4RotationMatrix G4ReflectedSolid::GetObjectRotation() const
                                                   >> 239 {
                                                   >> 240   G4RotationMatrix Rotation= fPtrTransform->NetRotation();
                                                   >> 241   return Rotation;
                                                   >> 242 }
210                                                   243 
                                                   >> 244 void G4ReflectedSolid::SetObjectRotation(const G4RotationMatrix& matrix)
                                                   >> 245 {
                                                   >> 246   fPtrTransform->SetNetRotation(matrix);
                                                   >> 247 }
                                                   >> 248 
                                                   >> 249 ///////////////////////////////////////////////////////////////////////
                                                   >> 250 
                                                   >> 251 G4ThreeVector  G4ReflectedSolid::GetObjectTranslation() const
                                                   >> 252 {
                                                   >> 253   return fDirectTransform->NetTranslation();
                                                   >> 254 }
                                                   >> 255 
                                                   >> 256 void G4ReflectedSolid::SetObjectTranslation(const G4ThreeVector& vector)
                                                   >> 257 {
                                                   >> 258   fDirectTransform->SetNetTranslation(vector);
                                                   >> 259 }
                                                   >> 260 
                                                   >> 261 ///////////////////////////////////////////////////////////////
                                                   >> 262 //
                                                   >> 263 //
                                                   >> 264      
211 G4bool                                            265 G4bool 
212 G4ReflectedSolid::CalculateExtent( const EAxis    266 G4ReflectedSolid::CalculateExtent( const EAxis pAxis,
213                                    const G4Vox << 267                                    const G4VoxelLimits& pVoxelLimit,
214                                    const G4Aff    268                                    const G4AffineTransform& pTransform,
215                                          G4dou    269                                          G4double& pMin, 
216                                          G4dou << 270                                          G4double& pMax           ) const 
217 {                                                 271 {
218   // Separation of transformations. Calculatio << 
219   // in a reflection of the global space. In s << 
220   // reflected, but the solid is transformed j << 
221   // It allows one to use CalculateExtent() of << 
222                                                   272 
223   // Reflect voxel limits in Z                 << 273   G4VoxelLimits unLimit;
224   //                                           << 274   G4AffineTransform unTransform;
225   G4VoxelLimits limits;                        << 
226   limits.AddLimit(kXAxis, pVoxelLimits.GetMinX << 
227                           pVoxelLimits.GetMaxX << 
228   limits.AddLimit(kYAxis, pVoxelLimits.GetMinY << 
229                           pVoxelLimits.GetMaxY << 
230   limits.AddLimit(kZAxis,-pVoxelLimits.GetMaxZ << 
231                          -pVoxelLimits.GetMinZ << 
232                                                   275 
233   // Set affine transformation                 << 276   G4double x1 = -kInfinity, x2 = kInfinity,
234   //                                           << 277            y1 = -kInfinity, y2 = kInfinity,
235   G4Transform3D transform3D = G4ReflectZ3D()*p << 278            z1 = -kInfinity, z2 = kInfinity;
236   G4AffineTransform transform(transform3D.getR << 
237                               transform3D.getT << 
238                                                   279 
239   // Find extent                               << 280   G4bool existsAfterClip = false ;
240   //                                           << 281   existsAfterClip =
241   if (!fPtrSolid->CalculateExtent(pAxis, limit << 282       fPtrSolid->CalculateExtent(kXAxis,unLimit,unTransform,x1,x2);
                                                   >> 283   existsAfterClip =
                                                   >> 284       fPtrSolid->CalculateExtent(kYAxis,unLimit,unTransform,y1,y2);
                                                   >> 285   existsAfterClip =
                                                   >> 286       fPtrSolid->CalculateExtent(kZAxis,unLimit,unTransform,z1,z2);
                                                   >> 287 
                                                   >> 288   existsAfterClip = false;
                                                   >> 289   pMin = +kInfinity ;
                                                   >> 290   pMax = -kInfinity ;
                                                   >> 291 
                                                   >> 292   G4Transform3D pTransform3D = G4Transform3D(pTransform.NetRotation().inverse(),
                                                   >> 293                                              pTransform.NetTranslation());
                                                   >> 294  
                                                   >> 295   G4Transform3D transform3D  = pTransform3D*(*fDirectTransform3D);
                                                   >> 296 
                                                   >> 297   G4Point3D tmpPoint;
                                                   >> 298 
                                                   >> 299   // Calculate rotated vertex coordinates
                                                   >> 300 
                                                   >> 301   G4ThreeVectorList* vertices = new G4ThreeVectorList();
                                                   >> 302 
                                                   >> 303   if (vertices)
242   {                                               304   {
243     return false;                              << 305     vertices->reserve(8);
                                                   >> 306 
                                                   >> 307     G4ThreeVector vertex0(x1,y1,z1) ;
                                                   >> 308     tmpPoint    = transform3D*G4Point3D(vertex0);
                                                   >> 309     vertex0     = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
                                                   >> 310     vertices->push_back(vertex0);
                                                   >> 311 
                                                   >> 312     G4ThreeVector vertex1(x2,y1,z1) ;
                                                   >> 313     tmpPoint    = transform3D*G4Point3D(vertex1);
                                                   >> 314     vertex1     = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
                                                   >> 315     vertices->push_back(vertex1);
                                                   >> 316 
                                                   >> 317     G4ThreeVector vertex2(x2,y2,z1) ;
                                                   >> 318     tmpPoint    = transform3D*G4Point3D(vertex2);
                                                   >> 319     vertex2     = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
                                                   >> 320     vertices->push_back(vertex2);
                                                   >> 321 
                                                   >> 322     G4ThreeVector vertex3(x1,y2,z1) ;
                                                   >> 323     tmpPoint    = transform3D*G4Point3D(vertex3);
                                                   >> 324     vertex3     = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
                                                   >> 325     vertices->push_back(vertex3);
                                                   >> 326 
                                                   >> 327     G4ThreeVector vertex4(x1,y1,z2) ;
                                                   >> 328     tmpPoint    = transform3D*G4Point3D(vertex4);
                                                   >> 329     vertex4     = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
                                                   >> 330     vertices->push_back(vertex4);
                                                   >> 331 
                                                   >> 332     G4ThreeVector vertex5(x2,y1,z2) ;
                                                   >> 333     tmpPoint    = transform3D*G4Point3D(vertex5);
                                                   >> 334     vertex5     = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
                                                   >> 335     vertices->push_back(vertex5);
                                                   >> 336 
                                                   >> 337     G4ThreeVector vertex6(x2,y2,z2) ;
                                                   >> 338     tmpPoint    = transform3D*G4Point3D(vertex6);
                                                   >> 339     vertex6     = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
                                                   >> 340     vertices->push_back(vertex6);
                                                   >> 341 
                                                   >> 342     G4ThreeVector vertex7(x1,y2,z2) ;
                                                   >> 343     tmpPoint    = transform3D*G4Point3D(vertex7);
                                                   >> 344     vertex7     = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
                                                   >> 345     vertices->push_back(vertex7);
244   }                                               346   }
245   if (pAxis == kZAxis)                         << 347   else
246   {                                               348   {
247     G4double tmp= -pMin; pMin= -pMax; pMax= tm << 349     DumpInfo();
                                                   >> 350     G4Exception("G4ReflectedSolid::CalculateExtent()",
                                                   >> 351                 "GeomMgt0003", FatalException,
                                                   >> 352                 "Error in allocation of vertices. Out of memory !");
248   }                                               353   }
                                                   >> 354   
                                                   >> 355   ClipCrossSection(vertices,0,pVoxelLimit,pAxis,pMin,pMax) ;
                                                   >> 356   ClipCrossSection(vertices,4,pVoxelLimit,pAxis,pMin,pMax) ;
                                                   >> 357   ClipBetweenSections(vertices,0,pVoxelLimit,pAxis,pMin,pMax) ;
                                                   >> 358 
                                                   >> 359     if (pVoxelLimit.IsLimited(pAxis) == false) 
                                                   >> 360     {  
                                                   >> 361       if ( pMin != kInfinity || pMax != -kInfinity ) 
                                                   >> 362       {
                                                   >> 363         existsAfterClip = true ;
                                                   >> 364 
                                                   >> 365         // Add 2*tolerance to avoid precision troubles
                                                   >> 366 
                                                   >> 367         pMin           -= kCarTolerance;
                                                   >> 368         pMax           += kCarTolerance;
                                                   >> 369       }
                                                   >> 370     }      
                                                   >> 371     else
                                                   >> 372     {
                                                   >> 373       G4ThreeVector clipCentre(
                                                   >> 374          ( pVoxelLimit.GetMinXExtent()+pVoxelLimit.GetMaxXExtent())*0.5,
                                                   >> 375          ( pVoxelLimit.GetMinYExtent()+pVoxelLimit.GetMaxYExtent())*0.5,
                                                   >> 376          ( pVoxelLimit.GetMinZExtent()+pVoxelLimit.GetMaxZExtent())*0.5);
                                                   >> 377 
                                                   >> 378       if ( pMin != kInfinity || pMax != -kInfinity )
                                                   >> 379       {
                                                   >> 380         existsAfterClip = true ;
                                                   >> 381   
249                                                   382 
250   return true;                                 << 383         // Check to see if endpoints are in the solid
251 }                                              << 
252                                                   384 
253 ////////////////////////////////////////////// << 385         clipCentre(pAxis) = pVoxelLimit.GetMinExtent(pAxis);
                                                   >> 386 
                                                   >> 387         if (Inside(transform3D.inverse()*G4Point3D(clipCentre)) != kOutside)
                                                   >> 388         {
                                                   >> 389           pMin = pVoxelLimit.GetMinExtent(pAxis);
                                                   >> 390         }
                                                   >> 391         else
                                                   >> 392         {
                                                   >> 393           pMin -= kCarTolerance;
                                                   >> 394         }
                                                   >> 395         clipCentre(pAxis) = pVoxelLimit.GetMaxExtent(pAxis);
                                                   >> 396 
                                                   >> 397         if (Inside(transform3D.inverse()*G4Point3D(clipCentre)) != kOutside)
                                                   >> 398         {
                                                   >> 399           pMax = pVoxelLimit.GetMaxExtent(pAxis);
                                                   >> 400         }
                                                   >> 401         else
                                                   >> 402         {
                                                   >> 403           pMax += kCarTolerance;
                                                   >> 404         }
                                                   >> 405       }
                                                   >> 406       // Check for case where completely enveloping clipping volume
                                                   >> 407       // If point inside then we are confident that the solid completely
                                                   >> 408       // envelopes the clipping volume. Hence set min/max extents according
                                                   >> 409       // to clipping volume extents along the specified axis.
                                                   >> 410         
                                                   >> 411     else if (Inside(transform3D.inverse()*G4Point3D(clipCentre)) != kOutside)
                                                   >> 412     {
                                                   >> 413       existsAfterClip = true ;
                                                   >> 414       pMin            = pVoxelLimit.GetMinExtent(pAxis) ;
                                                   >> 415       pMax            = pVoxelLimit.GetMaxExtent(pAxis) ;
                                                   >> 416     }
                                                   >> 417   } 
                                                   >> 418   delete vertices;
                                                   >> 419   return existsAfterClip;
                                                   >> 420 }
                                                   >> 421  
                                                   >> 422 /////////////////////////////////////////////////////
254 //                                                423 //
255 //                                                424 // 
256                                                   425 
257 EInside G4ReflectedSolid::Inside(const G4Three << 426 EInside G4ReflectedSolid::Inside(const G4ThreeVector& p) const
258 {                                                 427 {
259   G4ThreeVector newPoint = (*fDirectTransform3 << 428 
260   return fPtrSolid->Inside(newPoint);          << 429   G4Point3D newPoint = (*fDirectTransform3D)*G4Point3D(p) ;
                                                   >> 430   // G4Point3D newPoint = (*fPtrTransform3D)*G4Point3D(p) ;
                                                   >> 431 
                                                   >> 432   return fPtrSolid->Inside(G4ThreeVector(newPoint.x(),
                                                   >> 433                                          newPoint.y(),
                                                   >> 434                                          newPoint.z())) ; 
261 }                                                 435 }
262                                                   436 
263 //////////////////////////////////////////////    437 //////////////////////////////////////////////////////////////
264 //                                                438 //
265 //                                                439 //
266                                                   440 
267 G4ThreeVector                                     441 G4ThreeVector 
268 G4ReflectedSolid::SurfaceNormal( const G4Three    442 G4ReflectedSolid::SurfaceNormal( const G4ThreeVector& p ) const 
269 {                                                 443 {
270   G4ThreeVector newPoint = (*fDirectTransform3 << 444   G4Point3D newPoint = (*fDirectTransform3D)*G4Point3D(p) ;
271   G4Vector3D normal = fPtrSolid->SurfaceNormal << 445   G4ThreeVector normal =
272   return (*fDirectTransform3D)*normal;         << 446       fPtrSolid->SurfaceNormal(G4ThreeVector(newPoint.x(),
                                                   >> 447                                              newPoint.y(),
                                                   >> 448                                              newPoint.z() ) ) ;
                                                   >> 449   G4Point3D newN = (*fDirectTransform3D)*G4Point3D(normal) ;
                                                   >> 450   newN.unit() ;
                                                   >> 451 
                                                   >> 452   return G4ThreeVector(newN.x(),newN.y(),newN.z()) ;    
273 }                                                 453 }
274                                                   454 
275 //////////////////////////////////////////////    455 /////////////////////////////////////////////////////////////
276 //                                                456 //
277 // The same algorithm as in DistanceToIn(p)       457 // The same algorithm as in DistanceToIn(p)
278                                                   458 
279 G4double                                          459 G4double 
280 G4ReflectedSolid::DistanceToIn( const G4ThreeV    460 G4ReflectedSolid::DistanceToIn( const G4ThreeVector& p,
281                                 const G4ThreeV << 461                                    const G4ThreeVector& v  ) const 
282 {                                                 462 {    
283   G4ThreeVector newPoint     = (*fDirectTransf << 463   G4Point3D newPoint     = (*fDirectTransform3D)*G4Point3D(p) ;
284   G4ThreeVector newDirection = (*fDirectTransf << 464   G4Point3D newDirection = (*fDirectTransform3D)*G4Point3D(v) ;
285   return fPtrSolid->DistanceToIn(newPoint,newD << 465   newDirection.unit() ;
                                                   >> 466   return fPtrSolid->DistanceToIn(
                                                   >> 467        G4ThreeVector(newPoint.x(),newPoint.y(),newPoint.z()),
                                                   >> 468        G4ThreeVector(newDirection.x(),newDirection.y(),newDirection.z())) ;   
286 }                                                 469 }
287                                                   470 
288 //////////////////////////////////////////////    471 ////////////////////////////////////////////////////////
289 //                                                472 //
290 // Approximate nearest distance from the point    473 // Approximate nearest distance from the point p to the intersection of
291 // two solids                                     474 // two solids
292                                                   475 
293 G4double                                          476 G4double 
294 G4ReflectedSolid::DistanceToIn( const G4ThreeV << 477 G4ReflectedSolid::DistanceToIn( const G4ThreeVector& p) const 
295 {                                                 478 {
296   G4ThreeVector newPoint = (*fDirectTransform3 << 479   G4Point3D newPoint = (*fDirectTransform3D)*G4Point3D(p) ;
297   return fPtrSolid->DistanceToIn(newPoint);    << 480   return fPtrSolid->DistanceToIn(
                                                   >> 481                     G4ThreeVector(newPoint.x(),newPoint.y(),newPoint.z())) ;   
298 }                                                 482 }
299                                                   483 
300 //////////////////////////////////////////////    484 //////////////////////////////////////////////////////////
301 //                                                485 //
302 // The same algorithm as DistanceToOut(p)         486 // The same algorithm as DistanceToOut(p)
303                                                   487 
304 G4double                                          488 G4double 
305 G4ReflectedSolid::DistanceToOut( const G4Three    489 G4ReflectedSolid::DistanceToOut( const G4ThreeVector& p,
306                                  const G4Three    490                                  const G4ThreeVector& v,
307                                  const G4bool     491                                  const G4bool calcNorm,
308                                        G4bool* << 492                                        G4bool *validNorm,
309                                        G4Three << 493                                        G4ThreeVector *n      ) const 
310 {                                                 494 {
311   G4ThreeVector solNorm;                       << 495   G4ThreeVector solNorm ; 
312                                                << 
313   G4ThreeVector newPoint     = (*fDirectTransf << 
314   G4ThreeVector newDirection = (*fDirectTransf << 
315                                                   496 
316   G4double dist = fPtrSolid->DistanceToOut(new << 497   G4Point3D newPoint     = (*fDirectTransform3D)*G4Point3D(p) ;
317                                            cal << 498   G4Point3D newDirection = (*fDirectTransform3D)*G4Point3D(v);
                                                   >> 499   newDirection.unit() ;
                                                   >> 500 
                                                   >> 501   G4double dist =
                                                   >> 502     fPtrSolid->DistanceToOut(
                                                   >> 503               G4ThreeVector(newPoint.x(),newPoint.y(),newPoint.z()),
                                                   >> 504               G4ThreeVector(newDirection.x(),newDirection.y(),newDirection.z()),
                                                   >> 505               calcNorm, validNorm, &solNorm) ;
318   if(calcNorm)                                    506   if(calcNorm)
319   {                                               507   { 
320     *n = (*fDirectTransform3D)*G4Vector3D(solN << 508     G4Point3D newN = (*fDirectTransform3D)*G4Point3D(solNorm);
                                                   >> 509     newN.unit() ;
                                                   >> 510     *n = G4ThreeVector(newN.x(),newN.y(),newN.z());
321   }                                               511   }
322   return dist;                                 << 512   return dist ;  
323 }                                                 513 }
324                                                   514 
325 //////////////////////////////////////////////    515 //////////////////////////////////////////////////////////////
326 //                                                516 //
327 // Inverted algorithm of DistanceToIn(p)          517 // Inverted algorithm of DistanceToIn(p)
328                                                   518 
329 G4double                                          519 G4double 
330 G4ReflectedSolid::DistanceToOut( const G4Three    520 G4ReflectedSolid::DistanceToOut( const G4ThreeVector& p ) const 
331 {                                                 521 {
332   G4ThreeVector newPoint = (*fDirectTransform3 << 522   G4Point3D newPoint = (*fDirectTransform3D)*G4Point3D(p);
333   return fPtrSolid->DistanceToOut(newPoint);   << 523   return fPtrSolid->DistanceToOut(
                                                   >> 524                     G4ThreeVector(newPoint.x(),newPoint.y(),newPoint.z()));   
334 }                                                 525 }
335                                                   526 
336 //////////////////////////////////////////////    527 //////////////////////////////////////////////////////////////
337 //                                                528 //
338 //                                                529 //
339                                                   530 
340 void                                              531 void 
341 G4ReflectedSolid::ComputeDimensions(       G4V    532 G4ReflectedSolid::ComputeDimensions(       G4VPVParameterisation*,
342                                      const G4i    533                                      const G4int,
343                                      const G4V    534                                      const G4VPhysicalVolume* ) 
344 {                                                 535 {
345   DumpInfo();                                     536   DumpInfo();
346   G4Exception("G4ReflectedSolid::ComputeDimens    537   G4Exception("G4ReflectedSolid::ComputeDimensions()",
347                "GeomMgt0001", FatalException,     538                "GeomMgt0001", FatalException,
348                "Method not applicable in this     539                "Method not applicable in this context!");
349 }                                                 540 }
350                                                   541 
351 //////////////////////////////////////////////    542 //////////////////////////////////////////////////////////////
352 //                                                543 //
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    544 // Return a point (G4ThreeVector) randomly and uniformly selected
372 // on the solid surface                           545 // on the solid surface
373                                                   546 
374 G4ThreeVector G4ReflectedSolid::GetPointOnSurf    547 G4ThreeVector G4ReflectedSolid::GetPointOnSurface() const
375 {                                                 548 {
376   G4ThreeVector p  =  fPtrSolid->GetPointOnSur << 549   G4ThreeVector p    =  fPtrSolid->GetPointOnSurface();
377   return (*fDirectTransform3D)*G4Point3D(p);   << 550   G4Point3D newPoint = (*fDirectTransform3D)*G4Point3D(p);
378 }                                              << 
379                                                   551 
380 ////////////////////////////////////////////// << 552   return G4ThreeVector(newPoint.x(),newPoint.y(),newPoint.z());
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 }                                                 553 }
398                                                   554 
399 //////////////////////////////////////////////    555 //////////////////////////////////////////////////////////////////////////
400 //                                                556 //
401 // Make a clone of this object                    557 // Make a clone of this object
402                                                   558 
403 G4VSolid* G4ReflectedSolid::Clone() const         559 G4VSolid* G4ReflectedSolid::Clone() const
404 {                                                 560 {
405   return new G4ReflectedSolid(*this);             561   return new G4ReflectedSolid(*this);
406 }                                                 562 }
407                                                   563 
                                                   >> 564 
408 //////////////////////////////////////////////    565 //////////////////////////////////////////////////////////////////////////
409 //                                                566 //
410 // Stream object contents to an output stream     567 // Stream object contents to an output stream
411                                                   568 
412 std::ostream& G4ReflectedSolid::StreamInfo(std    569 std::ostream& G4ReflectedSolid::StreamInfo(std::ostream& os) const
413 {                                                 570 {
414   os << "-------------------------------------    571   os << "-----------------------------------------------------------\n"
415      << "    *** Dump for Reflected solid - "     572      << "    *** Dump for Reflected solid - " << GetName() << " ***\n"
416      << "    =================================    573      << "    ===================================================\n"
417      << " Solid type: " << GetEntityType() <<     574      << " Solid type: " << GetEntityType() << "\n"
418      << " Parameters of constituent solid: \n"    575      << " Parameters of constituent solid: \n"
419      << "=====================================    576      << "===========================================================\n";
420   fPtrSolid->StreamInfo(os);                      577   fPtrSolid->StreamInfo(os);
421   os << "=====================================    578   os << "===========================================================\n"
422      << " Transformations: \n"                    579      << " Transformations: \n"
423      << "    Direct transformation - translati    580      << "    Direct transformation - translation : \n"
424      << "           " << fDirectTransform3D->g << 581      << "           " << fDirectTransform->NetTranslation() << "\n"
425      << "                          - rotation     582      << "                          - rotation    : \n"
426      << "           ";                            583      << "           ";
427   fDirectTransform3D->getRotation().print(os); << 584   fDirectTransform->NetRotation().print(os);
428   os << "\n"                                      585   os << "\n"
429      << "=====================================    586      << "===========================================================\n";
430                                                   587 
431   return os;                                      588   return os;
432 }                                                 589 }
433                                                   590 
434 //////////////////////////////////////////////    591 /////////////////////////////////////////////////
435 //                                                592 //
436 //                                                593 //                    
437                                                   594 
438 void                                              595 void 
439 G4ReflectedSolid::DescribeYourselfTo ( G4VGrap    596 G4ReflectedSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const 
440 {                                                 597 {
441   scene.AddSolid (*this);                         598   scene.AddSolid (*this);
442 }                                                 599 }
443                                                   600 
444 //////////////////////////////////////////////    601 ////////////////////////////////////////////////////
445 //                                                602 //
446 //                                                603 //
447                                                   604 
448 G4Polyhedron*                                     605 G4Polyhedron* 
449 G4ReflectedSolid::CreatePolyhedron () const       606 G4ReflectedSolid::CreatePolyhedron () const 
450 {                                                 607 {
451   G4Polyhedron* polyhedron = fPtrSolid->Create    608   G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron();
452   if (polyhedron != nullptr)                   << 609   if (polyhedron)
453   {                                               610   {
454     polyhedron->Transform(*fDirectTransform3D)    611     polyhedron->Transform(*fDirectTransform3D);
455     return polyhedron;                            612     return polyhedron;
456   }                                               613   }
457   else                                            614   else
458   {                                               615   {
459     std::ostringstream message;                   616     std::ostringstream message;
460     message << "Solid - " << GetName()            617     message << "Solid - " << GetName()
461             << " - original solid has no" << G    618             << " - original solid has no" << G4endl
462             << "corresponding polyhedron. Retu    619             << "corresponding polyhedron. Returning NULL!";
463     G4Exception("G4ReflectedSolid::CreatePolyh    620     G4Exception("G4ReflectedSolid::CreatePolyhedron()",
464                 "GeomMgt1001", JustWarning, me    621                 "GeomMgt1001", JustWarning, message);
465     return nullptr;                            << 622     return 0;
466   }                                               623   }
467 }                                                 624 }
468                                                   625 
469 //////////////////////////////////////////////    626 /////////////////////////////////////////////////////////
470 //                                                627 //
471 //                                                628 //
472                                                   629 
473 G4Polyhedron*                                     630 G4Polyhedron*
474 G4ReflectedSolid::GetPolyhedron () const          631 G4ReflectedSolid::GetPolyhedron () const
475 {                                                 632 {
476   if ((fpPolyhedron == nullptr) || fRebuildPol << 633   if (!fpPolyhedron ||
477       (fpPolyhedron->GetNumberOfRotationStepsA << 634       fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
478        fpPolyhedron->GetNumberOfRotationSteps( << 635       fpPolyhedron->GetNumberOfRotationSteps())
479     {                                             636     {
480       fpPolyhedron = CreatePolyhedron();       << 637       delete fpPolyhedron;
481       fRebuildPolyhedron = false;              << 638       fpPolyhedron = CreatePolyhedron ();
482     }                                             639     }
483   return fpPolyhedron;                            640   return fpPolyhedron;
484 }                                                 641 }
485                                                   642