Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/solids/specific/src/G4UTessellatedSolid.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/G4UTessellatedSolid.cc (Version 11.3.0) and /geometry/solids/specific/src/G4UTessellatedSolid.cc (Version 11.0)


  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 G4UTessellatedSolid wrapp     26 // Implementation of G4UTessellatedSolid wrapper class
 27 //                                                 27 //
 28 // 11.01.18 G.Cosmo, CERN                          28 // 11.01.18 G.Cosmo, CERN
 29 // -------------------------------------------     29 // --------------------------------------------------------------------
 30                                                    30 
 31 #include "G4TessellatedSolid.hh"                   31 #include "G4TessellatedSolid.hh"
 32 #include "G4UTessellatedSolid.hh"                  32 #include "G4UTessellatedSolid.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 "G4TriangularFacet.hh"                    36 #include "G4TriangularFacet.hh"
 37 #include "G4QuadrangularFacet.hh"                  37 #include "G4QuadrangularFacet.hh"
 38                                                    38 
 39 #include "G4GeomTools.hh"                          39 #include "G4GeomTools.hh"
 40 #include "G4AffineTransform.hh"                    40 #include "G4AffineTransform.hh"
 41 #include "G4BoundingEnvelope.hh"                   41 #include "G4BoundingEnvelope.hh"
 42                                                    42 
                                                   >>  43 #include "G4PolyhedronArbitrary.hh"
                                                   >>  44 
 43 //////////////////////////////////////////////     45 ////////////////////////////////////////////////////////////////////////
 44 //                                                 46 //
 45 // Constructors                                    47 // Constructors
 46 //                                                 48 //
 47 G4UTessellatedSolid::G4UTessellatedSolid()         49 G4UTessellatedSolid::G4UTessellatedSolid()
 48  : Base_t("")                                      50  : Base_t("")
 49 {                                                  51 {
 50 }                                                  52 }
 51                                                    53 
 52 G4UTessellatedSolid::G4UTessellatedSolid(const     54 G4UTessellatedSolid::G4UTessellatedSolid(const G4String& name)
 53  : Base_t(name)                                    55  : Base_t(name)
 54 {                                                  56 {
 55 }                                                  57 }
 56                                                    58 
 57 //////////////////////////////////////////////     59 ////////////////////////////////////////////////////////////////////////
 58 //                                                 60 //
 59 // Fake default constructor - sets only member     61 // Fake default constructor - sets only member data and allocates memory
 60 //                            for usage restri     62 //                            for usage restricted to object persistency.
 61 //                                                 63 //
 62 G4UTessellatedSolid::G4UTessellatedSolid(__voi     64 G4UTessellatedSolid::G4UTessellatedSolid(__void__& a)
 63   : Base_t(a)                                      65   : Base_t(a)
 64 {                                                  66 {
 65 }                                                  67 }
 66                                                    68 
 67 //////////////////////////////////////////////     69 //////////////////////////////////////////////////////////////////////////
 68 //                                                 70 //
 69 // Destructor                                      71 // Destructor
 70 //                                                 72 //
 71 G4UTessellatedSolid::~G4UTessellatedSolid()        73 G4UTessellatedSolid::~G4UTessellatedSolid()
 72 {                                                  74 {
 73   std::size_t size = fFacets.size();           <<  75   G4int size = fFacets.size();
 74   for (std::size_t i = 0; i < size; ++i)  { de <<  76   for (G4int i = 0; i < size; ++i)  { delete fFacets[i]; }
 75   fFacets.clear();                                 77   fFacets.clear();
 76 }                                                  78 }
 77                                                    79 
 78 //////////////////////////////////////////////     80 //////////////////////////////////////////////////////////////////////////
 79 //                                                 81 //
 80 // Copy constructor                                82 // Copy constructor
 81 //                                                 83 //
 82 G4UTessellatedSolid::G4UTessellatedSolid(const     84 G4UTessellatedSolid::G4UTessellatedSolid(const G4UTessellatedSolid& source)
 83   : Base_t(source)                                 85   : Base_t(source)
 84 {                                                  86 {
 85 }                                                  87 }
 86                                                    88 
 87 //////////////////////////////////////////////     89 //////////////////////////////////////////////////////////////////////////
 88 //                                                 90 //
 89 // Assignment operator                             91 // Assignment operator
 90 //                                                 92 //
 91 G4UTessellatedSolid&                               93 G4UTessellatedSolid&
 92 G4UTessellatedSolid::operator=(const G4UTessel     94 G4UTessellatedSolid::operator=(const G4UTessellatedSolid& source)
 93 {                                                  95 {
 94   if (this == &source) return *this;               96   if (this == &source) return *this;
 95                                                    97   
 96   Base_t::operator=( source );                     98   Base_t::operator=( source );
 97                                                    99   
 98   return *this;                                   100   return *this;
 99 }                                                 101 }
100                                                   102 
101 //////////////////////////////////////////////    103 //////////////////////////////////////////////////////////////////////////
102 //                                                104 //
103 // Accessors                                      105 // Accessors
104                                                   106 
105 G4bool G4UTessellatedSolid::AddFacet(G4VFacet*    107 G4bool G4UTessellatedSolid::AddFacet(G4VFacet* aFacet)
106 {                                                 108 {
107   // Add a facet to the structure, checking va    109   // Add a facet to the structure, checking validity.
108   //                                              110   //
109   if (GetSolidClosed())                           111   if (GetSolidClosed())
110   {                                               112   {
111     G4Exception("G4UTessellatedSolid::AddFacet    113     G4Exception("G4UTessellatedSolid::AddFacet()", "GeomSolids1002",
112                 JustWarning, "Attempt to add f    114                 JustWarning, "Attempt to add facets when solid is closed.");
113     return false;                                 115     return false;
114   }                                               116   }
115   if (!aFacet->IsDefined())                       117   if (!aFacet->IsDefined())
116   {                                               118   {
117     G4Exception("G4UTessellatedSolid::AddFacet    119     G4Exception("G4UTessellatedSolid::AddFacet()", "GeomSolids1002",
118                 JustWarning, "Attempt to add f    120                 JustWarning, "Attempt to add facet not properly defined.");    
119     aFacet->StreamInfo(G4cout);                   121     aFacet->StreamInfo(G4cout);
120     return false;                                 122     return false;
121   }                                               123   }
122   if (aFacet->GetNumberOfVertices() == 3)         124   if (aFacet->GetNumberOfVertices() == 3)
123   {                                               125   {
124     auto a3Facet = dynamic_cast<G4TriangularFa << 126     G4TriangularFacet* a3Facet = dynamic_cast<G4TriangularFacet*>(aFacet);
125     return Base_t::AddTriangularFacet(U3Vector    127     return Base_t::AddTriangularFacet(U3Vector(a3Facet->GetVertex(0).x(),
126                                                   128                                                a3Facet->GetVertex(0).y(),
127                                                   129                                                a3Facet->GetVertex(0).z()),
128                                       U3Vector    130                                       U3Vector(a3Facet->GetVertex(1).x(),
129                                                   131                                                a3Facet->GetVertex(1).y(),
130                                                   132                                                a3Facet->GetVertex(1).z()),
131                                       U3Vector    133                                       U3Vector(a3Facet->GetVertex(2).x(),
132                                                   134                                                a3Facet->GetVertex(2).y(),
133                                                   135                                                a3Facet->GetVertex(2).z()),
134                                       true);      136                                       true);
135   }                                               137   }
136   else if (aFacet->GetNumberOfVertices() == 4)    138   else if (aFacet->GetNumberOfVertices() == 4)
137   {                                               139   {
138     auto a4Facet = dynamic_cast<G4Quadrangular << 140     G4QuadrangularFacet* a4Facet = dynamic_cast<G4QuadrangularFacet*>(aFacet);
139     return Base_t::AddQuadrilateralFacet(U3Vec    141     return Base_t::AddQuadrilateralFacet(U3Vector(a4Facet->GetVertex(0).x(),
140                                                   142                                                   a4Facet->GetVertex(0).y(),
141                                                   143                                                   a4Facet->GetVertex(0).z()),
142                                          U3Vec    144                                          U3Vector(a4Facet->GetVertex(1).x(),
143                                                   145                                                   a4Facet->GetVertex(1).y(),
144                                                   146                                                   a4Facet->GetVertex(1).z()),
145                                          U3Vec    147                                          U3Vector(a4Facet->GetVertex(2).x(),
146                                                   148                                                   a4Facet->GetVertex(2).y(),
147                                                   149                                                   a4Facet->GetVertex(2).z()),
148                                          U3Vec    150                                          U3Vector(a4Facet->GetVertex(3).x(),
149                                                   151                                                   a4Facet->GetVertex(3).y(),
150                                                   152                                                   a4Facet->GetVertex(3).z()),
151                                          true)    153                                          true);
152   }                                               154   }
153   else                                            155   else
154   {                                               156   {
155     G4Exception("G4UTessellatedSolid::AddFacet    157     G4Exception("G4UTessellatedSolid::AddFacet()", "GeomSolids1002",
156                 JustWarning, "Attempt to add f    158                 JustWarning, "Attempt to add facet not properly defined.");    
157     aFacet->StreamInfo(G4cout);                   159     aFacet->StreamInfo(G4cout);
158     return false;                                 160     return false;
159   }                                               161   }
160 }                                                 162 }
161                                                   163 
162 G4VFacet* G4UTessellatedSolid::GetFacet(G4int     164 G4VFacet* G4UTessellatedSolid::GetFacet(G4int i) const
163 {                                                 165 {
164   return fFacets[i];                              166   return fFacets[i];
165 }                                                 167 }
166                                                   168 
167 G4int G4UTessellatedSolid::GetNumberOfFacets()    169 G4int G4UTessellatedSolid::GetNumberOfFacets() const
168 {                                                 170 {
169   return GetNFacets();                            171   return GetNFacets();
170 }                                                 172 }
171                                                   173 
172 void G4UTessellatedSolid::SetSolidClosed(const    174 void G4UTessellatedSolid::SetSolidClosed(const G4bool t)
173 {                                                 175 {
174   if (t && !Base_t::IsClosed())                   176   if (t && !Base_t::IsClosed())
175   {                                               177   {
176     Base_t::Close();                              178     Base_t::Close();
177     std::size_t nVertices = fTessellated.fVert << 179     G4int nVertices = fTessellated.fVertices.size();
178     std::size_t nFacets   = fTessellated.fFace << 180     G4int nFacets   = fTessellated.fFacets.size();
179     for (std::size_t j = 0; j < nVertices; ++j << 181     for (G4int j = 0; j < nVertices; ++j)
180     {                                             182     {
181       U3Vector vt = fTessellated.fVertices[j];    183       U3Vector vt = fTessellated.fVertices[j];
182       fVertexList.emplace_back(vt.x(), vt.y(), << 184       fVertexList.push_back(G4ThreeVector(vt.x(), vt.y(), vt.z()));
183     }                                             185     }
184     for (std::size_t i = 0; i < nFacets; ++i)  << 186     for (G4int i = 0; i < nFacets; ++i)
185     {                                             187     {
186       vecgeom::TriangleFacet<G4double>* afacet    188       vecgeom::TriangleFacet<G4double>* afacet = Base_t::GetFacet(i);
187       std::vector<G4ThreeVector> v;               189       std::vector<G4ThreeVector> v;
188       for (const auto & vertex : afacet->fVert << 190       for (G4int k=0; k<3; ++k)
189       {                                           191       {
190         v.emplace_back(vertex.x(),             << 192         v.push_back(G4ThreeVector(afacet->fVertices[k].x(),
191                                   vertex.y(),  << 193                                   afacet->fVertices[k].y(),
192                                   vertex.z()); << 194                                   afacet->fVertices[k].z()));
193       }                                           195       }
194       G4VFacet* facet = new G4TriangularFacet(    196       G4VFacet* facet = new G4TriangularFacet(v[0], v[1], v[2],
195                                                   197                                               G4FacetVertexType::ABSOLUTE);
196       facet->SetVertices(&fVertexList);           198       facet->SetVertices(&fVertexList);
197       for (G4int k=0; k<3; ++k)                   199       for (G4int k=0; k<3; ++k)
198       {                                           200       {
199         facet->SetVertexIndex(k, afacet->fIndi    201         facet->SetVertexIndex(k, afacet->fIndices[k]);
200       }                                           202       }
201       fFacets.push_back(facet);                   203       fFacets.push_back(facet);
202     }                                             204     }
203   }                                               205   }
204 }                                                 206 }
205                                                   207 
206 G4bool G4UTessellatedSolid::GetSolidClosed() c    208 G4bool G4UTessellatedSolid::GetSolidClosed() const
207 {                                                 209 {
208   return Base_t::IsClosed();                      210   return Base_t::IsClosed();
209 }                                                 211 }
210                                                   212 
211 void G4UTessellatedSolid::SetMaxVoxels(G4int)     213 void G4UTessellatedSolid::SetMaxVoxels(G4int)
212 {                                                 214 {
213   // Not yet implemented !                        215   // Not yet implemented !
214 }                                                 216 }
215                                                   217 
216 G4double G4UTessellatedSolid::GetMinXExtent()     218 G4double G4UTessellatedSolid::GetMinXExtent() const
217 {                                                 219 {
218   U3Vector aMin, aMax;                            220   U3Vector aMin, aMax;
219   Base_t::Extent(aMin, aMax);                     221   Base_t::Extent(aMin, aMax);
220   return aMin.x();                                222   return aMin.x();
221 }                                                 223 }
222 G4double G4UTessellatedSolid::GetMaxXExtent()     224 G4double G4UTessellatedSolid::GetMaxXExtent() const
223 {                                                 225 {
224   U3Vector aMin, aMax;                            226   U3Vector aMin, aMax;
225   Base_t::Extent(aMin, aMax);                     227   Base_t::Extent(aMin, aMax);
226   return aMax.x();                                228   return aMax.x();
227 }                                                 229 }
228 G4double G4UTessellatedSolid::GetMinYExtent()     230 G4double G4UTessellatedSolid::GetMinYExtent() const
229 {                                                 231 {
230   U3Vector aMin, aMax;                            232   U3Vector aMin, aMax;
231   Base_t::Extent(aMin, aMax);                     233   Base_t::Extent(aMin, aMax);
232   return aMin.y();                                234   return aMin.y();
233 }                                                 235 }
234 G4double G4UTessellatedSolid::GetMaxYExtent()     236 G4double G4UTessellatedSolid::GetMaxYExtent() const
235 {                                                 237 {
236   U3Vector aMin, aMax;                            238   U3Vector aMin, aMax;
237   Base_t::Extent(aMin, aMax);                     239   Base_t::Extent(aMin, aMax);
238   return aMax.y();                                240   return aMax.y();
239 }                                                 241 }
240 G4double G4UTessellatedSolid::GetMinZExtent()     242 G4double G4UTessellatedSolid::GetMinZExtent() const
241 {                                                 243 {
242   U3Vector aMin, aMax;                            244   U3Vector aMin, aMax;
243   Base_t::Extent(aMin, aMax);                     245   Base_t::Extent(aMin, aMax);
244   return aMin.z();                                246   return aMin.z();
245 }                                                 247 }
246 G4double G4UTessellatedSolid::GetMaxZExtent()     248 G4double G4UTessellatedSolid::GetMaxZExtent() const
247 {                                                 249 {
248   U3Vector aMin, aMax;                            250   U3Vector aMin, aMax;
249   Base_t::Extent(aMin, aMax);                     251   Base_t::Extent(aMin, aMax);
250   return aMax.z();                                252   return aMax.z();
251 }                                                 253 }
252                                                   254 
253 G4int G4UTessellatedSolid::AllocatedMemoryWith    255 G4int G4UTessellatedSolid::AllocatedMemoryWithoutVoxels()
254 {                                                 256 {
255   G4int base = sizeof(*this);                     257   G4int base = sizeof(*this);
256   base += fVertexList.capacity() * sizeof(G4Th    258   base += fVertexList.capacity() * sizeof(G4ThreeVector);
257                                                   259 
258   std::size_t limit = fFacets.size();          << 260   G4int limit = fFacets.size();
259   for (std::size_t i = 0; i < limit; ++i)      << 261   for (G4int i = 0; i < limit; ++i)
260   {                                               262   {
261     G4VFacet &facet = *fFacets[i];                263     G4VFacet &facet = *fFacets[i];
262     base += facet.AllocatedMemory();              264     base += facet.AllocatedMemory();
263   }                                               265   }
264   return base;                                    266   return base;
265 }                                                 267 }
266 G4int G4UTessellatedSolid::AllocatedMemory()      268 G4int G4UTessellatedSolid::AllocatedMemory()
267 {                                                 269 {
268   return AllocatedMemoryWithoutVoxels();          270   return AllocatedMemoryWithoutVoxels();
269 }                                                 271 }
270 void G4UTessellatedSolid::DisplayAllocatedMemo    272 void G4UTessellatedSolid::DisplayAllocatedMemory()
271 {                                                 273 {
272   G4int without = AllocatedMemoryWithoutVoxels    274   G4int without = AllocatedMemoryWithoutVoxels();
273   //  G4int with = AllocatedMemory();             275   //  G4int with = AllocatedMemory();
274   //  G4double ratio = (G4double) with / witho    276   //  G4double ratio = (G4double) with / without;
275   //  G4cout << "G4TessellatedSolid - Allocate    277   //  G4cout << "G4TessellatedSolid - Allocated memory without voxel overhead "
276   //         << without << "; with " << with <    278   //         << without << "; with " << with << "; ratio: " << ratio << G4endl; 
277   G4cout << "G4TessellatedSolid - Allocated me    279   G4cout << "G4TessellatedSolid - Allocated memory without voxel overhead "
278          << without << G4endl;                    280          << without << G4endl; 
279 }                                                 281 }
280                                                   282 
281                                                   283 
282 //////////////////////////////////////////////    284 ///////////////////////////////////////////////////////////////////////////////
283 //                                                285 //
284 // Get bounding box                               286 // Get bounding box
285                                                   287 
286 void G4UTessellatedSolid::BoundingLimits(G4Thr    288 void G4UTessellatedSolid::BoundingLimits(G4ThreeVector& pMin,
287                                          G4Thr    289                                          G4ThreeVector& pMax) const
288 {                                                 290 {
289   U3Vector aMin, aMax;                            291   U3Vector aMin, aMax;
290   Base_t::Extent(aMin, aMax);                     292   Base_t::Extent(aMin, aMax);
291   pMin = G4ThreeVector(aMin.x(), aMin.y(), aMi    293   pMin = G4ThreeVector(aMin.x(), aMin.y(), aMin.z());
292   pMax = G4ThreeVector(aMax.x(), aMax.y(), aMa    294   pMax = G4ThreeVector(aMax.x(), aMax.y(), aMax.z());
293                                                   295 
294   // Check correctness of the bounding box        296   // Check correctness of the bounding box
295   //                                              297   //
296   if (pMin.x() >= pMax.x() || pMin.y() >= pMax    298   if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
297   {                                               299   {
298     std::ostringstream message;                   300     std::ostringstream message;
299     message << "Bad bounding box (min >= max)     301     message << "Bad bounding box (min >= max) for solid: "
300             << GetName() << " !"                  302             << GetName() << " !"
301             << "\npMin = " << pMin                303             << "\npMin = " << pMin
302             << "\npMax = " << pMax;               304             << "\npMax = " << pMax;
303     G4Exception("G4UTessellatedSolid::Bounding    305     G4Exception("G4UTessellatedSolid::BoundingLimits()",
304                 "GeomMgt0001", JustWarning, me    306                 "GeomMgt0001", JustWarning, message);
305     StreamInfo(G4cout);                           307     StreamInfo(G4cout);
306   }                                               308   }
307 }                                                 309 }
308                                                   310 
309                                                   311 
310 //////////////////////////////////////////////    312 //////////////////////////////////////////////////////////////////////////////
311 //                                                313 //
312 // Calculate extent under transform and specif    314 // Calculate extent under transform and specified limit
313                                                   315 
314 G4bool                                            316 G4bool
315 G4UTessellatedSolid::CalculateExtent(const EAx    317 G4UTessellatedSolid::CalculateExtent(const EAxis pAxis,
316                                      const G4V    318                                      const G4VoxelLimits& pVoxelLimit,
317                                      const G4A    319                                      const G4AffineTransform& pTransform,
318                                            G4d    320                                            G4double& pMin, G4double& pMax) const
319 {                                                 321 {
320   G4ThreeVector bmin, bmax;                       322   G4ThreeVector bmin, bmax;
321                                                   323 
322   // Check bounding box (bbox)                    324   // Check bounding box (bbox)
323   //                                              325   //
324   BoundingLimits(bmin,bmax);                      326   BoundingLimits(bmin,bmax);
325   G4BoundingEnvelope bbox(bmin,bmax);             327   G4BoundingEnvelope bbox(bmin,bmax);
326                                                   328 
327   // Use simple bounding-box to help in the ca    329   // Use simple bounding-box to help in the case of complex meshes
328   //                                              330   //
329   return bbox.CalculateExtent(pAxis,pVoxelLimi    331   return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
330                                                   332 
331 #if 0                                             333 #if 0
332   // Precise extent computation (disabled by d    334   // Precise extent computation (disabled by default for this shape)
333   //                                              335   //
334   G4double kCarToleranceHalf = 0.5*kCarToleran    336   G4double kCarToleranceHalf = 0.5*kCarTolerance;
335   if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVox    337   if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
336   {                                               338   {
337     return (pMin < pMax) ? true : false;          339     return (pMin < pMax) ? true : false;
338   }                                               340   }
339                                                   341 
340   // The extent is calculated as cumulative ex    342   // The extent is calculated as cumulative extent of the pyramids
341   // formed by facets and the center of the bo    343   // formed by facets and the center of the bounding box.
342   //                                              344   //
343   G4double eminlim = pVoxelLimit.GetMinExtent(    345   G4double eminlim = pVoxelLimit.GetMinExtent(pAxis);
344   G4double emaxlim = pVoxelLimit.GetMaxExtent(    346   G4double emaxlim = pVoxelLimit.GetMaxExtent(pAxis);
345                                                   347 
346   G4ThreeVectorList base;                         348   G4ThreeVectorList base;
347   G4ThreeVectorList apex(1);                      349   G4ThreeVectorList apex(1);
348   std::vector<const G4ThreeVectorList *> pyram    350   std::vector<const G4ThreeVectorList *> pyramid(2);
349   pyramid[0] = &base;                             351   pyramid[0] = &base;
350   pyramid[1] = &apex;                             352   pyramid[1] = &apex;
351   apex[0] = (bmin+bmax)*0.5;                      353   apex[0] = (bmin+bmax)*0.5;
352                                                   354 
353   // main loop along facets                       355   // main loop along facets
354   pMin =  kInfinity;                              356   pMin =  kInfinity;
355   pMax = -kInfinity;                              357   pMax = -kInfinity;
356   for (G4int i=0; i<GetNumberOfFacets(); ++i)     358   for (G4int i=0; i<GetNumberOfFacets(); ++i)
357   {                                               359   {
358     G4VFacet* facet = GetFacet(i);                360     G4VFacet* facet = GetFacet(i);
359     if (std::abs((facet->GetSurfaceNormal()).d    361     if (std::abs((facet->GetSurfaceNormal()).dot(facet->GetVertex(0)-apex[0]))
360         < kCarToleranceHalf) continue;            362         < kCarToleranceHalf) continue;
361                                                   363 
362     base.resize(3);                               364     base.resize(3);
363     for (G4int k=0; k<3; ++k) { base[k] = face    365     for (G4int k=0; k<3; ++k) { base[k] = facet->GetVertex(k); }
364     G4double emin,emax;                           366     G4double emin,emax;
365     G4BoundingEnvelope benv(pyramid);             367     G4BoundingEnvelope benv(pyramid);
366     if (!benv.CalculateExtent(pAxis,pVoxelLimi    368     if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax)) continue;
367     if (emin < pMin) pMin = emin;                 369     if (emin < pMin) pMin = emin;
368     if (emax > pMax) pMax = emax;                 370     if (emax > pMax) pMax = emax;
369     if (eminlim > pMin && emaxlim < pMax) brea    371     if (eminlim > pMin && emaxlim < pMax) break; // max possible extent
370   }                                               372   }
371   return (pMin < pMax);                           373   return (pMin < pMax);
372 #endif                                            374 #endif
373 }                                                 375 }
374                                                   376 
375                                                   377 
376 //////////////////////////////////////////////    378 ///////////////////////////////////////////////////////////////////////////////
377 //                                                379 //
378 // CreatePolyhedron()                             380 // CreatePolyhedron()
379 //                                                381 //
380 G4Polyhedron* G4UTessellatedSolid::CreatePolyh    382 G4Polyhedron* G4UTessellatedSolid::CreatePolyhedron () const
381 {                                                 383 {
382   auto nVertices = (G4int)fVertexList.size();  << 384   G4int nVertices = fVertexList.size();
383   auto nFacets = (G4int)fFacets.size();        << 385   G4int nFacets   = fFacets.size();
384   auto polyhedron = new G4Polyhedron(nVertices << 386   G4PolyhedronArbitrary *polyhedron = new G4PolyhedronArbitrary (nVertices,
385   for (auto i = 0; i < nVertices; ++i)         << 387                                                                  nFacets);
                                                   >> 388   for (G4int j = 0; j < nVertices; ++j)
386   {                                               389   {
387     polyhedron->SetVertex(i+1, fVertexList[i]) << 390     polyhedron->AddVertex(fVertexList[j]);
388   }                                               391   }
389                                                   392 
390   for (auto i = 0; i < nFacets; ++i)           << 393   for (G4int i = 0; i < nFacets; ++i)
391   {                                               394   {
392     G4int v[3];  // Only facets with 3 vertice    395     G4int v[3];  // Only facets with 3 vertices are defined in VecGeom
393     G4VFacet* facet = GetFacet(i);                396     G4VFacet* facet = GetFacet(i);
394     for (auto j = 0; j < 3; ++j) // Retrieve i << 397     for (G4int j=0; j<3; ++j)  // Retrieve indexing directly from VecGeom
395     {                                             398     {
396       v[j] = facet->GetVertexIndex(j) + 1;        399       v[j] = facet->GetVertexIndex(j) + 1;
397     }                                             400     }
398     polyhedron->SetFacet(i+1, v[0], v[1], v[2] << 401     polyhedron->AddFacet(v[0],v[1],v[2]);
399   }                                               402   }
400   polyhedron->SetReferences();                    403   polyhedron->SetReferences();  
401                                                   404 
402   return polyhedron;                           << 405   return (G4Polyhedron*) polyhedron;
403 }                                                 406 }
404                                                   407 
405 #endif  // G4GEOM_USE_USOLIDS                     408 #endif  // G4GEOM_USE_USOLIDS
406                                                   409