Import Geant4 10.6.0 source tree
This commit is contained in:
@@ -19,6 +19,23 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
November 26, 2019 G.Cosmo geom-bool-V10-05-04
|
||||
- G4MultiUnion: fixed cases of implicit type conversions from size_t to G4int.
|
||||
|
||||
September 14, 2019 E.Tcherniaev geom-bool-V10-05-03
|
||||
- G4BooleanSolid::GetPointOnSurface(): Use G4QuickRand(), reduced
|
||||
max number of tries to generate a point to 100k.
|
||||
|
||||
September 2, 2019 G.Cosmo geom-bool-V10-05-02
|
||||
- Fixed defect in G4ScaledSolid detected by Coverity.
|
||||
|
||||
August 22, 2019 G.Cosmo geom-bool-V10-05-01
|
||||
- Use pre-increment wherever possible.
|
||||
|
||||
August 16, 2019 G.Cosmo geom-bool-V10-05-00
|
||||
- Implemented minor c++11 revision: nullptr, auto, inline data
|
||||
initialisation...
|
||||
|
||||
October 4, 2018 E.Tcherniaev geom-bool-V10-04-08
|
||||
- G4ScaledSolid: return back using EstimateSurfaceArea() from G4VSolid,
|
||||
as it was originally, but now adopting the more precise algorithm
|
||||
|
||||
@@ -23,10 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// class G4BooleanSolid
|
||||
// G4BooleanSolid
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
@@ -34,7 +31,6 @@
|
||||
// between other solids.
|
||||
|
||||
// 10.09.98 V.Grichine - created
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4BOOLEANSOLID_HH
|
||||
#define G4BOOLEANSOLID_HH
|
||||
@@ -117,26 +113,25 @@ class G4BooleanSolid : public G4VSolid
|
||||
|
||||
protected:
|
||||
|
||||
G4VSolid* fPtrSolidA;
|
||||
G4VSolid* fPtrSolidB;
|
||||
G4VSolid* fPtrSolidA = nullptr;
|
||||
G4VSolid* fPtrSolidB = nullptr;
|
||||
|
||||
private:
|
||||
|
||||
G4int fStatistics;
|
||||
G4double fCubVolEpsilon;
|
||||
G4double fAreaAccuracy;
|
||||
G4double fCubicVolume;
|
||||
G4double fSurfaceArea;
|
||||
G4int fStatistics = 1000000;
|
||||
G4double fCubVolEpsilon = 0.001;
|
||||
G4double fAreaAccuracy = -1;
|
||||
G4double fCubicVolume = -1.0;
|
||||
G4double fSurfaceArea = -1.0;
|
||||
|
||||
mutable G4bool fRebuildPolyhedron;
|
||||
mutable G4Polyhedron* fpPolyhedron;
|
||||
mutable G4bool fRebuildPolyhedron = false;
|
||||
mutable G4Polyhedron* fpPolyhedron = nullptr;
|
||||
|
||||
mutable std::vector<std::pair<G4VSolid *,G4Transform3D>> fPrimitives;
|
||||
mutable G4double fPrimitivesSurfaceArea;
|
||||
mutable G4double fPrimitivesSurfaceArea = 0.0;
|
||||
|
||||
G4bool createdDisplacedSolid;
|
||||
G4bool createdDisplacedSolid = false;
|
||||
// If & only if this object created it, it must delete it
|
||||
|
||||
} ;
|
||||
|
||||
#include "G4BooleanSolid.icc"
|
||||
|
||||
@@ -23,14 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Class G4BooleanSolid inline implementation
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 inline definitions file
|
||||
//
|
||||
// G4BooleanSolid.icc
|
||||
//
|
||||
// Implementation of inline methods of G4BooleanSolid
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
inline
|
||||
|
||||
@@ -23,10 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// class G4DisplacedSolid
|
||||
// G4DisplacedSolid
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
@@ -34,14 +31,10 @@
|
||||
// frame of reference to a new one. It is meant to be used only for
|
||||
// simplifying the implementation of "Boolean solids".
|
||||
|
||||
// History:
|
||||
//
|
||||
// 28.10.98 V.Grichine: created
|
||||
// 22.11.00 V.Grichine: new set methods for matrix/vectors
|
||||
//
|
||||
// 28.10.98 V.Grichine - created
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4DisplacedSolid_HH
|
||||
#define G4DisplacedSolid_HH
|
||||
#ifndef G4DISPLACEDSOLID_HH
|
||||
#define G4DISPLACEDSOLID_HH
|
||||
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4RotationMatrix.hh"
|
||||
@@ -116,27 +109,27 @@ class G4DisplacedSolid : public G4VSolid
|
||||
// If the Solid is a "G4DisplacedSolid",
|
||||
// return a self pointer else return 0.
|
||||
|
||||
G4VSolid* GetConstituentMovedSolid() const;
|
||||
G4VSolid* GetConstituentMovedSolid() const;
|
||||
|
||||
G4AffineTransform GetTransform() const;
|
||||
G4AffineTransform GetTransform() const;
|
||||
void SetTransform(G4AffineTransform& );
|
||||
|
||||
G4AffineTransform GetDirectTransform() const;
|
||||
G4AffineTransform GetDirectTransform() const;
|
||||
void SetDirectTransform(G4AffineTransform&);
|
||||
// Access/Set methods.
|
||||
|
||||
G4RotationMatrix GetFrameRotation() const;
|
||||
void SetFrameRotation(const G4RotationMatrix&);
|
||||
G4RotationMatrix GetFrameRotation() const;
|
||||
void SetFrameRotation(const G4RotationMatrix&);
|
||||
|
||||
G4ThreeVector GetFrameTranslation() const;
|
||||
void SetFrameTranslation(const G4ThreeVector&);
|
||||
G4ThreeVector GetFrameTranslation() const;
|
||||
void SetFrameTranslation(const G4ThreeVector&);
|
||||
// Get/Set the rotation/translation, as applied to the frame of reference.
|
||||
|
||||
G4RotationMatrix GetObjectRotation() const;
|
||||
void SetObjectRotation(const G4RotationMatrix&);
|
||||
G4RotationMatrix GetObjectRotation() const;
|
||||
void SetObjectRotation(const G4RotationMatrix&);
|
||||
|
||||
G4ThreeVector GetObjectTranslation() const;
|
||||
void SetObjectTranslation(const G4ThreeVector&);
|
||||
G4ThreeVector GetObjectTranslation() const;
|
||||
void SetObjectTranslation(const G4ThreeVector&);
|
||||
// Get/Set the rotation/translation, as applied to the object.
|
||||
|
||||
std::ostream& StreamInfo(std::ostream& os) const;
|
||||
@@ -154,16 +147,16 @@ class G4DisplacedSolid : public G4VSolid
|
||||
|
||||
void DescribeYourselfTo ( G4VGraphicsScene& scene ) const ;
|
||||
G4Polyhedron* CreatePolyhedron () const ;
|
||||
G4Polyhedron* GetPolyhedron () const ;
|
||||
G4Polyhedron* GetPolyhedron () const ;
|
||||
// For creating graphical representations (ie for visualisation).
|
||||
|
||||
protected:
|
||||
|
||||
G4VSolid* fPtrSolid ;
|
||||
G4AffineTransform* fPtrTransform ;
|
||||
G4AffineTransform* fDirectTransform ;
|
||||
mutable G4bool fRebuildPolyhedron;
|
||||
mutable G4Polyhedron* fpPolyhedron;
|
||||
} ;
|
||||
G4VSolid* fPtrSolid = nullptr;
|
||||
G4AffineTransform* fPtrTransform = nullptr;
|
||||
G4AffineTransform* fDirectTransform = nullptr;
|
||||
mutable G4bool fRebuildPolyhedron = false;
|
||||
mutable G4Polyhedron* fpPolyhedron = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,20 +23,13 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// class G4IntersectionSolid
|
||||
// G4IntersectionSolid
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Class for description of intersection of two CSG solids.
|
||||
// Class for description of intersection of two solids.
|
||||
|
||||
// History:
|
||||
//
|
||||
// 12.09.98 V.Grichine: initial design and implementation
|
||||
// 28.10.98 V.Grichine: addition of two constructors with G4PlacedSolid
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4INTERSECTIONSOLID_HH
|
||||
#define G4INTERSECTIONSOLID_HH
|
||||
@@ -116,8 +109,7 @@ class G4IntersectionSolid : public G4BooleanSolid
|
||||
|
||||
void DescribeYourselfTo ( G4VGraphicsScene& scene ) const ;
|
||||
G4Polyhedron* CreatePolyhedron () const ;
|
||||
|
||||
} ;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,12 +23,6 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
//
|
||||
// G4MultiUnion
|
||||
//
|
||||
// Class description:
|
||||
@@ -38,9 +32,8 @@
|
||||
// instance of "G4Node". An instance of "G4MultiUnion" is subsequently
|
||||
// composed of one or several nodes.
|
||||
|
||||
// History:
|
||||
// 06.04.17 G.Cosmo - Imported implementation in Geant4 for VecGeom migration
|
||||
// 19.10.12 M.Gayer - Original implementation from USolids module
|
||||
// 06.04.17 G.Cosmo - Adapted implementation in Geant4 for VecGeom migration
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4MULTIUNION_HH
|
||||
#define G4MULTIUNION_HH
|
||||
@@ -93,9 +86,9 @@ class G4MultiUnion : public G4VSolid
|
||||
const G4ThreeVector& aDirection) const;
|
||||
G4double DistanceToOut(const G4ThreeVector& aPoint,
|
||||
const G4ThreeVector& aDirection,
|
||||
const G4bool calcNorm=false,
|
||||
G4bool *validNorm=0,
|
||||
G4ThreeVector *aNormalVector=0) const;
|
||||
const G4bool calcNorm = false,
|
||||
G4bool* validNorm = nullptr,
|
||||
G4ThreeVector* aNormalVector = nullptr) const;
|
||||
|
||||
G4double DistanceToInNoVoxels(const G4ThreeVector& aPoint,
|
||||
const G4ThreeVector& aDirection) const;
|
||||
@@ -178,14 +171,14 @@ class G4MultiUnion : public G4VSolid
|
||||
|
||||
std::vector<G4VSolid*> fSolids;
|
||||
std::vector<G4Transform3D> fTransformObjs;
|
||||
G4Voxelizer fVoxels; // Pointer to the vozelized solid
|
||||
G4double fCubicVolume; // Cubic Volume
|
||||
G4double fSurfaceArea; // Surface Area
|
||||
G4double kRadTolerance; // Cached radial tolerance
|
||||
mutable G4bool fAccurate; // Accurate safety (off by default)
|
||||
G4Voxelizer fVoxels; // Vozelizer for the solid
|
||||
G4double fCubicVolume = 0.0; // Cubic Volume
|
||||
G4double fSurfaceArea = 0.0; // Surface Area
|
||||
G4double kRadTolerance; // Cached radial tolerance
|
||||
mutable G4bool fAccurate = false; // Accurate safety (off by default)
|
||||
|
||||
mutable G4bool fRebuildPolyhedron;
|
||||
mutable G4Polyhedron* fpPolyhedron;
|
||||
mutable G4bool fRebuildPolyhedron = false;
|
||||
mutable G4Polyhedron* fpPolyhedron = nullptr;
|
||||
};
|
||||
|
||||
//______________________________________________________________________________
|
||||
@@ -209,7 +202,7 @@ inline G4VSolid* G4MultiUnion::GetSolid(G4int index) const
|
||||
//______________________________________________________________________________
|
||||
inline G4int G4MultiUnion::GetNumberOfSolids() const
|
||||
{
|
||||
return fSolids.size();
|
||||
return G4int(fSolids.size());
|
||||
}
|
||||
|
||||
//______________________________________________________________________________
|
||||
|
||||
@@ -23,23 +23,17 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// class G4ScaledSolid
|
||||
// G4ScaledSolid
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// A scaled solid is a solid that has been scaled in dimensions
|
||||
// in X, Y or Z, from its original description.
|
||||
|
||||
// History:
|
||||
//
|
||||
// 27.10.15 G.Cosmo: created
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4ScaledSolid_HH
|
||||
#define G4ScaledSolid_HH
|
||||
#ifndef G4SCALEDSOLID_HH
|
||||
#define G4SCALEDSOLID_HH
|
||||
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
@@ -76,9 +70,9 @@ class G4ScaledSolid : public G4VSolid
|
||||
|
||||
G4double DistanceToOut( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm=false,
|
||||
G4bool *validNorm=0,
|
||||
G4ThreeVector *n=0 ) const;
|
||||
const G4bool calcNorm = false,
|
||||
G4bool* validNorm = nullptr,
|
||||
G4ThreeVector* n = nullptr ) const;
|
||||
|
||||
G4double DistanceToOut( const G4ThreeVector& p ) const;
|
||||
|
||||
@@ -121,12 +115,12 @@ class G4ScaledSolid : public G4VSolid
|
||||
|
||||
private:
|
||||
|
||||
G4VSolid* fPtrSolid;
|
||||
G4ScaleTransform* fScale;
|
||||
G4double fCubicVolume;
|
||||
G4double fSurfaceArea;
|
||||
mutable G4bool fRebuildPolyhedron;
|
||||
mutable G4Polyhedron* fpPolyhedron;
|
||||
G4VSolid* fPtrSolid = nullptr;
|
||||
G4ScaleTransform* fScale = nullptr;
|
||||
G4double fCubicVolume = -1.0;
|
||||
G4double fSurfaceArea = -1.0;
|
||||
mutable G4bool fRebuildPolyhedron = false;
|
||||
mutable G4Polyhedron* fpPolyhedron = nullptr;
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,19 +23,13 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// class G4SubtractionSolid
|
||||
// G4SubtractionSolid
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Class for description of subtraction of two CSG solids: A - B.
|
||||
// Class for description of subtraction of two solids: A - B.
|
||||
|
||||
// History:
|
||||
//
|
||||
// 14.10.98 V.Grichine: first implementation
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4SUBTRACTIONSOLID_HH
|
||||
#define G4SUBTRACTIONSOLID_HH
|
||||
@@ -103,9 +97,9 @@ class G4SubtractionSolid : public G4BooleanSolid
|
||||
|
||||
G4double DistanceToOut( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm=false,
|
||||
G4bool *validNorm=0,
|
||||
G4ThreeVector *n=0 ) const ;
|
||||
const G4bool calcNorm = false,
|
||||
G4bool* validNorm = nullptr,
|
||||
G4ThreeVector* n = nullptr ) const ;
|
||||
|
||||
G4double DistanceToOut( const G4ThreeVector& p ) const ;
|
||||
|
||||
|
||||
@@ -23,19 +23,13 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// class G4UnionSolid
|
||||
// G4UnionSolid
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Class for description of union of two CSG solids.
|
||||
// Class for description of union of two solids.
|
||||
|
||||
// History:
|
||||
//
|
||||
// 12.09.98 V.Grichine: created
|
||||
//
|
||||
// 12.09.98 V.Grichine - created
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4UNIONSOLID_HH
|
||||
#define G4UNIONSOLID_HH
|
||||
@@ -102,9 +96,9 @@ class G4UnionSolid : public G4BooleanSolid
|
||||
|
||||
G4double DistanceToOut( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm=false,
|
||||
G4bool *validNorm=0,
|
||||
G4ThreeVector *n=0 ) const ;
|
||||
const G4bool calcNorm = false,
|
||||
G4bool* validNorm = nullptr,
|
||||
G4ThreeVector* n = nullptr ) const ;
|
||||
|
||||
G4double DistanceToOut( const G4ThreeVector& p ) const ;
|
||||
|
||||
|
||||
@@ -23,18 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// Implementation for the abstract base class for solids created by boolean
|
||||
// Implementation of the base class for solids created by Boolean
|
||||
// operations between other solids
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 2016.03.16 E.Tcherniaev - added GetListOfPrimitives(),
|
||||
// reimplemented GetPointOnSurface()
|
||||
//
|
||||
// 1998.09.10 V.Grichine - created
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4BooleanSolid.hh"
|
||||
@@ -44,7 +36,7 @@
|
||||
#include "G4ScaledSolid.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "HepPolyhedronProcessor.h"
|
||||
#include "Randomize.hh"
|
||||
#include "G4QuickRand.hh"
|
||||
|
||||
#include "G4AutoLock.hh"
|
||||
|
||||
@@ -59,14 +51,9 @@ namespace
|
||||
|
||||
G4BooleanSolid::G4BooleanSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ) :
|
||||
G4VSolid(pName), fStatistics(1000000), fCubVolEpsilon(0.001),
|
||||
fAreaAccuracy(-1.), fCubicVolume(-1.), fSurfaceArea(-1.),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
|
||||
createdDisplacedSolid(false)
|
||||
G4VSolid* pSolidB )
|
||||
: G4VSolid(pName), fPtrSolidA(pSolidA), fPtrSolidB(pSolidB)
|
||||
{
|
||||
fPtrSolidA = pSolidA ;
|
||||
fPtrSolidB = pSolidB ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
@@ -77,11 +64,8 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ,
|
||||
G4RotationMatrix* rotMatrix,
|
||||
const G4ThreeVector& transVector ) :
|
||||
G4VSolid(pName), fStatistics(1000000), fCubVolEpsilon(0.001),
|
||||
fAreaAccuracy(-1.), fCubicVolume(-1.), fSurfaceArea(-1.),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
|
||||
createdDisplacedSolid(true)
|
||||
const G4ThreeVector& transVector )
|
||||
: G4VSolid(pName), createdDisplacedSolid(true)
|
||||
{
|
||||
fPtrSolidA = pSolidA ;
|
||||
fPtrSolidB = new G4DisplacedSolid("placedB",pSolidB,rotMatrix,transVector) ;
|
||||
@@ -94,11 +78,8 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
|
||||
G4BooleanSolid::G4BooleanSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ,
|
||||
const G4Transform3D& transform ) :
|
||||
G4VSolid(pName), fStatistics(1000000), fCubVolEpsilon(0.001),
|
||||
fAreaAccuracy(-1.), fCubicVolume(-1.), fSurfaceArea(-1.),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
|
||||
createdDisplacedSolid(true)
|
||||
const G4Transform3D& transform )
|
||||
: G4VSolid(pName), createdDisplacedSolid(true)
|
||||
{
|
||||
fPtrSolidA = pSolidA ;
|
||||
fPtrSolidB = new G4DisplacedSolid("placedB",pSolidB,transform) ;
|
||||
@@ -110,11 +91,7 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
|
||||
// for usage restricted to object persistency.
|
||||
|
||||
G4BooleanSolid::G4BooleanSolid( __void__& a )
|
||||
: G4VSolid(a), fPtrSolidA(0), fPtrSolidB(0),
|
||||
fStatistics(1000000), fCubVolEpsilon(0.001),
|
||||
fAreaAccuracy(-1.), fCubicVolume(-1.), fSurfaceArea(-1.),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
|
||||
createdDisplacedSolid(false)
|
||||
: G4VSolid(a)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -128,7 +105,7 @@ G4BooleanSolid::~G4BooleanSolid()
|
||||
{
|
||||
((G4DisplacedSolid*)fPtrSolidB)->CleanTransformations();
|
||||
}
|
||||
delete fpPolyhedron; fpPolyhedron = 0;
|
||||
delete fpPolyhedron; fpPolyhedron = nullptr;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
@@ -139,8 +116,8 @@ G4BooleanSolid::G4BooleanSolid(const G4BooleanSolid& rhs)
|
||||
: G4VSolid (rhs), fPtrSolidA(rhs.fPtrSolidA), fPtrSolidB(rhs.fPtrSolidB),
|
||||
fStatistics(rhs.fStatistics), fCubVolEpsilon(rhs.fCubVolEpsilon),
|
||||
fAreaAccuracy(rhs.fAreaAccuracy), fCubicVolume(rhs.fCubicVolume),
|
||||
fSurfaceArea(rhs.fSurfaceArea), fRebuildPolyhedron(false), fpPolyhedron(0),
|
||||
createdDisplacedSolid(rhs.createdDisplacedSolid)
|
||||
fSurfaceArea(rhs.fSurfaceArea), fRebuildPolyhedron(false),
|
||||
fpPolyhedron(nullptr), createdDisplacedSolid(rhs.createdDisplacedSolid)
|
||||
{
|
||||
fPrimitives.resize(0); fPrimitivesSurfaceArea = 0.;
|
||||
}
|
||||
@@ -167,7 +144,7 @@ G4BooleanSolid& G4BooleanSolid::operator = (const G4BooleanSolid& rhs)
|
||||
fSurfaceArea= rhs.fSurfaceArea;
|
||||
createdDisplacedSolid= rhs.createdDisplacedSolid;
|
||||
fRebuildPolyhedron = false;
|
||||
delete fpPolyhedron; fpPolyhedron = 0;
|
||||
delete fpPolyhedron; fpPolyhedron = nullptr;
|
||||
fPrimitives.resize(0); fPrimitivesSurfaceArea = 0.;
|
||||
|
||||
return *this;
|
||||
@@ -181,7 +158,7 @@ G4BooleanSolid& G4BooleanSolid::operator = (const G4BooleanSolid& rhs)
|
||||
|
||||
const G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no) const
|
||||
{
|
||||
const G4VSolid* subSolid=0;
|
||||
const G4VSolid* subSolid = nullptr;
|
||||
if( no == 0 )
|
||||
subSolid = fPtrSolidA;
|
||||
else if( no == 1 )
|
||||
@@ -192,7 +169,6 @@ const G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no) const
|
||||
G4Exception("G4BooleanSolid::GetConstituentSolid()",
|
||||
"GeomSolids0002", FatalException, "Invalid solid index.");
|
||||
}
|
||||
|
||||
return subSolid;
|
||||
}
|
||||
|
||||
@@ -204,7 +180,7 @@ const G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no) const
|
||||
|
||||
G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no)
|
||||
{
|
||||
G4VSolid* subSolid=0;
|
||||
G4VSolid* subSolid = nullptr;
|
||||
if( no == 0 )
|
||||
subSolid = fPtrSolidA;
|
||||
else if( no == 1 )
|
||||
@@ -215,7 +191,6 @@ G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no)
|
||||
G4Exception("G4BooleanSolid::GetConstituentSolid()",
|
||||
"GeomSolids0002", FatalException, "Invalid solid index.");
|
||||
}
|
||||
|
||||
return subSolid;
|
||||
}
|
||||
|
||||
@@ -252,7 +227,7 @@ std::ostream& G4BooleanSolid::StreamInfo(std::ostream& os) const
|
||||
// Creates list of constituent primitives of and their placements
|
||||
|
||||
void G4BooleanSolid::GetListOfPrimitives(
|
||||
std::vector<std::pair<G4VSolid *,G4Transform3D>>& primitives,
|
||||
std::vector<std::pair<G4VSolid*,G4Transform3D>>& primitives,
|
||||
const G4Transform3D& curPlacement) const
|
||||
{
|
||||
G4Transform3D transform;
|
||||
@@ -261,7 +236,7 @@ void G4BooleanSolid::GetListOfPrimitives(
|
||||
|
||||
// Repeat two times, first time for fPtrSolidA and then for fPtrSolidB
|
||||
//
|
||||
for (G4int i=0; i<2; i++)
|
||||
for (auto i=0; i<2; ++i)
|
||||
{
|
||||
transform = curPlacement;
|
||||
solid = (i == 0) ? fPtrSolidA : fPtrSolidB;
|
||||
@@ -317,7 +292,7 @@ void G4BooleanSolid::GetListOfPrimitives(
|
||||
|
||||
G4ThreeVector G4BooleanSolid::GetPointOnSurface() const
|
||||
{
|
||||
G4int nprims = fPrimitives.size();
|
||||
size_t nprims = fPrimitives.size();
|
||||
std::pair<G4VSolid *, G4Transform3D> prim;
|
||||
|
||||
// Get list of primitives and find the total area of their surfaces
|
||||
@@ -327,7 +302,7 @@ G4ThreeVector G4BooleanSolid::GetPointOnSurface() const
|
||||
GetListOfPrimitives(fPrimitives, G4Transform3D());
|
||||
nprims = fPrimitives.size();
|
||||
fPrimitivesSurfaceArea = 0.;
|
||||
for (G4int i=0; i<nprims; i++)
|
||||
for (size_t i=0; i<nprims; ++i)
|
||||
{
|
||||
fPrimitivesSurfaceArea += fPrimitives[i].first->GetSurfaceArea();
|
||||
}
|
||||
@@ -337,11 +312,11 @@ G4ThreeVector G4BooleanSolid::GetPointOnSurface() const
|
||||
// check that the point belongs to the surface of the solid
|
||||
//
|
||||
G4ThreeVector p;
|
||||
for (G4int k=0; k<1000000; k++) // try 1000000 times
|
||||
for (size_t k=0; k<100000; ++k) // try 100k times
|
||||
{
|
||||
G4double rand = fPrimitivesSurfaceArea * G4UniformRand();
|
||||
G4double rand = fPrimitivesSurfaceArea * G4QuickRand();
|
||||
G4double area = 0.;
|
||||
for (G4int i=0; i<nprims; i++)
|
||||
for (size_t i=0; i<nprims; ++i)
|
||||
{
|
||||
prim = fPrimitives[i];
|
||||
area += prim.first->GetSurfaceArea();
|
||||
@@ -353,7 +328,7 @@ G4ThreeVector G4BooleanSolid::GetPointOnSurface() const
|
||||
}
|
||||
std::ostringstream message;
|
||||
message << "Solid - " << GetName() << "\n"
|
||||
<< "All attempts to generate a point on the surface have failed!\n"
|
||||
<< "All 100k attempts to generate a point on the surface have failed!\n"
|
||||
<< "The solid created may be an invalid Boolean construct!";
|
||||
G4Exception("G4BooleanSolid::GetPointOnSurface()",
|
||||
"GeomSolids1001", JustWarning, message);
|
||||
@@ -366,7 +341,7 @@ G4ThreeVector G4BooleanSolid::GetPointOnSurface() const
|
||||
|
||||
G4Polyhedron* G4BooleanSolid::GetPolyhedron () const
|
||||
{
|
||||
if (!fpPolyhedron ||
|
||||
if (fpPolyhedron == nullptr ||
|
||||
fRebuildPolyhedron ||
|
||||
fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
|
||||
fpPolyhedron->GetNumberOfRotationSteps())
|
||||
@@ -403,14 +378,14 @@ G4BooleanSolid::StackPolyhedron(HepPolyhedronProcessor& processor,
|
||||
<< " - Unrecognised composite solid" << G4endl
|
||||
<< " Returning NULL !";
|
||||
G4Exception("StackPolyhedron()", "GeomSolids1001", JustWarning, message);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
G4Polyhedron* top = 0;
|
||||
G4Polyhedron* top = nullptr;
|
||||
const G4VSolid* solidA = solid->GetConstituentSolid(0);
|
||||
const G4VSolid* solidB = solid->GetConstituentSolid(1);
|
||||
|
||||
if (solidA->GetConstituentSolid(0))
|
||||
if (solidA->GetConstituentSolid(0) != nullptr)
|
||||
{
|
||||
top = StackPolyhedron(processor, solidA);
|
||||
}
|
||||
@@ -419,7 +394,7 @@ G4BooleanSolid::StackPolyhedron(HepPolyhedronProcessor& processor,
|
||||
top = solidA->GetPolyhedron();
|
||||
}
|
||||
G4Polyhedron* operand = solidB->GetPolyhedron();
|
||||
if (operand)
|
||||
if (operand != nullptr)
|
||||
{
|
||||
processor.push_back (operation, *operand);
|
||||
}
|
||||
|
||||
@@ -23,18 +23,11 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// Implementation for G4DisplacedSolid class for boolean
|
||||
// Implementation of G4DisplacedSolid class for Boolean
|
||||
// operations between other solids
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 28.10.98 V.Grichine: created
|
||||
// 14.11.99 V.Grichine: modifications in CalculateExtent(...) method
|
||||
// 22.11.00 V.Grichine: new set methods for matrix/vectors
|
||||
// 28.02.18 E.Tcherniaev: improved contruction from G4DisplacedSolid
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4DisplacedSolid.hh"
|
||||
@@ -55,7 +48,7 @@ G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
G4RotationMatrix* rotMatrix,
|
||||
const G4ThreeVector& transVector )
|
||||
: G4VSolid(pName), fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
: G4VSolid(pName)
|
||||
{
|
||||
if (pSolid->GetEntityType() == "G4DisplacedSolid")
|
||||
{
|
||||
@@ -79,7 +72,7 @@ G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
const G4Transform3D& transform )
|
||||
: G4VSolid(pName), fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
: G4VSolid(pName)
|
||||
{
|
||||
if (pSolid->GetEntityType() == "G4DisplacedSolid")
|
||||
{
|
||||
@@ -106,7 +99,7 @@ G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
const G4AffineTransform directTransform )
|
||||
: G4VSolid(pName), fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
: G4VSolid(pName)
|
||||
{
|
||||
if (pSolid->GetEntityType() == "G4DisplacedSolid")
|
||||
{
|
||||
@@ -129,8 +122,7 @@ G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
// for usage restricted to object persistency.
|
||||
|
||||
G4DisplacedSolid::G4DisplacedSolid( __void__& a )
|
||||
: G4VSolid(a), fPtrSolid(0), fPtrTransform(0),
|
||||
fDirectTransform(0), fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
: G4VSolid(a)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -141,7 +133,7 @@ G4DisplacedSolid::G4DisplacedSolid( __void__& a )
|
||||
G4DisplacedSolid::~G4DisplacedSolid()
|
||||
{
|
||||
CleanTransformations();
|
||||
delete fpPolyhedron; fpPolyhedron = 0;
|
||||
delete fpPolyhedron; fpPolyhedron = nullptr;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
@@ -149,8 +141,7 @@ G4DisplacedSolid::~G4DisplacedSolid()
|
||||
// Copy constructor
|
||||
|
||||
G4DisplacedSolid::G4DisplacedSolid(const G4DisplacedSolid& rhs)
|
||||
: G4VSolid (rhs), fPtrSolid(rhs.fPtrSolid),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
: G4VSolid (rhs), fPtrSolid(rhs.fPtrSolid)
|
||||
{
|
||||
fPtrTransform = new G4AffineTransform(*(rhs.fPtrTransform));
|
||||
fDirectTransform = new G4AffineTransform(*(rhs.fDirectTransform));
|
||||
@@ -177,17 +168,17 @@ G4DisplacedSolid& G4DisplacedSolid::operator = (const G4DisplacedSolid& rhs)
|
||||
fPtrTransform = new G4AffineTransform(*(rhs.fPtrTransform));
|
||||
fDirectTransform = new G4AffineTransform(*(rhs.fDirectTransform));
|
||||
fRebuildPolyhedron = false;
|
||||
delete fpPolyhedron; fpPolyhedron= 0;
|
||||
delete fpPolyhedron; fpPolyhedron = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void G4DisplacedSolid::CleanTransformations()
|
||||
{
|
||||
if(fPtrTransform)
|
||||
if(fPtrTransform != nullptr)
|
||||
{
|
||||
delete fPtrTransform; fPtrTransform=0;
|
||||
delete fDirectTransform; fDirectTransform=0;
|
||||
delete fPtrTransform; fPtrTransform = nullptr;
|
||||
delete fDirectTransform; fDirectTransform = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +229,7 @@ void G4DisplacedSolid::SetDirectTransform(G4AffineTransform& transform)
|
||||
|
||||
G4RotationMatrix G4DisplacedSolid::GetFrameRotation() const
|
||||
{
|
||||
G4RotationMatrix InvRotation= fDirectTransform->NetRotation();
|
||||
G4RotationMatrix InvRotation = fDirectTransform->NetRotation();
|
||||
return InvRotation;
|
||||
}
|
||||
|
||||
@@ -265,7 +256,7 @@ void G4DisplacedSolid::SetFrameTranslation(const G4ThreeVector& vector)
|
||||
|
||||
G4RotationMatrix G4DisplacedSolid::GetObjectRotation() const
|
||||
{
|
||||
G4RotationMatrix Rotation= fPtrTransform->NetRotation();
|
||||
G4RotationMatrix Rotation = fPtrTransform->NetRotation();
|
||||
return Rotation;
|
||||
}
|
||||
|
||||
@@ -350,7 +341,7 @@ G4DisplacedSolid::CalculateExtent( const EAxis pAxis,
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// SurfaceNormal
|
||||
|
||||
EInside G4DisplacedSolid::Inside(const G4ThreeVector& p) const
|
||||
{
|
||||
@@ -431,7 +422,7 @@ G4DisplacedSolid::DistanceToOut( const G4ThreeVector& p ) const
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// ComputeDimensions
|
||||
|
||||
void
|
||||
G4DisplacedSolid::ComputeDimensions( G4VPVParameterisation*,
|
||||
@@ -452,7 +443,7 @@ G4DisplacedSolid::ComputeDimensions( G4VPVParameterisation*,
|
||||
|
||||
G4ThreeVector G4DisplacedSolid::GetPointOnSurface() const
|
||||
{
|
||||
G4ThreeVector p = fPtrSolid->GetPointOnSurface();
|
||||
G4ThreeVector p = fPtrSolid->GetPointOnSurface();
|
||||
return fDirectTransform->TransformPoint(p);
|
||||
}
|
||||
|
||||
@@ -502,7 +493,7 @@ std::ostream& G4DisplacedSolid::StreamInfo(std::ostream& os) const
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// DescribeYourselfTo
|
||||
|
||||
void
|
||||
G4DisplacedSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
@@ -512,13 +503,13 @@ G4DisplacedSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// CreatePolyhedron
|
||||
|
||||
G4Polyhedron*
|
||||
G4DisplacedSolid::CreatePolyhedron () const
|
||||
{
|
||||
G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron();
|
||||
if (polyhedron)
|
||||
if (polyhedron != nullptr)
|
||||
{
|
||||
polyhedron
|
||||
->Transform(G4Transform3D(GetObjectRotation(),GetObjectTranslation()));
|
||||
@@ -535,11 +526,11 @@ G4DisplacedSolid::CreatePolyhedron () const
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// GetPolyhedron
|
||||
|
||||
G4Polyhedron* G4DisplacedSolid::GetPolyhedron () const
|
||||
{
|
||||
if (!fpPolyhedron ||
|
||||
if (fpPolyhedron == nullptr ||
|
||||
fRebuildPolyhedron ||
|
||||
fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
|
||||
fpPolyhedron->GetNumberOfRotationSteps())
|
||||
|
||||
@@ -23,22 +23,11 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// Implementation of methods for the class G4IntersectionSolid
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 17.02.05 V.Grichine: bug was fixed in DistanceToIn(p,v) based on algorithm
|
||||
// proposed by Dino Bazzacco <dino.bazzacco@pd.infn.it>
|
||||
// 29.05.01 V.Grichine: bug was fixed in DistanceToIn(p,v)
|
||||
// 16.03.01 V.Grichine: modifications in CalculateExtent() and Inside()
|
||||
// 29.07.99 V.Grichine: modifications in DistanceToIn(p,v)
|
||||
// 12.09.98 V.Grichine: first implementation
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "G4IntersectionSolid.hh"
|
||||
@@ -208,7 +197,7 @@ G4IntersectionSolid::CalculateExtent(const EAxis pAxis,
|
||||
EInside G4IntersectionSolid::Inside(const G4ThreeVector& p) const
|
||||
{
|
||||
EInside positionA = fPtrSolidA->Inside(p);
|
||||
if(positionA == kOutside) return positionA; //outside A
|
||||
if(positionA == kOutside) return positionA; // outside A
|
||||
|
||||
EInside positionB = fPtrSolidB->Inside(p);
|
||||
if(positionA == kInside) return positionB;
|
||||
@@ -226,8 +215,8 @@ G4IntersectionSolid::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
G4ThreeVector normal;
|
||||
EInside insideA, insideB;
|
||||
|
||||
insideA= fPtrSolidA->Inside(p);
|
||||
insideB= fPtrSolidB->Inside(p);
|
||||
insideA = fPtrSolidA->Inside(p);
|
||||
insideB = fPtrSolidB->Inside(p);
|
||||
|
||||
#ifdef G4BOOLDEBUG
|
||||
if( (insideA == kOutside) || (insideB == kOutside) )
|
||||
@@ -247,27 +236,31 @@ G4IntersectionSolid::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
//
|
||||
if( insideA == kSurface )
|
||||
{
|
||||
normal= fPtrSolidA->SurfaceNormal(p) ;
|
||||
normal = fPtrSolidA->SurfaceNormal(p) ;
|
||||
}
|
||||
else if( insideB == kSurface )
|
||||
{
|
||||
normal= fPtrSolidB->SurfaceNormal(p) ;
|
||||
normal = fPtrSolidB->SurfaceNormal(p) ;
|
||||
}
|
||||
else // We are on neither surface, so we should generate an exception
|
||||
{
|
||||
if(fPtrSolidA->DistanceToOut(p) <= fPtrSolidB->DistanceToOut(p) )
|
||||
if(fPtrSolidA->DistanceToOut(p) <= fPtrSolidB->DistanceToOut(p) )
|
||||
{
|
||||
normal= fPtrSolidA->SurfaceNormal(p) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
normal= fPtrSolidB->SurfaceNormal(p) ;
|
||||
}
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4cout << "WARNING - Invalid call in "
|
||||
<< "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
|
||||
<< " Point p is out of surface !" << G4endl;
|
||||
G4cout << " p = " << p << G4endl;
|
||||
G4cerr << "WARNING - Invalid call in "
|
||||
<< "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
|
||||
<< " Point p is out of surface !" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
G4cout << "WARNING - Invalid call in "
|
||||
<< "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
|
||||
<< " Point p is out of surface !" << G4endl;
|
||||
G4cout << " p = " << p << G4endl;
|
||||
G4cerr << "WARNING - Invalid call in "
|
||||
<< "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
|
||||
<< " Point p is out of surface !" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -405,20 +398,20 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p) const
|
||||
EInside sideB = fPtrSolidB->Inside(p) ;
|
||||
G4double dist=0.0 ;
|
||||
|
||||
if( sideA != kInside && sideB != kOutside )
|
||||
if( sideA != kInside && sideB != kOutside )
|
||||
{
|
||||
dist = fPtrSolidA->DistanceToIn(p) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( sideB != kInside && sideA != kOutside )
|
||||
if( sideB != kInside && sideA != kOutside )
|
||||
{
|
||||
dist = fPtrSolidB->DistanceToIn(p) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
dist = std::min(fPtrSolidA->DistanceToIn(p),
|
||||
fPtrSolidB->DistanceToIn(p) ) ;
|
||||
fPtrSolidB->DistanceToIn(p) ) ;
|
||||
}
|
||||
}
|
||||
return dist ;
|
||||
@@ -433,7 +426,7 @@ G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm,
|
||||
G4bool *validNorm,
|
||||
G4ThreeVector *n ) const
|
||||
G4ThreeVector *n ) const
|
||||
{
|
||||
G4bool validNormA, validNormB;
|
||||
G4ThreeVector nA, nB;
|
||||
@@ -511,7 +504,7 @@ G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p ) const
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// ComputeDimensions
|
||||
|
||||
void
|
||||
G4IntersectionSolid::ComputeDimensions( G4VPVParameterisation*,
|
||||
@@ -522,7 +515,7 @@ G4IntersectionSolid::ComputeDimensions( G4VPVParameterisation*,
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// GetEntityType
|
||||
|
||||
G4GeometryType G4IntersectionSolid::GetEntityType() const
|
||||
{
|
||||
@@ -540,7 +533,7 @@ G4VSolid* G4IntersectionSolid::Clone() const
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// DescribeYourselfTo
|
||||
|
||||
void
|
||||
G4IntersectionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
@@ -550,7 +543,7 @@ G4IntersectionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// CreatePolyhedron
|
||||
|
||||
G4Polyhedron*
|
||||
G4IntersectionSolid::CreatePolyhedron () const
|
||||
@@ -561,5 +554,5 @@ G4IntersectionSolid::CreatePolyhedron () const
|
||||
G4Polyhedron* top = StackPolyhedron(processor, this);
|
||||
G4Polyhedron* result = new G4Polyhedron(*top);
|
||||
if (processor.execute(*result)) { return result; }
|
||||
else { return 0; }
|
||||
else { return nullptr; }
|
||||
}
|
||||
|
||||
@@ -23,14 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Implementation of G4MultiUnion class
|
||||
//
|
||||
//
|
||||
// Implementation for G4MultiUnion class
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 06.04.17 G.Cosmo - Imported implementation in Geant4 for VecGeom migration
|
||||
// 19.10.12 Marek Gayer - Original implementation from USolids module
|
||||
// 19.10.12 M.Gayer - Original implementation from USolids module
|
||||
// 06.04.17 G.Cosmo - Adapted implementation in Geant4 for VecGeom migration
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include <iostream>
|
||||
@@ -56,14 +52,11 @@ namespace
|
||||
|
||||
//______________________________________________________________________________
|
||||
G4MultiUnion::G4MultiUnion(const G4String& name)
|
||||
: G4VSolid(name), fAccurate(false),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
: G4VSolid(name)
|
||||
{
|
||||
SetName(name);
|
||||
fSolids.clear();
|
||||
fTransformObjs.clear();
|
||||
fCubicVolume = 0;
|
||||
fSurfaceArea = 0;
|
||||
kRadTolerance = G4GeometryTolerance::GetInstance()->GetRadialTolerance();
|
||||
}
|
||||
|
||||
@@ -88,18 +81,16 @@ G4VSolid* G4MultiUnion::Clone() const
|
||||
// Copy constructor
|
||||
//______________________________________________________________________________
|
||||
G4MultiUnion::G4MultiUnion(const G4MultiUnion& rhs)
|
||||
: G4VSolid(rhs),fCubicVolume (rhs.fCubicVolume),
|
||||
fSurfaceArea (rhs.fSurfaceArea),
|
||||
kRadTolerance(rhs.kRadTolerance), fAccurate(false),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
: G4VSolid(rhs), fCubicVolume(rhs.fCubicVolume),
|
||||
fSurfaceArea(rhs.fSurfaceArea),
|
||||
kRadTolerance(rhs.kRadTolerance), fAccurate(rhs.fAccurate)
|
||||
{
|
||||
}
|
||||
|
||||
// Fake default constructor for persistency
|
||||
//______________________________________________________________________________
|
||||
G4MultiUnion::G4MultiUnion( __void__& a )
|
||||
: G4VSolid(a), fCubicVolume (0.), fSurfaceArea (0.), kRadTolerance(0.),
|
||||
fAccurate(false), fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
: G4VSolid(a)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -136,13 +127,13 @@ G4double G4MultiUnion::GetCubicVolume()
|
||||
p = (extentMax + extentMin) / 2.;
|
||||
G4ThreeVector left = p - d;
|
||||
G4ThreeVector length = d * 2;
|
||||
for (generated = 0; generated < 10000; generated++)
|
||||
for (generated = 0; generated < 10000; ++generated)
|
||||
{
|
||||
G4ThreeVector rvec(G4UniformRand(), G4UniformRand(), G4UniformRand());
|
||||
point = left + G4ThreeVector(length.x()*rvec.x(),
|
||||
length.y()*rvec.y(),
|
||||
length.z()*rvec.z());
|
||||
if (Inside(point) != EInside::kOutside) inside++;
|
||||
if (Inside(point) != EInside::kOutside) ++inside;
|
||||
}
|
||||
G4double vbox = (2 * d.x()) * (2 * d.y()) * (2 * d.z());
|
||||
fCubicVolume = inside * vbox / generated;
|
||||
@@ -393,7 +384,7 @@ G4double G4MultiUnion::DistanceToOutVoxels(const G4ThreeVector& aPoint,
|
||||
|
||||
distance += maxDistance;
|
||||
currentPoint += maxDistance * direction;
|
||||
if(maxDistance == 0.) count++;
|
||||
if(maxDistance == 0.) ++count;
|
||||
|
||||
// the current component will be ignored
|
||||
exclusion.SetBitNumber(maxCandidate);
|
||||
@@ -541,7 +532,7 @@ EInside G4MultiUnion::InsideNoVoxels(const G4ThreeVector& aPoint) const
|
||||
location = solid.Inside(localPoint);
|
||||
|
||||
if (location == EInside::kSurface)
|
||||
countSurface++;
|
||||
++countSurface;
|
||||
|
||||
if (location == EInside::kInside) return EInside::kInside;
|
||||
}
|
||||
@@ -779,14 +770,14 @@ G4double G4MultiUnion::DistanceToIn(const G4ThreeVector& point) const
|
||||
{
|
||||
const G4ThreeVector& pos = boxes[j].pos;
|
||||
const G4ThreeVector& hlen = boxes[j].hlen;
|
||||
for (G4int i = 0; i <= 2; ++i)
|
||||
for (auto i = 0; i <= 2; ++i)
|
||||
// distance to middle point - hlength => distance from point to border
|
||||
// of x,y,z
|
||||
if ((dxyz[i] = std::abs(point[i] - pos[i]) - hlen[i]) > safetyMin)
|
||||
continue;
|
||||
|
||||
G4double d2xyz = 0.;
|
||||
for (G4int i = 0; i <= 2; ++i)
|
||||
for (auto i = 0; i <= 2; ++i)
|
||||
if (dxyz[i] > 0) d2xyz += dxyz[i] * dxyz[i];
|
||||
|
||||
// minimal distance is at least this, but could be even higher. therefore,
|
||||
@@ -994,7 +985,7 @@ G4Polyhedron* G4MultiUnion::CreatePolyhedron() const
|
||||
//______________________________________________________________________________
|
||||
G4Polyhedron* G4MultiUnion::GetPolyhedron() const
|
||||
{
|
||||
if (!fpPolyhedron ||
|
||||
if (fpPolyhedron == nullptr ||
|
||||
fRebuildPolyhedron ||
|
||||
fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
|
||||
fpPolyhedron->GetNumberOfRotationSteps())
|
||||
|
||||
@@ -23,14 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// Implementation for G4ScaledSolid class
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 27.10.15 G.Cosmo: created, based on implementation also provided in Root
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4ScaledSolid.hh"
|
||||
@@ -50,9 +45,7 @@
|
||||
G4ScaledSolid::G4ScaledSolid( const G4String& pName,
|
||||
G4VSolid* pSolid,
|
||||
const G4Scale3D& pScale )
|
||||
: G4VSolid(pName), fPtrSolid(pSolid),
|
||||
fCubicVolume(-1.), fSurfaceArea(-1.),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
: G4VSolid(pName), fPtrSolid(pSolid)
|
||||
{
|
||||
fScale = new G4ScaleTransform(pScale);
|
||||
}
|
||||
@@ -63,9 +56,7 @@ G4ScaledSolid::G4ScaledSolid( const G4String& pName,
|
||||
// for usage restricted to object persistency
|
||||
//
|
||||
G4ScaledSolid::G4ScaledSolid( __void__& a )
|
||||
: G4VSolid(a), fPtrSolid(0), fScale(0),
|
||||
fCubicVolume(-1.), fSurfaceArea(-1.),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
: G4VSolid(a)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -75,8 +66,8 @@ G4ScaledSolid::G4ScaledSolid( __void__& a )
|
||||
//
|
||||
G4ScaledSolid::~G4ScaledSolid()
|
||||
{
|
||||
delete fpPolyhedron; fpPolyhedron= 0;
|
||||
delete fScale; fScale= 0;
|
||||
delete fpPolyhedron; fpPolyhedron = nullptr;
|
||||
delete fScale; fScale = nullptr;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
@@ -85,8 +76,7 @@ G4ScaledSolid::~G4ScaledSolid()
|
||||
//
|
||||
G4ScaledSolid::G4ScaledSolid(const G4ScaledSolid& rhs)
|
||||
: G4VSolid (rhs), fPtrSolid(rhs.fPtrSolid),
|
||||
fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea)
|
||||
{
|
||||
fScale = new G4ScaleTransform(*(rhs.fScale));
|
||||
}
|
||||
@@ -113,7 +103,7 @@ G4ScaledSolid& G4ScaledSolid::operator = (const G4ScaledSolid& rhs)
|
||||
fCubicVolume = rhs.fCubicVolume;
|
||||
fSurfaceArea = rhs.fSurfaceArea;
|
||||
fRebuildPolyhedron = false;
|
||||
delete fpPolyhedron; fpPolyhedron= 0;
|
||||
delete fpPolyhedron; fpPolyhedron = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -361,7 +351,7 @@ G4Scale3D G4ScaledSolid::GetScaleTransform() const
|
||||
//
|
||||
void G4ScaledSolid::SetScaleTransform(const G4Scale3D& scale)
|
||||
{
|
||||
if (fScale) { delete fScale; }
|
||||
if (fScale != nullptr) { delete fScale; }
|
||||
fScale = new G4ScaleTransform(scale);
|
||||
fRebuildPolyhedron = true;
|
||||
}
|
||||
@@ -437,7 +427,7 @@ G4Polyhedron*
|
||||
G4ScaledSolid::CreatePolyhedron () const
|
||||
{
|
||||
G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron();
|
||||
if (polyhedron)
|
||||
if (polyhedron != nullptr)
|
||||
{
|
||||
polyhedron->Transform(GetScaleTransform());
|
||||
}
|
||||
@@ -457,7 +447,7 @@ G4ScaledSolid::CreatePolyhedron () const
|
||||
//
|
||||
G4Polyhedron* G4ScaledSolid::GetPolyhedron () const
|
||||
{
|
||||
if (!fpPolyhedron ||
|
||||
if (fpPolyhedron == nullptr ||
|
||||
fRebuildPolyhedron ||
|
||||
fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
|
||||
fpPolyhedron->GetNumberOfRotationSteps())
|
||||
|
||||
@@ -23,19 +23,11 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// Implementation of methods for the class G4IntersectionSolid
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 14.10.98 V.Grichine: implementation of the first version
|
||||
// 22.07.11 T.Nikitina: added detection of infinite loop in DistanceToIn(p,v)
|
||||
// 19.10.98 V.Grichine: new algorithm of DistanceToIn(p,v)
|
||||
// 02.08.99 V.Grichine: bugs fixed in DistanceToOut(p,v,...)
|
||||
// while -> do-while & surfaceA limitations
|
||||
// 13.09.00 V.Grichine: bug fixed in SurfaceNormal(p), p can be inside
|
||||
// 22.07.11 T.Nikitina: add detection of Infinite Loop in DistanceToIn(p,v)
|
||||
//
|
||||
// 14.10.98 V.Grichine: implementation of the first version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4SubtractionSolid.hh"
|
||||
@@ -315,7 +307,7 @@ G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p,
|
||||
dist2 = dist+disTmp;
|
||||
if (dist == dist2) { return dist; } // no progress
|
||||
dist = dist2 ;
|
||||
count1++;
|
||||
++count1;
|
||||
if( count1 > 1000 ) // Infinite loop detected
|
||||
{
|
||||
G4String nameB = fPtrSolidB->GetName();
|
||||
@@ -371,7 +363,7 @@ G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p,
|
||||
dist2 = dist+disTmp;
|
||||
if (dist == dist2) { return dist; } // no progress
|
||||
dist = dist2 ;
|
||||
count2++;
|
||||
++count2;
|
||||
if( count2 > 1000 ) // Infinite loop detected
|
||||
{
|
||||
G4String nameB = fPtrSolidB->GetName();
|
||||
@@ -412,7 +404,7 @@ G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p,
|
||||
G4double
|
||||
G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p ) const
|
||||
{
|
||||
G4double dist=0.0;
|
||||
G4double dist = 0.0;
|
||||
|
||||
#ifdef G4BOOLDEBUG
|
||||
if( Inside(p) == kInside )
|
||||
@@ -431,11 +423,11 @@ G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p ) const
|
||||
if( ( fPtrSolidA->Inside(p) != kOutside) && // case 1
|
||||
( fPtrSolidB->Inside(p) != kOutside) )
|
||||
{
|
||||
dist= fPtrSolidB->DistanceToOut(p) ;
|
||||
dist = fPtrSolidB->DistanceToOut(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
dist= fPtrSolidA->DistanceToIn(p) ;
|
||||
dist = fPtrSolidA->DistanceToIn(p);
|
||||
}
|
||||
|
||||
return dist;
|
||||
@@ -545,7 +537,7 @@ G4VSolid* G4SubtractionSolid::Clone() const
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// ComputeDimensions
|
||||
|
||||
void
|
||||
G4SubtractionSolid::ComputeDimensions( G4VPVParameterisation*,
|
||||
@@ -556,7 +548,7 @@ G4SubtractionSolid::ComputeDimensions( G4VPVParameterisation*,
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// DescribeYourselfTo
|
||||
|
||||
void
|
||||
G4SubtractionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
@@ -566,7 +558,7 @@ G4SubtractionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// CreatePolyhedron
|
||||
|
||||
G4Polyhedron*
|
||||
G4SubtractionSolid::CreatePolyhedron () const
|
||||
@@ -577,5 +569,5 @@ G4SubtractionSolid::CreatePolyhedron () const
|
||||
G4Polyhedron* top = StackPolyhedron(processor, this);
|
||||
G4Polyhedron* result = new G4Polyhedron(*top);
|
||||
if (processor.execute(*result)) { return result; }
|
||||
else { return 0; }
|
||||
else { return nullptr; }
|
||||
}
|
||||
|
||||
@@ -23,19 +23,11 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// Implementation of methods for the class G4UnionSolid
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 12.09.98 V.Grichine: first implementation
|
||||
// 28.11.98 V.Grichine: fix while loops in DistToIn/Out
|
||||
// 27.07.99 V.Grichine: modifications in DistToOut(p,v,...), while -> do-while
|
||||
// 16.03.01 V.Grichine: modifications in CalculateExtent()
|
||||
// 17.03.17 E.Tcherniaev: revision of SurfaceNormal()
|
||||
// 23.04.18 E.Tcherniaev: added extended BBox, yearly return in Inside()
|
||||
//
|
||||
// 17.03.17 E.Tcherniaev: revision of SurfaceNormal()
|
||||
// 12.09.98 V.Grichine: first implementation
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include <sstream>
|
||||
@@ -355,7 +347,7 @@ G4UnionSolid::DistanceToOut( const G4ThreeVector& p,
|
||||
{
|
||||
G4double dist = 0.0, disTmp = 0.0 ;
|
||||
G4ThreeVector normTmp;
|
||||
G4ThreeVector* nTmp= &normTmp;
|
||||
G4ThreeVector* nTmp = &normTmp;
|
||||
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
@@ -383,7 +375,6 @@ G4UnionSolid::DistanceToOut( const G4ThreeVector& p,
|
||||
else
|
||||
{
|
||||
EInside positionA = fPtrSolidA->Inside(p) ;
|
||||
// EInside positionB = fPtrSolidB->Inside(p) ;
|
||||
|
||||
if( positionA != kOutside )
|
||||
{
|
||||
@@ -483,7 +474,7 @@ G4UnionSolid::DistanceToOut( const G4ThreeVector& p ) const
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// GetEntityType
|
||||
|
||||
G4GeometryType G4UnionSolid::GetEntityType() const
|
||||
{
|
||||
@@ -501,7 +492,7 @@ G4VSolid* G4UnionSolid::Clone() const
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// ComputeDimensions
|
||||
|
||||
void
|
||||
G4UnionSolid::ComputeDimensions( G4VPVParameterisation*,
|
||||
@@ -512,7 +503,7 @@ G4UnionSolid::ComputeDimensions( G4VPVParameterisation*,
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// DescribeYourselfTo
|
||||
|
||||
void
|
||||
G4UnionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
@@ -522,7 +513,7 @@ G4UnionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// CreatePolyhedron
|
||||
|
||||
G4Polyhedron*
|
||||
G4UnionSolid::CreatePolyhedron () const
|
||||
@@ -533,5 +524,5 @@ G4UnionSolid::CreatePolyhedron () const
|
||||
G4Polyhedron* top = StackPolyhedron(processor, this);
|
||||
G4Polyhedron* result = new G4Polyhedron(*top);
|
||||
if (processor.execute(*result)) { return result; }
|
||||
else { return 0; }
|
||||
else { return nullptr; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user