Import Geant4 10.5.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2018-06-29 10:58:11 +02:00
parent fe81a77428
commit 6aa23be517
1581 changed files with 124288 additions and 83758 deletions
+10 -5
View File
@@ -1,5 +1,5 @@
$Id: History 110069 2018-05-15 09:32:07Z gcosmo $
$Id: History 110606 2018-06-01 14:48:58Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -20,21 +20,26 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
April 24, 2018 E. Tcherniaev geom-bool-V10-03-05
June 1, 2018 G. Cosmo geom-bool-V10-04-04
- G4MultiUnion: added protection for normal initialisation in
DistanceToOutVoxels(). (M.Gheata)
Minor optimisation in DistanceToOut(p,v,..).
April 24, 2018 E. Tcherniaev geom-bool-V10-04-03
- G4UnionSolid: define simple bounding-box and make use of early returns
in Inside() for points laying outside.
April 11, 2018 E. Tcherniaev
April 11, 2018 E. Tcherniaev geom-bool-V10-04-02
- G4BooleanSolid: Use -1 instead of 0 as default initialisation value
for area and capacity, so to distinguish cases when values are zero
referring to NULL Boolean constructs.
April 11, 2018 G. Cosmo
April 11, 2018 G. Cosmo geom-bool-V10-04-01
- G4BooleanSolid: enhanced warning message for the case of an invalid
(NULL) Boolean construct in GetPointOnSurface() and StackPolyhedron().
- Replaced USOLIDS_LIBRARIES with VECGEOM_LIBRARIES in sources.cmake.
February 28, 2018 E. Tcherniaev
February 28, 2018 E. Tcherniaev geom-bool-V10-04-00
- Improved contruction of G4DiplaceSolid to combine transformations for
nested displaced types.
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4BooleanSolid.icc 110069 2018-05-15 09:32:07Z gcosmo $
// $Id: G4BooleanSolid.icc 109382 2018-04-13 13:01:28Z gcosmo $
//
// --------------------------------------------------------------------
// GEANT 4 inline definitions file
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4UnionSolid.hh 110069 2018-05-15 09:32:07Z gcosmo $
// $Id: G4UnionSolid.hh 109479 2018-04-24 14:33:49Z gcosmo $
//
//
// class G4UnionSolid
+1 -1
View File
@@ -11,7 +11,7 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake 110069 2018-05-15 09:32:07Z gcosmo $
# $Id: sources.cmake 109329 2018-04-11 08:40:52Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4BooleanSolid.cc 110069 2018-05-15 09:32:07Z gcosmo $
// $Id: G4BooleanSolid.cc 109382 2018-04-13 13:01:28Z gcosmo $
//
// Implementation for the abstract base class for solids created by boolean
// operations between other solids
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4DisplacedSolid.cc 110069 2018-05-15 09:32:07Z gcosmo $
// $Id: G4DisplacedSolid.cc 108788 2018-03-07 08:39:32Z gcosmo $
//
// Implementation for G4DisplacedSolid class for boolean
// operations between other solids
@@ -303,9 +303,7 @@ G4double G4MultiUnion::DistanceToOut(const G4ThreeVector& aPoint,
G4bool* /* validNorm */,
G4ThreeVector* aNormal) const
{
G4double distanceToOutVoxels = DistanceToOutVoxels(aPoint, aDirection,
aNormal);
return distanceToOutVoxels;
return DistanceToOutVoxels(aPoint, aDirection, aNormal);
}
//______________________________________________________________________________
@@ -392,7 +390,7 @@ G4double G4MultiUnion::DistanceToOutVoxels(const G4ThreeVector& aPoint,
const G4Transform3D& transform = fTransformObjs[maxCandidate];
// convert from local normal
*aNormal = GetGlobalVector(transform, maxNormal);
if (aNormal) *aNormal = GetGlobalVector(transform, maxNormal);
distance += maxDistance;
currentPoint += maxDistance * direction;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4UnionSolid.cc 110069 2018-05-15 09:32:07Z gcosmo $
// $Id: G4UnionSolid.cc 109479 2018-04-24 14:33:49Z gcosmo $
//
// Implementation of methods for the class G4UnionSolid
//
+8 -4
View File
@@ -1,4 +1,4 @@
$Id: History 110070 2018-05-15 09:40:05Z gcosmo $
$Id: History 109684 2018-05-08 10:37:49Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -17,16 +17,20 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
April 11, 2018 G.Cosmo geom-csg-V10-03-40
May 7, 2018 G.Cosmo geom-csg-V10-04-03
- Make G4UCons wrapper inheriting from vecgeom::GenericUnplacedCone,
following the latest changes in VecGeom.
April 11, 2018 G.Cosmo geom-csg-V10-04-02
- G4Box: simplified and optimised calculation of normal in method
DistanceToOut(p,v,..). (E.Tcherniaev)
- Replaced USOLIDS_LIBRARIES with VECGEOM_LIBRARIES in sources.cmake.
February 5, 2018 G.Cosmo geom-csg-V10-03-39
February 5, 2018 G.Cosmo geom-csg-V10-04-01
- Correction in G4UPara::ComputeDimensions() to add explicit cast for the
solid type to parameterise.
December 11, 2017 E.Tcherniaev
December 11, 2017 E.Tcherniaev geom-csg-V10-04-00
- Fixed typo in G4Trd::GetPointOnSurface() for the area settings.
November 22, 2017 G.Cosmo geom-csg-V10-03-38
@@ -51,10 +51,10 @@
#include "G4Polyhedron.hh"
class G4UCons : public G4UAdapter<vecgeom::UnplacedCone>
class G4UCons : public G4UAdapter<vecgeom::GenericUnplacedCone>
{
using Shape_t = vecgeom::UnplacedCone;
using Base_t = G4UAdapter<vecgeom::UnplacedCone>;
using Shape_t = vecgeom::GenericUnplacedCone;
using Base_t = G4UAdapter<vecgeom::GenericUnplacedCone>;
public: // with description
+1 -1
View File
@@ -11,7 +11,7 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake 110070 2018-05-15 09:40:05Z gcosmo $
# $Id: sources.cmake 109330 2018-04-11 08:42:02Z gcosmo $
#
#------------------------------------------------------------------------------
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Box.cc 110070 2018-05-15 09:40:05Z gcosmo $
// $Id: G4Box.cc 109330 2018-04-11 08:42:02Z gcosmo $
//
//
//
+1 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Trd.cc 108482 2018-02-15 14:34:23Z gcosmo $
// $Id: G4Trd.cc 107895 2017-12-11 07:33:57Z gcosmo $
//
//
// Implementation for G4Trd class
+35 -7
View File
@@ -1,4 +1,4 @@
$Id: History 110072 2018-05-15 09:59:42Z gcosmo $
$Id: History 110899 2018-06-25 08:39:48Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -10,25 +10,53 @@ $Id: History 110072 2018-05-15 09:59:42Z gcosmo $
This file should be used by G4 developers and category coordinators
to briefly summarize all major modifications introduced in the code
and keep track of all directory-tags.
It DOES NOT substitute the CVS log-message one should put at every
committal in the CVS repository !
It DOES NOT substitute the log-message one should put at every
committal in the source repository !
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
11-April-2018 G.Cosmo (geom-specific-V10-03-27)
25-Jun-2018 G.Cosmo (geom-specific-V10-04-10)
- Use dynamic_cast to attempt fix for spurious compilation warnings on
CentOS7/gcc-5.3 on G4UTessellatedSolid wrapper.
17-May-2018 J.Madsen (geom-specific-V10-04-09)
- Updated "thread-local-static-var" model to
"function-returning-thread-local-static-reference" model
which fixes Windows DLL + MT
11-April-2018 G.Cosmo (geom-specific-V10-04-08)
- Replaced USOLIDS_LIBRARIES with VECGEOM_LIBRARIES in sources.cmake.
13-February-2018 G.Cosmo
13-February-2018 E.Tcherniaev (geom-specific-V10-04-07)
- Corrected conversion of input parameters to internal structure (used for
caching for adoption in GDML persistency) in G4UPolycone and G4UPolyhedra
wrappers.
13-December-2017 E.Tcherniaev (geom-specific-V10-03-26)
9-February-2018 G.Cosmo (geom-specific-V10-04-06)
- Caching facets and vertices in G4UTessellatedSolid wrapper for properly
treating indexing in facets.
31-January-2018 G.Cosmo (geom-specific-V10-04-05)
- Corrected use of facets indeces in G4UTessellatedSolid for visualization.
- Minor cleanup in G4TessellatedSolid::CreatePolyhedron(), no functional
changes.
15-January-2018 G.Cosmo (geom-specific-V10-04-04)
- Added validity checks in G4UTessellatedSolid::AddFacet().
11-January-2018 G.Cosmo (geom-specific-V10-04-03)
- Added and enabled VecGeom wrapper for G4TessellatedSolid.
Requires tags cmake-V10-04-01 and config-V10-04-00.
20-December-2017 G.Cosmo (geom-specific-V10-04-02)
- Enabled VecGeom wrappers for G4ExtrudedSolid and G4Hype.
13-December-2017 E.Tcherniaev (geom-specific-V10-04-01)
- Removed redundant data initialistion in G4ExtrudedSolid constructors.
11-December-2017 E.Tcherniaev
11-December-2017 E.Tcherniaev (geom-specific-V10-04-00)
- Added missing initialisation of two data-members in copy-ctor and
assignment operator of G4ExtrudedSolid. Addressing problem report #2016.
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ExtrudedSolid.hh 107099 2017-11-02 11:40:23Z gcosmo $
// $Id: G4ExtrudedSolid.hh 108078 2017-12-20 08:15:44Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -62,7 +62,7 @@
#ifndef G4ExtrudedSolid_HH
#define G4ExtrudedSolid_HH
/*
#if defined(G4GEOM_USE_USOLIDS)
#define G4GEOM_USE_UEXTRUDEDSOLID 1
#endif
@@ -71,7 +71,7 @@
#define G4UExtrudedSolid G4ExtrudedSolid
#include "G4UExtrudedSolid.hh"
#else
*/
#include <vector>
#include "G4TwoVector.hh"
@@ -215,6 +215,6 @@ class G4ExtrudedSolid : public G4TessellatedSolid
#include "G4ExtrudedSolid.icc"
//#endif
#endif
#endif
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Hype.hh 106627 2017-10-17 06:23:58Z gcosmo $
// $Id: G4Hype.hh 108078 2017-12-20 08:15:44Z gcosmo $
// $Original: G4Hype.hh,v 1.0 1998/06/09 16:57:50 safai Exp $
//
//
@@ -56,7 +56,7 @@
// --------------------------------------------------------------------
#ifndef G4HYPE_HH
#define G4HYPE_HH
/*
#if defined(G4GEOM_USE_USOLIDS)
#define G4GEOM_USE_UHYPE 1
#endif
@@ -65,7 +65,7 @@
#define G4UHype G4Hype
#include "G4UHype.hh"
#else
*/
#include "G4VSolid.hh"
#include "G4ThreeVector.hh"
#include "G4Polyhedron.hh"
@@ -208,6 +208,6 @@ class G4Hype : public G4VSolid
#include "G4Hype.icc"
//#endif // defined(G4GEOM_USE_UHYPE) && defined(G4GEOM_USE_SYS_USOLIDS)
#endif // defined(G4GEOM_USE_UHYPE) && defined(G4GEOM_USE_SYS_USOLIDS)
#endif // G4HYPE_HH
@@ -50,7 +50,7 @@ class G4SolidsWorkspacePool
// Reuse an existing workspace - or create a new one if needed.
// This will never fail, except if system is out of resources
inline G4SolidsWorkspace* GetWorkspace() { return fMyWorkspace; }
inline G4SolidsWorkspace* GetWorkspace() { return fMyWorkspace(); }
// Give back the existing, active workspace for my thread / task
void Recycle( G4SolidsWorkspace * );
@@ -71,7 +71,7 @@ class G4SolidsWorkspacePool
private:
static G4SolidsWorkspacePool* thePool;
G4GEOM_DLL static G4ThreadLocal G4SolidsWorkspace* fMyWorkspace;
G4GEOM_DLL static G4SolidsWorkspace*& fMyWorkspace();
// The thread's workspace - if assigned.
};
@@ -24,7 +24,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TessellatedSolid.hh 104316 2017-05-24 13:04:23Z gcosmo $
// $Id: G4TessellatedSolid.hh 108151 2018-01-12 09:29:46Z gcosmo $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
@@ -99,6 +99,15 @@
#ifndef G4TessellatedSolid_hh
#define G4TessellatedSolid_hh 1
#if defined(G4GEOM_USE_USOLIDS)
#define G4GEOM_USE_UTESSELLATEDSOLID 1
#endif
#if defined(G4GEOM_USE_UTESSELLATEDSOLID)
#define G4UTessellatedSolid G4TessellatedSolid
#include "G4UTessellatedSolid.hh"
#else
#include <iostream>
#include <vector>
#include <set>
@@ -327,3 +336,5 @@ inline G4bool G4TessellatedSolid::OutsideOfExtent(const G4ThreeVector &p,
}
#endif
#endif
@@ -35,33 +35,34 @@
//
// Class description:
//
// Wrapper class for G4UExtrudedSolid to make use of it from USolids module.
// Wrapper class for G4ExtrudedSolid to make use of VecGeom ExtrudedSolid.
// History:
// 30.10.13 G.Cosmo, CERN/PH
// 17.11.17 G.Cosmo, CERN
// --------------------------------------------------------------------
#ifndef G4UEXTRUDEDSOLID_hh
#define G4UEXTRUDEDSOLID_hh
#include "G4USolid.hh"
#include "G4UAdapter.hh"
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UExtrudedSolid.hh"
#include <volumes/UnplacedExtruded.h>
#include "G4TwoVector.hh"
#include "G4Polyhedron.hh"
class G4UExtrudedSolid : public G4USolid
class G4UExtrudedSolid : public G4UAdapter<vecgeom::UnplacedExtruded>
{
using Shape_t = vecgeom::UnplacedExtruded;
using Base_t = G4UAdapter<vecgeom::UnplacedExtruded>;
public: // without description
struct ZSection
{
ZSection(G4double z, G4TwoVector offset, G4double scale)
: fZ(z), fOffset(offset), fScale(scale) {}
ZSection(const UExtrudedSolid::ZSection& zs)
: fZ(zs.fZ), fOffset(G4TwoVector(zs.fOffset.x,zs.fOffset.y)),
fScale(zs.fScale) {}
G4double fZ;
G4TwoVector fOffset;
@@ -71,21 +72,19 @@ class G4UExtrudedSolid : public G4USolid
public: // with description
G4UExtrudedSolid(const G4String& pName,
std::vector<G4TwoVector> polygon,
std::vector<ZSection> zsections);
std::vector<G4TwoVector> polygon,
std::vector<ZSection> zsections);
// General constructor
G4UExtrudedSolid(const G4String& pName,
std::vector<G4TwoVector> polygon,
G4double halfZ,
G4TwoVector off1, G4double scale1,
G4TwoVector off2, G4double scale2);
std::vector<G4TwoVector> polygon,
G4double halfZ,
G4TwoVector off1, G4double scale1,
G4TwoVector off2, G4double scale2);
// Special constructor for solid with 2 z-sections
~G4UExtrudedSolid();
inline UExtrudedSolid* GetShape() const;
G4int GetNofVertices() const;
G4TwoVector GetVertex(G4int index) const;
std::vector<G4TwoVector> GetPolygon() const;
@@ -119,11 +118,6 @@ class G4UExtrudedSolid : public G4USolid
// Inline methods
// --------------------------------------------------------------------
inline UExtrudedSolid* G4UExtrudedSolid::GetShape() const
{
return (UExtrudedSolid*) fShape;
}
inline G4GeometryType G4UExtrudedSolid::GetEntityType() const
{
return "G4ExtrudedSolid";
@@ -0,0 +1,125 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4UTesselladedSolid
//
// Class description:
//
// Wrapper class for G4TessellatedSolid to make use of VecGeom TessellatedSolid.
// History:
// 11.01.18 G.Cosmo, CERN
// --------------------------------------------------------------------
#ifndef G4UTESSELLATEDSOLID_hh
#define G4UTESSELLATEDSOLID_hh
#include "G4UAdapter.hh"
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include <volumes/UnplacedTessellated.h>
#include "G4Polyhedron.hh"
class G4VFacet;
class G4UTessellatedSolid : public G4UAdapter<vecgeom::UnplacedTessellated>
{
using Shape_t = vecgeom::UnplacedTessellated;
using Base_t = G4UAdapter<vecgeom::UnplacedTessellated>;
public: // with description
G4UTessellatedSolid();
G4UTessellatedSolid(const G4String& pName);
~G4UTessellatedSolid();
G4bool AddFacet(G4VFacet* aFacet);
G4VFacet* GetFacet(G4int i) const;
G4int GetNumberOfFacets() const;
inline G4GeometryType GetEntityType() const;
void SetSolidClosed(const G4bool t);
G4bool GetSolidClosed() const;
void SetMaxVoxels(G4int);
G4double GetMinXExtent() const;
G4double GetMaxXExtent() const;
G4double GetMinYExtent() const;
G4double GetMaxYExtent() const;
G4double GetMinZExtent() const;
G4double GetMaxZExtent() const;
G4int AllocatedMemoryWithoutVoxels();
G4int AllocatedMemory();
void DisplayAllocatedMemory();
public: // without description
G4UTessellatedSolid(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4UTessellatedSolid( const G4UTessellatedSolid& source );
G4UTessellatedSolid &operator=(const G4UTessellatedSolid& source);
// Copy constructor and assignment operator.
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const;
G4Polyhedron* CreatePolyhedron() const;
private:
std::vector<G4VFacet *> fFacets;
std::vector<G4ThreeVector> fVertexList;
};
// --------------------------------------------------------------------
// Inline methods
// --------------------------------------------------------------------
inline G4GeometryType G4UTessellatedSolid::GetEntityType() const
{
return "G4TessellatedSolid";
}
#endif // G4GEOM_USE_USOLIDS
#endif
@@ -11,7 +11,7 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake 110072 2018-05-15 09:59:42Z gcosmo $
# $Id: sources.cmake 109328 2018-04-11 08:40:09Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -95,6 +95,7 @@ GEANT4_DEFINE_MODULE(NAME G4specsolids
G4UPolycone.hh
G4UPolyhedra.hh
G4UHype.hh
G4UTessellatedSolid.hh
G4UTet.hh
G4VCSGface.hh
G4VCSGfaceted.hh
@@ -151,6 +152,7 @@ GEANT4_DEFINE_MODULE(NAME G4specsolids
G4UParaboloid.cc
G4UPolycone.cc
G4UPolyhedra.cc
G4UTessellatedSolid.cc
G4UTet.cc
G4VCSGfaceted.cc
G4VFacet.cc
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ExtrudedSolid.cc 108484 2018-02-15 14:38:03Z gcosmo $
// $Id: G4ExtrudedSolid.cc 108078 2017-12-20 08:15:44Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -50,7 +50,7 @@
#include "G4ExtrudedSolid.hh"
//#if !defined(G4GEOM_USE_UEXTRUDEDSOLID)
#if !defined(G4GEOM_USE_UEXTRUDEDSOLID)
#include <set>
#include <algorithm>
@@ -1564,4 +1564,4 @@ std::ostream& G4ExtrudedSolid::StreamInfo(std::ostream &os) const
return os;
}
//#endif
#endif
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Hype.cc 106627 2017-10-17 06:23:58Z gcosmo $
// $Id: G4Hype.cc 108078 2017-12-20 08:15:44Z gcosmo $
// $Original: G4Hype.cc,v 1.0 1998/06/09 16:57:50 safai Exp $
//
//
@@ -45,7 +45,7 @@
#include "G4Hype.hh"
//#if !(defined(G4GEOM_USE_UHYPE) && defined(G4GEOM_USE_SYS_USOLIDS))
#if !(defined(G4GEOM_USE_UHYPE) && defined(G4GEOM_USE_SYS_USOLIDS))
#include "G4VoxelLimits.hh"
#include "G4AffineTransform.hh"
@@ -1341,4 +1341,4 @@ G4double G4Hype::asinh(G4double arg)
return std::log(arg+std::sqrt(sqr(arg)+1));
}
//#endif // !defined(G4GEOM_USE_UHYPE) || !defined(G4GEOM_USE_SYS_USOLIDS)
#endif // !defined(G4GEOM_USE_UHYPE) || !defined(G4GEOM_USE_SYS_USOLIDS)
@@ -36,7 +36,11 @@ namespace
G4Mutex singletonMutexSWP = G4MUTEX_INITIALIZER;
}
G4ThreadLocal G4SolidsWorkspace* G4SolidsWorkspacePool::fMyWorkspace=0;
G4SolidsWorkspace*& G4SolidsWorkspacePool::fMyWorkspace()
{
G4ThreadLocalStatic G4SolidsWorkspace* _instance = nullptr;
return _instance;
}
G4SolidsWorkspacePool* G4SolidsWorkspacePool::thePool=0;
G4SolidsWorkspacePool* G4SolidsWorkspacePool::GetInstance()
@@ -51,7 +55,7 @@ G4SolidsWorkspacePool* G4SolidsWorkspacePool::GetInstance()
G4SolidsWorkspace* G4SolidsWorkspacePool::CreateWorkspace()
{
G4SolidsWorkspace* geometryWrk=0;
if( !fMyWorkspace )
if( !fMyWorkspace() )
{
geometryWrk= new G4SolidsWorkspace();
@@ -63,7 +67,7 @@ G4SolidsWorkspace* G4SolidsWorkspacePool::CreateWorkspace()
else
{
// geometryWrk->UseWorkspace(); // Do not assign it already.
fMyWorkspace= geometryWrk;
fMyWorkspace()= geometryWrk;
}
}
else
@@ -71,7 +75,7 @@ G4SolidsWorkspace* G4SolidsWorkspacePool::CreateWorkspace()
G4Exception("GeometryWorspacePool::CreateWorkspace", "Geom-003",
FatalException,
"Cannot create workspace twice for the same thread.");
geometryWrk= fMyWorkspace;
geometryWrk= fMyWorkspace();
}
return geometryWrk;
@@ -88,14 +92,14 @@ void G4SolidsWorkspacePool::CreateAndUseWorkspace()
//
G4SolidsWorkspace* G4SolidsWorkspacePool::FindOrCreateWorkspace()
{
G4SolidsWorkspace* geometryWrk= fMyWorkspace;
G4SolidsWorkspace* geometryWrk= fMyWorkspace();
if( !geometryWrk )
{
geometryWrk= this->CreateWorkspace();
}
geometryWrk->UseWorkspace();
fMyWorkspace= geometryWrk; // assign it for use by this thread.
fMyWorkspace()= geometryWrk; // assign it for use by this thread.
return geometryWrk;
}
@@ -111,11 +115,11 @@ void G4SolidsWorkspacePool::Recycle( G4SolidsWorkspace *geometryWrk )
void G4SolidsWorkspacePool::CleanUpAndDestroyAllWorkspaces()
{
if (fMyWorkspace)
if (fMyWorkspace())
{
fMyWorkspace->DestroyWorkspace();
delete fMyWorkspace;
fMyWorkspace=0;
fMyWorkspace()->DestroyWorkspace();
delete fMyWorkspace();
fMyWorkspace()=0;
}
}
@@ -24,7 +24,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TessellatedSolid.cc 106710 2017-10-20 09:22:51Z gcosmo $
// $Id: G4TessellatedSolid.cc 108288 2018-01-31 09:36:41Z gcosmo $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
@@ -72,6 +72,10 @@
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#include "G4TessellatedSolid.hh"
#if !defined(G4GEOM_USE_UTESSELLATEDSOLID)
#include <iostream>
#include <stack>
#include <iostream>
@@ -80,8 +84,6 @@
#include <algorithm>
#include <list>
#include "G4TessellatedSolid.hh"
#include "geomdefs.hh"
#include "Randomize.hh"
#include "G4SystemOfUnits.hh"
@@ -1785,14 +1787,14 @@ G4Polyhedron *G4TessellatedSolid::CreatePolyhedron () const
G4int size = fFacets.size();
for (G4int i = 0; i < size; ++i)
{
G4VFacet &facet = *fFacets[i];
G4VFacet* facet = fFacets[i];
G4int v[4];
G4int n = facet.GetNumberOfVertices();
G4int n = facet->GetNumberOfVertices();
if (n > 4) n = 4;
else if (n == 3) v[3] = 0;
for (G4int j=0; j<n; ++j)
{
G4int k = facet.GetVertexIndex(j);
G4int k = facet->GetVertexIndex(j);
v[j] = k+1;
}
polyhedron->AddFacet(v[0],v[1],v[2],v[3]);
@@ -2098,3 +2100,5 @@ G4int G4TessellatedSolid::AllocatedMemory()
size += sizeInsides + sizeVoxels;
return size;
}
#endif
@@ -31,7 +31,6 @@
// --------------------------------------------------------------------
#include "G4ExtrudedSolid.hh"
#if 0
#include "G4UExtrudedSolid.hh"
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
@@ -49,22 +48,29 @@
G4UExtrudedSolid::G4UExtrudedSolid(const G4String& name,
std::vector<G4TwoVector> polygon,
std::vector<ZSection> zsections)
: G4USolid(name, new UExtrudedSolid())
: Base_t(name) // General constructor
{
GetShape()->SetName(name);
std::vector<UVector2> pvec;
for (unsigned int i=0; i<polygon.size(); ++i)
unsigned int nVertices = polygon.size();
unsigned int nSections = zsections.size();
vecgeom::XtruVertex2* vertices = new vecgeom::XtruVertex2[nVertices];
vecgeom::XtruSection* sections = new vecgeom::XtruSection[nSections];
for (unsigned int i = 0; i < nVertices; ++i)
{
pvec.push_back(UVector2(polygon[i].x(), polygon[i].y()));
vertices[i].x = polygon[i].x();
vertices[i].y = polygon[i].y();
}
std::vector<UExtrudedSolid::ZSection> svec;
for (unsigned int i=0; i<zsections.size(); ++i)
for (unsigned int i = 0; i < nSections; ++i)
{
ZSection sec = zsections[i];
svec.push_back(UExtrudedSolid::ZSection(sec.fZ,
UVector2(sec.fOffset.x(), sec.fOffset.y()), sec.fScale));
sections[i].fOrigin.Set(zsections[i].fOffset.x(),
zsections[i].fOffset.y(),
zsections[i].fZ);
sections[i].fScale = zsections[i].fScale;
}
GetShape()->Initialise(pvec, svec);
Base_t::Initialize(nVertices, vertices, nSections, sections);
delete[] vertices;
delete[] sections;
}
@@ -73,16 +79,26 @@ G4UExtrudedSolid::G4UExtrudedSolid(const G4String& name,
G4double halfZ,
G4TwoVector off1, G4double scale1,
G4TwoVector off2, G4double scale2)
: G4USolid(name, new UExtrudedSolid())
{
GetShape()->SetName(name);
std::vector<UVector2> pvec;
for (unsigned int i=0; i<polygon.size(); ++i)
: Base_t(name) // Special constructor for 2 sections
{
unsigned int nVertices = polygon.size();
unsigned int nSections = 2;
vecgeom::XtruVertex2* vertices = new vecgeom::XtruVertex2[nVertices];
vecgeom::XtruSection* sections = new vecgeom::XtruSection[nSections];
for (unsigned int i = 0; i < nVertices; ++i)
{
pvec.push_back(UVector2(polygon[i].x(), polygon[i].y()));
vertices[i].x = polygon[i].x();
vertices[i].y = polygon[i].y();
}
GetShape()->Initialise(pvec, halfZ, UVector2(off1.x(), off1.y()), scale1,
UVector2(off2.x(), off2.y()), scale2);
sections[0].fOrigin.Set(off1.x(), off1.y(), -halfZ);
sections[0].fScale = scale1;
sections[1].fOrigin.Set(off2.x(), off2.y(), halfZ);
sections[1].fScale = scale2;
Base_t::Initialize(nVertices, vertices, nSections, sections);
delete[] vertices;
delete[] sections;
}
////////////////////////////////////////////////////////////////////////
@@ -91,7 +107,7 @@ G4UExtrudedSolid::G4UExtrudedSolid(const G4String& name,
// for usage restricted to object persistency.
//
G4UExtrudedSolid::G4UExtrudedSolid(__void__& a)
: G4USolid(a)
: Base_t(a)
{
}
@@ -110,7 +126,7 @@ G4UExtrudedSolid::~G4UExtrudedSolid()
// Copy constructor
//
G4UExtrudedSolid::G4UExtrudedSolid(const G4UExtrudedSolid &source)
: G4USolid(source)
: Base_t(source)
{
}
@@ -124,7 +140,7 @@ G4UExtrudedSolid::operator=(const G4UExtrudedSolid &source)
{
if (this == &source) return *this;
G4USolid::operator=( source );
Base_t::operator=( source );
return *this;
}
@@ -136,40 +152,45 @@ G4UExtrudedSolid::operator=(const G4UExtrudedSolid &source)
G4int G4UExtrudedSolid::GetNofVertices() const
{
return GetShape()->GetNofVertices();
return Base_t::GetNVertices();
}
G4TwoVector G4UExtrudedSolid::GetVertex(G4int i) const
{
UVector2 v = GetShape()->GetVertex(i);
return G4TwoVector(v.x, v.y);
G4double xx, yy;
Base_t::GetVertex(i, xx, yy);
return G4TwoVector(xx, yy);
}
std::vector<G4TwoVector> G4UExtrudedSolid::GetPolygon() const
{
std::vector<UVector2> pol = GetShape()->GetPolygon();
std::vector<G4TwoVector> v;
for (unsigned int i=0; i<pol.size(); ++i)
std::vector<G4TwoVector> pol;
for (unsigned int i = 0; i < Base_t::GetNVertices(); ++i)
{
v.push_back(G4TwoVector(pol[i].x, pol[i].y));
pol.push_back(GetVertex(i));
}
return v;
return pol;
}
G4int G4UExtrudedSolid::GetNofZSections() const
{
return GetShape()->GetNofZSections();
return Base_t::GetNSections();
}
G4UExtrudedSolid::ZSection G4UExtrudedSolid::GetZSection(G4int i) const
{
return ZSection(GetShape()->GetZSection(i));
vecgeom::XtruSection sect = Base_t::GetSection(i);
return ZSection(sect.fOrigin[2],
G4TwoVector(sect.fOrigin[0], sect.fOrigin[1]),
sect.fScale);
}
std::vector<G4UExtrudedSolid::ZSection> G4UExtrudedSolid::GetZSections() const
{
std::vector<UExtrudedSolid::ZSection> sv = GetShape()->GetZSections();
std::vector<G4UExtrudedSolid::ZSection> vec;
for (unsigned int i=0; i<sv.size(); ++i)
std::vector<G4UExtrudedSolid::ZSection> sections;
for (unsigned int i = 0; i < Base_t::GetNSections(); ++i)
{
vec.push_back(ZSection(sv[i]));
vecgeom::XtruSection sect = Base_t::GetSection(i);
sections.push_back(ZSection(sect.fOrigin[2],
G4TwoVector(sect.fOrigin[0], sect.fOrigin[1]),
sect.fScale));
}
return vec;
return sections;
}
@@ -237,7 +258,7 @@ void G4UExtrudedSolid::BoundingLimits(G4ThreeVector& pMin,
if (checkBBox)
{
UVector3 vmin, vmax;
GetShape()->Extent(vmin,vmax);
Base_t::Extent(vmin,vmax);
if (std::abs(pMin.x()-vmin.x()) > kCarTolerance ||
std::abs(pMin.y()-vmin.y()) > kCarTolerance ||
std::abs(pMin.z()-vmin.z()) > kCarTolerance ||
@@ -360,36 +381,22 @@ G4UExtrudedSolid::CalculateExtent(const EAxis pAxis,
//
G4Polyhedron* G4UExtrudedSolid::CreatePolyhedron () const
{
G4int nFacets = GetShape()->GetNumberOfFacets();
G4int nVertices = 0;
for (G4int l = 0; l<nFacets; ++l) // compute total number of vertices first
{
VUFacet* facet = GetShape()->GetFacet(l);
G4int n = facet->GetNumberOfVertices();
nVertices += n;
}
unsigned int nFacets = Base_t::GetStruct().fTslHelper.fFacets.size();
unsigned int fVertices = 3*nFacets;
G4PolyhedronArbitrary *polyhedron =
new G4PolyhedronArbitrary (nVertices,nFacets);
new G4PolyhedronArbitrary (fVertices,nFacets);
for (G4int i = 0; i<nFacets; ++i)
for (unsigned int i = 0; i < nFacets; ++i)
{
VUFacet* facet = GetShape()->GetFacet(i);
G4int v[4];
G4int n = facet->GetNumberOfVertices();
for (G4int m = 0; m<n; ++m)
G4int v[3]; // Facets are only triangular in VecGeom
for (unsigned int j = 0; j < 3; ++j)
{
UVector3 vtx = facet->GetVertex(m);
UVector3 vtx = Base_t::GetStruct().fTslHelper.fFacets[i]->fVertices[j];
polyhedron->AddVertex(G4ThreeVector(vtx.x(), vtx.y(), vtx.z()));
v[j] = Base_t::GetStruct().fTslHelper.fFacets[i]->fIndices[j]+1;
}
if (n > 4) n = 4;
else if (n == 3) v[3] = 0;
for (G4int j=0; j<n; ++j)
{
G4int k = facet->GetVertexIndex(j);
v[j] = k+1;
}
polyhedron->AddFacet(v[0],v[1],v[2],v[3]);
polyhedron->AddFacet(v[0],v[1],v[2],0);
}
polyhedron->SetReferences();
@@ -397,4 +404,3 @@ G4Polyhedron* G4UExtrudedSolid::CreatePolyhedron () const
}
#endif // G4GEOM_USE_USOLIDS
#endif
@@ -33,7 +33,7 @@
// --------------------------------------------------------------------
#include "G4Hype.hh"
#if 0
#include "G4UHype.hh"
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
@@ -240,5 +240,3 @@ G4Polyhedron* G4UHype::CreatePolyhedron() const
}
#endif // G4GEOM_USE_USOLIDS
#endif
@@ -0,0 +1,410 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
//
// Implementation of G4UTessellatedSolid wrapper class
// --------------------------------------------------------------------
#include "G4TessellatedSolid.hh"
#include "G4UTessellatedSolid.hh"
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4TriangularFacet.hh"
#include "G4QuadrangularFacet.hh"
#include "G4GeomTools.hh"
#include "G4AffineTransform.hh"
#include "G4BoundingEnvelope.hh"
#include "G4PolyhedronArbitrary.hh"
////////////////////////////////////////////////////////////////////////
//
// Constructors
//
G4UTessellatedSolid::G4UTessellatedSolid()
: Base_t("")
{
}
G4UTessellatedSolid::G4UTessellatedSolid(const G4String& name)
: Base_t(name)
{
}
////////////////////////////////////////////////////////////////////////
//
// Fake default constructor - sets only member data and allocates memory
// for usage restricted to object persistency.
//
G4UTessellatedSolid::G4UTessellatedSolid(__void__& a)
: Base_t(a)
{
}
//////////////////////////////////////////////////////////////////////////
//
// Destructor
//
G4UTessellatedSolid::~G4UTessellatedSolid()
{
G4int size = fFacets.size();
for (G4int i = 0; i < size; ++i) { delete fFacets[i]; }
fFacets.clear();
}
//////////////////////////////////////////////////////////////////////////
//
// Copy constructor
//
G4UTessellatedSolid::G4UTessellatedSolid(const G4UTessellatedSolid& source)
: Base_t(source)
{
}
//////////////////////////////////////////////////////////////////////////
//
// Assignment operator
//
G4UTessellatedSolid&
G4UTessellatedSolid::operator=(const G4UTessellatedSolid& source)
{
if (this == &source) return *this;
Base_t::operator=( source );
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Accessors
G4bool G4UTessellatedSolid::AddFacet(G4VFacet* aFacet)
{
// Add a facet to the structure, checking validity.
//
if (GetSolidClosed())
{
G4Exception("G4UTessellatedSolid::AddFacet()", "GeomSolids1002",
JustWarning, "Attempt to add facets when solid is closed.");
return false;
}
if (!aFacet->IsDefined())
{
G4Exception("G4UTessellatedSolid::AddFacet()", "GeomSolids1002",
JustWarning, "Attempt to add facet not properly defined.");
aFacet->StreamInfo(G4cout);
return false;
}
if (aFacet->GetNumberOfVertices() == 3)
{
G4TriangularFacet* a3Facet = dynamic_cast<G4TriangularFacet*>(aFacet);
return Base_t::AddTriangularFacet(UVector3(a3Facet->GetVertex(0).x(),
a3Facet->GetVertex(0).y(),
a3Facet->GetVertex(0).z()),
UVector3(a3Facet->GetVertex(1).x(),
a3Facet->GetVertex(1).y(),
a3Facet->GetVertex(1).z()),
UVector3(a3Facet->GetVertex(2).x(),
a3Facet->GetVertex(2).y(),
a3Facet->GetVertex(2).z()),
true);
}
else if (aFacet->GetNumberOfVertices() == 4)
{
G4QuadrangularFacet* a4Facet = dynamic_cast<G4QuadrangularFacet*>(aFacet);
return Base_t::AddQuadrilateralFacet(UVector3(a4Facet->GetVertex(0).x(),
a4Facet->GetVertex(0).y(),
a4Facet->GetVertex(0).z()),
UVector3(a4Facet->GetVertex(1).x(),
a4Facet->GetVertex(1).y(),
a4Facet->GetVertex(1).z()),
UVector3(a4Facet->GetVertex(2).x(),
a4Facet->GetVertex(2).y(),
a4Facet->GetVertex(2).z()),
UVector3(a4Facet->GetVertex(3).x(),
a4Facet->GetVertex(3).y(),
a4Facet->GetVertex(3).z()),
true);
}
else
{
G4Exception("G4UTessellatedSolid::AddFacet()", "GeomSolids1002",
JustWarning, "Attempt to add facet not properly defined.");
aFacet->StreamInfo(G4cout);
return false;
}
}
G4VFacet* G4UTessellatedSolid::GetFacet(G4int i) const
{
return fFacets[i];
}
G4int G4UTessellatedSolid::GetNumberOfFacets() const
{
return GetNFacets();
}
void G4UTessellatedSolid::SetSolidClosed(const G4bool t)
{
if (t && !Base_t::IsClosed())
{
Base_t::Close();
G4int nVertices = fTessellated.fVertices.size();
G4int nFacets = fTessellated.fFacets.size();
for (G4int j = 0; j < nVertices; ++j)
{
UVector3 vt = fTessellated.fVertices[j];
fVertexList.push_back(G4ThreeVector(vt.x(), vt.y(), vt.z()));
}
for (G4int i = 0; i < nFacets; ++i)
{
vecgeom::TriangleFacet<G4double>* afacet = Base_t::GetFacet(i);
std::vector<G4ThreeVector> v;
for (G4int k=0; k<3; ++k)
{
v.push_back(G4ThreeVector(afacet->fVertices[k].x(),
afacet->fVertices[k].y(),
afacet->fVertices[k].z()));
}
G4VFacet* facet = new G4TriangularFacet(v[0], v[1], v[2],
G4FacetVertexType::ABSOLUTE);
facet->SetVertices(&fVertexList);
for (G4int k=0; k<3; ++k)
{
facet->SetVertexIndex(k, afacet->fIndices[k]);
}
fFacets.push_back(facet);
}
}
}
G4bool G4UTessellatedSolid::GetSolidClosed() const
{
return Base_t::IsClosed();
}
void G4UTessellatedSolid::SetMaxVoxels(G4int)
{
// Not yet implemented !
}
G4double G4UTessellatedSolid::GetMinXExtent() const
{
UVector3 aMin, aMax;
Base_t::Extent(aMin, aMax);
return aMin.x();
}
G4double G4UTessellatedSolid::GetMaxXExtent() const
{
UVector3 aMin, aMax;
Base_t::Extent(aMin, aMax);
return aMax.x();
}
G4double G4UTessellatedSolid::GetMinYExtent() const
{
UVector3 aMin, aMax;
Base_t::Extent(aMin, aMax);
return aMin.y();
}
G4double G4UTessellatedSolid::GetMaxYExtent() const
{
UVector3 aMin, aMax;
Base_t::Extent(aMin, aMax);
return aMax.y();
}
G4double G4UTessellatedSolid::GetMinZExtent() const
{
UVector3 aMin, aMax;
Base_t::Extent(aMin, aMax);
return aMin.z();
}
G4double G4UTessellatedSolid::GetMaxZExtent() const
{
UVector3 aMin, aMax;
Base_t::Extent(aMin, aMax);
return aMax.z();
}
G4int G4UTessellatedSolid::AllocatedMemoryWithoutVoxels()
{
G4int base = sizeof(*this);
base += fVertexList.capacity() * sizeof(G4ThreeVector);
G4int limit = fFacets.size();
for (G4int i = 0; i < limit; i++)
{
G4VFacet &facet = *fFacets[i];
base += facet.AllocatedMemory();
}
return base;
}
G4int G4UTessellatedSolid::AllocatedMemory()
{
return AllocatedMemoryWithoutVoxels();
}
void G4UTessellatedSolid::DisplayAllocatedMemory()
{
G4int without = AllocatedMemoryWithoutVoxels();
// G4int with = AllocatedMemory();
// G4double ratio = (G4double) with / without;
// G4cout << "G4TessellatedSolid - Allocated memory without voxel overhead "
// << without << "; with " << with << "; ratio: " << ratio << G4endl;
G4cout << "G4TessellatedSolid - Allocated memory without voxel overhead "
<< without << G4endl;
}
///////////////////////////////////////////////////////////////////////////////
//
// Get bounding box
void G4UTessellatedSolid::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
UVector3 aMin, aMax;
Base_t::Extent(aMin, aMax);
pMin = G4ThreeVector(aMin.x(), aMin.y(), aMin.z());
pMax = G4ThreeVector(aMax.x(), aMax.y(), aMax.z());
// Check correctness of the bounding box
//
if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
{
std::ostringstream message;
message << "Bad bounding box (min >= max) for solid: "
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4UTessellatedSolid::BoundingLimits()",
"GeomMgt0001", JustWarning, message);
StreamInfo(G4cout);
}
}
//////////////////////////////////////////////////////////////////////////////
//
// Calculate extent under transform and specified limit
G4bool
G4UTessellatedSolid::CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const
{
G4ThreeVector bmin, bmax;
G4bool exist;
G4double kCarToleranceHalf = 0.5*kCarTolerance;
// Check bounding box (bbox)
//
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
#endif
if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
{
return exist = (pMin < pMax) ? true : false;
}
// The extent is calculated as cumulative extent of the pyramids
// formed by facets and the center of the bounding box.
//
G4double eminlim = pVoxelLimit.GetMinExtent(pAxis);
G4double emaxlim = pVoxelLimit.GetMaxExtent(pAxis);
G4ThreeVectorList base;
G4ThreeVectorList apex(1);
std::vector<const G4ThreeVectorList *> pyramid(2);
pyramid[0] = &base;
pyramid[1] = &apex;
apex[0] = (bmin+bmax)*0.5;
// main loop along facets
pMin = kInfinity;
pMax = -kInfinity;
for (G4int i=0; i<GetNumberOfFacets(); ++i)
{
G4VFacet* facet = GetFacet(i);
if (std::abs((facet->GetSurfaceNormal()).dot(facet->GetVertex(0)-apex[0]))
< kCarToleranceHalf) continue;
base.resize(3);
for (G4int k=0; k<3; ++k) { base[k] = facet->GetVertex(k); }
G4double emin,emax;
G4BoundingEnvelope benv(pyramid);
if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax)) continue;
if (emin < pMin) pMin = emin;
if (emax > pMax) pMax = emax;
if (eminlim > pMin && emaxlim < pMax) break; // max possible extent
}
return (pMin < pMax);
}
///////////////////////////////////////////////////////////////////////////////
//
// CreatePolyhedron()
//
G4Polyhedron* G4UTessellatedSolid::CreatePolyhedron () const
{
G4int nVertices = fVertexList.size();
G4int nFacets = fFacets.size();
G4PolyhedronArbitrary *polyhedron = new G4PolyhedronArbitrary (nVertices,
nFacets);
for (G4int j = 0; j < nVertices; ++j)
{
polyhedron->AddVertex(fVertexList[j]);
}
for (G4int i = 0; i < nFacets; ++i)
{
G4int v[3]; // Only facets with 3 vertices are defined in VecGeom
G4VFacet* facet = GetFacet(i);
for (G4int j=0; j<3; ++j) // Retrieve indexing directly from VecGeom
{
v[j] = facet->GetVertexIndex(j) + 1;
}
polyhedron->AddFacet(v[0],v[1],v[2]);
}
polyhedron->SetReferences();
return (G4Polyhedron*) polyhedron;
}
#endif // G4GEOM_USE_USOLIDS