Import Geant4 10.4.0.beta source tree
This commit is contained in:
@@ -122,11 +122,11 @@ class G4GeomSplitter
|
||||
}
|
||||
|
||||
void SlaveReCopySubInstanceArray()
|
||||
// Invoked by each worker thread at start of a run (2nd or later)
|
||||
// to copy again all the subinstance array from the master thread.
|
||||
// To cope with user's changes in Geometry - e.g. change of material in a volume
|
||||
// Invoked by each worker thread at start of a run (2nd or later)
|
||||
// to copy again all the subinstance array from the master thread.
|
||||
// To cope with user's changes in Geometry - e.g. change of material
|
||||
// in a volume
|
||||
{
|
||||
G4AutoLock l(&mutex);
|
||||
if (!offset)
|
||||
{
|
||||
SlaveInitializeSubInstance();
|
||||
@@ -134,7 +134,6 @@ class G4GeomSplitter
|
||||
"MissingInitialisation", JustWarning,
|
||||
"Must be called after Initialisation or first Copy.");
|
||||
}
|
||||
l.unlock();
|
||||
CopyMasterContents();
|
||||
}
|
||||
|
||||
@@ -146,14 +145,13 @@ class G4GeomSplitter
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Extension - to allow sharing of workspaces - John Apostolakis 28 May 2013
|
||||
// Extension - to allow sharing of workspaces
|
||||
|
||||
T* GetOffset() { return offset; }
|
||||
T* GetOffset() { return offset; }
|
||||
|
||||
void UseWorkArea( T* newOffset ) // , G4int numObjects, G4int numSpace)
|
||||
{
|
||||
void UseWorkArea( T* newOffset )
|
||||
// Use recycled work area - which was created previously
|
||||
{
|
||||
if( offset && offset!=newOffset )
|
||||
{
|
||||
G4Exception("G4GeomSplitter::UseWorkspace()",
|
||||
@@ -161,25 +159,15 @@ class G4GeomSplitter
|
||||
"Thread already has workspace - cannot use another.");
|
||||
}
|
||||
offset= newOffset;
|
||||
// totalobj= numObjects;
|
||||
// totalspace= numSpace;
|
||||
}
|
||||
|
||||
T* FreeWorkArea() // G4int* numObjects, G4int* numSpace)
|
||||
{
|
||||
// Detach this thread from this Location
|
||||
T* FreeWorkArea()
|
||||
// Detach this thread from this Location.
|
||||
// The object which calls this method is responsible for it.
|
||||
//
|
||||
T* offsetRet= offset;
|
||||
|
||||
offset= 0;
|
||||
|
||||
return offsetRet;
|
||||
}
|
||||
|
||||
void Destroy()
|
||||
{
|
||||
|
||||
T* offsetRet= offset;
|
||||
offset= 0;
|
||||
return offsetRet;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -108,7 +108,7 @@ class G4GeomTools
|
||||
G4TwoVectorList& result);
|
||||
|
||||
static G4bool TriangulatePolygon(const G4TwoVectorList& polygon,
|
||||
std::vector<G4int>& result);
|
||||
std::vector<G4int>& result);
|
||||
// Simple implementation of "ear clipping" algorithm for
|
||||
// triangulation of a simple contour/polygon, it places results
|
||||
// in a std::vector as triplets of vertices. If triangulation
|
||||
@@ -123,7 +123,7 @@ class G4GeomTools
|
||||
static G4bool DiskExtent(G4double rmin, G4double rmax,
|
||||
G4double startPhi, G4double delPhi,
|
||||
G4TwoVector& pmin, G4TwoVector& pmax);
|
||||
// Calculate bounding square of a disk sector,
|
||||
// Calculate bounding rectangle of a disk sector,
|
||||
// it returns false if input parameters do not meet the following:
|
||||
// rmin >= 0
|
||||
// rmax > rmin + kCarTolerance
|
||||
@@ -133,46 +133,67 @@ class G4GeomTools
|
||||
G4double sinPhiStart, G4double cosPhiStart,
|
||||
G4double sinPhiEnd, G4double cosPhiEnd,
|
||||
G4TwoVector& pmin, G4TwoVector& pmax);
|
||||
// Calculate bounding square of a disk sector,
|
||||
// Calculate bounding rectangle of a disk sector,
|
||||
// faster version without check of parameters
|
||||
|
||||
static G4double EllipsePerimeter(G4double a,
|
||||
G4double b);
|
||||
// Compute the circumference (perimeter) of an ellipse
|
||||
|
||||
static G4double EllipticConeLateralArea(G4double a,
|
||||
G4double b,
|
||||
G4double h);
|
||||
// Compute the lateral surface area of an elliptic cone
|
||||
|
||||
// ==================================================================
|
||||
// 3D Utilities
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
static G4ThreeVector TriangleAreaNormal(const G4ThreeVector& A,
|
||||
const G4ThreeVector& B,
|
||||
const G4ThreeVector& C);
|
||||
// Calcuate normal to the plane of of 3D triangle ABC with
|
||||
// length equal to its area
|
||||
// Find the normal to the plane of 3D triangle ABC,
|
||||
// length of the normal is equal to the area of the triangle
|
||||
|
||||
static G4ThreeVector QuadAreaNormal(const G4ThreeVector& A,
|
||||
const G4ThreeVector& B,
|
||||
const G4ThreeVector& C,
|
||||
const G4ThreeVector& D);
|
||||
// Calcuate normal to the plane of 3D quadrilateral ABCD with
|
||||
// length equal to its area
|
||||
// Find normal to the plane of 3D quadrilateral ABCD,
|
||||
// length of the normal is equal to the area of the quadrilateral
|
||||
|
||||
static G4ThreeVector PolygonAreaNormal(const G4ThreeVectorList& polygon);
|
||||
// Calcuate normal to the plane of 3D polygon with
|
||||
// length equal to its area
|
||||
// Find normal to the plane of 3D polygon
|
||||
// length of the normal is equal to the area of the polygon
|
||||
|
||||
/*
|
||||
static G4bool IsPlanar(const G4ThreeVector& A,
|
||||
const G4ThreeVector& B,
|
||||
const G4ThreeVector& C,
|
||||
const G4ThreeVector& D);
|
||||
// Decide if 3D quadrilateral ABCD is planar
|
||||
|
||||
static G4bool IsPlanar(const G4ThreeVectorList& polygon);
|
||||
static G4bool IsPlanar(const G4ThreeVectorList& polygon
|
||||
const G4ThreeVector& normal);
|
||||
// Decide if 3D polygon is planar
|
||||
*/
|
||||
|
||||
static G4double DistancePointSegment(G4ThreeVector P,
|
||||
G4ThreeVector A,
|
||||
G4ThreeVector B);
|
||||
static G4double DistancePointSegment(const G4ThreeVector& P,
|
||||
const G4ThreeVector& A,
|
||||
const G4ThreeVector& B);
|
||||
// Calculate distance between point P and line segment AB in 3D
|
||||
|
||||
static G4ThreeVector ClosestPointOnSegment(const G4ThreeVector& P,
|
||||
const G4ThreeVector& A,
|
||||
const G4ThreeVector& B);
|
||||
// Find point on 3D line segment AB closest to point P
|
||||
|
||||
static G4ThreeVector ClosestPointOnTriangle(const G4ThreeVector& P,
|
||||
const G4ThreeVector& A,
|
||||
const G4ThreeVector& B,
|
||||
const G4ThreeVector& C);
|
||||
// Find point on 3D triangle ABC closest to point P
|
||||
|
||||
static G4bool SphereExtent(G4double rmin, G4double rmax,
|
||||
G4double startTheta, G4double delTheta,
|
||||
G4double startPhi, G4double delPhi,
|
||||
@@ -191,6 +212,9 @@ class G4GeomTools
|
||||
G4int a, G4int b, G4int c,
|
||||
G4int n, const G4int* V);
|
||||
// Helper function for TriangulatePolygon()
|
||||
|
||||
static G4double comp_ellint_2(G4double e);
|
||||
// Complete Elliptic Integral of the Second Kind
|
||||
};
|
||||
|
||||
#endif // G4GEOMTOOLS_HH
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GeometryManager.hh 66872 2013-01-15 01:25:57Z japost $
|
||||
// $Id: G4GeometryManager.hh 103235 2017-03-22 15:53:48Z gcosmo $
|
||||
//
|
||||
// class G4GeometryManager
|
||||
//
|
||||
@@ -37,8 +37,8 @@
|
||||
//
|
||||
// Member data:
|
||||
//
|
||||
// static G4GeometryManager* fgInstance
|
||||
// - Ptr to the unique instance of class
|
||||
// - fgInstance
|
||||
// Ptr to the unique instance of class
|
||||
|
||||
// Author:
|
||||
// 26.07.95 P.Kent Initial version, including optimisation Build
|
||||
@@ -67,7 +67,7 @@ class G4GeometryManager
|
||||
// present. Applies to just a specific subtree if a physical volume is
|
||||
// specified.
|
||||
|
||||
G4bool IsGeometryClosed();
|
||||
static G4bool IsGeometryClosed();
|
||||
// Return true/false according to state of optimised geoemtry.
|
||||
|
||||
void SetWorldMaximumExtent(G4double worldExtent);
|
||||
@@ -75,11 +75,21 @@ class G4GeometryManager
|
||||
// allowed only if NO solids have been created already.
|
||||
|
||||
static G4GeometryManager* GetInstance();
|
||||
// Return ptr to singleton instance of the class.
|
||||
// Return ptr to singleton instance of the class, creating it if
|
||||
// not existing.
|
||||
|
||||
static G4GeometryManager* GetInstanceIfExist();
|
||||
// Return ptr to singleton instance.
|
||||
|
||||
public: // without description
|
||||
|
||||
~G4GeometryManager();
|
||||
// Destructor.
|
||||
|
||||
protected:
|
||||
|
||||
G4GeometryManager();
|
||||
// Protected constructor
|
||||
|
||||
private:
|
||||
|
||||
@@ -90,7 +100,7 @@ class G4GeometryManager
|
||||
static void ReportVoxelStats( std::vector<G4SmartVoxelStat> & stats,
|
||||
G4double totalCpuTime );
|
||||
static G4ThreadLocal G4GeometryManager* fgInstance;
|
||||
G4bool fIsClosed;
|
||||
static G4ThreadLocal G4bool fIsClosed;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4LogicalVolume.hh 100397 2016-10-20 07:34:38Z gcosmo $
|
||||
// $Id: G4LogicalVolume.hh 103096 2017-03-15 15:21:33Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4LogicalVolume
|
||||
@@ -360,14 +360,12 @@ class G4LogicalVolume
|
||||
|
||||
inline G4int GetInstanceID() const;
|
||||
// Returns the instance ID.
|
||||
static const G4LVManager& GetSubInstanceManager();
|
||||
|
||||
// Sets the private data instance manager - in order to use a particular Workspace
|
||||
|
||||
// static const G4LVManager* GetSubInstanceManagerPtr();
|
||||
// static const G4LVManager SetSubInstanceManager(G4LVManager* subInstanceManager);
|
||||
// Revised Implementation - to enable Workspaces which can used by different
|
||||
// threads at different times (only one thread or task can use a workspace at a time. )
|
||||
static const G4LVManager& GetSubInstanceManager();
|
||||
// Returns the private data instance manager.
|
||||
|
||||
static void Clean();
|
||||
// Clear memory allocated by sub-instance manager.
|
||||
|
||||
inline void Lock();
|
||||
// Set lock identifier for final deletion of entity.
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4LogicalVolumeStore.hh 66872 2013-01-15 01:25:57Z japost $
|
||||
// $Id: G4LogicalVolumeStore.hh 103096 2017-03-15 15:21:33Z gcosmo $
|
||||
//
|
||||
// class G4LogicalVolumeStore
|
||||
//
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4PhysicalVolumeStore.hh 66872 2013-01-15 01:25:57Z japost $
|
||||
// $Id: G4PhysicalVolumeStore.hh 103096 2017-03-15 15:21:33Z gcosmo $
|
||||
//
|
||||
// class G4PhysicalVolume
|
||||
//
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ReflectedSolid.hh 100906 2016-11-03 09:59:32Z gcosmo $
|
||||
// $Id: G4ReflectedSolid.hh 104317 2017-05-24 13:08:38Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4ReflectedSolid
|
||||
@@ -63,7 +63,7 @@ class G4ReflectedSolid : public G4VSolid
|
||||
|
||||
EInside Inside( 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,
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Region.hh 99379 2016-09-20 09:45:19Z gcosmo $
|
||||
// $Id: G4Region.hh 103096 2017-03-15 15:21:33Z gcosmo $
|
||||
//
|
||||
// class G4Region
|
||||
//
|
||||
@@ -226,6 +226,9 @@ class G4Region
|
||||
static const G4RegionManager& GetSubInstanceManager();
|
||||
// Returns the private data instance manager.
|
||||
|
||||
static void Clean();
|
||||
// Clear memory allocated by sub-instance manager.
|
||||
|
||||
inline void UsedInMassGeometry(G4bool val=true);
|
||||
inline void UsedInParallelGeometry(G4bool val=true);
|
||||
inline G4bool IsInMassGeometry() const;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4RegionStore.hh 89814 2015-04-30 14:49:43Z gcosmo $
|
||||
// $Id: G4RegionStore.hh 103096 2017-03-15 15:21:33Z gcosmo $
|
||||
//
|
||||
// class G4RegionStore
|
||||
//
|
||||
|
||||
@@ -0,0 +1,549 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id:$
|
||||
//
|
||||
//
|
||||
// class G4UAdapter
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Utility class for adapting VecGeom solids API to Geant4 solids.
|
||||
// NOTE: Using protected inheritance since the Adapter is supposed to
|
||||
// be a G4VSolid "implemented-in-terms-of" the VecGeom UnplacedVolume_t.
|
||||
// The choice of protected vs private is due to the fact that we want
|
||||
// to propagate functions further down in the inheritance hierarchy.
|
||||
|
||||
// Author:
|
||||
// 17.05.17 G.Cosmo: Adapted for G4VSolid from original G4USolids bridge
|
||||
// class and the USolidsAdapter class in VecGeom.
|
||||
// ------------------------------------------------------------------------
|
||||
#ifndef G4UADAPTER_HH
|
||||
#define G4UADAPTER_HH
|
||||
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4VSolid.hh"
|
||||
|
||||
// Required for inline visualization adapter functions
|
||||
//
|
||||
#include "G4AffineTransform.hh"
|
||||
#include "G4VoxelLimits.hh"
|
||||
#include "G4VGraphicsScene.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "G4VisExtent.hh"
|
||||
#include "G4BoundingEnvelope.hh"
|
||||
#include "G4AutoLock.hh"
|
||||
|
||||
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
|
||||
|
||||
#include <base/Global.h>
|
||||
#include <base/Vector3D.h>
|
||||
|
||||
class G4VPVParameterisation;
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
class G4UAdapter : public G4VSolid, protected UnplacedVolume_t
|
||||
{
|
||||
public:
|
||||
|
||||
typedef vecgeom::Vector3D<G4double> U3Vector;
|
||||
|
||||
using UnplacedVolume_t::operator delete;
|
||||
using UnplacedVolume_t::operator new;
|
||||
// VecGeom volumes have special delete/new ("AlignedBase")
|
||||
// and we need to make these functions public again
|
||||
|
||||
G4UAdapter(const G4String& name)
|
||||
: G4VSolid(name), fRebuildPolyhedron(false), fPolyhedron(0)
|
||||
{ kHalfTolerance = 0.5*kCarTolerance; }
|
||||
|
||||
template <typename... T>
|
||||
G4UAdapter(const G4String& name, const T &... params)
|
||||
: G4VSolid(name), UnplacedVolume_t(params...),
|
||||
fRebuildPolyhedron(false), fPolyhedron(0)
|
||||
{ kHalfTolerance = 0.5*kCarTolerance; }
|
||||
|
||||
virtual ~G4UAdapter();
|
||||
|
||||
G4bool operator==(const G4UAdapter& s) const;
|
||||
// Return true only if addresses are the same.
|
||||
|
||||
virtual G4bool CalculateExtent(const EAxis pAxis,
|
||||
const G4VoxelLimits& pVoxelLimit,
|
||||
const G4AffineTransform& pTransform,
|
||||
G4double& pMin, G4double& pMax) const override;
|
||||
// Calculate the minimum and maximum extent of the solid, when under the
|
||||
// specified transform, and within the specified limits. If the solid
|
||||
// is not intersected by the region, return false, else return true.
|
||||
|
||||
virtual EInside Inside(const G4ThreeVector& p) const override;
|
||||
// Returns kOutside if the point at offset p is outside the shapes
|
||||
// boundaries plus Tolerance/2, kSurface if the point is <= Tolerance/2
|
||||
// from a surface, otherwise kInside.
|
||||
|
||||
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
|
||||
// Returns the outwards pointing unit normal of the shape for the
|
||||
// surface closest to the point at offset p.
|
||||
|
||||
virtual G4double DistanceToIn(const G4ThreeVector& p,
|
||||
const G4ThreeVector& v) const override;
|
||||
// Return the distance along the normalised vector v to the shape,
|
||||
// from the point at offset p. If there is no intersection, return
|
||||
// kInfinity. The first intersection resulting from `leaving' a
|
||||
// surface/volume is discarded. Hence, it is tolerant of points on
|
||||
// the surface of the shape.
|
||||
|
||||
virtual G4double DistanceToIn(const G4ThreeVector& p) const override;
|
||||
// Calculate the distance to the nearest surface of a shape from an
|
||||
// outside point. The distance can be an underestimate.
|
||||
|
||||
virtual G4double DistanceToOut(const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm = false,
|
||||
G4bool* validNorm = 0,
|
||||
G4ThreeVector* n = 0) const override;
|
||||
// Return the distance along the normalised vector v to the shape,
|
||||
// from a point at an offset p inside or on the surface of the shape.
|
||||
// Intersections with surfaces, when the point is < Tolerance/2 from a
|
||||
// surface must be ignored.
|
||||
// If calcNorm==true:
|
||||
// validNorm set true if the solid lies entirely behind or on the
|
||||
// exiting surface.
|
||||
// n set to exiting outwards normal vector (undefined Magnitude).
|
||||
// validNorm set to false if the solid does not lie entirely behind
|
||||
// or on the exiting surface
|
||||
// If calcNorm==false:
|
||||
// validNorm and n are unused.
|
||||
//
|
||||
// Must be called as solid.DistanceToOut(p,v) or by specifying all
|
||||
// the parameters.
|
||||
|
||||
virtual G4double DistanceToOut(const G4ThreeVector& p) const override;
|
||||
// Calculate the distance to the nearest surface of a shape from an
|
||||
// inside point. The distance can be an underestimate.
|
||||
|
||||
virtual void ComputeDimensions(G4VPVParameterisation* p,
|
||||
const G4int n,
|
||||
const G4VPhysicalVolume* pRep) override;
|
||||
// Throw exception if ComputeDimensions called from an illegal
|
||||
// derived class.
|
||||
|
||||
virtual G4double GetCubicVolume() override;
|
||||
// Returns an estimation of the solid volume in internal units.
|
||||
// This method may be overloaded by derived classes to compute the
|
||||
// exact geometrical quantity for solids where this is possible,
|
||||
// or anyway to cache the computed value.
|
||||
// Note: the computed value is NOT cached.
|
||||
|
||||
virtual G4double GetSurfaceArea() override;
|
||||
// Return an estimation of the solid surface area in internal units.
|
||||
// This method may be overloaded by derived classes to compute the
|
||||
// exact geometrical quantity for solids where this is possible,
|
||||
// or anyway to cache the computed value.
|
||||
// Note: the computed value is NOT cached.
|
||||
|
||||
virtual G4ThreeVector GetPointOnSurface() const override;
|
||||
// Returns a random point located on the surface of the solid.
|
||||
|
||||
virtual G4GeometryType GetEntityType() const override;
|
||||
// Provide identification of the class of an object.
|
||||
// (required for persistency)
|
||||
|
||||
virtual G4VSolid* Clone() const override;
|
||||
// Returns a pointer of a dynamically allocated copy of the solid.
|
||||
// Returns NULL pointer with warning in case the concrete solid does not
|
||||
// implement this method. The caller has responsibility for ownership.
|
||||
|
||||
virtual std::ostream& StreamInfo(std::ostream& os) const override;
|
||||
// Dumps contents of the solid to a stream.
|
||||
|
||||
virtual void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
|
||||
// A "double dispatch" function which identifies the solid
|
||||
// to the graphics scene for visualization.
|
||||
|
||||
virtual G4VisExtent GetExtent() const override;
|
||||
// Provide extent (bounding box) as possible hint to the graphics view.
|
||||
virtual G4Polyhedron* CreatePolyhedron() const override;
|
||||
// Create Polyhedron used for Visualisation
|
||||
virtual G4Polyhedron* GetPolyhedron() const override;
|
||||
// Smart access function - creates on request and stores for future
|
||||
// access. A null pointer means "not available".
|
||||
|
||||
public: // without description
|
||||
|
||||
G4UAdapter(__void__&);
|
||||
// Fake default constructor for usage restricted to direct object
|
||||
// persistency for clients requiring preallocation of memory for
|
||||
// persistifiable objects.
|
||||
|
||||
G4UAdapter(const G4UAdapter& rhs);
|
||||
G4UAdapter& operator=(const G4UAdapter& rhs);
|
||||
// Copy constructor and assignment operator.
|
||||
|
||||
public: // VecGeom overridden methods
|
||||
|
||||
vecgeom::Precision
|
||||
DistanceToOut(U3Vector const &position, U3Vector const &direction,
|
||||
vecgeom::Precision stepMax = kInfinity) const override
|
||||
{
|
||||
return UnplacedVolume_t::DistanceToOut(position, direction, stepMax);
|
||||
}
|
||||
|
||||
vecgeom::EnumInside
|
||||
Inside(U3Vector const &aPoint) const override
|
||||
{
|
||||
return UnplacedVolume_t::Inside(aPoint);
|
||||
}
|
||||
|
||||
vecgeom::Precision
|
||||
DistanceToIn(U3Vector const &position, U3Vector const &direction,
|
||||
const vecgeom::Precision step_max = kInfinity) const override
|
||||
{
|
||||
return UnplacedVolume_t::DistanceToIn(position, direction, step_max);
|
||||
}
|
||||
|
||||
G4bool Normal(U3Vector const &aPoint, U3Vector &aNormal) const override
|
||||
{
|
||||
return UnplacedVolume_t::Normal(aPoint, aNormal);
|
||||
}
|
||||
|
||||
void Extent(U3Vector &aMin, U3Vector &aMax) const override
|
||||
{
|
||||
return UnplacedVolume_t::Extent(aMin, aMax);
|
||||
}
|
||||
|
||||
U3Vector SamplePointOnSurface() const override
|
||||
{
|
||||
return UnplacedVolume_t::SamplePointOnSurface();
|
||||
}
|
||||
|
||||
protected: // data
|
||||
|
||||
mutable G4bool fRebuildPolyhedron;
|
||||
mutable G4Polyhedron* fPolyhedron;
|
||||
|
||||
G4double kHalfTolerance; // Cached geometrical tolerance
|
||||
|
||||
using UnplacedVolume_t::DistanceToOut;
|
||||
using UnplacedVolume_t::DistanceToIn;
|
||||
};
|
||||
|
||||
// Inline implementations
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4UAdapter<UnplacedVolume_t>::G4UAdapter(__void__& a)
|
||||
: G4VSolid(a), UnplacedVolume_t(*this),
|
||||
fRebuildPolyhedron(false), fPolyhedron(0),
|
||||
kHalfTolerance(0.5*kCarTolerance)
|
||||
{
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4UAdapter<UnplacedVolume_t>::~G4UAdapter()
|
||||
{
|
||||
delete fPolyhedron; fPolyhedron = 0;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4bool G4UAdapter<UnplacedVolume_t>::
|
||||
operator==(const G4UAdapter& rhs) const
|
||||
{
|
||||
return (this == &rhs) ? true : false;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4UAdapter<UnplacedVolume_t>::
|
||||
G4UAdapter(const G4UAdapter& rhs)
|
||||
: G4VSolid(rhs), UnplacedVolume_t(rhs),
|
||||
fRebuildPolyhedron(false), fPolyhedron(0)
|
||||
{
|
||||
kHalfTolerance = 0.5*kCarTolerance;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4UAdapter<UnplacedVolume_t>& G4UAdapter<UnplacedVolume_t>::
|
||||
operator=(const G4UAdapter& rhs)
|
||||
{
|
||||
// Check assignment to self
|
||||
//
|
||||
if (this == &rhs)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Copy base class data
|
||||
//
|
||||
G4VSolid::operator=(rhs);
|
||||
|
||||
// Copy data
|
||||
//
|
||||
fRebuildPolyhedron = false;
|
||||
delete fPolyhedron; fPolyhedron = 0;
|
||||
kHalfTolerance = 0.5*kCarTolerance;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
EInside G4UAdapter<UnplacedVolume_t>::
|
||||
Inside(const G4ThreeVector& p) const
|
||||
{
|
||||
U3Vector pt(p.x(), p.y(), p.z());
|
||||
vecgeom::EnumInside in_temp;
|
||||
EInside in = kOutside;
|
||||
|
||||
in_temp = UnplacedVolume_t::Inside(pt);
|
||||
|
||||
if (in_temp == vecgeom::EnumInside::eInside) in = kInside;
|
||||
else if (in_temp == vecgeom::EnumInside::eSurface) in = kSurface;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4ThreeVector G4UAdapter<UnplacedVolume_t>::
|
||||
SurfaceNormal(const G4ThreeVector& pt) const
|
||||
{
|
||||
U3Vector p(pt.x(), pt.y(), pt.z());
|
||||
U3Vector n;
|
||||
UnplacedVolume_t::Normal(p, n);
|
||||
return G4ThreeVector(n.x(), n.y(), n.z());
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4double G4UAdapter<UnplacedVolume_t>::
|
||||
DistanceToIn(const G4ThreeVector& pt, const G4ThreeVector& d) const
|
||||
{
|
||||
U3Vector p(pt.x(), pt.y(), pt.z());
|
||||
U3Vector v(d.x(), d.y(), d.z());
|
||||
G4double dist = UnplacedVolume_t::DistanceToIn(p, v, kInfinity);
|
||||
|
||||
// apply Geant4 distance conventions
|
||||
//
|
||||
if (dist < kHalfTolerance) return 0.0;
|
||||
return (dist > kInfinity) ? kInfinity : dist;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4double G4UAdapter<UnplacedVolume_t>::
|
||||
DistanceToIn(const G4ThreeVector& pt) const
|
||||
{
|
||||
U3Vector p(pt.x(), pt.y(), pt.z());
|
||||
G4double dist = UnplacedVolume_t::SafetyToIn(p);
|
||||
|
||||
// Apply Geant4 convention: convert negative values to zero
|
||||
//
|
||||
if (dist < kHalfTolerance) return 0.0;
|
||||
return (dist > kInfinity) ? kInfinity : dist;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4double G4UAdapter<UnplacedVolume_t>::
|
||||
DistanceToOut(const G4ThreeVector& pt, const G4ThreeVector& d,
|
||||
const G4bool calcNorm, G4bool* validNorm,
|
||||
G4ThreeVector* norm) const
|
||||
{
|
||||
U3Vector p(pt.x(), pt.y(), pt.z());
|
||||
U3Vector v(d.x(), d.y(), d.z());
|
||||
|
||||
G4double dist = UnplacedVolume_t::DistanceToOut(p, v, kInfinity);
|
||||
if(calcNorm) // *norm=n, but only after calcNorm check and if convex volume
|
||||
{
|
||||
if (UnplacedVolume_t::IsConvex())
|
||||
{
|
||||
U3Vector n, hitpoint = p + dist * v;
|
||||
UnplacedVolume_t::Normal(hitpoint, n);
|
||||
*validNorm = true;
|
||||
norm->set(n.x(), n.y(), n.z());
|
||||
}
|
||||
else
|
||||
{
|
||||
*validNorm = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply Geant4 distance conventions
|
||||
//
|
||||
if (dist < kHalfTolerance) return 0.0;
|
||||
return (dist > kInfinity) ? kInfinity : dist;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4double G4UAdapter<UnplacedVolume_t>::
|
||||
DistanceToOut(const G4ThreeVector& pt) const
|
||||
{
|
||||
U3Vector p(pt.x(), pt.y(), pt.z());
|
||||
G4double dist = UnplacedVolume_t::SafetyToOut(p);
|
||||
|
||||
// Apply Geant4 convention: convert negative values to zero
|
||||
//
|
||||
if (dist < kHalfTolerance) return 0.0;
|
||||
return (dist > kInfinity) ? kInfinity : dist;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4double G4UAdapter<UnplacedVolume_t>::GetCubicVolume()
|
||||
{
|
||||
return UnplacedVolume_t::Capacity();
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4double G4UAdapter<UnplacedVolume_t>::GetSurfaceArea()
|
||||
{
|
||||
return UnplacedVolume_t::SurfaceArea();
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4ThreeVector G4UAdapter<UnplacedVolume_t>::GetPointOnSurface() const
|
||||
{
|
||||
U3Vector p = UnplacedVolume_t::SamplePointOnSurface();;
|
||||
return G4ThreeVector(p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
// Inline visualization adapters
|
||||
|
||||
namespace
|
||||
{
|
||||
G4Mutex pMutex = G4MUTEX_INITIALIZER;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
void G4UAdapter<UnplacedVolume_t>::
|
||||
ComputeDimensions(G4VPVParameterisation*, const G4int,
|
||||
const G4VPhysicalVolume*)
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Illegal call to G4UAdapter::ComputeDimensions()" << G4endl
|
||||
<< "Method not overloaded by derived class !";
|
||||
G4Exception("G4UAdapter::ComputeDimensions()", "GeomSolids0003",
|
||||
FatalException, message);
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
void G4UAdapter<UnplacedVolume_t>::
|
||||
DescribeYourselfTo(G4VGraphicsScene& scene) const
|
||||
{
|
||||
scene.AddSolid(*this);
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4GeometryType G4UAdapter<UnplacedVolume_t>::
|
||||
GetEntityType() const
|
||||
{
|
||||
|
||||
G4String string = "VSolid"; // UnplacedVolume_t::GetEntityType();
|
||||
return "G4" + string;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
std::ostream& G4UAdapter<UnplacedVolume_t>::
|
||||
StreamInfo(std::ostream& os) const
|
||||
{
|
||||
UnplacedVolume_t::Print(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4VSolid* G4UAdapter<UnplacedVolume_t>::Clone() const
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Clone() method not implemented for type: "
|
||||
<< GetEntityType() << "!" << G4endl
|
||||
<< "Returning NULL pointer!";
|
||||
G4Exception("G4UAdapter::Clone()", "GeomSolids1001", JustWarning, message);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4bool G4UAdapter<UnplacedVolume_t>::CalculateExtent(const EAxis pAxis,
|
||||
const G4VoxelLimits& pVoxelLimit,
|
||||
const G4AffineTransform& pTransform,
|
||||
G4double& pMin, G4double& pMax) const
|
||||
{
|
||||
U3Vector vmin, vmax;
|
||||
UnplacedVolume_t::Extent(vmin,vmax);
|
||||
G4ThreeVector bmin(vmin.x(),vmin.y(),vmin.z());
|
||||
G4ThreeVector bmax(vmax.x(),vmax.y(),vmax.z());
|
||||
|
||||
// Check correctness of the bounding box
|
||||
//
|
||||
if (bmin.x() >= bmax.x() || bmin.y() >= bmax.y() || bmin.z() >= bmax.z())
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Bad bounding box (min >= max) for solid: "
|
||||
<< GetName() << " - " << GetEntityType() << " !"
|
||||
<< "\nmin = " << bmin
|
||||
<< "\nmax = " << bmax;
|
||||
G4Exception("G4UAdapter::CalculateExtent()", "GeomMgt0001",
|
||||
JustWarning, message);
|
||||
StreamInfo(G4cout);
|
||||
}
|
||||
|
||||
G4BoundingEnvelope bbox(bmin,bmax);
|
||||
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4Polyhedron* G4UAdapter<UnplacedVolume_t>::CreatePolyhedron() const
|
||||
{
|
||||
// Must be implemented in concrete wrappers...
|
||||
|
||||
std::ostringstream message;
|
||||
message << "Visualization not supported for USolid shape "
|
||||
<< GetEntityType() << "... Sorry!" << G4endl;
|
||||
G4Exception("G4UAdapter::CreatePolyhedron()", "GeomSolids0003",
|
||||
FatalException, message);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4Polyhedron* G4UAdapter<UnplacedVolume_t>::GetPolyhedron() const
|
||||
{
|
||||
if (!fPolyhedron ||
|
||||
fRebuildPolyhedron ||
|
||||
fPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
|
||||
fPolyhedron->GetNumberOfRotationSteps())
|
||||
{
|
||||
G4AutoLock l(&pMutex);
|
||||
delete fPolyhedron;
|
||||
fPolyhedron = CreatePolyhedron();
|
||||
fRebuildPolyhedron = false;
|
||||
l.unlock();
|
||||
}
|
||||
return fPolyhedron;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4VisExtent G4UAdapter<UnplacedVolume_t>::GetExtent() const
|
||||
{
|
||||
U3Vector vmin, vmax;
|
||||
UnplacedVolume_t::Extent(vmin,vmax);
|
||||
return G4VisExtent(vmin.x(),vmax.x(),
|
||||
vmin.y(),vmax.y(),
|
||||
vmin.z(),vmax.z());
|
||||
}
|
||||
|
||||
#endif // G4GEOM_USE_USOLIDS
|
||||
|
||||
#endif // G4UADAPTER_HH
|
||||
@@ -183,6 +183,132 @@ class G4USolid : public G4VSolid
|
||||
mutable G4Polyhedron* fPolyhedron;
|
||||
};
|
||||
|
||||
// Inline implementations
|
||||
|
||||
inline
|
||||
EInside G4USolid::Inside(const G4ThreeVector& p) const
|
||||
{
|
||||
UVector3 pt;
|
||||
VUSolid::EnumInside in_temp;
|
||||
EInside in = kOutside;
|
||||
pt.x() = p.x();
|
||||
pt.y() = p.y();
|
||||
pt.z() = p.z(); // better assign at construction
|
||||
|
||||
in_temp = fShape->Inside(pt);
|
||||
|
||||
if (in_temp == VUSolid::EnumInside::eInside) in = kInside;
|
||||
else if (in_temp == VUSolid::EnumInside::eSurface) in = kSurface;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
inline
|
||||
G4ThreeVector G4USolid::SurfaceNormal(const G4ThreeVector& pt) const
|
||||
{
|
||||
UVector3 p;
|
||||
p.x() = pt.x();
|
||||
p.y() = pt.y();
|
||||
p.z() = pt.z();
|
||||
UVector3 n;
|
||||
fShape->Normal(p, n);
|
||||
return G4ThreeVector(n.x(), n.y(), n.z());
|
||||
}
|
||||
|
||||
inline
|
||||
G4double G4USolid::DistanceToIn(const G4ThreeVector& pt,
|
||||
const G4ThreeVector& d) const
|
||||
{
|
||||
UVector3 p;
|
||||
p.x() = pt.x();
|
||||
p.y() = pt.y();
|
||||
p.z() = pt.z(); // better assign at construction
|
||||
UVector3 v;
|
||||
v.x() = d.x();
|
||||
v.y() = d.y();
|
||||
v.z() = d.z(); // better assign at construction
|
||||
G4double dist = fShape->DistanceToIn(p, v);
|
||||
// return (dist > halfTolerance) ? dist : 0.0;
|
||||
return (dist > kInfinity) ? kInfinity : dist;
|
||||
}
|
||||
|
||||
inline
|
||||
G4double G4USolid::DistanceToIn(const G4ThreeVector& pt) const
|
||||
{
|
||||
UVector3 p;
|
||||
p.x() = pt.x();
|
||||
p.y() = pt.y();
|
||||
p.z() = pt.z(); // better assign at construction
|
||||
G4double dist = fShape->SafetyFromOutside(p); // true?
|
||||
// return (dist > halfTolerance) ? dist : 0.0;
|
||||
return (dist > kInfinity) ? kInfinity : dist;
|
||||
}
|
||||
|
||||
inline
|
||||
G4double G4USolid::DistanceToOut(const G4ThreeVector& pt,
|
||||
const G4ThreeVector& d,
|
||||
const G4bool calcNorm,
|
||||
G4bool* validNorm,
|
||||
G4ThreeVector* norm) const
|
||||
{
|
||||
UVector3 p;
|
||||
p.x() = pt.x();
|
||||
p.y() = pt.y();
|
||||
p.z() = pt.z(); // better assign at construction
|
||||
UVector3 v;
|
||||
v.x() = d.x();
|
||||
v.y() = d.y();
|
||||
v.z() = d.z(); // better assign at construction
|
||||
UVector3 n;
|
||||
G4bool valid;
|
||||
G4double dist = fShape->DistanceToOut(p, v, n, valid); // should use local variable
|
||||
if(calcNorm)
|
||||
{
|
||||
if(valid){ *validNorm = true; }
|
||||
else { *validNorm = false; }
|
||||
if(*validNorm) // *norm = n, but only after calcNorm check
|
||||
{
|
||||
norm->setX(n.x());
|
||||
norm->setY(n.y());
|
||||
norm->setZ(n.z());
|
||||
}
|
||||
}
|
||||
// return (dist > halfTolerance) ? dist : 0.0;
|
||||
return (dist > kInfinity) ? kInfinity : dist;
|
||||
}
|
||||
|
||||
inline
|
||||
G4double G4USolid::DistanceToOut(const G4ThreeVector& pt) const
|
||||
{
|
||||
UVector3 p;
|
||||
p.x() = pt.x();
|
||||
p.y() = pt.y();
|
||||
p.z() = pt.z(); // better assign at construction
|
||||
G4double dist = fShape->SafetyFromInside(p); // true?
|
||||
// return (dist > halfTolerance) ? dist : 0.0;
|
||||
return dist;
|
||||
}
|
||||
|
||||
inline
|
||||
G4double G4USolid::GetCubicVolume()
|
||||
{
|
||||
return fShape->Capacity();
|
||||
}
|
||||
|
||||
inline
|
||||
G4double G4USolid::GetSurfaceArea()
|
||||
{
|
||||
return fShape->SurfaceArea();
|
||||
}
|
||||
|
||||
inline
|
||||
G4ThreeVector G4USolid::GetPointOnSurface() const
|
||||
{
|
||||
UVector3 p;
|
||||
p = fShape->GetPointOnSurface();
|
||||
return G4ThreeVector(p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
#endif // G4GEOM_USE_USOLIDS
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VPhysicalVolume.hh 99379 2016-09-20 09:45:19Z gcosmo $
|
||||
// $Id: G4VPhysicalVolume.hh 103096 2017-03-15 15:21:33Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4VPhysicalVolume
|
||||
@@ -212,6 +212,9 @@ class G4VPhysicalVolume
|
||||
static const G4PVManager& GetSubInstanceManager();
|
||||
// Returns the private data instance manager.
|
||||
|
||||
static void Clean();
|
||||
// Clear memory allocated by sub-instance manager.
|
||||
|
||||
protected:
|
||||
|
||||
void InitialiseWorker(G4VPhysicalVolume *pMasterObject,
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VSolid.hh 100906 2016-11-03 09:59:32Z gcosmo $
|
||||
// $Id: G4VSolid.hh 104317 2017-05-24 13:08:38Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4VSolid
|
||||
@@ -108,7 +108,7 @@ class G4VSolid
|
||||
inline G4double GetTolerance() const;
|
||||
// Returns the cached geometrical tolerance.
|
||||
|
||||
virtual void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
|
||||
virtual void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
|
||||
// Returns the bounding box of the solid.
|
||||
|
||||
virtual G4bool CalculateExtent(const EAxis pAxis,
|
||||
|
||||
Reference in New Issue
Block a user