Import Geant4 10.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-12-09 12:35:28 +01:00
parent 4ec577e5c4
commit a3452e42ac
3514 changed files with 210500 additions and 89628 deletions
+92 -1
View File
@@ -1,4 +1,4 @@
$Id: History 97689 2016-06-07 09:34:01Z gcosmo $
$Id: History 101700 2016-11-21 16:16:14Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -17,6 +17,97 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
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.
November 8, 2016 G.Cosmo geommng-V10-02-31
- Again code formatting to G4LogicalCrystalVolume files.
November 7, 2016 E. Bagli geommng-V10-02-30
- Modified G4LogicalCrystalVolume for the G4CrystalExtension
November 3, 2016 G.Cosmo geommng-V10-02-29
- Added Extent() virtual method to G4VSolid and G4ReflectedSolid (E.Tcherniaev).
- Fixed Coverity defect in G4LogicalVolume::ClearDaughters().
November 1, 2016 E.Tcherniaev geommng-V10-02-28
- Added function DistancePointSegment() to G4GeomTools class.
- Code formatting in G4LogicalCrystalVolume.
October 26, 2016 E.Tcherniaev geommng-V10-02-27
- Added new functions SphereExtent(), TriangulatePolygon(), IsConvex() and
RemoveRedundantVertices() to G4GeomTools class.
October 24, 2016 E.Bagli geommng-V10-02-26
- Added class G4LogicalCrystalVolume, representing an extended logical
volume for crystal description.
October 21, 2016 G.Cosmo geommng-V10-02-25
- Moved initialisation of G4GeomSplitter thread-local data to be inline
along with generic template type.
Fixing compilation/linking errors on clang-3.9 and XCode-8 on MacOS.
- Added IsConvex() method to G4GeomTools.
October 19, 2016 M.Asai geommng-V10-02-24, 23
- G4LogicalVolume: added virtual keyword is to destructor for extended
yypes in the kernel. Added IsExtended() method.
October 16, 2016 E.Tcherniaev
- New utility class G4GeomTools providing static utility methods for
geometry related calculations.
October 2, 2016 E.Tcherniaev geommng-V10-02-22
- G4BoundingEnvelope: take into account four points instead of three in
CreateListOfPlanes().
September 26, 2016 E.Tcherniaev geommng-V10-02-21
- G4USolid: make direct use extent from shapes for computing bounding-box
in CalculateExtent().
September 22, 2016 E.Tcherniaev geommng-V10-02-20
- Added checks for bounding-box extents in G4USolid.
- Converted fatal exception to warning for CheckBoundingBox() in
G4BoundingEnvelope. Corrected use of 'const' data to resolve Coverity
defects.
September 20, 2016 G.Cosmo geommng-V10-02-19
- Moved accessors/modifiers for splitter data to non-inline in G4Region,
G4LogicalVolume, G4VPhysicalVolume.
Fixing compilation/linking errors on clang-3.9 and XCode-8 on MacOS.
September 9, 2016 E.Tcherniaev
- G4BoundingEnvelope: added QuickCheck() function.
September 2, 2016 E.Tcherniaev geommng-V10-02-18
- G4BoundingEnvelope: fixed bug in construction of voxel edges.
August 8, 2016 E.Tcherniaev geommng-V10-02-17
- G4BoundingEnvelope: some improvement of internal consistency in the code.
July 7, 2016 G.Cosmo geommng-V10-02-16
- Removed redundant check in G4GeomSplitter::UseWorkArea().
Addressing problem report #1876.
July 6, 2016 G.Cosmo geommng-V10-02-15
- Correction in G4USolid::CalculateExtent() for correct return-type.
June 29, 2016 E.Tcherniaev geommng-V10-02-14
- Optimised version of G4BoundingEnvelope.
June 28, 2016 E.Tcherniaev
- Re-implemented CalculateExtent() in G4USolid to use G4BoundingEnvelope;
removed method CreateRotatedVertices().
June 27, 2016 E.Tcherniaev
- G4AffineTransform: added conversion operator to G4Transform3D and
simplified implementation of NetRotation() in terms of G4Rep3x3.
June 13, 2016 E.Tcherniaev
- G4ReflectedSolid: new revision of CalculateExtent(), to make use of
CalculateExtent() from the constituent solid, applying proper transformation.
Removed use of G4BoundingEnvelope.
June 7, 2016 G.Cosmo geommng-V10-02-13
- Initialise 'emin' and 'emax' in G4BoundingEnvelope::CalculateExtent().
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4AffineTransform.hh 96126 2016-03-16 21:16:54Z gcosmo $
// $Id: G4AffineTransform.hh 98309 2016-07-06 10:30:15Z gcosmo $
//
//
// class G4AffineTransform
@@ -65,6 +65,7 @@
#include "G4Types.hh"
#include "G4ThreeVector.hh"
#include "G4RotationMatrix.hh"
#include "G4Transform3D.hh"
class G4AffineTransform
{
@@ -152,6 +153,9 @@ public: // with description
inline void SetNetTranslation(const G4ThreeVector& tlate);
inline operator G4Transform3D () const;
// Conversion operator (cast) to G4Transform3D
private:
inline G4AffineTransform(
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4AffineTransform.icc 93152 2015-10-08 11:53:57Z gcosmo $
// $Id: G4AffineTransform.icc 98309 2016-07-06 10:30:15Z gcosmo $
//
//
// G4AffineTransformation Inline implementation
@@ -363,10 +363,9 @@ G4bool G4AffineTransform::IsTranslated() const
inline G4RotationMatrix G4AffineTransform::NetRotation() const
{
G4RotationMatrix mat;
return mat.rotateAxes(G4ThreeVector(rxx,ryx,rzx),
G4ThreeVector(rxy,ryy,rzy),
G4ThreeVector(rxz,ryz,rzz));
return G4Rep3x3(rxx,rxy,rxz,
ryx,ryy,ryz,
rzx,rzy,rzz);
}
inline
@@ -397,6 +396,12 @@ void G4AffineTransform::SetNetTranslation(const G4ThreeVector& tlate)
tz=tlate.z();
}
inline
G4AffineTransform::operator G4Transform3D () const
{
return G4Transform3D(NetRotation().inverse(),NetTranslation());
}
inline
std::ostream& operator << (std::ostream& os, const G4AffineTransform& transf)
{
@@ -32,32 +32,14 @@
// Class description:
//
// Helper class to facilitate calculation of the extent of a solid
// within the limits defined by the G4VoxelLimits object.
// within the limits defined by a G4VoxelLimits object.
//
// The function CalculateExtent() of a particular solid can create
// a G4BoundingEnvelope object that bounds the solid and then call
// CalculateExtent() of the G4BoundingEnvelope object.
//
// Calculation of the extent by G4BoundingEnvelope takes into account
// special parameter "delta" - width of an imagery layer that envelops
// the object. This value, multiplied by max scale factor, is added
// to the voxel limits during calculation of the extent.
//
// Example of use.
// In case of G4Box, max possible distance of a point to the border
// of the box, where the point is still considered as belonging to
// the surface of the box, is sqrt(0.5)*kCarTolerance (see corner).
// So, it will be safe to set the extension = kCarTolerance.
//
// Alternative solution can be to define G4BoundingEnvelope wide
// enough to include the surface of the solid and set delta = 0.
//
// The class supports the following bouding envelopes:
// - axis aligned bounding box (AABB);
// - bounding prism given by two convex polygonal bases;
// - bounding pyramid given by apex and convex polygonal base;
// - set of bounding prisms, given by a sequence of convex
// polygonal bases;
// Calculation of extent uses G4Transform3D, thus takes into account
// scaling and reflection, if any.
// History:
//
@@ -84,98 +66,88 @@ class G4BoundingEnvelope
{
public:
G4BoundingEnvelope(const G4ThreeVector& pMin,
const G4ThreeVector& pMax, G4double delta);
G4BoundingEnvelope(const G4ThreeVector& pMin,
const G4ThreeVector& pMax);
// Constructor from an axis aligned bounding box (AABB)
G4BoundingEnvelope(const G4ThreeVectorList& baseA,
const G4ThreeVectorList& baseB, G4double delta);
// Constructor from a prism given by two bases, the bases
// should have equal number of vertices
G4BoundingEnvelope(const G4ThreeVector& apex,
const G4ThreeVectorList& base, G4double delta);
// Constructor from a pyramid given by apex and base
G4BoundingEnvelope(const std::vector<G4ThreeVectorList*>& polygons,
G4double delta);
G4BoundingEnvelope(const std::vector<const G4ThreeVectorList*>& polygons);
// Constructor from a sequence of convex polygons, the polygons
// should have equal numbers of vertices except first and last
// polygons which may consist of a single vertex
G4BoundingEnvelope(const G4BoundingEnvelope& rhs);
// Copy constructor
G4BoundingEnvelope& operator=(const G4BoundingEnvelope& rhs);
// Assignment operator
G4BoundingEnvelope(const G4ThreeVector& pMin,
const G4ThreeVector& pMax,
const std::vector<const G4ThreeVectorList*>& polygons);
// Constructor from AABB and a sequence of polygons
~G4BoundingEnvelope();
// Destructor
G4bool BoundingBoxVsVoxelLimits(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimits,
const G4Transform3D& pTransform3D,
G4double& pMin, G4double& pMax) const;
// Analyse the position of the bounding box relative to the voxel.
// It returns "true" in the case where the value of the extent can be
// figured out directly from the dimensions of the bounding box, or
// it is clear that the bounding box and the voxel do not intersect.
// The reply "false" means that further calculations are needed.
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimits,
const G4Transform3D& pTransform3D,
G4double& pMin, G4double& pMax) const;
// Calculate extent of the envelope
// Calculate extent of the bounding envelope
private:
void SetDelta(G4double delta);
// Set the extension
void CheckBoundingBox();
// Check correctness of the AABB (axis aligned bounding box)
void SetBoundingBox(const G4ThreeVector& pMin,
const G4ThreeVector& pMax);
// Set AABB (axis aligned bounding box)
void CheckBoundingPolygons();
// Check correctness of the sequence of convex polygonal bases
void SetBoundingPrism(const G4ThreeVectorList& baseA,
const G4ThreeVectorList& baseB);
// Set bounding prism
void SetBoundingPyramid(const G4ThreeVector& apex,
const G4ThreeVectorList& base);
// Set bounding pyramid
void SetBoundingPolygons(const std::vector<G4ThreeVectorList*>& polygons);
// Set bounding sequence of convex polygons
void CleanPolygons();
// Free allocated memory
G4VoxelLimits GetAdjustedVoxelLimits(const G4VoxelLimits& pVoxelLimits,
G4double pDelta) const;
// Extend voxel limits by scaled surface tolerance
G4double FindScaleFactor(const G4Transform3D& pTransform3D) const;
// Find max scale factor of the transformation
void TransformVertices(const G4Transform3D& pTransform3D,
const G4Polygon3D& polyA,
G4Polygon3D& polyB,
G4Segment3D& pAABB) const;
// Transform vertices of a polygon and update AABB (bounding box)
std::vector<G4Polygon3D*>& pBases) const;
// Create list of transformed polygons
void GetPrismAABB(const G4Polygon3D& pBaseA,
const G4Polygon3D& pBaseB,
G4Segment3D& pAABB) const;
// Find bounding box of a prism
void CreateListOfEdges(const G4Polygon3D& baseA,
const G4Polygon3D& baseB,
std::vector<G4Segment3D>& pEdges) const;
std::vector<G4Segment3D>& pEdges) const;
// Create list of edges of a prism
void CreateListOfPlanes(const G4Polygon3D& baseA,
const G4Polygon3D& baseB,
std::vector<G4Plane3D>& pPlanes) const;
std::vector<G4Plane3D>& pPlanes) const;
// Create list of planes bounding a prism
G4bool ClipEdgesByVoxelLimits(const std::vector<G4Segment3D>& pEdges,
const G4VoxelLimits& pLimits,
G4Segment3D& pExtent) const;
G4bool ClipEdgesByVoxel(const std::vector<G4Segment3D>& pEdges,
const G4VoxelLimits& pLimits,
G4Segment3D& pExtent) const;
// Clip set of edges by G4VoxelLimits
void ClipVoxelLimitsByPlanes(const G4VoxelLimits& pLimits,
const std::vector<G4Plane3D>& pPlanes,
const G4Segment3D& pAABB,
G4Segment3D& pExtent) const;
// Clip G4VoxelLimits by set of planes bounding a convex prism
void ClipVoxelByPlanes(G4int pBits,
const G4VoxelLimits& pLimits,
const std::vector<G4Plane3D>& pPlanes,
const G4Segment3D& pAABB,
G4Segment3D& pExtent) const;
// Clip G4VoxelLimits by set of planes bounding a prism
private:
G4double fDelta; // extention
std::vector<G4Polygon3D*> fBases; // sequence of polygonal bases
G4ThreeVector fMin, fMax;
// original bounding box
const std::vector<const G4ThreeVectorList*>* fPolygons;
// ref to original sequence of polygonal bases
};
#endif // G4BOUNDINGENVELOPE_HH
@@ -52,8 +52,10 @@ class G4GeomSplitter
{
public:
G4GeomSplitter() : totalobj(0), totalspace(0), sharedOffset(0) {
G4MUTEXINIT(mutex);
G4GeomSplitter()
: totalobj(0), totalspace(0), sharedOffset(0)
{
G4MUTEXINIT(mutex);
}
G4int CreateSubInstance()
@@ -125,7 +127,8 @@ class G4GeomSplitter
// To cope with user's changes in Geometry - e.g. change of material in a volume
{
G4AutoLock l(&mutex);
if (!offset) {
if (!offset)
{
SlaveInitializeSubInstance();
G4Exception("G4GeomSPlitter::SlaveReCopySubInstance()",
"MissingInitialisation", JustWarning,
@@ -153,18 +156,9 @@ class G4GeomSplitter
// Use recycled work area - which was created previously
if( offset && offset!=newOffset )
{
if( newOffset != offset )
{
G4Exception("G4GeomSplitter::UseWorkspace()",
"TwoWorkspaces", FatalException,
"Thread already has workspace - cannot use another.");
}
else
{
G4Exception("G4GeomSplitter::UseWorkspace()",
"TwoWorkspaces", JustWarning,
"Thread already has a workspace - trying to set the same again.");
}
G4Exception("G4GeomSplitter::UseWorkspace()",
"TwoWorkspaces", FatalException,
"Thread already has workspace - cannot use another.");
}
offset= newOffset;
// totalobj= numObjects;
@@ -200,4 +194,6 @@ class G4GeomSplitter
G4Mutex mutex;
};
template <typename T> G4ThreadLocal T* G4GeomSplitter<T>::offset = 0;
#endif
@@ -0,0 +1,196 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: $
//
//
// --------------------------------------------------------------------
// class G4GeomTools
//
// Class description:
//
// A collection of utilities which can be helpfull for a wide range
// of geometry-related tasks
// History:
//
// 10.10.2016 E.Tcherniaev: Initial version.
// --------------------------------------------------------------------
#ifndef G4GEOMTOOLS_HH
#define G4GEOMTOOLS_HH
#include <vector>
#include "G4TwoVector.hh"
#include "G4ThreeVector.hh"
typedef std::vector<G4TwoVector> G4TwoVectorList;
typedef std::vector<G4ThreeVector> G4ThreeVectorList;
class G4GeomTools
{
public:
// ==================================================================
// 2D Utilities
// ------------------------------------------------------------------
static G4double TriangleArea(G4double Ax, G4double Ay,
G4double Bx, G4double By,
G4double Cx, G4double Cy);
static G4double TriangleArea(const G4TwoVector& A,
const G4TwoVector& B,
const G4TwoVector& C);
// Calcuate area of 2D triangle, return value is positive if
// vertices of the triangle are given in anticlockwise order,
// otherwise it is negative
static G4double QuadArea(const G4TwoVector& A,
const G4TwoVector& B,
const G4TwoVector& C,
const G4TwoVector& D);
// Calcuate area of 2D quadrilateral, return value is positive if
// vertices of the quadrilateral are given in anticlockwise order,
// otherwise it is negative
static G4double PolygonArea(const G4TwoVectorList& polygon);
// Calcuate area of 2D polygon, return value is positive if
// vertices of the polygon are defined in anticlockwise order,
// otherwise it is negative
static G4bool PointInTriangle(G4double Px, G4double Py,
G4double Ax, G4double Ay,
G4double Bx, G4double By,
G4double Cx, G4double Cy);
// Decide if point (Px,Py) is inside triangle (Ax,Ay)(Bx,By)(Cx,Cy)
static G4bool PointInTriangle(const G4TwoVector& P,
const G4TwoVector& A,
const G4TwoVector& B,
const G4TwoVector& C);
// Decide if point P is inside triangle ABC
/*
static G4bool PointInPolygon(const G4TwoVector& P
const G4TwoVectorList& Polygon);
// Decide if point P is inside Polygon
*/
static G4bool IsConvex(const G4TwoVectorList& polygon);
// Decide if 2D polygon is convex, i.e. all internal angles are
// less than pi
static G4bool TriangulatePolygon(const G4TwoVectorList& polygon,
G4TwoVectorList& result);
static G4bool TriangulatePolygon(const G4TwoVectorList& polygon,
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
// is sucsessfull then the function returns true, otherwise false
static void RemoveRedundantVertices(G4TwoVectorList& polygon,
std::vector<G4int>& iout,
G4double tolerance = 0);
// Remove collinear and coincident points from 2D polygon.
// Indices of removed points are available in iout.
static G4bool DiskExtent(G4double rmin, G4double rmax,
G4double startPhi, G4double delPhi,
G4TwoVector& pmin, G4TwoVector& pmax);
// Calculate bounding square of a disk sector,
// it returns false if input parameters do not meet the following:
// rmin >= 0
// rmax > rmin + kCarTolerance
// delPhi > 0 + kCarTolerance
static void DiskExtent(G4double rmin, G4double rmax,
G4double sinPhiStart, G4double cosPhiStart,
G4double sinPhiEnd, G4double cosPhiEnd,
G4TwoVector& pmin, G4TwoVector& pmax);
// Calculate bounding square of a disk sector,
// faster version without check of parameters
// ==================================================================
// 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
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
static G4ThreeVector PolygonAreaNormal(const G4ThreeVectorList& polygon);
// Calcuate normal to the plane of 3D polygon with
// length equal to its area
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);
// Decide if 3D polygon is planar
*/
static G4double DistancePointSegment(G4ThreeVector P,
G4ThreeVector A,
G4ThreeVector B);
// Calculate distance between point P and line segment AB in 3D
static G4bool SphereExtent(G4double rmin, G4double rmax,
G4double startTheta, G4double delTheta,
G4double startPhi, G4double delPhi,
G4ThreeVector& pmin, G4ThreeVector& pmax);
// Calculate bounding box of a spherical sector,
// it returns false if input parameters do not meet the following:
// rmin >= 0
// rmax > rmin + kCarTolerance
// startTheta >= 0 && <= pi;
// delTheta > 0 + kCarTolerance
// delPhi > 0 + kCarTolerance
private:
static G4bool CheckSnip(const G4TwoVectorList& contour,
G4int a, G4int b, G4int c,
G4int n, const G4int* V);
// Helper function for TriangulatePolygon()
};
#endif // G4GEOMTOOLS_HH
@@ -0,0 +1,106 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
// ---------------------------------------------------------------------------
//
// class G4LogicalCrystalVolume
//
// Class description:
//
// Specialised logical volume for the description of crystals.
// The object can be created only with an extended material
// with a crystal extension. The class handles the orientation
// of the crystal axes wrt the solid to which the crystal is attached.
//
// History:
//
// 21-04-16, created by E.Bagli
//
// ---------------------------------------------------------------------------
#ifndef G4LOGICALCRYSTALVOLUME_HH
#define G4LOGICALCRYSTALVOLUME_HH 1
#include <vector>
#include "G4LogicalVolume.hh"
class G4CrystalExtension;
class G4ExtendedMaterial;
class G4LogicalCrystalVolume : public G4LogicalVolume
{
public:
G4LogicalCrystalVolume(G4VSolid* pSolid,
G4ExtendedMaterial* pMaterial,
const G4String& name,
G4FieldManager* pFieldMgr=0,
G4VSensitiveDetector* pSDetector=0,
G4UserLimits* pULimits=0,
G4bool optimise=true,
G4int h=0,
G4int k=0,
G4int l=0,
G4double rot=0.);
~G4LogicalCrystalVolume();
G4bool IsExtended() const { return true; }
// Return true if it is not a base-class object.
void SetMillerOrientation(G4int h, G4int k, G4int l, G4double rot=0.);
// Set physical lattice orientation, relative to G4VSolid coordinates
// Miller orientation aligns lattice normal (hkl) with geometry +Z
const G4ThreeVector& RotateToLattice(G4ThreeVector& dir) const;
const G4ThreeVector& RotateToSolid(G4ThreeVector& dir) const;
// Rotate input vector between lattice and solid orientations
// Returns new vector value for convenience
const G4CrystalExtension* GetCrystal() const;
const G4ThreeVector& GetBasis(G4int i) const;
// Call through to get crystal basis vectors
void SetVerbose(G4int aInt) { verboseLevel = aInt; }
static G4bool IsLattice(G4LogicalVolume* aLV);
private:
G4RotationMatrix fOrient; // Rotate geometry into lattice frame
G4RotationMatrix fInverse;
G4int hMiller, kMiller, lMiller; // Save Miller indices for dumps
G4double fRot;
G4int verboseLevel;
static std::vector<G4LogicalVolume*> fLCVvec;
};
#endif
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4LogicalVolume.hh 93287 2015-10-15 09:50:22Z gcosmo $
// $Id: G4LogicalVolume.hh 100397 2016-10-20 07:34:38Z gcosmo $
//
//
// class G4LogicalVolume
@@ -96,6 +96,7 @@
// - Flags if the Logical Volume is an envelope for a FastSimulationManager.
// History:
// 19.10.16 M.Asai: Added virtual keyword to the destructor
// 15.01.13 G.Cosmo, A.Dotti: Modified for thread-safety for MT
// 12.11.04 G.Cosmo: Added GetMass() method for computing mass of the tree
// 24.09.02 G.Cosmo: Added flags and accessors for region cuts handling
@@ -119,6 +120,7 @@
#include "G4Region.hh" // Required by inline methods
#include "G4VPhysicalVolume.hh" // Need operator == for vector fdaughters
#include "G4GeomSplitter.hh" // Needed for MT RW data splitting
#include "G4Threading.hh"
// Forward declarations
//
@@ -139,13 +141,14 @@ class G4LVData
public:
G4LVData();
void initialize() {
fSolid = 0;
fSensitiveDetector = 0;
fFieldManager = 0;
fMaterial = 0;
fMass = 0.0;
fCutsCouple = 0;
void initialize()
{
fSolid = 0;
fSensitiveDetector = 0;
fFieldManager = 0;
fMaterial = 0;
fMass = 0.0;
fCutsCouple = 0;
}
public:
@@ -204,9 +207,10 @@ class G4LogicalVolume
// hierarchy is applied by default. For parameterised volumes in
// the hierarchy, optimisation is -always- applied.
~G4LogicalVolume();
virtual ~G4LogicalVolume();
// Destructor. Removes the logical volume from the logical volume Store.
// NOT virtual, since not meant to act as base class.
// This class is NOT meant to act as base class, except for exceptional
// circumstances of extended types used in the kernel.
inline const G4String& GetName() const;
inline void SetName(const G4String& pName);
@@ -217,7 +221,7 @@ class G4LogicalVolume
inline G4VPhysicalVolume* GetDaughter(const G4int i) const;
// Returns the ith daughter. Note numbering starts from 0,
// and no bounds checking is performed.
inline void AddDaughter(G4VPhysicalVolume* p);
void AddDaughter(G4VPhysicalVolume* p);
// Adds the volume p as a daughter of the current logical volume.
inline G4bool IsDaughter(const G4VPhysicalVolume* p) const;
// Returns true if the volume p is a daughter of the current
@@ -226,10 +230,10 @@ class G4LogicalVolume
// Returns true if the volume p is part of the hierarchy of
// volumes established by the current logical volume. Scans
// recursively the volume tree.
inline void RemoveDaughter(const G4VPhysicalVolume* p);
void RemoveDaughter(const G4VPhysicalVolume* p);
// Removes the volume p from the List of daughter of the current
// logical volume.
inline void ClearDaughters();
void ClearDaughters();
// Clears the list of daughters. Used by the phys-volume store when
// the geometry tree is cleared, since modified at run-time.
G4int TotalVolumeEntities() const;
@@ -238,14 +242,14 @@ class G4LogicalVolume
inline EVolume CharacteriseDaughters() const;
// Characterise the daughters of this logical volume.
inline G4VSolid* GetSolid() const;
inline void SetSolid(G4VSolid *pSolid);
G4VSolid* GetSolid() const;
void SetSolid(G4VSolid *pSolid);
// Gets and sets the current solid.
inline G4Material* GetMaterial() const;
inline void SetMaterial(G4Material *pMaterial);
G4Material* GetMaterial() const;
void SetMaterial(G4Material *pMaterial);
// Gets and sets the current material.
inline void UpdateMaterial(G4Material *pMaterial);
void UpdateMaterial(G4Material *pMaterial);
// Sets material and corresponding MaterialCutsCouple.
// This method is invoked by G4Navigator while it is navigating through
// material parameterization.
@@ -264,12 +268,12 @@ class G4LogicalVolume
// method returns the mass of the present logical volume only
// (subtracted for the volume occupied by the daughter volumes).
// An optional argument to specify a material is also provided.
void ResetMass();
void ResetMass();
// Ensure that cached value of Mass is invalidated - due to change in
// state, e.g. change of size of Solid, change of type of solid,
// or the addition/deletion of a daughter volume.
inline G4FieldManager* GetFieldManager() const;
G4FieldManager* GetFieldManager() const;
// Gets current FieldManager.
void SetFieldManager(G4FieldManager *pFieldMgr, G4bool forceToAllDaughters);
// Sets FieldManager and propagates it:
@@ -278,9 +282,9 @@ class G4LogicalVolume
// ii) to all daughters
// if forceToAllDaughters=true
inline G4VSensitiveDetector* GetSensitiveDetector() const;
G4VSensitiveDetector* GetSensitiveDetector() const;
// Gets current SensitiveDetector.
inline void SetSensitiveDetector(G4VSensitiveDetector *pSDetector);
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector);
// Sets SensitiveDetector (can be 0).
inline G4UserLimits* GetUserLimits() const;
@@ -316,8 +320,8 @@ class G4LogicalVolume
inline void PropagateRegion();
// Propagates region pointer to daughters.
inline const G4MaterialCutsCouple* GetMaterialCutsCouple() const;
inline void SetMaterialCutsCouple(G4MaterialCutsCouple* cuts);
const G4MaterialCutsCouple* GetMaterialCutsCouple() const;
void SetMaterialCutsCouple(G4MaterialCutsCouple* cuts);
// Accessors for production cuts.
G4bool operator == (const G4LogicalVolume& lv) const;
@@ -344,6 +348,9 @@ class G4LogicalVolume
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
virtual G4bool IsExtended() const;
// Return true if it is not a base-class object.
inline G4FieldManager* GetMasterFieldManager() const;
// Gets current FieldManager for the master thread.
inline G4VSensitiveDetector* GetMasterSensitiveDetector() const;
@@ -374,12 +381,12 @@ class G4LogicalVolume
// 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.
inline void AssignFieldManager( G4FieldManager *fldMgr);
void AssignFieldManager( G4FieldManager *fldMgr);
// Set the FieldManager - only at this level (do not push down hierarchy)
// Optimised Methods - passing thread instance of worker data
inline static G4VSolid* GetSolid(G4LVData &instLVdata) ; // const;
inline static void SetSolid(G4LVData &instLVdata, G4VSolid *pSolid);
static G4VSolid* GetSolid(G4LVData &instLVdata) ; // const;
static void SetSolid(G4LVData &instLVdata, G4VSolid *pSolid);
// Optimised Methods - passing thread instance of worker data
private:
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4LogicalVolume.icc 91010 2015-06-15 09:55:26Z gcosmo $
// $Id: G4LogicalVolume.icc 99379 2016-09-20 09:45:19Z gcosmo $
//
//
// class G4LogicalVolume Inline Implementation file
@@ -38,19 +38,6 @@
// 17.05.02 - G.Cosmo: Added IsToOptimise() method
// --------------------------------------------------------------------
// These macros change the references to fields that are now encapsulated
// in the class G4LVData.
//
#define G4MT_solid ((subInstanceManager.offset[instanceID]).fSolid)
#define G4MT_sdetector ((subInstanceManager.offset[instanceID]).fSensitiveDetector)
#define G4MT_fmanager ((subInstanceManager.offset[instanceID]).fFieldManager)
#define G4MT_material ((subInstanceManager.offset[instanceID]).fMaterial)
#define G4MT_mass ((subInstanceManager.offset[instanceID]).fMass)
#define G4MT_ccouple ((subInstanceManager.offset[instanceID]).fCutsCouple)
#define G4MT_instance (subInstanceManager.offset[instanceID])
#include "G4Threading.hh"
// ********************************************************************
// GetName
// ********************************************************************
@@ -81,23 +68,6 @@ G4int G4LogicalVolume::GetInstanceID() const
return instanceID;
}
// ********************************************************************
// GetFieldManager
// ********************************************************************
//
inline
G4FieldManager* G4LogicalVolume::GetFieldManager() const
{
return G4MT_fmanager;
}
inline void G4LogicalVolume::AssignFieldManager( G4FieldManager *fldMgr)
{
G4MT_fmanager= fldMgr;
if(G4Threading::IsMasterThread()) fFieldManager = fldMgr;
}
// ********************************************************************
// GetMasterFieldManager
// ********************************************************************
@@ -140,49 +110,6 @@ G4FastSimulationManager* G4LogicalVolume::GetFastSimulationManager () const
return fFSM;
}
// ********************************************************************
// AddDaughter
// ********************************************************************
//
inline
void G4LogicalVolume::AddDaughter(G4VPhysicalVolume* pNewDaughter)
{
if( !fDaughters.empty() && fDaughters[0]->IsReplicated() )
{
std::ostringstream message;
message << "ERROR - Attempt to place a volume in a mother volume" << G4endl
<< " already containing a replicated volume." << G4endl
<< " A volume can either contain several placements" << G4endl
<< " or a unique replica or parameterised volume !" << G4endl
<< " Mother logical volume: " << GetName() << G4endl
<< " Placing volume: " << pNewDaughter->GetName() << G4endl;
G4Exception("G4LogicalVolume::AddDaughter()", "GeomMgt0002",
FatalException, message,
"Replica or parameterised volume must be the only daughter !");
}
// Invalidate previous calculation of mass - if any - for all threads
G4MT_mass = 0.;
// SignalVolumeChange(); // fVolumeChanged= true;
fDaughters.push_back(pNewDaughter);
G4LogicalVolume* pDaughterLogical = pNewDaughter->GetLogicalVolume();
// Propagate the Field Manager, if the daughter has no field Manager.
//
G4FieldManager* pDaughterFieldManager = pDaughterLogical->GetFieldManager();
if( pDaughterFieldManager == 0 )
{
pDaughterLogical->SetFieldManager(G4MT_fmanager, false);
}
if (fRegion)
{
PropagateRegion();
fRegion->RegionModified(true);
}
}
// ********************************************************************
// IsDaughter
// ********************************************************************
@@ -198,48 +125,6 @@ G4bool G4LogicalVolume::IsDaughter(const G4VPhysicalVolume* p) const
return false;
}
// ********************************************************************
// RemoveDaughter
// ********************************************************************
//
inline
void G4LogicalVolume::RemoveDaughter(const G4VPhysicalVolume* p)
{
G4PhysicalVolumeList::iterator i;
for ( i=fDaughters.begin(); i!=fDaughters.end(); ++i )
{
if (**i==*p)
{
fDaughters.erase(i);
break;
}
}
if (fRegion)
{
fRegion->RegionModified(true);
}
G4MT_mass = 0.;
}
// ********************************************************************
// ClearDaughters
// ********************************************************************
//
inline
void G4LogicalVolume::ClearDaughters()
{
G4PhysicalVolumeList::iterator i;
for ( i=fDaughters.begin(); i!=fDaughters.end(); ++i )
{
fDaughters.erase(i);
}
if (fRegion)
{
fRegion->RegionModified(true);
}
G4MT_mass = 0.;
}
// ********************************************************************
// CharacteriseDaughters
// ********************************************************************
@@ -262,30 +147,6 @@ EVolume G4LogicalVolume::CharacteriseDaughters() const
return type;
}
inline
void G4LogicalVolume::ResetMass()
{
G4MT_mass= 0.0;
}
// ********************************************************************
// GetSolid
// ********************************************************************
//
inline
G4VSolid* G4LogicalVolume::GetSolid(G4LVData &instLVdata) // const
{
return instLVdata.fSolid;
}
inline
G4VSolid* G4LogicalVolume::GetSolid() const
{
// return G4MT_solid;
// return ((subInstanceManager.offset[instanceID]).fSolid);
return this->GetSolid( subInstanceManager.offset[instanceID] );
}
// ********************************************************************
// GetMasterSolid
// ********************************************************************
@@ -296,72 +157,6 @@ G4VSolid* G4LogicalVolume::GetMasterSolid() const
return fSolid;
}
// ********************************************************************
// SetSolid
// ********************************************************************
//
inline
void G4LogicalVolume::SetSolid(G4VSolid *pSolid)
{
// ((subInstanceManager.offset[instanceID]).fSolid) = pSolid;
G4MT_solid=pSolid;
// G4MT_mass = 0.;
this->ResetMass();
}
inline
void G4LogicalVolume::SetSolid(G4LVData &instLVdata, G4VSolid *pSolid)
{
instLVdata.fSolid = pSolid;
// G4MT_solid=pSolid;
instLVdata.fMass= 0;
// A fast way to reset the mass ... ie G4MT_mass = 0.;
}
// ********************************************************************
// GetMaterial
// ********************************************************************
//
inline
G4Material* G4LogicalVolume::GetMaterial() const
{
return G4MT_material;
}
// ********************************************************************
// SetMaterial
// ********************************************************************
//
inline
void G4LogicalVolume::SetMaterial(G4Material *pMaterial)
{
G4MT_material=pMaterial;
G4MT_mass = 0.;
}
// ********************************************************************
// UpdateMaterial
// ********************************************************************
//
inline
void G4LogicalVolume::UpdateMaterial(G4Material *pMaterial)
{
G4MT_material=pMaterial;
if(fRegion) { G4MT_ccouple = fRegion->FindCouple(pMaterial); }
G4MT_mass = 0.;
}
// ********************************************************************
// GetSensitiveDetector
// ********************************************************************
//
inline
G4VSensitiveDetector* G4LogicalVolume::GetSensitiveDetector() const
{
return G4MT_sdetector;
}
// ********************************************************************
// GetMasterSensitiveDetector
// ********************************************************************
@@ -372,17 +167,6 @@ G4VSensitiveDetector* G4LogicalVolume::GetMasterSensitiveDetector() const
return fSensitiveDetector;
}
// ********************************************************************
// SetSensitiveDetector
// ********************************************************************
//
inline
void G4LogicalVolume::SetSensitiveDetector(G4VSensitiveDetector* pSDetector)
{
G4MT_sdetector = pSDetector;
if(G4Threading::IsMasterThread()) fSensitiveDetector = pSDetector;
}
// ********************************************************************
// GetUserLimits
// ********************************************************************
@@ -527,26 +311,6 @@ void G4LogicalVolume::PropagateRegion()
fRegion->ScanVolumeTree(this, true);
}
// ********************************************************************
// GetMaterialCutsCouple
// ********************************************************************
//
inline
const G4MaterialCutsCouple* G4LogicalVolume::GetMaterialCutsCouple() const
{
return G4MT_ccouple;
}
// ********************************************************************
// SetMaterialCutsCouple
// ********************************************************************
//
inline
void G4LogicalVolume::SetMaterialCutsCouple(G4MaterialCutsCouple* cuts)
{
G4MT_ccouple = cuts;
}
// ********************************************************************
// Lock
// ********************************************************************
@@ -606,10 +370,3 @@ G4double G4LogicalVolume::GetBiasWeight() const
{
return fBiasWeight;
}
#undef G4MT_solid
#undef G4MT_sdetector
#undef G4MT_fmanager
#undef G4MT_material
// #undef G4MT_mass
// #undef G4MT_ccouple
#undef G4MT_instance
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ReflectedSolid.hh 96930 2016-05-18 08:56:58Z gcosmo $
// $Id: G4ReflectedSolid.hh 100906 2016-11-03 09:59:32Z gcosmo $
//
//
// class G4ReflectedSolid
@@ -63,6 +63,8 @@ class G4ReflectedSolid : public G4VSolid
EInside Inside( const G4ThreeVector& p ) const;
void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
+5 -11
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Region.hh 67975 2013-03-13 10:19:44Z gcosmo $
// $Id: G4Region.hh 99379 2016-09-20 09:45:19Z gcosmo $
//
// class G4Region
//
@@ -96,12 +96,6 @@ class G4RegionData
//
typedef G4GeomSplitter<G4RegionData> G4RegionManager;
// These macros changes the references to fields that are now encapsulated
// in the class G4RegionData.
//
#define G4MT_fsmanager ((subInstanceManager.offset[instanceID]).fFastSimulationManager)
#define G4MT_rsaction ((subInstanceManager.offset[instanceID]).fRegionalSteppingAction)
class G4Region
{
typedef std::vector<G4LogicalVolume*> G4RootLVList;
@@ -177,8 +171,8 @@ class G4Region
// Find a G4MaterialCutsCouple which corresponds to the material
// in this region.
inline void SetFastSimulationManager(G4FastSimulationManager* fsm);
inline G4FastSimulationManager* GetFastSimulationManager() const;
void SetFastSimulationManager(G4FastSimulationManager* fsm);
G4FastSimulationManager* GetFastSimulationManager() const;
// Set and Get methods for G4FastSimulationManager.
// The root logical volume that has the region with G4FastSimulationManager
// becomes an envelope of fast simulation.
@@ -215,8 +209,8 @@ class G4Region
// Flag 'unique' is true if there is only one parent region containing
// the current region.
inline void SetRegionalSteppingAction(G4UserSteppingAction* rusa);
inline G4UserSteppingAction* GetRegionalSteppingAction() const;
void SetRegionalSteppingAction(G4UserSteppingAction* rusa);
G4UserSteppingAction* GetRegionalSteppingAction() const;
// Set/Get method of the regional user stepping action
public: // without description
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Region.icc 67975 2013-03-13 10:19:44Z gcosmo $
// $Id: G4Region.icc 99379 2016-09-20 09:45:19Z gcosmo $
//
//
// class G4Region Inline Implementation file
@@ -237,26 +237,6 @@ G4MaterialCutsCouple* G4Region::FindCouple(G4Material* mat)
return couple;
}
// ********************************************************************
// SetFastSimulationManager
// ********************************************************************
//
inline
void G4Region::SetFastSimulationManager(G4FastSimulationManager* fsm)
{
G4MT_fsmanager = fsm;
}
// ********************************************************************
// GetFastSimulationManager
// ********************************************************************
//
inline
G4FastSimulationManager* G4Region::GetFastSimulationManager() const
{
return G4MT_fsmanager;
}
// ********************************************************************
// GetFieldManager
// ********************************************************************
@@ -303,26 +283,6 @@ void G4Region::AddMaterial(G4Material* aMaterial)
}
}
// ********************************************************************
// SetRegionalSteppingAction
// ********************************************************************
//
inline
void G4Region::SetRegionalSteppingAction(G4UserSteppingAction* rusa)
{
G4MT_rsaction = rusa;
}
// ********************************************************************
// GetRegionalSteppingAction
// ********************************************************************
//
inline
G4UserSteppingAction* G4Region::GetRegionalSteppingAction() const
{
return G4MT_rsaction;
}
// ********************************************************************
// UsedInMassGeometry
// ********************************************************************
@@ -176,10 +176,6 @@ class G4USolid : public G4VSolid
return fShape;
}
protected:
G4ThreeVectorList* CreateRotatedVertices(const G4AffineTransform& pT) const;
protected: // data
VUSolid* fShape;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VPhysicalVolume.hh 93287 2015-10-15 09:50:22Z gcosmo $
// $Id: G4VPhysicalVolume.hh 99379 2016-09-20 09:45:19Z gcosmo $
//
//
// class G4VPhysicalVolume
@@ -115,26 +115,26 @@ class G4VPhysicalVolume
// (They are the inverse of each other).
G4RotationMatrix* GetObjectRotation() const; // Obsolete
inline G4RotationMatrix GetObjectRotationValue() const; // Replacement
inline G4ThreeVector GetObjectTranslation() const;
G4RotationMatrix GetObjectRotationValue() const; // Replacement
G4ThreeVector GetObjectTranslation() const;
// Return the rotation/translation of the Object relative to the mother.
inline const G4RotationMatrix* GetFrameRotation() const;
inline G4ThreeVector GetFrameTranslation() const;
const G4RotationMatrix* GetFrameRotation() const;
G4ThreeVector GetFrameTranslation() const;
// Return the rotation/translation of the Frame used to position
// this volume in its mother volume (opposite of object rot/trans).
// Older access functions, that do not distinguish between frame/object!
inline const G4ThreeVector& GetTranslation() const;
inline const G4RotationMatrix* GetRotation() const;
const G4ThreeVector& GetTranslation() const;
const G4RotationMatrix* GetRotation() const;
// Old access functions, that do not distinguish between frame/object!
// They return the translation/rotation of the volume.
// Set functions
inline void SetTranslation(const G4ThreeVector &v);
inline G4RotationMatrix* GetRotation();
inline void SetRotation(G4RotationMatrix*);
void SetTranslation(const G4ThreeVector &v);
G4RotationMatrix* GetRotation();
void SetRotation(G4RotationMatrix*);
// NOT INTENDED FOR GENERAL USE.
// Non constant versions of above. Used to change transformation
// for replication/parameterisation mechanism.
@@ -24,21 +24,13 @@
// ********************************************************************
//
//
// $Id: G4VPhysicalVolume.icc 74466 2013-10-07 15:36:32Z gcosmo $
// $Id: G4VPhysicalVolume.icc 99379 2016-09-20 09:45:19Z gcosmo $
//
//
// class G4VPhysicalVolume Inline Implementation
//
// --------------------------------------------------------------------
// These macros change the references to fields that are now encapsulated
// in the class G4PVData.
//
#define G4MT_rot ((subInstanceManager.offset[instanceID]).frot)
#define G4MT_trans ((subInstanceManager.offset[instanceID]).ftrans)
#define G4MT_pvdata (subInstanceManager.offset[instanceID])
inline
G4bool G4VPhysicalVolume::operator == (const G4VPhysicalVolume& right) const
{
@@ -51,37 +43,6 @@ G4int G4VPhysicalVolume::GetInstanceID() const
return instanceID;
}
inline
const G4ThreeVector& G4VPhysicalVolume::GetTranslation() const
{
return G4MT_trans;
}
inline
void G4VPhysicalVolume::SetTranslation(const G4ThreeVector &vec)
{
G4MT_trans=vec;
}
inline
const G4RotationMatrix* G4VPhysicalVolume::GetRotation() const
{
return G4MT_rot;
}
inline
G4RotationMatrix* G4VPhysicalVolume::GetRotation()
{
return G4MT_rot;
}
inline
void G4VPhysicalVolume::SetRotation(G4RotationMatrix *pRot)
{
G4MT_rot=pRot;
}
inline
G4LogicalVolume* G4VPhysicalVolume::GetLogicalVolume() const
{
@@ -137,37 +98,3 @@ EVolume G4VPhysicalVolume::VolumeType() const
}
return type;
}
inline
G4RotationMatrix G4VPhysicalVolume::GetObjectRotationValue() const
{
G4RotationMatrix aRotM; // Initialised to identity
// Insure against G4MT_rot being a null pointer
if(G4MT_rot)
{
aRotM= G4MT_rot->inverse();
}
return aRotM;
}
inline
G4ThreeVector G4VPhysicalVolume::GetObjectTranslation() const
{
return G4MT_trans;
}
inline
const G4RotationMatrix* G4VPhysicalVolume::GetFrameRotation() const
{
return G4MT_rot;
}
inline
G4ThreeVector G4VPhysicalVolume::GetFrameTranslation() const
{
return -G4MT_trans;
}
#undef G4MT_rot
#undef G4MT_trans
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VSolid.hh 92695 2015-09-14 08:49:44Z gcosmo $
// $Id: G4VSolid.hh 100906 2016-11-03 09:59:32Z gcosmo $
//
//
// class G4VSolid
@@ -108,6 +108,9 @@ class G4VSolid
inline G4double GetTolerance() const;
// Returns the cached geometrical tolerance.
virtual void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
// Returns the bounding box of the solid.
virtual G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
+5 -1
View File
@@ -11,7 +11,7 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake 97686 2016-06-07 09:27:32Z gcosmo $
# $Id: sources.cmake 100683 2016-10-31 10:56:21Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -44,8 +44,10 @@ GEANT4_DEFINE_MODULE(NAME G4geometrymng
G4ErrorTanPlaneTarget.hh
G4ErrorTarget.hh
G4GeomSplitter.hh
G4GeomTools.hh
G4GeometryManager.hh
G4IdentityTrajectoryFilter.hh
G4LogicalCrystalVolume.hh
G4LogicalSurface.hh
G4LogicalSurface.icc
G4LogicalVolume.hh
@@ -94,8 +96,10 @@ GEANT4_DEFINE_MODULE(NAME G4geometrymng
G4ErrorSurfaceTarget.cc
G4ErrorTanPlaneTarget.cc
G4ErrorTarget.cc
G4GeomTools.cc
G4GeometryManager.cc
G4IdentityTrajectoryFilter.cc
G4LogicalCrystalVolume.cc
G4LogicalSurface.cc
G4LogicalVolume.cc
G4LogicalVolumeStore.cc
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,593 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: $
//
//
// class G4GeomTools Implementation
//
// Author: evgueni.tcherniaev@cern.ch
//
// 10.10.2016 E.Tcherniaev: initial version.
// --------------------------------------------------------------------
#include "G4GeomTools.hh"
#include "geomdefs.hh"
#include "G4SystemOfUnits.hh"
#include "G4GeometryTolerance.hh"
///////////////////////////////////////////////////////////////////////
//
// Calculate area of a triangle in 2D
G4double G4GeomTools::TriangleArea(G4double Ax, G4double Ay,
G4double Bx, G4double By,
G4double Cx, G4double Cy)
{
return ((Bx-Ax)*(Cy-Ay) - (By-Ay)*(Cx-Ax))*0.5;
}
///////////////////////////////////////////////////////////////////////
//
// Calculate area of a triangle in 2D
G4double G4GeomTools::TriangleArea(const G4TwoVector& A,
const G4TwoVector& B,
const G4TwoVector& C)
{
G4double Ax = A.x(), Ay = A.y();
return ((B.x()-Ax)*(C.y()-Ay) - (B.y()-Ay)*(C.x()-Ax))*0.5;
}
///////////////////////////////////////////////////////////////////////
//
// Calculate area of a quadrilateral in 2D
G4double G4GeomTools::QuadArea(const G4TwoVector& A,
const G4TwoVector& B,
const G4TwoVector& C,
const G4TwoVector& D)
{
return ((C.x()-A.x())*(D.y()-B.y()) - (C.y()-A.y())*(D.x()-B.x()))*0.5;
}
///////////////////////////////////////////////////////////////////////
//
// Calculate area of a polygon in 2D
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)
{
area += p[k].x()*p[i].y() - p[i].x()*p[k].y();
}
return area*0.5;
}
///////////////////////////////////////////////////////////////////////
//
// Point inside 2D triangle
G4bool G4GeomTools::PointInTriangle(G4double Ax, G4double Ay,
G4double Bx, G4double By,
G4double Cx, G4double Cy,
G4double Px, G4double Py)
{
if ((Bx-Ax)*(Cy-Ay) - (By-Ay)*(Cx-Ax) > 0.)
{
if ((Ax-Cx)*(Py-Cy) - (Ay-Cy)*(Px-Cx) < 0.) return false;
if ((Bx-Ax)*(Py-Ay) - (By-Ay)*(Px-Ax) < 0.) return false;
if ((Cx-Bx)*(Py-By) - (Cy-By)*(Px-Bx) < 0.) return false;
}
else
{
if ((Ax-Cx)*(Py-Cy) - (Ay-Cy)*(Px-Cx) > 0.) return false;
if ((Bx-Ax)*(Py-Ay) - (By-Ay)*(Px-Ax) > 0.) return false;
if ((Cx-Bx)*(Py-By) - (Cy-By)*(Px-Bx) > 0.) return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////
//
// Point inside 2D triangle
G4bool G4GeomTools::PointInTriangle(const G4TwoVector& A,
const G4TwoVector& B,
const G4TwoVector& C,
const G4TwoVector& P)
{
G4double Ax = A.x(), Ay = A.y();
G4double Bx = B.x(), By = B.y();
G4double Cx = C.x(), Cy = C.y();
G4double Px = P.x(), Py = P.y();
if ((Bx-Ax)*(Cy-Ay) - (By-Ay)*(Cx-Ax) > 0.)
{
if ((Ax-Cx)*(Py-Cy) - (Ay-Cy)*(Px-Cx) < 0.) return false;
if ((Bx-Ax)*(Py-Ay) - (By-Ay)*(Px-Ax) < 0.) return false;
if ((Cx-Bx)*(Py-By) - (Cy-By)*(Px-Bx) < 0.) return false;
}
else
{
if ((Ax-Cx)*(Py-Cy) - (Ay-Cy)*(Px-Cx) > 0.) return false;
if ((Bx-Ax)*(Py-Ay) - (By-Ay)*(Px-Ax) > 0.) return false;
if ((Cx-Bx)*(Py-By) - (Cy-By)*(Px-Bx) > 0.) return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////
//
// Detemine whether 2D polygon is convex or not
G4bool G4GeomTools::IsConvex(const G4TwoVectorList& polygon)
{
static const G4double kCarTolerance =
G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
G4bool gotNegative = false;
G4bool gotPositive = false;
G4int n = polygon.size();
if (n <= 0) return false;
for (G4int icur=0; icur<n; ++icur)
{
G4int iprev = (icur == 0) ? n-1 : icur-1;
G4int inext = (icur == n-1) ? 0 : icur+1;
G4TwoVector e1 = polygon[icur] - polygon[iprev];
G4TwoVector e2 = polygon[inext] - polygon[icur];
G4double cross = e1.x()*e2.y() - e1.y()*e2.x();
if (std::abs(cross) < kCarTolerance) return false;
if (cross < 0) gotNegative = true;
if (cross > 0) gotPositive = true;
if (gotNegative && gotPositive) return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////
//
// Triangulate simple polygon
G4bool G4GeomTools::TriangulatePolygon(const G4TwoVectorList& polygon,
G4TwoVectorList& result)
{
result.resize(0);
std::vector<G4int> triangles;
G4bool reply = TriangulatePolygon(polygon,triangles);
G4int n = triangles.size();
for (G4int i=0; i<n; ++i) result.push_back(polygon[triangles[i]]);
return reply;
}
///////////////////////////////////////////////////////////////////////
//
// Triangulation of a simple polygon by "ear clipping"
G4bool G4GeomTools::TriangulatePolygon(const G4TwoVectorList& polygon,
std::vector<G4int>& result)
{
result.resize(0);
// allocate and initialize list of Vertices in polygon
//
G4int n = polygon.size();
if (n < 3) return false;
// we want a counter-clockwise polygon in V
//
G4double area = G4GeomTools::PolygonArea(polygon);
G4int* V = new G4int[n];
if (area > 0.)
for (G4int i=0; i<n; ++i) V[i] = i;
else
for (G4int i=0; i<n; ++i) V[i] = (n-1)-i;
// Triangulation: remove nv-2 Vertices, creating 1 triangle every time
//
G4int nv = n;
G4int count = 2*nv; // error detection counter
for(G4int b=nv-1; nv>2; )
{
// ERROR: if we loop, it is probably a non-simple polygon
if ((count--) <= 0)
{
delete[] V;
if (area < 0.) std::reverse(result.begin(),result.end());
return false;
}
// three consecutive vertices in current polygon, <a,b,c>
G4int a = (b < nv) ? b : 0; // previous
b = (a+1 < nv) ? a+1 : 0; // current
G4int c = (b+1 < nv) ? b+1 : 0; // next
if (CheckSnip(polygon, a,b,c, nv,V))
{
// output Triangle
result.push_back(V[a]);
result.push_back(V[b]);
result.push_back(V[c]);
// remove vertex b from remaining polygon
nv--;
for(G4int i=b; i<nv; ++i) V[i] = V[i+1];
count = 2*nv; // resest error detection counter
}
}
delete[] V;
if (area < 0.) std::reverse(result.begin(),result.end());
return true;
}
///////////////////////////////////////////////////////////////////////
//
// Helper function for "ear clipping" polygon triangulation.
// Check for a valid snip
G4bool G4GeomTools::CheckSnip(const G4TwoVectorList& contour,
G4int a, G4int b, G4int c,
G4int n, const G4int* V)
{
static const G4double kCarTolerance =
G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
// check orientation of Triangle
G4double Ax = contour[V[a]].x(), Ay = contour[V[a]].y();
G4double Bx = contour[V[b]].x(), By = contour[V[b]].y();
G4double Cx = contour[V[c]].x(), Cy = contour[V[c]].y();
if ((Bx-Ax)*(Cy-Ay) - (By-Ay)*(Cx-Ax) < kCarTolerance) return false;
// check that there is no point inside Triangle
G4double xmin = std::min(std::min(Ax,Bx),Cx);
G4double xmax = std::max(std::max(Ax,Bx),Cx);
G4double ymin = std::min(std::min(Ay,By),Cy);
G4double ymax = std::max(std::max(Ay,By),Cy);
for (G4int i=0; i<n; ++i)
{
if((i == a) || (i == b) || (i == c)) continue;
G4double Px = contour[V[i]].x();
if (Px < xmin || Px > xmax) continue;
G4double Py = contour[V[i]].y();
if (Py < ymin || Py > ymax) continue;
if (PointInTriangle(Ax,Ay,Bx,By,Cx,Cy,Px,Py)) return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////
//
// Remove collinear and coincident points from 2D polygon
void G4GeomTools::RemoveRedundantVertices(G4TwoVectorList& polygon,
std::vector<G4int>& iout,
G4double tolerance)
{
iout.resize(0);
// set tolerance squared
G4double delta = tolerance*tolerance;
// set special value to mark vertices for removal
G4double removeIt = kInfinity;
G4int nv = polygon.size();
// Main loop: check every three consecutive points, if the points
// are collinear then mark middle point for removal
//
G4int icur = 0, iprev = 0, inext = 0, nout = 0;
for (G4int i=0; i<nv; ++i)
{
icur = i; // index of current point
for (G4int k=1; k<nv+1; ++k) // set index of previous point
{
iprev = icur - k;
if (iprev < 0) iprev += nv;
if (polygon[iprev].x() != removeIt) break;
}
for (G4int k=1; k<nv+1; ++k) // set index of next point
{
inext = icur + k;
if (inext >= nv) inext -= nv;
if (polygon[inext].x() != removeIt) break;
}
if (iprev == inext) break; // degenerate polygon, stop
// Calculate parameters of triangle (iprev->icur->inext),
// if triangle is too small or too narrow then mark current
// point for removal
G4TwoVector e1 = polygon[iprev] - polygon[icur];
G4TwoVector e2 = polygon[inext] - polygon[icur];
// Check length of edges, then check height of the triangle
G4double leng1 = e1.mag2();
G4double leng2 = e2.mag2();
G4double leng3 = (e2-e1).mag2();
if (leng1 <= delta || leng2 <= delta || leng3 <= delta)
{
polygon[icur].setX(removeIt); nout++;
}
else
{
G4double lmax = std::max(std::max(leng1,leng2),leng3);
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++;
}
}
}
// Remove marked points
//
icur = 0;
if (nv - nout < 3) // degenerate polygon, remove all points
{
for (G4int i=0; i<nv; ++i) iout.push_back(i);
polygon.resize(0);
nv = 0;
}
for (G4int i=0; i<nv; ++i) // move points, if required
{
if (polygon[i].x() != removeIt)
polygon[icur++] = polygon[i];
else
iout.push_back(i);
}
if (icur < nv) polygon.resize(icur);
return;
}
///////////////////////////////////////////////////////////////////////
//
// Find bounding box of a disk sector
G4bool G4GeomTools::DiskExtent(G4double rmin, G4double rmax,
G4double startPhi, G4double delPhi,
G4TwoVector& pmin, G4TwoVector& pmax)
{
static const G4double kCarTolerance =
G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
// check parameters
//
pmin.set(0,0);
pmax.set(0,0);
if (rmin < 0) return false;
if (rmax <= rmin + kCarTolerance) return false;
if (delPhi <= 0 + kCarTolerance) return false;
// calculate extent
//
pmin.set(-rmax,-rmax);
pmax.set( rmax, rmax);
if (delPhi >= CLHEP::twopi) return true;
DiskExtent(rmin,rmax,
std::sin(startPhi),std::cos(startPhi),
std::sin(startPhi+delPhi),std::cos(startPhi+delPhi),
pmin,pmax);
return true;
}
///////////////////////////////////////////////////////////////////////
//
// Find bounding box of a disk sector, fast version.
// No check of parameters !!!
void G4GeomTools::DiskExtent(G4double rmin, G4double rmax,
G4double sinStart, G4double cosStart,
G4double sinEnd, G4double cosEnd,
G4TwoVector& pmin, G4TwoVector& pmax)
{
static const G4double kCarTolerance =
G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
// check if 360 degrees
//
pmin.set(-rmax,-rmax);
pmax.set( rmax, rmax);
if (std::abs(sinEnd-sinStart) < kCarTolerance &&
std::abs(cosEnd-cosStart) < kCarTolerance) return;
// get start and end quadrants
//
// 1 | 0
// ---+---
// 3 | 2
//
G4int icase = (cosEnd < 0) ? 1 : 0;
if (sinEnd < 0) icase += 2;
if (cosStart < 0) icase += 4;
if (sinStart < 0) icase += 8;
switch (icase)
{
// start quadrant 0
case 0: // start->end : 0->0
if (sinEnd < sinStart) break;
pmin.set(rmin*cosEnd,rmin*sinStart);
pmax.set(rmax*cosStart,rmax*sinEnd );
break;
case 1: // start->end : 0->1
pmin.set(rmax*cosEnd,std::min(rmin*sinStart,rmin*sinEnd));
pmax.set(rmax*cosStart,rmax );
break;
case 2: // start->end : 0->2
pmin.set(-rmax,-rmax);
pmax.set(std::max(rmax*cosStart,rmax*cosEnd),rmax);
break;
case 3: // start->end : 0->3
pmin.set(-rmax,rmax*sinEnd);
pmax.set(rmax*cosStart,rmax);
break;
// start quadrant 1
case 4: // start->end : 1->0
pmin.set(-rmax,-rmax);
pmax.set(rmax,std::max(rmax*sinStart,rmax*sinEnd));
break;
case 5: // start->end : 1->1
if (sinEnd > sinStart) break;
pmin.set(rmax*cosEnd,rmin*sinEnd );
pmax.set(rmin*cosStart,rmax*sinStart);
break;
case 6: // start->end : 1->2
pmin.set(-rmax,-rmax);
pmax.set(rmax*cosEnd,rmax*sinStart);
break;
case 7: // start->end : 1->3
pmin.set(-rmax,rmax*sinEnd);
pmax.set(std::max(rmin*cosStart,rmin*cosEnd),rmax*sinStart);
break;
// start quadrant 2
case 8: // start->end : 2->0
pmin.set(std::min(rmin*cosStart,rmin*cosEnd),rmax*sinStart);
pmax.set(rmax,rmax*sinEnd);
break;
case 9: // start->end : 2->1
pmin.set(rmax*cosEnd,rmax*sinStart);
pmax.set(rmax,rmax);
break;
case 10: // start->end : 2->2
if (sinEnd < sinStart) break;
pmin.set(rmin*cosStart,rmax*sinStart);
pmax.set(rmax*cosEnd,rmin*sinEnd );
break;
case 11: // start->end : 2->3
pmin.set(-rmax,std::min(rmax*sinStart,rmax*sinEnd));
pmax.set(rmax,rmax);
break;
// start quadrant 3
case 12: // start->end : 3->0
pmin.set(rmax*cosStart,-rmax);
pmax.set(rmax,rmax*sinEnd);
break;
case 13: // start->end : 3->1
pmin.set(std::min(rmax*cosStart,rmax*cosEnd),-rmax);
pmax.set(rmax,rmax);
break;
case 14: // start->end : 3->2
pmin.set(rmax*cosStart,-rmax);
pmax.set(rmax*cosEnd,std::max(rmin*sinStart,rmin*sinEnd));
break;
case 15: // start->end : 3->3
if (sinEnd > sinStart) break;
pmin.set(rmax*cosStart,rmax*sinEnd);
pmax.set(rmin*cosEnd,rmin*sinStart);
break;
}
return;
}
///////////////////////////////////////////////////////////////////////
//
// Calculate distance between point P and line segment AB in 3D
G4double G4GeomTools::DistancePointSegment(G4ThreeVector P,
G4ThreeVector A,
G4ThreeVector B)
{
G4ThreeVector AP = P - A;
G4ThreeVector AB = B - A;
G4double u = AP.dot(AB);
if (u <= 0) return AP.mag(); // closest point is A
G4double len2 = AB.mag2();
if (u >= len2) return (B-P).mag(); // closest point is B
return ((u/len2)*AB - AP).mag(); // distance to line
}
///////////////////////////////////////////////////////////////////////
//
// Calculate bounding box of a spherical sector
G4bool
G4GeomTools::SphereExtent(G4double rmin, G4double rmax,
G4double startTheta, G4double delTheta,
G4double startPhi, G4double delPhi,
G4ThreeVector& pmin, G4ThreeVector& pmax)
{
static const G4double kCarTolerance =
G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
// check parameters
//
pmin.set(0,0,0);
pmax.set(0,0,0);
if (rmin < 0) return false;
if (rmax <= rmin + kCarTolerance) return false;
if (delTheta <= 0 + kCarTolerance) return false;
if (delPhi <= 0 + kCarTolerance) return false;
G4double stheta = startTheta;
G4double dtheta = delTheta;
if (stheta < 0 && stheta > CLHEP::pi) return false;
if (stheta + dtheta > CLHEP::pi) dtheta = CLHEP::pi - stheta;
if (dtheta <= 0 + kCarTolerance) return false;
// calculate extent
//
pmin.set(-rmax,-rmax,-rmax);
pmax.set( rmax, rmax, rmax);
if (dtheta >= CLHEP::pi && delPhi >= CLHEP::twopi) return true;
G4double etheta = stheta + dtheta;
G4double sinStart = std::sin(stheta);
G4double cosStart = std::cos(stheta);
G4double sinEnd = std::sin(etheta);
G4double cosEnd = std::cos(etheta);
G4double rhomin = rmin*std::min(sinStart,sinEnd);
G4double rhomax = rmax;
if (stheta > CLHEP::halfpi) rhomax = rmax*sinStart;
if (etheta < CLHEP::halfpi) rhomax = rmax*sinEnd;
G4TwoVector xymin,xymax;
DiskExtent(rhomin,rhomax,
std::sin(startPhi),std::cos(startPhi),
std::sin(startPhi+delPhi),std::cos(startPhi+delPhi),
xymin,xymax);
G4double zmin = std::min(rmin*cosEnd,rmax*cosEnd);
G4double zmax = std::max(rmin*cosStart,rmax*cosStart);
pmin.set(xymin.x(),xymin.y(),zmin);
pmax.set(xymax.x(),xymax.y(),zmax);
return true;
}
@@ -0,0 +1,138 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
//
// Implementation of G4LogicalCrystalVolume
//
// 21-04-16, created by E.Bagli
//
// --------------------------------------------------------------------
#include "G4LogicalCrystalVolume.hh"
#include "G4ExtendedMaterial.hh"
#include "G4CrystalExtension.hh"
#include "G4VMaterialExtension.hh"
std::vector<G4LogicalVolume*> G4LogicalCrystalVolume::fLCVvec;
// --------------------------------------------------------------------
G4LogicalCrystalVolume::
G4LogicalCrystalVolume(G4VSolid* pSolid, G4ExtendedMaterial* pMaterial,
const G4String& name, G4FieldManager* pFieldMgr,
G4VSensitiveDetector* pSDetector,
G4UserLimits* pULimits, G4bool optimise,
G4int h, G4int k, G4int l, G4double rot)
: G4LogicalVolume(pSolid,pMaterial,name,pFieldMgr,pSDetector,pULimits,optimise),
hMiller(1), kMiller(0), lMiller(0), fRot(0), verboseLevel(0)
{
SetMillerOrientation(h, k, l, rot);
fLCVvec.push_back(this);
}
// --------------------------------------------------------------------
G4LogicalCrystalVolume::~G4LogicalCrystalVolume()
{
fLCVvec.erase( std::remove(fLCVvec.begin(),fLCVvec.end(), this ),
fLCVvec.end() );
}
// --------------------------------------------------------------------
G4bool G4LogicalCrystalVolume::IsLattice(G4LogicalVolume* aLV)
{
return std::find(fLCVvec.begin(), fLCVvec.end(), aLV) != fLCVvec.end();
}
// --------------------------------------------------------------------
const G4CrystalExtension* G4LogicalCrystalVolume::GetCrystal() const
{
return dynamic_cast<G4CrystalExtension*>(dynamic_cast<G4ExtendedMaterial*>(GetMaterial())
->RetrieveExtension("crystal"));
}
// --------------------------------------------------------------------
const G4ThreeVector& G4LogicalCrystalVolume::GetBasis(G4int i) const
{
return GetCrystal()->GetUnitCell()->GetBasis(i);
}
// --------------------------------------------------------------------
void G4LogicalCrystalVolume::SetMillerOrientation(G4int h,
G4int k,
G4int l,
G4double rot)
{
// Align Miller normal vector (hkl) with +Z axis, and rotation about axis
if (verboseLevel)
{
G4cout << "G4LatticePhysical::SetMillerOrientation(" << h << " "
<< k << " " << l << ", " << rot/CLHEP::deg << " deg)" << G4endl;
}
hMiller = h;
kMiller = k;
lMiller = l;
fRot = rot;
G4ThreeVector norm = (h*GetBasis(0)+k*GetBasis(1)+l*GetBasis(2)).unit();
if (verboseLevel>1) G4cout << " norm = " << norm << G4endl;
// Aligns geometry +Z axis with lattice (hkl) normal
fOrient = G4RotationMatrix::IDENTITY;
fOrient.rotateZ(rot).rotateY(norm.theta()).rotateZ(norm.phi());
fInverse = fOrient.inverse();
if (verboseLevel>1) G4cout << " fOrient = " << fOrient << G4endl;
// FIXME: Is this equivalent to (phi,theta,rot) Euler angles???
}
// --------------------------------------------------------------------
// Rotate input vector between lattice and solid orientations
const G4ThreeVector&
G4LogicalCrystalVolume::RotateToLattice(G4ThreeVector& dir) const
{
return dir.transform(fOrient);
}
const G4ThreeVector&
G4LogicalCrystalVolume::RotateToSolid(G4ThreeVector& dir) const
{
return dir.transform(fInverse);
}
// --------------------------------------------------------------------
+289 -71
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4LogicalVolume.cc 93287 2015-10-15 09:50:22Z gcosmo $
// $Id: G4LogicalVolume.cc 100906 2016-11-03 09:59:32Z gcosmo $
//
//
// class G4LogicalVolume Implementation
@@ -40,12 +40,6 @@
// --------------------------------------------------------------------
#include "G4LogicalVolume.hh"
#ifdef NO_INLINE
#define inline
#include "G4LogicalVolume.icc"
#undef inline
#endif
#include "G4LogicalVolumeStore.hh"
#include "G4VSolid.hh"
#include "G4Material.hh"
@@ -54,12 +48,6 @@
#include "G4UnitsTable.hh"
// This static member is thread local. For each thread, it points to the
// array of G4LVData instances.
//
template <class G4LVData> G4ThreadLocal
G4LVData* G4GeomSplitter<G4LVData>::offset = 0;
G4LVData::G4LVData()
: fSolid(0),fSensitiveDetector(0),fFieldManager(0),
fMaterial(0),fMass(0.),fCutsCouple(0)
@@ -69,65 +57,16 @@ G4LVData::G4LVData()
//
G4LVManager G4LogicalVolume::subInstanceManager;
// ********************************************************************
// InitialiseWorker
// These macros change the references to fields that are now encapsulated
// in the class G4LVData.
//
// This method is similar to the constructor. It is used by each worker
// thread to achieve the same effect as that of the master thread exept
// to register the new created instance. This method is invoked explicitly.
// It does not create a new G4LogicalVolume instance. It only assign the value
// for the fields encapsulated by the class G4LVData.
// ********************************************************************
//
void G4LogicalVolume::
InitialiseWorker( G4LogicalVolume* /*pMasterObject*/,
G4VSolid* pSolid,
G4VSensitiveDetector* pSDetector)
{
subInstanceManager.SlaveCopySubInstanceArray();
SetSolid(pSolid);
SetSensitiveDetector(pSDetector); // How this object is available now ?
AssignFieldManager(fFieldManager); // Should be set - but a per-thread copy is not available yet
// G4MT_fmanager= fFieldManager;
// Must not call SetFieldManager(fFieldManager, false); which propagates FieldMgr
#ifdef CLONE_FIELD_MGR
// Create a field FieldManager by cloning
G4FieldManager workerFldMgr= fFieldManager->GetWorkerClone(G4bool* created);
if( created || (GetFieldManager()!=workerFldMgr) )
{
SetFieldManager(fFieldManager, false); // which propagates FieldMgr
}else{
// Field manager existed and is equal to current one
AssignFieldManager(workerFldMgr);
}
#endif
}
// ********************************************************************
// TerminateWorker
//
// 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 G4LogicalVolume instances, nothing more to do here.
// ********************************************************************
//
void G4LogicalVolume::
TerminateWorker( G4LogicalVolume* /*pMasterObject*/)
{
}
// ********************************************************************
// GetSubInstanceManager
//
// Returns the private data instance manager.
// ********************************************************************
//
const G4LVManager& G4LogicalVolume::GetSubInstanceManager()
{
return subInstanceManager;
}
#define G4MT_solid ((subInstanceManager.offset[instanceID]).fSolid)
#define G4MT_sdetector ((subInstanceManager.offset[instanceID]).fSensitiveDetector)
#define G4MT_fmanager ((subInstanceManager.offset[instanceID]).fFieldManager)
#define G4MT_material ((subInstanceManager.offset[instanceID]).fMaterial)
#define G4MT_mass ((subInstanceManager.offset[instanceID]).fMass)
#define G4MT_ccouple ((subInstanceManager.offset[instanceID]).fCutsCouple)
#define G4MT_instance (subInstanceManager.offset[instanceID])
// ********************************************************************
// Constructor - sets member data and adds to logical Store,
@@ -215,6 +154,94 @@ G4LogicalVolume::~G4LogicalVolume()
G4LogicalVolumeStore::DeRegister(this);
}
// ********************************************************************
// InitialiseWorker
//
// This method is similar to the constructor. It is used by each worker
// thread to achieve the same effect as that of the master thread exept
// to register the new created instance. This method is invoked explicitly.
// It does not create a new G4LogicalVolume instance. It only assign the value
// for the fields encapsulated by the class G4LVData.
// ********************************************************************
//
void G4LogicalVolume::
InitialiseWorker( G4LogicalVolume* /*pMasterObject*/,
G4VSolid* pSolid,
G4VSensitiveDetector* pSDetector)
{
subInstanceManager.SlaveCopySubInstanceArray();
SetSolid(pSolid);
SetSensitiveDetector(pSDetector); // How this object is available now ?
AssignFieldManager(fFieldManager); // Should be set - but a per-thread copy is not available yet
// G4MT_fmanager= fFieldManager;
// Must not call SetFieldManager(fFieldManager, false); which propagates FieldMgr
#ifdef CLONE_FIELD_MGR
// Create a field FieldManager by cloning
G4FieldManager workerFldMgr= fFieldManager->GetWorkerClone(G4bool* created);
if( created || (GetFieldManager()!=workerFldMgr) )
{
SetFieldManager(fFieldManager, false); // which propagates FieldMgr
}else{
// Field manager existed and is equal to current one
AssignFieldManager(workerFldMgr);
}
#endif
}
// ********************************************************************
// TerminateWorker
//
// 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 G4LogicalVolume instances, nothing more to do here.
// ********************************************************************
//
void G4LogicalVolume::
TerminateWorker( G4LogicalVolume* /*pMasterObject*/)
{
}
// ********************************************************************
// GetSubInstanceManager
//
// Returns the private data instance manager.
// ********************************************************************
//
const G4LVManager& G4LogicalVolume::GetSubInstanceManager()
{
return subInstanceManager;
}
// ********************************************************************
// GetFieldManager
// ********************************************************************
//
G4FieldManager* G4LogicalVolume::GetFieldManager() const
{
return G4MT_fmanager;
}
// ********************************************************************
// AssignFieldManager
// ********************************************************************
//
void G4LogicalVolume::AssignFieldManager( G4FieldManager *fldMgr)
{
G4MT_fmanager= fldMgr;
if(G4Threading::IsMasterThread()) fFieldManager = fldMgr;
}
// ********************************************************************
// IsExtended
// ********************************************************************
//
G4bool G4LogicalVolume::IsExtended() const
{
return false;
}
// ********************************************************************
// SetFieldManager
// ********************************************************************
@@ -238,6 +265,196 @@ G4LogicalVolume::SetFieldManager(G4FieldManager* pNewFieldMgr,
}
}
// ********************************************************************
// AddDaughter
// ********************************************************************
//
void G4LogicalVolume::AddDaughter(G4VPhysicalVolume* pNewDaughter)
{
if( !fDaughters.empty() && fDaughters[0]->IsReplicated() )
{
std::ostringstream message;
message << "ERROR - Attempt to place a volume in a mother volume" << G4endl
<< " already containing a replicated volume." << G4endl
<< " A volume can either contain several placements" << G4endl
<< " or a unique replica or parameterised volume !" << G4endl
<< " Mother logical volume: " << GetName() << G4endl
<< " Placing volume: " << pNewDaughter->GetName() << G4endl;
G4Exception("G4LogicalVolume::AddDaughter()", "GeomMgt0002",
FatalException, message,
"Replica or parameterised volume must be the only daughter !");
}
// Invalidate previous calculation of mass - if any - for all threads
G4MT_mass = 0.;
// SignalVolumeChange(); // fVolumeChanged= true;
fDaughters.push_back(pNewDaughter);
G4LogicalVolume* pDaughterLogical = pNewDaughter->GetLogicalVolume();
// Propagate the Field Manager, if the daughter has no field Manager.
//
G4FieldManager* pDaughterFieldManager = pDaughterLogical->GetFieldManager();
if( pDaughterFieldManager == 0 )
{
pDaughterLogical->SetFieldManager(G4MT_fmanager, false);
}
if (fRegion)
{
PropagateRegion();
fRegion->RegionModified(true);
}
}
// ********************************************************************
// RemoveDaughter
// ********************************************************************
//
void G4LogicalVolume::RemoveDaughter(const G4VPhysicalVolume* p)
{
G4PhysicalVolumeList::iterator i;
for ( i=fDaughters.begin(); i!=fDaughters.end(); ++i )
{
if (**i==*p)
{
fDaughters.erase(i);
break;
}
}
if (fRegion)
{
fRegion->RegionModified(true);
}
G4MT_mass = 0.;
}
// ********************************************************************
// ClearDaughters
// ********************************************************************
//
void G4LogicalVolume::ClearDaughters()
{
fDaughters.erase(fDaughters.begin(), fDaughters.end());
if (fRegion)
{
fRegion->RegionModified(true);
}
G4MT_mass = 0.;
}
// ********************************************************************
// ResetMass
// ********************************************************************
//
void G4LogicalVolume::ResetMass()
{
G4MT_mass= 0.0;
}
// ********************************************************************
// GetSolid
// ********************************************************************
//
G4VSolid* G4LogicalVolume::GetSolid(G4LVData &instLVdata) // const
{
return instLVdata.fSolid;
}
G4VSolid* G4LogicalVolume::GetSolid() const
{
// return G4MT_solid;
// return ((subInstanceManager.offset[instanceID]).fSolid);
return this->GetSolid( subInstanceManager.offset[instanceID] );
}
// ********************************************************************
// SetSolid
// ********************************************************************
//
void G4LogicalVolume::SetSolid(G4VSolid *pSolid)
{
// ((subInstanceManager.offset[instanceID]).fSolid) = pSolid;
G4MT_solid=pSolid;
// G4MT_mass = 0.;
this->ResetMass();
}
void G4LogicalVolume::SetSolid(G4LVData &instLVdata, G4VSolid *pSolid)
{
instLVdata.fSolid = pSolid;
// G4MT_solid=pSolid;
instLVdata.fMass= 0;
// A fast way to reset the mass ... ie G4MT_mass = 0.;
}
// ********************************************************************
// GetMaterial
// ********************************************************************
//
G4Material* G4LogicalVolume::GetMaterial() const
{
return G4MT_material;
}
// ********************************************************************
// SetMaterial
// ********************************************************************
//
void G4LogicalVolume::SetMaterial(G4Material *pMaterial)
{
G4MT_material=pMaterial;
G4MT_mass = 0.;
}
// ********************************************************************
// UpdateMaterial
// ********************************************************************
//
void G4LogicalVolume::UpdateMaterial(G4Material *pMaterial)
{
G4MT_material=pMaterial;
if(fRegion) { G4MT_ccouple = fRegion->FindCouple(pMaterial); }
G4MT_mass = 0.;
}
// ********************************************************************
// GetSensitiveDetector
// ********************************************************************
//
G4VSensitiveDetector* G4LogicalVolume::GetSensitiveDetector() const
{
return G4MT_sdetector;
}
// ********************************************************************
// SetSensitiveDetector
// ********************************************************************
//
void G4LogicalVolume::SetSensitiveDetector(G4VSensitiveDetector* pSDetector)
{
G4MT_sdetector = pSDetector;
if(G4Threading::IsMasterThread()) fSensitiveDetector = pSDetector;
}
// ********************************************************************
// GetMaterialCutsCouple
// ********************************************************************
//
const G4MaterialCutsCouple* G4LogicalVolume::GetMaterialCutsCouple() const
{
return G4MT_ccouple;
}
// ********************************************************************
// SetMaterialCutsCouple
// ********************************************************************
//
void G4LogicalVolume::SetMaterialCutsCouple(G4MaterialCutsCouple* cuts)
{
G4MT_ccouple = cuts;
}
// ********************************************************************
// IsAncestor
@@ -392,3 +609,4 @@ void G4LogicalVolume::SetVisAttributes (const G4VisAttributes& VA)
{
fVisAttributes = new G4VisAttributes(VA);
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ReflectedSolid.cc 97686 2016-06-07 09:27:32Z gcosmo $
// $Id: G4ReflectedSolid.cc 100906 2016-11-03 09:59:32Z gcosmo $
//
//
// Implementation for G4ReflectedSolid class
@@ -34,7 +34,6 @@
// --------------------------------------------------------------------
#include "G4ReflectedSolid.hh"
#include "G4BoundingEnvelope.hh"
#include <sstream>
@@ -42,6 +41,7 @@
#include "G4Vector3D.hh"
#include "G4AffineTransform.hh"
#include "G4Transform3D.hh"
#include "G4VoxelLimits.hh"
#include "G4VPVParameterisation.hh"
@@ -129,6 +129,7 @@ G4VSolid* G4ReflectedSolid::GetConstituentMovedSolid() const
}
/////////////////////////////////////////////////////////////////////////////
//
G4Transform3D G4ReflectedSolid::GetTransform3D() const
{
@@ -147,37 +148,113 @@ void G4ReflectedSolid::SetDirectTransform3D(G4Transform3D& transform)
fRebuildPolyhedron = true;
}
///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Get bounding box
void G4ReflectedSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
{
fPtrSolid->Extent(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();
G4double yy = fDirectTransform3D->yy();
G4double zz = fDirectTransform3D->zz();
if (std::abs(xx) == 1 && std::abs(yy) == 1 && std::abs(zz) == 1)
{
// Special case of reflection in axis and pure translation
//
if (xx == -1) { G4double tmp = -xmin; xmin = -xmax; xmax = tmp; }
if (yy == -1) { G4double tmp = -ymin; ymin = -ymax; ymax = tmp; }
if (zz == -1) { G4double tmp = -zmin; zmin = -zmax; zmax = tmp; }
xmin += fDirectTransform3D->dx();
xmax += fDirectTransform3D->dx();
ymin += fDirectTransform3D->dy();
ymax += fDirectTransform3D->dy();
zmin += fDirectTransform3D->dz();
zmax += fDirectTransform3D->dz();
}
else
{
// Use additional reflection in Z to set up affine transformation
//
G4Transform3D transform3D = G4ReflectZ3D()*(*fDirectTransform3D);
G4AffineTransform transform(transform3D.getRotation().inverse(),
transform3D.getTranslation());
// Find bounding box
//
G4VoxelLimits unLimit;
fPtrSolid->CalculateExtent(kXAxis,unLimit,transform,xmin,xmax);
fPtrSolid->CalculateExtent(kYAxis,unLimit,transform,ymin,ymax);
fPtrSolid->CalculateExtent(kZAxis,unLimit,transform,zmin,zmax);
}
pMin.set(xmin,ymin,-zmax);
pMax.set(xmax,ymax,-zmin);
// Check correctness of the bounding box
//
if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
{
std::ostringstream message;
message << "Bad bounding box (min >= max) for solid: "
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4ReflectedSolid::Extent()", "GeomMgt0001",
JustWarning, message);
DumpInfo();
}
}
//////////////////////////////////////////////////////////////////////////
//
// Calculate extent under transform and specified limit
G4bool
G4ReflectedSolid::CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4VoxelLimits& pVoxelLimits,
const G4AffineTransform& pTransform,
G4double& pMin,
G4double& pMax ) const
{
G4VoxelLimits unLimit;
G4AffineTransform unTransform;
// Separation of transformations. Calculation of the extent is done
// in a reflection of the global space. In such way, the voxel is
// reflected, but the solid is transformed just by G4AffineTransform.
// It allows to use CalculateExtent() of the solid.
// Find bounding box
G4double x1,x2,y1,y2,z1,z2;
fPtrSolid->CalculateExtent(kXAxis,unLimit,unTransform,x1,x2);
fPtrSolid->CalculateExtent(kYAxis,unLimit,unTransform,y1,y2);
fPtrSolid->CalculateExtent(kZAxis,unLimit,unTransform,z1,z2);
G4BoundingEnvelope bbox(G4Point3D(x1,y1,z1),
G4Point3D(x2,y2,z2),kCarTolerance);
// Reflect voxel limits in Z
//
G4VoxelLimits limits;
limits.AddLimit(kXAxis, pVoxelLimits.GetMinXExtent(),
pVoxelLimits.GetMaxXExtent());
limits.AddLimit(kYAxis, pVoxelLimits.GetMinYExtent(),
pVoxelLimits.GetMaxYExtent());
limits.AddLimit(kZAxis,-pVoxelLimits.GetMaxZExtent(),
-pVoxelLimits.GetMinZExtent());
// Set combined transformation
G4Transform3D transform3D =
G4Transform3D(pTransform.NetRotation().inverse(),
pTransform.NetTranslation())*(*fDirectTransform3D);
// Set affine transformation
//
G4Transform3D transform3D = G4ReflectZ3D()*pTransform*(*fDirectTransform3D);
G4AffineTransform transform(transform3D.getRotation().inverse(),
transform3D.getTranslation());
// Find extent
return bbox.CalculateExtent(pAxis,pVoxelLimit,transform3D,pMin,pMax);
//
if (!fPtrSolid->CalculateExtent(pAxis, limits, transform, pMin, pMax))
{
return false;
}
if (pAxis == kZAxis)
{
G4double tmp= -pMin; pMin= -pMax; pMax= tmp;
}
return true;
}
//////////////////////////////////////////////////////////////
//
//
+41 -5
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Region.cc 91803 2015-08-06 12:17:01Z gcosmo $
// $Id: G4Region.cc 100428 2016-10-21 12:59:37Z gcosmo $
//
//
// class G4Region Implementation
@@ -40,11 +40,11 @@
#include "G4VUserRegionInformation.hh"
#include "G4Material.hh"
// This static member is thread local. For each thread, it points to the
// array of G4RegionData instances.
// These macros changes the references to fields that are now encapsulated
// in the class G4RegionData.
//
template <class G4RegionData> G4ThreadLocal
G4RegionData* G4GeomSplitter<G4RegionData>::offset = 0;
#define G4MT_fsmanager ((subInstanceManager.offset[instanceID]).fFastSimulationManager)
#define G4MT_rsaction ((subInstanceManager.offset[instanceID]).fRegionalSteppingAction)
// This new field helps to use the class G4RegionManager
//
@@ -121,6 +121,42 @@ G4Region::~G4Region()
if(fUserInfo) delete fUserInfo;
}
// ********************************************************************
// SetFastSimulationManager
// ********************************************************************
//
void G4Region::SetFastSimulationManager(G4FastSimulationManager* fsm)
{
G4MT_fsmanager = fsm;
}
// ********************************************************************
// GetFastSimulationManager
// ********************************************************************
//
G4FastSimulationManager* G4Region::GetFastSimulationManager() const
{
return G4MT_fsmanager;
}
// ********************************************************************
// SetRegionalSteppingAction
// ********************************************************************
//
void G4Region::SetRegionalSteppingAction(G4UserSteppingAction* rusa)
{
G4MT_rsaction = rusa;
}
// ********************************************************************
// GetRegionalSteppingAction
// ********************************************************************
//
G4UserSteppingAction* G4Region::GetRegionalSteppingAction() const
{
return G4MT_rsaction;
}
// *******************************************************************
// ScanVolumeTree:
// - Scans recursively the 'lv' logical volume tree, retrieves
+25 -201
View File
@@ -43,6 +43,7 @@
#include "G4VisExtent.hh"
#include "G4PhysicalConstants.hh"
#include "G4GeometryTolerance.hh"
#include "G4BoundingEnvelope.hh"
#include "G4AutoLock.hh"
@@ -194,154 +195,27 @@ G4bool G4USolid::CalculateExtent(const EAxis pAxis,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const
{
if (!pTransform.IsRotated())
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())
{
VUSolid::EAxisType eAxis = VUSolid::eXaxis;
G4double offset = pTransform.NetTranslation().x();
if (pAxis == kYAxis)
{
eAxis = VUSolid::eYaxis;
offset = pTransform.NetTranslation().y();
}
if (pAxis == kZAxis)
{
eAxis = VUSolid::eZaxis;
offset = pTransform.NetTranslation().z();
}
fShape->ExtentAxis(eAxis, pMin, pMax);
pMin += offset;
pMax += offset;
if (pVoxelLimit.IsLimited())
{
switch (pAxis)
{
case kXAxis:
if ((pMin > pVoxelLimit.GetMaxXExtent() + kCarTolerance) ||
(pMax < pVoxelLimit.GetMinXExtent() - kCarTolerance))
{
return false;
}
else
{
pMin = std::max(pMin, pVoxelLimit.GetMinXExtent());
pMax = std::min(pMax, pVoxelLimit.GetMaxXExtent());
}
break;
case kYAxis:
if ((pMin > pVoxelLimit.GetMaxYExtent() + kCarTolerance) ||
(pMax < pVoxelLimit.GetMinYExtent() - kCarTolerance))
{
return false;
}
else
{
pMin = std::max(pMin, pVoxelLimit.GetMinYExtent());
pMax = std::min(pMax, pVoxelLimit.GetMaxYExtent());
}
break;
case kZAxis:
if ((pMin > pVoxelLimit.GetMaxZExtent() + kCarTolerance) ||
(pMax < pVoxelLimit.GetMinZExtent() - kCarTolerance))
{
return false;
}
else
{
pMin = std::max(pMin, pVoxelLimit.GetMinZExtent());
pMax = std::min(pMax, pVoxelLimit.GetMaxZExtent());
}
break;
default:
break;
}
pMin -= kCarTolerance ;
pMax += kCarTolerance ;
}
return true;
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);
}
else // General rotated case - create and clip mesh to boundaries
{
// Rotate BoundingBox and Calculate Extent as for BREPS
G4bool existsAfterClip = false ;
G4ThreeVectorList* vertices ;
pMin = +kInfinity ;
pMax = -kInfinity ;
// Calculate rotated vertex coordinates
vertices = CreateRotatedVertices(pTransform) ;
ClipCrossSection(vertices, 0, pVoxelLimit, pAxis, pMin, pMax) ;
ClipCrossSection(vertices, 4, pVoxelLimit, pAxis, pMin, pMax) ;
ClipBetweenSections(vertices, 0, pVoxelLimit, pAxis, pMin, pMax) ;
if (pVoxelLimit.IsLimited(pAxis) == false)
{
if ((pMin != kInfinity) || (pMax != -kInfinity))
{
existsAfterClip = true ;
// Add 2*tolerance to avoid precision troubles
pMin -= kCarTolerance;
pMax += kCarTolerance;
}
}
else
{
G4ThreeVector clipCentre(
(pVoxelLimit.GetMinXExtent() + pVoxelLimit.GetMaxXExtent()) * 0.5,
(pVoxelLimit.GetMinYExtent() + pVoxelLimit.GetMaxYExtent()) * 0.5,
(pVoxelLimit.GetMinZExtent() + pVoxelLimit.GetMaxZExtent()) * 0.5);
if ((pMin != kInfinity) || (pMax != -kInfinity))
{
existsAfterClip = true ;
// Check to see if endpoints are in the solid
clipCentre(pAxis) = pVoxelLimit.GetMinExtent(pAxis);
if (Inside(pTransform.Inverse().TransformPoint(clipCentre)) != kOutside)
{
pMin = pVoxelLimit.GetMinExtent(pAxis);
}
else
{
pMin -= kCarTolerance;
}
clipCentre(pAxis) = pVoxelLimit.GetMaxExtent(pAxis);
if (Inside(pTransform.Inverse().TransformPoint(clipCentre)) != kOutside)
{
pMax = pVoxelLimit.GetMaxExtent(pAxis);
}
else
{
pMax += kCarTolerance;
}
}
// Check for case where completely enveloping clipping volume
// If point inside then we are confident that the solid completely
// envelopes the clipping volume. Hence set min/max extents according
// to clipping volume extents along the specified axis.
else if (Inside(pTransform.Inverse().TransformPoint(clipCentre))
!= kOutside)
{
existsAfterClip = true ;
pMin = pVoxelLimit.GetMinExtent(pAxis) ;
pMax = pVoxelLimit.GetMaxExtent(pAxis) ;
}
}
delete vertices;
return existsAfterClip;
}
G4BoundingEnvelope bbox(bmin,bmax);
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
}
void G4USolid::ComputeDimensions(G4VPVParameterisation*,
@@ -410,47 +284,6 @@ G4VSolid* G4USolid::Clone() const
return 0;
}
G4ThreeVectorList*
G4USolid::CreateRotatedVertices(const G4AffineTransform& pTransform) const
{
G4double xMin, xMax, yMin, yMax, zMin, zMax;
fShape->ExtentAxis(VUSolid::eXaxis, xMin, xMax);
fShape->ExtentAxis(VUSolid::eYaxis, yMin, yMax);
fShape->ExtentAxis(VUSolid::eZaxis, zMin, zMax);
G4ThreeVectorList* vertices;
vertices = new G4ThreeVectorList();
if (vertices)
{
vertices->reserve(8);
G4ThreeVector vertex0(xMin, yMin, zMin);
G4ThreeVector vertex1(xMax, yMin, zMin);
G4ThreeVector vertex2(xMax, yMax, zMin);
G4ThreeVector vertex3(xMin, yMax, zMin);
G4ThreeVector vertex4(xMin, yMin, zMax);
G4ThreeVector vertex5(xMax, yMin, zMax);
G4ThreeVector vertex6(xMax, yMax, zMax);
G4ThreeVector vertex7(xMin, yMax, zMax);
vertices->push_back(pTransform.TransformPoint(vertex0));
vertices->push_back(pTransform.TransformPoint(vertex1));
vertices->push_back(pTransform.TransformPoint(vertex2));
vertices->push_back(pTransform.TransformPoint(vertex3));
vertices->push_back(pTransform.TransformPoint(vertex4));
vertices->push_back(pTransform.TransformPoint(vertex5));
vertices->push_back(pTransform.TransformPoint(vertex6));
vertices->push_back(pTransform.TransformPoint(vertex7));
}
else
{
G4Exception("G4VUSolid::CreateRotatedVertices()", "FatalError",
FatalException, "Out of memory - Cannot allocate vertices!");
}
return vertices;
}
G4Polyhedron* G4USolid::CreatePolyhedron() const
{
// Must be implemented in concrete wrappers...
@@ -479,22 +312,13 @@ G4Polyhedron* G4USolid::GetPolyhedron() const
return fPolyhedron;
}
G4VisExtent G4USolid:: GetExtent() const
G4VisExtent G4USolid::GetExtent() const
{
G4VisExtent extent;
G4VoxelLimits voxelLimits; // Defaults to "infinite" limits.
G4AffineTransform affineTransform;
G4double vmin, vmax;
CalculateExtent(kXAxis, voxelLimits, affineTransform, vmin, vmax);
extent.SetXmin(vmin);
extent.SetXmax(vmax);
CalculateExtent(kYAxis, voxelLimits, affineTransform, vmin, vmax);
extent.SetYmin(vmin);
extent.SetYmax(vmax);
CalculateExtent(kZAxis, voxelLimits, affineTransform, vmin, vmax);
extent.SetZmin(vmin);
extent.SetZmax(vmax);
return extent;
UVector3 vmin, vmax;
fShape->Extent(vmin,vmax);
return G4VisExtent(vmin.x(),vmax.x(),
vmin.y(),vmax.y(),
vmin.z(),vmax.z());
}
#endif // G4GEOM_USE_USOLIDS
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VPhysicalVolume.cc 93287 2015-10-15 09:50:22Z gcosmo $
// $Id: G4VPhysicalVolume.cc 100428 2016-10-21 12:59:37Z gcosmo $
//
//
// class G4VPhysicalVolume Implementation
@@ -36,48 +36,16 @@
#include "G4PhysicalVolumeStore.hh"
#include "G4LogicalVolume.hh"
// This static member is thread local. For each thread, it points to the
// array of G4PVData instances.
//
template <class G4PVData> G4ThreadLocal
G4PVData* G4GeomSplitter<G4PVData>::offset = 0;
// This new field helps to use the class G4PVManager
//
G4PVManager G4VPhysicalVolume::subInstanceManager;
// This method is similar to the constructor. It is used by each worker
// thread to achieve the same effect as that of the master thread exept
// to register the new created instance. This method is invoked explicitly.
// It does not create a new G4VPhysicalVolume instance.
// It only assign the value for the fields encapsulated by the class G4PVData.
// These macros change the references to fields that are now encapsulated
// in the class G4PVData.
//
void G4VPhysicalVolume::
InitialiseWorker( G4VPhysicalVolume* /*pMasterObject*/,
G4RotationMatrix *pRot,
const G4ThreeVector &tlate)
{
subInstanceManager.SlaveCopySubInstanceArray();
this->SetRotation( pRot ); // G4MT_rot = pRot;
this->SetTranslation( tlate ); // G4MT_trans = tlate;
// G4PhysicalVolumeStore::Register(this);
}
// 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.
//
void G4VPhysicalVolume::TerminateWorker( G4VPhysicalVolume* /*pMasterObject*/)
{
}
// Returns the private data instance manager.
//
const G4PVManager& G4VPhysicalVolume::GetSubInstanceManager()
{
return subInstanceManager;
}
#define G4MT_rot ((subInstanceManager.offset[instanceID]).frot)
#define G4MT_trans ((subInstanceManager.offset[instanceID]).ftrans)
#define G4MT_pvdata (subInstanceManager.offset[instanceID])
// Constructor: init parameters and register in Store
//
@@ -123,11 +91,69 @@ G4VPhysicalVolume::~G4VPhysicalVolume()
G4PhysicalVolumeStore::DeRegister(this);
}
// This method is similar to the constructor. It is used by each worker
// thread to achieve the same effect as that of the master thread exept
// to register the new created instance. This method is invoked explicitly.
// It does not create a new G4VPhysicalVolume instance.
// It only assign the value for the fields encapsulated by the class G4PVData.
//
void G4VPhysicalVolume::
InitialiseWorker( G4VPhysicalVolume* /*pMasterObject*/,
G4RotationMatrix *pRot,
const G4ThreeVector &tlate)
{
subInstanceManager.SlaveCopySubInstanceArray();
this->SetRotation( pRot ); // G4MT_rot = pRot;
this->SetTranslation( tlate ); // G4MT_trans = tlate;
// G4PhysicalVolumeStore::Register(this);
}
// 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.
//
void G4VPhysicalVolume::TerminateWorker( G4VPhysicalVolume* /*pMasterObject*/)
{
}
// Returns the private data instance manager.
//
const G4PVManager& G4VPhysicalVolume::GetSubInstanceManager()
{
return subInstanceManager;
}
G4int G4VPhysicalVolume::GetMultiplicity() const
{
return 1;
}
const G4ThreeVector& G4VPhysicalVolume::GetTranslation() const
{
return G4MT_trans;
}
void G4VPhysicalVolume::SetTranslation(const G4ThreeVector &vec)
{
G4MT_trans=vec;
}
const G4RotationMatrix* G4VPhysicalVolume::GetRotation() const
{
return G4MT_rot;
}
G4RotationMatrix* G4VPhysicalVolume::GetRotation()
{
return G4MT_rot;
}
void G4VPhysicalVolume::SetRotation(G4RotationMatrix *pRot)
{
G4MT_rot=pRot;
}
G4RotationMatrix* G4VPhysicalVolume::GetObjectRotation() const
{
static G4RotationMatrix aRotM;
@@ -144,6 +170,33 @@ G4RotationMatrix* G4VPhysicalVolume::GetObjectRotation() const
return retval;
}
G4RotationMatrix G4VPhysicalVolume::GetObjectRotationValue() const
{
G4RotationMatrix aRotM; // Initialised to identity
// Insure against G4MT_rot being a null pointer
if(G4MT_rot)
{
aRotM= G4MT_rot->inverse();
}
return aRotM;
}
G4ThreeVector G4VPhysicalVolume::GetObjectTranslation() const
{
return G4MT_trans;
}
const G4RotationMatrix* G4VPhysicalVolume::GetFrameRotation() const
{
return G4MT_rot;
}
G4ThreeVector G4VPhysicalVolume::GetFrameTranslation() const
{
return -G4MT_trans;
}
// Only implemented for placed and parameterised volumes.
// Not required for replicas.
//
+22 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VSolid.cc 72936 2013-08-14 13:17:11Z gcosmo $
// $Id: G4VSolid.cc 100906 2016-11-03 09:59:32Z gcosmo $
//
// class G4VSolid
//
@@ -32,6 +32,7 @@
//
// 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
@@ -618,6 +619,26 @@ G4VSolid::ClipPolygonToSimpleLimits( G4ThreeVectorList& pPolygon,
}
}
//////////////////////////////////////////////////////////////////////////
//
// Throw exception (warning) for solids not implementing the method
void G4VSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
{
std::ostringstream message;
message << "Not implemented for solid: "
<< GetEntityType() << " !"
<< "\nReturning infinite boundinx box.";
G4Exception("G4VSolid::Extent()", "GeomMgt1001", JustWarning, message);
pMin.set(-kInfinity,-kInfinity,-kInfinity);
pMax.set( kInfinity, kInfinity, kInfinity);
}
//////////////////////////////////////////////////////////////////////////
//
// Get G4VisExtent - bounding box for graphics
G4VisExtent G4VSolid::GetExtent () const
{
G4VisExtent extent;