Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/solids/specific/src/G4UExtrudedSolid.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/solids/specific/src/G4UExtrudedSolid.cc (Version 11.3.0) and /geometry/solids/specific/src/G4UExtrudedSolid.cc (Version 10.7)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 // 
 26 // Implementation of G4UExtrudedSolid wrapper      26 // Implementation of G4UExtrudedSolid wrapper class
 27 //                                                 27 //
 28 // 17.11.17 G.Cosmo, CERN                          28 // 17.11.17 G.Cosmo, CERN
 29 // -------------------------------------------     29 // --------------------------------------------------------------------
 30                                                    30 
 31 #include "G4ExtrudedSolid.hh"                      31 #include "G4ExtrudedSolid.hh"
 32 #include "G4UExtrudedSolid.hh"                     32 #include "G4UExtrudedSolid.hh"
 33                                                    33 
 34 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G     34 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
 35                                                    35 
 36 #include "G4GeomTools.hh"                          36 #include "G4GeomTools.hh"
 37 #include "G4AffineTransform.hh"                    37 #include "G4AffineTransform.hh"
 38 #include "G4BoundingEnvelope.hh"                   38 #include "G4BoundingEnvelope.hh"
 39                                                    39 
                                                   >>  40 #include "G4PolyhedronArbitrary.hh"
                                                   >>  41 
 40 //////////////////////////////////////////////     42 ////////////////////////////////////////////////////////////////////////
 41 //                                                 43 //
 42 // Constructors                                    44 // Constructors
 43 //                                                 45 //
 44 G4UExtrudedSolid::G4UExtrudedSolid(const G4Str     46 G4UExtrudedSolid::G4UExtrudedSolid(const G4String&          name,
 45                                    const std::     47                                    const std::vector<G4TwoVector>& polygon,
 46                                    const std::     48                                    const std::vector<ZSection>&    zsections)
 47   : Base_t(name)  // General constructor           49   : Base_t(name)  // General constructor
 48 {                                                  50 {
 49   unsigned int nVertices = polygon.size();         51   unsigned int nVertices = polygon.size();
 50   unsigned int nSections = zsections.size();       52   unsigned int nSections = zsections.size();
 51                                                    53 
 52   auto vertices = new vecgeom::XtruVertex2[nVe <<  54   vecgeom::XtruVertex2* vertices = new vecgeom::XtruVertex2[nVertices];
 53   auto sections = new vecgeom::XtruSection[nSe <<  55   vecgeom::XtruSection* sections = new vecgeom::XtruSection[nSections];
 54                                                    56 
 55   for (unsigned int i = 0; i < nVertices; ++i)     57   for (unsigned int i = 0; i < nVertices; ++i)
 56   {                                                58   {
 57     vertices[i].x = polygon[i].x();                59     vertices[i].x = polygon[i].x();
 58     vertices[i].y = polygon[i].y();                60     vertices[i].y = polygon[i].y();
 59   }                                                61   }
 60   for (unsigned int i = 0; i < nSections; ++i)     62   for (unsigned int i = 0; i < nSections; ++i)
 61   {                                                63   {
 62     sections[i].fOrigin.Set(zsections[i].fOffs     64     sections[i].fOrigin.Set(zsections[i].fOffset.x(),
 63                             zsections[i].fOffs     65                             zsections[i].fOffset.y(),
 64                             zsections[i].fZ);      66                             zsections[i].fZ);
 65     sections[i].fScale = zsections[i].fScale;      67     sections[i].fScale = zsections[i].fScale;
 66   }                                                68   }
 67   Base_t::Initialize(nVertices, vertices, nSec     69   Base_t::Initialize(nVertices, vertices, nSections, sections);
 68   delete[] vertices;                               70   delete[] vertices;
 69   delete[] sections;                               71   delete[] sections;
 70 }                                                  72 }
 71                                                    73 
 72                                                    74 
 73 G4UExtrudedSolid::G4UExtrudedSolid(const G4Str     75 G4UExtrudedSolid::G4UExtrudedSolid(const G4String&          name,
 74                                    const std::     76                                    const std::vector<G4TwoVector>& polygon,
 75                                    G4double        77                                    G4double                 halfZ,
 76                                    const G4Two     78                                    const G4TwoVector& off1, G4double scale1,
 77                                    const G4Two     79                                    const G4TwoVector& off2, G4double scale2)
 78   : Base_t(name)  // Special constructor for 2     80   : Base_t(name)  // Special constructor for 2 sections
 79 {                                                  81 {
 80   unsigned int nVertices = polygon.size();         82   unsigned int nVertices = polygon.size();
 81   unsigned int nSections = 2;                      83   unsigned int nSections = 2;
 82                                                    84 
 83   auto vertices = new vecgeom::XtruVertex2[nVe <<  85   vecgeom::XtruVertex2* vertices = new vecgeom::XtruVertex2[nVertices];
 84   auto sections = new vecgeom::XtruSection[nSe <<  86   vecgeom::XtruSection* sections = new vecgeom::XtruSection[nSections];
 85                                                    87 
 86   for (unsigned int i = 0; i < nVertices; ++i)     88   for (unsigned int i = 0; i < nVertices; ++i)
 87   {                                                89   {
 88     vertices[i].x = polygon[i].x();                90     vertices[i].x = polygon[i].x();
 89     vertices[i].y = polygon[i].y();                91     vertices[i].y = polygon[i].y();
 90   }                                                92   }
 91   sections[0].fOrigin.Set(off1.x(), off1.y(),      93   sections[0].fOrigin.Set(off1.x(), off1.y(), -halfZ);
 92   sections[0].fScale = scale1;                     94   sections[0].fScale = scale1;
 93   sections[1].fOrigin.Set(off2.x(), off2.y(),      95   sections[1].fOrigin.Set(off2.x(), off2.y(), halfZ);
 94   sections[1].fScale = scale2;                     96   sections[1].fScale = scale2;
 95   Base_t::Initialize(nVertices, vertices, nSec     97   Base_t::Initialize(nVertices, vertices, nSections, sections);
 96   delete[] vertices;                               98   delete[] vertices;
 97   delete[] sections;                               99   delete[] sections;
 98 }                                                 100 }
 99                                                   101 
100 //////////////////////////////////////////////    102 ////////////////////////////////////////////////////////////////////////
101 //                                                103 //
102 // Fake default constructor - sets only member    104 // Fake default constructor - sets only member data and allocates memory
103 //                            for usage restri    105 //                            for usage restricted to object persistency.
104 //                                                106 //
105 G4UExtrudedSolid::G4UExtrudedSolid(__void__& a    107 G4UExtrudedSolid::G4UExtrudedSolid(__void__& a)
106   : Base_t(a)                                     108   : Base_t(a)
107 {                                                 109 {
108 }                                                 110 }
109                                                   111 
110                                                   112 
111 //////////////////////////////////////////////    113 //////////////////////////////////////////////////////////////////////////
112 //                                                114 //
113 // Destructor                                     115 // Destructor
114 //                                                116 //
115 G4UExtrudedSolid::~G4UExtrudedSolid() = defaul << 117 G4UExtrudedSolid::~G4UExtrudedSolid()
                                                   >> 118 {
                                                   >> 119 }
116                                                   120 
117                                                   121 
118 //////////////////////////////////////////////    122 //////////////////////////////////////////////////////////////////////////
119 //                                                123 //
120 // Copy constructor                               124 // Copy constructor
121 //                                                125 //
122 G4UExtrudedSolid::G4UExtrudedSolid(const G4UEx    126 G4UExtrudedSolid::G4UExtrudedSolid(const G4UExtrudedSolid &source)
123   : Base_t(source)                                127   : Base_t(source)
124 {                                                 128 {
125 }                                                 129 }
126                                                   130 
127                                                   131 
128 //////////////////////////////////////////////    132 //////////////////////////////////////////////////////////////////////////
129 //                                                133 //
130 // Assignment operator                            134 // Assignment operator
131 //                                                135 //
132 G4UExtrudedSolid&                                 136 G4UExtrudedSolid&
133 G4UExtrudedSolid::operator=(const G4UExtrudedS    137 G4UExtrudedSolid::operator=(const G4UExtrudedSolid &source)
134 {                                                 138 {
135   if (this == &source) return *this;              139   if (this == &source) return *this;
136                                                   140   
137   Base_t::operator=( source );                    141   Base_t::operator=( source );
138                                                   142   
139   return *this;                                   143   return *this;
140 }                                                 144 }
141                                                   145 
142                                                   146 
143 //////////////////////////////////////////////    147 //////////////////////////////////////////////////////////////////////////
144 //                                                148 //
145 // Accessors                                      149 // Accessors
146                                                   150 
147 G4int G4UExtrudedSolid::GetNofVertices() const    151 G4int G4UExtrudedSolid::GetNofVertices() const
148 {                                                 152 {
149   return Base_t::GetNVertices();                  153   return Base_t::GetNVertices();
150 }                                                 154 }
151                                                << 
152 G4TwoVector G4UExtrudedSolid::GetVertex(G4int     155 G4TwoVector G4UExtrudedSolid::GetVertex(G4int i) const
153 {                                                 156 {
154   G4double xx, yy;                                157   G4double xx, yy;
155   Base_t::GetVertex(i, xx, yy);                   158   Base_t::GetVertex(i, xx, yy);
156   return { xx, yy };                           << 159   return G4TwoVector(xx, yy);
157 }                                                 160 }
158                                                << 
159 std::vector<G4TwoVector> G4UExtrudedSolid::Get    161 std::vector<G4TwoVector> G4UExtrudedSolid::GetPolygon() const
160 {                                                 162 {
161   std::vector<G4TwoVector> pol;                   163   std::vector<G4TwoVector> pol;
162   for (unsigned int i = 0; i < Base_t::GetNVer    164   for (unsigned int i = 0; i < Base_t::GetNVertices(); ++i)
163   {                                               165   {
164     pol.push_back(GetVertex(i));                  166     pol.push_back(GetVertex(i));
165   }                                               167   }
166   return pol;                                     168   return pol;
167 }                                                 169 }
168                                                << 
169 G4int G4UExtrudedSolid::GetNofZSections() cons    170 G4int G4UExtrudedSolid::GetNofZSections() const
170 {                                                 171 {
171   return Base_t::GetNSections();                  172   return Base_t::GetNSections();
172 }                                                 173 }
173                                                << 
174 G4UExtrudedSolid::ZSection G4UExtrudedSolid::G    174 G4UExtrudedSolid::ZSection G4UExtrudedSolid::GetZSection(G4int i) const
175 {                                                 175 {
176   vecgeom::XtruSection sect = Base_t::GetSecti    176   vecgeom::XtruSection sect = Base_t::GetSection(i);
177   return { sect.fOrigin[2],                    << 177   return ZSection(sect.fOrigin[2],
178            G4TwoVector(sect.fOrigin[0], sect.f << 178                   G4TwoVector(sect.fOrigin[0], sect.fOrigin[1]),
179            sect.fScale };                      << 179                   sect.fScale);
180 }                                                 180 }
181                                                << 
182 std::vector<G4UExtrudedSolid::ZSection> G4UExt    181 std::vector<G4UExtrudedSolid::ZSection> G4UExtrudedSolid::GetZSections() const
183 {                                                 182 {
184   std::vector<G4UExtrudedSolid::ZSection> sect    183   std::vector<G4UExtrudedSolid::ZSection> sections;
185   for (unsigned int i = 0; i < Base_t::GetNSec    184   for (unsigned int i = 0; i < Base_t::GetNSections(); ++i)
186   {                                               185   {
187     vecgeom::XtruSection sect = Base_t::GetSec    186     vecgeom::XtruSection sect = Base_t::GetSection(i);
188     sections.emplace_back(sect.fOrigin[2],     << 187     sections.push_back(ZSection(sect.fOrigin[2],
189                           G4TwoVector(sect.fOr << 188                                 G4TwoVector(sect.fOrigin[0], sect.fOrigin[1]),
190                           sect.fScale);        << 189                                 sect.fScale));
191   }                                               190   }
192   return sections;                                191   return sections;
193 }                                                 192 }
194                                                   193 
195                                                   194 
196 //////////////////////////////////////////////    195 ///////////////////////////////////////////////////////////////////////////////
197 //                                                196 //
198 // Get bounding box                               197 // Get bounding box
199                                                   198 
200 void G4UExtrudedSolid::BoundingLimits(G4ThreeV    199 void G4UExtrudedSolid::BoundingLimits(G4ThreeVector& pMin,
201                                       G4ThreeV    200                                       G4ThreeVector& pMax) const
202 {                                                 201 {
203   static G4bool checkBBox = true;                 202   static G4bool checkBBox = true;
204                                                   203 
205   G4double xmin0 = kInfinity, xmax0 = -kInfini    204   G4double xmin0 = kInfinity, xmax0 = -kInfinity;
206   G4double ymin0 = kInfinity, ymax0 = -kInfini    205   G4double ymin0 = kInfinity, ymax0 = -kInfinity;
207                                                   206 
208   for (G4int i=0; i<GetNofVertices(); ++i)        207   for (G4int i=0; i<GetNofVertices(); ++i)
209   {                                               208   {
210     G4TwoVector vertex = GetVertex(i);            209     G4TwoVector vertex = GetVertex(i);
211     G4double x = vertex.x();                      210     G4double x = vertex.x();
212     if (x < xmin0) xmin0 = x;                     211     if (x < xmin0) xmin0 = x;
213     if (x > xmax0) xmax0 = x;                     212     if (x > xmax0) xmax0 = x;
214     G4double y = vertex.y();                      213     G4double y = vertex.y();
215     if (y < ymin0) ymin0 = y;                     214     if (y < ymin0) ymin0 = y;
216     if (y > ymax0) ymax0 = y;                     215     if (y > ymax0) ymax0 = y;
217   }                                               216   }
218                                                   217 
219   G4double xmin = kInfinity, xmax = -kInfinity    218   G4double xmin = kInfinity, xmax = -kInfinity;
220   G4double ymin = kInfinity, ymax = -kInfinity    219   G4double ymin = kInfinity, ymax = -kInfinity;
221                                                   220 
222   G4int nsect = GetNofZSections();                221   G4int nsect = GetNofZSections();
223   for (G4int i=0; i<nsect; ++i)                   222   for (G4int i=0; i<nsect; ++i)
224   {                                               223   {
225     ZSection zsect = GetZSection(i);              224     ZSection zsect = GetZSection(i);
226     G4double dx    = zsect.fOffset.x();           225     G4double dx    = zsect.fOffset.x();
227     G4double dy    = zsect.fOffset.y();           226     G4double dy    = zsect.fOffset.y();
228     G4double scale = zsect.fScale;                227     G4double scale = zsect.fScale;
229     xmin = std::min(xmin,xmin0*scale+dx);         228     xmin = std::min(xmin,xmin0*scale+dx);
230     xmax = std::max(xmax,xmax0*scale+dx);         229     xmax = std::max(xmax,xmax0*scale+dx);
231     ymin = std::min(ymin,ymin0*scale+dy);         230     ymin = std::min(ymin,ymin0*scale+dy);
232     ymax = std::max(ymax,ymax0*scale+dy);         231     ymax = std::max(ymax,ymax0*scale+dy);
233   }                                               232   }
234                                                   233 
235   G4double zmin = GetZSection(0).fZ;              234   G4double zmin = GetZSection(0).fZ;
236   G4double zmax = GetZSection(nsect-1).fZ;        235   G4double zmax = GetZSection(nsect-1).fZ;
237                                                   236 
238   pMin.set(xmin,ymin,zmin);                       237   pMin.set(xmin,ymin,zmin);
239   pMax.set(xmax,ymax,zmax);                       238   pMax.set(xmax,ymax,zmax);
240                                                   239 
241   // Check correctness of the bounding box        240   // Check correctness of the bounding box
242   //                                              241   //
243   if (pMin.x() >= pMax.x() || pMin.y() >= pMax    242   if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
244   {                                               243   {
245     std::ostringstream message;                   244     std::ostringstream message;
246     message << "Bad bounding box (min >= max)     245     message << "Bad bounding box (min >= max) for solid: "
247             << GetName() << " !"                  246             << GetName() << " !"
248             << "\npMin = " << pMin                247             << "\npMin = " << pMin
249             << "\npMax = " << pMax;               248             << "\npMax = " << pMax;
250     G4Exception("G4UExtrudedSolid::BoundingLim    249     G4Exception("G4UExtrudedSolid::BoundingLimits()", "GeomMgt0001",
251                 JustWarning, message);            250                 JustWarning, message);
252     StreamInfo(G4cout);                           251     StreamInfo(G4cout);
253   }                                               252   }
254                                                   253 
255   // Check consistency of bounding boxes          254   // Check consistency of bounding boxes
256   //                                              255   //
257   if (checkBBox)                                  256   if (checkBBox)
258   {                                               257   {
259     U3Vector vmin, vmax;                          258     U3Vector vmin, vmax;
260     Base_t::Extent(vmin,vmax);                    259     Base_t::Extent(vmin,vmax);
261     if (std::abs(pMin.x()-vmin.x()) > kCarTole    260     if (std::abs(pMin.x()-vmin.x()) > kCarTolerance ||
262         std::abs(pMin.y()-vmin.y()) > kCarTole    261         std::abs(pMin.y()-vmin.y()) > kCarTolerance ||
263         std::abs(pMin.z()-vmin.z()) > kCarTole    262         std::abs(pMin.z()-vmin.z()) > kCarTolerance ||
264         std::abs(pMax.x()-vmax.x()) > kCarTole    263         std::abs(pMax.x()-vmax.x()) > kCarTolerance ||
265         std::abs(pMax.y()-vmax.y()) > kCarTole    264         std::abs(pMax.y()-vmax.y()) > kCarTolerance ||
266         std::abs(pMax.z()-vmax.z()) > kCarTole    265         std::abs(pMax.z()-vmax.z()) > kCarTolerance)
267     {                                             266     {
268       std::ostringstream message;                 267       std::ostringstream message;
269       message << "Inconsistency in bounding bo    268       message << "Inconsistency in bounding boxes for solid: "
270               << GetName() << " !"                269               << GetName() << " !"
271               << "\nBBox min: wrapper = " << p    270               << "\nBBox min: wrapper = " << pMin << " solid = " << vmin
272               << "\nBBox max: wrapper = " << p    271               << "\nBBox max: wrapper = " << pMax << " solid = " << vmax;
273       G4Exception("G4UExtrudedSolid::BoundingL    272       G4Exception("G4UExtrudedSolid::BoundingLimits()", "GeomMgt0001",
274                   JustWarning, message);          273                   JustWarning, message);
275       checkBBox = false;                          274       checkBBox = false;
276     }                                             275     }
277   }                                               276   }
278 }                                                 277 }
279                                                   278 
280                                                   279 
281 //////////////////////////////////////////////    280 //////////////////////////////////////////////////////////////////////////////
282 //                                                281 //
283 // Calculate extent under transform and specif    282 // Calculate extent under transform and specified limit
284                                                   283 
285 G4bool                                            284 G4bool
286 G4UExtrudedSolid::CalculateExtent(const EAxis     285 G4UExtrudedSolid::CalculateExtent(const EAxis pAxis,
287                                   const G4Voxe    286                                   const G4VoxelLimits& pVoxelLimit,
288                                   const G4Affi    287                                   const G4AffineTransform& pTransform,
289                                         G4doub    288                                         G4double& pMin, G4double& pMax) const
290 {                                                 289 {
291   G4ThreeVector bmin, bmax;                       290   G4ThreeVector bmin, bmax;
292   G4bool exist;                                   291   G4bool exist;
293                                                   292 
294   // Check bounding box (bbox)                    293   // Check bounding box (bbox)
295   //                                              294   //
296   BoundingLimits(bmin,bmax);                      295   BoundingLimits(bmin,bmax);
297   G4BoundingEnvelope bbox(bmin,bmax);             296   G4BoundingEnvelope bbox(bmin,bmax);
298 #ifdef G4BBOX_EXTENT                              297 #ifdef G4BBOX_EXTENT
299   return bbox.CalculateExtent(pAxis,pVoxelLimi    298   return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
300 #endif                                            299 #endif
301   if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVox    300   if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
302   {                                               301   {
303     return exist = pMin < pMax;                << 302     return exist = (pMin < pMax) ? true : false;
304   }                                               303   }
305                                                   304 
306   // To find the extent, the base polygon is s    305   // To find the extent, the base polygon is subdivided in triangles.
307   // The extent is calculated as cumulative ex    306   // The extent is calculated as cumulative extent of the parts
308   // formed by extrusion of the triangles         307   // formed by extrusion of the triangles
309   //                                              308   //
310   G4TwoVectorList basePolygon = GetPolygon();     309   G4TwoVectorList basePolygon = GetPolygon();
311   G4TwoVectorList triangles;                      310   G4TwoVectorList triangles;
312   G4double eminlim = pVoxelLimit.GetMinExtent(    311   G4double eminlim = pVoxelLimit.GetMinExtent(pAxis);
313   G4double emaxlim = pVoxelLimit.GetMaxExtent(    312   G4double emaxlim = pVoxelLimit.GetMaxExtent(pAxis);
314                                                   313 
315   // triangulate the base polygon                 314   // triangulate the base polygon
316   if (!G4GeomTools::TriangulatePolygon(basePol    315   if (!G4GeomTools::TriangulatePolygon(basePolygon,triangles))
317   {                                               316   {
318     std::ostringstream message;                   317     std::ostringstream message;
319     message << "Triangulation of the base poly    318     message << "Triangulation of the base polygon has failed for solid: "
320             << GetName() << " !"                  319             << GetName() << " !"
321             << "\nExtent has been calculated u    320             << "\nExtent has been calculated using boundary box";
322     G4Exception("G4UExtrudedSolid::CalculateEx    321     G4Exception("G4UExtrudedSolid::CalculateExtent()",
323                 "GeomMgt1002",JustWarning,mess    322                 "GeomMgt1002",JustWarning,message);
324     return bbox.CalculateExtent(pAxis,pVoxelLi    323     return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
325   }                                               324   }
326                                                   325 
327   // allocate vector lists                        326   // allocate vector lists
328   G4int nsect = GetNofZSections();                327   G4int nsect = GetNofZSections();
329   std::vector<const G4ThreeVectorList *> polyg    328   std::vector<const G4ThreeVectorList *> polygons;
330   polygons.resize(nsect);                         329   polygons.resize(nsect);
331   for (G4int k=0; k<nsect; ++k) { polygons[k]     330   for (G4int k=0; k<nsect; ++k) { polygons[k] = new G4ThreeVectorList(3); }
332                                                   331 
333   // main loop along triangles                    332   // main loop along triangles
334   pMin =  kInfinity;                              333   pMin =  kInfinity;
335   pMax = -kInfinity;                              334   pMax = -kInfinity;
336   G4int ntria = triangles.size()/3;               335   G4int ntria = triangles.size()/3;
337   for (G4int i=0; i<ntria; ++i)                   336   for (G4int i=0; i<ntria; ++i)
338   {                                               337   {
339     G4int i3 = i*3;                               338     G4int i3 = i*3;
340     for (G4int k=0; k<nsect; ++k) // extrude t    339     for (G4int k=0; k<nsect; ++k) // extrude triangle
341     {                                             340     {
342       ZSection zsect = GetZSection(k);            341       ZSection zsect = GetZSection(k);
343       G4double z     = zsect.fZ;                  342       G4double z     = zsect.fZ;
344       G4double dx    = zsect.fOffset.x();         343       G4double dx    = zsect.fOffset.x();
345       G4double dy    = zsect.fOffset.y();         344       G4double dy    = zsect.fOffset.y();
346       G4double scale = zsect.fScale;              345       G4double scale = zsect.fScale;
347                                                   346 
348       auto ptr = const_cast<G4ThreeVectorList* << 347       G4ThreeVectorList* ptr = const_cast<G4ThreeVectorList*>(polygons[k]);
349       auto iter = ptr->begin();                << 348       G4ThreeVectorList::iterator iter = ptr->begin();
350       G4double x0 = triangles[i3+0].x()*scale+    349       G4double x0 = triangles[i3+0].x()*scale+dx;
351       G4double y0 = triangles[i3+0].y()*scale+    350       G4double y0 = triangles[i3+0].y()*scale+dy;
352       iter->set(x0,y0,z);                         351       iter->set(x0,y0,z);
353       iter++;                                     352       iter++;
354       G4double x1 = triangles[i3+1].x()*scale+    353       G4double x1 = triangles[i3+1].x()*scale+dx;
355       G4double y1 = triangles[i3+1].y()*scale+    354       G4double y1 = triangles[i3+1].y()*scale+dy;
356       iter->set(x1,y1,z);                         355       iter->set(x1,y1,z);
357       iter++;                                     356       iter++;
358       G4double x2 = triangles[i3+2].x()*scale+    357       G4double x2 = triangles[i3+2].x()*scale+dx;
359       G4double y2 = triangles[i3+2].y()*scale+    358       G4double y2 = triangles[i3+2].y()*scale+dy;
360       iter->set(x2,y2,z);                         359       iter->set(x2,y2,z);
361     }                                             360     }
362                                                   361 
363     // set sub-envelope and adjust extent         362     // set sub-envelope and adjust extent
364     G4double emin,emax;                           363     G4double emin,emax;
365     G4BoundingEnvelope benv(polygons);            364     G4BoundingEnvelope benv(polygons);
366     if (!benv.CalculateExtent(pAxis,pVoxelLimi    365     if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax)) continue;
367     if (emin < pMin) pMin = emin;                 366     if (emin < pMin) pMin = emin;
368     if (emax > pMax) pMax = emax;                 367     if (emax > pMax) pMax = emax;
369     if (eminlim > pMin && emaxlim < pMax) brea    368     if (eminlim > pMin && emaxlim < pMax) break; // max possible extent
370   }                                               369   }
371   // free memory                                  370   // free memory
372   for (G4int k=0; k<nsect; ++k) { delete polyg << 371   for (G4int k=0; k<nsect; ++k) { delete polygons[k]; polygons[k]=0;}
373   return (pMin < pMax);                           372   return (pMin < pMax);
374 }                                                 373 }
375                                                   374 
376                                                   375 
377 //////////////////////////////////////////////    376 ///////////////////////////////////////////////////////////////////////////////
378 //                                                377 //
379 // CreatePolyhedron()                             378 // CreatePolyhedron()
380 //                                                379 //
381 G4Polyhedron* G4UExtrudedSolid::CreatePolyhedr    380 G4Polyhedron* G4UExtrudedSolid::CreatePolyhedron () const
382 {                                                 381 {
383   unsigned int nFacets = Base_t::GetStruct().f    382   unsigned int nFacets = Base_t::GetStruct().fTslHelper.fFacets.size();
384   unsigned int nVertices = Base_t::GetStruct()    383   unsigned int nVertices = Base_t::GetStruct().fTslHelper.fVertices.size();
385                                                   384 
386   auto polyhedron = new G4Polyhedron(nVertices << 385   G4PolyhedronArbitrary* polyhedron =
                                                   >> 386     new G4PolyhedronArbitrary (nVertices, nFacets);
387                                                   387 
388   // Copy vertices                                388   // Copy vertices
389   for (unsigned int i = 0; i < nVertices; ++i)    389   for (unsigned int i = 0; i < nVertices; ++i)
390   {                                               390   {
391     U3Vector v = Base_t::GetStruct().fTslHelpe    391     U3Vector v = Base_t::GetStruct().fTslHelper.fVertices[i];
392     polyhedron->SetVertex(i+1, G4ThreeVector(v << 392     polyhedron->AddVertex(G4ThreeVector(v.x(), v.y(), v.z()));
393   }                                               393   }
394                                                   394 
395   // Copy facets                                  395   // Copy facets
396   for (unsigned int i = 0; i < nFacets; ++i)      396   for (unsigned int i = 0; i < nFacets; ++i)
397   {                                               397   {
398     // Facets are only triangular in VecGeom      398     // Facets are only triangular in VecGeom
399     G4int i1 = Base_t::GetStruct().fTslHelper.    399     G4int i1 = Base_t::GetStruct().fTslHelper.fFacets[i]->fIndices[0] + 1;
400     G4int i2 = Base_t::GetStruct().fTslHelper.    400     G4int i2 = Base_t::GetStruct().fTslHelper.fFacets[i]->fIndices[1] + 1;
401     G4int i3 = Base_t::GetStruct().fTslHelper.    401     G4int i3 = Base_t::GetStruct().fTslHelper.fFacets[i]->fIndices[2] + 1;
402     polyhedron->SetFacet(i+1, i1, i2, i3);     << 402     polyhedron->AddFacet(i1, i2, i3);
403   }                                               403   }
404   polyhedron->SetReferences();                    404   polyhedron->SetReferences();
405                                                   405 
406   return polyhedron;                           << 406   return (G4Polyhedron*) polyhedron;
407 }                                                 407 }
408                                                   408 
409 #endif  // G4GEOM_USE_USOLIDS                     409 #endif  // G4GEOM_USE_USOLIDS
410                                                   410