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.4.p2)


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