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