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


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