Import Geant4 11.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2021-12-10 14:46:44 +01:00
committed by Ben Morgan
parent 6399a014b6
commit 80e2389dd8
3932 changed files with 202519 additions and 246221 deletions
+3
View File
@@ -16,6 +16,9 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
December 1st, 2021 B.Morgan (geombias-V10-07-01)
- Add missing include of G4Threading header for G4Mutex
March 30th, 2021 B.Morgan (geombias-V10-07-00)
- Migrate sources.cmake to modular build API
@@ -35,6 +35,7 @@
#ifndef G4IMPORTANCEALGORITHM_HH
#define G4IMPORTANCEALGORITHM_HH 1
#include "G4Threading.hh"
#include "G4VImportanceAlgorithm.hh"
class G4ImportanceAlgorithm : public G4VImportanceAlgorithm
+2 -1
View File
@@ -17,7 +17,8 @@ CPPFLAGS += \
-I$(G4BASE)/graphics_reps/include \
-I$(G4BASE)/geometry/solids/CSG/include \
-I$(G4BASE)/geometry/solids/specific/include \
-I$(G4BASE)/geometry/management/include
-I$(G4BASE)/geometry/management/include \
-I$(G4BASE)/geometry/volumes/include
ifdef G4DIVDEBUG
CPPFLAGS += -DG4DIVDEBUG
+17
View File
@@ -16,6 +16,23 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
October 29th, 2021 G.Cosmo (geomdiv-V10-07-04)
- G4ReplicatedSlice: added protection against null pointer for mother
physical-volume in constructor.
October 14th, 2021 G.Cosmo (geomdiv-V10-07-03)
- Make G4PVDivision and G4ReplicatedSlice inherit from G4PVReplica
rather than G4VPhysicalVolume, in order to have instances properly
cloned in MT mode. Coworks with "geomvol-V10-07-05".
September 24th, 2021 P.Arce (geomdiv-V10-07-02)
- Fix bug in G4ParameterisationTrd for division along X.
Debug messages cleaning.
August 18th, 2021 G.Cosmo (geomdiv-V10-07-01)
- Bring internal interactive test for divisions up-to-date.
No functional changes.
March 30th, 2021 B.Morgan (geomdiv-V10-07-00)
- Migrate sources.cmake to modular build API
@@ -65,13 +65,13 @@
#define G4PVDIVISION_HH
#include "geomdefs.hh"
#include "G4VPhysicalVolume.hh"
#include "G4PVReplica.hh"
#include "G4VDivisionParameterisation.hh"
class G4LogicalVolume;
class G4VSolid;
class G4PVDivision : public G4VPhysicalVolume
class G4PVDivision : public G4PVReplica
{
public: // with description
@@ -115,8 +115,6 @@ class G4PVDivision : public G4VPhysicalVolume
G4PVDivision& operator=(const G4PVDivision&) = delete;
virtual G4bool IsMany() const;
virtual G4int GetCopyNo() const;
virtual void SetCopyNo(G4int CopyNo);
virtual G4bool IsReplicated() const;
virtual G4int GetMultiplicity() const;
virtual G4VPVParameterisation* GetParameterisation() const;
@@ -159,7 +157,6 @@ class G4PVDivision : public G4VPhysicalVolume
EAxis fdivAxis; // axis of division
G4int fnReplicas = 0;
G4double fwidth = 0.0, foffset = 0.0;
G4int fcopyNo = -1;
G4VDivisionParameterisation* fparam = nullptr;
};
@@ -81,8 +81,6 @@ class G4ParameterisationTrdX : public G4VParameterisationTrd
G4VSolid* motherSolid, DivisionType divType );
~G4ParameterisationTrdX();
void CheckParametersValidity();
G4double GetMaxParameter() const;
void ComputeTransformation(const G4int copyNo,
@@ -92,11 +90,8 @@ class G4ParameterisationTrdX : public G4VParameterisationTrd
const G4VPhysicalVolume* pv) const;
void ComputeDimensions(G4Trap& trd, const G4int copyNo,
const G4VPhysicalVolume* pv) const;
const G4VPhysicalVolume* pv) const;
G4VSolid* ComputeSolid(const G4int, G4VPhysicalVolume *);
private: // Dummy declarations to get rid of warnings ...
void ComputeDimensions (G4Cons&,const G4int,
@@ -121,8 +116,6 @@ class G4ParameterisationTrdX : public G4VParameterisationTrd
const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Polyhedra&,const G4int,
const G4VPhysicalVolume*) const {}
void ComputeTrapParams();
};
@@ -135,8 +128,6 @@ class G4ParameterisationTrdY : public G4VParameterisationTrd
G4VSolid* motherSolid, DivisionType divType );
~G4ParameterisationTrdY();
void CheckParametersValidity();
G4double GetMaxParameter() const;
void ComputeTransformation(const G4int copyNo,
@@ -145,6 +136,9 @@ class G4ParameterisationTrdY : public G4VParameterisationTrd
void ComputeDimensions(G4Trd& trd, const G4int copyNo,
const G4VPhysicalVolume* pv) const;
void ComputeDimensions (G4Trap&,const G4int,
const G4VPhysicalVolume*) const;
private: // Dummy declarations to get rid of warnings ...
void ComputeDimensions (G4Cons&,const G4int,
@@ -161,8 +155,6 @@ class G4ParameterisationTrdY : public G4VParameterisationTrd
const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Para&,const G4int,
const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Trap&,const G4int,
const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Hype&,const G4int,
const G4VPhysicalVolume*) const {}
void ComputeDimensions (G4Tubs&,const G4int,
@@ -57,15 +57,15 @@
#define G4REPLICATEDSLICE_HH 1
#include "geomdefs.hh"
#include "G4VPhysicalVolume.hh"
#include "G4PVReplica.hh"
#include "G4VDivisionParameterisation.hh"
class G4LogicalVolume;
class G4VSolid;
class G4ReplicatedSlice : public G4VPhysicalVolume
class G4ReplicatedSlice : public G4PVReplica
{
public: // with description
public:
G4ReplicatedSlice(const G4String& pName,
G4LogicalVolume* pLogical,
@@ -129,8 +129,6 @@ class G4ReplicatedSlice : public G4VPhysicalVolume
G4ReplicatedSlice& operator=(const G4ReplicatedSlice&) = delete;
virtual G4bool IsMany() const;
virtual G4int GetCopyNo() const;
virtual void SetCopyNo(G4int CopyNo);
virtual G4bool IsReplicated() const;
virtual G4int GetMultiplicity() const;
virtual G4VPVParameterisation* GetParameterisation() const;
@@ -177,7 +175,6 @@ class G4ReplicatedSlice : public G4VPhysicalVolume
EAxis fdivAxis; // axis of division
G4int fnReplicas = 0;
G4double fwidth = 0.0, foffset = 0.0;
G4int fcopyNo = -1;
G4VDivisionParameterisation* fparam = nullptr;
};
+1 -1
View File
@@ -29,5 +29,5 @@ geant4_add_module(G4geomdivision
G4VDivisionParameterisation.cc)
geant4_module_link_libraries(G4geomdivision
PUBLIC G4specsolids G4globman G4geometrymng G4hepgeometry
PUBLIC G4specsolids G4volumes G4globman G4geometrymng G4hepgeometry
PRIVATE G4csg)
+5 -16
View File
@@ -48,7 +48,7 @@ G4PVDivision::G4PVDivision(const G4String& pName,
const G4int nDivs,
const G4double width,
const G4double offset )
: G4VPhysicalVolume(nullptr,G4ThreeVector(),pName,pLogical,nullptr)
: G4PVReplica(pName, nDivs, pAxis, pLogical, pMotherLogical)
{
if (pMotherLogical == nullptr)
{
@@ -82,7 +82,7 @@ G4PVDivision::G4PVDivision(const G4String& pName,
const EAxis pAxis,
const G4int nDivs,
const G4double offset )
: G4VPhysicalVolume(nullptr,G4ThreeVector(),pName,pLogical,nullptr)
: G4PVReplica(pName, nDivs, pAxis, pLogical, pMotherLogical)
{
if (pMotherLogical == nullptr)
{
@@ -114,7 +114,7 @@ G4PVDivision::G4PVDivision(const G4String& pName,
const EAxis pAxis,
const G4double width,
const G4double offset )
: G4VPhysicalVolume(nullptr,G4ThreeVector(),pName,pLogical,nullptr)
: G4PVReplica(pName, 0, pAxis, pLogical, pMotherLogical)
{
if (pMotherLogical == nullptr)
{
@@ -147,7 +147,8 @@ G4PVDivision::G4PVDivision(const G4String& pName,
const G4int nDivs,
const G4double width,
const G4double offset )
: G4VPhysicalVolume(nullptr,G4ThreeVector(),pName,pLogical,nullptr)
: G4PVReplica(pName, nDivs, pAxis, pLogical,
pMotherPhysical ? pMotherPhysical->GetLogicalVolume() : nullptr)
{
if (pMotherPhysical == nullptr)
{
@@ -290,18 +291,6 @@ G4bool G4PVDivision::IsMany() const
return false;
}
//--------------------------------------------------------------------------
G4int G4PVDivision::GetCopyNo() const
{
return fcopyNo;
}
//--------------------------------------------------------------------------
void G4PVDivision::SetCopyNo(G4int newCopyNo)
{
fcopyNo = newCopyNo;
}
//--------------------------------------------------------------------------
G4bool G4PVDivision::IsReplicated() const
{
@@ -267,10 +267,10 @@ ComputeTransformation( const G4int copyNo, G4VPhysicalVolume *physVol ) const
#ifdef G4DIVDEBUG
if( verbose >= 2 )
{
G4cout << " G4ParameterisationConsPhi - position: " << posi/deg << G4endl
G4cout << " G4ParameterisationConsPhi - position: " << posi/CLHEP::deg << G4endl
<< " Origin: " << origin << " copyNo: " << copyNo
<< " - foffset: " << foffset/deg
<< " - fwidth: " << fwidth/deg << G4endl
<< " - foffset: " << foffset/CLHEP::deg
<< " - fwidth: " << fwidth/CLHEP::deg << G4endl
<< " - Axis: " << faxis << G4endl;
}
#endif
@@ -45,14 +45,14 @@ G4VParameterisationPolycone( EAxis axis, G4int nDiv, G4double width,
DivisionType divType )
: G4VDivisionParameterisation( axis, nDiv, width, offset, divType, msolid )
{
#ifdef G4MULTITHREADED
/*#ifdef G4MULTITHREADED
std::ostringstream message;
message << "Divisions for G4Polycone currently NOT supported in MT-mode."
<< G4endl
<< "Sorry! Solid: " << msolid->GetName();
G4Exception("G4VParameterisationPolycone::G4VParameterisationPolycone()",
"GeomDiv0001", FatalException, message);
#endif
#endif */
G4Polycone* msol = (G4Polycone*)(msolid);
if (msolid->GetEntityType() == "G4ReflectedSolid")
{
@@ -200,8 +200,8 @@ ComputeTransformation( const G4int, G4VPhysicalVolume* physVol ) const
{
G4cout << std::setprecision(8) << " G4ParameterisationPolyconeRho "
<< G4endl
<< " Position: " << origin/mm
<< " - Width: " << fwidth/deg
<< " Position: (0,0,0)"
<< " - Width: " << fwidth/CLHEP::deg
<< " - Axis: " << faxis << G4endl;
}
#endif
@@ -268,8 +268,8 @@ G4ParameterisationPolyconePhi( EAxis axis, G4int nDiv,
{
G4cout << " G4ParameterisationPolyconePhi - # divisions " << fnDiv
<< " = " << nDiv << G4endl
<< " Offset " << foffset/deg << " = " << offset/deg << G4endl
<< " Width " << fwidth/deg << " = " << width/deg << G4endl;
<< " Offset " << foffset/CLHEP::deg << " = " << offset/CLHEP::deg << G4endl
<< " Width " << fwidth/CLHEP::deg << " = " << width/CLHEP::deg << G4endl;
}
#endif
}
@@ -302,10 +302,10 @@ ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const
#ifdef G4DIVDEBUG
if( verbose >= 2 )
{
G4cout << " G4ParameterisationPolyconePhi - position: " << posi/deg
G4cout << " G4ParameterisationPolyconePhi - position: " << posi/CLHEP::deg
<< G4endl
<< " copyNo: " << copyNo << " - foffset: " << foffset/deg
<< " - fwidth: " << fwidth/deg << G4endl;
<< " copyNo: " << copyNo << " - foffset: " << foffset/CLHEP::deg
<< " - fwidth: " << fwidth/CLHEP::deg << G4endl;
}
#endif
@@ -316,7 +316,7 @@ ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const
{
G4cout << std::setprecision(8) << " G4ParameterisationPolyconePhi "
<< copyNo << G4endl
<< " Position: " << origin << " - Width: " << fwidth
<< " Position: (0,0,0) - Width: " << fwidth
<< " - Axis: " << faxis << G4endl;
}
#endif
@@ -542,11 +542,12 @@ void
G4ParameterisationPolyconeZ::
ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol) const
{
G4double posi = 0.;
if ( fDivisionType == DivNDIV )
{
// The position of the centre of copyNo-th mother polycone segment
//
G4double posi = ( fOrigParamMother->Z_values[copyNo]
posi = ( fOrigParamMother->Z_values[copyNo]
+ fOrigParamMother->Z_values[copyNo+1])/2;
physVol->SetTranslation( G4ThreeVector(0, 0, posi) );
}
@@ -555,7 +556,7 @@ ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol) const
{
// The position of the centre of copyNo-th division
//
G4double posi = fOrigParamMother->Z_values[0];
posi = fOrigParamMother->Z_values[0];
if ( !fReflectedSolid )
posi += foffset + (2*copyNo + 1) * fwidth/2.;
@@ -571,8 +572,8 @@ ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol) const
if( verbose >= 2 )
{
G4cout << " G4ParameterisationPolyconeZ - position: " << posi << G4endl
<< " copyNo: " << copyNo << " - foffset: " << foffset/deg
<< " - fwidth: " << fwidth/deg << G4endl;
<< " copyNo: " << copyNo << " - foffset: " << foffset/CLHEP::deg
<< " - fwidth: " << fwidth/CLHEP::deg << G4endl;
}
#endif
@@ -583,7 +584,7 @@ ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol) const
{
G4cout << std::setprecision(8) << " G4ParameterisationPolyconeZ "
<< copyNo << G4endl
<< " Position: " << origin << " - Width: " << fwidth
<< " Position: (0,0,0) - Width: " << fwidth
<< " - Axis: " << faxis << G4endl;
}
#endif
@@ -49,13 +49,13 @@ G4VParameterisationPolyhedra( EAxis axis, G4int nDiv, G4double width,
: G4VDivisionParameterisation( axis, nDiv, width, offset, divType, msolid )
{
std::ostringstream message;
#ifdef G4MULTITHREADED
/* #ifdef G4MULTITHREADED
message << "Divisions for G4Polyhedra currently NOT supported in MT-mode."
<< G4endl
<< "Sorry! Solid: " << msolid->GetName();
G4Exception("G4VParameterisationPolyhedra::G4VParameterisationPolyhedra()",
"GeomDiv0001", FatalException, message);
#endif
#endif */
G4Polyhedra* msol = (G4Polyhedra*)(msolid);
if ((msolid->GetEntityType() != "G4ReflectedSolid") && (msol->IsGeneric()))
@@ -226,8 +226,8 @@ ComputeTransformation( const G4int, G4VPhysicalVolume* physVol ) const
if( verbose >= 2 )
{
G4cout << " G4ParameterisationPolyhedraRho " << G4endl
<< " foffset: " << foffset/deg
<< " - fwidth: " << fwidth/deg << G4endl;
<< " foffset: " << foffset/CLHEP::deg
<< " - fwidth: " << fwidth/CLHEP::deg << G4endl;
}
#endif
@@ -381,10 +381,10 @@ ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const
#ifdef G4DIVDEBUG
if( verbose >= 2 )
{
G4cout << " G4ParameterisationPolyhedraPhi - position: " << posi/deg
G4cout << " G4ParameterisationPolyhedraPhi - position: " << posi/CLHEP::deg
<< G4endl
<< " copyNo: " << copyNo
<< " - fwidth: " << fwidth/deg << G4endl;
<< " - fwidth: " << fwidth/CLHEP::deg << G4endl;
}
#endif
@@ -619,11 +619,12 @@ void
G4ParameterisationPolyhedraZ::
ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol) const
{
G4double posi;
if ( fDivisionType == DivNDIV )
{
// The position of the centre of copyNo-th mother polycone segment
G4double posi = ( fOrigParamMother->Z_values[copyNo]
posi = ( fOrigParamMother->Z_values[copyNo]
+ fOrigParamMother->Z_values[copyNo+1])/2;
physVol->SetTranslation( G4ThreeVector(0, 0, posi) );
}
@@ -632,7 +633,7 @@ ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol) const
{
// The position of the centre of copyNo-th division
G4double posi = fOrigParamMother->Z_values[0];
posi = fOrigParamMother->Z_values[0];
if ( !fReflectedSolid )
posi += foffset + (2*copyNo + 1) * fwidth/2.;
@@ -648,8 +649,8 @@ ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol) const
if( verbose >= 2 )
{
G4cout << " G4ParameterisationPolyhedraZ - position: " << posi << G4endl
<< " copyNo: " << copyNo << " - foffset: " << foffset/deg
<< " - fwidth: " << fwidth/deg << G4endl;
<< " copyNo: " << copyNo << " - foffset: " << foffset/CLHEP::deg
<< " - fwidth: " << fwidth/CLHEP::deg << G4endl;
}
#endif
@@ -660,7 +661,7 @@ ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol) const
{
G4cout << std::setprecision(8) << " G4ParameterisationPolyhedraZ "
<< copyNo << G4endl
<< " Position: " << origin << " - Width: " << fwidth
<< " Position: (0,0,0) - Width: " << fwidth
<< " - Axis: " << faxis << G4endl;
}
#endif
@@ -134,19 +134,10 @@ ComputeTransformation( const G4int copyNo,
{
G4Trd* msol = (G4Trd*)(fmotherSolid );
G4double mdx = ( msol->GetXHalfLength1() + msol->GetXHalfLength2() ) / 2.;
//----- translation
G4ThreeVector origin(0.,0.,0.);
G4double posi;
if( !bDivInTrap )
{
posi = -mdx + foffset + (copyNo+0.5)*fwidth;
}
else
{
G4double aveHL = (msol->GetXHalfLength1()+msol->GetXHalfLength2())/2.;
posi = - aveHL + foffset + (copyNo+0.5)*aveHL/fnDiv*2;
}
posi = -mdx + foffset + (copyNo+0.5)*fwidth;
if( faxis == kXAxis )
{
origin.setX( posi );
@@ -176,15 +167,14 @@ ComputeTransformation( const G4int copyNo,
//--------------------------------------------------------------------------
void
G4ParameterisationTrdX::
ComputeDimensions( G4Trd& trd, const G4int, const G4VPhysicalVolume* ) const
{
ComputeDimensions( G4Trd& trd, [[maybe_unused]] const G4int copyNo, const G4VPhysicalVolume* ) const
{
G4Trd* msol = (G4Trd*)(fmotherSolid);
G4double pDy1 = msol->GetYHalfLength1();
G4double pDy2 = msol->GetYHalfLength2();
G4double pDz = msol->GetZHalfLength();
G4double pDx = fwidth/2. - fhgap;
trd.SetAllParameters ( pDx, pDx, pDy1, pDy2, pDz );
#ifdef G4DIVDEBUG
@@ -197,49 +187,45 @@ ComputeDimensions( G4Trd& trd, const G4int, const G4VPhysicalVolume* ) const
#endif
}
G4VSolid* G4ParameterisationTrdX::
ComputeSolid(const G4int i, G4VPhysicalVolume* pv)
{
if( bDivInTrap )
{
return G4VDivisionParameterisation::ComputeSolid(i, pv);
}
else
{
return fmotherSolid;
}
}
//--------------------------------------------------------------------------
void
G4ParameterisationTrdX::ComputeDimensions( G4Trap& trap, const G4int copyNo,
const G4VPhysicalVolume* ) const
{
G4Trd* msol = (G4Trd*)(fmotherSolid);
G4Trd* msol = (G4Trd*)(fmotherSolid);
G4double pDy1 = msol->GetYHalfLength1();
G4double pDy2 = msol->GetYHalfLength2();
G4double pDz = msol->GetZHalfLength();
G4double pDx1 = msol->GetXHalfLength1()/fnDiv;
G4double pDx2 = msol->GetXHalfLength2()/fnDiv;
//fwidth is at Z=0
G4double pDx1 = msol->GetXHalfLength1();
G4double pDx2 = msol->GetXHalfLength2();
// G4double pDxAVE = (pDx1+pDx2)/2.;
G4double xChangeRatio = (pDx2-pDx1) / (pDx2+pDx1);
G4double fWidChange = xChangeRatio*fwidth;
G4double fWid1 = fwidth - fWidChange;
G4double fWid2 = fwidth + fWidChange;
G4double fOffsetChange = xChangeRatio*foffset/2.;
G4double fOffset1 = foffset - fOffsetChange;
G4double fOffset2 = foffset + fOffsetChange;
G4double cxy1 = -pDx1+fOffset1 + (copyNo+0.5)*fWid1;// centre of the side at y=-pDy1
G4double cxy2 = -pDx2+fOffset2 + (copyNo+0.5)*fWid2;// centre of the side at y=+pDy1
G4double alp = std::atan( (cxy2-cxy1)/(pDz*2.) );
pDx1 = fwidth/2. - fWidChange/2.;
pDx2 = fwidth/2. + fWidChange/2.;
G4double cxy1 = -msol->GetXHalfLength1() + foffset
+ (copyNo+0.5)*pDx1*2;// centre of the side at y=-pDy1
G4double cxy2 = -msol->GetXHalfLength2() + foffset
+ (copyNo+0.5)*pDx2*2;// centre of the side at y=+pDy1
G4double alp = std::atan( (cxy2-cxy1)/pDz );
trap.SetAllParameters ( pDz,
0.,
alp,
0.,
pDy1,
pDx1,
pDx2,
alp,
pDx1,
0.,
pDy2,
pDx1 - fhgap,
pDx2 - fhgap,
pDx2 - fhgap * pDx2/pDx1,
alp);
0.);
#ifdef G4DIVDEBUG
if( verbose >= 2 )
@@ -251,36 +237,6 @@ G4ParameterisationTrdX::ComputeDimensions( G4Trap& trap, const G4int copyNo,
#endif
}
//--------------------------------------------------------------------------
void G4ParameterisationTrdX::CheckParametersValidity()
{
G4VDivisionParameterisation::CheckParametersValidity();
/*
G4Trd* msol = (G4Trd*)(fmotherSolid);
G4double mpDx1 = msol->GetXHalfLength1();
G4double mpDx2 = msol->GetXHalfLength2();
bDivInTrap = false;
if( std::fabs(mpDx1 - mpDx2) > kCarTolerance )
{
std::ostringstream message;
message << "Invalid solid specification. NOT supported." << G4endl
<< "Making a division of a TRD along axis X," << G4endl
<< "while the X half lengths are not equal," << G4endl
<< "is not (yet) supported. It will result" << G4endl
<< "in non-equal division solids.";
G4Exception("G4ParameterisationTrdX::CheckParametersValidity()",
"GeomDiv0001", FatalException, message);
}
*/
}
//--------------------------------------------------------------------------
void G4ParameterisationTrdX::
ComputeTrapParams()
{
}
//--------------------------------------------------------------------------
G4ParameterisationTrdY::
@@ -324,7 +280,7 @@ G4ParameterisationTrdY::~G4ParameterisationTrdY()
G4double G4ParameterisationTrdY::GetMaxParameter() const
{
G4Trd* msol = (G4Trd*)(fmotherSolid);
return 2*msol->GetYHalfLength1();
return (msol->GetYHalfLength1()+msol->GetYHalfLength2());
}
//--------------------------------------------------------------------------
@@ -333,7 +289,7 @@ G4ParameterisationTrdY::
ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const
{
G4Trd* msol = (G4Trd*)(fmotherSolid );
G4double mdy = msol->GetYHalfLength1();
G4double mdy = ( msol->GetYHalfLength1() + msol->GetYHalfLength2() ) / 2.;
//----- translation
G4ThreeVector origin(0.,0.,0.);
@@ -390,26 +346,53 @@ ComputeDimensions(G4Trd& trd, const G4int, const G4VPhysicalVolume*) const
}
//--------------------------------------------------------------------------
void G4ParameterisationTrdY::CheckParametersValidity()
void
G4ParameterisationTrdY::ComputeDimensions( G4Trap& trap, const G4int copyNo,
const G4VPhysicalVolume* ) const
{
G4VDivisionParameterisation::CheckParametersValidity();
G4Trd* msol = (G4Trd*)(fmotherSolid);
G4double pDx1 = msol->GetXHalfLength1();
G4double pDx2 = msol->GetXHalfLength2();
G4double pDz = msol->GetZHalfLength();
//fwidth is at Z=0
G4double pDy1 = msol->GetYHalfLength1();
G4double pDy2 = msol->GetYHalfLength2();
// G4double pDxAVE = (pDy1+pDy2)/2.;
G4double yChangeRatio = (pDy2-pDy1) / (pDy2+pDy1);
G4double fWidChange = yChangeRatio*fwidth;
G4double fWid1 = fwidth - fWidChange;
G4double fWid2 = fwidth + fWidChange;
G4double fOffsetChange = yChangeRatio*foffset/2.;
G4double fOffset1 = foffset - fOffsetChange;
G4double fOffset2 = foffset + fOffsetChange;
G4double cyx1 = -pDy1+fOffset1 + (copyNo+0.5)*fWid1;// centre of the side at y=-pDy1
G4double cyx2 = -pDy2+fOffset2 + (copyNo+0.5)*fWid2;// centre of the side at y=+pDy1
G4double alp = std::atan( (cyx2-cyx1)/(pDz*2.) );
G4Trd* msol = (G4Trd*)(fmotherSolid);
pDy1 = fwidth/2. - fWidChange/2.;
pDy2 = fwidth/2. + fWidChange/2.;
G4double mpDy1 = msol->GetYHalfLength1();
G4double mpDy2 = msol->GetYHalfLength2();
if( std::fabs(mpDy1 - mpDy2) > kCarTolerance )
trap.SetAllParameters ( pDz,
alp,
90*CLHEP::deg,
pDy1,
pDx1,
pDx1,
0.,
pDy2,
pDx2 - fhgap,
pDx2 - fhgap * pDx2/pDx1,
0.);
#ifdef G4DIVDEBUG
if( verbose >= 2 )
{
std::ostringstream message;
message << "Invalid solid specification. NOT supported." << G4endl
<< "Making a division of a TRD along axis Y while" << G4endl
<< "the Y half lengths are not equal is not (yet)" << G4endl
<< "supported. It will result in non-equal" << G4endl
<< "division solids.";
G4Exception("G4ParameterisationTrdY::CheckParametersValidity()",
"GeomDiv0001", FatalException, message);
G4cout << " G4ParameterisationTrdY::ComputeDimensions():"
<< copyNo << G4endl;
trap.DumpInfo();
}
#endif
}
//--------------------------------------------------------------------------
@@ -127,8 +127,8 @@ ComputeTransformation(const G4int, G4VPhysicalVolume* physVol) const
if( verbose >= 2 )
{
G4cout << " G4ParameterisationTubsRho " << G4endl
<< " Offset: " << foffset/deg
<< " - Width: " << fwidth/deg << G4endl;
<< " Offset: " << foffset/CLHEP::deg
<< " - Width: " << fwidth/CLHEP::deg << G4endl;
}
#endif
@@ -234,9 +234,9 @@ ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
#ifdef G4DIVDEBUG
if( verbose >= 2 )
{
G4cout << " G4ParameterisationTubsPhi - position: " << posi/deg << G4endl
<< " copyNo: " << copyNo << " - foffset: " << foffset/deg
<< " - fwidth: " << fwidth/deg << G4endl;
G4cout << " G4ParameterisationTubsPhi - position: " << posi/CLHEP::deg << G4endl
<< " copyNo: " << copyNo << " - foffset: " << foffset/CLHEP::deg
<< " - fwidth: " << fwidth/CLHEP::deg << G4endl;
}
#endif
@@ -346,7 +346,7 @@ ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
{
G4cout << " G4ParameterisationTubsZ::ComputeTransformation()" << G4endl
<< " Position: " << posi << " - copyNo: " << copyNo << G4endl
<< " foffset " << foffset/deg << " - fwidth " << fwidth/deg
<< " foffset " << foffset/CLHEP::deg << " - fwidth " << fwidth/CLHEP::deg
<< G4endl;
}
#endif
@@ -49,7 +49,7 @@ G4ReplicatedSlice::G4ReplicatedSlice(const G4String& pName,
const G4double width,
const G4double half_gap,
const G4double offset )
: G4VPhysicalVolume(nullptr,G4ThreeVector(),pName,pLogical,nullptr)
: G4PVReplica(pName, nDivs, pAxis, pLogical, pMotherLogical)
{
CheckAndSetParameters(pAxis, nDivs, width, half_gap, offset,
DivNDIVandWIDTH, pMotherLogical, pLogical);
@@ -63,7 +63,7 @@ G4ReplicatedSlice::G4ReplicatedSlice(const G4String& pName,
const G4int nDivs,
const G4double half_gap,
const G4double offset )
: G4VPhysicalVolume(nullptr,G4ThreeVector(),pName,pLogical,nullptr)
: G4PVReplica(pName, nDivs, pAxis, pLogical, pMotherLogical)
{
CheckAndSetParameters(pAxis, nDivs, 0., half_gap, offset,
DivNDIV, pMotherLogical, pLogical);
@@ -77,7 +77,7 @@ G4ReplicatedSlice::G4ReplicatedSlice(const G4String& pName,
const G4double width,
const G4double half_gap,
const G4double offset )
: G4VPhysicalVolume(nullptr,G4ThreeVector(),pName,pLogical,nullptr)
: G4PVReplica(pName, 0, pAxis, pLogical, pMotherLogical)
{
CheckAndSetParameters(pAxis, 0, width, half_gap, offset,
DivWIDTH, pMotherLogical, pLogical);
@@ -92,8 +92,18 @@ G4ReplicatedSlice::G4ReplicatedSlice(const G4String& pName,
const G4double width,
const G4double half_gap,
const G4double offset )
: G4VPhysicalVolume(nullptr,G4ThreeVector(),pName,pLogical,nullptr)
: G4PVReplica(pName, nDivs, pAxis, pLogical,
pMotherPhysical ? pMotherPhysical->GetLogicalVolume() : nullptr)
{
if (pMotherPhysical == nullptr)
{
std::ostringstream message;
message << "Invalid setup." << G4endl
<< "NULL pointer specified as mother for volume: " << pName;
G4Exception("G4ReplicatedSlice::G4ReplicatedSlice()", "GeomDiv0002",
FatalException, message);
return;
}
CheckAndSetParameters(pAxis, nDivs, width, half_gap, offset,
DivNDIVandWIDTH, pMotherPhysical->GetLogicalVolume(), pLogical);
}
@@ -106,8 +116,18 @@ G4ReplicatedSlice::G4ReplicatedSlice(const G4String& pName,
const G4int nDivs,
const G4double half_gap,
const G4double offset )
: G4VPhysicalVolume(nullptr,G4ThreeVector(),pName,pLogical,nullptr)
: G4PVReplica(pName, nDivs, pAxis, pLogical,
pMotherPhysical ? pMotherPhysical->GetLogicalVolume() : nullptr)
{
if (pMotherPhysical == nullptr)
{
std::ostringstream message;
message << "Invalid setup." << G4endl
<< "NULL pointer specified as mother for volume: " << pName;
G4Exception("G4ReplicatedSlice::G4ReplicatedSlice()", "GeomDiv0002",
FatalException, message);
return;
}
CheckAndSetParameters(pAxis, nDivs, 0., half_gap, offset,
DivNDIV, pMotherPhysical->GetLogicalVolume(), pLogical);
}
@@ -120,8 +140,18 @@ G4ReplicatedSlice::G4ReplicatedSlice(const G4String& pName,
const G4double width,
const G4double half_gap,
const G4double offset )
: G4VPhysicalVolume(nullptr,G4ThreeVector(),pName,pLogical,nullptr)
: G4PVReplica(pName, 0, pAxis, pLogical,
pMotherPhysical ? pMotherPhysical->GetLogicalVolume() : nullptr)
{
if (pMotherPhysical == nullptr)
{
std::ostringstream message;
message << "Invalid setup." << G4endl
<< "NULL pointer specified as mother for volume: " << pName;
G4Exception("G4ReplicatedSlice::G4ReplicatedSlice()", "GeomDiv0002",
FatalException, message);
return;
}
CheckAndSetParameters(pAxis, 0, width, half_gap, offset,
DivWIDTH, pMotherPhysical->GetLogicalVolume(), pLogical);
}
@@ -269,18 +299,6 @@ G4bool G4ReplicatedSlice::IsMany() const
return false;
}
//--------------------------------------------------------------------------
G4int G4ReplicatedSlice::GetCopyNo() const
{
return fcopyNo;
}
//--------------------------------------------------------------------------
void G4ReplicatedSlice::SetCopyNo(G4int newCopyNo)
{
fcopyNo= newCopyNo;
}
//--------------------------------------------------------------------------
G4bool G4ReplicatedSlice::IsReplicated() const
{
+12
View File
@@ -15,6 +15,18 @@ commit in the repository !
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
September 28, 2021 G.Cosmo (geommng-V10-07-07)
- Use G4Allocator to dynamically allocate nodes and proxies for the
voxels optimisation structure. Should help reducing memory fragmentation.
September 24, 2021 G.Cosmo (geommng-V10-07-06)
- Basic clang-tidy review of code.
August 31, 2021 B.Morgan (geommng-V10-07-05)
- Provide operator<< as a free function for G4UAdapter to support Geant4Py
- Make operator<< for G4VSolid a free function
June 15, 2021 J.Apostolakis (geommng-V10-07-04)
- G4UAdapter: added std::ostream& operator << to avoid compilation clash
between similar methods for G4VSolid and VecGeom UnplacedVolume.
@@ -88,7 +88,7 @@ class G4AffineTransform
const G4ThreeVector& tlate);
// Optionally rotate by *rot then translate by tlate - rot may be null
inline G4AffineTransform(const G4AffineTransform& rhs);
inline G4AffineTransform(const G4AffineTransform& rhs) = default;
inline G4AffineTransform(G4AffineTransform&& rhs) = default;
// Copy and move constructors
@@ -96,7 +96,7 @@ class G4AffineTransform
inline G4AffineTransform& operator=(G4AffineTransform&& rhs) = default;
// Assignment & Move operators
inline ~G4AffineTransform();
inline ~G4AffineTransform() = default;
// Destructor
inline G4AffineTransform operator * (const G4AffineTransform& tf) const;
@@ -86,13 +86,6 @@ G4AffineTransform( const G4double prxx,const G4double prxy,const G4double prxz,
tx(ptx),ty(pty),tz(ptz)
{}
inline G4AffineTransform::G4AffineTransform(const G4AffineTransform& rhs)
: rxx(rhs.rxx),rxy(rhs.rxy),rxz(rhs.rxz),
ryx(rhs.ryx),ryy(rhs.ryy),ryz(rhs.ryz),
rzx(rhs.rzx),rzy(rhs.rzy),rzz(rhs.rzz),
tx(rhs.tx),ty(rhs.ty),tz(rhs.tz)
{}
inline G4AffineTransform&
G4AffineTransform::operator = (const G4AffineTransform& rhs)
{
@@ -104,9 +97,6 @@ G4AffineTransform::operator = (const G4AffineTransform& rhs)
return *this;
}
inline G4AffineTransform::~G4AffineTransform()
{}
inline G4AffineTransform
G4AffineTransform::operator * (const G4AffineTransform& tf) const
{
@@ -40,7 +40,7 @@
// 24.7.96, P.Kent - Separated from G4Navigator
// --------------------------------------------------------------------
#ifndef G4BLOCKINGLIST_HH
#define G4BLOCKINGLIST_HH
#define G4BLOCKINGLIST_HH 1
#include "G4Types.hh"
#include <vector>
@@ -52,13 +52,13 @@ const G4int kBlockTagNoMax = 2147483647; // 2^31-1 maximum tag no may reach
class G4BlockingList
{
public: // with description
public:
G4BlockingList(G4int maxDefault = kBlockingListMaxDefault,
G4int stride = kBlockingListStride);
// Create empty blocking List of default size and `stride' resize count.
~G4BlockingList();
~G4BlockingList() = default;
// Destructor. No operations.
void Reset();
@@ -68,12 +68,12 @@ class G4BoundingEnvelope
// should have equal numbers of vertices except first and last
// polygons which may consist of a single vertex
G4BoundingEnvelope(const G4ThreeVector& pMin,
G4BoundingEnvelope(const G4ThreeVector& pMin,
const G4ThreeVector& pMax,
const std::vector<const G4ThreeVectorList*>& polygons);
// Constructor from AABB and a sequence of polygons
~G4BoundingEnvelope();
~G4BoundingEnvelope() = default;
// Destructor
G4bool BoundingBoxVsVoxelLimits(const EAxis pAxis,
@@ -31,8 +31,8 @@
// Created: P.Arce, September 2004
// --------------------------------------------------------------------
#ifndef G4ErrorCylSurfaceTarget_hh
#define G4ErrorCylSurfaceTarget_hh
#ifndef G4ERRORCYLSURFACETARGET_HH
#define G4ERRORCYLSURFACETARGET_HH 1
#include "globals.hh"
#include "G4ErrorSurfaceTarget.hh"
@@ -43,7 +43,7 @@
class G4ErrorCylSurfaceTarget : public G4ErrorSurfaceTarget
{
public: // with description
public:
G4ErrorCylSurfaceTarget( const G4double& radius,
const G4ThreeVector& trans=G4ThreeVector(),
@@ -54,7 +54,7 @@ class G4ErrorCylSurfaceTarget : public G4ErrorSurfaceTarget
const G4AffineTransform& trans );
// Constructs cylindrical surface by radius and affine transformation
~G4ErrorCylSurfaceTarget();
~G4ErrorCylSurfaceTarget() = default;
virtual G4ThreeVector IntersectLocal( const G4ThreeVector& point,
const G4ThreeVector& direc ) const;
@@ -31,8 +31,8 @@
// Created: P.Arce, September 2004
// --------------------------------------------------------------------
#ifndef G4ErrorPlaneSurfaceTarget_hh
#define G4ErrorPlaneSurfaceTarget_hh
#ifndef G4ERRORPLANESURFACETARGET_HH
#define G4ERRORPLANESURFACETARGET_HH 1
#include "globals.hh"
#include "G4ErrorSurfaceTarget.hh"
@@ -41,7 +41,7 @@
class G4ErrorPlaneSurfaceTarget : public G4ErrorSurfaceTarget, G4Plane3D
{
public: // with description
public:
G4ErrorPlaneSurfaceTarget(G4double a=0., G4double b=0.,
G4double c=0., G4double d=0.);
@@ -56,7 +56,7 @@ class G4ErrorPlaneSurfaceTarget : public G4ErrorSurfaceTarget, G4Plane3D
const G4Point3D& p3);
// Constructs plane by three points
~G4ErrorPlaneSurfaceTarget();
~G4ErrorPlaneSurfaceTarget() = default;
virtual G4ThreeVector Intersect( const G4ThreeVector& point,
const G4ThreeVector& direc ) const;
@@ -74,7 +74,6 @@ class G4ErrorPlaneSurfaceTarget : public G4ErrorSurfaceTarget, G4Plane3D
virtual void Dump( const G4String& msg ) const;
// Dump plane surface parameter
};
#endif
@@ -31,9 +31,8 @@
// Created: P.Arce, September 2004
// --------------------------------------------------------------------
#ifndef G4ErrorSurfaceTarget_hh
#define G4ErrorSurfaceTarget_hh
#ifndef G4ERRORSURFACETARGET_HH
#define G4ERRORSURFACETARGET_HH 1
#include "globals.hh"
#include "G4ThreeVector.hh"
@@ -42,10 +41,10 @@
class G4ErrorSurfaceTarget : public G4ErrorTanPlaneTarget
{
public: // with description
public:
G4ErrorSurfaceTarget();
virtual ~G4ErrorSurfaceTarget();
virtual ~G4ErrorSurfaceTarget() = default;
virtual double GetDistanceFromPoint( const G4ThreeVector& point,
const G4ThreeVector& direc ) const = 0;
@@ -31,8 +31,8 @@
// Created: P.Arce, September 2004
// --------------------------------------------------------------------
#ifndef G4ErrorTanPlaneTarget_hh
#define G4ErrorTanPlaneTarget_hh
#ifndef G4ERRORTANPLANETARGET_HH
#define G4ERRORTANPLANETARGET_HH 1
#include "globals.hh"
#include "G4ThreeVector.hh"
@@ -42,17 +42,16 @@
class G4ErrorTanPlaneTarget : public G4ErrorTarget
{
public: // with description
public:
G4ErrorTanPlaneTarget();
virtual ~G4ErrorTanPlaneTarget();
virtual ~G4ErrorTanPlaneTarget() = default;
virtual G4Plane3D GetTangentPlane( const G4ThreeVector& point ) const = 0;
// Get tangent plane at point
virtual void Dump( const G4String& msg ) const = 0;
// Dump surface
};
#endif
@@ -31,8 +31,8 @@
// Created: P.Arce, September 2004
// --------------------------------------------------------------------
#ifndef G4ErrorTarget_hh
#define G4ErrorTarget_hh
#ifndef G4ERRORTARGET_HH
#define G4ERRORTARGET_HH 1
#include "globals.hh"
#include "G4ThreeVector.hh"
@@ -45,10 +45,10 @@ enum G4ErrorTargetType{ G4ErrorTarget_PlaneSurface,
G4ErrorTarget_TrkL };
class G4ErrorTarget
{
public: // with description
public:
G4ErrorTarget();
virtual ~G4ErrorTarget();
virtual ~G4ErrorTarget() = default;
virtual G4double GetDistanceFromPoint( const G4ThreeVector&,
const G4ThreeVector& ) const;
@@ -40,9 +40,10 @@
// 26.07.95, P.Kent - Initial version, including optimisation build
// --------------------------------------------------------------------
#ifndef G4GEOMETRYMANAGER_HH
#define G4GEOMETRYMANAGER_HH
#define G4GEOMETRYMANAGER_HH 1
#include <vector>
#include "G4Types.hh"
#include "G4SmartVoxelStat.hh"
@@ -50,7 +51,7 @@ class G4VPhysicalVolume;
class G4GeometryManager
{
public: // with description
public:
G4bool CloseGeometry(G4bool pOptimise = true, G4bool verbose = false,
G4VPhysicalVolume* vol = nullptr);
@@ -77,15 +78,15 @@ class G4GeometryManager
static G4GeometryManager* GetInstanceIfExist();
// Return ptr to singleton instance.
public: // without description
public:
~G4GeometryManager();
// Destructor.
protected:
G4GeometryManager();
// Protected constructor
G4GeometryManager() = default;
// Protected constructor. Set the geometry to be open
private:
@@ -37,8 +37,8 @@
// First version: Nov 19, 2002 - Jacek Generowicz
// ------------------------------------------------------------------------
#ifndef G4IdentityTrajectoryFilter_hh
#define G4IdentityTrajectoryFilter_hh
#ifndef G4IDENTITYTRAJECTORYFILTER_HH
#define G4IDENTITYTRAJECTORYFILTER_HH 1
#include "G4VCurvedTrajectoryFilter.hh"
#include "G4ThreeVector.hh"
@@ -46,10 +46,10 @@
class G4IdentityTrajectoryFilter : public G4VCurvedTrajectoryFilter
{
public: // with description
public:
G4IdentityTrajectoryFilter();
virtual ~G4IdentityTrajectoryFilter();
G4IdentityTrajectoryFilter() = default;
virtual ~G4IdentityTrajectoryFilter() = default;
G4IdentityTrajectoryFilter(const G4IdentityTrajectoryFilter&) = delete;
G4IdentityTrajectoryFilter& operator=(const G4IdentityTrajectoryFilter&) = delete;
@@ -60,4 +60,4 @@ class G4IdentityTrajectoryFilter : public G4VCurvedTrajectoryFilter
// to consider keeping or rejecting
};
#endif /* G4IdentityTrajectoryFilter_hh */
#endif
@@ -49,11 +49,11 @@
// G4SurfaceProperty* theSurfaceProperty
// G4TransitionRadiationSurface* theTransRadSurface
// Created: 1997, June, 4th to 17th
// Author: John Apostolakis, (with help of Peter Gumplinger)
// Created: 1997, June, 4th to 17th
// Author: John Apostolakis, (with help of Peter Gumplinger)
// ------------------------------------------------------------------------
#ifndef G4LogicalSurface_h
#define G4LogicalSurface_h 1
#ifndef G4LOGICALSURFACE_HH
#define G4LOGICALSURFACE_HH 1
#include "G4Types.hh"
#include "G4String.hh"
@@ -64,7 +64,7 @@ class G4TransitionRadiationSurface;
class G4LogicalSurface
{
public: // with description
public:
inline G4SurfaceProperty* GetSurfaceProperty() const;
inline void SetSurfaceProperty(G4SurfaceProperty* ptrSurfaceProperty);
@@ -75,9 +75,7 @@ class G4LogicalSurface
inline G4TransitionRadiationSurface* GetTransitionRadiationSurface() const;
inline void SetTransitionRadiationSurface(G4TransitionRadiationSurface* trs);
public: // without description
virtual ~G4LogicalSurface();
virtual ~G4LogicalSurface() = default;
G4LogicalSurface(const G4LogicalSurface&) = delete;
G4LogicalSurface& operator=(const G4LogicalSurface&) = delete;
@@ -102,4 +100,4 @@ class G4LogicalSurface
#include "G4LogicalSurface.icc"
#endif /* G4LogicalSurface_h */
#endif
@@ -98,12 +98,11 @@
// 18.04.01 G.Cosmo: Migrated to STL vector
// 12.02.99 S.Giani: Added user defined optimisation quality
// 09.11.98 M.Verderi, J.Apostolakis: Added BiasWeight member and accessors
// 10.20.97 P.M.DeFreitas: Added pointer to a FastSimulation
// J.Apostolakis: & flag to indicate if it is an Envelope for it
// 10.20.97 P.M.DeFreitas, J.Apostolakis: Added pointer to a FastSimulation
// 11.07.95 P.Kent: Initial version
// ------------------------------------------------------------------------
#ifndef G4LOGICALVOLUME_HH
#define G4LOGICALVOLUME_HH
#define G4LOGICALVOLUME_HH 1
#include <vector>
@@ -177,13 +176,11 @@ class G4LVData
// In addition, it invokes a method similiar to the constructor explicitly
// to achieve the partial effect for each instance in the array.
//
typedef G4GeomSplitter<G4LVData> G4LVManager;
using G4LVManager = G4GeomSplitter<G4LVData>;
class G4LogicalVolume
{
typedef std::vector<G4VPhysicalVolume*> G4PhysicalVolumeList;
public: // with description
public:
G4LogicalVolume(G4VSolid* pSolid,
G4Material* pMaterial,
@@ -339,7 +336,7 @@ class G4LogicalVolume
inline G4double GetBiasWeight() const;
// Sets and gets bias weight.
public: // without description
public:
G4LogicalVolume(__void__&);
// Fake default constructor for usage restricted to direct object
@@ -391,7 +388,8 @@ class G4LogicalVolume
// Returns: success (true) or failure (false).
private:
// Data members:
using G4PhysicalVolumeList = std::vector<G4VPhysicalVolume *>;
G4GEOM_DLL static G4LVManager subInstanceManager;
// This new field helps to use the class G4LVManager introduced above.
@@ -34,7 +34,7 @@
// 18.09.02, G.Cosmo - Initial version
// --------------------------------------------------------------------
#ifndef G4REGION_HH
#define G4REGION_HH
#define G4REGION_HH 1
#include <vector>
#include <map>
@@ -90,16 +90,11 @@ class G4RegionData
// In addition, it invokes a method similiar to the constructor explicitly
// to achieve the partial effect for each instance in the array.
//
typedef G4GeomSplitter<G4RegionData> G4RegionManager;
using G4RegionManager = G4GeomSplitter<G4RegionData>;
class G4Region
{
typedef std::vector<G4LogicalVolume*> G4RootLVList;
typedef std::vector<G4Material*> G4MaterialList;
typedef std::pair<G4Material*,G4MaterialCutsCouple*> G4MaterialCouplePair;
typedef std::map<G4Material*,G4MaterialCutsCouple*> G4MaterialCoupleMap;
public: // with description
public:
G4Region(const G4String& name);
virtual ~G4Region();
@@ -217,7 +212,7 @@ class G4Region
G4UserSteppingAction* GetRegionalSteppingAction() const;
// Set/Get method of the regional user stepping action
public: // without description
public:
G4Region(__void__&);
// Fake default constructor for usage restricted to direct object
@@ -248,6 +243,11 @@ class G4Region
private:
using G4RootLVList = std::vector<G4LogicalVolume*>;
using G4MaterialList = std::vector<G4Material*>;
using G4MaterialCouplePair = std::pair<G4Material*, G4MaterialCutsCouple*>;
using G4MaterialCoupleMap = std::map<G4Material*, G4MaterialCutsCouple*>;
G4String fName;
G4RootLVList fRootVolumes;
@@ -107,9 +107,7 @@ inline
std::vector<G4LogicalVolume*>::iterator
G4Region::GetRootLogicalVolumeIterator()
{
G4RootLVList::iterator iterator =
G4RootLVList::iterator(fRootVolumes.begin());
return iterator;
return G4RootLVList::iterator(fRootVolumes.begin());
}
// ********************************************************************
@@ -120,8 +118,7 @@ inline
std::vector<G4Material*>::const_iterator
G4Region::GetMaterialIterator() const
{
G4MaterialList::const_iterator iterator = fMaterials.cbegin();
return iterator;
return fMaterials.cbegin();
}
// ********************************************************************
@@ -78,7 +78,7 @@ class G4RegionStore : public std::vector<G4Region*>
// to FALSE. Used by the run manager to notify that the
// physics table has been updated.
void UpdateMaterialList(G4VPhysicalVolume* currentWorld=0);
void UpdateMaterialList(G4VPhysicalVolume* currentWorld=nullptr);
// Forces recomputation of material lists in all regions
// in the store.
@@ -50,7 +50,9 @@
// 13.07.95, P.Kent - Initial version
// --------------------------------------------------------------------
#ifndef G4SMARTVOXELHEADER_HH
#define G4SMARTVOXELHEADER_HH
#define G4SMARTVOXELHEADER_HH 1
#include <vector>
#include "G4Types.hh"
#include "geomdefs.hh"
@@ -58,8 +60,6 @@
#include "G4SmartVoxelProxy.hh"
#include "G4SmartVoxelNode.hh"
#include <vector>
// Forward declarations
class G4LogicalVolume;
class G4VoxelLimits;
@@ -73,7 +73,7 @@ using G4VolumeExtentVector = std::vector<G4double>;
class G4SmartVoxelHeader
{
public: // with description
public:
G4SmartVoxelHeader(G4LogicalVolume* pVolume, G4int pSlice = 0);
// Constructor for topmost header, to begin voxel construction at a
@@ -110,7 +110,7 @@ class G4SmartVoxelHeader
G4bool AllSlicesEqual() const;
// True if all slices equal (after collection).
public: // without description
public:
G4bool operator == (const G4SmartVoxelHeader& pHead) const;
@@ -45,16 +45,19 @@
// 12.07.95, P.Kent - Initial version
// --------------------------------------------------------------------
#ifndef G4SMARTVOXELNODE_HH
#define G4SMARTVOXELNODE_HH
#define G4SMARTVOXELNODE_HH 1
#include "G4Types.hh"
#include <vector>
#include "geomwdefs.hh"
#include "G4Types.hh"
#include "G4Allocator.hh"
using G4SliceVector = std::vector<G4int>;
class G4SmartVoxelNode
{
public: // with description
public:
G4SmartVoxelNode(G4int pSlice = 0) : fminEquivalent(pSlice),
fmaxEquivalent(pSlice) {}
@@ -62,7 +65,7 @@ class G4SmartVoxelNode
// This number is not stored, but used to provide defaults for the
// minimum and maximum equivalent node numbers.
~G4SmartVoxelNode();
~G4SmartVoxelNode() = default;
// Destructor. No actions.
inline G4int GetVolume(G4int pVolumeNo) const;
@@ -72,10 +75,10 @@ class G4SmartVoxelNode
inline void Insert(G4int pVolumeNo);
// Add the specified volume number to the contents.
inline size_t GetNoContained() const;
inline std::size_t GetNoContained() const;
// Return the number of volumes inside the node.
inline size_t GetCapacity() const;
inline std::size_t GetCapacity() const;
// Return the maximum capacity of the buffer.
inline void Reserve(G4int noSlices);
@@ -99,6 +102,11 @@ class G4SmartVoxelNode
G4bool operator == (const G4SmartVoxelNode& v) const;
// Equality operator.
inline void* operator new(std::size_t);
// Override "new" for "G4Allocator".
inline void operator delete(void* aNode);
// Override "delete" for "G4Allocator".
private:
G4int fminEquivalent;
@@ -27,60 +27,90 @@
//
// --------------------------------------------------------------------
extern G4GEOM_DLL G4Allocator<G4SmartVoxelNode>*& aNodeAllocator();
// --------------------------------------------------------------------
inline
void* G4SmartVoxelNode::operator new(std::size_t)
{
if(aNodeAllocator() == nullptr)
{
aNodeAllocator() = new G4Allocator<G4SmartVoxelNode>;
}
return (void*) aNodeAllocator()->MallocSingle();
}
// --------------------------------------------------------------------
inline
void G4SmartVoxelNode::operator delete(void* aNode)
{
aNodeAllocator()->FreeSingle((G4SmartVoxelNode*) aNode);
}
// --------------------------------------------------------------------
inline
G4int G4SmartVoxelNode::GetVolume(G4int pVolumeNo) const
{
return fcontents[pVolumeNo];
}
// --------------------------------------------------------------------
inline
void G4SmartVoxelNode::Insert(G4int pVolumeNo)
{
fcontents.push_back(pVolumeNo);
}
// --------------------------------------------------------------------
inline
size_t G4SmartVoxelNode::GetNoContained() const
std::size_t G4SmartVoxelNode::GetNoContained() const
{
return fcontents.size();
}
// --------------------------------------------------------------------
inline
size_t G4SmartVoxelNode::GetCapacity() const
std::size_t G4SmartVoxelNode::GetCapacity() const
{
return fcontents.capacity();
}
// --------------------------------------------------------------------
inline
void G4SmartVoxelNode::Reserve(G4int noSlices)
{
fcontents.reserve(noSlices);
}
// --------------------------------------------------------------------
inline
void G4SmartVoxelNode::Shrink()
{
G4SliceVector(fcontents).swap(fcontents);
}
// --------------------------------------------------------------------
inline
G4int G4SmartVoxelNode::GetMaxEquivalentSliceNo() const
{
return fmaxEquivalent;
}
// --------------------------------------------------------------------
inline
void G4SmartVoxelNode::SetMaxEquivalentSliceNo(G4int pMax)
{
fmaxEquivalent = pMax;
}
// --------------------------------------------------------------------
inline
G4int G4SmartVoxelNode::GetMinEquivalentSliceNo() const
{
return fminEquivalent;
}
// --------------------------------------------------------------------
inline
void G4SmartVoxelNode::SetMinEquivalentSliceNo(G4int pMin)
{
@@ -37,18 +37,21 @@
// 12.07.95, P.Kent - Initial version
// --------------------------------------------------------------------
#ifndef G4SMARTVOXELPROXY_HH
#define G4SMARTVOXELPROXY_HH
#define G4SMARTVOXELPROXY_HH 1
#include "G4Types.hh"
#include <assert.h>
#include "geomwdefs.hh"
#include "G4Types.hh"
#include "G4Allocator.hh"
class G4SmartVoxelNode;
class G4SmartVoxelHeader;
class G4SmartVoxelProxy
{
public: // with description
public:
G4SmartVoxelProxy(G4SmartVoxelHeader *pHeader)
: fHeader(pHeader) {}
@@ -58,7 +61,7 @@ class G4SmartVoxelProxy
: fNode(pNode) {}
// Proxy for the specified node.
~G4SmartVoxelProxy();
~G4SmartVoxelProxy() = default;
// Destructor - do nothing. Not responsible for proxied objects.
G4bool IsHeader() const;
@@ -77,6 +80,11 @@ class G4SmartVoxelProxy
// Equality operator.
// True when objects share same address.
inline void* operator new(std::size_t);
// Override "new" for "G4Allocator".
inline void operator delete(void* aProxy);
// Override "delete" for "G4Allocator".
private:
G4SmartVoxelHeader* fHeader = nullptr;
@@ -27,18 +27,41 @@
//
// --------------------------------------------------------------------
extern G4GEOM_DLL G4Allocator<G4SmartVoxelProxy>*& aProxyAllocator();
// --------------------------------------------------------------------
inline
void* G4SmartVoxelProxy::operator new(std::size_t)
{
if(aProxyAllocator() == nullptr)
{
aProxyAllocator() = new G4Allocator<G4SmartVoxelProxy>;
}
return (void*) aProxyAllocator()->MallocSingle();
}
// --------------------------------------------------------------------
inline
void G4SmartVoxelProxy::operator delete(void* aProxy)
{
aProxyAllocator()->FreeSingle((G4SmartVoxelProxy*) aProxy);
}
// --------------------------------------------------------------------
inline
G4bool G4SmartVoxelProxy::IsHeader() const
{
return (fHeader) ? true : false;
}
// --------------------------------------------------------------------
inline
G4bool G4SmartVoxelProxy::IsNode() const
{
return (fNode) ? true : false;
}
// --------------------------------------------------------------------
inline
G4SmartVoxelNode* G4SmartVoxelProxy::GetNode() const
{
@@ -46,6 +69,7 @@ G4SmartVoxelNode* G4SmartVoxelProxy::GetNode() const
return fNode;
}
// --------------------------------------------------------------------
inline
G4SmartVoxelHeader* G4SmartVoxelProxy::GetHeader() const
{
@@ -53,6 +77,7 @@ G4SmartVoxelHeader* G4SmartVoxelProxy::GetHeader() const
return fHeader;
}
// --------------------------------------------------------------------
inline
G4bool G4SmartVoxelProxy::operator == (const G4SmartVoxelProxy& right) const
{
@@ -189,10 +189,6 @@ class G4UAdapter : public G4VSolid, protected UnplacedVolume_t
// Smart access function - creates on request and stores for future
// access. A null pointer means "not available".
inline friend std::ostream& operator<< ( std::ostream& os, const G4UAdapter<UnplacedVolume_t>& uad )
{ const UnplacedVolume_t& origUnplaced = uad; return operator<< ( os, origUnplaced ); }
// Streaming operator, forward to VecGeom method
public: // without description
G4UAdapter(__void__&);
@@ -423,6 +419,14 @@ namespace
G4Mutex pMutex = G4MUTEX_INITIALIZER;
}
// Free function to enable ostream output
template <class UnplacedVolume_t>
std::ostream&
operator<<(std::ostream& os, const G4UAdapter<UnplacedVolume_t>& uAdapted)
{
return uAdapted.StreamInfo(os);
}
template <class UnplacedVolume_t>
void G4UAdapter<UnplacedVolume_t>::
ComputeDimensions(G4VPVParameterisation*, const G4int,
@@ -41,8 +41,8 @@
// First version: Oct 30, 2002 - Jacek Generowicz
// ------------------------------------------------------------------------
#ifndef G4VCurvedTrajectoryFilter_hh
#define G4VCurvedTrajectoryFilter_hh
#ifndef G4VCURVEDTRAJECTORYFILTER_HH
#define G4VCURVEDTRAJECTORYFILTER_HH 1
#include "G4ThreeVector.hh"
#include <vector>
@@ -50,27 +50,27 @@
class G4VCurvedTrajectoryFilter
{
public: // with description
public:
G4VCurvedTrajectoryFilter();
virtual ~G4VCurvedTrajectoryFilter();
G4VCurvedTrajectoryFilter() = default;
virtual ~G4VCurvedTrajectoryFilter() = default;
// Probably do not want these objects to be copied,
// so make the copy constructor private
// Probably do not want these objects to be copied,
// so make the copy constructor private
void CreateNewTrajectorySegment();
// Each segment stores the auxiliary points of a single step.
void CreateNewTrajectorySegment();
// Each segment stores the auxiliary points of a single step.
virtual void TakeIntermediatePoint( G4ThreeVector newPoint ) = 0;
// Submit intermediate points for the filter to consider keeping or
// rejecting. Derived classes should implement the filtering algorithm
// in this method.
virtual void TakeIntermediatePoint( G4ThreeVector newPoint ) = 0;
// Submit intermediate points for the filter to consider keeping or
// rejecting. Derived classes should implement the filtering algorithm
// in this method.
std::vector<G4ThreeVector>* GimmeThePointsAndForgetThem();
std::vector<G4ThreeVector>* GimmeThePointsAndForgetThem();
protected:
protected:
std::vector<G4ThreeVector>* fpFilteredPoints = nullptr;
std::vector<G4ThreeVector>* fpFilteredPoints = nullptr;
};
#endif /* G4VCurvedTrajectoryFilter_hh */
#endif
@@ -45,7 +45,7 @@
// 24.02.05, J.Apostolakis - First created version.
// --------------------------------------------------------------------
#ifndef G4VNESTEDPARAMETERISATION_HH
#define G4VNESTEDPARAMETERISATION_HH
#define G4VNESTEDPARAMETERISATION_HH 1
#include "G4Types.hh"
#include "G4VPVParameterisation.hh"
@@ -72,13 +72,13 @@ class G4Polycone;
class G4Polyhedra;
class G4Hype;
class G4VNestedParameterisation: public G4VPVParameterisation,
public G4VVolumeMaterialScanner
class G4VNestedParameterisation : public G4VPVParameterisation,
public G4VVolumeMaterialScanner
{
public: // with description
public:
G4VNestedParameterisation();
virtual ~G4VNestedParameterisation();
G4VNestedParameterisation() = default;
virtual ~G4VNestedParameterisation() = default;
// Methods required in derived classes
// -----------------------------------
@@ -32,8 +32,8 @@
// Author: Ivana Hrivnacova, 4.5.2004
// ------------------------------------------------------------------------
#ifndef G4VPVDIVISION_FACTORY_HH
#define G4VPVDIVISION_FACTORY_HH
#ifndef G4VPVDIVISIONFACTORY_HH
#define G4VPVDIVISIONFACTORY_HH 1
#include "geomdefs.hh"
@@ -43,9 +43,9 @@ class G4VPVParameterisation;
class G4VPVDivisionFactory
{
public: // with description
public:
virtual ~G4VPVDivisionFactory();
virtual ~G4VPVDivisionFactory() = default;
static G4VPVDivisionFactory* Instance();
@@ -89,12 +89,11 @@ class G4VPVDivisionFactory
protected:
G4VPVDivisionFactory();
G4VPVDivisionFactory() = default;
protected:
static G4ThreadLocal G4VPVDivisionFactory* fgInstance;
static G4ThreadLocal G4VPVDivisionFactory* fgInstance;
};
#endif
@@ -37,7 +37,7 @@
// 17.02.98, J.Apostolakis - Allowing the parameterisation of solid type
// --------------------------------------------------------------------
#ifndef G4VPVPARAMETERISATION_HH
#define G4VPVPARAMETERISATION_HH
#define G4VPVPARAMETERISATION_HH 1
#include "G4Types.hh"
#include "G4VVolumeMaterialScanner.hh"
@@ -69,10 +69,8 @@ class G4VPVParameterisation
{
public:
G4VPVParameterisation();
virtual ~G4VPVParameterisation();
public: // with description
G4VPVParameterisation() = default;
virtual ~G4VPVParameterisation() = default;
virtual void ComputeTransformation(const G4int,
G4VPhysicalVolume * ) const = 0;
@@ -38,7 +38,7 @@
// 24.07.95, P.Kent: First non-stub version
// --------------------------------------------------------------------
#ifndef G4VPHYSICALVOLUME_HH
#define G4VPHYSICALVOLUME_HH
#define G4VPHYSICALVOLUME_HH 1
#include "G4Types.hh"
#include "G4String.hh"
@@ -60,7 +60,7 @@ class G4PVData
public:
G4PVData() {}
G4PVData() = default;
void initialize()
{
@@ -72,12 +72,12 @@ class G4PVData
G4double tx = 0., ty = 0., tz = 0.;
};
typedef G4GeomSplitter<G4PVData> G4PVManager;
using G4PVManager = G4GeomSplitter<G4PVData>;
// Implementation detail for use of G4PVData objects
class G4VPhysicalVolume
{
public: // with description
public:
G4VPhysicalVolume(G4RotationMatrix* pRot,
const G4ThreeVector& tlate,
@@ -198,7 +198,7 @@ class G4VPhysicalVolume
// Concrete implementation is done and required only for placed and
// parameterised volumes. Returns true if the volume is overlapping.
public: // without description
public:
G4VPhysicalVolume(__void__&);
// Fake default constructor for usage restricted to direct object
@@ -266,7 +266,6 @@ class G4VPhysicalVolume
// it copies the array of G4PVData instances from the master thread.
// In addition, it invokes a method similiar to the constructor explicitly
// to achieve the partial effect for each instance in the array.
//
#include "G4VPhysicalVolume.icc"
+16 -16
View File
@@ -38,10 +38,10 @@
// surface normal of the shape at a given point, and to compute
// the extent of the shape. [see descriptions below]
//
// Some protected/private utility functions are implemented for the
// Some protected/private utility functions are implemented for the
// clipping of regions for the computation of a solid's extent. Note that
// the clipping mechanism is presently inefficient.
//
//
// Some visualization/graphics functions are also defined.
//
// Member Data:
@@ -52,11 +52,11 @@
// 12.04.00 J.Allison Implemented GetExtent() in terms of CalculateExtent()
// 17.06.98 J.Apostolakis Added pure virtual function GetEntityType()
// 26.07.96 P.Kent Added ComputeDimensions() for replication mechanism
// 27.03.96 J.Allison Methods for visualisation
// 27.03.96 J.Allison Methods for visualisation
// 30.06.95 P.Kent Initial version, no scoping or visualisation functions
// --------------------------------------------------------------------
#ifndef G4VSOLID_HH
#define G4VSOLID_HH
#define G4VSOLID_HH 1
#include "G4Types.hh"
#include "G4String.hh"
@@ -81,7 +81,7 @@ using G4GeometryType = G4String;
class G4VSolid
{
public: // with description
public: // with description
G4VSolid(const G4String& name);
// Creates a new shape, with the supplied name. No provision is made
@@ -89,12 +89,9 @@ class G4VSolid
virtual ~G4VSolid();
// Default destructor.
inline G4bool operator==( const G4VSolid& s ) const;
inline G4bool operator==(const G4VSolid& s) const;
// Return true only if addresses are the same.
friend std::ostream& operator<< ( std::ostream& os, const G4VSolid& e );
// Streaming operator, using DumpInfo().
inline G4String GetName() const;
// Returns the current shape's name.
void SetName(const G4String& name);
@@ -218,8 +215,8 @@ class G4VSolid
// If the solid is made up from a Boolean operation of two solids,
// return the "no" solid. If the solid is not a "Boolean", return 0.
virtual const G4DisplacedSolid* GetDisplacedSolidPtr() const;
virtual G4DisplacedSolid* GetDisplacedSolidPtr();
virtual const G4DisplacedSolid* GetDisplacedSolidPtr() const;
virtual G4DisplacedSolid* GetDisplacedSolidPtr();
// If the solid is a "G4DisplacedSolid", return a self pointer
// else return 0.
@@ -231,7 +228,7 @@ class G4VSolid
// persistifiable objects.
G4VSolid(const G4VSolid& rhs);
G4VSolid& operator=(const G4VSolid& rhs);
G4VSolid& operator=(const G4VSolid& rhs);
// Copy constructor and assignment operator.
G4double EstimateCubicVolume(G4int nStat, G4double epsilon) const;
@@ -248,7 +245,7 @@ class G4VSolid
void CalculateClippedPolygonExtent(G4ThreeVectorList& pPolygon,
const G4VoxelLimits& pVoxelLimit,
const EAxis pAxis,
const EAxis pAxis,
G4double& pMin, G4double& pMax) const;
// Calculate the maximum and minimum extents of the convex polygon
// pPolygon along the axis pAxis, within the limits pVoxelLimit.
@@ -261,7 +258,7 @@ class G4VSolid
void ClipCrossSection(G4ThreeVectorList* pVertices,
const G4int pSectionIndex,
const G4VoxelLimits& pVoxelLimit,
const EAxis pAxis,
const EAxis pAxis,
G4double& pMin, G4double& pMax) const;
// Calculate the maximum and minimum extents of the polygon described
// by the vertices: pSectionIndex->pSectionIndex+1->
@@ -276,7 +273,7 @@ class G4VSolid
void ClipBetweenSections(G4ThreeVectorList* pVertices,
const G4int pSectionIndex,
const G4VoxelLimits& pVoxelLimit,
const EAxis pAxis,
const EAxis pAxis,
G4double& pMin, G4double& pMax) const;
// Calculate the maximum and minimum extents of the polygons
// joining the CrossSections at pSectionIndex->pSectionIndex+3 and
@@ -294,7 +291,7 @@ class G4VSolid
const EAxis pAxis ) const;
// Clip the specified convex polygon to the given limits, where
// the polygon is described by the vertices at (0),(1),...,(n),(0) in
// pPolygon.
// pPolygon.
// If the polygon is completely clipped away, the polygon is cleared.
protected:
@@ -315,6 +312,9 @@ class G4VSolid
G4String fshapeName; // Name
};
/// Output solid information to given ostream
std::ostream& operator<<(std::ostream& os, const G4VSolid& e);
#include "G4VSolid.icc"
#endif
@@ -88,7 +88,7 @@
// Created: Paul Kent, August 1996
// --------------------------------------------------------------------
#ifndef G4VTOUCHABLE_HH
#define G4VTOUCHABLE_HH
#define G4VTOUCHABLE_HH 1
#include "G4Types.hh"
@@ -102,10 +102,10 @@ class G4NavigationHistory;
class G4VTouchable
{
public: // with description
public:
G4VTouchable();
virtual ~G4VTouchable();
G4VTouchable() = default;
virtual ~G4VTouchable() = default;
// Constructor and destructor.
virtual const G4ThreeVector& GetTranslation(G4int depth=0) const = 0;
@@ -125,12 +125,8 @@ class G4VTouchable
const G4NavigationHistory* history = nullptr);
// Update method.
public: // without description
// virtual void ResetLevel();
virtual const G4NavigationHistory* GetHistory() const;
// Should this method be deprecated ? It is used in G4Navigator!
// Method used in G4Navigator.
};
#include "G4VTouchable.icc"
@@ -37,15 +37,15 @@
// 21/10/2003 - M.Asai, Created.
// --------------------------------------------------------------------
#ifndef G4VUserRegionInformation_HH
#define G4VUserRegionInformation_HH 1
#ifndef G4VUSERREGIONINFORMATION_HH
#define G4VUSERREGIONINFORMATION_HH 1
class G4VUserRegionInformation
{
public: // with description
public:
G4VUserRegionInformation() {}
virtual ~G4VUserRegionInformation() {}
G4VUserRegionInformation() = default;
virtual ~G4VUserRegionInformation() = default;
virtual void Print() const = 0;
};
@@ -40,7 +40,7 @@
// 13.07.95, P.Kent - Initial version.
// --------------------------------------------------------------------
#ifndef G4VOXELLIMITS_HH
#define G4VOXELLIMITS_HH
#define G4VOXELLIMITS_HH 1
#include "G4Types.hh"
#include "geomdefs.hh"
@@ -51,12 +51,12 @@
class G4VoxelLimits
{
public: // with description
public:
G4VoxelLimits();
G4VoxelLimits() = default;
// Constructor - initialise to be unlimited. Volume unrestricted.
~G4VoxelLimits();
~G4VoxelLimits() = default;
// Destructor. No actions.
void AddLimit(const EAxis pAxis, const G4double pMin, const G4double pMax);
@@ -34,12 +34,6 @@ G4BlockingList::G4BlockingList(G4int maxDefault, G4int stride)
{
}
// Do nothing destructor
//
G4BlockingList::~G4BlockingList()
{
}
// Clear List and reset tag
//
void G4BlockingList::FullyReset()
@@ -29,8 +29,8 @@
// --------------------------------------------------------------------
#include <cmath>
#include "globals.hh"
#include "globals.hh"
#include "G4BoundingEnvelope.hh"
#include "G4GeometryTolerance.hh"
@@ -105,14 +105,6 @@ G4BoundingEnvelope( const G4ThreeVector& pMin,
CheckBoundingPolygons();
}
///////////////////////////////////////////////////////////////////////
//
// Destructor
//
G4BoundingEnvelope::~G4BoundingEnvelope()
{
}
///////////////////////////////////////////////////////////////////////
//
// Check correctness of the axis aligned bounding box
@@ -428,7 +420,7 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
// Allocate memory for transformed polygons
//
G4int nbases = (fPolygons == 0) ? 2 : fPolygons->size();
G4int nbases = (fPolygons == nullptr) ? 2 : fPolygons->size();
std::vector<G4Polygon3D*> bases(nbases);
if (fPolygons == nullptr)
{
@@ -539,7 +531,7 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
// Free memory
//
for (G4int i=0; i<nbases; ++i) { delete bases[i]; bases[i] = 0; }
for (G4int i=0; i<nbases; ++i) { delete bases[i]; bases[i] = nullptr; }
// Final adjustment of the extent
//
@@ -609,27 +601,27 @@ G4BoundingEnvelope::TransformVertices(const G4Transform3D& pTransform3D,
baseB[3].set(fMin.x(),fMax.y(),fMax.z());
}
std::vector<const G4ThreeVectorList*>::const_iterator ia, iaend;
std::vector<G4Polygon3D*>::iterator ib = pBases.begin();
ia = (fPolygons == 0) ? aabb.begin() : fPolygons->begin();
iaend = (fPolygons == 0) ? aabb.end() : fPolygons->end();
auto ib = pBases.begin();
ia = (fPolygons == nullptr) ? aabb.cbegin() : fPolygons->cbegin();
iaend = (fPolygons == nullptr) ? aabb.cend() : fPolygons->cend();
if (pTransform3D.xx()==1 && pTransform3D.yy()==1 && pTransform3D.zz()==1)
{
G4ThreeVector offset = pTransform3D.getTranslation();
for ( ; ia != iaend; ++ia, ++ib)
{
G4ThreeVectorList::const_iterator ka = (*ia)->begin();
G4Polygon3D::iterator kb = (*ib)->begin();
for ( ; ka != (*ia)->end(); ++ka, ++kb) { (*kb) = (*ka) + offset; }
auto ka = (*ia)->cbegin();
auto kb = (*ib)->begin();
for ( ; ka != (*ia)->cend(); ++ka, ++kb) { (*kb) = (*ka) + offset; }
}
}
else
{
for ( ; ia != iaend; ++ia, ++ib)
{
G4ThreeVectorList::const_iterator ka = (*ia)->begin();
G4Polygon3D::iterator kb = (*ib)->begin();
for ( ; ka != (*ia)->end(); ++ka, ++kb)
auto ka = (*ia)->cbegin();
auto kb = (*ib)->begin();
for ( ; ka != (*ia)->cend(); ++ka, ++kb)
{
(*kb) = pTransform3D*G4Point3D(*ka);
}
@@ -76,12 +76,6 @@ G4ErrorCylSurfaceTarget( const G4double& radius,
//---------------------------------------------------------------------
G4ErrorCylSurfaceTarget::~G4ErrorCylSurfaceTarget()
{
}
//---------------------------------------------------------------------
G4double G4ErrorCylSurfaceTarget::
GetDistanceFromPoint( const G4ThreeVector& point,
const G4ThreeVector& dir ) const
@@ -89,12 +89,6 @@ G4ErrorPlaneSurfaceTarget(const G4Point3D &p1,
//---------------------------------------------------------------------
G4ErrorPlaneSurfaceTarget::~G4ErrorPlaneSurfaceTarget()
{
}
//---------------------------------------------------------------------
G4ThreeVector G4ErrorPlaneSurfaceTarget::
Intersect( const G4ThreeVector& pt, const G4ThreeVector& dir ) const
{
@@ -30,5 +30,4 @@
#include "G4ErrorSurfaceTarget.hh"
G4ErrorSurfaceTarget::G4ErrorSurfaceTarget(){}
G4ErrorSurfaceTarget::~G4ErrorSurfaceTarget(){}
G4ErrorSurfaceTarget::G4ErrorSurfaceTarget() = default;
@@ -30,5 +30,4 @@
#include "G4ErrorTanPlaneTarget.hh"
G4ErrorTanPlaneTarget::G4ErrorTanPlaneTarget(){}
G4ErrorTanPlaneTarget::~G4ErrorTanPlaneTarget(){}
G4ErrorTanPlaneTarget::G4ErrorTanPlaneTarget() = default;
@@ -32,8 +32,6 @@
G4ErrorTarget::G4ErrorTarget() : theType(G4ErrorTarget_GeomVolume) {}
G4ErrorTarget::~G4ErrorTarget() {}
G4double G4ErrorTarget::GetDistanceFromPoint( const G4ThreeVector&,
const G4ThreeVector& ) const
{
@@ -29,6 +29,7 @@
// --------------------------------------------------------------------
#include <iomanip>
#include "G4Timer.hh"
#include "G4GeometryManager.hh"
#include "G4SystemOfUnits.hh"
@@ -57,14 +58,6 @@
G4ThreadLocal G4GeometryManager* G4GeometryManager::fgInstance = nullptr;
G4ThreadLocal G4bool G4GeometryManager::fIsClosed = false;
// ***************************************************************************
// Constructor. Set the geometry to be open
// ***************************************************************************
//
G4GeometryManager::G4GeometryManager()
{
}
// ***************************************************************************
// Destructor
// ***************************************************************************
@@ -179,7 +172,7 @@ void G4GeometryManager::BuildOptimisations(G4bool allOpts, G4bool verbose)
//
head = volume->GetVoxelHeader();
delete head;
volume->SetVoxelHeader(0);
volume->SetVoxelHeader(nullptr);
if ( ( (volume->IsToOptimise())
&& (volume->GetNoDaughters()>=kMinVoxelVolumesLevel1&&allOpts) )
|| ( (volume->GetNoDaughters()==1)
@@ -30,14 +30,6 @@
#include "G4IdentityTrajectoryFilter.hh"
G4IdentityTrajectoryFilter::G4IdentityTrajectoryFilter()
{
}
G4IdentityTrajectoryFilter::~G4IdentityTrajectoryFilter()
{
}
void
G4IdentityTrajectoryFilter::TakeIntermediatePoint( G4ThreeVector newPoint )
{
@@ -35,7 +35,3 @@ G4LogicalSurface::G4LogicalSurface(const G4String& name,
: theName(name), theSurfaceProperty(surfaceProperty)
{
}
G4LogicalSurface::~G4LogicalSurface()
{
}
+1 -1
View File
@@ -398,7 +398,7 @@ void G4Region::UpdateMaterialList()
void G4Region::SetWorld(G4VPhysicalVolume* wp)
{
if(!wp)
{ fWorldPhys = 0; }
{ fWorldPhys = nullptr; }
else
{ if(BelongsTo(wp)) fWorldPhys = wp; }
@@ -63,7 +63,6 @@ G4SmartVoxelHeader::G4SmartVoxelHeader(G4LogicalVolume* pVolume,
fparamAxis(kUndefined)
{
size_t nDaughters = pVolume->GetNoDaughters();
G4VoxelLimits limits; // Create `unlimited' limits object
// Determine whether daughter is replicated
//
@@ -955,7 +954,7 @@ G4ProxyVector* G4SmartVoxelHeader::BuildNodes(G4LogicalVolume* pVolume,
// Create G4VoxelNodes. Will Add proxies before setting fslices
//
G4NodeVector* nodeList = new G4NodeVector();
auto* nodeList = new G4NodeVector();
if (nodeList == nullptr)
{
G4Exception("G4SmartVoxelHeader::BuildNodes()", "GeomMgt0003",
@@ -1017,7 +1016,7 @@ G4ProxyVector* G4SmartVoxelHeader::BuildNodes(G4LogicalVolume* pVolume,
// Create proxy List : caller has deletion responsibility
// (but we must delete nodeList *itself* - not the contents)
//
G4ProxyVector* proxyList = new G4ProxyVector();
auto* proxyList = new G4ProxyVector();
if (proxyList == nullptr)
{
G4Exception("G4SmartVoxelHeader::BuildNodes()", "GeomMgt0003",
@@ -1034,7 +1033,7 @@ G4ProxyVector* G4SmartVoxelHeader::BuildNodes(G4LogicalVolume* pVolume,
// Get rid of possible excess capacity in the internal node vector
//
((*nodeList)[nNode])->Shrink();
G4SmartVoxelProxy* pProxyNode = new G4SmartVoxelProxy((*nodeList)[nNode]);
auto* pProxyNode = new G4SmartVoxelProxy((*nodeList)[nNode]);
if (pProxyNode == nullptr)
{
G4Exception("G4SmartVoxelHeader::BuildNodes()", "GeomMgt0003",
@@ -1214,7 +1213,7 @@ void G4SmartVoxelHeader::RefineNodes(G4LogicalVolume* pVolume,
// Delete node proxies at start of collected sets of nodes/headers
//
lastProxy=0;
lastProxy=nullptr;
for (replaceNo=minNo; replaceNo<=maxNo; ++replaceNo)
{
if (lastProxy != fslices[replaceNo])
@@ -1341,7 +1340,7 @@ std::ostream& operator << (std::ostream& os, const G4SmartVoxelHeader& h)
if (haveHeaders)
{
collectHead=0;
collectHead=nullptr;
for (j=0; j<h.fslices.size(); ++j)
{
if (h.fslices[j]->IsHeader())
@@ -31,23 +31,26 @@
#include "G4SmartVoxelNode.hh"
// Empty destructor
//
G4SmartVoxelNode::~G4SmartVoxelNode()
// --------------------------------------------------------------------
G4Allocator<G4SmartVoxelNode>*& aNodeAllocator()
{
G4ThreadLocalStatic G4Allocator<G4SmartVoxelNode>* _instance = nullptr;
return _instance;
}
// --------------------------------------------------------------------
// Return true if contents equal
//
// Preconditions:
//
// Node contents were entered in the same order
//
G4bool G4SmartVoxelNode::operator == (const G4SmartVoxelNode& v) const
{
size_t maxNode = GetNoContained();
std::size_t maxNode = GetNoContained();
if (maxNode == v.GetNoContained())
{
for (size_t node=0; node<maxNode; ++node)
for (std::size_t node=0; node<maxNode; ++node)
{
if (GetVolume(node) != v.GetVolume(node))
{
@@ -30,8 +30,9 @@
#include "G4SmartVoxelProxy.hh"
// Empty destructor
//
G4SmartVoxelProxy::~G4SmartVoxelProxy()
// --------------------------------------------------------------------
G4Allocator<G4SmartVoxelProxy>*& aProxyAllocator()
{
G4ThreadLocalStatic G4Allocator<G4SmartVoxelProxy>* _instance = nullptr;
return _instance;
}
@@ -30,14 +30,6 @@
#include "G4VCurvedTrajectoryFilter.hh"
G4VCurvedTrajectoryFilter::G4VCurvedTrajectoryFilter()
{
}
G4VCurvedTrajectoryFilter::~G4VCurvedTrajectoryFilter()
{
}
std::vector<G4ThreeVector>*
G4VCurvedTrajectoryFilter::GimmeThePointsAndForgetThem()
{
@@ -55,7 +47,7 @@ G4VCurvedTrajectoryFilter::GimmeThePointsAndForgetThem()
}
void
G4VCurvedTrajectoryFilter::CreateNewTrajectorySegment( )
G4VCurvedTrajectoryFilter::CreateNewTrajectorySegment()
{
if (fpFilteredPoints != nullptr)
{
@@ -34,32 +34,26 @@
#include "G4LogicalVolume.hh"
#include "G4VTouchable.hh"
G4VNestedParameterisation::G4VNestedParameterisation()
: G4VPVParameterisation(),
G4VVolumeMaterialScanner()
{
}
G4VNestedParameterisation::~G4VNestedParameterisation()
{
}
// --------------------------------------------------------------------
G4VSolid* G4VNestedParameterisation::ComputeSolid(const G4int,
G4VPhysicalVolume* pvol)
{
return pvol->GetLogicalVolume()->GetSolid();
}
// --------------------------------------------------------------------
G4bool G4VNestedParameterisation::IsNested() const
{
return true;
}
// --------------------------------------------------------------------
G4VVolumeMaterialScanner* G4VNestedParameterisation::GetMaterialScanner()
{
return this;
}
// --------------------------------------------------------------------
G4Material*
G4VNestedParameterisation::ComputeMaterial(const G4int repNo,
G4VPhysicalVolume* currentVol,
@@ -40,19 +40,3 @@ G4VPVDivisionFactory* G4VPVDivisionFactory::Instance()
// ---
return fgInstance;
}
//_____________________________________________________________________________
G4VPVDivisionFactory::G4VPVDivisionFactory()
{
// Protected singleton constructor.
// ---
// fgInstance = this;
}
//_____________________________________________________________________________
G4VPVDivisionFactory::~G4VPVDivisionFactory()
{
}
@@ -34,14 +34,7 @@
#include "G4LogicalVolume.hh"
#include "G4VVolumeMaterialScanner.hh"
G4VPVParameterisation::G4VPVParameterisation()
{
}
G4VPVParameterisation::~G4VPVParameterisation()
{
}
// --------------------------------------------------------------------
G4VSolid*
G4VPVParameterisation::ComputeSolid(const G4int,
G4VPhysicalVolume* pPhysicalVol)
@@ -49,6 +42,7 @@ G4VPVParameterisation::ComputeSolid(const G4int,
return pPhysicalVol->GetLogicalVolume()->GetSolid();
}
// --------------------------------------------------------------------
G4Material*
G4VPVParameterisation::ComputeMaterial(const G4int,
G4VPhysicalVolume* pPhysicalVol,
@@ -57,15 +51,15 @@ G4VPVParameterisation::ComputeMaterial(const G4int,
return pPhysicalVol->GetLogicalVolume()->GetMaterial();
}
// --------------------------------------------------------------------
G4bool G4VPVParameterisation::IsNested() const
{
return false;
}
// --------------------------------------------------------------------
G4VVolumeMaterialScanner*
G4VPVParameterisation::GetMaterialScanner()
{
return nullptr;
}
// These enable material scan for nested parameterisations
+37 -35
View File
@@ -39,6 +39,15 @@
#include "G4AffineTransform.hh"
#include "G4VisExtent.hh"
//////////////////////////////////////////////////////////////////////////
//
// Streaming operator dumping solid contents
std::ostream& operator<< ( std::ostream& os, const G4VSolid& e )
{
return e.StreamInfo(os);
}
//////////////////////////////////////////////////////////////////////////
//
// Constructor
@@ -95,7 +104,7 @@ G4VSolid::~G4VSolid()
//
// Assignment operator
G4VSolid& G4VSolid::operator = (const G4VSolid& rhs)
G4VSolid& G4VSolid::operator = (const G4VSolid& rhs)
{
// Check assignment to self
//
@@ -107,17 +116,10 @@ G4VSolid& G4VSolid::operator = (const G4VSolid& rhs)
fshapeName = rhs.fshapeName;
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Streaming operator dumping solid contents
std::ostream& operator<< ( std::ostream& os, const G4VSolid& e )
{
return e.StreamInfo(os);
}
//////////////////////////////////////////////////////////////////////////
//
// Set solid name and notify store of the change
@@ -126,7 +128,7 @@ void G4VSolid::SetName(const G4String& name)
{
fshapeName = name;
G4SolidStore::GetInstance()->SetMapValid(false);
}
}
//////////////////////////////////////////////////////////////////////////
//
@@ -163,16 +165,16 @@ G4ThreeVector G4VSolid::GetPointOnSurface() const
// Dummy implementations ...
const G4VSolid* G4VSolid::GetConstituentSolid(G4int) const
{ return nullptr; }
{ return nullptr; }
G4VSolid* G4VSolid::GetConstituentSolid(G4int)
{ return nullptr; }
{ return nullptr; }
const G4DisplacedSolid* G4VSolid::GetDisplacedSolidPtr() const
{ return nullptr; }
{ return nullptr; }
G4DisplacedSolid* G4VSolid::GetDisplacedSolidPtr()
{ return nullptr; }
G4DisplacedSolid* G4VSolid::GetDisplacedSolidPtr()
{ return nullptr; }
////////////////////////////////////////////////////////////////
//
@@ -229,7 +231,7 @@ G4double G4VSolid::EstimateCubicVolume(G4int nStat, G4double epsilon) const
pz = minZ-halfepsilon+(maxZ-minZ+epsilon)*G4QuickRand();
p = G4ThreeVector(px,py,pz);
in = Inside(p);
if(in != kOutside) ++iInside;
if(in != kOutside) ++iInside;
}
volume = (maxX-minX+epsilon)*(maxY-minY+epsilon)
* (maxZ-minZ+epsilon)*iInside/nStat;
@@ -313,7 +315,7 @@ G4double G4VSolid::EstimateSurfaceArea(G4int nstat, G4double ell) const
G4double dX = bmax.x() - bmin.x();
G4double dY = bmax.y() - bmin.y();
G4double dZ = bmax.z() - bmin.z();
// Define statistics and shell thickness
//
G4int npoints = (nstat < 1000) ? 1000 : nstat;
@@ -380,7 +382,7 @@ G4double G4VSolid::EstimateSurfaceArea(G4int nstat, G4double ell) const
}
///////////////////////////////////////////////////////////////////////////
//
//
// Returns a pointer of a dynamically allocated copy of the solid.
// Returns NULL pointer with warning in case the concrete solid does not
// implement this method. The caller has responsibility for ownership.
@@ -397,7 +399,7 @@ G4VSolid* G4VSolid::Clone() const
}
///////////////////////////////////////////////////////////////////////////
//
//
// Calculate the maximum and minimum extents of the polygon described
// by the vertices: pSectionIndex->pSectionIndex+1->
// pSectionIndex+2->pSectionIndex+3->pSectionIndex
@@ -412,7 +414,7 @@ G4VSolid* G4VSolid::Clone() const
void G4VSolid::ClipCrossSection( G4ThreeVectorList* pVertices,
const G4int pSectionIndex,
const G4VoxelLimits& pVoxelLimit,
const EAxis pAxis,
const EAxis pAxis,
G4double& pMin, G4double& pMax) const
{
@@ -442,7 +444,7 @@ void G4VSolid::ClipCrossSection( G4ThreeVectorList* pVertices,
void G4VSolid::ClipBetweenSections( G4ThreeVectorList* pVertices,
const G4int pSectionIndex,
const G4VoxelLimits& pVoxelLimit,
const EAxis pAxis,
const EAxis pAxis,
G4double& pMin, G4double& pMax) const
{
G4ThreeVectorList polygon;
@@ -486,7 +488,7 @@ void G4VSolid::ClipBetweenSections( G4ThreeVectorList* pVertices,
void
G4VSolid::CalculateClippedPolygonExtent(G4ThreeVectorList& pPolygon,
const G4VoxelLimits& pVoxelLimit,
const EAxis pAxis,
const EAxis pAxis,
G4double& pMin,
G4double& pMax) const
{
@@ -501,15 +503,15 @@ G4VSolid::CalculateClippedPolygonExtent(G4ThreeVectorList& pPolygon,
for (i=0; i<noLeft; ++i)
{
component = pPolygon[i].operator()(pAxis);
if (component < pMin)
{
pMin = component;
if (component < pMin)
{
pMin = component;
}
if (component > pMax)
{
pMax = component;
}
{
pMax = component;
}
}
}
}
@@ -547,7 +549,7 @@ void G4VSolid::ClipPolygon( G4ThreeVectorList& pPolygon,
G4VoxelLimits simpleLimit1;
simpleLimit1.AddLimit(kXAxis,pVoxelLimit.GetMinXExtent(),kInfinity);
ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
pPolygon.clear();
if ( !outputPolygon.size() ) return;
@@ -635,7 +637,7 @@ G4VSolid::ClipPolygonToSimpleLimits( G4ThreeVectorList& pPolygon,
//
pVoxelLimit.ClipToLimits(vStart,vEnd);
outputPolygon.push_back(vEnd);
}
}
}
else
{
@@ -645,12 +647,12 @@ G4VSolid::ClipPolygonToSimpleLimits( G4ThreeVectorList& pPolygon,
//
pVoxelLimit.ClipToLimits(vStart,vEnd);
outputPolygon.push_back(vStart);
outputPolygon.push_back(vEnd);
outputPolygon.push_back(vEnd);
}
else // Both point outside -> no output
{
// outputPolygon.push_back(vStart);
// outputPolygon.push_back(vEnd);
// outputPolygon.push_back(vEnd);
}
}
}
@@ -677,7 +679,7 @@ void G4VSolid::BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const
//
// Get G4VisExtent - bounding box for graphics
G4VisExtent G4VSolid::GetExtent () const
G4VisExtent G4VSolid::GetExtent () const
{
G4VisExtent extent;
G4VoxelLimits voxelLimits; // Defaults to "infinite" limits.
@@ -30,14 +30,7 @@
#include "G4VTouchable.hh"
G4VTouchable::G4VTouchable()
{
}
G4VTouchable::~G4VTouchable()
{
}
// --------------------------------------------------------------------
G4VPhysicalVolume* G4VTouchable::GetVolume(G4int) const
{
G4Exception("G4VTouchable::GetVolume()", "GeomMgt0001",
@@ -45,6 +38,7 @@ G4VPhysicalVolume* G4VTouchable::GetVolume(G4int) const
return nullptr;
}
// --------------------------------------------------------------------
G4VSolid* G4VTouchable::GetSolid(G4int) const
{
G4Exception("G4VTouchable::GetSolid()", "GeomMgt0001",
@@ -52,6 +46,7 @@ G4VSolid* G4VTouchable::GetSolid(G4int) const
return nullptr;
}
// --------------------------------------------------------------------
G4int G4VTouchable::GetReplicaNumber(G4int) const
{
G4Exception("G4VTouchable::GetReplicaNumber()", "GeomMgt0001",
@@ -59,6 +54,7 @@ G4int G4VTouchable::GetReplicaNumber(G4int) const
return 0;
}
// --------------------------------------------------------------------
G4int G4VTouchable::MoveUpHistory(G4int)
{
G4Exception("G4VTouchable::MoveUpHistory()", "GeomMgt0001",
@@ -66,6 +62,7 @@ G4int G4VTouchable::MoveUpHistory(G4int)
return 0;
}
// --------------------------------------------------------------------
void G4VTouchable::UpdateYourself(G4VPhysicalVolume*,
const G4NavigationHistory* )
{
@@ -73,6 +70,7 @@ void G4VTouchable::UpdateYourself(G4VPhysicalVolume*,
FatalException, "Undefined call to base class.");
}
// --------------------------------------------------------------------
G4int G4VTouchable::GetHistoryDepth() const
{
G4Exception("G4VTouchable::GetHistoryDepth()", "GeomMgt0001",
@@ -80,9 +78,10 @@ G4int G4VTouchable::GetHistoryDepth() const
return 0;
}
// --------------------------------------------------------------------
const G4NavigationHistory* G4VTouchable::GetHistory() const
{
G4Exception("G4VTouchable::GetHistory()", "GeomMgt0001",
FatalException, "Undefined call to base class.");
return 0;
return nullptr;
}
@@ -32,18 +32,6 @@
#include "G4ios.hh"
///////////////////////////////////////////////////////////////////////////
//
// Empty constructor and destructor
//
G4VoxelLimits::G4VoxelLimits()
{
}
G4VoxelLimits::~G4VoxelLimits()
{
}
///////////////////////////////////////////////////////////////////////////
//
// Further restrict limits
+5
View File
@@ -16,6 +16,11 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
September 25, 2021 - P.Arce (geomnav-V10-07-05)
----------------------------
- Reduce warning messages in GetReplicaNo: only when difference is > kCarTolerance
- NoVoxel -> NoVoxels for coherence with rest of code
May 4, 2021 - J.Apostolakis (geomnav-V10-07-04)
----------------------------
- G4Navigator:
@@ -125,15 +125,15 @@ class G4PhantomParameterisation : public G4VPVParameterisation
inline void SetMaterialIndices( size_t* matInd );
void SetVoxelDimensions( G4double halfx, G4double halfy, G4double halfz );
void SetNoVoxel( size_t nx, size_t ny, size_t nz );
void SetNoVoxels( size_t nx, size_t ny, size_t nz );
inline G4double GetVoxelHalfX() const;
inline G4double GetVoxelHalfY() const;
inline G4double GetVoxelHalfZ() const;
inline size_t GetNoVoxelX() const;
inline size_t GetNoVoxelY() const;
inline size_t GetNoVoxelZ() const;
inline size_t GetNoVoxel() const;
inline size_t GetNoVoxelsX() const;
inline size_t GetNoVoxelsY() const;
inline size_t GetNoVoxelsZ() const;
inline size_t GetNoVoxels() const;
inline std::vector<G4Material*> GetMaterials() const;
inline size_t* GetMaterialIndices() const;
@@ -167,11 +167,11 @@ class G4PhantomParameterisation : public G4VPVParameterisation
G4double fVoxelHalfX = 0.0, fVoxelHalfY = 0.0, fVoxelHalfZ = 0.0;
// Half dimension of voxels (assume they are boxes).
size_t fNoVoxelX = 0, fNoVoxelY = 0, fNoVoxelZ = 0;
size_t fNoVoxelsX = 0, fNoVoxelsY = 0, fNoVoxelsZ = 0;
// Number of voxel in x, y and z dimensions.
size_t fNoVoxelXY = 0;
size_t fNoVoxelsXY = 0;
// Number of voxels in x times number of voxels in y (for speed-up).
size_t fNoVoxel = 0;
size_t fNoVoxels = 0;
// Total number of voxels (for speed-up).
std::vector<G4Material*> fMaterials;
@@ -38,15 +38,15 @@ SetVoxelDimensions( G4double halfx, G4double halfy, G4double halfz )
//--------------------------------------------------------------------
inline
void G4PhantomParameterisation::SetNoVoxel( size_t nx, size_t ny, size_t nz )
void G4PhantomParameterisation::SetNoVoxels( size_t nx, size_t ny, size_t nz )
{
fNoVoxelX = nx;
fNoVoxelY = ny;
fNoVoxelZ = nz;
fNoVoxelXY = nx*ny;
fNoVoxel = nx*ny*nz;
fNoVoxelsX = nx;
fNoVoxelsY = ny;
fNoVoxelsZ = nz;
fNoVoxelsXY = nx*ny;
fNoVoxels = nx*ny*nz;
}
//--------------------------------------------------------------------
inline
void G4PhantomParameterisation::SetMaterials( std::vector<G4Material*>& mates )
@@ -84,30 +84,30 @@ G4double G4PhantomParameterisation::GetVoxelHalfZ() const
//--------------------------------------------------------------------
inline
size_t G4PhantomParameterisation::GetNoVoxelX() const
size_t G4PhantomParameterisation::GetNoVoxelsX() const
{
return fNoVoxelX;
return fNoVoxelsX;
}
//--------------------------------------------------------------------
inline
size_t G4PhantomParameterisation::GetNoVoxelY() const
size_t G4PhantomParameterisation::GetNoVoxelsY() const
{
return fNoVoxelY;
return fNoVoxelsY;
}
//--------------------------------------------------------------------
inline
size_t G4PhantomParameterisation::GetNoVoxelZ() const
size_t G4PhantomParameterisation::GetNoVoxelsZ() const
{
return fNoVoxelZ;
return fNoVoxelsZ;
}
//--------------------------------------------------------------------
inline
size_t G4PhantomParameterisation::GetNoVoxel() const
size_t G4PhantomParameterisation::GetNoVoxels() const
{
return fNoVoxel;
return fNoVoxels;
}
//--------------------------------------------------------------------
@@ -106,7 +106,7 @@ GetMaterialIndex( size_t copyNo ) const
size_t G4PartialPhantomParameterisation::
GetMaterialIndex( size_t nx, size_t ny, size_t nz ) const
{
size_t copyNo = nx + fNoVoxelX*ny + fNoVoxelXY*nz;
size_t copyNo = nx + fNoVoxelsX*ny + fNoVoxelsXY*nz;
return GetMaterialIndex( copyNo );
}
@@ -136,8 +136,8 @@ ComputeVoxelIndices(const G4int copyNo, size_t& nx,
auto ite = fFilledIDs.lower_bound(size_t(copyNo));
G4int dist = std::distance( fFilledIDs.cbegin(), ite );
nz = size_t( dist/fNoVoxelY );
ny = size_t( dist%fNoVoxelY );
nz = size_t( dist/fNoVoxelsY );
ny = size_t( dist%fNoVoxelsY );
G4int ifmin = (*ite).second;
G4int nvoxXprev;
@@ -183,7 +183,7 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
// If it is on the surface side, check the direction: if direction is
// negative place it on the previous voxel (if direction is positive it is
// already in the next voxel...).
// Correct also cases where n = -1 or n = fNoVoxel. It is always traced to be
// Correct also cases where n = -1 or n = fNoVoxels. It is always traced to be
// due to multiple scattering: track is entering a voxel but multiple
// scattering changes the angle towards outside
//
@@ -198,7 +198,7 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
}
else
{
if( nx == G4int(fNoVoxelX) )
if( nx == G4int(fNoVoxelsX) )
{
nx -= 1;
}
@@ -215,7 +215,7 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
}
else
{
if( ny == G4int(fNoVoxelY) )
if( ny == G4int(fNoVoxelsY) )
{
ny -= 1;
}
@@ -232,7 +232,7 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
}
else
{
if( nz == G4int(fNoVoxelZ) )
if( nz == G4int(fNoVoxelsZ) )
{
nz -= 1;
}
@@ -247,9 +247,9 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
nx = 0;
isOK = false;
}
else if( nx >= G4int(fNoVoxelX) )
else if( nx >= G4int(fNoVoxelsX) )
{
nx = fNoVoxelX-1;
nx = fNoVoxelsX-1;
isOK = false;
}
if( ny < 0 )
@@ -257,9 +257,9 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
ny = 0;
isOK = false;
}
else if( ny >= G4int(fNoVoxelY) )
else if( ny >= G4int(fNoVoxelsY) )
{
ny = fNoVoxelY-1;
ny = fNoVoxelsY-1;
isOK = false;
}
if( nz < 0 )
@@ -267,9 +267,9 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
nz = 0;
isOK = false;
}
else if( nz >= G4int(fNoVoxelZ) )
else if( nz >= G4int(fNoVoxelsZ) )
{
nz = fNoVoxelZ-1;
nz = fNoVoxelsZ-1;
isOK = false;
}
if( !isOK )
@@ -289,7 +289,7 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
"GeomNav1002", JustWarning, message);
}
G4int nyz = nz*fNoVoxelY+ny;
G4int nyz = nz*fNoVoxelsY+ny;
auto ite = fFilledIDs.cbegin();
/*
for( ite = fFilledIDs.cbegin(); ite != fFilledIDs.cend(); ++ite )
@@ -318,12 +318,12 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
//------------------------------------------------------------------
void G4PartialPhantomParameterisation::CheckCopyNo( const G4int copyNo ) const
{
if( copyNo < 0 || copyNo >= G4int(fNoVoxel) )
if( copyNo < 0 || copyNo >= G4int(fNoVoxels) )
{
std::ostringstream message;
message << "Copy number is negative or too big!" << G4endl
<< " Copy number: " << copyNo << G4endl
<< " Total number of voxels: " << fNoVoxel;
<< " Total number of voxels: " << fNoVoxels;
G4Exception("G4PartialPhantomParameterisation::CheckCopyNo()",
"GeomNav0002", FatalErrorInArgument, message);
}
@@ -333,7 +333,7 @@ void G4PartialPhantomParameterisation::CheckCopyNo( const G4int copyNo ) const
//------------------------------------------------------------------
void G4PartialPhantomParameterisation::BuildContainerWalls()
{
fContainerWallX = fNoVoxelX * fVoxelHalfX;
fContainerWallY = fNoVoxelY * fVoxelHalfY;
fContainerWallZ = fNoVoxelZ * fVoxelHalfZ;
fContainerWallX = fNoVoxelsX * fVoxelHalfX;
fContainerWallY = fNoVoxelsY * fVoxelHalfY;
fContainerWallZ = fNoVoxelsZ * fVoxelHalfZ;
}
@@ -56,9 +56,9 @@ void G4PhantomParameterisation::
BuildContainerSolid( G4VPhysicalVolume* pMotherPhysical )
{
fContainerSolid = pMotherPhysical->GetLogicalVolume()->GetSolid();
fContainerWallX = fNoVoxelX * fVoxelHalfX;
fContainerWallY = fNoVoxelY * fVoxelHalfY;
fContainerWallZ = fNoVoxelZ * fVoxelHalfZ;
fContainerWallX = fNoVoxelsX * fVoxelHalfX;
fContainerWallY = fNoVoxelsY * fVoxelHalfY;
fContainerWallZ = fNoVoxelsZ * fVoxelHalfZ;
// CheckVoxelsFillContainer();
}
@@ -68,9 +68,9 @@ void G4PhantomParameterisation::
BuildContainerSolid( G4VSolid* pMotherSolid )
{
fContainerSolid = pMotherSolid;
fContainerWallX = fNoVoxelX * fVoxelHalfX;
fContainerWallY = fNoVoxelY * fVoxelHalfY;
fContainerWallZ = fNoVoxelZ * fVoxelHalfZ;
fContainerWallX = fNoVoxelsX * fVoxelHalfX;
fContainerWallY = fNoVoxelsY * fVoxelHalfY;
fContainerWallZ = fNoVoxelsZ * fVoxelHalfZ;
// CheckVoxelsFillContainer();
}
@@ -141,7 +141,7 @@ GetMaterialIndex( size_t copyNo ) const
size_t G4PhantomParameterisation::
GetMaterialIndex( size_t nx, size_t ny, size_t nz ) const
{
size_t copyNo = nx + fNoVoxelX*ny + fNoVoxelXY*nz;
size_t copyNo = nx + fNoVoxelsX*ny + fNoVoxelsXY*nz;
return GetMaterialIndex( copyNo );
}
@@ -165,9 +165,9 @@ ComputeVoxelIndices(const G4int copyNo, size_t& nx,
size_t& ny, size_t& nz ) const
{
CheckCopyNo( copyNo );
nx = size_t(copyNo%fNoVoxelX);
ny = size_t( (copyNo/fNoVoxelX)%fNoVoxelY );
nz = size_t(copyNo/fNoVoxelXY);
nx = size_t(copyNo%fNoVoxelsX);
ny = size_t( (copyNo/fNoVoxelsX)%fNoVoxelsY );
nz = size_t(copyNo/fNoVoxelsXY);
}
@@ -186,31 +186,31 @@ CheckVoxelsFillContainer( G4double contX, G4double contY, G4double contZ ) const
// Any bigger value than kCarTolerance will give an error in GetReplicaNo()
//
if( std::fabs(contX-fNoVoxelX*fVoxelHalfX) >= toleranceForError
|| std::fabs(contY-fNoVoxelY*fVoxelHalfY) >= toleranceForError
|| std::fabs(contZ-fNoVoxelZ*fVoxelHalfZ) >= toleranceForError )
if( std::fabs(contX-fNoVoxelsX*fVoxelHalfX) >= toleranceForError
|| std::fabs(contY-fNoVoxelsY*fVoxelHalfY) >= toleranceForError
|| std::fabs(contZ-fNoVoxelsZ*fVoxelHalfZ) >= toleranceForError )
{
std::ostringstream message;
message << "Voxels do not fully fill the container: "
<< fContainerSolid->GetName() << G4endl
<< " DiffX= " << contX-fNoVoxelX*fVoxelHalfX << G4endl
<< " DiffY= " << contY-fNoVoxelY*fVoxelHalfY << G4endl
<< " DiffZ= " << contZ-fNoVoxelZ*fVoxelHalfZ << G4endl
<< " DiffX= " << contX-fNoVoxelsX*fVoxelHalfX << G4endl
<< " DiffY= " << contY-fNoVoxelsY*fVoxelHalfY << G4endl
<< " DiffZ= " << contZ-fNoVoxelsZ*fVoxelHalfZ << G4endl
<< " Maximum difference is: " << toleranceForError;
G4Exception("G4PhantomParameterisation::CheckVoxelsFillContainer()",
"GeomNav0002", FatalException, message);
}
else if( std::fabs(contX-fNoVoxelX*fVoxelHalfX) >= toleranceForWarning
|| std::fabs(contY-fNoVoxelY*fVoxelHalfY) >= toleranceForWarning
|| std::fabs(contZ-fNoVoxelZ*fVoxelHalfZ) >= toleranceForWarning )
else if( std::fabs(contX-fNoVoxelsX*fVoxelHalfX) >= toleranceForWarning
|| std::fabs(contY-fNoVoxelsY*fVoxelHalfY) >= toleranceForWarning
|| std::fabs(contZ-fNoVoxelsZ*fVoxelHalfZ) >= toleranceForWarning )
{
std::ostringstream message;
message << "Voxels do not fully fill the container: "
<< fContainerSolid->GetName() << G4endl
<< " DiffX= " << contX-fNoVoxelX*fVoxelHalfX << G4endl
<< " DiffY= " << contY-fNoVoxelY*fVoxelHalfY << G4endl
<< " DiffZ= " << contZ-fNoVoxelZ*fVoxelHalfZ << G4endl
<< " DiffX= " << contX-fNoVoxelsX*fVoxelHalfX << G4endl
<< " DiffY= " << contY-fNoVoxelsY*fVoxelHalfY << G4endl
<< " DiffZ= " << contZ-fNoVoxelsZ*fVoxelHalfZ << G4endl
<< " Maximum difference is: " << toleranceForWarning;
G4Exception("G4PhantomParameterisation::CheckVoxelsFillContainer()",
"GeomNav1002", JustWarning, message);
@@ -227,17 +227,22 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
//
if( fContainerSolid->Inside( localPoint ) == kOutside )
{
std::ostringstream message;
message << "Point outside voxels!" << G4endl
<< " localPoint - " << localPoint
<< " - is outside container solid: "
<< fContainerSolid->GetName() << G4endl
<< "DIFFERENCE WITH PHANTOM WALLS X: "
<< std::fabs(localPoint.x()) - fContainerWallX
<< " Y: " << std::fabs(localPoint.y()) - fContainerWallY
<< " Z: " << std::fabs(localPoint.z()) - fContainerWallZ;
G4Exception("G4PhantomParameterisation::GetReplicaNo()", "GeomNav0003",
FatalErrorInArgument, message);
if( std::fabs(localPoint.x()) - fContainerWallX > kCarTolerance
&& std::fabs(localPoint.y()) - fContainerWallY > kCarTolerance
&& std::fabs(localPoint.z()) - fContainerWallZ > kCarTolerance )
{
std::ostringstream message;
message << "Point outside voxels!" << G4endl
<< " localPoint - " << localPoint
<< " - is outside container solid: "
<< fContainerSolid->GetName() << G4endl
<< "DIFFERENCE WITH PHANTOM WALLS X: "
<< std::fabs(localPoint.x()) - fContainerWallX
<< " Y: " << std::fabs(localPoint.y()) - fContainerWallY
<< " Z: " << std::fabs(localPoint.z()) - fContainerWallZ;
G4Exception("G4PhantomParameterisation::GetReplicaNo()", "GeomNav0003",
FatalErrorInArgument, message);
}
}
// Check the voxel numbers corresponding to localPoint
@@ -264,7 +269,7 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
// If it is on the surface side, check the direction: if direction is
// negative place it in the previous voxel (if direction is positive it is
// already in the next voxel).
// Correct also cases where n = -1 or n = fNoVoxel. It is always traced to be
// Correct also cases where n = -1 or n = fNoVoxels. It is always traced to be
// due to multiple scattering: track is entering a voxel but multiple
// scattering changes the angle towards outside
//
@@ -279,7 +284,7 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
}
else
{
if( nx == G4int(fNoVoxelX) )
if( nx == G4int(fNoVoxelsX) )
{
nx -= 1;
}
@@ -296,7 +301,7 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
}
else
{
if( ny == G4int(fNoVoxelY) )
if( ny == G4int(fNoVoxelsY) )
{
ny -= 1;
}
@@ -313,14 +318,14 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
}
else
{
if( nz == G4int(fNoVoxelZ) )
if( nz == G4int(fNoVoxelsZ) )
{
nz -= 1;
}
}
}
G4int copyNo = nx + fNoVoxelX*ny + fNoVoxelXY*nz;
G4int copyNo = nx + fNoVoxelsX*ny + fNoVoxelsXY*nz;
// Check if there are still errors
//
@@ -330,9 +335,9 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
nx = 0;
isOK = false;
}
else if( nx >= G4int(fNoVoxelX) )
else if( nx >= G4int(fNoVoxelsX) )
{
nx = fNoVoxelX-1;
nx = fNoVoxelsX-1;
isOK = false;
}
if( ny < 0 )
@@ -340,9 +345,9 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
ny = 0;
isOK = false;
}
else if( ny >= G4int(fNoVoxelY) )
else if( ny >= G4int(fNoVoxelsY) )
{
ny = fNoVoxelY-1;
ny = fNoVoxelsY-1;
isOK = false;
}
if( nz < 0 )
@@ -350,26 +355,31 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
nz = 0;
isOK = false;
}
else if( nz >= G4int(fNoVoxelZ) )
else if( nz >= G4int(fNoVoxelsZ) )
{
nz = fNoVoxelZ-1;
nz = fNoVoxelsZ-1;
isOK = false;
}
if( !isOK )
{
std::ostringstream message;
message << "Corrected the copy number! It was negative or too big" << G4endl
<< " LocalPoint: " << localPoint << G4endl
<< " LocalDir: " << localDir << G4endl
<< " Voxel container size: " << fContainerWallX
<< " " << fContainerWallY << " " << fContainerWallZ << G4endl
<< " LocalPoint - wall: "
<< localPoint.x()-fContainerWallX << " "
<< localPoint.y()-fContainerWallY << " "
<< localPoint.z()-fContainerWallZ;
G4Exception("G4PhantomParameterisation::GetReplicaNo()",
"GeomNav1002", JustWarning, message);
copyNo = nx + fNoVoxelX*ny + fNoVoxelXY*nz;
if( std::fabs(localPoint.x()-fContainerWallX) > kCarTolerance &&
std::fabs(localPoint.y()-fContainerWallY) > kCarTolerance &&
std::fabs(localPoint.z()-fContainerWallZ) > kCarTolerance ){ // only if difference is big
std::ostringstream message;
message << "Corrected the copy number! It was negative or too big" << G4endl
<< " LocalPoint: " << localPoint << G4endl
<< " LocalDir: " << localDir << G4endl
<< " Voxel container size: " << fContainerWallX
<< " " << fContainerWallY << " " << fContainerWallZ << G4endl
<< " LocalPoint - wall: "
<< localPoint.x()-fContainerWallX << " "
<< localPoint.y()-fContainerWallY << " "
<< localPoint.z()-fContainerWallZ;
G4Exception("G4PhantomParameterisation::GetReplicaNo()",
"GeomNav1002", JustWarning, message);
}
copyNo = nx + fNoVoxelsX*ny + fNoVoxelsXY*nz;
}
return copyNo;
@@ -379,12 +389,12 @@ GetReplicaNo( const G4ThreeVector& localPoint, const G4ThreeVector& localDir )
//------------------------------------------------------------------
void G4PhantomParameterisation::CheckCopyNo( const G4int copyNo ) const
{
if( copyNo < 0 || copyNo >= G4int(fNoVoxel) )
if( copyNo < 0 || copyNo >= G4int(fNoVoxels) )
{
std::ostringstream message;
message << "Copy number is negative or too big!" << G4endl
<< " Copy number: " << copyNo << G4endl
<< " Total number of voxels: " << fNoVoxel;
<< " Total number of voxels: " << fNoVoxels;
G4Exception("G4PhantomParameterisation::CheckCopyNo()",
"GeomNav0002", FatalErrorInArgument, message);
}
@@ -404,7 +404,7 @@ G4RegularNavigation::LevelLocate( G4NavigationHistory& history,
//
replicaNo = pParam->GetReplicaNo( localPoint, localDir );
if( replicaNo < 0 || replicaNo >= G4int(pParam->GetNoVoxel()) )
if( replicaNo < 0 || replicaNo >= G4int(pParam->GetNoVoxels()) )
{
return false;
}
+7 -3
View File
@@ -19,12 +19,16 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
May 6, 2021 J.Apostolakis geom-bool-V10-07-02
October 12, 2021 G.Cosmo geom-bool-V10-07-03
- In G4BooleanSolid, use G4RecursiveMutex in place of G4Mutex in GetPolyhedron()
to avoid potential deadlocks in recursive Boolean operations.
Courtesy of S.Boogert (London Univ.).
May 6, 2021 J.Apostolakis geom-bool-V10-07-02
- Revised GetCubicVolume of UnionSolid and SubtractionSolid to use cubic volume
of constituent volume(s) and the intersection solid.
Test cases show the potential for improvement: factors of 40-3000.
Cases with small overlap will improve most. Not all cases will improve.
Cases with small overlap will improve most. Not all cases will improve.
Need to monitor cpu cost in most difficult cases:
- Union now involves 3 calculations (a, b, a n b) - likely 2x cost.
- Subtraction involves 2 calculations (a, a n b) - 1.5x cost.
@@ -42,7 +42,7 @@
namespace
{
G4Mutex polyhedronMutex = G4MUTEX_INITIALIZER;
G4RecursiveMutex polyhedronMutex = G4MUTEX_INITIALIZER;
}
//////////////////////////////////////////////////////////////////
@@ -346,7 +346,7 @@ G4Polyhedron* G4BooleanSolid::GetPolyhedron () const
fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
fpPolyhedron->GetNumberOfRotationSteps())
{
G4AutoLock l(&polyhedronMutex);
G4RecursiveAutoLock l(&polyhedronMutex);
delete fpPolyhedron;
fpPolyhedron = CreatePolyhedron();
fRebuildPolyhedron = false;
+13 -2
View File
@@ -16,12 +16,23 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
November 24, 2021 G.Cosmo geom-csg-V10-07-06
- Corrected typo in G4UPara::GetXHalfLength().
Addressing problem report #2446.
November 01, 2021 E.Tcherniaev geom-csg-V10-07-05
- Revision of G4UTrap:
o List of accessors and modifiers made consistent with G4Trap
o Implemented check of parameters similar to G4Trap
August 31, 2021 B.Morgan geom-csg-V10-07-04
- Remove old Get-er methods that simply forward to the new main Get-er
methods
May 18, 2021 J.Apostolakis geom-csg-V10-07-03
- Added method to enable simpler conversion of G4 solids to VecGeom:
o G4Trap: added methods to calculate Phi & Theta
o G4Para: added methods to calculate original alpha, theta, phi
o G4Para: added methods to calculate original alpha, theta, phi
May 17, 2021 E.Tcherniaev geom-csg-V10-07-02
- Bux fix in G4Sphere::GetSurfaceArea()
@@ -169,16 +169,6 @@ class G4Cons : public G4CSGSolid
G4Cons& operator=(const G4Cons& rhs);
// Copy constructor and assignment operator.
// Old access functions
inline G4double GetRmin1() const;
inline G4double GetRmax1() const;
inline G4double GetRmin2() const;
inline G4double GetRmax2() const;
inline G4double GetDz() const;
inline G4double GetSPhi() const;
inline G4double GetDPhi() const;
private:
inline void Initialize();
+7 -51
View File
@@ -56,7 +56,7 @@ G4double G4Cons::GetZHalfLength() const
return fDz ;
}
inline
inline
G4double G4Cons::GetStartPhiAngle() const
{
return fSPhi ;
@@ -100,11 +100,11 @@ void G4Cons::Initialize()
fRebuildPolyhedron = true;
}
inline
inline
void G4Cons::InitializeTrigonometry()
{
G4double hDPhi = 0.5*fDPhi; // half delta phi
G4double cPhi = fSPhi + hDPhi;
G4double cPhi = fSPhi + hDPhi;
G4double ePhi = fSPhi + fDPhi;
sinCPhi = std::sin(cPhi);
@@ -223,55 +223,11 @@ void G4Cons::SetDeltaPhiAngle ( G4double newDPhi )
Initialize();
}
// Old access methods ...
inline
G4double G4Cons::GetRmin1() const
{
return GetInnerRadiusMinusZ();
}
inline
G4double G4Cons::GetRmax1() const
{
return GetOuterRadiusMinusZ();
}
inline
G4double G4Cons::GetRmin2() const
{
return GetInnerRadiusPlusZ();
}
inline
G4double G4Cons::GetRmax2() const
{
return GetOuterRadiusPlusZ();
}
inline
G4double G4Cons::GetDz() const
{
return GetZHalfLength();
}
inline
G4double G4Cons::GetSPhi() const
{
return GetStartPhiAngle();
}
inline
G4double G4Cons::GetDPhi() const
{
return GetDeltaPhiAngle();
}
inline
G4double G4Cons::GetCubicVolume()
{
if(fCubicVolume != 0.) {;}
else
else
{
G4double Rmean, rMean, deltaR, deltar;
@@ -281,7 +237,7 @@ G4double G4Cons::GetCubicVolume()
rMean = 0.5*(fRmin1+fRmin2);
deltar = fRmin1-fRmin2;
fCubicVolume = fDPhi*fDz*(Rmean*Rmean-rMean*rMean
+(deltaR*deltaR-deltar*deltar)/12);
+(deltaR*deltaR-deltar*deltar)/12);
}
return fCubicVolume;
}
@@ -290,7 +246,7 @@ inline
G4double G4Cons::GetSurfaceArea()
{
if(fSurfaceArea != 0.) {;}
else
else
{
G4double mmin, mmax, dmin, dmax;
@@ -298,7 +254,7 @@ G4double G4Cons::GetSurfaceArea()
mmax= (fRmax1+fRmax2)*0.5;
dmin= (fRmin2-fRmin1);
dmax= (fRmax2-fRmax1);
fSurfaceArea = fDPhi*( mmin * std::sqrt(dmin*dmin+4*fDz*fDz)
+ mmax * std::sqrt(dmax*dmax+4*fDz*fDz)
+ 0.5*(fRmax1*fRmax1-fRmin1*fRmin1
@@ -146,14 +146,6 @@ class G4CutTubs : public G4CSGSolid
G4CutTubs& operator=(const G4CutTubs& rhs);
// Copy constructor and assignment operator.
// Older names for access functions
inline G4double GetRMin() const;
inline G4double GetRMax() const;
inline G4double GetDz () const;
inline G4double GetSPhi() const;
inline G4double GetDPhi() const;
protected:
inline void Initialize();
@@ -242,35 +242,3 @@ void G4CutTubs::SetDeltaPhiAngle (G4double newDPhi)
CheckPhiAngles(fSPhi, newDPhi);
Initialize();
}
// Older names for access functions
inline
G4double G4CutTubs::GetRMin () const
{
return GetInnerRadius();
}
inline
G4double G4CutTubs::GetRMax () const
{
return GetOuterRadius();
}
inline
G4double G4CutTubs::GetDz () const
{
return GetZHalfLength();
}
inline
G4double G4CutTubs::GetSPhi () const
{
return GetStartPhiAngle();
}
inline
G4double G4CutTubs::GetDPhi () const
{
return GetDeltaPhiAngle();
}
@@ -178,16 +178,6 @@ class G4Sphere : public G4CSGSolid
G4Sphere& operator=(const G4Sphere& rhs);
// Copy constructor and assignment operator.
// Old access functions
inline G4double GetRmin() const;
inline G4double GetRmax() const;
inline G4double GetSPhi() const;
inline G4double GetDPhi() const;
inline G4double GetSTheta() const;
inline G4double GetDTheta() const;
inline G4double GetInsideRadius() const;
inline void SetInsideRadius(G4double newRmin);
private:
@@ -26,12 +26,6 @@
// Implementation of inline methods of G4Sphere
// --------------------------------------------------------------------
inline
G4double G4Sphere::GetInsideRadius() const
{
return fRmin;
}
inline
G4double G4Sphere::GetInnerRadius() const
{
@@ -253,19 +247,13 @@ void G4Sphere::CheckPhiAngles(G4double sPhi, G4double dPhi)
}
inline
void G4Sphere::SetInsideRadius(G4double newRmin)
void G4Sphere::SetInnerRadius(G4double newRmin)
{
fRmin= newRmin;
fRminTolerance = (fRmin) ? std::max( kRadTolerance, fEpsilon*fRmin ) : 0;
Initialize();
}
inline
void G4Sphere::SetInnerRadius(G4double newRmin)
{
SetInsideRadius(newRmin);
}
inline
void G4Sphere::SetOuterRadius(G4double newRmax)
{
@@ -306,41 +294,3 @@ void G4Sphere::SetDeltaThetaAngle(G4double newDTheta)
CheckThetaAngles(fSTheta, newDTheta);
Initialize();
}
// Old access functions
inline
G4double G4Sphere::GetRmin() const
{
return GetInsideRadius();
}
inline
G4double G4Sphere::GetRmax() const
{
return GetOuterRadius();
}
inline
G4double G4Sphere::GetSPhi() const
{
return GetStartPhiAngle();
}
inline
G4double G4Sphere::GetDPhi() const
{
return GetDeltaPhiAngle();
}
inline
G4double G4Sphere::GetSTheta() const
{
return GetStartThetaAngle();
}
inline
G4double G4Sphere::GetDTheta() const
{
return GetDeltaThetaAngle();
}
+4 -12
View File
@@ -161,14 +161,6 @@ class G4Tubs : public G4CSGSolid
G4Tubs& operator=(const G4Tubs& rhs);
// Copy constructor and assignment operator.
// Older names for access functions
inline G4double GetRMin() const;
inline G4double GetRMax() const;
inline G4double GetDz () const;
inline G4double GetSPhi() const;
inline G4double GetDPhi() const;
protected:
inline void Initialize();
@@ -212,10 +204,10 @@ class G4Tubs : public G4CSGSolid
// Radial and angular tolerances
static constexpr G4double kNormTolerance = 1.0e-6;
//
//
// Tolerance of unity for surface normal
// (for speedup - use fInvRmax if possible )
G4double fRMin, fRMax, fDz, fSPhi, fDPhi;
//
// Radial and angular dimensions
@@ -230,9 +222,9 @@ class G4Tubs : public G4CSGSolid
// Flag for identification of section or full tube
G4double fInvRmax, fInvRmin;
//
//
// More cached values - inverse of Rmax, Rmin.
G4double halfCarTolerance, halfRadTolerance, halfAngTolerance;
//
// Cached half tolerance values
+3 -35
View File
@@ -80,7 +80,7 @@ G4double G4Tubs::GetCosEndPhi () const
return cosEPhi;
}
inline
inline
void G4Tubs::Initialize()
{
fCubicVolume = 0.;
@@ -90,11 +90,11 @@ void G4Tubs::Initialize()
fRebuildPolyhedron = true;
}
inline
inline
void G4Tubs::InitializeTrigonometry()
{
G4double hDPhi = 0.5*fDPhi; // half delta phi
G4double cPhi = fSPhi + hDPhi;
G4double cPhi = fSPhi + hDPhi;
G4double ePhi = fSPhi + fDPhi;
sinCPhi = std::sin(cPhi);
@@ -231,38 +231,6 @@ void G4Tubs::SetDeltaPhiAngle (G4double newDPhi)
Initialize();
}
// Older names for access functions
inline
G4double G4Tubs::GetRMin () const
{
return GetInnerRadius();
}
inline
G4double G4Tubs::GetRMax () const
{
return GetOuterRadius();
}
inline
G4double G4Tubs::GetDz () const
{
return GetZHalfLength() ;
}
inline
G4double G4Tubs::GetSPhi () const
{
return GetStartPhiAngle();
}
inline
G4double G4Tubs::GetDPhi () const
{
return GetDeltaPhiAngle();
}
inline
G4double G4Tubs::GetCubicVolume()
{
+20 -6
View File
@@ -42,7 +42,7 @@
#include "G4Polyhedron.hh"
class G4UTrap : public G4UAdapter<vecgeom::UnplacedTrapezoid>
class G4UTrap : public G4UAdapter<vecgeom::UnplacedTrapezoid>
{
using Shape_t = vecgeom::UnplacedTrapezoid;
using Base_t = G4UAdapter<vecgeom::UnplacedTrapezoid>;
@@ -77,7 +77,7 @@ class G4UTrap : public G4UAdapter<vecgeom::UnplacedTrapezoid>
G4double pDy1, G4double pDy2,
G4double pDz );
//
// Constructor for G4Trd
// Constructor for G4Trd
G4UTrap(const G4String& pName,
G4double pDx, G4double pDy, G4double pDz,
@@ -100,18 +100,19 @@ class G4UTrap : public G4UAdapter<vecgeom::UnplacedTrapezoid>
using Base_t::GetTanAlpha1;
using Base_t::GetTanAlpha2;
// Accessors
G4double GetZHalfLength() const;
G4double GetYHalfLength1() const;
G4double GetXHalfLength1() const;
G4double GetXHalfLength2() const;
G4double GetTanAlpha1() const;
G4double GetYHalfLength2() const;
G4double GetXHalfLength3() const;
G4double GetXHalfLength4() const;
G4double GetThetaCphi() const;
G4double GetThetaSphi() const;
G4double GetTanAlpha2() const;
TrapSidePlane GetSidePlane(G4int n) const;
G4ThreeVector GetSymAxis() const;
@@ -128,7 +129,6 @@ class G4UTrap : public G4UAdapter<vecgeom::UnplacedTrapezoid>
G4double pAlp1,
G4double pDy2, G4double pDx3, G4double pDx4,
G4double pAlp2);
void SetPlanes(const G4ThreeVector pt[8]);
inline G4GeometryType GetEntityType() const;
@@ -151,6 +151,20 @@ class G4UTrap : public G4UAdapter<vecgeom::UnplacedTrapezoid>
G4UTrap(const G4UTrap& rhs);
G4UTrap& operator=(const G4UTrap& rhs);
// Copy constructor and assignment operator.
private:
void SetPlanes(const G4ThreeVector pt[8]);
// Set parameters using eight vertices
void CheckParameters() const;
// Check dimensions
void GetVertices(G4ThreeVector pt[8]) const;
// Compute coordinates of vertices
void CheckPlanarity(const G4ThreeVector pt[8]) const;
// Check planarity of lateral planes
};
// --------------------------------------------------------------------
@@ -80,7 +80,7 @@ class G4UTubs : public G4UAdapter<vecgeom::GenericUnplacedTube>
void SetZHalfLength (G4double newDz);
void SetStartPhiAngle (G4double newSPhi, G4bool trig=true);
void SetDeltaPhiAngle (G4double newDPhi);
inline G4GeometryType GetEntityType() const;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
@@ -100,9 +100,9 @@ class G4UTubs : public G4UAdapter<vecgeom::GenericUnplacedTube>
// persistifiable objects.
G4UTubs(const G4UTubs& rhs);
G4UTubs& operator=(const G4UTubs& rhs);
G4UTubs& operator=(const G4UTubs& rhs);
// Copy constructor and assignment operator.
};
// --------------------------------------------------------------------
+1 -1
View File
@@ -188,7 +188,7 @@ G4double G4UPara::GetYHalfLength() const
}
G4double G4UPara::GetXHalfLength() const
{
return GetZ();
return GetX();
}
G4ThreeVector G4UPara::GetSymAxis() const
{
+158 -25
View File
@@ -53,13 +53,48 @@ G4UTrap::G4UTrap( const G4String& pName,
: Base_t(pName, pdz, pTheta, pPhi, pdy1, pdx1, pdx2,
pAlp1, pdy2, pdx3, pdx4, pAlp2)
{
G4ThreeVector pt[8];
CheckParameters();
GetVertices(pt);
CheckPlanarity(pt);
}
G4UTrap::G4UTrap( const G4String& pName,
const G4ThreeVector pt[8] )
: Base_t(pName)
{
// Start with check of centering - the center of gravity trap line
// should cross the origin of frame
if (!( pt[0].z() < 0
&& pt[0].z() == pt[1].z()
&& pt[0].z() == pt[2].z()
&& pt[0].z() == pt[3].z()
&& pt[4].z() > 0
&& pt[4].z() == pt[5].z()
&& pt[4].z() == pt[6].z()
&& pt[4].z() == pt[7].z()
&& std::abs( pt[0].z() + pt[4].z() ) < kCarTolerance
&& pt[0].y() == pt[1].y()
&& pt[2].y() == pt[3].y()
&& pt[4].y() == pt[5].y()
&& pt[6].y() == pt[7].y()
&& std::abs(pt[0].y()+pt[2].y()+pt[4].y()+pt[6].y()) < kCarTolerance
&& std::abs(pt[0].x()+pt[1].x()+pt[4].x()+pt[5].x() +
pt[2].x()+pt[3].x()+pt[6].x()+pt[7].x()) < kCarTolerance ))
{
std::ostringstream message;
message << "Invalid vertice coordinates for Solid: " << GetName();
G4Exception("G4UTrap::G4UTrap()", "GeomSolids0002",
FatalException, message);
}
SetPlanes(pt);
CheckParameters();
CheckPlanarity(pt);
}
G4UTrap::G4UTrap( const G4String& pName,
@@ -68,6 +103,7 @@ G4UTrap::G4UTrap( const G4String& pName,
G4double pX, G4double pLTX )
: Base_t(pName, pZ, pY, pX, pLTX)
{
CheckParameters();
}
G4UTrap::G4UTrap( const G4String& pName,
@@ -76,6 +112,7 @@ G4UTrap::G4UTrap( const G4String& pName,
G4double pdz )
: Base_t(pName, pdx1, pdx2, pdy1, pdy2, pdz)
{
CheckParameters();
}
G4UTrap::G4UTrap(const G4String& pName,
@@ -83,6 +120,7 @@ G4UTrap::G4UTrap(const G4String& pName,
G4double pAlpha, G4double pTheta, G4double pPhi )
: Base_t(pName, pdx, pdy, pdz, pAlpha, pTheta, pPhi)
{
CheckParameters();
}
G4UTrap::G4UTrap( const G4String& pName )
@@ -136,8 +174,8 @@ G4UTrap& G4UTrap::operator = (const G4UTrap& rhs)
//////////////////////////////////////////////////////////////////////////
//
// Accessors & modifiers
// Accessors
//
G4double G4UTrap::GetZHalfLength() const
{
return GetDz();
@@ -154,6 +192,10 @@ G4double G4UTrap::GetXHalfLength2() const
{
return GetDx2();
}
G4double G4UTrap::GetTanAlpha1() const
{
return Base_t::GetTanAlpha1();
}
G4double G4UTrap::GetYHalfLength2() const
{
return GetDy2();
@@ -166,32 +208,25 @@ G4double G4UTrap::GetXHalfLength4() const
{
return GetDx4();
}
G4double G4UTrap::GetThetaCphi() const
G4double G4UTrap::GetTanAlpha2() const
{
return GetTanThetaCosPhi();
}
G4double G4UTrap::GetThetaSphi() const
{
return GetTanThetaSinPhi();
return Base_t::GetTanAlpha2();
}
G4double G4UTrap::GetPhi() const
{
return std::atan2(GetTanThetaSinPhi(),GetTanThetaCosPhi());
return Base_t::GetPhi();
}
G4double G4UTrap::GetTheta() const
{
const G4double tanThetaCphi=GetTanThetaSinPhi();
const G4double tanThetaSphi=GetTanThetaCosPhi();
return std::atan( std::sqrt(tanThetaCphi*tanThetaCphi
+tanThetaSphi*tanThetaSphi));
return Base_t::GetTheta();
}
G4double G4UTrap::GetAlpha1() const
{
return std::atan(GetTanAlpha1());
return Base_t::GetAlpha1();
}
G4double G4UTrap::GetAlpha2() const
{
return std::atan(GetTanAlpha2());
return Base_t::GetAlpha2();
}
TrapSidePlane G4UTrap::GetSidePlane(G4int n) const
{
@@ -211,6 +246,10 @@ G4ThreeVector G4UTrap::GetSymAxis() const
return G4ThreeVector(tanThetaCphi*cosTheta, tanThetaSphi*cosTheta, cosTheta);
}
//////////////////////////////////////////////////////////////////////////
//
// Modifier
//
void G4UTrap::SetAllParameters(G4double pDz, G4double pTheta, G4double pPhi,
G4double pDy1, G4double pDx1, G4double pDx2,
G4double pAlp1,
@@ -230,8 +269,17 @@ void G4UTrap::SetAllParameters(G4double pDz, G4double pTheta, G4double pPhi,
SetTheta(pTheta);
SetPhi(pPhi);
fRebuildPolyhedron = true;
G4ThreeVector pt[8];
CheckParameters();
GetVertices(pt);
CheckPlanarity(pt);
}
/////////////////////////////////////////////////////////////////////////
//
// Set parameters using eight vertices
//
void G4UTrap::SetPlanes(const G4ThreeVector pt[8])
{
U3Vector upt[8];
@@ -243,6 +291,98 @@ void G4UTrap::SetPlanes(const G4ThreeVector pt[8])
fRebuildPolyhedron = true;
}
/////////////////////////////////////////////////////////////////////////
//
// Check dimensions
//
void G4UTrap::CheckParameters() const
{
G4double fDz = GetZHalfLength();
G4double fDy1 = GetYHalfLength1();
G4double fDx1 = GetXHalfLength1();
G4double fDx2 = GetXHalfLength2();
G4double fDy2 = GetYHalfLength2();
G4double fDx3 = GetXHalfLength3();
G4double fDx4 = GetXHalfLength4();
if (fDz<=0 ||
fDy1<=0 || fDx1<=0 || fDx2<=0 ||
fDy2<=0 || fDx3<=0 || fDx4<=0)
{
std::ostringstream message;
message << "Invalid Length Parameters for Solid: " << GetName()
<< "\n X - " <<fDx1<<", "<<fDx2<<", "<<fDx3<<", "<<fDx4
<< "\n Y - " <<fDy1<<", "<<fDy2
<< "\n Z - " <<fDz;
G4Exception("G4UTrap::CheckParameters()", "GeomSolids0002",
FatalException, message);
}
}
/////////////////////////////////////////////////////////////////////////
//
// Compute coordinates of vertices
//
void G4UTrap::GetVertices(G4ThreeVector pt[8]) const
{
G4double fDz = GetZHalfLength();
G4double fDy1 = GetYHalfLength1();
G4double fDx1 = GetXHalfLength1();
G4double fDx2 = GetXHalfLength2();
G4double fDy2 = GetYHalfLength2();
G4double fDx3 = GetXHalfLength3();
G4double fDx4 = GetXHalfLength4();
G4double phi = GetPhi();
G4double theta = GetTheta();
G4double fTalpha1 = GetTanAlpha1();
G4double fTalpha2 = GetTanAlpha2();
G4double DzTthetaCphi = fDz*std::tan(theta)*std::cos(phi);
G4double DzTthetaSphi = fDz*std::tan(theta)*std::sin(phi);
G4double Dy1Talpha1 = fDy1*fTalpha1;
G4double Dy2Talpha2 = fDy2*fTalpha2;
pt[0].set(-DzTthetaCphi-Dy1Talpha1-fDx1,-DzTthetaSphi-fDy1,-fDz);
pt[1].set(-DzTthetaCphi-Dy1Talpha1+fDx1,-DzTthetaSphi-fDy1,-fDz);
pt[2].set(-DzTthetaCphi+Dy1Talpha1-fDx2,-DzTthetaSphi+fDy1,-fDz);
pt[3].set(-DzTthetaCphi+Dy1Talpha1+fDx2,-DzTthetaSphi+fDy1,-fDz);
pt[4].set( DzTthetaCphi-Dy2Talpha2-fDx3, DzTthetaSphi-fDy2, fDz);
pt[5].set( DzTthetaCphi-Dy2Talpha2+fDx3, DzTthetaSphi-fDy2, fDz);
pt[6].set( DzTthetaCphi+Dy2Talpha2-fDx4, DzTthetaSphi+fDy2, fDz);
pt[7].set( DzTthetaCphi+Dy2Talpha2+fDx4, DzTthetaSphi+fDy2, fDz);
}
/////////////////////////////////////////////////////////////////////////
//
// Check planarity of lateral planes
//
void G4UTrap::CheckPlanarity(const G4ThreeVector pt[8]) const
{
constexpr G4int iface[4][4] = { {0,4,5,1}, {2,3,7,6}, {0,2,6,4}, {1,5,7,3} };
const static G4String side[4] = { "~-Y", "~+Y", "~-X", "~+X" };
for (G4int i=0; i<4; ++i)
{
TrapSidePlane plane = GetSidePlane(i);
G4double dmax = 0;
for (G4int k=0; k<4; ++k)
{
const G4ThreeVector p = pt[iface[i][k]];
G4double dist = plane.a*p.x() + plane.b*p.y() + plane.c*p.z() + plane.d;
if (std::abs(dist) > std::abs(dmax)) dmax = dist;
}
if (std::abs(dmax) > 1000 * kCarTolerance)
{
std::ostringstream message;
message << "Side face " << side[i] << " is not planar for solid: "
<< GetName() << "\nDiscrepancy: " << dmax/mm << " mm\n";
StreamInfo(message);
G4Exception("G4UTrap::CheckPlanarity()", "GeomSolids0002",
FatalException, message);
}
}
}
/////////////////////////////////////////////////////////////////////////
//
// Dispatch to parameterisation for replication mechanism dimension
@@ -402,18 +542,11 @@ G4UTrap::CalculateExtent(const EAxis pAxis,
//
G4Polyhedron* G4UTrap::CreatePolyhedron() const
{
G4double fTthetaSphi = GetThetaSphi();
G4double fTthetaCphi = GetThetaCphi();
G4double phi = std::atan2(fTthetaSphi, fTthetaCphi);
G4double alpha1 = std::atan(GetTanAlpha1());
G4double alpha2 = std::atan(GetTanAlpha2());
G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi+fTthetaSphi*fTthetaSphi));
return new G4PolyhedronTrap(GetZHalfLength(), theta, phi,
return new G4PolyhedronTrap(GetZHalfLength(), GetTheta(), GetPhi(),
GetYHalfLength1(),
GetXHalfLength1(), GetXHalfLength2(), alpha1,
GetXHalfLength1(), GetXHalfLength2(), GetAlpha1(),
GetYHalfLength2(),
GetXHalfLength3(), GetXHalfLength4(), alpha2);
GetXHalfLength3(), GetXHalfLength4(), GetAlpha2());
}
#endif // G4GEOM_USE_USOLIDS
+29
View File
@@ -16,6 +16,35 @@ committal in the source repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
03-December-2021 E.Tcherniaev (geom-specific-V10-07-13)
- G4TwistedTubs: Accurate calculation of the bounding box in
BoundingLimits() and GetExtent(), fixing measured performance
penalty. Addressing problem report #2450.
- G4TwistedTubs, G4VTwistedFaceted: Fixed GetCubicVolume()
15-October-2021 E.Tcherniaev (geom-specific-V10-07-12)
- G4Tet, G4UTet: Added SetBoundingLimits()
06-October-2021 E.Tcherniaev (geom-specific-V10-07-11)
- G4Tet: some changes in calculation of bounding box
- G4UTet: added CheckDegeneracy() and SetVertices()
27-September-2021 E.Tcherniaev (geom-specific-V10-07-10)
- Added degeneracyFlag to the list of parameters of G4Tet::SetVertices(),
it addresses first part of the problem report #2427
24-September-2021 E.Tcherniaev (geom-specific-V10-07-09)
- Implemented G4TesselatedSolid::GetFacetIndex(p)
10-September-2021 E.Tcherniaev (geom-specific-V10-07-08)
- Implemented G4TesselatedSolid::CheckStructure()
- Optimisation in G4TessellatedSolid::SetExtremeFacets():
shuffle of vertices and checking of six extreme vertices
21-July-2021 E.Tcherniaev (geom-specific-V10-07-07)
- More accurate calculation of distance from point to triangle
in G4TriangularFacet, it addresses problem report #2401
25-June-2021 G.Cosmo (geom-specific-V10-07-06)
- Added missing accessor in G4UTet.
@@ -146,6 +146,7 @@ class G4TessellatedSolid : public G4VSolid
inline G4VFacet* GetFacet (G4int i) const;
G4int GetNumberOfFacets () const;
G4int GetFacetIndex (const G4ThreeVector& p) const;
virtual EInside Inside (const G4ThreeVector& p) const;
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const;
@@ -176,6 +177,7 @@ class G4TessellatedSolid : public G4VSolid
void SetSolidClosed (const G4bool t);
G4bool GetSolidClosed () const;
G4int CheckStructure() const;
inline void SetMaxVoxels(G4int max);
@@ -72,7 +72,8 @@ class G4Tet : public G4VSolid
void SetVertices(const G4ThreeVector& anchor,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3);
const G4ThreeVector& p3,
G4bool* degeneracyFlag = nullptr);
// Accessors, return the four vertices of the shape
void GetVertices(G4ThreeVector& anchor,
@@ -95,6 +96,7 @@ class G4Tet : public G4VSolid
const G4int n,
const G4VPhysicalVolume* pRep);
void SetBoundingLimits(const G4ThreeVector& pMin, const G4ThreeVector& pMax);
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
@@ -27,14 +27,15 @@
//
// Class description:
//
// G4TwistedTubs is a sort of twisted cylinder.
// G4TwistedTubs is a sector of a twisted hollow cylinder.
// A twisted cylinder which is placed along with z-axis and is
// separated into phi-segments should become a hyperboloid, and
// its each segmented piece should be tilted with a stereo angle.
// its each segmented piece should be tilted with a stereo angle.
// G4TwistedTubs is a G4VSolid.
// It can have inner & outer surfaces as well as G4TwistedTubs,
// but cannot has different stereo angles between the inner surface
// and outer surface.
//
// Details of the implementation: "Development of a Geant4 solid
// for stereo mini-jet cells in a cylindrical drift chamber",
// Computer Physics Communications 153 (2003) pp.373391
// 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepburn.s.chiba-u.ac.jp), created.
// 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), Integration in Geant4
@@ -50,11 +50,11 @@ class G4UTet : public G4UAdapter<vecgeom::UnplacedTet>
public: // with description
G4UTet(const G4String& pName,
G4ThreeVector anchor,
G4ThreeVector p2,
G4ThreeVector p3,
G4ThreeVector p4,
G4UTet(const G4String& pName,
const G4ThreeVector& anchor,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3,
G4bool* degeneracyFlag = nullptr);
~G4UTet();
@@ -75,9 +75,10 @@ class G4UTet : public G4UAdapter<vecgeom::UnplacedTet>
// persistifiable objects.
G4UTet(const G4UTet& rhs);
G4UTet& operator=(const G4UTet& rhs);
G4UTet& operator=(const G4UTet& rhs);
// Copy constructor and assignment operator.
void SetBoundingLimits(const G4ThreeVector& pMin, const G4ThreeVector& pMax);
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
G4bool CalculateExtent(const EAxis pAxis,
@@ -87,12 +88,29 @@ class G4UTet : public G4UAdapter<vecgeom::UnplacedTet>
G4Polyhedron* CreatePolyhedron() const;
void SetVertices(const G4ThreeVector& anchor,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3,
G4bool* degeneracyFlag = nullptr);
// Set new position of the vertices.
void GetVertices(G4ThreeVector& anchor,
G4ThreeVector& p1,
G4ThreeVector& p2,
G4ThreeVector& p3) const;
std::vector<G4ThreeVector> GetVertices() const;
// Return the four vertices of the shape.
G4bool CheckDegeneracy(const G4ThreeVector& p0,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3) const;
// Return true if the tetrahedron is degenerate.
private:
G4ThreeVector fBmin, fBmax; // bounding box
};
// --------------------------------------------------------------------
@@ -297,9 +297,11 @@ class G4VTwistedFaceted: public G4VSolid
inline
G4double G4VTwistedFaceted::GetCubicVolume()
{
if(fCubicVolume != 0.) ;
else fCubicVolume = 2 * fDz
* ( ( fDx1 + fDx2 ) * fDy1 + ( fDx3 + fDx4 ) * fDy2 );
if(fCubicVolume == 0.)
{
fCubicVolume = ((fDx1 + fDx2 + fDx3 + fDx4)*(fDy1 + fDy2) +
(fDx4 + fDx3 - fDx2 - fDx1)*(fDy2 - fDy1)/3)*fDz;
}
return fCubicVolume;
}
@@ -38,7 +38,7 @@
// 12.10.2012, M Gayer, CERN, complete rewrite reducing memory
// requirements more than 50% and speedup by a factor of
// tens or more depending on the number of facets, thanks
// to voxelization of surface and improvements.
// to voxelization of surface and improvements.
// Speedup factor of thousands for solids with number of
// facets in hundreds of thousands.
// 23.10.2016, E Tcherniaev, reimplemented CalculateExtent() to make
@@ -56,6 +56,7 @@
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include "geomdefs.hh"
#include "Randomize.hh"
@@ -248,7 +249,7 @@ G4bool G4TessellatedSolid::AddFacet (G4VFacet* aFacet)
{
--it;
G4int id = (*it).id;
G4VFacet *facet = fFacets[id];
G4VFacet *facet = fFacets[id];
G4ThreeVector q = facet->GetCircumcentre();
found = (facet == aFacet);
if (found) break;
@@ -268,7 +269,7 @@ G4bool G4TessellatedSolid::AddFacet (G4VFacet* aFacet)
else
{
G4Exception("G4TessellatedSolid::AddFacet()", "GeomSolids1002",
JustWarning, "Attempt to add facet not properly defined.");
JustWarning, "Attempt to add facet not properly defined.");
aFacet->StreamInfo(G4cout);
return false;
}
@@ -392,21 +393,52 @@ void G4TessellatedSolid::Voxelize ()
// returns true. So will this work?? Need non-equality
// "G4bool inside = displacement < 0.0;"
// or
// "G4bool inside = displacement <= -0.5*kCarTolerance"
// "G4bool inside = displacement <= -0.5*kCarTolerance"
// (Notes from PT 13/08/2007).
//
void G4TessellatedSolid::SetExtremeFacets()
{
// Copy vertices to local array
G4int vsize = fVertexList.size();
std::vector<G4ThreeVector> vertices(vsize);
for (G4int i = 0; i < vsize; ++i) { vertices[i] = fVertexList[i]; }
// Shuffle vertices
std::mt19937 gen(12345678);
std::shuffle(vertices.begin(), vertices.end(), gen);
// Select six extreme vertices in different directions
G4ThreeVector points[6];
for (G4int i=0; i < 6; ++i) { points[i] = vertices[0]; }
for (G4int i=1; i < vsize; ++i)
{
if (vertices[i].x() < points[0].x()) points[0] = vertices[i];
if (vertices[i].x() > points[1].x()) points[1] = vertices[i];
if (vertices[i].y() < points[2].y()) points[2] = vertices[i];
if (vertices[i].y() > points[3].y()) points[3] = vertices[i];
if (vertices[i].z() < points[4].z()) points[4] = vertices[i];
if (vertices[i].z() > points[5].z()) points[5] = vertices[i];
}
// Find extreme facets
G4int size = fFacets.size();
for (G4int j = 0; j < size; ++j)
{
G4VFacet &facet = *fFacets[j];
// Check extreme vertices
if (!facet.IsInside(points[0])) continue;
if (!facet.IsInside(points[1])) continue;
if (!facet.IsInside(points[2])) continue;
if (!facet.IsInside(points[3])) continue;
if (!facet.IsInside(points[4])) continue;
if (!facet.IsInside(points[5])) continue;
// Check vertices
G4bool isExtreme = true;
G4int vsize = fVertexList.size();
for (G4int i=0; i < vsize; ++i)
{
if (!facet.IsInside(fVertexList[i]))
if (!facet.IsInside(vertices[i]))
{
isExtreme = false;
break;
@@ -442,7 +474,7 @@ void G4TessellatedSolid::CreateVertexList()
G4double kCarTolerance24 = kCarTolerance * kCarTolerance / 4.0;
G4double kCarTolerance3 = 3 * kCarTolerance;
vector<G4int> newIndex(100);
for (G4int k = 0; k < size; ++k)
{
G4VFacet &facet = *fFacets[k];
@@ -505,7 +537,7 @@ void G4TessellatedSolid::CreateVertexList()
//
// Now update the maximum x, y and z limits of the volume.
//
if (value.id == 0) fMinExtent = fMaxExtent = p;
if (value.id == 0) fMinExtent = fMaxExtent = p;
else
{
if (p.x() > fMaxExtent.x()) fMaxExtent.setX(p.x());
@@ -534,7 +566,7 @@ void G4TessellatedSolid::CreateVertexList()
facet.SetVertexIndex(i,newIndex[i]);
}
vector<G4ThreeVector>(fVertexList).swap(fVertexList);
#ifdef G4SPECSDEBUG
G4double previousValue = 0.;
for (auto res=vertexListSorted.cbegin(); res!=vertexListSorted.cend(); ++res)
@@ -543,7 +575,7 @@ void G4TessellatedSolid::CreateVertexList()
G4ThreeVector vec = fVertexList[id];
G4double mvalue = vec.x() + vec.y() + vec.z();
if (previousValue && (previousValue - 1e-9 > mvalue))
G4cout << "Error in CreateVertexList: previousValue " << previousValue
G4cout << "Error in CreateVertexList: previousValue " << previousValue
<< " is smaller than mvalue " << mvalue << G4endl;
previousValue = mvalue;
}
@@ -558,7 +590,7 @@ void G4TessellatedSolid::DisplayAllocatedMemory()
G4int with = AllocatedMemory();
G4double ratio = (G4double) with / without;
G4cout << "G4TessellatedSolid - Allocated memory without voxel overhead "
<< without << "; with " << with << "; ratio: " << ratio << G4endl;
<< without << "; with " << with << "; ratio: " << ratio << G4endl;
}
///////////////////////////////////////////////////////////////////////////////
@@ -567,17 +599,17 @@ void G4TessellatedSolid::SetSolidClosed (const G4bool t)
{
if (t)
{
#ifdef G4SPECSDEBUG
#ifdef G4SPECSDEBUG
G4cout << "Creating vertex list..." << G4endl;
#endif
CreateVertexList();
#ifdef G4SPECSDEBUG
#ifdef G4SPECSDEBUG
G4cout << "Setting extreme facets..." << G4endl;
#endif
SetExtremeFacets();
#ifdef G4SPECSDEBUG
#ifdef G4SPECSDEBUG
G4cout << "Voxelizing..." << G4endl;
#endif
Voxelize();
@@ -586,7 +618,38 @@ void G4TessellatedSolid::SetSolidClosed (const G4bool t)
DisplayAllocatedMemory();
#endif
}
#ifdef G4SPECSDEBUG
G4cout << "Checking Structure..." << G4endl;
#endif
G4int irep = CheckStructure();
if (irep != 0)
{
if (irep & 1)
{
std::ostringstream message;
message << "Defects in solid: " << GetName()
<< " - negative cubic volume, please check orientation of facets!";
G4Exception("G4TessellatedSolid::SetSolidClosed()",
"GeomSolids1001", JustWarning, message);
}
if (irep & 2)
{
std::ostringstream message;
message << "Defects in solid: " << GetName()
<< " - some facets have wrong orientation!";
G4Exception("G4TessellatedSolid::SetSolidClosed()",
"GeomSolids1001", JustWarning, message);
}
if (irep & 4)
{
std::ostringstream message;
message << "Defects in solid: " << GetName()
<< " - there are holes in the surface!";
G4Exception("G4TessellatedSolid::SetSolidClosed()",
"GeomSolids1001", JustWarning, message);
}
}
}
fSolidClosed = t;
}
@@ -601,6 +664,77 @@ G4bool G4TessellatedSolid::GetSolidClosed () const
return fSolidClosed;
}
///////////////////////////////////////////////////////////////////////////////
//
// CheckStructure
//
// Checks structure of the solid. Return value is a sum of the following
// defect indicators, if any (0 means no defects):
// 1 - cubic volume is negative, wrong orientation of facets
// 2 - some facets have wrong orientation
// 4 - holes in the surface
//
G4int G4TessellatedSolid::CheckStructure() const
{
G4int nedge = 0;
G4int nface = fFacets.size();
// Calculate volume
//
G4double volume = 0.;
for (G4int i = 0; i < nface; ++i)
{
G4VFacet& facet = *fFacets[i];
nedge += facet.GetNumberOfVertices();
volume += facet.GetArea()*(facet.GetVertex(0).dot(facet.GetSurfaceNormal()));
}
G4int ivolume = (volume <= 0.);
// Create sorted vector of edges
//
std::vector<int64_t> iedge(nedge);
G4int kk = 0;
for (G4int i = 0; i < nface; ++i)
{
G4VFacet& facet = *fFacets[i];
G4int nnode = facet.GetNumberOfVertices();
for (G4int k = 0; k < nnode; ++k)
{
int64_t i1 = facet.GetVertexIndex((k == 0) ? nnode - 1 : k - 1);
int64_t i2 = facet.GetVertexIndex(k);
int64_t inverse = (i2 > i1);
if (inverse) std::swap(i1, i2);
iedge[kk++] = i1*1000000000 + i2*2 + inverse;
}
}
std::sort(iedge.begin(), iedge.end());
// Check edges, correct structure should consist of paired edges
// with different orientation
//
G4int iorder = 0;
G4int ihole = 0;
G4int i = 0;
while (i < nedge - 1)
{
if (iedge[i + 1] - iedge[i] == 1) // paired edges with different orientation
{
i += 2;
}
else if (iedge[i + 1] == iedge[i]) // paired edges with the same orientation
{
iorder = 2;
i += 2;
}
else // unpaired edge
{
ihole = 4;
i++;
}
}
return ivolume + iorder + ihole;
}
///////////////////////////////////////////////////////////////////////////////
//
// operator+=
@@ -722,7 +856,7 @@ EInside G4TessellatedSolid::InsideVoxels(const G4ThreeVector& p) const
started ? startingCandidates : fVoxels.GetCandidates(curVoxel);
started = false;
if (G4int candidatesCount = candidates.size())
{
{
for (G4int i = 0 ; i < candidatesCount; ++i)
{
G4int candidate = candidates[i];
@@ -741,9 +875,9 @@ EInside G4TessellatedSolid::InsideVoxels(const G4ThreeVector& p) const
|| (crossingI && std::fabs(normalI.dot(v))<dirTolerance);
if (!nearParallel)
{
if (crossingO && distO > 0.0 && distO < distOut)
if (crossingO && distO > 0.0 && distO < distOut)
distOut = distO;
if (crossingI && distI > 0.0 && distI < distIn)
if (crossingI && distI > 0.0 && distI < distIn)
distIn = distI;
}
else break;
@@ -819,7 +953,7 @@ EInside G4TessellatedSolid::InsideVoxels(const G4ThreeVector& p) const
return location;
}
///////////////////////////////////////////////////////////////////////////////
//
EInside G4TessellatedSolid::InsideNoVoxels (const G4ThreeVector &p) const
@@ -963,6 +1097,55 @@ EInside G4TessellatedSolid::InsideNoVoxels (const G4ThreeVector &p) const
return location;
}
///////////////////////////////////////////////////////////////////////////////
//
// Return index of the facet closest to the point p, normally the point should
// be located on the surface. Return -1 if no facet selected.
//
G4int G4TessellatedSolid::GetFacetIndex (const G4ThreeVector& p) const
{
G4int index = -1;
if (fVoxels.GetCountOfVoxels() > 1)
{
vector<G4int> curVoxel(3);
fVoxels.GetVoxel(curVoxel, p);
const vector<G4int> &candidates = fVoxels.GetCandidates(curVoxel);
if (G4int limit = candidates.size())
{
G4double minDist = kInfinity;
for(G4int i = 0 ; i < limit ; ++i)
{
G4int candidate = candidates[i];
G4VFacet& facet = *fFacets[candidate];
G4double dist = facet.Distance(p, minDist);
if (dist <= kCarToleranceHalf) return index = candidate;
if (dist < minDist)
{
minDist = dist;
index = candidate;
}
}
}
}
else
{
G4double minDist = kInfinity;
G4int size = fFacets.size();
for (G4int i = 0; i < size; ++i)
{
G4VFacet& facet = *fFacets[i];
G4double dist = facet.Distance(p, minDist);
if (dist < minDist)
{
minDist = dist;
index = i;
}
}
}
return index;
}
///////////////////////////////////////////////////////////////////////////////
//
// Return the outwards pointing unit normal of the shape for the
@@ -985,7 +1168,7 @@ G4bool G4TessellatedSolid::Normal (const G4ThreeVector& p,
{
minDist = kInfinity;
for(G4int i = 0 ; i < limit ; ++i)
{
{
G4int candidate = candidates[i];
G4VFacet &fct = *fFacets[candidate];
G4double dist = fct.Distance(p,minDist);
@@ -1257,8 +1440,8 @@ G4TessellatedSolid::DistanceToOutCore(const G4ThreeVector& aPoint,
if (old != &candidates && candidates.size())
{
DistanceToOutCandidates(candidates, aPoint, direction, minDistance,
aNormalVector, minCandidate);
if (minDistance <= totalShift) break;
aNormalVector, minCandidate);
if (minDistance <= totalShift) break;
}
G4double shift=fVoxels.DistanceToNext(currentPoint, direction, curVoxel);
@@ -1306,7 +1489,7 @@ DistanceToInCandidates(const std::vector<G4int>& candidates,
G4double distFromSurface = 0.0;
G4ThreeVector normal;
G4double minDistance = kInfinity;
G4double minDistance = kInfinity;
for (G4int i = 0 ; i < candidatesCount; ++i)
{
G4int candidate = candidates[i];
@@ -1334,7 +1517,7 @@ DistanceToInCandidates(const std::vector<G4int>& candidates,
else if (distFromSurface > -kCarToleranceHalf
&& distFromSurface < kCarToleranceHalf)
{
minDistance = dist;
minDistance = dist;
}
}
}
@@ -1359,7 +1542,7 @@ G4TessellatedSolid::DistanceToInCore(const G4ThreeVector& aPoint,
G4double shift = fVoxels.DistanceToFirst(currentPoint, direction);
if (shift == kInfinity) return shift;
G4double shiftBonus = kCarTolerance;
if (shift)
if (shift)
currentPoint += direction * (shift + shiftBonus);
// if (!fVoxels.Contains(currentPoint)) return minDistance;
G4double totalShift = shift;
@@ -1416,7 +1599,7 @@ G4TessellatedSolid::MinDistanceFacet(const G4ThreeVector& p,
G4int size = fVoxels.GetVoxelBoxesSize();
vector<pair<G4int, G4double> > voxelsSorted(size);
pair<G4int, G4double> info;
for (G4int i = 0; i < size; ++i)
@@ -1519,7 +1702,7 @@ G4double G4TessellatedSolid::SafetyFromOutside (const G4ThreeVector& p,
//
G4double
G4TessellatedSolid::SafetyFromInside (const G4ThreeVector& p, G4bool) const
{
{
#if G4SPECSDEBUG
if ( Inside(p) == kOutside )
{
@@ -1767,7 +1950,7 @@ G4Polyhedron *G4TessellatedSolid::CreatePolyhedron () const
}
polyhedron->AddFacet(v[0],v[1],v[2],v[3]);
}
polyhedron->SetReferences();
polyhedron->SetReferences();
return (G4Polyhedron*) polyhedron;
}
+44 -3
View File
@@ -250,11 +250,15 @@ void G4Tet::Initialize(const G4ThreeVector& p0,
void G4Tet::SetVertices(const G4ThreeVector& p0,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3)
const G4ThreeVector& p3, G4bool* degeneracyFlag)
{
// Check for degeneracy
G4bool degenerate = CheckDegeneracy(p0, p1, p2, p3);
if (degenerate)
if (degeneracyFlag)
{
*degeneracyFlag = degenerate;
}
else if (degenerate)
{
std::ostringstream message;
message << "Degenerate tetrahedron is not permitted: " << GetName() << " !\n"
@@ -264,7 +268,7 @@ void G4Tet::SetVertices(const G4ThreeVector& p0,
<< " p3 : " << p3 << "\n"
<< " volume: "
<< std::abs((p1 - p0).cross(p2 - p0).dot(p3 - p0))/6.;
G4Exception("G4Tet::G4SetVertices()", "GeomSolids0002",
G4Exception("G4Tet::SetVertices()", "GeomSolids0002",
FatalException, message);
}
@@ -312,6 +316,43 @@ void G4Tet::ComputeDimensions(G4VPVParameterisation* ,
{
}
////////////////////////////////////////////////////////////////////////
//
// Set bounding box
//
void G4Tet::SetBoundingLimits(const G4ThreeVector& pMin,
const G4ThreeVector& pMax)
{
G4int iout[4] = { 0, 0, 0, 0 };
for (G4int i = 0; i < 4; ++i)
{
iout[i] = (fVertex[i].x() < pMin.x() ||
fVertex[i].y() < pMin.y() ||
fVertex[i].z() < pMin.z() ||
fVertex[i].x() > pMax.x() ||
fVertex[i].y() > pMax.y() ||
fVertex[i].z() > pMax.z());
}
if (iout[0] + iout[1] + iout[2] + iout[3] != 0)
{
std::ostringstream message;
message << "Attempt to set bounding box that does not encapsulate solid: "
<< GetName() << " !\n"
<< " Specified bounding box limits:\n"
<< " pmin: " << pMin << "\n"
<< " pmax: " << pMax << "\n"
<< " Tetrahedron vertices:\n"
<< " anchor " << fVertex[0] << ((iout[0]) ? " is outside\n" : "\n")
<< " p1 " << fVertex[1] << ((iout[1]) ? " is outside\n" : "\n")
<< " p2 " << fVertex[2] << ((iout[2]) ? " is outside\n" : "\n")
<< " p3 " << fVertex[3] << ((iout[3]) ? " is outside" : "");
G4Exception("G4Tet::SetBoundingLimits()", "GeomSolids0002",
FatalException, message);
}
fBmin = pMin;
fBmax = pMax;
}
////////////////////////////////////////////////////////////////////////
//
// Return bounding box
@@ -346,9 +346,9 @@ G4ThreeVector G4TriangularFacet::Distance (const G4ThreeVector& p)
//
// We are in region 0.
//
q = q / fDet;
t = t / fDet;
fSqrDist = q*(fA*q + fB*t + 2.0*d) + t*(fB*q + fC*t + 2.0*e) + f;
G4double dist = fSurfaceNormal.dot(D);
fSqrDist = dist*dist;
return fSurfaceNormal*dist;
}
}
else
@@ -32,6 +32,7 @@
#include "G4TwistedTubs.hh"
#include "G4GeomTools.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "G4GeometryTolerance.hh"
@@ -308,10 +309,31 @@ void G4TwistedTubs::ComputeDimensions(G4VPVParameterisation* /* p */ ,
void G4TwistedTubs::BoundingLimits(G4ThreeVector& pMin,
G4ThreeVector& pMax) const
{
G4double maxEndOuterRad = (fEndOuterRadius[0] > fEndOuterRadius[1] ?
fEndOuterRadius[0] : fEndOuterRadius[1]);
pMin.set(-maxEndOuterRad,-maxEndOuterRad,-fZHalfLength);
pMax.set( maxEndOuterRad, maxEndOuterRad, fZHalfLength);
// Find bounding tube
G4double rmin = GetInnerRadius();
G4double rmax = GetEndOuterRadius();
G4double zmin = std::min(GetEndZ(0), GetEndZ(1));
G4double zmax = std::max(GetEndZ(0), GetEndZ(1));
G4double dphi = 0.5*GetDPhi();
G4double sphi = std::min(GetEndPhi(0), GetEndPhi(1)) - dphi;
G4double ephi = std::max(GetEndPhi(0), GetEndPhi(1)) + dphi;
G4double totalphi = ephi - sphi;
// Find bounding box
if (dphi <= 0 || totalphi >= CLHEP::twopi)
{
pMin.set(-rmax,-rmax, zmin);
pMax.set( rmax, rmax, zmax);
}
else
{
G4TwoVector vmin,vmax;
G4GeomTools::DiskExtent(rmin, rmax, sphi, totalphi, vmin, vmax);
pMin.set(vmin.x(), vmin.y(), zmin);
pMax.set(vmax.x(), vmax.y(), zmax);
}
// Check correctness of the bounding box
//
@@ -859,15 +881,15 @@ void G4TwistedTubs::DescribeYourselfTo (G4VGraphicsScene& scene) const
//=====================================================================
//* GetExtent ---------------------------------------------------------
G4VisExtent G4TwistedTubs::GetExtent() const
G4VisExtent G4TwistedTubs::GetExtent() const
{
// Define the sides of the box into which the G4Tubs instance would fit.
G4double maxEndOuterRad = (fEndOuterRadius[0] > fEndOuterRadius[1] ?
fEndOuterRadius[0] : fEndOuterRadius[1]);
return G4VisExtent( -maxEndOuterRad, maxEndOuterRad,
-maxEndOuterRad, maxEndOuterRad,
-fZHalfLength, fZHalfLength );
//
G4ThreeVector pmin,pmax;
BoundingLimits(pmin,pmax);
return G4VisExtent(pmin.x(),pmax.x(),
pmin.y(),pmax.y(),
pmin.z(),pmax.z());
}
//=====================================================================
@@ -1008,9 +1030,23 @@ G4VSolid* G4TwistedTubs::Clone() const
G4double G4TwistedTubs::GetCubicVolume()
{
if(fCubicVolume != 0.) {;}
else { fCubicVolume = fDPhi*fZHalfLength*(fOuterRadius*fOuterRadius
-fInnerRadius*fInnerRadius); }
if (fCubicVolume == 0.)
{
G4double DPhi = GetDPhi();
G4double Z0 = GetEndZ(0);
G4double Z1 = GetEndZ(1);
G4double Ain = GetInnerRadius();
G4double Aout = GetOuterRadius();
G4double R0in = GetEndInnerRadius(0);
G4double R1in = GetEndInnerRadius(1);
G4double R0out = GetEndOuterRadius(0);
G4double R1out = GetEndOuterRadius(1);
// V_hyperboloid = pi*h*(2*a*a + R*R)/3
fCubicVolume = (2.*(Z1 - Z0)*(Aout + Ain)*(Aout - Ain)
+ Z1*(R1out + R1in)*(R1out - R1in)
- Z0*(R0out + R0in)*(R0out - R0in))*DPhi/6.;
}
return fCubicVolume;
}
@@ -1019,8 +1055,7 @@ G4double G4TwistedTubs::GetCubicVolume()
G4double G4TwistedTubs::GetSurfaceArea()
{
if(fSurfaceArea != 0.) {;}
else { fSurfaceArea = G4VSolid::GetSurfaceArea(); }
if (fSurfaceArea == 0.) fSurfaceArea = G4VSolid::GetSurfaceArea();
return fSurfaceArea;
}
+124 -56
View File
@@ -22,7 +22,7 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// Implementation for G4UTet wrapper class
//
// 1.11.13 G.Cosmo, CERN
@@ -49,44 +49,30 @@ using namespace CLHEP;
// A Tet has all of its geometrical information precomputed
//
G4UTet::G4UTet(const G4String& pName,
G4ThreeVector anchor,
G4ThreeVector p2,
G4ThreeVector p3,
G4ThreeVector p4, G4bool* degeneracyFlag)
const G4ThreeVector& anchor,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3, G4bool* degeneracyFlag)
: Base_t(pName, U3Vector(anchor.x(),anchor.y(),anchor.z()),
U3Vector(p1.x(), p1.y(), p1.z()),
U3Vector(p2.x(), p2.y(), p2.z()),
U3Vector(p3.x(), p3.y(), p3.z()),
U3Vector(p4.x(), p4.y(), p4.z()))
U3Vector(p3.x(), p3.y(), p3.z()))
{
G4double fXMin=std::min(std::min(std::min(anchor.x(), p2.x()),p3.x()),p4.x());
G4double fXMax=std::max(std::max(std::max(anchor.x(), p2.x()),p3.x()),p4.x());
G4double fYMin=std::min(std::min(std::min(anchor.y(), p2.y()),p3.y()),p4.y());
G4double fYMax=std::max(std::max(std::max(anchor.y(), p2.y()),p3.y()),p4.y());
G4double fZMin=std::min(std::min(std::min(anchor.z(), p2.z()),p3.z()),p4.z());
G4double fZMax=std::max(std::max(std::max(anchor.z(), p2.z()),p3.z()),p4.z());
G4ThreeVector fMiddle=G4ThreeVector(fXMax+fXMin,fYMax+fYMin,fZMax+fZMin)*0.5;
G4double fMaxSize=std::max(std::max(std::max((anchor-fMiddle).mag(),
(p2-fMiddle).mag()),
(p3-fMiddle).mag()),
(p4-fMiddle).mag());
// fV<x><y> is vector from vertex <y> to vertex <x>
//
G4ThreeVector fV21=p2-anchor;
G4ThreeVector fV31=p3-anchor;
G4ThreeVector fV41=p4-anchor;
// make sure this is a correctly oriented set of points for the tetrahedron
//
G4double signed_vol=fV21.cross(fV31).dot(fV41);
G4bool degenerate=std::fabs(signed_vol) < 1e-9*fMaxSize*fMaxSize*fMaxSize;
// Check for degeneracy
G4bool degenerate = CheckDegeneracy(anchor, p1, p2, p3);
if(degeneracyFlag) *degeneracyFlag = degenerate;
else if (degenerate)
{
G4Exception("G4UTet::G4UTet()", "GeomSolids0002", FatalException,
"Degenerate tetrahedron not allowed.");
}
// Set bounding box
for (G4int i = 0; i < 3; ++i)
{
fBmin[i] = std::min(std::min(std::min(anchor[i], p1[i]), p2[i]), p3[i]);
fBmax[i] = std::max(std::max(std::max(anchor[i], p1[i]), p2[i]), p3[i]);
}
}
//////////////////////////////////////////////////////////////////////////
@@ -114,6 +100,8 @@ G4UTet::~G4UTet()
G4UTet::G4UTet(const G4UTet& rhs)
: Base_t(rhs)
{
fBmin = rhs.fBmin;
fBmax = rhs.fBmax;
}
@@ -121,17 +109,50 @@ G4UTet::G4UTet(const G4UTet& rhs)
//
// Assignment operator
//
G4UTet& G4UTet::operator = (const G4UTet& rhs)
G4UTet& G4UTet::operator = (const G4UTet& rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Check assignment to self
if (this == &rhs) { return *this; }
// Copy base class data
//
Base_t::operator=(rhs);
// Copy base class data
Base_t::operator=(rhs);
return *this;
// Copy bounding box
fBmin = rhs.fBmin;
fBmax = rhs.fBmax;
return *this;
}
///////////////////////////////////////////////////////////////////////////////
//
// Return true if tetrahedron is degenerate
// Tetrahedron is concidered as degenerate in case if its minimal
// height is less than the degeneracy tolerance
//
G4bool G4UTet::CheckDegeneracy(const G4ThreeVector& p0,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3) const
{
G4double hmin = 4. * kCarTolerance; // degeneracy tolerance
// Calculate volume
G4double vol = std::abs((p1 - p0).cross(p2 - p0).dot(p3 - p0));
// Calculate face areas squared
G4double ss[4];
ss[0] = ((p1 - p0).cross(p2 - p0)).mag2();
ss[1] = ((p2 - p0).cross(p3 - p0)).mag2();
ss[2] = ((p3 - p0).cross(p1 - p0)).mag2();
ss[3] = ((p2 - p1).cross(p3 - p1)).mag2();
// Find face with max area
G4int k = 0;
for (G4int i = 1; i < 4; ++i) { if (ss[i] > ss[k]) k = i; }
// Check: vol^2 / s^2 <= hmin^2
return (vol*vol <= ss[k]*hmin*hmin);
}
////////////////////////////////////////////////////////////////////////
@@ -154,6 +175,29 @@ G4VSolid* G4UTet::Clone() const
return new G4UTet(*this);
}
///////////////////////////////////////////////////////////////////////////////
//
// Modifier
//
void G4UTet::SetVertices(const G4ThreeVector& anchor,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3,
G4bool* degeneracyFlag)
{
// Check for degeneracy
G4bool degenerate = CheckDegeneracy(anchor, p1, p2, p3);
if(degeneracyFlag) *degeneracyFlag = degenerate;
else if (degenerate)
{
G4Exception("G4UTet::SetVertices()", "GeomSolids0002", FatalException,
"Degenerate tetrahedron not allowed.");
}
// Change tetrahedron
*this = G4UTet(GetName(), anchor, p1, p2, p3, &degenerate);
}
///////////////////////////////////////////////////////////////////////////////
//
// Accessors
@@ -184,30 +228,54 @@ std::vector<G4ThreeVector> G4UTet::GetVertices() const
return vertices;
}
////////////////////////////////////////////////////////////////////////
//
// Set bounding box
//
void G4UTet::SetBoundingLimits(const G4ThreeVector& pMin,
const G4ThreeVector& pMax)
{
G4ThreeVector fVertex[4];
GetVertices(fVertex[0], fVertex[1], fVertex[2], fVertex[3]);
G4int iout[4] = { 0, 0, 0, 0 };
for (G4int i = 0; i < 4; ++i)
{
iout[i] = (fVertex[i].x() < pMin.x() ||
fVertex[i].y() < pMin.y() ||
fVertex[i].z() < pMin.z() ||
fVertex[i].x() > pMax.x() ||
fVertex[i].y() > pMax.y() ||
fVertex[i].z() > pMax.z());
}
if (iout[0] + iout[1] + iout[2] + iout[3] != 0)
{
std::ostringstream message;
message << "Attempt to set bounding box that does not encapsulate solid: "
<< GetName() << " !\n"
<< " Specified bounding box limits:\n"
<< " pmin: " << pMin << "\n"
<< " pmax: " << pMax << "\n"
<< " Tetrahedron vertices:\n"
<< " anchor " << fVertex[0] << ((iout[0]) ? " is outside\n" : "\n")
<< " p1 " << fVertex[1] << ((iout[1]) ? " is outside\n" : "\n")
<< " p2 " << fVertex[2] << ((iout[2]) ? " is outside\n" : "\n")
<< " p3 " << fVertex[3] << ((iout[3]) ? " is outside" : "");
G4Exception("G4UTet::SetBoundingLimits()", "GeomSolids0002",
FatalException, message);
}
fBmin = pMin;
fBmax = pMax;
}
//////////////////////////////////////////////////////////////////////////
//
// Get bounding box
void G4UTet::BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const
{
U3Vector vmin, vmax;
Base_t::Extent(vmin,vmax);
pMin.set(vmin.x(),vmin.y(),vmin.z());
pMax.set(vmax.x(),vmax.y(),vmax.z());
// 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("G4UTet::BoundingLimits()", "GeomMgt0001",
JustWarning, message);
StreamInfo(G4cout);
}
pMin = fBmin;
pMax = fBmax;
}
//////////////////////////////////////////////////////////////////////////

Some files were not shown because too many files have changed in this diff Show More