Import Geant4 10.4.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2017-06-30 10:49:55 +02:00
parent 3a5407696b
commit 1a1316fea4
2180 changed files with 237880 additions and 59109 deletions
+43 -2
View File
@@ -1,4 +1,4 @@
$Id: History 102532 2017-02-08 13:44:45Z gcosmo $
$Id: History 104759 2017-06-15 12:46:56Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -17,7 +17,48 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
13-December-2016 G.Cosmo (geom-specific-V10-02-26)
15-June-2017 G.Cosmo (geom-specific-V10-03-08)
- Enabled adapter also in G4UPolycone wrapper.
- Added check on open solid for G4UPolyhedra wrapper.
6-June-2017 G.Cosmo (geom-specific-V10-03-07)
- Enable adapter for VecGeom shapes in G4U* wrappers for: paraboloid,
polyhedra and GenericTrap. From now on, wrappers depends directly on
VecGeom shapes implementation. USolids API is deprecated and no longer
supported.
24-May-2017 G.Cosmo (geom-specific-V10-03-06)
- Renamed ambiguous name Extent() in all solids and G4U* wrappers to
BoundingLimits(). Change required in order to avoid signature conflict
with VecGeom in G4U* wrappers.
Requires tag geommng-V10-03-16.
11-May-2017 G.Cosmo (geom-specific-V10-03-05)
- Removed potential race condition in G4VTwistSurface::AmIOnLeftSide().
Addressing problem report #1972.
7-April-2017 G.Cosmo (geom-specific-V10-03-04)
- Renamed G4SurfaceVoxelizer to G4Voxelizer and extended to support
voxelisation of shapes in 3D space. Adapted G4TessellatedSolid accordingly.
13-March-2017 G.Cosmo (geom-specific-V10-03-03)
- G4SolidsWorkspacePool: implemented CleanUpAndDestroyAllWorkspaces(),
to be called by worker threads. Removed declaration (i.e. not implemented)
of protected method ReleaseAndDestroyWorkspace().
2-March-2017 E.Tcherniaev (geom-specific-V10-03-02)
- Fixed possible rounding off error in calculation of 'astep' (max angle
for one step) in CalculateExtent() for G4Polycone, G4GenericPolycone
and related USolids wrappers.
27-February-2017 E.Tcherniaev (geom-specific-V10-03-01)
- Revised implementation of GetCubicVolume() and GetSurfaceArea() for
G4EllipticalTube, to return exact values.
- Revised implementation of GetSurfaceArea() for G4EllipticalCone, to
return exact value; moved both GetCubicVolume() and GetSurfaceArea() to
be not inline.
13-December-2016 G.Cosmo (geom-specific-V10-03-00)
- Correction in G4UExtrudedSolid to signature for CalculateExtent().
Fixes issue of undefined symbol if extruded-solid not included in the
list of VecGeom wrappers to activate.
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Ellipsoid.hh 100819 2016-11-02 15:17:36Z gcosmo $
// $Id: G4Ellipsoid.hh 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -86,7 +86,7 @@ class G4Ellipsoid : public G4VSolid
const G4int n,
const G4VPhysicalVolume* pRep);
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4EllipticalCone.hh 100819 2016-11-02 15:17:36Z gcosmo $
// $Id: G4EllipticalCone.hh 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -104,12 +104,12 @@ class G4EllipticalCone : public G4VSolid
inline void SetSemiAxis (G4double x, G4double y, G4double z);
inline void SetZCut (G4double newzTopCut);
inline G4double GetCubicVolume();
inline G4double GetSurfaceArea();
G4double GetCubicVolume();
G4double GetSurfaceArea();
// Solid standard methods
//
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4EllipticalCone.icc 83572 2014-09-01 15:23:27Z gcosmo $
// $Id: G4EllipticalCone.icc 102864 2017-02-27 14:22:02Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -89,31 +89,3 @@ void G4EllipticalCone::SetZCut (G4double newzTopCut)
{ zTopCut = newzTopCut; }
fRebuildPolyhedron = true;
}
inline
G4double G4EllipticalCone::GetCubicVolume()
{
if(fCubicVolume != 0 ) {;}
else
{
if (zTopCut > +zheight )
{
fCubicVolume = (8./3.)*CLHEP::pi*xSemiAxis*
ySemiAxis*zheight*zheight*zheight;
}
else
{
fCubicVolume = CLHEP::pi*xSemiAxis*ySemiAxis*
(2./3.*std::pow(zTopCut,3.)+2.*sqr(zheight)*zTopCut);
}
}
return fCubicVolume;
}
inline
G4double G4EllipticalCone::GetSurfaceArea()
{
if(fSurfaceArea != 0.) {;}
else { fSurfaceArea = G4VSolid::GetSurfaceArea(); }
return fSurfaceArea;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4EllipticalTube.hh 99781 2016-10-05 10:18:54Z gcosmo $
// $Id: G4EllipticalTube.hh 104316 2017-05-24 13:04:23Z gcosmo $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
@@ -66,7 +66,7 @@ class G4EllipticalTube : public G4VSolid
// Standard solid methods
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ExtrudedSolid.hh 100819 2016-11-02 15:17:36Z gcosmo $
// $Id: G4ExtrudedSolid.hh 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -130,7 +130,7 @@ class G4ExtrudedSolid : public G4TessellatedSolid
const G4bool calcNorm=false,
G4bool *validNorm=0, G4ThreeVector *n=0) const;
G4double DistanceToOut (const G4ThreeVector &p) const;
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
@@ -87,7 +87,7 @@ class G4GenericPolycone : public G4VCSGfaceted
G4double DistanceToIn( const G4ThreeVector &p, const G4ThreeVector &v ) const;
G4double DistanceToIn( const G4ThreeVector &p ) const;
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GenericTrap.hh 99781 2016-10-05 10:18:54Z gcosmo $
// $Id: G4GenericTrap.hh 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -120,7 +120,7 @@ class G4GenericTrap : public G4VSolid
G4bool *validNorm = 0,
G4ThreeVector *n = 0) const;
G4double DistanceToOut(const G4ThreeVector& p) const;
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Hype.hh 100819 2016-11-02 15:17:36Z gcosmo $
// $Id: G4Hype.hh 104316 2017-05-24 13:04:23Z gcosmo $
// $Original: G4Hype.hh,v 1.0 1998/06/09 16:57:50 safai Exp $
//
//
@@ -81,7 +81,7 @@ class G4Hype : public G4VSolid
const G4int n,
const G4VPhysicalVolume* pRep);
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Paraboloid.hh 100819 2016-11-02 15:17:36Z gcosmo $
// $Id: G4Paraboloid.hh 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -104,7 +104,7 @@ class G4Paraboloid : public G4VSolid
//void ComputeDimensions( G4VPVParamerisation p,
// const G4Int n,
// const G4VPhysicalVolume* pRep );
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Polycone.hh 100819 2016-11-02 15:17:36Z gcosmo $
// $Id: G4Polycone.hh 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -107,7 +107,7 @@ class G4Polycone : public G4VCSGfaceted
G4double DistanceToIn( const G4ThreeVector &p, const G4ThreeVector &v ) const;
G4double DistanceToIn( const G4ThreeVector &p ) const;
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Polyhedra.hh 100819 2016-11-02 15:17:36Z gcosmo $
// $Id: G4Polyhedra.hh 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -108,7 +108,7 @@ class G4Polyhedra : public G4VCSGfaceted
const G4ThreeVector &v ) const;
G4double DistanceToIn( const G4ThreeVector &p ) const;
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
@@ -31,22 +31,20 @@
#define G4SOLIDSWORKSPACEPOOL_HH
class G4SolidsWorkspace;
// #include "G4SolidsWorkspace.hh"
//Note: Investigate potential to make it a template - on the workspace type
class G4SolidsWorkspacePool
{
public:
static G4SolidsWorkspacePool* GetInstance();
// For use with simple MT mode - each thread gets a workspace and uses it until end
G4SolidsWorkspace* CreateWorkspace();
// For use with simple MT mode - each thread gets a workspace
// and uses it until end
void CreateAndUseWorkspace(); // Create it (as above) and use it
// For use with 'dynamic' model of threading - workspaces can be recycled
G4SolidsWorkspace* FindOrCreateWorkspace();
// For use with 'dynamic' model of threading - workspaces can be recycled
// Reuse an existing workspace - or create a new one if needed.
// This will never fail, except if system is out of resources
@@ -60,8 +58,6 @@ class G4SolidsWorkspacePool
// To be called once at the end of the job
protected:
void ReleaseAndDestroyWorkspace(G4SolidsWorkspace*);
// Destroy workspace - after releasing it
// void RegisterWarehouse( G4GeometryWarehouse *) ;
// The (optional) warehouse keeps a list of free workspaces
@@ -73,7 +69,7 @@ class G4SolidsWorkspacePool
private:
static G4SolidsWorkspacePool* thePool;
static G4ThreadLocal G4SolidsWorkspace* fMyWorkspace;
static G4ThreadLocal G4SolidsWorkspace* fMyWorkspace;
// The thread's workspace - if assigned.
};
@@ -24,7 +24,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TessellatedSolid.hh 100819 2016-11-02 15:17:36Z gcosmo $
// $Id: G4TessellatedSolid.hh 104316 2017-05-24 13:04:23Z gcosmo $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
@@ -106,7 +106,7 @@
#include "G4VSolid.hh"
#include "G4Types.hh"
#include "G4SurfaceVoxelizer.hh"
#include "G4Voxelizer.hh"
struct G4VertexInfo
{
@@ -180,14 +180,14 @@ class G4TessellatedSolid : public G4VSolid
inline void SetMaxVoxels(G4int max);
inline G4SurfaceVoxelizer &GetVoxels();
inline G4Voxelizer &GetVoxels();
virtual G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const;
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4double GetMinXExtent () const;
G4double GetMaxXExtent () const;
@@ -291,7 +291,7 @@ class G4TessellatedSolid : public G4VSolid
G4int fMaxTries;
G4SurfaceVoxelizer fVoxels; // Pointer to the voxelized solid
G4Voxelizer fVoxels; // Pointer to the voxelized solid
G4SurfBits fInsides;
};
@@ -310,7 +310,7 @@ inline void G4TessellatedSolid::SetMaxVoxels(G4int max)
fVoxels.SetMaxVoxels(max);
}
inline G4SurfaceVoxelizer &G4TessellatedSolid::GetVoxels()
inline G4Voxelizer &G4TessellatedSolid::GetVoxels()
{
return fVoxels;
}
@@ -28,7 +28,7 @@
// ********************************************************************
//
//
// $Id: G4Tet.hh 99781 2016-10-05 10:18:54Z gcosmo $
// $Id: G4Tet.hh 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -47,7 +47,7 @@
// 10.02.2005 - D.Anninos (CERN) - Added GetPointOnSurface() method.
// 12.11.2006 - M.H.Mendenhall - Added GetSurfaceArea() concrete implementation.
// 20.09.2010 - G.Cosmo (CERN) - Added copy-ctor and operator=().
// 24.09.2016 - E.Tcherniaev - Added Extent(), removed CreateRotatedVertices().
// 24.09.2016 - E.Tcherniaev - Removed CreateRotatedVertices().
// --------------------------------------------------------------------
#ifndef G4TET_HH
#define G4TET_HH
@@ -81,7 +81,7 @@ class G4Tet : public G4VSolid
const G4int n,
const G4VPhysicalVolume* pRep);
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
@@ -133,7 +133,7 @@ class G4Tet : public G4VSolid
// Copy constructor and assignment operator.
const char* CVSHeaderVers()
{ return "$Id: G4Tet.hh 99781 2016-10-05 10:18:54Z gcosmo $"; }
{ return "$Id: G4Tet.hh 104316 2017-05-24 13:04:23Z gcosmo $"; }
const char* CVSFileVers()
{ return CVSVers; }
void PrintWarnings(G4bool flag)
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4TwistedTubs.hh 100819 2016-11-02 15:17:36Z gcosmo $
// $Id: G4TwistedTubs.hh 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -104,7 +104,7 @@ class G4TwistedTubs : public G4VSolid
const G4int /* n */ ,
const G4VPhysicalVolume * /* prep */ );
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits &pVoxelLimit,
@@ -106,7 +106,7 @@ class G4UExtrudedSolid : public G4USolid
G4UExtrudedSolid &operator=(const G4UExtrudedSolid& source);
// Copy constructor and assignment operator.
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
@@ -88,7 +88,7 @@ class G4UGenericPolycone : public G4USolid
G4UGenericPolycone &operator=(const G4UGenericPolycone& source);
// Copy constructor and assignment operator.
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
@@ -43,17 +43,20 @@
#ifndef G4UGENERICTRAP_hh
#define G4UGENERICTRAP_hh
#include "G4USolid.hh"
#include "G4UAdapter.hh"
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UGenericTrap.hh"
#include <volumes/UnplacedGenTrap.h>
#include "G4TwoVector.hh"
#include "G4Polyhedron.hh"
class G4UGenericTrap : public G4USolid
class G4UGenericTrap : public G4UAdapter<vecgeom::UnplacedGenTrap>
{
using Shape_t = vecgeom::UnplacedGenTrap;
using Base_t = G4UAdapter<vecgeom::UnplacedGenTrap>;
public: // with description
G4UGenericTrap(const G4String& name, G4double halfZ,
@@ -61,8 +64,6 @@ class G4UGenericTrap : public G4USolid
~G4UGenericTrap();
inline UGenericTrap* GetShape() const;
G4double GetZHalfLength() const;
G4int GetNofVertices() const;
G4TwoVector GetVertex(G4int index) const;
@@ -72,6 +73,7 @@ class G4UGenericTrap : public G4USolid
G4int GetVisSubdivisions() const;
void SetVisSubdivisions(G4int subdiv);
void SetZHalfLength(G4double);
void Initialise(const std::vector<G4TwoVector>& v);
inline G4GeometryType GetEntityType() const;
@@ -86,7 +88,7 @@ class G4UGenericTrap : public G4USolid
G4UGenericTrap &operator=(const G4UGenericTrap& source);
// Copy constructor and assignment operator.
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
@@ -94,17 +96,18 @@ class G4UGenericTrap : public G4USolid
G4double& pMin, G4double& pMax) const;
G4Polyhedron* CreatePolyhedron() const;
private:
G4int fVisSubdivisions;
std::vector<G4TwoVector> fVertices;
};
// --------------------------------------------------------------------
// Inline methods
// --------------------------------------------------------------------
inline UGenericTrap* G4UGenericTrap::GetShape() const
{
return (UGenericTrap*) fShape;
}
inline G4GeometryType G4UGenericTrap::GetEntityType() const
{
return "G4GenericTrap";
@@ -43,16 +43,18 @@
#ifndef G4UPARABOLOID_HH
#define G4UPARABOLOID_HH
#include "G4USolid.hh"
#include "G4UAdapter.hh"
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UParaboloid.hh"
#include <volumes/UnplacedParaboloid.h>
#include "G4Polyhedron.hh"
class G4UParaboloid : public G4USolid
class G4UParaboloid : public G4UAdapter<vecgeom::UnplacedParaboloid>
{
using Shape_t = vecgeom::UnplacedParaboloid;
using Base_t = G4UAdapter<vecgeom::UnplacedParaboloid>;
public: // with description
@@ -63,12 +65,14 @@ class G4UParaboloid : public G4USolid
G4VSolid* Clone() const;
inline UParaboloid* GetShape() const;
G4double GetZHalfLength() const;
G4double GetRadiusMinusZ() const;
G4double GetRadiusPlusZ() const;
void SetZHalfLength(G4double dz);
void SetRadiusMinusZ(G4double r1);
void SetRadiusPlusZ(G4double r2);
inline G4GeometryType GetEntityType() const;
public: // without description
@@ -82,7 +86,7 @@ class G4UParaboloid : public G4USolid
G4UParaboloid &operator=( const G4UParaboloid &source );
// Copy constructor and assignment operator.
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
@@ -94,11 +98,6 @@ class G4UParaboloid : public G4USolid
// Inline methods
// --------------------------------------------------------------------
inline UParaboloid* G4UParaboloid::GetShape() const
{
return (UParaboloid*) fShape;
}
inline G4GeometryType G4UParaboloid::GetEntityType() const
{
return "G4Paraboloid";
@@ -43,18 +43,21 @@
#ifndef G4UPOLYCONE_HH
#define G4UPOLYCONE_HH
#include "G4USolid.hh"
#include "G4UAdapter.hh"
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UPolycone.hh"
#include <volumes/UnplacedPolycone.h>
#include "G4TwoVector.hh"
#include "G4PolyconeSide.hh"
#include "G4PolyconeHistorical.hh"
#include "G4Polyhedron.hh"
class G4UPolycone : public G4USolid
class G4UPolycone : public G4UAdapter<vecgeom::UnplacedPolycone>
{
using Shape_t = vecgeom::UnplacedPolycone;
using Base_t = G4UAdapter<vecgeom::UnplacedPolycone>;
public: // with description
@@ -81,9 +84,8 @@ class G4UPolycone : public G4USolid
G4VSolid* Clone() const;
inline UPolycone* GetShape() const;
G4double GetStartPhi() const;
G4double GetDeltaPhi() const;
G4double GetEndPhi() const;
G4double GetSinStartPhi() const;
G4double GetCosStartPhi() const;
@@ -110,7 +112,7 @@ class G4UPolycone : public G4USolid
G4UPolycone &operator=( const G4UPolycone &source );
// Copy constructor and assignment operator.
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
@@ -119,6 +121,13 @@ class G4UPolycone : public G4USolid
G4Polyhedron* CreatePolyhedron() const;
protected:
void SetOriginalParameters();
G4bool fGenericPcon; // true if created through the 2nd generic constructor
G4PolyconeHistorical fOriginalParameters; // original input parameters
private:
G4double wrStart;
@@ -130,11 +139,6 @@ class G4UPolycone : public G4USolid
// Inline methods
// --------------------------------------------------------------------
inline UPolycone* G4UPolycone::GetShape() const
{
return (UPolycone*) fShape;
}
inline G4GeometryType G4UPolycone::GetEntityType() const
{
return "G4Polycone";
@@ -43,11 +43,12 @@
#ifndef G4UPOLYHEDRA_HH
#define G4UPOLYHEDRA_HH
#include "G4USolid.hh"
#include "G4UAdapter.hh"
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UPolyhedra.hh"
#include <volumes/UnplacedPolyhedron.h>
#include "G4TwoVector.hh"
#include "G4PolyhedraSide.hh"
#include "G4PolyhedraHistorical.hh"
@@ -56,8 +57,11 @@
class G4EnclosingCylinder;
class G4ReduciblePolygon;
class G4UPolyhedra : public G4USolid
class G4UPolyhedra : public G4UAdapter<vecgeom::UnplacedPolyhedron>
{
using Shape_t = vecgeom::UnplacedPolyhedron;
using Base_t = G4UAdapter<vecgeom::UnplacedPolyhedron>;
public: // with description
G4UPolyhedra( const G4String& name,
@@ -85,8 +89,6 @@ class G4UPolyhedra : public G4USolid
G4VSolid* Clone() const;
inline UPolyhedra* GetShape() const;
G4int GetNumSide() const;
G4double GetStartPhi() const;
G4double GetEndPhi() const;
@@ -116,7 +118,7 @@ class G4UPolyhedra : public G4USolid
G4UPolyhedra &operator=( const G4UPolyhedra &source );
// Copy constructor and assignment operator.
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
@@ -125,6 +127,13 @@ class G4UPolyhedra : public G4USolid
G4Polyhedron* CreatePolyhedron() const;
protected:
void SetOriginalParameters();
G4bool fGenericPgon; // true if created through the 2nd generic constructor
G4PolyhedraHistorical fOriginalParameters; // original input parameters
private:
G4double wrStart;
@@ -137,11 +146,6 @@ class G4UPolyhedra : public G4USolid
// Inline methods
// --------------------------------------------------------------------
inline UPolyhedra* G4UPolyhedra::GetShape() const
{
return (UPolyhedra*) fShape;
}
inline G4GeometryType G4UPolyhedra::GetEntityType() const
{
return "G4Polyhedra";
@@ -83,7 +83,7 @@ class G4UTet : public G4USolid
G4UTet& operator=(const G4UTet& rhs);
// Copy constructor and assignment operator.
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VTwistedFaceted.hh 99781 2016-10-05 10:18:54Z gcosmo $
// $Id: G4VTwistedFaceted.hh 104316 2017-05-24 13:04:23Z gcosmo $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
@@ -79,7 +79,7 @@ class G4VTwistedFaceted: public G4VSolid
const G4int,
const G4VPhysicalVolume* );
virtual void Extent(G4ThreeVector &pMin, G4ThreeVector &pMax) const;
virtual void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const;
virtual G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits &pVoxelLimit,
@@ -0,0 +1,270 @@
//
// ********************************************************************
// * 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
//
// G4Voxelizer
//
// Class description:
//
// Voxelizer for tessellated surfaces and solids positioning in 3D space,
// used in G4TessellatedSolid and G4MultiUnion.
// History:
// 19.10.12 Marek Gayer, created
// --------------------------------------------------------------------
#ifndef G4Voxelizer_HH
#define G4Voxelizer_HH
#include <vector>
#include <string>
#include <map>
#include "G4Transform3D.hh"
#include "G4RotationMatrix.hh"
#include "G4SurfBits.hh"
#include "G4Box.hh"
#include "G4VFacet.hh"
#include "G4VSolid.hh"
struct G4VoxelBox
{
G4ThreeVector hlen; // half length of the box
G4ThreeVector pos; // position of the box
};
struct G4VoxelInfo
{
G4int count;
G4int previous;
G4int next;
};
class G4Voxelizer
{
public:
template <typename T>
static inline G4int BinarySearch(const std::vector<T> &vec, T value);
void Voxelize(std::vector<G4VSolid *> &solids,
std::vector<G4Transform3D>& transforms);
void Voxelize(std::vector<G4VFacet *> &facets);
void DisplayVoxelLimits() const;
void DisplayBoundaries();
void DisplayListNodes() const;
G4Voxelizer();
~G4Voxelizer();
void GetCandidatesVoxel(std::vector<G4int> &voxels);
// Method displaying the nodes located in a voxel characterized
// by its three indexes.
G4int GetCandidatesVoxelArray(const G4ThreeVector &point,
std::vector<G4int> &list,
G4SurfBits *crossed=0) const;
// Method returning in a vector container the nodes located in a voxel
// characterized by its three indexes.
G4int GetCandidatesVoxelArray(const std::vector<G4int> &voxels,
const G4SurfBits bitmasks[],
std::vector<G4int> &list,
G4SurfBits *crossed=0) const;
G4int GetCandidatesVoxelArray(const std::vector<G4int> &voxels,
std::vector<G4int> &list,
G4SurfBits *crossed=0)const;
inline const std::vector<G4VoxelBox> &GetBoxes() const;
// Method returning the pointer to the array containing the
// characteristics of each box.
inline const std::vector<G4double> &GetBoundary(G4int index) const;
G4bool UpdateCurrentVoxel(const G4ThreeVector &point,
const G4ThreeVector &direction,
std::vector<G4int> &curVoxel) const;
inline void GetVoxel(std::vector<G4int> &curVoxel,
const G4ThreeVector &point) const;
inline G4int GetBitsPerSlice () const;
G4bool Contains(const G4ThreeVector &point) const;
G4double DistanceToNext(const G4ThreeVector &point,
const G4ThreeVector &direction,
std::vector<G4int> &curVoxel) const;
G4double DistanceToFirst(const G4ThreeVector &point,
const G4ThreeVector &direction) const;
G4double DistanceToBoundingBox(const G4ThreeVector &point) const;
inline G4int GetVoxelsIndex(G4int x, G4int y, G4int z) const;
inline G4int GetVoxelsIndex(const std::vector<G4int> &voxels) const;
inline G4bool GetPointVoxel(const G4ThreeVector& p,
std::vector<G4int>& voxels) const;
inline G4int GetPointIndex(const G4ThreeVector &p) const;
inline const G4SurfBits &Empty() const;
inline G4bool IsEmpty(G4int index) const;
void SetMaxVoxels(G4int max);
void SetMaxVoxels(const G4ThreeVector &reductionRatio);
inline G4int GetMaxVoxels(G4ThreeVector &ratioOfReduction);
G4int AllocatedMemory();
inline long long GetCountOfVoxels() const;
inline long long CountVoxels(std::vector<G4double> boundaries[]) const;
inline const std::vector<G4int> &
GetCandidates(std::vector<G4int> &curVoxel) const;
inline G4int GetVoxelBoxesSize() const;
inline const G4VoxelBox &GetVoxelBox(G4int i) const;
inline const std::vector<G4int> &GetVoxelBoxCandidates(G4int i) const;
inline G4int GetTotalCandidates() const;
static G4double MinDistanceToBox (const G4ThreeVector &aPoint,
const G4ThreeVector &f);
static void SetDefaultVoxelsCount(G4int count);
static G4int GetDefaultVoxelsCount();
private:
class G4VoxelComparator
{
public:
std::vector<G4VoxelInfo> &fVoxels;
G4VoxelComparator(std::vector<G4VoxelInfo> &voxels) : fVoxels(voxels) {}
G4bool operator()(const G4int& l, const G4int& r) const
{
G4VoxelInfo &lv = fVoxels[l], &rv = fVoxels[r];
G4int left = lv.count + fVoxels[lv.next].count;
G4int right = rv.count + fVoxels[rv.next].count;
return (left == right) ? l < r : left < right;
}
};
private:
void BuildEmpty ();
G4String GetCandidatesAsString(const G4SurfBits &bits) const;
void CreateSortedBoundary(std::vector<G4double> &boundaryRaw, G4int axis);
void BuildBoundaries();
void BuildReduceVoxels(std::vector<G4double> fBoundaries[],
G4ThreeVector reductionRatio);
void BuildReduceVoxels2(std::vector<G4double> fBoundaries[],
G4ThreeVector reductionRatio);
void BuildVoxelLimits(std::vector<G4VSolid*>& solids,
std::vector<G4Transform3D>& transforms);
void BuildVoxelLimits(std::vector<G4VFacet *> &facets);
void DisplayBoundaries(std::vector<G4double> &fBoundaries);
void BuildBitmasks(std::vector<G4double> fBoundaries[],
G4SurfBits bitmasks[], G4bool countsOnly=false);
void BuildBoundingBox();
void BuildBoundingBox(G4ThreeVector& amin, G4ThreeVector& amax,
G4double tolerance = 0);
void SetReductionRatio(G4int maxVoxels, G4ThreeVector &reductionRatio);
void CreateMiniVoxels(std::vector<G4double> fBoundaries[],
G4SurfBits bitmasks[]);
static void FindComponentsFastest(unsigned int mask,
std::vector<G4int> &list, G4int i);
inline G4ThreeVector GetGlobalPoint(const G4Transform3D& trans,
const G4ThreeVector& lpoint) const;
void TransformLimits(G4ThreeVector& min, G4ThreeVector& max,
const G4Transform3D& transformation) const;
private:
static G4ThreadLocal G4int fDefaultVoxelsCount;
std::vector<G4VoxelBox> fVoxelBoxes;
std::vector<std::vector<G4int> > fVoxelBoxesCandidates;
mutable std::map<G4int, std::vector<G4int> > fCandidates;
const std::vector<G4int> fNoCandidates;
long long fCountOfVoxels;
G4int fNPerSlice;
std::vector<G4VoxelBox> fBoxes;
// Array of box limits on the 3 cartesian axis
std::vector<G4double> fBoundaries[3];
// Sorted and if need skimmed fBoundaries along X,Y,Z axis
std::vector<G4int> fCandidatesCounts[3];
G4int fTotalCandidates;
G4SurfBits fBitmasks[3];
G4ThreeVector fBoundingBoxCenter;
G4Box fBoundingBox;
G4ThreeVector fBoundingBoxSize;
G4ThreeVector fReductionRatio;
G4int fMaxVoxels;
G4double fTolerance;
G4SurfBits fEmpty;
};
#include "G4Voxelizer.icc"
#endif
@@ -0,0 +1,213 @@
//
// ********************************************************************
// * 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:$
// GEANT4 tag $Name: not supported by cvs2svn $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// G4Voxelizer inline methods
//
// History:
// 19.10.12 Marek Gayer, created
// --------------------------------------------------------------------
template <typename T> inline
G4int G4Voxelizer::BinarySearch(const std::vector<T> &vec, T value)
{
typename std::vector<T>::const_iterator begin=vec.begin(), end=vec.end();
G4int res = std::upper_bound(begin, end, value) - begin - 1;
return res;
}
inline
const std::vector<G4VoxelBox> &G4Voxelizer::GetBoxes() const
{
return fBoxes;
}
inline
const std::vector<G4double> &G4Voxelizer::GetBoundary(G4int index) const
{
return fBoundaries[index];
}
inline
void G4Voxelizer::GetVoxel(std::vector<G4int> &curVoxel,
const G4ThreeVector &point) const
{
for (G4int i=0; i<=2; ++i)
{
const std::vector<double> &boundary = GetBoundary(i);
G4int n = BinarySearch(boundary, point[i]);
if (n == -1)
{ n = 0; }
else if (n == G4int(boundary.size()) - 1)
{ n--; }
curVoxel[i] = n;
}
}
inline
G4int G4Voxelizer::GetBitsPerSlice () const
{
return fNPerSlice*8*sizeof(unsigned int);
}
inline
G4int G4Voxelizer::GetVoxelsIndex(G4int x, G4int y, G4int z) const
{
if (x < 0 || y < 0 || z < 0) { return -1; }
G4int maxX = fBoundaries[0].size();
G4int maxY = fBoundaries[1].size();
G4int index = x + y*maxX + z*maxX*maxY;
return index;
}
inline
G4int G4Voxelizer::GetVoxelsIndex(const std::vector<G4int> &voxels) const
{
return GetVoxelsIndex(voxels[0], voxels[1], voxels[2]);
}
inline
G4bool G4Voxelizer::GetPointVoxel(const G4ThreeVector& p,
std::vector<G4int>& voxels) const
{
for (G4int i = 0; i <= 2; ++i)
{
if (p[i] < *fBoundaries[i].begin() || p[i] > *fBoundaries[i].end())
{
return false;
}
}
for (G4int i = 0; i <= 2; ++i)
{
voxels[i] = BinarySearch(fBoundaries[i], p[i]);
}
return true;
}
inline
G4int G4Voxelizer::GetPointIndex(const G4ThreeVector &p) const
{
G4int maxX = fBoundaries[0].size();
G4int maxY = fBoundaries[1].size();
G4int x = BinarySearch(fBoundaries[0], p[0]);
G4int y = BinarySearch(fBoundaries[1], p[1]);
G4int z = BinarySearch(fBoundaries[2], p[2]);
G4int index = x + y*maxX + z*maxX*maxY;
return index;
}
inline
const G4SurfBits &G4Voxelizer::Empty() const
{
return fEmpty;
}
inline
G4bool G4Voxelizer::IsEmpty(G4int index) const
{
return fEmpty[index];
}
inline
G4int G4Voxelizer::GetMaxVoxels(G4ThreeVector &ratioOfReduction)
{
ratioOfReduction = fReductionRatio;
return fMaxVoxels;
}
inline
long long G4Voxelizer::GetCountOfVoxels() const
{
return fCountOfVoxels;
}
inline
long long G4Voxelizer::CountVoxels(std::vector<G4double> boundaries[]) const
{
long long sx = boundaries[0].size() - 1;
long long sy = boundaries[1].size() - 1;
long long sz = boundaries[2].size() - 1;
return sx * sy *sz;
}
inline
const std::vector<G4int>&
G4Voxelizer::GetCandidates(std::vector<G4int> &curVoxel) const
{
G4int voxelsIndex = GetVoxelsIndex(curVoxel);
if (voxelsIndex >= 0 && !fEmpty[voxelsIndex])
{
return fCandidates[voxelsIndex];
}
return fNoCandidates;
}
inline
G4int G4Voxelizer::GetTotalCandidates() const
{
return fTotalCandidates;
}
inline
G4int G4Voxelizer::GetVoxelBoxesSize() const
{
return fVoxelBoxes.size();
}
inline
const G4VoxelBox &G4Voxelizer::GetVoxelBox(G4int i) const
{
return fVoxelBoxes[i];
}
inline
const std::vector<G4int>&
G4Voxelizer::GetVoxelBoxCandidates(G4int i) const
{
return fVoxelBoxesCandidates[i];
}
inline
G4ThreeVector
G4Voxelizer::GetGlobalPoint(const G4Transform3D& trans,
const G4ThreeVector& local) const
{
// Returns global point coordinates converted from the local frame defined
// by the transformation. This is defined by multiplying this transformation
// with the local vector.
return trans*G4Point3D(local);
}
@@ -11,7 +11,7 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake 92392 2015-08-31 14:07:02Z gcosmo $
# $Id: sources.cmake 103465 2017-04-11 07:24:57Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -71,8 +71,6 @@ GEANT4_DEFINE_MODULE(NAME G4specsolids
G4SolidExtentList.hh
G4SolidsWorkspace.hh
G4SolidsWorkspacePool.hh
G4SurfaceVoxelizer.hh
G4SurfaceVoxelizer.icc
G4SurfBits.hh
G4TessellatedGeometryAlgorithms.hh
G4TessellatedSolid.hh
@@ -99,6 +97,8 @@ GEANT4_DEFINE_MODULE(NAME G4specsolids
G4VCSGface.hh
G4VCSGfaceted.hh
G4VFacet.hh
G4Voxelizer.hh
G4Voxelizer.icc
G4VTwistSurface.hh
G4VTwistSurface.icc
G4VTwistedFaceted.hh
@@ -126,7 +126,6 @@ GEANT4_DEFINE_MODULE(NAME G4specsolids
G4SolidExtentList.cc
G4SolidsWorkspace.cc
G4SolidsWorkspacePool.cc
G4SurfaceVoxelizer.cc
G4SurfBits.cc
G4TessellatedGeometryAlgorithms.cc
G4TessellatedSolid.cc
@@ -152,6 +151,7 @@ GEANT4_DEFINE_MODULE(NAME G4specsolids
G4UTet.cc
G4VCSGfaceted.cc
G4VFacet.cc
G4Voxelizer.cc
G4VTwistSurface.cc
G4VTwistedFaceted.cc
GRANULAR_DEPENDENCIES
@@ -162,7 +162,6 @@ GEANT4_DEFINE_MODULE(NAME G4specsolids
G4hepnumerics
G4intercoms
G4volumes
G4GeomUSolids
GLOBAL_DEPENDENCIES
G4global
G4graphics_reps
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4Ellipsoid.cc 100819 2016-11-02 15:17:36Z gcosmo $
// $Id: G4Ellipsoid.cc 104316 2017-05-24 13:04:23Z gcosmo $
//
// class G4Ellipsoid
//
@@ -33,9 +33,8 @@
//
// 10.11.99 G.Horton-Smith: first writing, based on G4Sphere class
// 25.02.05 G.Guerrieri: Modified for future Geant4 release
// 26.10.16 E.Tcherniaev: Added Extent(pmin,pmax),
// reimplemented CalculateExtent() using G4BoundingEnvelope,
// removed CreateRotatedVertices()
// 26.10.16 E.Tcherniaev: reimplemented CalculateExtent() using
// G4BoundingEnvelope, removed CreateRotatedVertices()
//
// --------------------------------------------------------------------
@@ -199,7 +198,7 @@ void G4Ellipsoid::ComputeDimensions(G4VPVParameterisation* p,
//
// Get bounding box
void G4Ellipsoid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4Ellipsoid::BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const
{
G4double dx = GetSemiAxisMax(0);
G4double dy = GetSemiAxisMax(1);
@@ -218,7 +217,8 @@ void G4Ellipsoid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4Ellipsoid::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4Ellipsoid::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
DumpInfo();
}
}
@@ -236,7 +236,7 @@ G4Ellipsoid::CalculateExtent(const EAxis pAxis,
G4ThreeVector bmin, bmax;
// Get bounding box
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
// Find extent
G4BoundingEnvelope bbox(bmin,bmax);
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EllipticalCone.cc 101118 2016-11-07 09:10:59Z gcosmo $
// $Id: G4EllipticalCone.cc 104316 2017-05-24 13:04:23Z gcosmo $
//
// Implementation of G4EllipticalCone class
//
@@ -41,6 +41,7 @@
#include "G4EllipticalCone.hh"
#include "G4GeomTools.hh"
#include "G4ClippablePolygon.hh"
#include "G4VoxelLimits.hh"
#include "G4AffineTransform.hh"
@@ -170,7 +171,8 @@ G4EllipticalCone& G4EllipticalCone::operator = (const G4EllipticalCone& rhs)
//
// Get bounding box
void G4EllipticalCone::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4EllipticalCone::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
G4double zcut = GetZTopCut();
G4double height = GetZMax();
@@ -188,7 +190,7 @@ void G4EllipticalCone::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4EllipticalCone::Extent()", "GeomMgt0001",
G4Exception("G4EllipticalCone::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
DumpInfo();
}
@@ -209,7 +211,7 @@ G4EllipticalCone::CalculateExtent(const EAxis pAxis,
// Check bounding box (bbox)
//
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
@@ -1023,6 +1025,42 @@ G4ThreeVector G4EllipticalCone::GetPointOnSurface() const
rRand1*ySemiAxis*(zheight-zTopCut)*sinphi, zTopCut);
}
/////////////////////////////////////////////////////////////////////////
//
// Get cubic volume
//
G4double G4EllipticalCone::GetCubicVolume()
{
if (fCubicVolume == 0)
{
G4double x0 = xSemiAxis*zheight; // x semi axis at z=0
G4double y0 = ySemiAxis*zheight; // y semi axis at z=0
G4double v0 = CLHEP::pi*x0*y0*zheight/3.;
G4double kmin = (zTopCut >= zheight ) ? 0. : (zheight - zTopCut)/zheight;
G4double kmax = (zTopCut >= zheight ) ? 2. : (zheight + zTopCut)/zheight;
fCubicVolume = (kmax - kmin)*(kmax*kmax + kmax*kmin + kmin*kmin)*v0;
}
return fCubicVolume;
}
/////////////////////////////////////////////////////////////////////////
//
// Get surface area
//
G4double G4EllipticalCone::GetSurfaceArea()
{
if (fSurfaceArea == 0)
{
G4double x0 = xSemiAxis*zheight; // x semi axis at z=0
G4double y0 = ySemiAxis*zheight; // y semi axis at z=0
G4double s0 = G4GeomTools::EllipticConeLateralArea(x0,y0,zheight);
G4double kmin = (zTopCut >= zheight ) ? 0. : (zheight - zTopCut)/zheight;
G4double kmax = (zTopCut >= zheight ) ? 2. : (zheight + zTopCut)/zheight;
fSurfaceArea = (kmax - kmin)*(kmax + kmin)*s0 + CLHEP::pi*x0*y0*(kmin*kmin + kmax*kmax);
}
return fSurfaceArea;
}
//
// Methods for visualisation
//
@@ -1037,7 +1075,7 @@ G4VisExtent G4EllipticalCone::GetExtent() const
// Define the sides of the box into which the solid instance would fit.
//
G4ThreeVector pmin,pmax;
Extent(pmin,pmax);
BoundingLimits(pmin,pmax);
return G4VisExtent(pmin.x(),pmax.x(),
pmin.y(),pmax.y(),
pmin.z(),pmax.z());
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4EllipticalTube.cc 101118 2016-11-07 09:10:59Z gcosmo $
// $Id: G4EllipticalTube.cc 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -40,6 +40,7 @@
#include "G4EllipticalTube.hh"
#include "G4GeomTools.hh"
#include "G4ClippablePolygon.hh"
#include "G4AffineTransform.hh"
#include "G4SolidExtentList.hh"
@@ -139,8 +140,8 @@ G4EllipticalTube& G4EllipticalTube::operator = (const G4EllipticalTube& rhs)
//
// Get bounding box
void G4EllipticalTube::Extent( G4ThreeVector& pMin,
G4ThreeVector& pMax ) const
void G4EllipticalTube::BoundingLimits( G4ThreeVector& pMin,
G4ThreeVector& pMax ) const
{
pMin.set(-dx,-dy,-dz);
pMax.set( dx, dy, dz);
@@ -161,7 +162,7 @@ G4EllipticalTube::CalculateExtent( const EAxis pAxis,
// Check bounding box (bbox)
//
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
@@ -813,14 +814,13 @@ G4VSolid* G4EllipticalTube::Clone() const
return new G4EllipticalTube(*this);
}
//
// GetCubicVolume
//
G4double G4EllipticalTube::GetCubicVolume()
{
if(fCubicVolume != 0.) {;}
else { fCubicVolume = G4VSolid::GetCubicVolume(); }
if (fCubicVolume == 0.)
fCubicVolume = twopi*dx*dy*dz;
return fCubicVolume;
}
@@ -829,8 +829,8 @@ G4double G4EllipticalTube::GetCubicVolume()
//
G4double G4EllipticalTube::GetSurfaceArea()
{
if(fSurfaceArea != 0.) {;}
else { fSurfaceArea = G4VSolid::GetSurfaceArea(); }
if(fSurfaceArea == 0.)
fSurfaceArea = 2.*(pi*dx*dy + G4GeomTools::EllipsePerimeter(dx,dy)*dz);
return fSurfaceArea;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ExtrudedSolid.cc 101118 2016-11-07 09:10:59Z gcosmo $
// $Id: G4ExtrudedSolid.cc 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -37,7 +37,7 @@
// CHANGE HISTORY
// --------------
//
// 21.10.2016 E.Tcherniaev: added Extent() and CalculateExtent(),
// 21.10.2016 E.Tcherniaev: reimplemented CalculateExtent(),
// used G4GeomTools::PolygonArea() to calculate area,
// replaced IsConvex() with G4GeomTools::IsConvex()
// 02.03.2016 E.Tcherniaev: added CheckPolygon() to remove
@@ -908,7 +908,8 @@ G4double G4ExtrudedSolid::DistanceToOut (const G4ThreeVector &p) const
//
// Get bounding box
void G4ExtrudedSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4ExtrudedSolid::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
G4double xmin0 = kInfinity, xmax0 = -kInfinity;
G4double ymin0 = kInfinity, ymax0 = -kInfinity;
@@ -954,7 +955,7 @@ void G4ExtrudedSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4ExtrudedSolid::Extent()",
G4Exception("G4ExtrudedSolid::BoundingLimits()",
"GeomMgt0001", JustWarning, message);
DumpInfo();
}
@@ -975,7 +976,7 @@ G4ExtrudedSolid::CalculateExtent(const EAxis pAxis,
// Check bounding box (bbox)
//
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
@@ -411,7 +411,8 @@ G4double G4GenericPolycone::DistanceToIn( const G4ThreeVector &p ) const
// Get bounding box
void
G4GenericPolycone::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
G4GenericPolycone::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
G4double rmin = kInfinity, rmax = -kInfinity;
G4double zmin = kInfinity, zmax = -kInfinity;
@@ -450,7 +451,7 @@ G4GenericPolycone::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("GenericG4Polycone::Extent()", "GeomMgt0001",
G4Exception("GenericG4Polycone::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
DumpInfo();
}
@@ -471,7 +472,7 @@ G4GenericPolycone::CalculateExtent(const EAxis pAxis,
// Check bounding box (bbox)
//
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
@@ -513,7 +514,7 @@ G4GenericPolycone::CalculateExtent(const EAxis pAxis,
// set trigonometric values
const G4int NSTEPS = 24; // number of steps for whole circle
G4double astep = (360/NSTEPS)*deg; // max angle for one step
G4double astep = twopi/NSTEPS; // max angle for one step
G4double sphi = GetStartPhi();
G4double ephi = GetEndPhi();
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GenericTrap.cc 101118 2016-11-07 09:10:59Z gcosmo $
// $Id: G4GenericTrap.cc 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -42,7 +42,7 @@
// 03.02.2016 E.Tcherniaev - Revised GetSurfaceArea() and GetCubicVolume(),
// rewritten GetFaceSurfaceArea(), added GetFaceCubicVolume()
// 25.09.2016 E.Tcherniaev - Use G4BoundingEnvelope for CalculateExtent(),
// added Extent(), removed CreateRotatedVertices()
// removed CreateRotatedVertices()
// --------------------------------------------------------------------
#include "G4GenericTrap.hh"
@@ -1212,7 +1212,8 @@ G4double G4GenericTrap::DistanceToOut(const G4ThreeVector& p) const
// --------------------------------------------------------------------
void G4GenericTrap::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4GenericTrap::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
pMin = GetMinimumBBox();
pMax = GetMaximumBBox();
@@ -1226,7 +1227,8 @@ void G4GenericTrap::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4GenericTrap::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4GenericTrap::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
DumpInfo();
}
}
@@ -1244,7 +1246,7 @@ G4GenericTrap::CalculateExtent(const EAxis pAxis,
// Check bounding box (bbox)
//
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Hype.cc 100819 2016-11-02 15:17:36Z gcosmo $
// $Id: G4Hype.cc 104316 2017-05-24 13:04:23Z gcosmo $
// $Original: G4Hype.cc,v 1.0 1998/06/09 16:57:50 safai Exp $
//
//
@@ -220,7 +220,7 @@ void G4Hype::ComputeDimensions(G4VPVParameterisation* p,
//
// Get bounding box
void G4Hype::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4Hype::BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const
{
pMin.set(-endOuterRadius,-endOuterRadius,-halfLenZ);
pMax.set( endOuterRadius, endOuterRadius, halfLenZ);
@@ -234,7 +234,8 @@ void G4Hype::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4Hype::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4Hype::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
DumpInfo();
}
}
@@ -251,7 +252,7 @@ G4bool G4Hype::CalculateExtent(const EAxis pAxis,
G4ThreeVector bmin, bmax;
// Get bounding box
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
// Find extent
G4BoundingEnvelope bbox(bmin,bmax);
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4Paraboloid.cc 101819 2016-12-01 08:13:36Z gcosmo $
// $Id: G4Paraboloid.cc 104316 2017-05-24 13:04:23Z gcosmo $
//
// class G4Paraboloid
//
@@ -167,7 +167,8 @@ G4Paraboloid& G4Paraboloid::operator = (const G4Paraboloid& rhs)
//
// Get bounding box
void G4Paraboloid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4Paraboloid::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
pMin.set(-r2,-r2,-dz);
pMax.set( r2, r2, dz);
@@ -181,7 +182,8 @@ void G4Paraboloid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4Paraboloid::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4Paraboloid::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
DumpInfo();
}
}
@@ -199,7 +201,7 @@ G4Paraboloid::CalculateExtent(const EAxis pAxis,
G4ThreeVector bmin, bmax;
// Get bounding box
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
// Find extent
G4BoundingEnvelope bbox(bmin,bmax);
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Polycone.cc 101819 2016-12-01 08:13:36Z gcosmo $
// $Id: G4Polycone.cc 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -523,7 +523,8 @@ G4double G4Polycone::DistanceToIn( const G4ThreeVector &p ) const
//
// Get bounding box
void G4Polycone::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4Polycone::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
G4double rmin = kInfinity, rmax = -kInfinity;
G4double zmin = kInfinity, zmax = -kInfinity;
@@ -562,7 +563,8 @@ void G4Polycone::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4Polycone::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4Polycone::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
DumpInfo();
}
}
@@ -581,7 +583,7 @@ G4bool G4Polycone::CalculateExtent(const EAxis pAxis,
// Check bounding box (bbox)
//
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
@@ -625,7 +627,7 @@ G4bool G4Polycone::CalculateExtent(const EAxis pAxis,
// set trigonometric values
const G4int NSTEPS = 24; // number of steps for whole circle
G4double astep = (360/NSTEPS)*deg; // max angle for one step
G4double astep = twopi/NSTEPS; // max angle for one step
G4double sphi = GetStartPhi();
G4double ephi = GetEndPhi();
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Polyhedra.cc 101819 2016-12-01 08:13:36Z gcosmo $
// $Id: G4Polyhedra.cc 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -573,7 +573,8 @@ G4double G4Polyhedra::DistanceToIn( const G4ThreeVector &p ) const
//
// Get bounding box
void G4Polyhedra::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4Polyhedra::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
G4double rmin = kInfinity, rmax = -kInfinity;
G4double zmin = kInfinity, zmax = -kInfinity;
@@ -632,7 +633,8 @@ void G4Polyhedra::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4Polyhedra::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4Polyhedra::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
DumpInfo();
}
}
@@ -651,7 +653,7 @@ G4bool G4Polyhedra::CalculateExtent(const EAxis pAxis,
// Check bounding box (bbox)
//
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
@@ -30,37 +30,44 @@
#include "G4SolidsWorkspace.hh"
#include "G4AutoLock.hh"
namespace {
G4Mutex singletonMutexSWP = G4MUTEX_INITIALIZER;
namespace
{
G4Mutex singletonMutexSWP = G4MUTEX_INITIALIZER;
}
G4ThreadLocal G4SolidsWorkspace* G4SolidsWorkspacePool::fMyWorkspace=0;
G4SolidsWorkspacePool* G4SolidsWorkspacePool::thePool=0;
// static
G4SolidsWorkspacePool* G4SolidsWorkspacePool::GetInstance()
{
G4AutoLock l(&singletonMutexSWP);
if( !thePool ) thePool= new G4SolidsWorkspacePool();
return thePool;
G4AutoLock l(&singletonMutexSWP);
if( !thePool ) { thePool= new G4SolidsWorkspacePool(); }
return thePool;
}
// For use with MT and current G4WorkerThread -- which uses static methods
//
G4SolidsWorkspace* G4SolidsWorkspacePool::CreateWorkspace()
{
G4SolidsWorkspace* geometryWrk=0;
if( !fMyWorkspace ){
if( !fMyWorkspace )
{
geometryWrk= new G4SolidsWorkspace();
if( !geometryWrk ) {
if( !geometryWrk )
{
G4Exception("GeometryWorspacePool::CreateWorkspace", "Geom-003",
FatalException, "Failed to create workspace.");
}else{
// geometryWrk->UseWorkspace(); // Do not assign it already.
fMyWorkspace= geometryWrk;
}
}else{
else
{
// geometryWrk->UseWorkspace(); // Do not assign it already.
fMyWorkspace= geometryWrk;
}
}
else
{
G4Exception("GeometryWorspacePool::CreateWorkspace", "Geom-003",
FatalException,
"Cannot create workspace twice for the same thread.");
@@ -70,8 +77,9 @@ G4SolidsWorkspace* G4SolidsWorkspacePool::CreateWorkspace()
return geometryWrk;
}
void G4SolidsWorkspacePool::CreateAndUseWorkspace() // Create it (as above) and use it
// Create it (as above) and use it
//
void G4SolidsWorkspacePool::CreateAndUseWorkspace()
{
(this->CreateWorkspace())->UseWorkspace();
}
@@ -80,43 +88,35 @@ void G4SolidsWorkspacePool::CreateAndUseWorkspace() // Create it (as above) and
//
G4SolidsWorkspace* G4SolidsWorkspacePool::FindOrCreateWorkspace()
{
G4SolidsWorkspace* geometryWrk= fMyWorkspace;
if( !geometryWrk ){
geometryWrk= this->CreateWorkspace();
}
geometryWrk->UseWorkspace();
G4SolidsWorkspace* geometryWrk= fMyWorkspace;
if( !geometryWrk )
{
geometryWrk= this->CreateWorkspace();
}
geometryWrk->UseWorkspace();
fMyWorkspace= geometryWrk; // assign it for use by this thread.
return geometryWrk;
fMyWorkspace= geometryWrk; // assign it for use by this thread.
return geometryWrk;
}
#if 0
void G4SolidsWorkspacePool::ReleaseAndDestroyMyWorkspace()
{
ReleaseAndDestroyWorkspace(fMyWorkspace);
fMyWorkspace=0;
}
void G4SolidsWorkspacePool::ReleaseAndDestroyWorkspace(G4SolidsWorkspace *geometryWrk)
{
geometryWrk->ReleaseWorkspace();
delete geometryWrk;
}
#endif
// Keep the unused Workspace - for recycling
//
void G4SolidsWorkspacePool::Recycle( G4SolidsWorkspace *geometryWrk )
{
geometryWrk->ReleaseWorkspace();
// if( fWarehouse ){
// } else {
delete geometryWrk;
// }
geometryWrk->ReleaseWorkspace();
delete geometryWrk;
}
// Keep the unused Workspace - for recycling
void G4SolidsWorkspacePool::CleanUpAndDestroyAllWorkspaces()
{
if (fMyWorkspace)
{
fMyWorkspace->DestroyWorkspace();
delete fMyWorkspace;
fMyWorkspace=0;
}
}
@@ -125,9 +125,7 @@ G4SolidsWorkspacePool::G4SolidsWorkspacePool()
// fWarehouse=0;
}
G4SolidsWorkspacePool::~G4SolidsWorkspacePool()
{
}
@@ -24,14 +24,14 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TessellatedSolid.cc 101118 2016-11-07 09:10:59Z gcosmo $
// $Id: G4TessellatedSolid.cc 104316 2017-05-24 13:04:23Z gcosmo $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
// CHANGE HISTORY
// --------------
// 23 October 2016, E Tcherniaev, reimplemented CalculateExtent() to make
// use of G4BoundingEnvelope, added Extent().
// use of G4BoundingEnvelope.
//
// 12 October 2012, M Gayer, CERN, complete rewrite reducing memory
// requirements more than 50% and speedup by a factor of
@@ -1825,7 +1825,8 @@ G4Polyhedron* G4TessellatedSolid::GetPolyhedron () const
//
// Get bounding box
//
void G4TessellatedSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4TessellatedSolid::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
pMin = fMinExtent;
pMax = fMaxExtent;
@@ -1839,7 +1840,7 @@ void G4TessellatedSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4TessellatedSolid::Extent()",
G4Exception("G4TessellatedSolid::BoundingLimits()",
"GeomMgt0001", JustWarning, message);
DumpInfo();
}
@@ -1860,7 +1861,7 @@ G4TessellatedSolid::CalculateExtent(const EAxis pAxis,
// Check bounding box (bbox)
//
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
+6 -7
View File
@@ -27,7 +27,7 @@
// * *
// ********************************************************************
//
// $Id: G4Tet.cc 101118 2016-11-07 09:10:59Z gcosmo $
// $Id: G4Tet.cc 104316 2017-05-24 13:04:23Z gcosmo $
//
// class G4Tet
//
@@ -51,8 +51,7 @@
// 20040803 - Dionysios Anninos, added GetPointOnSurface() method
// 20061112 - MHM added code for G4VSolid GetSurfaceArea()
// 20100920 - Gabriele Cosmo added copy-ctor and operator=()
// 20160924 - Evgueni Tcherniaev, added Extent(pmin,pmax),
// use G4BoundingEnvelope for CalculateExtent()
// 20160924 - Evgueni Tcherniaev, use G4BoundingEnvelope for CalculateExtent()
//
// --------------------------------------------------------------------
@@ -60,7 +59,7 @@
#if !defined(G4GEOM_USE_UTET)
const char G4Tet::CVSVers[]="$Id: G4Tet.cc 101118 2016-11-07 09:10:59Z gcosmo $";
const char G4Tet::CVSVers[]="$Id: G4Tet.cc 104316 2017-05-24 13:04:23Z gcosmo $";
#include "G4VoxelLimits.hh"
#include "G4AffineTransform.hh"
@@ -301,7 +300,7 @@ void G4Tet::ComputeDimensions(G4VPVParameterisation* ,
//
// Get bounding box
void G4Tet::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4Tet::BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const
{
pMin.set(fXMin,fYMin,fZMin);
pMax.set(fXMax,fYMax,fZMax);
@@ -315,7 +314,7 @@ void G4Tet::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4Tet::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4Tet::BoundingLimits()", "GeomMgt0001", JustWarning, message);
DumpInfo();
}
}
@@ -334,7 +333,7 @@ G4bool G4Tet::CalculateExtent(const EAxis pAxis,
// Check bounding box (bbox)
//
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4TwistedTubs.cc 100819 2016-11-02 15:17:36Z gcosmo $
// $Id: G4TwistedTubs.cc 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -328,7 +328,8 @@ void G4TwistedTubs::ComputeDimensions(G4VPVParameterisation* /* p */ ,
//
// Get bounding box
void G4TwistedTubs::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4TwistedTubs::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
G4double maxEndOuterRad = (fEndOuterRadius[0] > fEndOuterRadius[1] ?
fEndOuterRadius[0] : fEndOuterRadius[1]);
@@ -344,7 +345,8 @@ void G4TwistedTubs::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4TwistedTubs::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4TwistedTubs::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
DumpInfo();
}
}
@@ -362,7 +364,7 @@ G4TwistedTubs::CalculateExtent(const EAxis pAxis,
G4ThreeVector bmin, bmax;
// Get bounding box
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
// Find extent
G4BoundingEnvelope bbox(bmin,bmax);
@@ -176,7 +176,8 @@ std::vector<G4UExtrudedSolid::ZSection> G4UExtrudedSolid::GetZSections() const
//
// Get bounding box
void G4UExtrudedSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4UExtrudedSolid::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
static G4bool checkBBox = true;
@@ -225,7 +226,7 @@ void G4UExtrudedSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4UExtrudedSolid::Extent()", "GeomMgt0001",
G4Exception("G4UExtrudedSolid::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
StreamInfo(G4cout);
}
@@ -248,7 +249,8 @@ void G4UExtrudedSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\nBBox min: wrapper = " << pMin << " solid = " << vmin
<< "\nBBox max: wrapper = " << pMax << " solid = " << vmax;
G4Exception("G4UExtrudedSolid::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4UExtrudedSolid::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
checkBBox = false;
}
}
@@ -270,7 +272,7 @@ G4UExtrudedSolid::CalculateExtent(const EAxis pAxis,
// Check bounding box (bbox)
//
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
@@ -156,7 +156,8 @@ G4PolyconeSideRZ G4UGenericPolycone::GetCorner(G4int index) const
// Get bounding box
void
G4UGenericPolycone::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
G4UGenericPolycone::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
G4double rmin = kInfinity, rmax = -kInfinity;
G4double zmin = kInfinity, zmax = -kInfinity;
@@ -195,7 +196,7 @@ G4UGenericPolycone::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4UGenericPolycone::Extent()", "GeomMgt0001",
G4Exception("G4UGenericPolycone::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
StreamInfo(G4cout);
}
@@ -216,7 +217,7 @@ G4UGenericPolycone::CalculateExtent(const EAxis pAxis,
// Check bounding box (bbox)
//
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
@@ -258,7 +259,7 @@ G4UGenericPolycone::CalculateExtent(const EAxis pAxis,
// set trigonometric values
const G4int NSTEPS = 24; // number of steps for whole circle
G4double astep = (360/NSTEPS)*deg; // max angle for one step
G4double astep = twopi/NSTEPS; // max angle for one step
G4double sphi = GetStartPhi();
G4double ephi = GetEndPhi();
@@ -42,8 +42,6 @@
#include "G4Polyhedron.hh"
#include "G4PolyhedronArbitrary.hh"
#include "G4AutoLock.hh"
namespace { G4Mutex UGenericTrapMutex = G4MUTEX_INITIALIZER; }
using namespace CLHEP;
////////////////////////////////////////////////////////////////////////
@@ -52,16 +50,10 @@ using namespace CLHEP;
//
G4UGenericTrap::G4UGenericTrap(const G4String& name, G4double halfZ,
const std::vector<G4TwoVector>& vertices)
: G4USolid(name, new UGenericTrap())
: Base_t(name), fVisSubdivisions(0)
{
SetZHalfLength(halfZ);
std::vector<UVector2> v;
for (size_t n=0; n<vertices.size(); ++n)
{
v.push_back(UVector2(vertices[n].x(),vertices[n].y()));
}
GetShape()->SetName(name);
GetShape()->Initialise(v);
Initialise(vertices);
}
@@ -71,7 +63,7 @@ G4UGenericTrap::G4UGenericTrap(const G4String& name, G4double halfZ,
// for usage restricted to object persistency.
//
G4UGenericTrap::G4UGenericTrap(__void__& a)
: G4USolid(a)
: Base_t(a), fVisSubdivisions(0), fVertices()
{
}
@@ -90,7 +82,9 @@ G4UGenericTrap::~G4UGenericTrap()
// Copy constructor
//
G4UGenericTrap::G4UGenericTrap(const G4UGenericTrap &source)
: G4USolid(source)
: Base_t(source), fVisSubdivisions(source.fVisSubdivisions),
fVertices(source.fVertices)
{
}
@@ -104,7 +98,9 @@ G4UGenericTrap::operator=(const G4UGenericTrap &source)
{
if (this == &source) return *this;
G4USolid::operator=( source );
Base_t::operator=( source );
fVertices = source.fVertices;
fVisSubdivisions = source.fVisSubdivisions;
return *this;
}
@@ -115,59 +111,64 @@ G4UGenericTrap::operator=(const G4UGenericTrap &source)
//
G4double G4UGenericTrap::GetZHalfLength() const
{
return GetShape()->GetZHalfLength();
return GetDZ();
}
G4int G4UGenericTrap::GetNofVertices() const
{
return GetShape()->GetNofVertices();
return fVertices.size();
}
G4TwoVector G4UGenericTrap::GetVertex(G4int index) const
{
UVector2 v = GetShape()->GetVertex(index);
return G4TwoVector(v.x,v.y);
return G4TwoVector(GetVerticesX()[index], GetVerticesY()[index]);
}
const std::vector<G4TwoVector>& G4UGenericTrap::GetVertices() const
{
G4AutoLock l(&UGenericTrapMutex);
std::vector<UVector2> v = GetShape()->GetVertices();
static std::vector<G4TwoVector> vertices; vertices.clear();
for (size_t n=0; n<v.size(); ++n)
{
vertices.push_back(G4TwoVector(v[n].x,v[n].y));
}
return vertices;
return fVertices;
}
G4double G4UGenericTrap::GetTwistAngle(G4int index) const
{
return GetShape()->GetTwistAngle(index);
return GetTwist(index);
}
G4bool G4UGenericTrap::IsTwisted() const
{
return GetShape()->IsTwisted();
return !IsPlanar();
}
G4int G4UGenericTrap::GetVisSubdivisions() const
{
return GetShape()->GetVisSubdivisions();
return fVisSubdivisions;
}
void G4UGenericTrap::SetVisSubdivisions(G4int subdiv)
{
GetShape()->SetVisSubdivisions(subdiv);
fVisSubdivisions = subdiv;
}
void G4UGenericTrap::SetZHalfLength(G4double halfZ)
{
GetShape()->SetZHalfLength(halfZ);
SetDZ(halfZ);
}
void G4UGenericTrap::Initialise(const std::vector<G4TwoVector>& v)
{
G4double verticesx[8], verticesy[8];
for (G4int i=0; i<8; ++i)
{
fVertices.push_back(v[i]);
verticesx[i] = v[i].x();
verticesy[i] = v[i].y();
}
Initialize(verticesx, verticesy, GetZHalfLength());
}
/////////////////////////////////////////////////////////////////////////
//
// Get bounding box
void G4UGenericTrap::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4UGenericTrap::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
UVector3 vmin, vmax;
GetShape()->Extent(vmin,vmax);
U3Vector vmin, vmax;
Extent(vmin,vmax);
pMin.set(vmin.x(),vmin.y(),vmin.z());
pMax.set(vmax.x(),vmax.y(),vmax.z());
@@ -180,7 +181,8 @@ void G4UGenericTrap::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4UGenericTrap::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4UGenericTrap::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
StreamInfo(G4cout);
}
}
@@ -200,7 +202,7 @@ G4UGenericTrap::CalculateExtent(const EAxis pAxis,
// Check bounding box (bbox)
//
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
@@ -281,10 +283,8 @@ G4Polyhedron* G4UGenericTrap::CreatePolyhedron() const
// Computes bounding vectors for the shape
//
G4double Dx,Dy;
UVector3 minBox = GetShape()->GetMinimumBBox();
UVector3 maxBox = GetShape()->GetMaximumBBox();
G4ThreeVector minVec(minBox.x(), minBox.y(), minBox.z());
G4ThreeVector maxVec(maxBox.x(), maxBox.y(), maxBox.z());
G4ThreeVector minVec, maxVec;
BoundingLimits(minVec,maxVec);
Dx = 0.5*(maxVec.x()- minVec.y());
Dy = 0.5*(maxVec.y()- minVec.y());
if (Dy > Dx) { Dx=Dy; }
@@ -52,7 +52,7 @@ G4UParaboloid::G4UParaboloid(const G4String& pName,
G4double dz,
G4double rlo,
G4double rhi )
: G4USolid(pName, new UParaboloid(pName, rlo, rhi, dz))
: Base_t(pName, rlo, rhi, dz)
{ }
//////////////////////////////////////////////////////////////////////////
@@ -61,7 +61,7 @@ G4UParaboloid::G4UParaboloid(const G4String& pName,
// for usage restricted to object persistency.
G4UParaboloid::G4UParaboloid( __void__& a )
: G4USolid(a)
: Base_t(a)
{ }
//////////////////////////////////////////////////////////////////////////
@@ -75,7 +75,7 @@ G4UParaboloid::~G4UParaboloid() { }
// Copy constructor
G4UParaboloid::G4UParaboloid(const G4UParaboloid& rhs)
: G4USolid(rhs)
: Base_t(rhs)
{ }
//////////////////////////////////////////////////////////////////////////
@@ -90,7 +90,7 @@ G4UParaboloid& G4UParaboloid::operator = (const G4UParaboloid& rhs)
// Copy base class data
//
G4USolid::operator=(rhs);
Base_t::operator=(rhs);
return *this;
}
@@ -101,17 +101,36 @@ G4UParaboloid& G4UParaboloid::operator = (const G4UParaboloid& rhs)
G4double G4UParaboloid::GetZHalfLength() const
{
return GetShape()->GetDz();
return GetDz();
}
G4double G4UParaboloid::GetRadiusMinusZ() const
{
return GetShape()->GetRlo();
return GetRlo();
}
G4double G4UParaboloid::GetRadiusPlusZ() const
{
return GetShape()->GetRhi();
return GetRhi();
}
//////////////////////////////////////////////////////////////////////////
//
// Modifiers
void G4UParaboloid::SetZHalfLength(G4double dz)
{
SetDz(dz);
}
void G4UParaboloid::SetRadiusMinusZ(G4double r1)
{
SetRlo(r1);
}
void G4UParaboloid::SetRadiusPlusZ(G4double r2)
{
SetRhi(r2);
}
//////////////////////////////////////////////////////////////////////////
@@ -127,7 +146,8 @@ G4VSolid* G4UParaboloid::Clone() const
//
// Get bounding box
void G4UParaboloid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4UParaboloid::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
static G4bool checkBBox = true;
@@ -145,7 +165,8 @@ void G4UParaboloid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4UParaboloid::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4UParaboloid::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
StreamInfo(G4cout);
}
@@ -153,8 +174,8 @@ void G4UParaboloid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
//
if (checkBBox)
{
UVector3 vmin, vmax;
GetShape()->Extent(vmin,vmax);
U3Vector vmin, vmax;
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 ||
@@ -167,7 +188,8 @@ void G4UParaboloid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\nBBox min: wrapper = " << pMin << " solid = " << vmin
<< "\nBBox max: wrapper = " << pMax << " solid = " << vmax;
G4Exception("G4UParaboloid::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4UParaboloid::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
checkBBox = false;
}
}
@@ -186,7 +208,7 @@ G4UParaboloid::CalculateExtent(const EAxis pAxis,
G4ThreeVector bmin, bmax;
// Get bounding box
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
// Find extent
G4BoundingEnvelope bbox(bmin,bmax);
@@ -52,10 +52,15 @@ G4UPolycone::G4UPolycone( const G4String& name,
const G4double zPlane[],
const G4double rInner[],
const G4double rOuter[] )
: G4USolid(name, new UPolycone(name, phiStart, phiTotal,
numZPlanes, zPlane, rInner, rOuter))
: Base_t(name, phiStart, phiTotal, numZPlanes, zPlane, rInner, rOuter)
{
wrStart = phiStart; while (wrStart < 0) wrStart += twopi;
fGenericPcon = false;
SetOriginalParameters();
wrStart = phiStart;
while (wrStart < 0)
{
wrStart += twopi;
}
wrDelta = phiTotal;
if (wrDelta <= 0 || wrDelta >= twopi*(1-DBL_EPSILON))
{
@@ -90,8 +95,10 @@ G4UPolycone::G4UPolycone(const G4String& name,
G4int numRZ,
const G4double r[],
const G4double z[] )
: G4USolid(name, new UPolycone(name, phiStart, phiTotal, numRZ, r, z))
: Base_t(name, phiStart, phiTotal, numRZ, r, z)
{
fGenericPcon = true;
SetOriginalParameters();
wrStart = phiStart; while (wrStart < 0) wrStart += twopi;
wrDelta = phiTotal;
if (wrDelta <= 0 || wrDelta >= twopi*(1-DBL_EPSILON))
@@ -115,7 +122,7 @@ G4UPolycone::G4UPolycone(const G4String& name,
// for usage restricted to object persistency.
//
G4UPolycone::G4UPolycone( __void__& a )
: G4USolid(a)
: Base_t(a)
{
}
@@ -134,8 +141,10 @@ G4UPolycone::~G4UPolycone()
// Copy constructor
//
G4UPolycone::G4UPolycone( const G4UPolycone &source )
: G4USolid( source )
: Base_t( source )
{
fGenericPcon = source.fGenericPcon;
fOriginalParameters = source.fOriginalParameters;
wrStart = source.wrStart;
wrDelta = source.wrDelta;
rzcorners = source.rzcorners;
@@ -150,7 +159,9 @@ G4UPolycone &G4UPolycone::operator=( const G4UPolycone &source )
{
if (this == &source) return *this;
G4USolid::operator=( source );
Base_t::operator=( source );
fGenericPcon = source.fGenericPcon;
fOriginalParameters = source.fOriginalParameters;
wrStart = source.wrStart;
wrDelta = source.wrDelta;
rzcorners = source.rzcorners;
@@ -167,6 +178,10 @@ G4double G4UPolycone::GetStartPhi() const
{
return wrStart;
}
G4double G4UPolycone::GetDeltaPhi() const
{
return wrDelta;
}
G4double G4UPolycone::GetEndPhi() const
{
return (wrStart + wrDelta);
@@ -212,59 +227,79 @@ G4PolyconeSideRZ G4UPolycone::GetCorner(G4int index) const
}
G4PolyconeHistorical* G4UPolycone::GetOriginalParameters() const
{
UPolyconeHistorical* pars = GetShape()->GetOriginalParameters();
G4PolyconeHistorical* pdata = new G4PolyconeHistorical(pars->fNumZPlanes);
pdata->Start_angle = pars->fStartAngle;
pdata->Opening_angle = pars->fOpeningAngle;
for (G4int i=0; i<pars->fNumZPlanes; ++i)
return new G4PolyconeHistorical(fOriginalParameters);
}
void G4UPolycone::SetOriginalParameters()
{
G4int numPlanes = GetNSections()+1;
delete [] fOriginalParameters.Z_values;
delete [] fOriginalParameters.Rmin;
delete [] fOriginalParameters.Rmax;
fOriginalParameters.Z_values = new G4double[numPlanes];
fOriginalParameters.Rmin = new G4double[numPlanes];
fOriginalParameters.Rmax = new G4double[numPlanes];
for (G4int j=0; j<numPlanes; ++j)
{
pdata->Z_values[i] = pars->fZValues[i];
pdata->Rmin[i] = pars->Rmin[i];
pdata->Rmax[i] = pars->Rmax[i];
fOriginalParameters.Z_values[j] = GetZAtPlane(j);
fOriginalParameters.Rmax[j] = GetRmaxAtPlane(j);
fOriginalParameters.Rmin[j] = GetRminAtPlane(j);
}
return pdata;
fOriginalParameters.Start_angle = Base_t::GetStartPhi();
fOriginalParameters.Opening_angle = Base_t::GetDeltaPhi();
fOriginalParameters.Num_z_planes = numPlanes;
}
void G4UPolycone::SetOriginalParameters(G4PolyconeHistorical* pars)
{
UPolyconeHistorical* pdata = GetShape()->GetOriginalParameters();
pdata->fStartAngle = pars->Start_angle;
pdata->fOpeningAngle = pars->Opening_angle;
pdata->fNumZPlanes = pars->Num_z_planes;
for (G4int i=0; i<pdata->fNumZPlanes; ++i)
{
pdata->fZValues[i] = pars->Z_values[i];
pdata->Rmin[i] = pars->Rmin[i];
pdata->Rmax[i] = pars->Rmax[i];
}
fOriginalParameters = *pars;
fRebuildPolyhedron = true;
Reset();
}
wrStart = pdata->fStartAngle; while (wrStart < 0) wrStart += twopi;
wrDelta = pdata->fOpeningAngle;
G4bool G4UPolycone::Reset()
{
if (fGenericPcon)
{
std::ostringstream message;
message << "Solid " << GetName() << " built using generic construct."
<< G4endl << "Not applicable to the generic construct !";
G4Exception("G4UPolycone::Reset()", "GeomSolids1001",
JustWarning, message, "Parameters NOT resetted.");
return true; // error code set
}
//
// Rebuild polycone based on original parameters
//
wrStart = fOriginalParameters.Start_angle;
while (wrStart < 0)
{
wrStart += twopi;
}
wrDelta = fOriginalParameters.Opening_angle;
if (wrDelta <= 0 || wrDelta >= twopi*(1-DBL_EPSILON))
{
wrStart = 0;
wrDelta = twopi;
}
rzcorners.resize(0);
for (G4int i=0; i<pdata->fNumZPlanes; ++i)
for (G4int i=0; i<fOriginalParameters.Num_z_planes; ++i)
{
G4double z = pdata->fZValues[i];
G4double r = pdata->Rmax[i];
G4double z = fOriginalParameters.Z_values[i];
G4double r = fOriginalParameters.Rmax[i];
rzcorners.push_back(G4TwoVector(r,z));
}
for (G4int i=pdata->fNumZPlanes-1; i>=0; --i)
for (G4int i=fOriginalParameters.Num_z_planes-1; i>=0; --i)
{
G4double z = pdata->fZValues[i];
G4double r = pdata->Rmin[i];
G4double z = fOriginalParameters.Z_values[i];
G4double r = fOriginalParameters.Rmin[i];
rzcorners.push_back(G4TwoVector(r,z));
}
std::vector<G4int> iout;
G4GeomTools::RemoveRedundantVertices(rzcorners,iout,2*kCarTolerance);
}
G4bool G4UPolycone::Reset()
{
GetShape()->Reset();
return 0;
return false; // error code unset
}
////////////////////////////////////////////////////////////////////////
@@ -293,7 +328,8 @@ G4VSolid* G4UPolycone::Clone() const
//
// Get bounding box
void G4UPolycone::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4UPolycone::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
static G4bool checkBBox = true;
static G4bool checkPhi = true;
@@ -335,7 +371,8 @@ void G4UPolycone::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4UPolycone::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4UPolycone::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
StreamInfo(G4cout);
}
@@ -343,8 +380,8 @@ void G4UPolycone::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
//
if (checkBBox)
{
UVector3 vmin, vmax;
GetShape()->Extent(vmin,vmax);
U3Vector vmin, vmax;
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 ||
@@ -357,7 +394,8 @@ void G4UPolycone::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\nBBox min: wrapper = " << pMin << " solid = " << vmin
<< "\nBBox max: wrapper = " << pMax << " solid = " << vmax;
G4Exception("G4UPolycone::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4UPolycone::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
checkBBox = false;
}
}
@@ -366,20 +404,22 @@ void G4UPolycone::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
//
if (checkPhi)
{
if (GetStartPhi() != GetShape()->GetStartPhi() ||
GetEndPhi() != GetShape()->GetEndPhi() ||
IsOpen() != GetShape()->IsOpen())
if (GetStartPhi() != Base_t::GetStartPhi() ||
GetEndPhi() != Base_t::GetEndPhi() ||
IsOpen() != (Base_t::GetDeltaPhi() < twopi))
{
std::ostringstream message;
message << "Inconsistency in Phi angles or # of sides for solid: "
<< GetName() << " !"
<< "\nPhi start : wrapper = " << GetStartPhi()
<< " solid = " << GetShape()->GetStartPhi()
<< " solid = " << Base_t::GetStartPhi()
<< "\nPhi end : wrapper = " << GetEndPhi()
<< " solid = " << GetShape()->GetEndPhi()
<< " solid = " << Base_t::GetEndPhi()
<< "\nPhi is open: wrapper = " << (IsOpen() ? "true" : "false")
<< " solid = " << (GetShape()->IsOpen() ? "true" : "false");
G4Exception("G4UPolycone::Extent()", "GeomMgt0001", JustWarning, message);
<< " solid = "
<< ((Base_t::GetDeltaPhi() < twopi) ? "true" : "false");
G4Exception("G4UPolycone::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
checkPhi = false;
}
}
@@ -399,7 +439,7 @@ G4bool G4UPolycone::CalculateExtent(const EAxis pAxis,
// Check bounding box (bbox)
//
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
@@ -443,7 +483,7 @@ G4bool G4UPolycone::CalculateExtent(const EAxis pAxis,
// set trigonometric values
const G4int NSTEPS = 24; // number of steps for whole circle
G4double astep = (360/NSTEPS)*deg; // max angle for one step
G4double astep = twopi/NSTEPS; // max angle for one step
G4double sphi = GetStartPhi();
G4double ephi = GetEndPhi();
@@ -522,17 +562,13 @@ G4bool G4UPolycone::CalculateExtent(const EAxis pAxis,
//
G4Polyhedron* G4UPolycone::CreatePolyhedron() const
{
G4PolyconeHistorical* original_parameters = GetOriginalParameters();
G4PolyhedronPcon*
polyhedron = new G4PolyhedronPcon( original_parameters->Start_angle,
original_parameters->Opening_angle,
original_parameters->Num_z_planes,
original_parameters->Z_values,
original_parameters->Rmin,
original_parameters->Rmax );
delete original_parameters; // delete local copy
polyhedron = new G4PolyhedronPcon( fOriginalParameters.Start_angle,
fOriginalParameters.Opening_angle,
fOriginalParameters.Num_z_planes,
fOriginalParameters.Z_values,
fOriginalParameters.Rmin,
fOriginalParameters.Rmax );
return polyhedron;
}
@@ -35,6 +35,7 @@
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4GeomTools.hh"
#include "G4GeometryTolerance.hh"
#include "G4AffineTransform.hh"
#include "G4VPVParameterisation.hh"
#include "G4BoundingEnvelope.hh"
@@ -55,10 +56,16 @@ G4UPolyhedra::G4UPolyhedra(const G4String& name,
const G4double zPlane[],
const G4double rInner[],
const G4double rOuter[] )
: G4USolid(name, new UPolyhedra(name,phiStart, phiTotal, numSide,
numZPlanes, zPlane, rInner, rOuter))
: Base_t(name, phiStart, phiTotal, numSide,
numZPlanes, zPlane, rInner, rOuter)
{
wrStart = phiStart; while (wrStart < 0) wrStart += twopi;
fGenericPgon = false;
SetOriginalParameters();
wrStart = phiStart;
while (wrStart < 0)
{
wrStart += twopi;
}
wrDelta = phiTotal;
if (wrDelta <= 0 || wrDelta >= twopi*(1-DBL_EPSILON))
{
@@ -95,10 +102,15 @@ G4UPolyhedra::G4UPolyhedra(const G4String& name,
G4int numRZ,
const G4double r[],
const G4double z[] )
: G4USolid(name, new UPolyhedra(name, phiStart, phiTotal, numSide,
numRZ, r, z))
: Base_t(name, phiStart, phiTotal, numSide, numRZ/2, r, z)
{
wrStart = phiStart; while (wrStart < 0) wrStart += twopi;
fGenericPgon = true;
SetOriginalParameters();
wrStart = phiStart;
while (wrStart < 0)
{
wrStart += twopi;
}
wrDelta = phiTotal;
if (wrDelta <= 0 || wrDelta >= twopi*(1-DBL_EPSILON))
{
@@ -122,7 +134,7 @@ G4UPolyhedra::G4UPolyhedra(const G4String& name,
// for usage restricted to object persistency.
//
G4UPolyhedra::G4UPolyhedra( __void__& a )
: G4USolid(a)
: Base_t(a)
{
}
@@ -141,8 +153,10 @@ G4UPolyhedra::~G4UPolyhedra()
// Copy constructor
//
G4UPolyhedra::G4UPolyhedra( const G4UPolyhedra &source )
: G4USolid( source )
: Base_t( source )
{
fGenericPgon = source.fGenericPgon;
fOriginalParameters = source.fOriginalParameters;
wrStart = source.wrStart;
wrDelta = source.wrDelta;
wrNumSide = source.wrNumSide;
@@ -158,7 +172,9 @@ G4UPolyhedra& G4UPolyhedra::operator=( const G4UPolyhedra &source )
{
if (this == &source) return *this;
G4USolid::operator=( source );
Base_t::operator=( source );
fGenericPgon = source.fGenericPgon;
fOriginalParameters = source.fOriginalParameters;
wrStart = source.wrStart;
wrDelta = source.wrDelta;
wrNumSide = source.wrNumSide;
@@ -210,7 +226,7 @@ G4bool G4UPolyhedra::IsOpen() const
}
G4bool G4UPolyhedra::IsGeneric() const
{
return GetShape()->IsGeneric();
return fGenericPgon;
}
G4int G4UPolyhedra::GetNumRZCorner() const
{
@@ -225,61 +241,81 @@ G4PolyhedraSideRZ G4UPolyhedra::GetCorner(G4int index) const
}
G4PolyhedraHistorical* G4UPolyhedra::GetOriginalParameters() const
{
UPolyhedraHistorical* pars = GetShape()->GetOriginalParameters();
G4PolyhedraHistorical* pdata = new G4PolyhedraHistorical(pars->fNumZPlanes);
pdata->Start_angle = pars->fStartAngle;
pdata->Opening_angle = pars->fOpeningAngle;
pdata->numSide = pars->fNumSide;
for (G4int i=0; i<pars->fNumZPlanes; ++i)
return new G4PolyhedraHistorical(fOriginalParameters);
}
void G4UPolyhedra::SetOriginalParameters()
{
G4int numPlanes = GetZSegmentCount() + 1;
delete [] fOriginalParameters.Z_values;
delete [] fOriginalParameters.Rmin;
delete [] fOriginalParameters.Rmax;
fOriginalParameters.Z_values = new G4double[numPlanes];
fOriginalParameters.Rmin = new G4double[numPlanes];
fOriginalParameters.Rmax = new G4double[numPlanes];
for (G4int j=0; j<numPlanes; ++j)
{
pdata->Z_values[i] = pars->fZValues[i];
pdata->Rmin[i] = pars->Rmin[i];
pdata->Rmax[i] = pars->Rmax[i];
fOriginalParameters.Z_values[j] = GetZPlanes()[j];
fOriginalParameters.Rmax[j] = GetRMax()[j];
fOriginalParameters.Rmin[j] = GetRMin()[j];
}
return pdata;
fOriginalParameters.Start_angle = GetPhiStart();
fOriginalParameters.Opening_angle = GetPhiDelta();
fOriginalParameters.Num_z_planes = numPlanes;
fOriginalParameters.numSide = GetSideCount();
}
void G4UPolyhedra::SetOriginalParameters(G4PolyhedraHistorical* pars)
{
UPolyhedraHistorical* pdata = GetShape()->GetOriginalParameters();
pdata->fStartAngle = pars->Start_angle;
pdata->fOpeningAngle = pars->Opening_angle;
pdata->fNumSide = pars->numSide;
pdata->fNumZPlanes = pars->Num_z_planes;
for (G4int i=0; i<pdata->fNumZPlanes; ++i)
{
pdata->fZValues[i] = pars->Z_values[i];
pdata->Rmin[i] = pars->Rmin[i];
pdata->Rmax[i] = pars->Rmax[i];
}
fOriginalParameters = *pars;
fRebuildPolyhedron = true;
Reset();
}
wrStart = pdata->fStartAngle; while (wrStart < 0) wrStart += twopi;
wrDelta = pdata->fOpeningAngle;
G4bool G4UPolyhedra::Reset()
{
if (fGenericPgon)
{
std::ostringstream message;
message << "Solid " << GetName() << " built using generic construct."
<< G4endl << "Not applicable to the generic construct !";
G4Exception("G4UPolyhedra::Reset()", "GeomSolids1001",
JustWarning, message, "Parameters NOT resetted.");
return true; // error code set
}
//
// Rebuild polyhedra based on original parameters
//
wrStart = fOriginalParameters.Start_angle;
while (wrStart < 0)
{
wrStart += twopi;
}
wrDelta = fOriginalParameters.Opening_angle;
if (wrDelta <= 0 || wrDelta >= twopi*(1-DBL_EPSILON))
{
wrDelta = twopi;
}
wrNumSide = pdata->fNumSide;
wrNumSide = fOriginalParameters.numSide;
G4double convertRad = 1./std::cos(0.5*wrDelta/wrNumSide);
rzcorners.resize(0);
for (G4int i=0; i<pdata->fNumZPlanes; ++i)
for (G4int i=0; i<fOriginalParameters.Num_z_planes; ++i)
{
G4double z = pdata->fZValues[i];
G4double r = pdata->Rmax[i]*convertRad;
G4double z = fOriginalParameters.Z_values[i];
G4double r = fOriginalParameters.Rmax[i]*convertRad;
rzcorners.push_back(G4TwoVector(r,z));
}
for (G4int i=pdata->fNumZPlanes-1; i>=0; --i)
for (G4int i=fOriginalParameters.Num_z_planes-1; i>=0; --i)
{
G4double z = pdata->fZValues[i];
G4double r = pdata->Rmin[i]*convertRad;
G4double z = fOriginalParameters.Z_values[i];
G4double r = fOriginalParameters.Rmin[i]*convertRad;
rzcorners.push_back(G4TwoVector(r,z));
}
std::vector<G4int> iout;
G4GeomTools::RemoveRedundantVertices(rzcorners,iout,2*kCarTolerance);
}
G4bool G4UPolyhedra::Reset()
{
return GetShape()->Reset();
return false; // error code unset
}
@@ -310,7 +346,8 @@ G4VSolid* G4UPolyhedra::Clone() const
//
// Get bounding box
void G4UPolyhedra::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4UPolyhedra::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
static G4bool checkBBox = true;
static G4bool checkPhi = true;
@@ -372,7 +409,8 @@ void G4UPolyhedra::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4UPolyhedra::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4UPolyhedra::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
StreamInfo(G4cout);
}
@@ -380,8 +418,8 @@ void G4UPolyhedra::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
//
if (checkBBox)
{
UVector3 vmin, vmax;
GetShape()->Extent(vmin,vmax);
U3Vector vmin, vmax;
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 ||
@@ -394,7 +432,8 @@ void G4UPolyhedra::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\nBBox min: wrapper = " << pMin << " solid = " << vmin
<< "\nBBox max: wrapper = " << pMax << " solid = " << vmax;
G4Exception("G4UPolyhedra::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4UPolyhedra::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
checkBBox = false;
}
}
@@ -403,23 +442,25 @@ void G4UPolyhedra::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
//
if (checkPhi)
{
if (GetStartPhi() != GetShape()->GetStartPhi() ||
GetEndPhi() != GetShape()->GetEndPhi() ||
IsOpen() != GetShape()->IsOpen() ||
GetNumSide() != GetShape()->GetNumSide())
if (GetStartPhi() != GetPhiStart() ||
GetEndPhi() != GetPhiEnd() ||
GetNumSide() != GetSideCount() ||
IsOpen() != (Base_t::GetPhiDelta() < twopi))
{
std::ostringstream message;
message << "Inconsistency in Phi angles or # of sides for solid: "
<< GetName() << " !"
<< "\nPhi start : wrapper = " << GetStartPhi()
<< " solid = " << GetShape()->GetStartPhi()
<< " solid = " << GetPhiStart()
<< "\nPhi end : wrapper = " << GetEndPhi()
<< " solid = " << GetShape()->GetEndPhi()
<< "\nPhi is open: wrapper = " << (IsOpen() ? "true" : "false")
<< " solid = " << (GetShape()->IsOpen() ? "true" : "false")
<< " solid = " << GetPhiEnd()
<< "\nPhi # sides: wrapper = " << GetNumSide()
<< " solid = " << GetShape()->GetNumSide();
G4Exception("G4UPolyhedra::Extent()", "GeomMgt0001", JustWarning, message);
<< " solid = " << GetSideCount()
<< "\nPhi is open: wrapper = " << (IsOpen() ? "true" : "false")
<< " solid = "
<< ((Base_t::GetPhiDelta() < twopi) ? "true" : "false");
G4Exception("G4UPolyhedra::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
checkPhi = false;
}
}
@@ -440,7 +481,7 @@ G4UPolyhedra::CalculateExtent(const EAxis pAxis,
// Check bounding box (bbox)
//
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
@@ -552,17 +593,13 @@ G4Polyhedron* G4UPolyhedra::CreatePolyhedron() const
{
if (!IsGeneric())
{
G4PolyhedraHistorical* original_parameters = GetOriginalParameters();
G4PolyhedronPgon*
polyhedron = new G4PolyhedronPgon( GetOriginalParameters()->Start_angle,
GetOriginalParameters()->Opening_angle,
GetOriginalParameters()->numSide,
GetOriginalParameters()->Num_z_planes,
GetOriginalParameters()->Z_values,
GetOriginalParameters()->Rmin,
GetOriginalParameters()->Rmax);
delete original_parameters; // delete local copy
return polyhedron;
return new G4PolyhedronPgon( fOriginalParameters.Start_angle,
fOriginalParameters.Opening_angle,
fOriginalParameters.numSide,
fOriginalParameters.Num_z_planes,
fOriginalParameters.Z_values,
fOriginalParameters.Rmin,
fOriginalParameters.Rmax);
}
else
{
@@ -132,7 +132,7 @@ std::vector<G4ThreeVector> G4UTet::GetVertices() const
//
// Get bounding box
void G4UTet::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
void G4UTet::BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const
{
UVector3 vmin, vmax;
GetShape()->Extent(vmin,vmax);
@@ -148,7 +148,8 @@ void G4UTet::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4UTet::Extent()", "GeomMgt0001", JustWarning, message);
G4Exception("G4UTet::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
StreamInfo(G4cout);
}
}
@@ -168,7 +169,7 @@ G4UTet::CalculateExtent(const EAxis pAxis,
// Check bounding box (bbox)
//
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
G4BoundingEnvelope bbox(bmin,bmax);
#ifdef G4BBOX_EXTENT
if (true) return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VTwistSurface.cc 98326 2016-07-07 07:47:15Z gcosmo $
// $Id: G4VTwistSurface.cc 104105 2017-05-11 08:23:18Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -172,8 +172,8 @@ G4int G4VTwistSurface::AmIOnLeftSide(const G4ThreeVector &me,
= G4GeometryTolerance::GetInstance()->GetAngularTolerance();
G4RotationMatrix unitrot;
static const G4RotationMatrix rottol = unitrot.rotateZ(0.5*kAngTolerance);
static const G4RotationMatrix invrottol = unitrot.rotateZ(-1.*kAngTolerance);
const G4RotationMatrix rottol = unitrot.rotateZ(0.5*kAngTolerance);
const G4RotationMatrix invrottol = unitrot.rotateZ(-1.*kAngTolerance);
if (fAmIOnLeftSide.me == me
&& fAmIOnLeftSide.vec == vec
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VTwistedFaceted.cc 99781 2016-10-05 10:18:54Z gcosmo $
// $Id: G4VTwistedFaceted.cc 104316 2017-05-24 13:04:23Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -302,8 +302,8 @@ void G4VTwistedFaceted::ComputeDimensions(G4VPVParameterisation* ,
//=====================================================================
//* Extent ------------------------------------------------------------
void G4VTwistedFaceted::Extent(G4ThreeVector &pMin,
G4ThreeVector &pMax) const
void G4VTwistedFaceted::BoundingLimits(G4ThreeVector &pMin,
G4ThreeVector &pMax) const
{
G4double maxRad = std::sqrt(fDx*fDx + fDy*fDy);
pMin.set(-maxRad,-maxRad,-fDz);
@@ -324,7 +324,7 @@ G4VTwistedFaceted::CalculateExtent( const EAxis pAxis,
G4ThreeVector bmin, bmax;
// Get bounding box
Extent(bmin,bmax);
BoundingLimits(bmin,bmax);
// Find extent
G4BoundingEnvelope bbox(bmin,bmax);
File diff suppressed because it is too large Load Diff