Import Geant4 10.4.0.beta source tree
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
$Id: History 101700 2016-11-21 16:16:14Z gcosmo $
|
||||
$Id: History 104670 2017-06-09 10:01:02Z gcosmo $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -17,6 +17,64 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
June 9, 2017 G.Cosmo geommng-V10-03-18
|
||||
- Corrections and improvements to G4UAdapter.
|
||||
|
||||
June 1, 2017 G.Cosmo geommng-V10-03-17
|
||||
- Made G4UAdapter compliant with latest modifications in VecGeom for
|
||||
renaming of GetPointOnSurface() method to SamplePointOnSurface().
|
||||
|
||||
May 24, 2017 G.Cosmo geommng-V10-03-16
|
||||
- Renamed ambiguous name Extent() in G4VSolid to BoundingLimits().
|
||||
Modified G4ReflectedSolid accordingly.
|
||||
Change required in order to avoid signature conflict with VecGeom
|
||||
in G4U* wrappers.
|
||||
|
||||
May 24, 2017 G.Cosmo geommng-V10-03-15
|
||||
- Added adapter class G4UAdapter for interfacing G4U* wrappers with VecGeom.
|
||||
Will replace G4USolid bridge class, deprecating USolids API in favour of
|
||||
direct use of VecGeom signatures and removal of one extra-level of
|
||||
indirection/inheritance.
|
||||
|
||||
May 9, 2017 G.Cosmo geommng-V10-03-14
|
||||
- Moved few key methods to be inline in G4USolid.
|
||||
|
||||
March 28, 2017 G.Cosmo geommng-V10-03-13
|
||||
- Enabled deletion of solids in G4SolidsStore destructor also for MT mode.
|
||||
|
||||
March 22, 2017 G.Cosmo geommng-V10-03-12
|
||||
- Define IsGeometryClosed() in G4GeometryManager as a static method, to
|
||||
avoid call to GetInstance(). Made related Boolean flag thread-local.
|
||||
|
||||
March 21, 2017 G.Cosmo geommng-V10-03-11, 10
|
||||
- Restore singleton pointer to thread-local and provide simple accessor to it.
|
||||
|
||||
March 17, 2017 G.Cosmo geommng-V10-03-09
|
||||
- Define G4GeometryManager as normal singleton.
|
||||
|
||||
March 15, 2017 G.Cosmo geommng-V10-03-08
|
||||
- Refined deletion of subinstance offsets in stores.
|
||||
|
||||
March 14, 2017 G.Cosmo geommng-V10-03-07
|
||||
- Removed additional wrong lock in G4GeomSplitter for function
|
||||
SlaveReCopySubInstanceArray().
|
||||
- Disable cleaning of subinstance offsets on Windows.
|
||||
|
||||
March 10, 2017 G.Cosmo geommng-V10-03-06,5,4,3
|
||||
- Fixed static memory leak from G4LogicalVolume, G4VPhysicalVolume and
|
||||
G4Region, for offsets allocated in sequential mode.
|
||||
|
||||
February 27, 2017 E.Tcherniaev geommng-V10-03-02
|
||||
- Added functions EllipsePerimeter(), EllipticConeLateralArea() and
|
||||
comp_ellint_2() to G4GeomTools.
|
||||
|
||||
December 16, 2016 G.Cosmo geommng-V10-03-01
|
||||
- Fixed compilation warning on gcc-6.2 for last changes in G4GeomTools.
|
||||
|
||||
December 14, 2016 E.Tcherniaev geommng-V10-03-00
|
||||
- Added methods TriangelAreaNormal(), QuadAreaNormal(), PolygonAreaNormal(),
|
||||
ClosestPointOnSegment() and ClosestPointOnTriangle() to G4GeomTools.
|
||||
|
||||
November 8, 2016 G.Cosmo geommng-V10-02-32
|
||||
- Fixed header inclusions in G4LogicalCrystalVolume and make use of
|
||||
dynamic_cast instead of C-style cast.
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# Generated on : 24/9/2010
|
||||
#
|
||||
# $Id: sources.cmake 100683 2016-10-31 10:56:21Z gcosmo $
|
||||
# $Id: sources.cmake 104304 2017-05-24 08:57:31Z gcosmo $
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@@ -69,6 +69,7 @@ GEANT4_DEFINE_MODULE(NAME G4geometrymng
|
||||
G4SmartVoxelStat.hh
|
||||
G4SolidStore.hh
|
||||
G4TouchableHandle.hh
|
||||
G4UAdapter.hh
|
||||
G4USolid.hh
|
||||
G4VCurvedTrajectoryFilter.hh
|
||||
G4VNestedParameterisation.hh
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
// $Id: $
|
||||
//
|
||||
//
|
||||
// class G4GeomTools Implementation
|
||||
// class G4GeomTools implementation
|
||||
//
|
||||
// Author: evgueni.tcherniaev@cern.ch
|
||||
//
|
||||
@@ -81,11 +81,12 @@ G4double G4GeomTools::QuadArea(const G4TwoVector& A,
|
||||
|
||||
G4double G4GeomTools::PolygonArea(const G4TwoVectorList& p)
|
||||
{
|
||||
G4double area = 0.0;
|
||||
G4int n = p.size();
|
||||
for(G4int i=0,k=n-1; i<n; k=i,++i)
|
||||
if (n < 3) return 0; // degerate polygon
|
||||
G4double area = p[n-1].x()*p[0].y() - p[0].x()*p[n-1].y();
|
||||
for(G4int i=1; i<n; ++i)
|
||||
{
|
||||
area += p[k].x()*p[i].y() - p[i].x()*p[k].y();
|
||||
area += p[i-1].x()*p[i].y() - p[i].x()*p[i-1].y();
|
||||
}
|
||||
return area*0.5;
|
||||
}
|
||||
@@ -192,7 +193,7 @@ G4bool G4GeomTools::TriangulatePolygon(const G4TwoVectorList& polygon,
|
||||
// Triangulation of a simple polygon by "ear clipping"
|
||||
|
||||
G4bool G4GeomTools::TriangulatePolygon(const G4TwoVectorList& polygon,
|
||||
std::vector<G4int>& result)
|
||||
std::vector<G4int>& result)
|
||||
{
|
||||
result.resize(0);
|
||||
|
||||
@@ -283,9 +284,6 @@ G4bool G4GeomTools::CheckSnip(const G4TwoVectorList& contour,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Remove collinear and coincident points from 2D polygon
|
||||
@@ -346,7 +344,7 @@ void G4GeomTools::RemoveRedundantVertices(G4TwoVectorList& polygon,
|
||||
G4double area = std::abs(e1.x()*e2.y()-e1.y()*e2.x())*0.5;
|
||||
if (area/std::sqrt(lmax) <= std::abs(tolerance))
|
||||
{
|
||||
polygon[icur].setX(removeIt); nout++;
|
||||
polygon[icur].setX(removeIt); nout++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -373,7 +371,7 @@ void G4GeomTools::RemoveRedundantVertices(G4TwoVectorList& polygon,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Find bounding box of a disk sector
|
||||
// Find bounding rectangle of a disk sector
|
||||
|
||||
G4bool G4GeomTools::DiskExtent(G4double rmin, G4double rmax,
|
||||
G4double startPhi, G4double delPhi,
|
||||
@@ -405,7 +403,7 @@ G4bool G4GeomTools::DiskExtent(G4double rmin, G4double rmax,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Find bounding box of a disk sector, fast version.
|
||||
// Find bounding rectangle of a disk sector, fast version.
|
||||
// No check of parameters !!!
|
||||
|
||||
void G4GeomTools::DiskExtent(G4double rmin, G4double rmax,
|
||||
@@ -513,13 +511,117 @@ void G4GeomTools::DiskExtent(G4double rmin, G4double rmax,
|
||||
return;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Compute the circumference (perimeter) of an ellipse
|
||||
|
||||
G4double G4GeomTools::EllipsePerimeter(G4double pA, G4double pB)
|
||||
{
|
||||
G4double x = std::abs(pA);
|
||||
G4double y = std::abs(pB);
|
||||
G4double a = std::max(x,y);
|
||||
G4double b = std::min(x,y);
|
||||
G4double e = std::sqrt((1. - b/a)*(1. + b/a));
|
||||
return 4. * a * comp_ellint_2(e);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Compute the lateral surface area of an elliptic cone
|
||||
|
||||
G4double G4GeomTools::EllipticConeLateralArea(G4double pA,
|
||||
G4double pB,
|
||||
G4double pH)
|
||||
{
|
||||
G4double x = std::abs(pA);
|
||||
G4double y = std::abs(pB);
|
||||
G4double h = std::abs(pH);
|
||||
G4double a = std::max(x,y);
|
||||
G4double b = std::min(x,y);
|
||||
G4double e = std::sqrt((1. - b/a)*(1. + b/a)) / std::hypot(1.,b/h);
|
||||
return 2. * a * std::hypot(b,h) * comp_ellint_2(e);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Compute Elliptical Integral of the Second Kind
|
||||
//
|
||||
// The algorithm is based upon Carlson B.C., "Computation of real
|
||||
// or complex elliptic integrals", Numerical Algorithms,
|
||||
// Volume 10, Issue 1, 1995 (see equations 2.36 - 2.39)
|
||||
//
|
||||
// The code was adopted from C code at:
|
||||
// http://paulbourke.net/geometry/ellipsecirc/
|
||||
|
||||
G4double G4GeomTools::comp_ellint_2(G4double e)
|
||||
{
|
||||
const G4double eps = 1. / 134217728.; // 1 / 2^27
|
||||
|
||||
G4double a = 1.;
|
||||
G4double b = std::sqrt((1. - e)*(1. + e));
|
||||
if (b == 1.) return CLHEP::halfpi;
|
||||
if (b == 0.) return 1.;
|
||||
|
||||
G4double x = 1.;
|
||||
G4double y = b;
|
||||
G4double S = 0.;
|
||||
G4double M = 1.;
|
||||
while (x - y > eps*y) {
|
||||
G4double tmp = (x + y) * 0.5;
|
||||
y = std::sqrt(x*y);
|
||||
x = tmp;
|
||||
M += M;
|
||||
S += M * (x - y)*(x - y);
|
||||
}
|
||||
return 0.5 * CLHEP::halfpi * ((a + b)*(a + b) - S) / (x + y);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Calcuate area of a triangle in 3D
|
||||
|
||||
G4ThreeVector G4GeomTools::TriangleAreaNormal(const G4ThreeVector& A,
|
||||
const G4ThreeVector& B,
|
||||
const G4ThreeVector& C)
|
||||
{
|
||||
return ((B-A).cross(C-A))*0.5;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Calcuate area of a quadrilateral in 3D
|
||||
|
||||
G4ThreeVector G4GeomTools::QuadAreaNormal(const G4ThreeVector& A,
|
||||
const G4ThreeVector& B,
|
||||
const G4ThreeVector& C,
|
||||
const G4ThreeVector& D)
|
||||
{
|
||||
return ((C-A).cross(D-B))*0.5;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Calculate area of a polygon in 3D
|
||||
|
||||
G4ThreeVector G4GeomTools::PolygonAreaNormal(const G4ThreeVectorList& p)
|
||||
{
|
||||
G4int n = p.size();
|
||||
if (n < 3) return G4ThreeVector(0,0,0); // degerate polygon
|
||||
G4ThreeVector normal = p[n-1].cross(p[0]);
|
||||
for(G4int i=1; i<n; ++i)
|
||||
{
|
||||
normal += p[i-1].cross(p[i]);
|
||||
}
|
||||
return normal*0.5;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Calculate distance between point P and line segment AB in 3D
|
||||
|
||||
G4double G4GeomTools::DistancePointSegment(G4ThreeVector P,
|
||||
G4ThreeVector A,
|
||||
G4ThreeVector B)
|
||||
G4double G4GeomTools::DistancePointSegment(const G4ThreeVector& P,
|
||||
const G4ThreeVector& A,
|
||||
const G4ThreeVector& B)
|
||||
{
|
||||
G4ThreeVector AP = P - A;
|
||||
G4ThreeVector AB = B - A;
|
||||
@@ -533,6 +635,137 @@ G4double G4GeomTools::DistancePointSegment(G4ThreeVector P,
|
||||
return ((u/len2)*AB - AP).mag(); // distance to line
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Find closest point on line segment in 3D
|
||||
|
||||
G4ThreeVector
|
||||
G4GeomTools::ClosestPointOnSegment(const G4ThreeVector& P,
|
||||
const G4ThreeVector& A,
|
||||
const G4ThreeVector& B)
|
||||
{
|
||||
G4ThreeVector AP = P - A;
|
||||
G4ThreeVector AB = B - A;
|
||||
|
||||
G4double u = AP.dot(AB);
|
||||
if (u <= 0) return A; // closest point is A
|
||||
|
||||
G4double len2 = AB.mag2();
|
||||
if (u >= len2) return B; // closest point is B
|
||||
|
||||
G4double t = u/len2;
|
||||
return A + t*AB; // closest point on segment
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Find closest point on triangle in 3D.
|
||||
//
|
||||
// The implementation is based on the algorithm published in
|
||||
// "Geometric Tools for Computer Graphics", Philip J Scheider and
|
||||
// David H Eberly, Elsevier Science (USA), 2003.
|
||||
//
|
||||
// The algorithm is also available at:
|
||||
// http://www.geometrictools.com/Documentation/DistancePoint3Triangle3.pdf
|
||||
|
||||
G4ThreeVector
|
||||
G4GeomTools::ClosestPointOnTriangle(const G4ThreeVector& P,
|
||||
const G4ThreeVector& A,
|
||||
const G4ThreeVector& B,
|
||||
const G4ThreeVector& C)
|
||||
{
|
||||
G4ThreeVector diff = A - P;
|
||||
G4ThreeVector edge0 = B - A;
|
||||
G4ThreeVector edge1 = C - A;
|
||||
|
||||
G4double a = edge0.mag2();
|
||||
G4double b = edge0.dot(edge1);
|
||||
G4double c = edge1.mag2();
|
||||
G4double d = diff.dot(edge0);
|
||||
G4double e = diff.dot(edge1);
|
||||
|
||||
G4double det = a*c - b*b;
|
||||
G4double t0 = b*e - c*d;
|
||||
G4double t1 = b*d - a*e;
|
||||
|
||||
/*
|
||||
^ t1
|
||||
\ 2 |
|
||||
\ |
|
||||
\ | regions
|
||||
\|
|
||||
C
|
||||
|\
|
||||
3 | \ 1
|
||||
| \
|
||||
| 0 \
|
||||
| \
|
||||
---- A --- B ----> t0
|
||||
| \
|
||||
4 | 5 \ 6
|
||||
| \
|
||||
*/
|
||||
|
||||
G4int region = -1;
|
||||
if (t0+t1 <= det)
|
||||
region = (t0 < 0) ? ((t1 < 0) ? 4 : 3) : ((t1 < 0) ? 5 : 0);
|
||||
else
|
||||
region = (t0 < 0) ? 2 : ((t1 < 0) ? 6 : 1);
|
||||
|
||||
switch (region)
|
||||
{
|
||||
case 0: // interior of triangle
|
||||
{
|
||||
G4double invDet = 1./det;
|
||||
return A + (t0*invDet)*edge0 + (t1*invDet)*edge1;
|
||||
}
|
||||
case 1: // edge BC
|
||||
{
|
||||
G4double numer = c + e - b - d;
|
||||
if (numer <= 0) return C;
|
||||
G4double denom = a - 2*b + c;
|
||||
return (numer >= denom) ? B : C + (numer/denom)*(edge0-edge1);
|
||||
}
|
||||
case 2: // edge AC or BC
|
||||
{
|
||||
G4double tmp0 = b + d;
|
||||
G4double tmp1 = c + e;
|
||||
if (tmp1 > tmp0)
|
||||
{
|
||||
G4double numer = tmp1 - tmp0;
|
||||
G4double denom = a - 2*b + c;
|
||||
return (numer >= denom) ? B : C + (numer/denom)*(edge0-edge1);
|
||||
}
|
||||
// same: (e >= 0) ? A : ((-e >= c) ? C : A + (-e/c)*edge1)
|
||||
return (tmp1 <= 0) ? C : (( e >= 0) ? A : A + (-e/c)*edge1);
|
||||
}
|
||||
case 3: // edge AC
|
||||
return (e >= 0) ? A : ((-e >= c) ? C : A + (-e/c)*edge1);
|
||||
|
||||
case 4: // edge AB or AC
|
||||
if (d < 0) return (-d >= a) ? B : A + (-d/a)*edge0;
|
||||
return (e >= 0) ? A : ((-e >= c) ? C : A + (-e/c)*edge1);
|
||||
|
||||
case 5: // edge AB
|
||||
return (d >= 0) ? A : ((-d >= a) ? B : A + (-d/a)*edge0);
|
||||
|
||||
case 6: // edge AB or BC
|
||||
{
|
||||
G4double tmp0 = b + e;
|
||||
G4double tmp1 = a + d;
|
||||
if (tmp1 > tmp0)
|
||||
{
|
||||
G4double numer = tmp1 - tmp0;
|
||||
G4double denom = a - 2*b + c;
|
||||
return (numer >= denom) ? C : B + (numer/denom)*(edge1-edge0);
|
||||
}
|
||||
// same: (d >= 0) ? A : ((-d >= a) ? B : A + (-d/a)*edge0)
|
||||
return (tmp1 <= 0) ? B : (( d >= 0) ? A : A + (-d/a)*edge0);
|
||||
}
|
||||
default: // impossible case
|
||||
return G4ThreeVector(kInfinity,kInfinity,kInfinity);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GeometryManager.cc 67975 2013-03-13 10:19:44Z gcosmo $
|
||||
// $Id: G4GeometryManager.cc 103235 2017-03-22 15:53:48Z gcosmo $
|
||||
//
|
||||
// class G4GeometryManager
|
||||
//
|
||||
@@ -57,20 +57,30 @@
|
||||
#include "G4VSolid.hh"
|
||||
|
||||
// ***************************************************************************
|
||||
// Static class variable: ptr to single instance of class
|
||||
// Static class data
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4ThreadLocal G4GeometryManager* G4GeometryManager::fgInstance = 0;
|
||||
G4ThreadLocal G4bool G4GeometryManager::fIsClosed = false;
|
||||
|
||||
// ***************************************************************************
|
||||
// Constructor. Set the geometry to be open
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4GeometryManager::G4GeometryManager()
|
||||
: fIsClosed(false)
|
||||
{
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Destructor
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4GeometryManager::~G4GeometryManager()
|
||||
{
|
||||
fgInstance = 0;
|
||||
fIsClosed = false;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Closes geometry - performs sanity checks and optionally builds optimisation
|
||||
// for placed volumes (always built for replicas & parameterised).
|
||||
@@ -81,7 +91,7 @@ G4GeometryManager::G4GeometryManager()
|
||||
G4bool G4GeometryManager::CloseGeometry(G4bool pOptimise, G4bool verbose,
|
||||
G4VPhysicalVolume* pVolume)
|
||||
{
|
||||
if (!fIsClosed)
|
||||
if (!fIsClosed)
|
||||
{
|
||||
if (pVolume)
|
||||
{
|
||||
@@ -138,7 +148,16 @@ G4GeometryManager* G4GeometryManager::GetInstance()
|
||||
{
|
||||
fgInstance = new G4GeometryManager;
|
||||
}
|
||||
return fgInstance;
|
||||
return fgInstance;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Returns the instance of the singleton.
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4GeometryManager* G4GeometryManager::GetInstanceIfExist()
|
||||
{
|
||||
return fgInstance;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4LogicalVolume.cc 100906 2016-11-03 09:59:32Z gcosmo $
|
||||
// $Id: G4LogicalVolume.cc 103096 2017-03-15 15:21:33Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4LogicalVolume Implementation
|
||||
@@ -190,6 +190,15 @@ InitialiseWorker( G4LogicalVolume* /*pMasterObject*/,
|
||||
#endif
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// Clean
|
||||
// ********************************************************************
|
||||
//
|
||||
void G4LogicalVolume::Clean()
|
||||
{
|
||||
subInstanceManager.FreeSlave();
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// TerminateWorker
|
||||
//
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4LogicalVolumeStore.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
// $Id: G4LogicalVolumeStore.cc 103235 2017-03-22 15:53:48Z gcosmo $
|
||||
//
|
||||
// G4LogicalVolumeStore
|
||||
//
|
||||
@@ -63,7 +63,8 @@ G4LogicalVolumeStore::G4LogicalVolumeStore()
|
||||
//
|
||||
G4LogicalVolumeStore::~G4LogicalVolumeStore()
|
||||
{
|
||||
Clean();
|
||||
Clean(); // Delete all volumes in the store
|
||||
G4LogicalVolume::Clean(); // Delete allocated sub-instance data
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -74,7 +75,7 @@ void G4LogicalVolumeStore::Clean()
|
||||
{
|
||||
// Do nothing if geometry is closed
|
||||
//
|
||||
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
|
||||
if (G4GeometryManager::IsGeometryClosed())
|
||||
{
|
||||
G4cout << "WARNING - Attempt to delete the logical volume store"
|
||||
<< " while geometry closed !" << G4endl;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4PhysicalVolumeStore.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
// $Id: G4PhysicalVolumeStore.cc 103235 2017-03-22 15:53:48Z gcosmo $
|
||||
//
|
||||
// G4PhysicalVolumeStore
|
||||
//
|
||||
@@ -64,7 +64,8 @@ G4PhysicalVolumeStore::G4PhysicalVolumeStore()
|
||||
//
|
||||
G4PhysicalVolumeStore::~G4PhysicalVolumeStore()
|
||||
{
|
||||
Clean();
|
||||
Clean(); // Delete all volumes in the store
|
||||
G4VPhysicalVolume::Clean(); // Delete allocated sub-instance data
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -75,7 +76,7 @@ void G4PhysicalVolumeStore::Clean()
|
||||
{
|
||||
// Do nothing if geometry is closed
|
||||
//
|
||||
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
|
||||
if (G4GeometryManager::IsGeometryClosed())
|
||||
{
|
||||
G4cout << "WARNING - Attempt to delete the physical volume store"
|
||||
<< " while geometry closed !" << G4endl;
|
||||
@@ -90,13 +91,12 @@ void G4PhysicalVolumeStore::Clean()
|
||||
|
||||
size_t i=0;
|
||||
G4PhysicalVolumeStore* store = GetInstance();
|
||||
std::vector<G4VPhysicalVolume*>::iterator pos;
|
||||
|
||||
#ifdef G4GEOMETRY_VOXELDEBUG
|
||||
G4cout << "Deleting Physical Volumes ... ";
|
||||
#endif
|
||||
|
||||
for(pos=store->begin(); pos!=store->end(); pos++)
|
||||
for(iterator pos=store->begin(); pos!=store->end(); pos++)
|
||||
{
|
||||
if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
|
||||
if (*pos) { delete *pos; }
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ReflectedSolid.cc 100906 2016-11-03 09:59:32Z gcosmo $
|
||||
// $Id: G4ReflectedSolid.cc 104317 2017-05-24 13:08:38Z gcosmo $
|
||||
//
|
||||
//
|
||||
// Implementation for G4ReflectedSolid class
|
||||
@@ -152,9 +152,10 @@ void G4ReflectedSolid::SetDirectTransform3D(G4Transform3D& transform)
|
||||
//
|
||||
// Get bounding box
|
||||
|
||||
void G4ReflectedSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
|
||||
void G4ReflectedSolid::BoundingLimits(G4ThreeVector& pMin,
|
||||
G4ThreeVector& pMax) const
|
||||
{
|
||||
fPtrSolid->Extent(pMin,pMax);
|
||||
fPtrSolid->BoundingLimits(pMin,pMax);
|
||||
G4double xmin = pMin.x(), ymin = pMin.y(), zmin = pMin.z();
|
||||
G4double xmax = pMax.x(), ymax = pMax.y(), zmax = pMax.z();
|
||||
G4double xx = fDirectTransform3D->xx();
|
||||
@@ -203,7 +204,7 @@ void G4ReflectedSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
|
||||
<< GetName() << " !"
|
||||
<< "\npMin = " << pMin
|
||||
<< "\npMax = " << pMax;
|
||||
G4Exception("G4ReflectedSolid::Extent()", "GeomMgt0001",
|
||||
G4Exception("G4ReflectedSolid::BoundingLimits()", "GeomMgt0001",
|
||||
JustWarning, message);
|
||||
DumpInfo();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Region.cc 100428 2016-10-21 12:59:37Z gcosmo $
|
||||
// $Id: G4Region.cc 103096 2017-03-15 15:21:33Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4Region Implementation
|
||||
@@ -341,6 +341,15 @@ void G4Region::RemoveRootLogicalVolume(G4LogicalVolume* lv, G4bool scan)
|
||||
fRegionMod = true;
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// Clean
|
||||
// ********************************************************************
|
||||
//
|
||||
void G4Region::Clean()
|
||||
{
|
||||
subInstanceManager.FreeSlave();
|
||||
}
|
||||
|
||||
// *******************************************************************
|
||||
// ClearMaterialList:
|
||||
// - Clears the material list.
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4RegionStore.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
// $Id: G4RegionStore.cc 103235 2017-03-22 15:53:48Z gcosmo $
|
||||
//
|
||||
// G4RegionStore
|
||||
//
|
||||
@@ -67,7 +67,8 @@ G4RegionStore::G4RegionStore()
|
||||
//
|
||||
G4RegionStore::~G4RegionStore()
|
||||
{
|
||||
Clean();
|
||||
Clean(); // Delete all regions in the store
|
||||
G4Region::Clean(); // Delete allocated sub-instance data
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -78,7 +79,7 @@ void G4RegionStore::Clean()
|
||||
{
|
||||
// Do nothing if geometry is closed
|
||||
//
|
||||
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
|
||||
if (G4GeometryManager::IsGeometryClosed())
|
||||
{
|
||||
G4cout << "WARNING - Attempt to delete the region store"
|
||||
<< " while geometry closed !" << G4endl;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4SolidStore.cc 67975 2013-03-13 10:19:44Z gcosmo $
|
||||
// $Id: G4SolidStore.cc 103345 2017-03-28 14:20:20Z gcosmo $
|
||||
//
|
||||
// G4SolidStore
|
||||
//
|
||||
@@ -63,13 +63,7 @@ G4SolidStore::G4SolidStore()
|
||||
//
|
||||
G4SolidStore::~G4SolidStore()
|
||||
{
|
||||
// In multi-threaded mode, since parameterised solids are replicated
|
||||
// by threads, the master thread can not free them when thread private
|
||||
// malloc library is used. May let the master thread to replicate.
|
||||
|
||||
#ifndef G4MULTITHREADED
|
||||
Clean();
|
||||
#endif
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -80,7 +74,7 @@ void G4SolidStore::Clean()
|
||||
{
|
||||
// Do nothing if geometry is closed
|
||||
//
|
||||
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
|
||||
if (G4GeometryManager::IsGeometryClosed())
|
||||
{
|
||||
G4cout << "WARNING - Attempt to delete the solid store"
|
||||
<< " while geometry closed !" << G4endl;
|
||||
|
||||
@@ -72,152 +72,6 @@ G4bool G4USolid::operator==(const G4USolid& s) const
|
||||
return (this == &s) ? true : false;
|
||||
}
|
||||
|
||||
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::eSurface) return kSurface;
|
||||
if (in_temp == VUSolid::EnumInside::eInside) return kInside;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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);
|
||||
if (dist > kInfinity) return kInfinity;
|
||||
// return (dist > halfTolerance) ? dist : 0.0;
|
||||
return dist;
|
||||
}
|
||||
|
||||
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?
|
||||
if (dist > kInfinity) return kInfinity;
|
||||
// return (dist > halfTolerance) ? dist : 0.0;
|
||||
return dist;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
if (dist > kInfinity) return kInfinity;
|
||||
// return (dist > halfTolerance) ? dist : 0.0;
|
||||
return dist;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
G4double G4USolid::GetCubicVolume()
|
||||
{
|
||||
return fShape->Capacity();
|
||||
}
|
||||
|
||||
G4double G4USolid::GetSurfaceArea()
|
||||
{
|
||||
return fShape->SurfaceArea();
|
||||
}
|
||||
|
||||
G4ThreeVector G4USolid::GetPointOnSurface() const
|
||||
{
|
||||
UVector3 p;
|
||||
p = fShape->GetPointOnSurface();
|
||||
return G4ThreeVector(p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
G4bool G4USolid::CalculateExtent(const EAxis pAxis,
|
||||
const G4VoxelLimits& pVoxelLimit,
|
||||
const G4AffineTransform& pTransform,
|
||||
G4double& pMin, G4double& pMax) const
|
||||
{
|
||||
UVector3 vmin, vmax;
|
||||
fShape->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("G4USolid::CalculateExtent()", "GeomMgt0001",
|
||||
JustWarning, message);
|
||||
StreamInfo(G4cout);
|
||||
}
|
||||
|
||||
G4BoundingEnvelope bbox(bmin,bmax);
|
||||
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
|
||||
}
|
||||
|
||||
void G4USolid::ComputeDimensions(G4VPVParameterisation*,
|
||||
const G4int,
|
||||
const G4VPhysicalVolume*)
|
||||
@@ -284,6 +138,34 @@ G4VSolid* G4USolid::Clone() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
G4bool G4USolid::CalculateExtent(const EAxis pAxis,
|
||||
const G4VoxelLimits& pVoxelLimit,
|
||||
const G4AffineTransform& pTransform,
|
||||
G4double& pMin, G4double& pMax) const
|
||||
{
|
||||
UVector3 vmin, vmax;
|
||||
fShape->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("G4USolid::CalculateExtent()", "GeomMgt0001",
|
||||
JustWarning, message);
|
||||
StreamInfo(G4cout);
|
||||
}
|
||||
|
||||
G4BoundingEnvelope bbox(bmin,bmax);
|
||||
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
|
||||
}
|
||||
|
||||
G4Polyhedron* G4USolid::CreatePolyhedron() const
|
||||
{
|
||||
// Must be implemented in concrete wrappers...
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VPhysicalVolume.cc 100428 2016-10-21 12:59:37Z gcosmo $
|
||||
// $Id: G4VPhysicalVolume.cc 103096 2017-03-15 15:21:33Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4VPhysicalVolume Implementation
|
||||
@@ -109,6 +109,13 @@ InitialiseWorker( G4VPhysicalVolume* /*pMasterObject*/,
|
||||
// G4PhysicalVolumeStore::Register(this);
|
||||
}
|
||||
|
||||
// Release memory allocated for offset
|
||||
//
|
||||
void G4VPhysicalVolume::Clean()
|
||||
{
|
||||
subInstanceManager.FreeSlave();
|
||||
}
|
||||
|
||||
// This method is similar to the destructor. It is used by each worker
|
||||
// thread to achieve the partial effect as that of the master thread.
|
||||
// For G4VPhysicalVolume instances, nothing more to do here.
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VSolid.cc 100906 2016-11-03 09:59:32Z gcosmo $
|
||||
// $Id: G4VSolid.cc 104317 2017-05-24 13:08:38Z gcosmo $
|
||||
//
|
||||
// class G4VSolid
|
||||
//
|
||||
@@ -32,7 +32,6 @@
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 03.11.16 E.Tcherniaev, added Extent()
|
||||
// 06.12.02 V.Grichine, restored original conditions in ClipPolygon()
|
||||
// 10.05.02 V.Grichine, ClipPolygon(): clip only other axis and limited voxels
|
||||
// 15.04.02 V.Grichine, bug fixed in ClipPolygon(): clip only one axis
|
||||
@@ -623,13 +622,14 @@ G4VSolid::ClipPolygonToSimpleLimits( G4ThreeVectorList& pPolygon,
|
||||
//
|
||||
// Throw exception (warning) for solids not implementing the method
|
||||
|
||||
void G4VSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
|
||||
void G4VSolid::BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Not implemented for solid: "
|
||||
<< GetEntityType() << " !"
|
||||
<< "\nReturning infinite boundinx box.";
|
||||
G4Exception("G4VSolid::Extent()", "GeomMgt1001", JustWarning, message);
|
||||
G4Exception("G4VSolid::BoundingLimits()", "GeomMgt1001",
|
||||
JustWarning, message);
|
||||
|
||||
pMin.set(-kInfinity,-kInfinity,-kInfinity);
|
||||
pMax.set( kInfinity, kInfinity, kInfinity);
|
||||
|
||||
Reference in New Issue
Block a user