Import Geant4 8.3.0 source tree
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
$Id: History,v 1.113 2006/11/13 18:23:55 gcosmo Exp $
|
||||
$Id: History,v 1.117 2007/05/10 10:11:08 japost Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -16,6 +16,26 @@ committal in the CVS repository !
|
||||
----------------------------------------------------------
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
May 10th, 2007 J.Apostolakis - field-V08-02-01
|
||||
-------------------------------
|
||||
- G4MagIntegratorDriver:
|
||||
* added protections against zero initial or internal step h=0, (exceptions)
|
||||
* revised (re)calculation of h, and quit loop if h/length < smallest-fraction (~ 10^-12)
|
||||
|
||||
April 26th, 2007 T.Nikitina - field-V08-02-00
|
||||
----------------------------
|
||||
- Corrected integration constants in G4MagHelicalStepper
|
||||
- Added implementation of G4RKG3_Stepper, stepper derived from Geant3.
|
||||
- Updated NTST unit test. New unit test "field06" for comparison of steppers.
|
||||
|
||||
November 14th, 2006 J.Apostolakis - field-V08-01-02
|
||||
----------------------------------
|
||||
- G4MagIntegratorDriver
|
||||
* Made first argument of GetDerivatives a reference - avoid copy
|
||||
- G4MagIntegratorStepper
|
||||
* Include the SetEquationOfMotion() method in G4MagIntegratorStepper
|
||||
(for Geant4e, as in field-V08-01-00)
|
||||
* Update of disclaimers.
|
||||
|
||||
November 13th, 2006 G.Cosmo - field-V08-01-01
|
||||
----------------------------
|
||||
@@ -43,11 +63,6 @@ June 21st, 2006 J.Apostolakis - field-V08-00-06
|
||||
|
||||
--- The field-V08-00-0x , x > 6, tags do not include the change below
|
||||
|
||||
June 21st, 2006 J.Apostolakis - field-V08-01-00
|
||||
-----------------------------
|
||||
- G4MagIntegratorStepper
|
||||
Added SetEquationOfMotion method - needed for Geant4e
|
||||
|
||||
May 27th, 2006 J.Apostolakis - field-V08-00-05
|
||||
-----------------------------
|
||||
- G4FieldTrack: Fix for simple compilation error on Sun.
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4MagIntegratorDriver.hh,v 1.17 2006/06/29 18:22:58 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4MagIntegratorDriver.hh,v 1.20 2007/05/10 10:10:05 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// class G4MagInt_Driver
|
||||
@@ -91,7 +91,7 @@ class G4MagInt_Driver
|
||||
inline G4double GetPshrnk() const;
|
||||
inline G4double GetPgrow() const;
|
||||
inline G4double GetErrcon() const;
|
||||
inline void GetDerivatives( const G4FieldTrack y_curr, // const, INput
|
||||
inline void GetDerivatives( const G4FieldTrack &y_curr, // const, INput
|
||||
G4double dydx[] ); // OUTput
|
||||
// Accessors.
|
||||
|
||||
@@ -158,6 +158,9 @@ class G4MagInt_Driver
|
||||
inline void SetVerboseLevel(G4int newLevel);
|
||||
inline G4double GetVerboseLevel() const;
|
||||
|
||||
inline G4double GetSmallestFraction() const;
|
||||
void SetSmallestFraction( G4double val );
|
||||
|
||||
protected: // without description
|
||||
void WarnSmallStepSize( G4double hnext, G4double hstep,
|
||||
G4double h, G4double xDone,
|
||||
@@ -208,7 +211,11 @@ class G4MagInt_Driver
|
||||
private:
|
||||
|
||||
G4double fMinimumStep;
|
||||
// Minimum Step allowed in a Step.
|
||||
// Minimum Step allowed in a Step (in absolute units)
|
||||
G4double fSmallestFraction; // Expected range 1e-12 to 5e-15;
|
||||
// Smallest fraction of (existing) curve length - in relative units
|
||||
// below this fraction the current step will be the last
|
||||
|
||||
|
||||
const G4int fNoIntegrationVariables; // Number of Variables in integration
|
||||
const G4int fMinNoVars; // Minimum number for FieldTrack
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4MagIntegratorDriver.icc,v 1.11 2006/06/29 18:23:00 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4MagIntegratorDriver.icc,v 1.13 2007/05/10 10:10:48 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -142,7 +142,7 @@ void G4MagInt_Driver::SetMaxNoSteps(G4int val)
|
||||
}
|
||||
|
||||
inline
|
||||
void G4MagInt_Driver::GetDerivatives(const G4FieldTrack y_curr, // const, INput
|
||||
void G4MagInt_Driver::GetDerivatives(const G4FieldTrack &y_curr, // const, INput
|
||||
G4double dydx[]) // OUTput
|
||||
{
|
||||
G4double tmpValArr[G4FieldTrack::ncompSVEC];
|
||||
@@ -161,3 +161,9 @@ void G4MagInt_Driver::SetVerboseLevel(G4int newLevel)
|
||||
{
|
||||
fVerboseLevel= newLevel;
|
||||
}
|
||||
|
||||
inline
|
||||
G4double G4MagInt_Driver::GetSmallestFraction() const
|
||||
{
|
||||
return fSmallestFraction;
|
||||
}
|
||||
|
||||
@@ -23,9 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4MagIntegratorStepper.hh,v 1.10.2.1 2006/06/29 18:23:03 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4MagIntegratorStepper.hh,v 1.12 2006/09/20 09:31:01 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// class G4MagIntegratorStepper
|
||||
@@ -97,17 +96,7 @@ class G4MagIntegratorStepper
|
||||
inline G4EquationOfMotion *GetEquationOfMotion();
|
||||
// As some steppers (eg RKG3) require other methods of Eq_Rhs
|
||||
// this function allows for access to them.
|
||||
|
||||
public: // without description
|
||||
|
||||
#if 0
|
||||
void
|
||||
SetChargeAndMomentum( G4double particleCharge, // in e+ units
|
||||
G4double MomentumXc)
|
||||
// Supply the standard Evaluation of the Right Hand side
|
||||
// of the associated equation.
|
||||
{theEquation_Rhs -> SetChargeAndMomentum(particleCharge, MomentumXc);}
|
||||
#endif
|
||||
inline void SetEquationOfMotion(G4EquationOfMotion* newEquation);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -23,9 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4MagIntegratorStepper.icc,v 1.8.2.1 2006/06/29 18:23:05 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4MagIntegratorStepper.icc,v 1.10 2006/09/20 09:31:46 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
|
||||
inline
|
||||
@@ -34,6 +33,14 @@ G4EquationOfMotion* G4MagIntegratorStepper::GetEquationOfMotion()
|
||||
return fEquation_Rhs;
|
||||
}
|
||||
|
||||
inline void
|
||||
G4MagIntegratorStepper::SetEquationOfMotion(G4EquationOfMotion* newEquation)
|
||||
{
|
||||
if( newEquation != 0 ) {
|
||||
fEquation_Rhs= newEquation;
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4MagIntegratorStepper::GetNumberOfVariables() const
|
||||
{
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4MagHelicalStepper.cc,v 1.16 2006/06/29 18:24:20 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4MagHelicalStepper.cc,v 1.17 2007/04/26 06:26:54 tnikitin Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -58,8 +58,12 @@ G4MagHelicalStepper::AdvanceHelix( const G4double yIn[],
|
||||
G4double yHelix[]) const
|
||||
{
|
||||
// const G4int nvar = 6;
|
||||
const G4double approc_limit = 0.05;
|
||||
|
||||
//OLD const G4double approc_limit = 0.05;
|
||||
// OLD approc_limit = 0.05 gives max.error=x^5/5!=(0.05)^5/5!=2.6*e-9
|
||||
// NEW approc_limit = 0.005 gives max.error=x^5/5!=2.6*e-14
|
||||
|
||||
const G4double approc_limit = 0.005;
|
||||
G4ThreeVector Bnorm, B_x_P, vperp, vpar;
|
||||
// G4double norm;
|
||||
G4double B_d_P; // B_perp;
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4MagIntegratorDriver.cc,v 1.44 2006/06/29 18:24:23 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4MagIntegratorDriver.cc,v 1.46 2007/05/10 10:10:31 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -66,7 +66,8 @@ G4MagInt_Driver::G4MagInt_Driver( G4double hminimum,
|
||||
G4MagIntegratorStepper *pItsStepper,
|
||||
G4int numComponents,
|
||||
G4int statisticsVerbose)
|
||||
: fNoIntegrationVariables(numComponents),
|
||||
: fSmallestFraction( 1.0e-12 ),
|
||||
fNoIntegrationVariables(numComponents),
|
||||
fMinNoVars(12),
|
||||
fNoVars( std::max( fNoIntegrationVariables, fMinNoVars )),
|
||||
fVerboseLevel(0),
|
||||
@@ -143,16 +144,26 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
|
||||
G4double x1, x2;
|
||||
G4bool succeeded = true, lastStepSucceeded;
|
||||
|
||||
G4double startCurveLength;
|
||||
|
||||
G4int noFullIntegr=0, noSmallIntegr = 0 ;
|
||||
static G4int noGoodSteps =0 ; // Bad = chord > curve-len
|
||||
const int nvar= fNoVars;
|
||||
|
||||
G4FieldTrack yStartFT(y_current);
|
||||
|
||||
// Assume that hstep > 0
|
||||
// Ensure that hstep > 0
|
||||
if( hstep <= 0.0 ) {
|
||||
G4cerr << " Hstep is " << hstep << G4endl;
|
||||
G4Exception("G4MagInt_Driver::AccurateAdvance()",
|
||||
"Requested Integration Step is zero or negative: it must be positive",
|
||||
FatalException, "Requested-Step-not-Positive.");
|
||||
}
|
||||
|
||||
y_current.DumpToArray( ystart );
|
||||
x1= y_current.GetCurveLength();
|
||||
|
||||
startCurveLength= y_current.GetCurveLength();
|
||||
x1= startCurveLength;
|
||||
x2= x1 + hstep;
|
||||
|
||||
if( (hinitial > 0.0)
|
||||
@@ -182,13 +193,6 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
|
||||
|
||||
pIntStepper->RightHandSide( y, dydx );
|
||||
|
||||
if( x+h > x2 ) {
|
||||
h = x2 - x ; // When stepsize overshoots, decrease it!
|
||||
if( h < eps * hstep) {
|
||||
lastStep = true; // Avoid numerous small last steps
|
||||
}
|
||||
}
|
||||
|
||||
fNoTotalSteps++;
|
||||
// Perform the Integration
|
||||
//
|
||||
@@ -233,6 +237,10 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
|
||||
<< G4endl;
|
||||
}
|
||||
#endif
|
||||
if( h == 0.0 ) {
|
||||
G4Exception("G4MagInt_Driver::AccurateAdvance()", "Integration Step became Zero",
|
||||
FatalException, "IntegrationStepUnderflow.");
|
||||
}
|
||||
dyerr = dyerr_len / h;
|
||||
hdid= h;
|
||||
x += hdid;
|
||||
@@ -277,15 +285,23 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
|
||||
}
|
||||
// #endif
|
||||
|
||||
// Check the proposed next stepsize
|
||||
if(std::fabs(hnext) <= Hmin())
|
||||
{
|
||||
// Avoid numerous small last steps
|
||||
if( (h < eps * hstep) || (h < fSmallestFraction * startCurveLength) ) {
|
||||
// No more integration -- the next step will not happen
|
||||
lastStep = true;
|
||||
// fNoLastStep++;
|
||||
} else {
|
||||
|
||||
// Check the proposed next stepsize
|
||||
if(std::fabs(hnext) <= Hmin())
|
||||
{
|
||||
#ifdef G4DEBUG_FIELD
|
||||
// If simply a very small interval is being integrated, do not warn
|
||||
if( (x < x2 * (1-eps) ) && // The last step can be small: it's OK
|
||||
(std::fabs(hstep) > Hmin()) // and if we are asked, it's OK
|
||||
// && (hnext < hstep * PerThousand )
|
||||
){
|
||||
// If simply a very small interval is being integrated, do not warn
|
||||
if( (x < x2 * (1-eps) ) && // The last step can be small: it's OK
|
||||
(std::fabs(hstep) > Hmin()) // and if we are asked, it's OK
|
||||
// && (hnext < hstep * PerThousand )
|
||||
)
|
||||
{
|
||||
if(dbg>0){ // G4cerr << "Mid:SmallStep> ";
|
||||
WarnSmallStepSize( hnext, hstep, h, x-x1, nstp );
|
||||
PrintStatus( ystart, x1, y, x, hstep, no_warnings?nstp:-nstp);
|
||||
@@ -293,10 +309,29 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
|
||||
no_warnings++;
|
||||
}
|
||||
#endif
|
||||
// Make sure that the next step is at least Hmin.
|
||||
h = Hmin();
|
||||
}else{
|
||||
h = hnext ;
|
||||
// Make sure that the next step is at least Hmin.
|
||||
h = Hmin();
|
||||
}else{
|
||||
h = hnext ;
|
||||
}
|
||||
|
||||
// Ensure that the next step does not overshoot
|
||||
if( x+h > x2 ) {
|
||||
h = x2 - x ; // When stepsize overshoots, decrease it!
|
||||
// Must cope with difficult rounding-error issues if hstep << x2
|
||||
}
|
||||
// if( h < smallestFraction * startCurveLength )
|
||||
if( h == 0.0 ){
|
||||
// Cannot progress - accept this as last step - by default
|
||||
lastStep = true;
|
||||
#ifdef G4DEBUG_FIELD
|
||||
if(dbg){
|
||||
G4cout << "Warning: G4MagIntegratorDriver::AccurateAdvance" << G4endl
|
||||
<< " Integration step 'h' became " << h << " due to roundoff " << G4endl
|
||||
<< " Forcing termination of advance." << G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}while ( ((nstp++)<=fMaxNoSteps)
|
||||
@@ -908,3 +943,14 @@ void G4MagInt_Driver::PrintStatisticsReport()
|
||||
|
||||
G4cout.precision(oldPrec);
|
||||
}
|
||||
|
||||
void G4MagInt_Driver::SetSmallestFraction(G4double newFraction)
|
||||
{
|
||||
if( (newFraction > 1.e-16) && (newFraction < 1e-8) ) {
|
||||
fSmallestFraction= newFraction;
|
||||
}else{
|
||||
G4cerr << "Warning: SmallestFraction not changed. " << G4endl
|
||||
<< " Proposed value was " << newFraction << G4endl
|
||||
<< " Value must be between 1.e-8 and 1.e-16" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4RKG3_Stepper.cc,v 1.10 2006/06/29 18:24:48 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4RKG3_Stepper.cc,v 1.12 2007/04/26 12:23:55 tnikitin Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
G4RKG3_Stepper::G4RKG3_Stepper(G4Mag_EqRhs *EqRhs)
|
||||
: G4MagIntegratorStepper(EqRhs,6)
|
||||
{
|
||||
G4Exception("G4RKG3_Stepper::G4RKG3_Stepper()", "NotImplemented",
|
||||
FatalException, "Stepper not yet available.");
|
||||
// G4Exception("G4RKG3_Stepper::G4RKG3_Stepper()", "NotImplemented",
|
||||
// FatalException, "Stepper not yet available.");
|
||||
}
|
||||
|
||||
G4RKG3_Stepper::~G4RKG3_Stepper()
|
||||
@@ -128,6 +128,7 @@ void G4RKG3_Stepper::StepWithEst( const G4double*,
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
|
||||
// Integrator RK Stepper from G3 with only two field evaluation per Step.
|
||||
// It is used in propagation initial Step by small substeps after solution
|
||||
// error and delta geometry considerations. B[3] is magnetic field which
|
||||
@@ -140,62 +141,83 @@ void G4RKG3_Stepper::StepNoErr(const G4double tIn[7],
|
||||
G4double B[3] ) // const
|
||||
|
||||
{
|
||||
|
||||
// Copy and edit the routine above, to delete alpha2, beta2, ...
|
||||
G4double K1[7],K2[7],K3[7],K4[7] ;
|
||||
G4double tTemp[7], yderiv[6] ;
|
||||
// Need Momentum value to give correct values to the coefficients in equation
|
||||
// Integration on unit velocity, but tIn[3,4,5] is momentum
|
||||
G4double mom;
|
||||
G4int i ;
|
||||
|
||||
|
||||
#ifdef END_CODE_G3STEPPER
|
||||
G4Exception(" G4RKG3_Stepper::StepNoErr(): method to be no longer used.");
|
||||
#else
|
||||
|
||||
// GetEquationOfMotion()->EvaluateRhsReturnB(tIn,dydx,B1) ;
|
||||
|
||||
// Correction for momentum not a velocity
|
||||
mom=std::sqrt(tIn[3]*tIn[3]+tIn[4]*tIn[4]+tIn[5]*tIn[5]);
|
||||
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
K1[i] = Step * dydx[i+3];
|
||||
tTemp[i] = tIn[i] + Step*(0.5*tIn[i+3] + 0.125*K1[i]) ;
|
||||
tTemp[i+3] = tIn[i+3] + 0.5*K1[i] ;
|
||||
K1[i] = Step * dydx[i+3]/mom;
|
||||
tTemp[i] = tIn[i] + Step*(0.5*tIn[i+3]/mom + 0.125*K1[i]) ;
|
||||
tTemp[i+3] = tIn[i+3] + 0.5*K1[i]*mom ;
|
||||
|
||||
}
|
||||
|
||||
GetEquationOfMotion()->EvaluateRhsReturnB(tTemp,yderiv,B) ;
|
||||
// Calculates yderiv & returns B too!
|
||||
|
||||
|
||||
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
K2[i] = Step * yderiv[i+3];
|
||||
tTemp[i+3] = tIn[i+3] + 0.5*K2[i] ;
|
||||
K2[i] = Step * yderiv[i+3]/mom;
|
||||
tTemp[i+3] = tIn[i+3] + 0.5*K2[i]*mom ;
|
||||
}
|
||||
|
||||
|
||||
// Given B, calculate yderiv !
|
||||
GetEquationOfMotion()->EvaluateRhsGivenB(tTemp,B,yderiv) ;
|
||||
|
||||
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
K3[i] = Step * yderiv[i+3];
|
||||
tTemp[i] = tIn[i] + Step*(tIn[i+3] + 0.5*K3[i]) ;
|
||||
tTemp[i+3] = tIn[i+3] + K3[i] ;
|
||||
K3[i] = Step * yderiv[i+3]/mom;
|
||||
tTemp[i] = tIn[i] + Step*(tIn[i+3]/mom + 0.5*K3[i]) ;
|
||||
tTemp[i+3] = tIn[i+3] + K3[i]*mom ;
|
||||
}
|
||||
|
||||
|
||||
// Calculates y-deriv(atives) & returns B too!
|
||||
GetEquationOfMotion()->EvaluateRhsReturnB(tTemp,yderiv,B) ;
|
||||
|
||||
|
||||
for(i=0;i<3;i++) // Output trajectory vector
|
||||
{
|
||||
K4[i] = Step * yderiv[i+3];
|
||||
tOut[i] = tIn[i] + Step*(tIn[i+3] + (K1[i] + K2[i] + K3[i])/6.0) ;
|
||||
tOut[i+3] = tIn[i+3] + (K1[i] + 2*K2[i] + 2*K3[i] +K4[i])/6.0 ;
|
||||
K4[i] = Step * yderiv[i+3]/mom;
|
||||
tOut[i] = tIn[i] + Step*(tIn[i+3]/mom + (K1[i] + K2[i] + K3[i])/6.0) ;
|
||||
tOut[i+3] = tIn[i+3] + mom*(K1[i] + 2*K2[i] + 2*K3[i] +K4[i])/6.0 ;
|
||||
}
|
||||
|
||||
// NormaliseTangentVector( tOut );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
G4double G4RKG3_Stepper::DistChord() const
|
||||
{
|
||||
// Soon: must check whether h/R > 2 pi !!
|
||||
// Method below is good only for < 2 pi
|
||||
G4double distChord,distLine;
|
||||
|
||||
if (fyInitial != fyFinal) {
|
||||
distLine= G4LineSection::Distline(fyMidPoint,fyInitial,fyFinal );
|
||||
|
||||
distChord = distLine;
|
||||
}else{
|
||||
distChord = (fyMidPoint-fyInitial).mag();
|
||||
}
|
||||
|
||||
return G4LineSection::Distline( fyMidPoint, fyInitial, fyFinal );
|
||||
// This is a class method that gives distance of Mid
|
||||
// from the Chord between the Initial and Final points.
|
||||
|
||||
return distChord;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$Id: History,v 1.111 2006/11/30 10:39:40 gcosmo Exp $
|
||||
$Id: History,v 1.115 2007/04/11 08:00:12 gcosmo Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -17,6 +17,21 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
April 11, 2007 G.Cosmo geommng-V08-02-02
|
||||
- Added 'get' methods to stores for retrivial of volumes/solid by name.
|
||||
- Modified signature of G4VPhysicalVolume::CheckOverlaps() to introduce
|
||||
ability of handling tolerances for overlaps.
|
||||
- Coworks with tag "geomvol-V08-02-02".
|
||||
|
||||
March 20, 2007 G.Cosmo geommng-V08-02-01
|
||||
- Do not reset RegionRootFlag in RemoveRootLogicalVolume() if volume is the
|
||||
world, since the volume itself may be already removed from the store if
|
||||
G4LogicalVolumeStore::Clean() is called.
|
||||
|
||||
January 31, 2007 G.Cosmo geommng-V08-02-00
|
||||
- Added flag for controlling verbosity to CheckOverlaps() method.
|
||||
By default, verbosity is ON.
|
||||
|
||||
November 30, 2006 G.Cosmo geommng-V08-01-08
|
||||
- Corrected deregistration and deletion of world default region, now
|
||||
happening through G4RunManagerKernel. Affected codes: G4LogicalVolume
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4LogicalVolumeStore.hh,v 1.12 2006/06/29 18:30:59 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4LogicalVolumeStore.hh,v 1.13 2007/04/10 10:13:50 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// class G4LogicalVolumeStore
|
||||
//
|
||||
@@ -75,6 +75,10 @@ class G4LogicalVolumeStore : public std::vector<G4LogicalVolume*>
|
||||
static void Clean();
|
||||
// Delete all volumes from the store.
|
||||
|
||||
G4LogicalVolume* GetVolume(const G4String& name, G4bool verbose=true) const;
|
||||
// Return the pointer of the first volume in the collection having
|
||||
// that name.
|
||||
|
||||
virtual ~G4LogicalVolumeStore();
|
||||
// Destructor: takes care to delete allocated logical volumes.
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4PhysicalVolumeStore.hh,v 1.14 2006/06/29 18:31:01 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4PhysicalVolumeStore.hh,v 1.15 2007/04/10 10:13:50 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// class G4PhysicalVolume
|
||||
//
|
||||
@@ -78,6 +78,11 @@ class G4PhysicalVolumeStore : public std::vector<G4VPhysicalVolume*>
|
||||
// store; the flag will guarantee that physical volumes to be deregistered
|
||||
// from LV's list of daughters.
|
||||
|
||||
G4VPhysicalVolume* GetVolume(const G4String& name,
|
||||
G4bool verbose=true) const;
|
||||
// Return the pointer of the first volume in the collection having
|
||||
// that name.
|
||||
|
||||
virtual ~G4PhysicalVolumeStore();
|
||||
// Destructor: takes care to delete allocated physical volumes.
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4SolidStore.hh,v 1.12 2006/06/29 18:32:23 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4SolidStore.hh,v 1.13 2007/04/10 10:13:50 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// class G4SolidStore
|
||||
//
|
||||
@@ -75,6 +75,10 @@ class G4SolidStore : public std::vector<G4VSolid*>
|
||||
static void Clean();
|
||||
// Delete all solids from the store.
|
||||
|
||||
G4VSolid* GetSolid(const G4String& name, G4bool verbose=true) const;
|
||||
// Return the pointer of the first solid in the collection having
|
||||
// that name.
|
||||
|
||||
virtual ~G4SolidStore();
|
||||
// Destructor: takes care to delete allocated solids.
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VPhysicalVolume.hh,v 1.15 2006/09/18 14:03:25 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4VPhysicalVolume.hh,v 1.17 2007/04/11 08:00:12 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// class G4VPhysicalVolume
|
||||
@@ -165,7 +165,8 @@ class G4VPhysicalVolume
|
||||
// is regular, voxel-like. Value is id for structure type.
|
||||
// If non-zero the volume is a candidate for specialised
|
||||
// navigation such as 'nearest neighbour' directly on volumes.
|
||||
virtual G4bool CheckOverlaps(G4int res=1000);
|
||||
virtual G4bool CheckOverlaps(G4int res=1000, G4double tol=0.,
|
||||
G4bool verbose=true);
|
||||
// Verifies if the placed volume is overlapping with existing
|
||||
// daughters or with the mother volume. Provides default resolution
|
||||
// for the number of points to be generated and verified.
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4LogicalVolumeStore.cc,v 1.17 2006/11/30 10:39:28 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4LogicalVolumeStore.cc,v 1.18 2007/04/10 10:13:50 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// G4LogicalVolumeStore
|
||||
//
|
||||
@@ -152,6 +152,28 @@ void G4LogicalVolumeStore::DeRegister(G4LogicalVolume* pVolume)
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Retrieve the first volume pointer in the container having that name
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4LogicalVolume*
|
||||
G4LogicalVolumeStore::GetVolume(const G4String& name, G4bool verbose) const
|
||||
{
|
||||
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
|
||||
{
|
||||
if ((*i)->GetName() == name) { return *i; }
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
G4cerr << "ERROR - G4LogicalVolumeStore::GetVolume()" << G4endl
|
||||
<< " Volume " << name << " NOT found in store !" << G4endl
|
||||
<< " Returning NULL pointer." << G4endl;
|
||||
G4Exception("G4LogicalVolumeStore::GetVolume()", "InvalidQuery",
|
||||
JustWarning, "Volume NOT found in store !");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Return ptr to Store, setting if necessary
|
||||
// ***************************************************************************
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4PhysicalVolumeStore.cc,v 1.18 2006/11/30 10:39:28 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4PhysicalVolumeStore.cc,v 1.19 2007/04/10 10:13:50 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// G4PhysicalVolumeStore
|
||||
//
|
||||
@@ -166,6 +166,28 @@ void G4PhysicalVolumeStore::DeRegister(G4VPhysicalVolume* pVolume)
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Retrieve the first volume pointer in the container having that name
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4VPhysicalVolume*
|
||||
G4PhysicalVolumeStore::GetVolume(const G4String& name, G4bool verbose) const
|
||||
{
|
||||
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
|
||||
{
|
||||
if ((*i)->GetName() == name) { return *i; }
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
G4cerr << "ERROR - G4PhysicalVolumeStore::GetVolume()" << G4endl
|
||||
<< " Volume " << name << " NOT found in store !" << G4endl
|
||||
<< " Returning NULL pointer." << G4endl;
|
||||
G4Exception("G4PhysicalVolumeStore::GetVolume()", "InvalidQuery",
|
||||
JustWarning, "Volume NOT found in store !");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Return ptr to Store, setting if necessary
|
||||
// ***************************************************************************
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Region.cc,v 1.21 2006/07/17 08:36:47 asaim Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4Region.cc,v 1.22 2007/03/20 22:29:50 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// class G4Region Implementation
|
||||
@@ -239,8 +239,11 @@ void G4Region::RemoveRootLogicalVolume(G4LogicalVolume* lv)
|
||||
pos = std::find(fRootVolumes.begin(),fRootVolumes.end(),lv);
|
||||
if (pos != fRootVolumes.end())
|
||||
{
|
||||
if (fRootVolumes.size() != 1) // Avoid resetting flag for world since
|
||||
{ // volume may be already deleted !
|
||||
lv->SetRegionRootFlag(false);
|
||||
}
|
||||
fRootVolumes.erase(pos);
|
||||
lv->SetRegionRootFlag(false);
|
||||
}
|
||||
|
||||
// Scan recursively the tree of daugther volumes and reset regions
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4RegionStore.cc,v 1.12 2006/11/30 10:39:28 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4RegionStore.cc,v 1.13 2007/04/10 10:13:50 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// G4RegionStore
|
||||
//
|
||||
@@ -224,7 +224,10 @@ G4Region* G4RegionStore::GetRegion(const G4String& name, G4bool verbose) const
|
||||
if (verbose)
|
||||
{
|
||||
G4cerr << "ERROR - G4RegionStore::GetRegion()" << G4endl
|
||||
<< " Region " << name << " NOT found in store !" << G4endl;
|
||||
<< " Region " << name << " NOT found in store !" << G4endl
|
||||
<< " Returning NULL pointer." << G4endl;
|
||||
G4Exception("G4RegionStore::GetRegion()", "InvalidQuery",
|
||||
JustWarning, "Region NOT found in store !");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4SolidStore.cc,v 1.16 2006/11/30 10:39:28 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4SolidStore.cc,v 1.17 2007/04/10 10:13:50 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// G4SolidStore
|
||||
//
|
||||
@@ -152,6 +152,27 @@ void G4SolidStore::DeRegister(G4VSolid* pSolid)
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Retrieve the first solid pointer in the container having that name
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4VSolid* G4SolidStore::GetSolid(const G4String& name, G4bool verbose) const
|
||||
{
|
||||
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
|
||||
{
|
||||
if ((*i)->GetName() == name) { return *i; }
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
G4cerr << "ERROR - G4SolidStore::GetSolid()" << G4endl
|
||||
<< " Solid " << name << " not found in store !" << G4endl
|
||||
<< " Returning NULL pointer." << G4endl;
|
||||
G4Exception("G4SolidStore::GetSolid()", "InvalidQuery",
|
||||
JustWarning, "Solid NOT found in store !");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Return ptr to Store, setting if necessary
|
||||
// ***************************************************************************
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VPhysicalVolume.cc,v 1.12 2006/09/18 14:03:25 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4VPhysicalVolume.cc,v 1.14 2007/04/11 08:00:12 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// class G4VPhysicalVolume Implementation
|
||||
@@ -95,7 +95,7 @@ G4RotationMatrix* G4VPhysicalVolume::GetObjectRotation() const
|
||||
// Only implemented for placed and parameterised volumes.
|
||||
// Not required for replicas.
|
||||
//
|
||||
G4bool G4VPhysicalVolume::CheckOverlaps(G4int)
|
||||
G4bool G4VPhysicalVolume::CheckOverlaps(G4int, G4double, G4bool)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$Id: History,v 1.69 2006/11/23 18:54:27 japost Exp $
|
||||
$Id: History,v 1.73.2.1 2007/04/26 15:23:01 gcosmo Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -17,6 +17,29 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
April 26th, 2007 - T.Nikitina (geomnav-V08-02-01a)
|
||||
-----------------------------
|
||||
- Fixed case of out of range access in G4GeomTestSegment responsible for
|
||||
crashes observed when recursive-grid test for overlaps was run.
|
||||
Addressing problem report #784.
|
||||
|
||||
February 13th, 2007 - J.Apostolakis (geomnav-V08-02-01)
|
||||
-----------------------------------
|
||||
- G4PropagatorInField:
|
||||
o Implemented ClearPropagatorState() to clear all the track-dependent
|
||||
state (incl. safety, zero-steps, loop flag ...).
|
||||
** Calling this is mandatory for each new track because in the case of
|
||||
geometry overlaps, the safety can be easily inconsistent (and/or
|
||||
incorrect) otherwise
|
||||
** Must be called from G4Transportation (or alternatives) !!
|
||||
- Fix created Jan 25th, 2007
|
||||
|
||||
January 31st, 2007 - G.Cosmo (geomnav-V08-02-00)
|
||||
----------------------------
|
||||
- G4Navigator: forcing call to CheckOverlaps() on the current volume
|
||||
before event abortion for cases of stuck tracks.
|
||||
- Requires tag "geommng-V08-02-00".
|
||||
|
||||
November 23rd, 2006 - J.Apostolakis (geomnav-V08-01-08)
|
||||
-----------------------------------
|
||||
- G4PathFinder:
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Navigator.hh,v 1.18 2006/11/11 01:17:49 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4Navigator.hh,v 1.19 2006/12/07 15:09:18 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// class G4Navigator
|
||||
@@ -317,8 +317,6 @@ class G4Navigator
|
||||
G4bool fActive;
|
||||
// States if the navigator is activated or not.
|
||||
|
||||
G4ThreeVector fLastLocatedPointLocal;
|
||||
// Position of the last located point relative to its containing volume.
|
||||
G4bool fEntering,fExiting;
|
||||
// Entering/Exiting volumes blocking/setup
|
||||
// o If exiting
|
||||
@@ -331,8 +329,14 @@ class G4Navigator
|
||||
G4VPhysicalVolume *fBlockedPhysicalVolume;
|
||||
G4int fBlockedReplicaNo;
|
||||
|
||||
G4VPhysicalVolume *fCandidatePhysicalVolume;
|
||||
G4int fCandidateReplicaNo;
|
||||
// G4VPhysicalVolume *fCandidatePhysicalVolume; // Unused
|
||||
// G4int fCandidateReplicaNo;
|
||||
|
||||
G4ThreeVector fLastLocatedPointLocal;
|
||||
// Position of the last located point relative to its containing volume.
|
||||
G4bool fLocatedOutsideWorld;
|
||||
// Whether the last call to Locate methods left the world
|
||||
// G4PhysicalVolume* fLastVolumeLocated;
|
||||
|
||||
G4bool fValidExitNormal; // Set true if have leaving volume normal
|
||||
G4ThreeVector fExitNormal; // Leaving volume normal, in the
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GeomTestSegment.cc,v 1.5 2006/06/29 18:36:46 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4GeomTestSegment.cc,v 1.7 2007/04/26 15:15:02 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
@@ -189,6 +189,8 @@ void G4GeomTestSegment::PatchInconsistencies( G4GeomTestLogger *logger )
|
||||
// Oh oh. No solution. Delete the current point and complain.
|
||||
//
|
||||
logger->SolidProblem( solid, "Spurious exiting intersection point", p );
|
||||
// G4cout<<" dir="<<curr->GetDistance()<<" entering="<<curr->Entering()<<" SigneNorm="<<v.dot(solid->SurfaceNormal(p))<<G4endl;
|
||||
|
||||
curr = points.erase(curr);
|
||||
break;
|
||||
}
|
||||
@@ -237,7 +239,7 @@ void G4GeomTestSegment::PatchInconsistencies( G4GeomTestLogger *logger )
|
||||
curr = points.erase(curr);
|
||||
}
|
||||
|
||||
curr = next + 1;
|
||||
if(curr!=points.end()){curr = next + 1;}
|
||||
} while( curr != points.end() );
|
||||
|
||||
//
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Navigator.cc,v 1.25 2006/11/11 01:28:23 japost Exp $
|
||||
// $Id: G4Navigator.cc,v 1.25.2.1 2007/01/31 15:05:07 gcosmo Exp $
|
||||
// GEANT4 tag $ Name: $
|
||||
//
|
||||
// class G4Navigator Implementation
|
||||
@@ -822,6 +822,7 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector &pGlobalpoint,
|
||||
<< " in volume -" << motherPhysical->GetName()
|
||||
<< "- at point " << pGlobalpoint << G4endl
|
||||
<< " direction: " << pDirection << "." << G4endl;
|
||||
motherPhysical->CheckOverlaps(5000, false);
|
||||
G4Exception("G4Navigator::ComputeStep()",
|
||||
"StuckTrack", EventMustBeAborted,
|
||||
"Stuck Track: potential geometry or navigation problem.");
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4PropagatorInField.cc,v 1.29 2006/11/17 16:53:45 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4PropagatorInField.cc,v 1.30 2007/01/25 21:27:50 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// This class implements an algorithm to track a particle in a
|
||||
@@ -1118,11 +1118,20 @@ G4PropagatorInField::IntersectChord( G4ThreeVector StartPointA,
|
||||
intersects = false;
|
||||
|
||||
NewSafety= currentSafety;
|
||||
|
||||
#if 0
|
||||
G4cout << " G4PropagatorInField does not call Navigator::ComputeStep " << G4endl ;
|
||||
G4cout << " step= " << LinearStepLength << " safety= " << NewSafety << G4endl;
|
||||
G4cout << " safety: Origin = " << fPreviousSftOrigin << " val= " << fPreviousSafety << G4endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
doCallNav= true;
|
||||
// Check whether any volumes are encountered by the chord AB
|
||||
|
||||
// G4cout << " G4PropagatorInField calling Navigator::ComputeStep " << G4endl ;
|
||||
|
||||
LinearStepLength =
|
||||
fNavigator->ComputeStep( StartPointA, ChordAB_Dir,
|
||||
ChordAB_Length, NewSafety );
|
||||
@@ -1131,6 +1140,8 @@ G4PropagatorInField::IntersectChord( G4ThreeVector StartPointA,
|
||||
// and it did not find a surface boundary at that length
|
||||
LinearStepLength = std::min( LinearStepLength, ChordAB_Length);
|
||||
|
||||
// G4cout << " G4PiF got step= " << LinearStepLength << " safety= " << NewSafety << G4endl;
|
||||
|
||||
// Save the last calculated safety!
|
||||
fPreviousSftOrigin = StartPointA;
|
||||
fPreviousSafety= NewSafety;
|
||||
@@ -1294,8 +1305,21 @@ G4PropagatorInField::SetTrajectoryFilter(G4VCurvedTrajectoryFilter* filter) {
|
||||
|
||||
void G4PropagatorInField::ClearPropagatorState()
|
||||
{
|
||||
G4Exception("G4PropagatorInField::ClearPropagatorState()", "NotImplemented",
|
||||
FatalException, "Functionality not yet implemented.");
|
||||
// G4Exception("G4PropagatorInField::ClearPropagatorState()", "NotImplemented",
|
||||
// FatalException, "Functionality not yet implemented.");
|
||||
|
||||
// Goal: Clear all memory of previous steps, cached information
|
||||
fParticleIsLooping= false;
|
||||
fNoZeroStep= 0;
|
||||
|
||||
End_PointAndTangent= G4FieldTrack( G4ThreeVector(0.,0.,0.),
|
||||
G4ThreeVector(0.,0.,0.),0.0,0.0,0.0,0.0,0.0);
|
||||
|
||||
fFull_CurveLen_of_LastAttempt = -1;
|
||||
fLast_ProposedStepLength = -1;
|
||||
|
||||
fPreviousSftOrigin= G4ThreeVector(0.,0.,0.);
|
||||
fPreviousSafety= 0.0;
|
||||
}
|
||||
|
||||
G4FieldManager*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$Id: History,v 1.100 2006/11/15 10:43:13 gcosmo Exp $
|
||||
$Id: History,v 1.109 2007/04/26 13:27:37 gcosmo Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -17,6 +17,54 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
26-Apr-2007, T.Nikitina (geom-specific-V08-02-05)
|
||||
- Fix in GetPointOnSurface() for G4Polycone to consider also points laying
|
||||
on rings when consecutive Z-sections are coincident.
|
||||
Added method GetPointOnRing().
|
||||
- Added unit test testPointOnSurfacePoly.cc.
|
||||
|
||||
27-Feb-2007, I.Hrivnacova (geom-specific-V08-02-04)
|
||||
- Added specialised constructor for handling Z-sections in G4ExtrudedSolid.
|
||||
- Cleared unecessary declaration of IsInside() methods in G4TriangularFacet
|
||||
and G4QuadrangularFacet.
|
||||
- Updated unit test for G4ExtrudedSolid.
|
||||
|
||||
26-Feb-2007, I.Hrivnacova (geom-specific-V08-02-04)
|
||||
- Added specialised constructor for handling Z-sections in G4ExtrudedSolid.
|
||||
- Cleared unecessary declaration of IsInside() methods in G4TriangularFacet
|
||||
and G4QuadrangularFacet.
|
||||
- Updated unit test for G4ExtrudedSolid.
|
||||
|
||||
15-Feb-2007, I.Hrivnacova (geom-specific-V08-02-03)
|
||||
- Corrected caching of values in G4ExtrudedSolid.
|
||||
- Bug fix in G4TriangularFacet::Intersect() to allow for correct update of
|
||||
'Distance' in condition.
|
||||
- Updated unit test for G4ExtrudedSolid.
|
||||
|
||||
09-Feb-2007, G.Cosmo (geom-specific-V08-02-02)
|
||||
- Introduced new shape G4ExtrudedSolid, a solid representing the extrusion
|
||||
of an arbitrary polygon with fixed outline in the two Z sections.
|
||||
New files: G4ExtrudedSolid[.hh.icc.cc] and testG4ExtrudedSolid.cc
|
||||
by I.Hrivnacova.
|
||||
- G4TessellatedSolid:
|
||||
o Made relevant solid's methods virtual, to be used as base class.
|
||||
o Added implementation for GetSurfaceArea() and GetPointOnSurface() methods.
|
||||
o Added protection in SurfaceNormal() method in case of facet not found.
|
||||
o Check and return kOutside in Inside() if point out of solid's extent.
|
||||
|
||||
01-Feb-2007, G.Cosmo (geom-specific-V08-02-01)
|
||||
- Fix in G4PolyconeSide::DistanceAway() for correct estimation of distance
|
||||
for the case of Phi sections (T.Nikitina).
|
||||
Addresses problem report #598.
|
||||
- Updated unit test for G4Polycone to consider new test case.
|
||||
|
||||
22-Jan-2007, G.Cosmo (geom-specific-V08-02-00)
|
||||
- Do not scale reducible-polygon in G4Polyhedra::Reset() method.
|
||||
The 'original_parameters' structure offered as input through the accessors
|
||||
are always assumed to be already scaled by the 'cos(0.5*phiTotal/theNumSide)'
|
||||
factor. Addresses problem report #873.
|
||||
- Fixed warning printout in G4Polycone::Reset().
|
||||
|
||||
15-Nov-2006, J.Allison (geom-specific-V08-01-04)
|
||||
- Fixed typo in G4Polycone::CreatePolyhedron() introduced by mistake in
|
||||
the last cleanup of the source code.
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ExtrudedSolid.hh,v 1.5 2007/02/26 08:40:01 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
//
|
||||
// G4ExtrudedSolid
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// G4ExtrudedSolid is a solid which represents the extrusion of an arbitrary
|
||||
// polygon with fixed outline in the defined Z sections.
|
||||
// The z-sides of the solid are the scaled versions of the same polygon.
|
||||
// The solid is implemented as a specification of G4TessellatedSolid.
|
||||
//
|
||||
// Parameters in the constructor:
|
||||
// const G4String& pName - solid name
|
||||
// std::vector<G4TwoVector> polygon - the vertices of the outlined polygon
|
||||
// defined in clock-wise order
|
||||
// std::vector<ZSection> - the z-sections defined by
|
||||
// z position, offset and scale
|
||||
// in increasing z-position order
|
||||
//
|
||||
// Parameters in the special constructor (for solid with 2 z-sections:
|
||||
// G4double hz - the solid half length in Z
|
||||
// G4TwoVector off1 - offset of the side in -hz
|
||||
// G4double scale1 - scale of the side in -hz
|
||||
// G4TwoVector off2 - offset of the side in +hz
|
||||
// G4double scale2 - scale of the side in -hz
|
||||
|
||||
// Author:
|
||||
// Ivana Hrivnacova, IPN Orsay
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#ifndef G4ExtrudedSolid_HH
|
||||
#define G4ExtrudedSolid_HH
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "G4TwoVector.hh"
|
||||
|
||||
#include "G4TessellatedSolid.hh"
|
||||
|
||||
class G4ExtrudedSolid : public G4TessellatedSolid
|
||||
{
|
||||
|
||||
public: // without description
|
||||
|
||||
struct ZSection
|
||||
{
|
||||
ZSection(G4double z, G4TwoVector offset, G4double scale)
|
||||
: fZ(z), fOffset(offset), fScale(scale) {}
|
||||
|
||||
G4double fZ;
|
||||
G4TwoVector fOffset;
|
||||
G4double fScale;
|
||||
};
|
||||
|
||||
public: // with description
|
||||
|
||||
G4ExtrudedSolid( const G4String& pName,
|
||||
std::vector<G4TwoVector> polygon,
|
||||
std::vector<ZSection> zsections);
|
||||
// General constructor
|
||||
|
||||
G4ExtrudedSolid( const G4String& pName,
|
||||
std::vector<G4TwoVector> polygon,
|
||||
G4double hz,
|
||||
G4TwoVector off1, G4double scale1,
|
||||
G4TwoVector off2, G4double scale2 );
|
||||
// Special constructor for solid with 2 z-sections
|
||||
|
||||
virtual ~G4ExtrudedSolid();
|
||||
// Destructor
|
||||
|
||||
// Accessors
|
||||
|
||||
inline G4int GetNofVertices() const;
|
||||
inline G4TwoVector GetVertex(G4int index) const;
|
||||
inline std::vector<G4TwoVector> GetPolygon() const;
|
||||
|
||||
inline G4int GetNofZSections() const;
|
||||
inline ZSection GetZSection(G4int index) const;
|
||||
inline std::vector<ZSection> GetZSections() const;
|
||||
|
||||
// Solid methods
|
||||
|
||||
EInside Inside (const G4ThreeVector &p) const;
|
||||
G4double DistanceToOut(const G4ThreeVector &p,
|
||||
const G4ThreeVector &v,
|
||||
const G4bool calcNorm=false,
|
||||
G4bool *validNorm=0, G4ThreeVector *n=0) const;
|
||||
G4double DistanceToOut (const G4ThreeVector &p) const;
|
||||
G4GeometryType GetEntityType () const;
|
||||
|
||||
std::ostream& StreamInfo(std::ostream &os) const;
|
||||
|
||||
public: // without description
|
||||
|
||||
G4ExtrudedSolid(__void__&);
|
||||
// Fake default constructor for usage restricted to direct object
|
||||
// persistency for clients requiring preallocation of memory for
|
||||
// persistifiable objects.
|
||||
|
||||
private:
|
||||
|
||||
void ComputeProjectionParameters();
|
||||
|
||||
G4ThreeVector GetVertex(G4int iz, G4int ind) const;
|
||||
G4TwoVector ProjectPoint(const G4ThreeVector& point) const;
|
||||
|
||||
G4bool IsSameLine(G4TwoVector p,
|
||||
G4TwoVector l1, G4TwoVector l2) const;
|
||||
G4bool IsSameSide(G4TwoVector p1, G4TwoVector p2,
|
||||
G4TwoVector l1, G4TwoVector l2) const;
|
||||
G4bool IsPointInside(G4TwoVector a, G4TwoVector b, G4TwoVector c,
|
||||
G4TwoVector p) const;
|
||||
|
||||
G4VFacet* MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const;
|
||||
G4VFacet* MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const;
|
||||
|
||||
G4bool AddGeneralPolygonFacets();
|
||||
G4bool MakeFacets();
|
||||
G4bool IsConvex() const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
G4int fNv;
|
||||
G4int fNz;
|
||||
std::vector<G4TwoVector> fPolygon;
|
||||
std::vector<ZSection> fZSections;
|
||||
std::vector< std::vector<G4int> > fTriangles;
|
||||
G4bool fIsConvex;
|
||||
G4GeometryType fGeometryType;
|
||||
|
||||
std::vector<G4double> fKScales;
|
||||
std::vector<G4double> fScale0s;
|
||||
std::vector<G4TwoVector> fKOffsets;
|
||||
std::vector<G4TwoVector> fOffset0s;
|
||||
};
|
||||
|
||||
#include "G4ExtrudedSolid.icc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ExtrudedSolid.icc,v 1.2 2007/02/19 10:17:45 ivana Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 inline definitions file
|
||||
//
|
||||
// G4ExtrudedSolid.icc
|
||||
//
|
||||
// Implementation of inline methods of G4ExtrudedSolid
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
inline
|
||||
G4int G4ExtrudedSolid::GetNofVertices() const
|
||||
{
|
||||
return fNv;
|
||||
}
|
||||
|
||||
inline G4TwoVector G4ExtrudedSolid::GetVertex(G4int index) const
|
||||
{
|
||||
if ( index<0 || index >= fNv )
|
||||
{
|
||||
G4Exception ("G4ExtrudedSolid::GetVertex()", "InvalidInput",
|
||||
FatalException, "Index outside range.");
|
||||
return G4TwoVector();
|
||||
}
|
||||
return fPolygon[index];
|
||||
}
|
||||
|
||||
inline
|
||||
std::vector<G4TwoVector> G4ExtrudedSolid::GetPolygon() const
|
||||
{
|
||||
return fPolygon;
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4ExtrudedSolid::GetNofZSections() const
|
||||
{
|
||||
return fNz;
|
||||
}
|
||||
|
||||
inline
|
||||
G4ExtrudedSolid::ZSection G4ExtrudedSolid::GetZSection(G4int index) const
|
||||
{
|
||||
if ( index<0 || index >= fNz )
|
||||
{
|
||||
G4Exception ("G4ExtrudedSolid::GetZSection()", "InvalidInput",
|
||||
FatalException, "Index outside range.");
|
||||
return ZSection(0.0, G4TwoVector(), 0.0);
|
||||
}
|
||||
return fZSections[index];
|
||||
}
|
||||
|
||||
inline
|
||||
std::vector<G4ExtrudedSolid::ZSection> G4ExtrudedSolid::GetZSections() const
|
||||
{
|
||||
return fZSections;
|
||||
}
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Polycone.hh,v 1.19 2006/06/29 18:47:12 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4Polycone.hh,v 1.20 2007/04/26 06:18:20 tnikitin Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
@@ -175,6 +175,10 @@ class G4Polycone : public G4VCSGfaceted
|
||||
G4double zOne, G4double zTwo,
|
||||
G4double& totArea) const;
|
||||
|
||||
G4ThreeVector GetPointOnRing(G4double fRMin, G4double fRMax,
|
||||
G4double fRMin2, G4double fRMax2,
|
||||
G4double zOne) const;
|
||||
|
||||
protected: // without description
|
||||
|
||||
// Here are our parameters
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Polyhedra.hh,v 1.16 2006/06/29 18:47:18 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4Polyhedra.hh,v 1.17 2007/01/22 12:58:53 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
@@ -143,8 +143,13 @@ class G4Polyhedra : public G4VCSGfaceted
|
||||
inline G4bool IsGeneric() const;
|
||||
inline G4int GetNumRZCorner() const;
|
||||
inline G4PolyhedraSideRZ GetCorner( const G4int index ) const;
|
||||
|
||||
inline G4PolyhedraHistorical* GetOriginalParameters() const;
|
||||
// Returns internal scaled parameters.
|
||||
inline void SetOriginalParameters(G4PolyhedraHistorical* pars);
|
||||
// Sets internal parameters. Parameters 'Rmin' and 'Rmax' in input must
|
||||
// be scaled first by a factor computed as 'cos(0.5*phiTotal/theNumSide)',
|
||||
// if not already scaled.
|
||||
|
||||
public: // without description
|
||||
|
||||
@@ -155,14 +160,15 @@ class G4Polyhedra : public G4VCSGfaceted
|
||||
|
||||
protected: // without description
|
||||
|
||||
// Generic initializer, call by all constructors
|
||||
|
||||
inline void SetOriginalParameters();
|
||||
|
||||
// Sets internal parameters for the generic constructor.
|
||||
|
||||
void Create( G4double phiStart, // initial phi starting angle
|
||||
G4double phiTotal, // total phi angle
|
||||
G4int numSide, // number sides
|
||||
G4ReduciblePolygon *rz ); // rz coordinates
|
||||
// Generates the shape and is called by each constructor, after the
|
||||
// conversion of the arguments
|
||||
|
||||
void CopyStuff( const G4Polyhedra &source );
|
||||
void DeleteStuff();
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Polyhedra.icc,v 1.10 2006/06/29 18:47:20 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4Polyhedra.icc,v 1.11 2007/01/22 12:58:53 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 inline definitions file
|
||||
@@ -87,8 +87,10 @@ inline
|
||||
void G4Polyhedra::SetOriginalParameters(G4PolyhedraHistorical* pars)
|
||||
{
|
||||
if (!pars)
|
||||
{
|
||||
G4Exception("G4Polyhedra::SetOriginalParameters()", "InvalidSetup",
|
||||
FatalException, "NULL pointer to parameters!");
|
||||
}
|
||||
*original_parameters = *pars;
|
||||
fCubicVolume = 0.;
|
||||
fpPolyhedron = 0;
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4QuadrangularFacet.hh,v 1.3 2006/06/29 18:47:26 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4QuadrangularFacet.hh,v 1.5 2007/02/26 08:39:13 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
//
|
||||
@@ -88,7 +88,7 @@ class G4QuadrangularFacet : public G4VFacet
|
||||
G4QuadrangularFacet (const G4QuadrangularFacet &right);
|
||||
const G4QuadrangularFacet &operator=(G4QuadrangularFacet &right);
|
||||
|
||||
G4VFacet *GetClone();
|
||||
G4VFacet *GetClone ();
|
||||
|
||||
G4ThreeVector Distance (const G4ThreeVector &p);
|
||||
G4double Distance (const G4ThreeVector &p, const G4double minDist);
|
||||
@@ -98,8 +98,10 @@ class G4QuadrangularFacet : public G4VFacet
|
||||
G4bool Intersect (const G4ThreeVector &p, const G4ThreeVector &v,
|
||||
const G4bool outgoing, G4double &distance,
|
||||
G4double &distFromSurface, G4ThreeVector &normal);
|
||||
G4bool IsInside (const G4ThreeVector &p) const;
|
||||
|
||||
G4double GetArea ();
|
||||
G4ThreeVector GetPointOnFace () const;
|
||||
|
||||
private:
|
||||
|
||||
G4TriangularFacet *facet1;
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4TessellatedSolid.hh,v 1.4 2006/10/20 13:45:20 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4TessellatedSolid.hh,v 1.7 2007/02/12 11:51:25 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
//
|
||||
@@ -129,7 +129,7 @@ class G4TessellatedSolid : public G4VSolid
|
||||
|
||||
G4TessellatedSolid ();
|
||||
G4TessellatedSolid (const G4String &name);
|
||||
~G4TessellatedSolid ();
|
||||
virtual ~G4TessellatedSolid ();
|
||||
|
||||
G4TessellatedSolid (const G4TessellatedSolid &s);
|
||||
const G4TessellatedSolid &operator= (const G4TessellatedSolid &s);
|
||||
@@ -139,45 +139,52 @@ class G4TessellatedSolid : public G4VSolid
|
||||
G4VFacet *GetFacet (size_t i) const;
|
||||
size_t GetNumberOfFacets () const;
|
||||
|
||||
G4double GetCubicVolume ();
|
||||
G4double GetSurfaceArea ();
|
||||
virtual G4double GetCubicVolume ();
|
||||
virtual G4double GetSurfaceArea ();
|
||||
|
||||
//
|
||||
// void ComputeDimensions (G4VPVParameterisation* p, const G4int n,
|
||||
// const G4VPhysicalVolume* pRep) const;
|
||||
// virtual void ComputeDimensions (G4VPVParameterisation* p, const G4int n,
|
||||
// const G4VPhysicalVolume* pRep) const;
|
||||
|
||||
EInside Inside (const G4ThreeVector &p) const;
|
||||
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const;
|
||||
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const;
|
||||
G4double DistanceToIn(const G4ThreeVector &p) const;
|
||||
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v,
|
||||
const G4bool calcNorm=false,
|
||||
virtual EInside Inside (const G4ThreeVector &p) const;
|
||||
virtual G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const;
|
||||
virtual G4double DistanceToIn(const G4ThreeVector &p,
|
||||
const G4ThreeVector &v) const;
|
||||
virtual G4double DistanceToIn(const G4ThreeVector &p) const;
|
||||
virtual G4double DistanceToOut(const G4ThreeVector &p,
|
||||
const G4ThreeVector &v,
|
||||
const G4bool calcNorm=false,
|
||||
G4bool *validNorm=0, G4ThreeVector *n=0) const;
|
||||
G4double DistanceToOut (const G4ThreeVector &p) const;
|
||||
G4GeometryType GetEntityType () const;
|
||||
virtual G4double DistanceToOut (const G4ThreeVector &p) const;
|
||||
virtual G4GeometryType GetEntityType () const;
|
||||
|
||||
void SetSolidClosed (const G4bool t);
|
||||
G4bool GetSolidClosed () const;
|
||||
|
||||
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits& pVoxelLimit,
|
||||
const G4AffineTransform& pTransform, G4double& pMin,
|
||||
G4double& pMax) const;
|
||||
virtual G4ThreeVector GetPointOnSurface() const;
|
||||
|
||||
std::ostream &StreamInfo(std::ostream &os) const;
|
||||
virtual G4bool CalculateExtent(const EAxis pAxis,
|
||||
const G4VoxelLimits& pVoxelLimit,
|
||||
const G4AffineTransform& pTransform,
|
||||
G4double& pMin, G4double& pMax) const;
|
||||
|
||||
virtual std::ostream &StreamInfo(std::ostream &os) const;
|
||||
|
||||
// Functions for visualization
|
||||
|
||||
void DescribeYourselfTo (G4VGraphicsScene& scene) const;
|
||||
G4VisExtent GetExtent () const;
|
||||
virtual void DescribeYourselfTo (G4VGraphicsScene& scene) const;
|
||||
virtual G4VisExtent GetExtent () const;
|
||||
|
||||
G4double GetMinXExtent () const;
|
||||
G4double GetMaxXExtent () const;
|
||||
G4double GetMinYExtent () const;
|
||||
G4double GetMaxYExtent () const;
|
||||
G4double GetMinZExtent () const;
|
||||
G4double GetMaxZExtent () const;
|
||||
G4Polyhedron* CreatePolyhedron () const;
|
||||
G4Polyhedron* GetPolyhedron () const;
|
||||
G4NURBS* CreateNURBS () const;
|
||||
|
||||
virtual G4Polyhedron* CreatePolyhedron () const;
|
||||
virtual G4Polyhedron* GetPolyhedron () const;
|
||||
virtual G4NURBS* CreateNURBS () const;
|
||||
|
||||
public: // without description
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4TriangularFacet.hh,v 1.3 2006/06/29 18:47:40 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4TriangularFacet.hh,v 1.6 2007/02/26 08:39:40 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
//
|
||||
@@ -83,7 +83,7 @@ class G4TriangularFacet : public G4VFacet
|
||||
G4TriangularFacet (const G4TriangularFacet &right);
|
||||
const G4TriangularFacet &operator=(G4TriangularFacet &right);
|
||||
|
||||
G4VFacet *GetClone();
|
||||
G4VFacet *GetClone ();
|
||||
G4TriangularFacet *GetFlippedFacet ();
|
||||
|
||||
G4ThreeVector Distance (const G4ThreeVector &p);
|
||||
@@ -94,8 +94,9 @@ class G4TriangularFacet : public G4VFacet
|
||||
G4bool Intersect (const G4ThreeVector &p, const G4ThreeVector &v,
|
||||
const G4bool outgoing, G4double &distance,
|
||||
G4double &distFromSurface, G4ThreeVector &normal);
|
||||
G4bool IsInside(const G4ThreeVector &p) const;
|
||||
|
||||
G4double GetArea ();
|
||||
G4ThreeVector GetPointOnFace () const;
|
||||
|
||||
private:
|
||||
|
||||
G4double a;
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4VFacet.hh,v 1.3 2006/06/29 18:48:12 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4VFacet.hh,v 1.4 2007/02/12 09:34:44 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
//
|
||||
@@ -72,23 +72,20 @@ class G4VFacet
|
||||
G4VFacet ();
|
||||
virtual ~G4VFacet ();
|
||||
|
||||
G4VFacet (const G4VFacet &right);
|
||||
const G4VFacet &operator=(G4VFacet &right);
|
||||
|
||||
G4bool operator== (const G4VFacet &right) const;
|
||||
|
||||
size_t GetNumberOfVertices () const;
|
||||
G4ThreeVector GetVertex (size_t i) const;
|
||||
inline size_t GetNumberOfVertices () const;
|
||||
inline G4ThreeVector GetVertex (size_t i) const;
|
||||
|
||||
G4GeometryType GetEntityType () const;
|
||||
G4ThreeVector GetSurfaceNormal () const;
|
||||
G4bool IsInside(const G4ThreeVector &p) const;
|
||||
G4bool IsDefined () const;
|
||||
void SetVertexIndex (const size_t i, const size_t j);
|
||||
size_t GetVertexIndex (const size_t i) const;
|
||||
G4ThreeVector GetCentroid () const;
|
||||
G4double GetRadius () const;
|
||||
G4double GetRadiusSquared() const;
|
||||
inline G4GeometryType GetEntityType () const;
|
||||
inline G4ThreeVector GetSurfaceNormal () const;
|
||||
inline G4bool IsInside(const G4ThreeVector &p) const;
|
||||
inline G4bool IsDefined () const;
|
||||
inline void SetVertexIndex (const size_t i, const size_t j);
|
||||
inline size_t GetVertexIndex (const size_t i) const;
|
||||
inline G4ThreeVector GetCentroid () const;
|
||||
inline G4double GetRadius () const;
|
||||
inline G4double GetRadiusSquared() const;
|
||||
|
||||
void ApplyTranslation (const G4ThreeVector v);
|
||||
|
||||
@@ -102,6 +99,9 @@ class G4VFacet
|
||||
virtual G4bool Intersect (const G4ThreeVector&, const G4ThreeVector &,
|
||||
const G4bool , G4double &, G4double &,
|
||||
G4ThreeVector &);
|
||||
virtual G4double GetArea() = 0;
|
||||
virtual G4ThreeVector GetPointOnFace() const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
G4GeometryType geometryType;
|
||||
@@ -117,6 +117,12 @@ class G4VFacet
|
||||
G4double radiusSqr;
|
||||
|
||||
G4double dirTolerance;
|
||||
G4double area;
|
||||
|
||||
private:
|
||||
|
||||
G4VFacet (const G4VFacet &right);
|
||||
const G4VFacet &operator=(G4VFacet &right);
|
||||
};
|
||||
|
||||
typedef std::vector<G4VFacet*>::iterator FacetI;
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4VFacet.icc,v 1.3 2006/06/29 18:48:15 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4VFacet.icc,v 1.4 2007/02/12 09:34:44 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
//
|
||||
@@ -47,28 +47,6 @@
|
||||
//
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
inline G4VFacet::G4VFacet ()
|
||||
{
|
||||
dirTolerance = 1.0E-14;
|
||||
|
||||
P.clear();
|
||||
E.clear();
|
||||
|
||||
centroid = G4ThreeVector(0.0,0.0,0.0);
|
||||
radius = 0.0;
|
||||
radiusSqr = 0.0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
inline G4VFacet::~G4VFacet ()
|
||||
{
|
||||
P.clear();
|
||||
E.clear();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
inline G4ThreeVector G4VFacet::GetSurfaceNormal () const
|
||||
@@ -99,8 +77,8 @@ inline G4bool G4VFacet::IsDefined () const
|
||||
//
|
||||
inline size_t G4VFacet::GetVertexIndex (const size_t i) const
|
||||
{
|
||||
if (i < I.size()) return I[i];
|
||||
else return 999999999;
|
||||
if (i < I.size()) { return I[i]; }
|
||||
else { return 999999999; }
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -119,45 +97,9 @@ inline void G4VFacet::SetVertexIndex (const size_t i, const size_t j)
|
||||
//
|
||||
inline G4ThreeVector G4VFacet::GetVertex (size_t i) const
|
||||
{
|
||||
if (i == 0) return P0;
|
||||
else if (i < nVertices) return P[i-1];
|
||||
else return G4ThreeVector(0.0,0.0,0.0);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
inline void G4VFacet::ApplyTranslation(const G4ThreeVector v)
|
||||
{
|
||||
P0 += v;
|
||||
for (G4ThreeVectorList::iterator it=P.begin(); it!=P.end(); it++)
|
||||
(*it) += v;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
inline G4bool G4VFacet::operator== (const G4VFacet &right) const
|
||||
{
|
||||
G4double tolerance = kCarTolerance*kCarTolerance/4.0;
|
||||
if (nVertices != right.GetNumberOfVertices())
|
||||
return false;
|
||||
else if ((centroid-right.GetCentroid()).mag2() > tolerance)
|
||||
return false;
|
||||
else if (std::fabs((right.GetSurfaceNormal()).dot(surfaceNormal)) < 0.9999999999)
|
||||
return false;
|
||||
|
||||
G4bool coincident = true;
|
||||
size_t i = 0;
|
||||
do
|
||||
{
|
||||
coincident = false;
|
||||
size_t j = 0;
|
||||
do
|
||||
{
|
||||
coincident = (GetVertex(i)-right.GetVertex(j)).mag2() < tolerance;
|
||||
} while (!coincident && j++ < nVertices);
|
||||
} while (coincident && i++ < nVertices);
|
||||
|
||||
return coincident;
|
||||
if (i == 0) { return P0; }
|
||||
else if (i < nVertices) { return P[i-1]; }
|
||||
else { return G4ThreeVector(0.0,0.0,0.0); }
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -174,31 +116,3 @@ inline G4double G4VFacet::GetRadius () const
|
||||
//
|
||||
inline G4double G4VFacet::GetRadiusSquared () const
|
||||
{return radiusSqr;}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
inline G4VFacet* G4VFacet::GetClone ()
|
||||
{return 0;}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
inline G4double G4VFacet::Distance (const G4ThreeVector&, const G4double)
|
||||
{return kInfinity;}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
inline G4double G4VFacet::Distance (const G4ThreeVector&, const G4double,
|
||||
const G4bool)
|
||||
{return kInfinity;}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
inline G4double G4VFacet::Extent (const G4ThreeVector)
|
||||
{return 0.0;}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
inline G4bool G4VFacet::Intersect (const G4ThreeVector&, const G4ThreeVector &,
|
||||
const G4bool , G4double &, G4double &,
|
||||
G4ThreeVector &)
|
||||
{return false;}
|
||||
|
||||
@@ -0,0 +1,675 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ExtrudedSolid.cc,v 1.7 2007/05/02 14:59:31 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
//
|
||||
// G4ExtrudedSolid.cc
|
||||
//
|
||||
// Author: Ivana Hrivnacova, IPN Orsay
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include "G4ExtrudedSolid.hh"
|
||||
#include "G4TriangularFacet.hh"
|
||||
#include "G4QuadrangularFacet.hh"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4ExtrudedSolid::G4ExtrudedSolid( const G4String& pName,
|
||||
std::vector<G4TwoVector> polygon,
|
||||
std::vector<ZSection> zsections)
|
||||
: G4TessellatedSolid(pName),
|
||||
fNv(polygon.size()),
|
||||
fNz(zsections.size()),
|
||||
fPolygon(),
|
||||
fZSections(),
|
||||
fTriangles(),
|
||||
fIsConvex(false),
|
||||
fGeometryType("G4ExtrudedSolid")
|
||||
|
||||
{
|
||||
// General constructor
|
||||
|
||||
// First check input parameters
|
||||
|
||||
if ( fNv < 3 ) {
|
||||
G4Exception(
|
||||
"G4ExtrudedSolid::G4ExtrudedSolid()", "InvalidSetup",
|
||||
FatalException, "Number of polygon vertices < 3");
|
||||
}
|
||||
|
||||
if ( fNz < 2 ) {
|
||||
G4Exception(
|
||||
"G4ExtrudedSolid::G4ExtrudedSolid()", "InvalidSetup",
|
||||
FatalException, "Number of z-sides < 2");
|
||||
}
|
||||
|
||||
for ( G4int i=0; i<fNz-1; ++i )
|
||||
{
|
||||
if ( zsections[i].fZ > zsections[i+1].fZ )
|
||||
{
|
||||
G4Exception(
|
||||
"G4ExtrudedSolid::G4ExtrudedSolid()", "InvalidSetup",
|
||||
FatalException,
|
||||
"Z-sections have to be ordered by z value (z0 < z1 < z2 ...)");
|
||||
}
|
||||
if ( std::fabs( zsections[i+1].fZ - zsections[i].fZ ) < kCarTolerance )
|
||||
{
|
||||
G4Exception(
|
||||
"G4ExtrudedSolid::G4ExtrudedSolid()", "InvalidSetup",
|
||||
FatalException,
|
||||
"Z-sections with the same z position are not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
// Copy polygon
|
||||
//
|
||||
for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[i]); }
|
||||
|
||||
// Copy z-sections
|
||||
//
|
||||
for ( G4int i=0; i<fNz; ++i ) { fZSections.push_back(zsections[i]); }
|
||||
|
||||
|
||||
G4bool result = MakeFacets();
|
||||
if (!result)
|
||||
{
|
||||
G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "InvalidSetup",
|
||||
FatalException, "Making facets failed.");
|
||||
}
|
||||
fIsConvex = IsConvex();
|
||||
|
||||
|
||||
ComputeProjectionParameters();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4ExtrudedSolid::G4ExtrudedSolid( const G4String& pName,
|
||||
std::vector<G4TwoVector> polygon,
|
||||
G4double dz,
|
||||
G4TwoVector off1, G4double scale1,
|
||||
G4TwoVector off2, G4double scale2 )
|
||||
: G4TessellatedSolid(pName),
|
||||
fNv(polygon.size()),
|
||||
fNz(2),
|
||||
fPolygon(),
|
||||
fZSections(),
|
||||
fTriangles(),
|
||||
fIsConvex(false),
|
||||
fGeometryType("G4ExtrudedSolid")
|
||||
|
||||
{
|
||||
// Special constructor for solid with 2 z-sections
|
||||
|
||||
// First check input parameters
|
||||
//
|
||||
if ( fNv < 3 )
|
||||
{
|
||||
G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "InvalidSetup",
|
||||
FatalException, "Number of polygon vertices < 3");
|
||||
}
|
||||
|
||||
// Copy polygon
|
||||
//
|
||||
for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[i]); }
|
||||
|
||||
// Copy z-sections
|
||||
//
|
||||
fZSections.push_back(ZSection(-dz, off1, scale1));
|
||||
fZSections.push_back(ZSection( dz, off2, scale2));
|
||||
|
||||
G4bool result = MakeFacets();
|
||||
if (!result)
|
||||
{
|
||||
G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "InvalidSetup",
|
||||
FatalException, "Making facets failed.");
|
||||
}
|
||||
fIsConvex = IsConvex();
|
||||
|
||||
ComputeProjectionParameters();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4ExtrudedSolid::G4ExtrudedSolid( __void__& a )
|
||||
: G4TessellatedSolid(a)
|
||||
{
|
||||
// Fake default constructor - sets only member data and allocates memory
|
||||
// for usage restricted to object persistency.
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4ExtrudedSolid::~G4ExtrudedSolid()
|
||||
{
|
||||
// Destructor
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
void G4ExtrudedSolid::ComputeProjectionParameters()
|
||||
{
|
||||
// Compute parameters for point projections p(z)
|
||||
// to the polygon scale & offset:
|
||||
// scale(z) = k*z + scale0
|
||||
// offset(z) = l*z + offset0
|
||||
// p(z) = scale(z)*p0 + offset(z)
|
||||
// p0 = (p(z) - offset(z))/scale(z);
|
||||
//
|
||||
|
||||
for ( G4int iz=0; iz<fNz-1; ++iz)
|
||||
{
|
||||
G4double z1 = fZSections[iz].fZ;
|
||||
G4double z2 = fZSections[iz+1].fZ;
|
||||
G4double scale1 = fZSections[iz].fScale;
|
||||
G4double scale2 = fZSections[iz+1].fScale;
|
||||
G4TwoVector off1 = fZSections[iz].fOffset;
|
||||
G4TwoVector off2 = fZSections[iz+1].fOffset;
|
||||
|
||||
G4double kscale = (scale2 - scale1)/(z2 - z1);
|
||||
G4double scale0 = scale2 - kscale*(z2 - z1)/2.0;
|
||||
G4TwoVector koff = (off2 - off1)/(z2 - z1);
|
||||
G4TwoVector off0 = off2 - koff*(z2 - z1)/2.0;
|
||||
|
||||
fKScales.push_back(kscale);
|
||||
fScale0s.push_back(scale0);
|
||||
fKOffsets.push_back(koff);
|
||||
fOffset0s.push_back(off0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4ThreeVector G4ExtrudedSolid::GetVertex(G4int iz, G4int ind) const
|
||||
{
|
||||
// Shift and scale vertices
|
||||
|
||||
return G4ThreeVector( fPolygon[ind].x() * fZSections[iz].fScale
|
||||
+ fZSections[iz].fOffset.x(),
|
||||
fPolygon[ind].y() * fZSections[iz].fScale
|
||||
+ fZSections[iz].fOffset.y(), fZSections[iz].fZ);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
|
||||
G4TwoVector G4ExtrudedSolid::ProjectPoint(const G4ThreeVector& point) const
|
||||
{
|
||||
// Project point in the polygon scale
|
||||
// scale(z) = k*z + scale0
|
||||
// offset(z) = l*z + offset0
|
||||
// p(z) = scale(z)*p0 + offset(z)
|
||||
// p0 = (p(z) - offset(z))/scale(z);
|
||||
|
||||
// Select projection (z-segment of the solid) according to p.z()
|
||||
//
|
||||
G4int iz = 0;
|
||||
while ( point.z() > fZSections[iz+1].fZ && iz < fNz-2 ) { ++iz; }
|
||||
|
||||
G4double z0 = ( fZSections[iz+1].fZ + fZSections[iz].fZ )/2.0;
|
||||
G4TwoVector p2(point.x(), point.y());
|
||||
G4double pscale = fKScales[iz]*(point.z()-z0) + fScale0s[iz];
|
||||
G4TwoVector poffset = fKOffsets[iz]*(point.z()-z0) + fOffset0s[iz];
|
||||
|
||||
// G4cout << point << " projected to "
|
||||
// << iz << "-th z-segment polygon as "
|
||||
// << (p2 - poffset)/pscale << G4endl;
|
||||
|
||||
// pscale is always >0 as it is an interpolation between two
|
||||
// positive scale values
|
||||
//
|
||||
return (p2 - poffset)/pscale;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4bool G4ExtrudedSolid::IsSameLine(G4TwoVector p,
|
||||
G4TwoVector l1, G4TwoVector l2) const
|
||||
{
|
||||
// Return true if p is on the line through l1, l2
|
||||
|
||||
if ( l1.x() == l2.x() )
|
||||
{
|
||||
return std::fabs(p.x() - l1.x()) < kCarTolerance;
|
||||
}
|
||||
return std::fabs (p.y() - l1.y() - ((l2.y() - l1.y())/(l2.x() - l1.x()))
|
||||
*(p.x() - l1.x())) < kCarTolerance;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4bool G4ExtrudedSolid::IsSameSide(G4TwoVector p1, G4TwoVector p2,
|
||||
G4TwoVector l1, G4TwoVector l2) const
|
||||
{
|
||||
// Return true if p1 and p2 are on the same side of the line through l1, l2
|
||||
|
||||
return ( (p1.x() - l1.x()) * (l2.y() - l1.y())
|
||||
- (l2.x() - l1.x()) * (p1.y() - l1.y()) )
|
||||
* ( (p2.x() - l1.x()) * (l2.y() - l1.y())
|
||||
- (l2.x() - l1.x()) * (p2.y() - l1.y()) ) > 0;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4bool G4ExtrudedSolid::IsPointInside(G4TwoVector a, G4TwoVector b,
|
||||
G4TwoVector c, G4TwoVector p) const
|
||||
{
|
||||
// Return true if p is inside of triangle abc, else returns false
|
||||
|
||||
// Check extent first
|
||||
//
|
||||
if ( ( p.x() < a.x() && p.x() < b.x() && p.x() < c.x() ) ||
|
||||
( p.x() > a.x() && p.x() > b.x() && p.x() > c.x() ) ||
|
||||
( p.y() < a.y() && p.y() < b.y() && p.y() < c.y() ) ||
|
||||
( p.y() > a.y() && p.y() > b.y() && p.y() > c.y() ) ) return false;
|
||||
|
||||
return IsSameSide(p, a, b, c)
|
||||
&& IsSameSide(p, b, a, c)
|
||||
&& IsSameSide(p, c, a, b);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4VFacet*
|
||||
G4ExtrudedSolid::MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const
|
||||
{
|
||||
// Create a triangular facet from the polygon points given by indices
|
||||
// forming the down side ( the normal goes in -z)
|
||||
|
||||
std::vector<G4ThreeVector> vertices;
|
||||
vertices.push_back(GetVertex(0, ind1));
|
||||
vertices.push_back(GetVertex(0, ind2));
|
||||
vertices.push_back(GetVertex(0, ind3));
|
||||
|
||||
// first vertex most left
|
||||
//
|
||||
G4ThreeVector cross
|
||||
= (vertices[1]-vertices[0]).cross(vertices[2]-vertices[1]);
|
||||
|
||||
if ( cross.z() > 0.0 )
|
||||
{
|
||||
// vertices ardered clock wise has to be reordered
|
||||
|
||||
// G4cout << "G4ExtrudedSolid::MakeDownFacet: reordering vertices "
|
||||
// << ind1 << ", " << ind2 << ", " << ind3 << G4endl;
|
||||
|
||||
G4ThreeVector tmp = vertices[1];
|
||||
vertices[1] = vertices[2];
|
||||
vertices[2] = tmp;
|
||||
}
|
||||
|
||||
return new G4TriangularFacet(vertices[0], vertices[1],
|
||||
vertices[2], ABSOLUTE);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4VFacet*
|
||||
G4ExtrudedSolid::MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const
|
||||
{
|
||||
// Creates a triangular facet from the polygon points given by indices
|
||||
// forming the upper side ( z>0 )
|
||||
|
||||
std::vector<G4ThreeVector> vertices;
|
||||
vertices.push_back(GetVertex(fNz-1, ind1));
|
||||
vertices.push_back(GetVertex(fNz-1, ind2));
|
||||
vertices.push_back(GetVertex(fNz-1, ind3));
|
||||
|
||||
// first vertex most left
|
||||
//
|
||||
G4ThreeVector cross
|
||||
= (vertices[1]-vertices[0]).cross(vertices[2]-vertices[1]);
|
||||
|
||||
if ( cross.z() < 0.0 )
|
||||
{
|
||||
// vertices ordered clock wise has to be reordered
|
||||
|
||||
// G4cout << "G4ExtrudedSolid::MakeUpFacet: reordering vertices "
|
||||
// << ind1 << ", " << ind2 << ", " << ind3 << G4endl;
|
||||
|
||||
G4ThreeVector tmp = vertices[1];
|
||||
vertices[1] = vertices[2];
|
||||
vertices[2] = tmp;
|
||||
}
|
||||
|
||||
return new G4TriangularFacet(vertices[0], vertices[1],
|
||||
vertices[2], ABSOLUTE);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4bool G4ExtrudedSolid::AddGeneralPolygonFacets()
|
||||
{
|
||||
// Decompose polygonal sides in triangular facets
|
||||
|
||||
typedef std::pair < G4TwoVector, G4int > Vertex;
|
||||
|
||||
// Fill one more vector
|
||||
//
|
||||
std::vector< Vertex > verticesToBeDone;
|
||||
for ( G4int i=0; i<fNv; ++i )
|
||||
{
|
||||
verticesToBeDone.push_back(Vertex(fPolygon[i], i));
|
||||
}
|
||||
std::vector< Vertex > ears;
|
||||
|
||||
std::vector< Vertex >::iterator c1 = verticesToBeDone.begin();
|
||||
std::vector< Vertex >::iterator c2 = c1+1;
|
||||
std::vector< Vertex >::iterator c3 = c1+2;
|
||||
while ( verticesToBeDone.size()>2 )
|
||||
{
|
||||
|
||||
// G4cout << "Looking at triangle : "
|
||||
// << c1->second << " " << c2->second
|
||||
// << " " << c3->second << G4endl;
|
||||
|
||||
G4bool good = true;
|
||||
std::vector< Vertex >::iterator it;
|
||||
for ( it=verticesToBeDone.begin(); it != verticesToBeDone.end(); ++it )
|
||||
{
|
||||
// skip vertices of tested triangle
|
||||
//
|
||||
if ( it == c1 || it == c2 || it == c3 ) { continue; }
|
||||
if ( IsPointInside(c1->first, c2->first, c3->first, it->first) )
|
||||
{
|
||||
// G4cout << "Point " << it->second << " is inside" << G4endl;
|
||||
good = false;
|
||||
|
||||
// try next three consecutive vertices
|
||||
//
|
||||
c1 = c2;
|
||||
c2 = c3;
|
||||
++c3;
|
||||
if ( c3 == verticesToBeDone.end() ) { c3 = verticesToBeDone.begin(); }
|
||||
break;
|
||||
}
|
||||
// else
|
||||
// { G4cout << "Point " << it->second << " is outside" << G4endl; }
|
||||
}
|
||||
if ( good )
|
||||
{
|
||||
// all points are outside triangle, we can make a facet
|
||||
|
||||
// G4cout << "Found triangle : "
|
||||
// << c1->second << " " << c2->second
|
||||
// << " " << c3->second << G4endl;
|
||||
|
||||
G4bool result;
|
||||
result = AddFacet( MakeDownFacet(c1->second, c2->second, c3->second) );
|
||||
if ( ! result ) { return false; }
|
||||
|
||||
result = AddFacet( MakeUpFacet(c1->second, c2->second, c3->second) );
|
||||
if ( ! result ) { return false; }
|
||||
|
||||
std::vector<G4int> triangle(3);
|
||||
triangle[0] = c1->second;
|
||||
triangle[1] = c2->second;
|
||||
triangle[2] = c3->second;
|
||||
fTriangles.push_back(triangle);
|
||||
|
||||
// remove the ear point from verticesToBeDone
|
||||
//
|
||||
verticesToBeDone.erase(c2);
|
||||
c1 = verticesToBeDone.begin();
|
||||
c2 = c1+1;
|
||||
c3 = c1+2;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4bool G4ExtrudedSolid::MakeFacets()
|
||||
{
|
||||
// Define facets
|
||||
|
||||
G4bool good;
|
||||
|
||||
// The quadrangular sides
|
||||
//
|
||||
for ( G4int iz = 0; iz < fNz-1; ++iz )
|
||||
{
|
||||
for ( G4int i = 0; i < fNv; ++i )
|
||||
{
|
||||
G4int j = (i+1) % fNv;
|
||||
good = AddFacet( new G4QuadrangularFacet
|
||||
( GetVertex(iz, j), GetVertex(iz, i),
|
||||
GetVertex(iz+1, i), GetVertex(iz+1, j), ABSOLUTE) );
|
||||
if ( ! good ) { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
// Decomposition of polygonal sides in the facets
|
||||
//
|
||||
if ( fNv == 3 )
|
||||
{
|
||||
good = AddFacet( new G4TriangularFacet( GetVertex(0, 0), GetVertex(0, 1),
|
||||
GetVertex(0, 2), ABSOLUTE) );
|
||||
if ( ! good ) { return false; }
|
||||
|
||||
good = AddFacet( new G4TriangularFacet( GetVertex(fNz-1, 2), GetVertex(fNz-1, 1),
|
||||
GetVertex(fNz-1, 0), ABSOLUTE) );
|
||||
if ( ! good ) { return false; }
|
||||
}
|
||||
|
||||
else if ( fNv == 4 )
|
||||
{
|
||||
good = AddFacet( new G4QuadrangularFacet( GetVertex(0, 0),GetVertex(0, 1),
|
||||
GetVertex(0, 2),GetVertex(0, 3),
|
||||
ABSOLUTE) );
|
||||
if ( ! good ) { return false; }
|
||||
|
||||
good = AddFacet( new G4QuadrangularFacet( GetVertex(fNz-1, 3), GetVertex(fNz-1, 2),
|
||||
GetVertex(fNz-1, 1), GetVertex(1, 0),
|
||||
ABSOLUTE) );
|
||||
if ( ! good ) { return false; }
|
||||
}
|
||||
else
|
||||
{
|
||||
good = AddGeneralPolygonFacets();
|
||||
if ( ! good ) { return false; }
|
||||
}
|
||||
|
||||
SetSolidClosed(true);
|
||||
|
||||
return good;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4bool G4ExtrudedSolid::IsConvex() const
|
||||
{
|
||||
// Get polygon convexity (polygon is convex if all vertex angles are < pi )
|
||||
|
||||
for ( G4int i=0; i< fNv; ++i )
|
||||
{
|
||||
G4int j = ( i + 1 ) % fNv;
|
||||
G4int k = ( i + 2 ) % fNv;
|
||||
G4TwoVector v1 = fPolygon[i]-fPolygon[j];
|
||||
G4TwoVector v2 = fPolygon[k]-fPolygon[j];
|
||||
G4double dphi = v2.phi() - v1.phi();
|
||||
if ( dphi < 0. ) { dphi += 2.*pi; }
|
||||
|
||||
if ( dphi >= pi ) { return false; }
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4GeometryType G4ExtrudedSolid::GetEntityType () const
|
||||
{
|
||||
// Return entity type
|
||||
|
||||
return fGeometryType;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
EInside G4ExtrudedSolid::Inside (const G4ThreeVector &p) const
|
||||
{
|
||||
// Override the base class function as it fails in case of concave polygon.
|
||||
// Project the point in the original polygon scale and check if it is inside
|
||||
// for each triangle.
|
||||
|
||||
// Check first if outside extent
|
||||
//
|
||||
if ( p.x() < GetMinXExtent() - kCarTolerance ||
|
||||
p.x() > GetMaxXExtent() + kCarTolerance ||
|
||||
p.y() < GetMinYExtent() - kCarTolerance ||
|
||||
p.y() > GetMaxYExtent() + kCarTolerance ||
|
||||
p.z() < GetMinZExtent() - kCarTolerance ||
|
||||
p.z() > GetMaxZExtent() + kCarTolerance )
|
||||
{
|
||||
// G4cout << "G4ExtrudedSolid::Outside extent: " << p << G4endl;
|
||||
return kOutside;
|
||||
}
|
||||
|
||||
// Project point p(z) to the polygon scale p0
|
||||
//
|
||||
G4TwoVector pscaled = ProjectPoint(p);
|
||||
|
||||
// Check if on surface of polygon
|
||||
//
|
||||
for ( G4int i=0; i<fNv; ++i )
|
||||
{
|
||||
G4int j = (i+1) % fNv;
|
||||
if ( IsSameLine(pscaled, fPolygon[i], fPolygon[j]) )
|
||||
{
|
||||
// G4cout << "G4ExtrudedSolid::Inside return Surface (on polygon) "
|
||||
// << G4endl;
|
||||
|
||||
return kSurface;
|
||||
}
|
||||
}
|
||||
|
||||
// Now check if inside triangles
|
||||
//
|
||||
std::vector< std::vector<G4int> >::const_iterator it = fTriangles.begin();
|
||||
G4bool inside = false;
|
||||
do
|
||||
{
|
||||
if ( IsPointInside(fPolygon[(*it)[0]], fPolygon[(*it)[1]],
|
||||
fPolygon[(*it)[2]], pscaled) ) { inside = true; }
|
||||
++it;
|
||||
} while ( (inside == false) && (it != fTriangles.end()) );
|
||||
|
||||
if ( inside )
|
||||
{
|
||||
// Check if on surface of z sides
|
||||
//
|
||||
if ( std::fabs( p.z() - fZSections[0].fZ ) < kCarTolerance ||
|
||||
std::fabs( p.z() - fZSections[fNz-1].fZ ) < kCarTolerance )
|
||||
{
|
||||
// G4cout << "G4ExtrudedSolid::Inside return Surface (on z side)"
|
||||
// << G4endl;
|
||||
|
||||
return kSurface;
|
||||
}
|
||||
|
||||
// G4cout << "G4ExtrudedSolid::Inside return Inside" << G4endl;
|
||||
|
||||
return kInside;
|
||||
}
|
||||
|
||||
// G4cout << "G4ExtrudedSolid::Inside return Outside " << G4endl;
|
||||
|
||||
return kOutside;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4double G4ExtrudedSolid::DistanceToOut (const G4ThreeVector &p,
|
||||
const G4ThreeVector &v,
|
||||
const G4bool calcNorm,
|
||||
G4bool *validNorm,
|
||||
G4ThreeVector *n) const
|
||||
{
|
||||
// Override the base class function to redefine validNorm
|
||||
// (the solid can be concave)
|
||||
|
||||
G4double distOut =
|
||||
G4TessellatedSolid::DistanceToOut(p, v, calcNorm, validNorm, n);
|
||||
if (validNorm) { *validNorm = fIsConvex; }
|
||||
|
||||
return distOut;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
G4double G4ExtrudedSolid::DistanceToOut (const G4ThreeVector &p) const
|
||||
{
|
||||
// Override the overloaded base class function
|
||||
|
||||
return G4TessellatedSolid::DistanceToOut(p);
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
std::ostream& G4ExtrudedSolid::StreamInfo(std::ostream &os) const
|
||||
{
|
||||
os << "-----------------------------------------------------------\n"
|
||||
<< " *** Dump for solid - " << GetName() << " ***\n"
|
||||
<< " ===================================================\n"
|
||||
<< " Solid geometry type: " << fGeometryType << G4endl;
|
||||
|
||||
if ( fIsConvex)
|
||||
{ os << " Convex polygon; list of vertices:" << G4endl; }
|
||||
else
|
||||
{ os << " Concave polygon; list of vertices:" << G4endl; }
|
||||
|
||||
for ( G4int i=0; i<fNv; ++i )
|
||||
{
|
||||
os << " vx = " << fPolygon[i].x()/mm << " mm"
|
||||
<< " vy = " << fPolygon[i].y()/mm << " mm" << G4endl;
|
||||
}
|
||||
|
||||
os << " Sections:" << G4endl;
|
||||
for ( G4int iz=0; iz<fNz; ++iz )
|
||||
{
|
||||
os << " z = " << fZSections[iz].fZ/mm << " mm "
|
||||
<< " x0= " << fZSections[iz].fOffset.x()/mm << " mm "
|
||||
<< " y0= " << fZSections[iz].fOffset.y()/mm << " mm "
|
||||
<< " scale= " << fZSections[iz].fScale << G4endl;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Polycone.cc,v 1.34 2006/11/15 10:40:38 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4Polycone.cc,v 1.37 2007/04/26 13:34:04 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
@@ -411,7 +411,7 @@ G4bool G4Polycone::Reset()
|
||||
if (genericPcon)
|
||||
{
|
||||
G4cerr << "Solid " << GetName() << " built using generic construct."
|
||||
<< G4endl << "Specify original parameters first !" << G4endl;
|
||||
<< G4endl << "Not applicable to the generic construct !" << G4endl;
|
||||
G4Exception("G4Polycone::Reset()", "NotApplicableConstruct",
|
||||
JustWarning, "Parameters NOT resetted.");
|
||||
return 1;
|
||||
@@ -567,7 +567,7 @@ G4ThreeVector G4Polycone::GetPointOnCone(G4double fRmin1, G4double fRmax1,
|
||||
G4double fRmin2, G4double fRmax2,
|
||||
G4double zOne, G4double zTwo,
|
||||
G4double& totArea) const
|
||||
{
|
||||
{
|
||||
// declare working variables
|
||||
//
|
||||
G4double Aone, Atwo, Afive, phi, zRand, fDPhi, fSPhi, cosu, sinu;
|
||||
@@ -576,12 +576,16 @@ G4ThreeVector G4Polycone::GetPointOnCone(G4double fRmin1, G4double fRmax1,
|
||||
G4ThreeVector point, offset;
|
||||
offset = G4ThreeVector(0.,0.,0.5*(zTwo+zOne));
|
||||
fSPhi = startPhi; fDPhi = endPhi - startPhi;
|
||||
|
||||
rone = (fRmax1-fRmax2)/(2.*fDz);
|
||||
rtwo = (fRmin1-fRmin2)/(2.*fDz);
|
||||
qone = fDz*(fRmax1+fRmax2)/(fRmax1-fRmax2);
|
||||
qtwo = fDz*(fRmin1+fRmin2)/(fRmin1-fRmin2);
|
||||
|
||||
if(fRmax1==fRmax2){qone=0.;}
|
||||
else{
|
||||
qone = fDz*(fRmax1+fRmax2)/(fRmax1-fRmax2);
|
||||
}
|
||||
if(fRmin1==fRmin2){qtwo=0.;}
|
||||
else{
|
||||
qtwo = fDz*(fRmin1+fRmin2)/(fRmin1-fRmin2);
|
||||
}
|
||||
Aone = 0.5*fDPhi*(fRmax2 + fRmax1)*(sqr(fRmin1-fRmin2)+sqr(zTwo-zOne));
|
||||
Atwo = 0.5*fDPhi*(fRmin2 + fRmin1)*(sqr(fRmax1-fRmax2)+sqr(zTwo-zOne));
|
||||
Afive = fDz*(fRmax1-fRmin1+fRmax2-fRmin2);
|
||||
@@ -590,10 +594,10 @@ G4ThreeVector G4Polycone::GetPointOnCone(G4double fRmin1, G4double fRmax1,
|
||||
phi = RandFlat::shoot(startPhi,endPhi);
|
||||
cosu = std::cos(phi);
|
||||
sinu = std::sin(phi);
|
||||
|
||||
|
||||
|
||||
if( (startPhi == 0) && (endPhi == twopi) ) { Afive = 0; }
|
||||
chose = RandFlat::shoot(0.,Aone+Atwo+2.*Afive);
|
||||
|
||||
if( (chose >= 0) && (chose < Aone) )
|
||||
{
|
||||
if(fRmax1 != fRmax2)
|
||||
@@ -601,25 +605,30 @@ G4ThreeVector G4Polycone::GetPointOnCone(G4double fRmin1, G4double fRmax1,
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
point = G4ThreeVector (rone*cosu*(qone-zRand),
|
||||
rone*sinu*(qone-zRand), zRand);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
point = G4ThreeVector(fRmax1*cosu, fRmax1*sinu,
|
||||
RandFlat::shoot(-1.*fDz,fDz));
|
||||
|
||||
}
|
||||
}
|
||||
else if(chose >= Aone && chose < Aone + Atwo)
|
||||
{
|
||||
if(fRmin1 != fRmin2)
|
||||
{
|
||||
{
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
point = G4ThreeVector (rtwo*cosu*(qtwo-zRand),
|
||||
rtwo*sinu*(qtwo-zRand), zRand);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
point = G4ThreeVector(fRmin1*cosu, fRmin1*sinu,
|
||||
RandFlat::shoot(-1.*fDz,fDz));
|
||||
|
||||
}
|
||||
}
|
||||
else if( (chose >= Aone + Atwo + Afive) && (chose < Aone + Atwo + 2.*Afive) )
|
||||
@@ -629,6 +638,7 @@ G4ThreeVector G4Polycone::GetPointOnCone(G4double fRmin1, G4double fRmax1,
|
||||
fRmax2-((zRand-fDz)/(2.*fDz))*(fRmax1-fRmax2));
|
||||
point = G4ThreeVector (rRand1*std::cos(startPhi),
|
||||
rRand1*std::sin(startPhi), zRand);
|
||||
G4cout<<"Point3="<<point<<G4endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -637,6 +647,7 @@ G4ThreeVector G4Polycone::GetPointOnCone(G4double fRmin1, G4double fRmax1,
|
||||
fRmax2-((zRand-fDz)/(2.*fDz))*(fRmax1-fRmax2));
|
||||
point = G4ThreeVector (rRand1*std::cos(endPhi),
|
||||
rRand1*std::sin(endPhi), zRand);
|
||||
|
||||
}
|
||||
return point+offset;
|
||||
}
|
||||
@@ -650,7 +661,7 @@ G4ThreeVector G4Polycone::GetPointOnCone(G4double fRmin1, G4double fRmax1,
|
||||
G4ThreeVector G4Polycone::GetPointOnTubs(G4double fRMin, G4double fRMax,
|
||||
G4double zOne, G4double zTwo,
|
||||
G4double& totArea) const
|
||||
{
|
||||
{
|
||||
G4double xRand,yRand,zRand,phi,cosphi,sinphi,chose,
|
||||
aOne,aTwo,aFou,rRand,fDz,fSPhi,fDPhi;
|
||||
fDz = std::fabs(0.5*(zTwo-zOne));
|
||||
@@ -661,7 +672,6 @@ G4ThreeVector G4Polycone::GetPointOnTubs(G4double fRMin, G4double fRMax,
|
||||
aTwo = 2.*fDz*fDPhi*fRMin;
|
||||
aFou = 2.*fDz*(fRMax-fRMin);
|
||||
totArea = aOne+aTwo+2.*aFou;
|
||||
|
||||
phi = RandFlat::shoot(startPhi,endPhi);
|
||||
cosphi = std::cos(phi);
|
||||
sinphi = std::sin(phi);
|
||||
@@ -702,6 +712,50 @@ G4ThreeVector G4Polycone::GetPointOnTubs(G4double fRMin, G4double fRMax,
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetPointOnRing
|
||||
//
|
||||
// Auxiliary method for GetPoint On Surface
|
||||
//
|
||||
G4ThreeVector G4Polycone::GetPointOnRing(G4double fRMin1, G4double fRMax1,
|
||||
G4double fRMin2,G4double fRMax2,
|
||||
G4double zOne) const
|
||||
{
|
||||
G4double xRand,yRand,phi,cosphi,sinphi,rRand1,rRand2,A1,Atot,rCh;
|
||||
|
||||
phi = RandFlat::shoot(startPhi,endPhi);
|
||||
cosphi = std::cos(phi);
|
||||
sinphi = std::sin(phi);
|
||||
|
||||
if(fRMin1==fRMin2)
|
||||
{
|
||||
rRand1 = fRMin1; A1=0.;
|
||||
}
|
||||
else
|
||||
{
|
||||
rRand1 = RandFlat::shoot(fRMin1,fRMin2);
|
||||
A1=std::abs(fRMin2*fRMin2-fRMin1*fRMin1);
|
||||
}
|
||||
if(fRMax1==fRMax2)
|
||||
{
|
||||
rRand2=fRMax1; Atot=A1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rRand2 = RandFlat::shoot(fRMax1,fRMax2);
|
||||
Atot = A1+std::abs(fRMax2*fRMax2-fRMax1*fRMax1);
|
||||
}
|
||||
rCh = RandFlat::shoot(0.,Atot);
|
||||
|
||||
if(rCh>A1) { rRand1=rRand2; }
|
||||
|
||||
xRand = rRand1*cosphi;
|
||||
yRand = rRand1*sinphi;
|
||||
|
||||
return G4ThreeVector(xRand, yRand, zOne);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetPointOnCut
|
||||
//
|
||||
@@ -711,12 +765,15 @@ G4ThreeVector G4Polycone::GetPointOnCut(G4double fRMin1, G4double fRMax1,
|
||||
G4double fRMin2, G4double fRMax2,
|
||||
G4double zOne, G4double zTwo,
|
||||
G4double& totArea) const
|
||||
{
|
||||
if( (fRMin1 == fRMin2) && (fRMax1 == fRMax2) )
|
||||
{
|
||||
return GetPointOnTubs(fRMin1, fRMax1,zOne,zTwo,totArea);
|
||||
}
|
||||
return GetPointOnCone(fRMin1,fRMax1,fRMin2,fRMax2,zOne,zTwo,totArea);
|
||||
{ if(zOne==zTwo)
|
||||
{
|
||||
return GetPointOnRing(fRMin1, fRMax1,fRMin2,fRMax2,zOne);
|
||||
}
|
||||
if( (fRMin1 == fRMin2) && (fRMax1 == fRMax2) )
|
||||
{
|
||||
return GetPointOnTubs(fRMin1, fRMax1,zOne,zTwo,totArea);
|
||||
}
|
||||
return GetPointOnCone(fRMin1,fRMax1,fRMin2,fRMax2,zOne,zTwo,totArea);
|
||||
}
|
||||
|
||||
|
||||
@@ -724,7 +781,7 @@ G4ThreeVector G4Polycone::GetPointOnCut(G4double fRMin1, G4double fRMax1,
|
||||
// GetPointOnSurface
|
||||
//
|
||||
G4ThreeVector G4Polycone::GetPointOnSurface() const
|
||||
{
|
||||
{
|
||||
G4double Area=0,totArea=0,Achose1=0,Achose2=0,phi,cosphi,sinphi,rRand;
|
||||
G4int i=0;
|
||||
G4int numPlanes = original_parameters->Num_z_planes;
|
||||
@@ -788,7 +845,7 @@ G4ThreeVector G4Polycone::GetPointOnSurface() const
|
||||
Achose1 += areas[i];
|
||||
Achose2 = (Achose1+areas[i+1]);
|
||||
if(chose>=Achose1 && chose<Achose2)
|
||||
{
|
||||
{// G4cout<<"will return Point On Cut"<<G4endl;
|
||||
return GetPointOnCut(original_parameters->Rmin[i],
|
||||
original_parameters->Rmax[i],
|
||||
original_parameters->Rmin[i+1],
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4PolyconeSide.cc,v 1.13 2006/06/29 18:48:44 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4PolyconeSide.cc,v 1.14 2007/02/01 09:20:33 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
@@ -930,7 +930,10 @@ G4double G4PolyconeSide::DistanceAway( const G4ThreeVector &p,
|
||||
G4double dist = d1*rx;
|
||||
|
||||
distOutside2 += dist*dist;
|
||||
if (edgeRZnorm) *edgeRZnorm = std::max(*edgeRZnorm,std::fabs(dist));
|
||||
if (edgeRZnorm)
|
||||
{
|
||||
*edgeRZnorm = std::max(std::fabs(*edgeRZnorm),std::fabs(dist));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Polyhedra.cc,v 1.32 2006/11/08 09:49:51 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4Polyhedra.cc,v 1.33 2007/01/22 12:58:53 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
@@ -100,7 +100,7 @@ G4Polyhedra::G4Polyhedra( const G4String& name,
|
||||
//
|
||||
G4double phiTotal = thePhiTotal;
|
||||
if ( (phiTotal <=0) || (phiTotal >= twopi*(1-DBL_EPSILON)) )
|
||||
phiTotal = twopi;
|
||||
{ phiTotal = twopi; }
|
||||
G4double convertRad = std::cos(0.5*phiTotal/theNumSide);
|
||||
|
||||
//
|
||||
@@ -176,7 +176,7 @@ G4Polyhedra::G4Polyhedra( const G4String& name,
|
||||
|
||||
// Set original_parameters struct for consistency
|
||||
//
|
||||
SetOriginalParameters(); // In .icc; looks dodgy to me (J.Allison). Ignore.
|
||||
SetOriginalParameters();
|
||||
|
||||
delete rz;
|
||||
}
|
||||
@@ -459,17 +459,17 @@ void G4Polyhedra::CopyStuff( const G4Polyhedra &source )
|
||||
//
|
||||
// Reset
|
||||
//
|
||||
// Recalculates and reshapes the solid, given pre-assigned
|
||||
// Recalculates and reshapes the solid, given pre-assigned scaled
|
||||
// original_parameters.
|
||||
//
|
||||
G4bool G4Polyhedra::Reset()
|
||||
{
|
||||
if (genericPgon)
|
||||
{
|
||||
G4cerr << "Solid " << GetName() << " built using generic construct."
|
||||
<< G4endl << "Not applicable to the generic construct !" << G4endl;
|
||||
G4Exception("G4Polyhedra::Reset()", "NotApplicableConstruct",
|
||||
JustWarning, "Parameters NOT resetted.");
|
||||
G4cerr << "Solid " << GetName() << " built using generic construct."
|
||||
<< G4endl << "Specify original parameters first !" << G4endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -488,16 +488,8 @@ G4bool G4Polyhedra::Reset()
|
||||
original_parameters->Rmax,
|
||||
original_parameters->Z_values,
|
||||
original_parameters->Num_z_planes );
|
||||
//
|
||||
// Calculate conversion factor
|
||||
//
|
||||
G4double phiTotal = original_parameters->Opening_angle;
|
||||
if ( (phiTotal <=0) || (phiTotal >= twopi*(1-DBL_EPSILON)) )
|
||||
phiTotal = twopi;
|
||||
G4double convertRad = std::cos(0.5*phiTotal/original_parameters->numSide);
|
||||
rz->ScaleA( 1/convertRad );
|
||||
|
||||
Create( original_parameters->Start_angle, phiTotal,
|
||||
Create( original_parameters->Start_angle,
|
||||
original_parameters->Opening_angle,
|
||||
original_parameters->numSide, rz );
|
||||
delete rz;
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4QuadrangularFacet.cc,v 1.3 2006/06/29 18:48:51 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4QuadrangularFacet.cc,v 1.5 2007/02/15 17:04:10 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
//
|
||||
@@ -48,6 +48,7 @@
|
||||
|
||||
#include "G4QuadrangularFacet.hh"
|
||||
#include "globals.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -255,8 +256,9 @@ G4bool G4QuadrangularFacet::Intersect (const G4ThreeVector &p,
|
||||
G4bool intersect =
|
||||
facet1->Intersect(p,v,outgoing,distance,distFromSurface,normal);
|
||||
if (!intersect)
|
||||
intersect =
|
||||
facet2->Intersect(p,v,outgoing,distance,distFromSurface,normal);
|
||||
{
|
||||
intersect = facet2->Intersect(p,v,outgoing,distance,distFromSurface,normal);
|
||||
}
|
||||
|
||||
if (!intersect)
|
||||
{
|
||||
@@ -267,3 +269,38 @@ G4bool G4QuadrangularFacet::Intersect (const G4ThreeVector &p,
|
||||
|
||||
return intersect;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GetPointOnFace
|
||||
//
|
||||
// Auxiliary method for get a random point on surface
|
||||
|
||||
G4ThreeVector G4QuadrangularFacet::GetPointOnFace() const
|
||||
{
|
||||
G4ThreeVector pr;
|
||||
|
||||
if ( G4UniformRand() < 0.5 )
|
||||
{
|
||||
pr = facet1->GetPointOnFace();
|
||||
}
|
||||
else
|
||||
{
|
||||
pr = facet2->GetPointOnFace();
|
||||
}
|
||||
|
||||
return pr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GetArea
|
||||
//
|
||||
// Auxiliary method for returning the surface area
|
||||
|
||||
G4double G4QuadrangularFacet::GetArea()
|
||||
{
|
||||
if (!area) { area = facet1->GetArea() + facet2->GetArea(); }
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4TessellatedSolid.cc,v 1.5 2006/10/20 13:45:21 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4TessellatedSolid.cc,v 1.9 2007/02/12 12:08:33 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
//
|
||||
@@ -54,6 +54,7 @@
|
||||
#include "G4TessellatedSolid.hh"
|
||||
#include "G4PolyhedronArbitrary.hh"
|
||||
#include "globals.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -123,14 +124,26 @@ G4TessellatedSolid::~G4TessellatedSolid ()
|
||||
DeleteObjects ();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Define copy constructor.
|
||||
//
|
||||
G4TessellatedSolid::G4TessellatedSolid (const G4TessellatedSolid &s)
|
||||
: G4VSolid(s)
|
||||
{
|
||||
if (&s == this) { return; }
|
||||
|
||||
CopyObjects (s);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Define assignment operator.
|
||||
//
|
||||
const G4TessellatedSolid &G4TessellatedSolid::operator=
|
||||
(const G4TessellatedSolid &s)
|
||||
const G4TessellatedSolid &
|
||||
G4TessellatedSolid::operator= (const G4TessellatedSolid &s)
|
||||
{
|
||||
if (&s == this) return *this;
|
||||
if (&s == this) { return *this; }
|
||||
|
||||
DeleteObjects ();
|
||||
CopyObjects (s);
|
||||
@@ -142,8 +155,10 @@ const G4TessellatedSolid &G4TessellatedSolid::operator=
|
||||
//
|
||||
void G4TessellatedSolid::DeleteObjects ()
|
||||
{
|
||||
for (std::vector<G4VFacet *>::iterator f=facets.begin();
|
||||
f!=facets.end(); f++) delete *f;
|
||||
for (std::vector<G4VFacet *>::iterator f=facets.begin(); f!=facets.end(); f++)
|
||||
{
|
||||
delete *f;
|
||||
}
|
||||
facets.clear();
|
||||
}
|
||||
|
||||
@@ -321,6 +336,16 @@ size_t G4TessellatedSolid::GetNumberOfFacets () const
|
||||
//
|
||||
EInside G4TessellatedSolid::Inside (const G4ThreeVector &p) const
|
||||
{
|
||||
if ( p.x() < xMinExtent - kCarTolerance ||
|
||||
p.x() > xMaxExtent + kCarTolerance ||
|
||||
p.y() < yMinExtent - kCarTolerance ||
|
||||
p.y() > yMaxExtent + kCarTolerance ||
|
||||
p.z() < zMinExtent - kCarTolerance ||
|
||||
p.z() > zMaxExtent + kCarTolerance )
|
||||
{
|
||||
return kOutside;
|
||||
}
|
||||
|
||||
G4double minDist = kInfinity;
|
||||
G4double dist = 0.0;
|
||||
typedef std::multimap< G4double, FacetCI, std::less<G4double> > DistMapType;
|
||||
@@ -372,6 +397,7 @@ G4ThreeVector G4TessellatedSolid::SurfaceNormal (const G4ThreeVector &p) const
|
||||
FacetCI minFacet;
|
||||
G4double minDist = kInfinity;
|
||||
G4double dist = 0.0;
|
||||
G4ThreeVector normal;
|
||||
|
||||
for (FacetCI f=facets.begin(); f!=facets.end(); f++)
|
||||
{
|
||||
@@ -383,7 +409,23 @@ G4ThreeVector G4TessellatedSolid::SurfaceNormal (const G4ThreeVector &p) const
|
||||
}
|
||||
}
|
||||
|
||||
return (*minFacet)->GetSurfaceNormal();
|
||||
if (minDist != kInfinity)
|
||||
{
|
||||
normal = (*minFacet)->GetSurfaceNormal();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
G4cout << "WARNING - G4TessellatedSolid::SurfaceNormal(p)" << G4endl
|
||||
<< " No facets found for point: " << p << " !" << G4endl
|
||||
<< " Returning approximated value for normal." << G4endl;
|
||||
G4Exception("G4TessellatedSolid::SurfaceNormal(p)", "Notification",
|
||||
JustWarning, "Point p is not on surface !?" );
|
||||
#endif
|
||||
normal = (p.z()>0 ? G4ThreeVector(0,0,1) : G4ThreeVector(0,0,-1));
|
||||
}
|
||||
|
||||
return normal;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -747,7 +789,21 @@ G4double G4TessellatedSolid::GetCubicVolume ()
|
||||
//
|
||||
G4double G4TessellatedSolid::GetSurfaceArea ()
|
||||
{
|
||||
if(surfaceArea != 0.) {;}
|
||||
else { surfaceArea = G4VSolid::GetSurfaceArea(); }
|
||||
if(surfaceArea != 0.) { return surfaceArea; }
|
||||
|
||||
for (FacetI f=facets.begin(); f!=facets.end(); f++)
|
||||
{
|
||||
surfaceArea += (*f)->GetArea();
|
||||
}
|
||||
return surfaceArea;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4ThreeVector G4TessellatedSolid::GetPointOnSurface() const
|
||||
{
|
||||
// Select randomly a facet and return a random point on it
|
||||
|
||||
G4int i = CLHEP::RandFlat::shootInt(facets.size());
|
||||
return facets[i]->GetPointOnFace();
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4TriangularFacet.cc,v 1.5 2006/06/29 18:49:02 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4TriangularFacet.cc,v 1.7 2007/02/15 17:03:49 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
//
|
||||
@@ -48,6 +48,7 @@
|
||||
|
||||
#include "G4TriangularFacet.hh"
|
||||
#include "globals.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -451,8 +452,8 @@ G4bool G4TriangularFacet::Intersect (const G4ThreeVector &p,
|
||||
|
||||
if (intersect)
|
||||
{
|
||||
if (dist > kCarTolerance * 0.5) distance = dist;
|
||||
else dist = 0.0;
|
||||
if (dist < kCarTolerance * 0.5) { dist = 0.0; }
|
||||
distance = dist;
|
||||
distFromSurface = dist * normalComp;
|
||||
normal = surfaceNormal;
|
||||
}
|
||||
@@ -465,3 +466,42 @@ G4bool G4TriangularFacet::Intersect (const G4ThreeVector &p,
|
||||
|
||||
return intersect;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GetPointOnFace
|
||||
//
|
||||
// Auxiliary method for get a random point on surface
|
||||
|
||||
G4ThreeVector G4TriangularFacet::GetPointOnFace() const
|
||||
{
|
||||
G4double lambda1,lambda2;
|
||||
G4ThreeVector v, w;
|
||||
|
||||
v = P[1] - P[0];
|
||||
w = P[0] - P0;
|
||||
|
||||
lambda1 = CLHEP::RandFlat::shoot(0.,1.);
|
||||
lambda2 = CLHEP::RandFlat::shoot(0.,lambda1);
|
||||
|
||||
return (P0 + lambda1*w + lambda2*v);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GetArea
|
||||
//
|
||||
// Auxiliary method for returning the surface area
|
||||
|
||||
G4double G4TriangularFacet::GetArea()
|
||||
{
|
||||
if (area) { return area; }
|
||||
|
||||
G4ThreeVector v, w;
|
||||
|
||||
v = P[1] - P[0];
|
||||
w = P[0] - P0;
|
||||
area = 0.5*(v.cross(w)).mag();
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4VFacet.cc,v 1.3 2006/06/29 18:49:31 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4VFacet.cc,v 1.4 2007/02/12 09:34:45 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
//
|
||||
@@ -49,6 +49,67 @@
|
||||
#include "G4VFacet.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4VFacet::G4VFacet ()
|
||||
{
|
||||
dirTolerance = 1.0E-14;
|
||||
|
||||
P.clear();
|
||||
E.clear();
|
||||
|
||||
centroid = G4ThreeVector(0.0,0.0,0.0);
|
||||
radius = 0.0;
|
||||
radiusSqr = 0.0;
|
||||
area = 0.0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4VFacet::~G4VFacet ()
|
||||
{
|
||||
P.clear();
|
||||
E.clear();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4VFacet::operator== (const G4VFacet &right) const
|
||||
{
|
||||
G4double tolerance = kCarTolerance*kCarTolerance/4.0;
|
||||
if (nVertices != right.GetNumberOfVertices())
|
||||
{ return false; }
|
||||
else if ((centroid-right.GetCentroid()).mag2() > tolerance)
|
||||
{ return false; }
|
||||
else if (std::fabs((right.GetSurfaceNormal()).dot(surfaceNormal)) < 0.9999999999)
|
||||
{ return false; }
|
||||
|
||||
G4bool coincident = true;
|
||||
size_t i = 0;
|
||||
do
|
||||
{
|
||||
coincident = false;
|
||||
size_t j = 0;
|
||||
do
|
||||
{
|
||||
coincident = (GetVertex(i)-right.GetVertex(j)).mag2() < tolerance;
|
||||
} while (!coincident && j++ < nVertices);
|
||||
} while (coincident && i++ < nVertices);
|
||||
|
||||
return coincident;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4VFacet::ApplyTranslation(const G4ThreeVector v)
|
||||
{
|
||||
P0 += v;
|
||||
for (G4ThreeVectorList::iterator it=P.begin(); it!=P.end(); it++)
|
||||
{
|
||||
(*it) += v;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
std::ostream &G4VFacet::StreamInfo(std::ostream &os) const
|
||||
@@ -71,3 +132,31 @@ std::ostream &G4VFacet::StreamInfo(std::ostream &os) const
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4VFacet* G4VFacet::GetClone ()
|
||||
{return 0;}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4double G4VFacet::Distance (const G4ThreeVector&, const G4double)
|
||||
{return kInfinity;}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4double G4VFacet::Distance (const G4ThreeVector&, const G4double,
|
||||
const G4bool)
|
||||
{return kInfinity;}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4double G4VFacet::Extent (const G4ThreeVector)
|
||||
{return 0.0;}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4VFacet::Intersect (const G4ThreeVector&, const G4ThreeVector &,
|
||||
const G4bool , G4double &, G4double &,
|
||||
G4ThreeVector &)
|
||||
{return false;}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$Id: History,v 1.142 2006/11/10 09:45:54 gcosmo Exp $
|
||||
$Id: History,v 1.145 2007/04/11 07:56:55 gcosmo Exp $
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
@@ -17,6 +17,24 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
Apr 11th, 2007 G.Cosmo - geomvol-V08-02-02
|
||||
- More extensions to the CheckOverlaps() algorithm:
|
||||
o Added possibility to define a tolerance for reporting overlaps; added
|
||||
new argument to signature, by default tolerance is set to zero.
|
||||
o Optimised implementation for detecting daughter volumes which are
|
||||
totally overlapping.
|
||||
o Added check on current volume to optimise and correctly handle the
|
||||
case of explicit call of the method when geometry is constructed.
|
||||
|
||||
Mar 23rd, 2007 G.Cosmo - geomvol-V08-02-01
|
||||
- Extended CheckOverlaps() algorithm, detect also cases of daughter volumes
|
||||
which are totally overlapping. Made warning message message more clear.
|
||||
|
||||
Jan 31st, 2007 G.Cosmo - geomvol-V08-02-00
|
||||
- Added flag for controlling verbosity to CheckOverlaps() method for
|
||||
G4PVPlacement and G4PVParameterised. By default, verbosity is ON.
|
||||
- Requires tag "geommng-V08-02-00".
|
||||
|
||||
Nov 10th, 2006 G.Cosmo - geomvol-V08-01-00
|
||||
- Use 'direct' rotation/translation instead of 'frame' rotation/translation
|
||||
in concrete CheckOverlaps() method of G4PVPlacement and G4PVParameterised
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4PVParameterised.hh,v 1.6 2006/06/29 18:57:32 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4PVParameterised.hh,v 1.8 2007/04/11 07:56:38 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// class G4PVParameterised
|
||||
@@ -98,10 +98,12 @@ class G4PVParameterised : public G4PVReplica
|
||||
virtual void SetRegularStructureId( G4int Code );
|
||||
// Method sets code and can prepare for special type of regular volumes.
|
||||
|
||||
G4bool CheckOverlaps(G4int res=1000);
|
||||
G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true);
|
||||
// Verifies if each instance of the parameterised volume is overlapping
|
||||
// with other instances or with the mother volume. Provides default
|
||||
// resolution for the number of points to be generated and verified.
|
||||
// A tolerance for the precision of the overlap check can be specified,
|
||||
// by default it is set to maximum precision.
|
||||
// Returns true if an overlap occurs.
|
||||
|
||||
private:
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4PVPlacement.hh,v 1.6 2006/06/29 18:57:34 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4PVPlacement.hh,v 1.8 2007/04/11 07:56:38 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// class G4PVPlacement
|
||||
@@ -127,10 +127,12 @@ class G4PVPlacement : public G4VPhysicalVolume
|
||||
void SetCopyNo(G4int CopyNo);
|
||||
// Gets and sets the copy number of the volume.
|
||||
|
||||
G4bool CheckOverlaps(G4int res=1000);
|
||||
G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true);
|
||||
// Verifies if the placed volume is overlapping with existing
|
||||
// daughters or with the mother volume. Provides default resolution
|
||||
// for the number of points to be generated and verified.
|
||||
// A tolerance for the precision of the overlap check can be specified,
|
||||
// by default it is set to maximum precision.
|
||||
// Returns true if the volume is overlapping.
|
||||
|
||||
public: // without description
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4PVParameterised.cc,v 1.7 2006/11/10 09:42:27 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4PVParameterised.cc,v 1.10 2007/04/11 07:56:38 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// class G4PVParameterised
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "G4PVParameterised.hh"
|
||||
#include "G4VPVParameterisation.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
|
||||
@@ -148,7 +149,8 @@ void G4PVParameterised::SetRegularStructureId( G4int Code )
|
||||
// ----------------------------------------------------------------------
|
||||
// CheckOverlaps
|
||||
//
|
||||
G4bool G4PVParameterised::CheckOverlaps(G4int res)
|
||||
G4bool
|
||||
G4PVParameterised::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
{
|
||||
if (res<=0) { return false; }
|
||||
|
||||
@@ -157,8 +159,11 @@ G4bool G4PVParameterised::CheckOverlaps(G4int res)
|
||||
G4VSolid *motherSolid = motherLog->GetSolid();
|
||||
std::vector<G4ThreeVector> points;
|
||||
|
||||
G4cout << "Checking overlaps for parameterised volume "
|
||||
<< GetName() << " ... ";
|
||||
if (verbose)
|
||||
{
|
||||
G4cout << "Checking overlaps for parameterised volume "
|
||||
<< GetName() << " ... ";
|
||||
}
|
||||
|
||||
for (G4int i=0; i<GetMultiplicity(); i++)
|
||||
{
|
||||
@@ -183,16 +188,22 @@ G4bool G4PVParameterised::CheckOverlaps(G4int res)
|
||||
//
|
||||
if (motherSolid->Inside(mp)==kOutside)
|
||||
{
|
||||
G4cout << G4endl;
|
||||
G4cout << "WARNING - G4PVParameterised::CheckOverlaps()" << G4endl
|
||||
<< " Overlap is detected for volume "
|
||||
<< GetName() << ", parameterised instance: " << i << G4endl
|
||||
<< " with its mother volume "
|
||||
<< motherLog->GetName() << G4endl
|
||||
<< " at mother local point " << mp << G4endl;
|
||||
G4Exception("G4PVParameterised::CheckOverlaps()", "InvalidSetup",
|
||||
JustWarning, "Overlap with mother volume !");
|
||||
return true;
|
||||
G4double distin = motherSolid->DistanceToIn(mp);
|
||||
if (distin > tol)
|
||||
{
|
||||
G4cout << G4endl;
|
||||
G4cout << "WARNING - G4PVParameterised::CheckOverlaps()" << G4endl
|
||||
<< " Overlap is detected for volume "
|
||||
<< GetName() << ", parameterised instance: " << i << G4endl
|
||||
<< " with its mother volume "
|
||||
<< motherLog->GetName() << G4endl
|
||||
<< " at mother local point " << mp << ", "
|
||||
<< "overlapping by at least: " << G4BestUnit(distin, "Length")
|
||||
<< G4endl;
|
||||
G4Exception("G4PVParameterised::CheckOverlaps()", "InvalidSetup",
|
||||
JustWarning, "Overlap with mother volume !");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
points.push_back(mp);
|
||||
}
|
||||
@@ -218,21 +229,31 @@ G4bool G4PVParameterised::CheckOverlaps(G4int res)
|
||||
|
||||
if (solidB->Inside(md)==kInside)
|
||||
{
|
||||
G4cout << G4endl;
|
||||
G4cout << "WARNING - G4PVParameterised::CheckOverlaps()" << G4endl
|
||||
<< " Overlap is detected for volume "
|
||||
<< GetName() << ", parameterised instance: " << i << G4endl
|
||||
<< " with parameterised volume instance: " << j
|
||||
<< G4endl
|
||||
<< " at daughter local point " << md << G4endl;
|
||||
G4Exception("G4PVParameterised::CheckOverlaps()", "InvalidSetup",
|
||||
JustWarning, "Overlap within parameterised volumes !");
|
||||
return true;
|
||||
G4double distout = solidB->DistanceToOut(md);
|
||||
if (distout > tol)
|
||||
{
|
||||
G4cout << G4endl;
|
||||
G4cout << "WARNING - G4PVParameterised::CheckOverlaps()" << G4endl
|
||||
<< " Overlap is detected for volume "
|
||||
<< GetName() << ", parameterised instance: " << i << G4endl
|
||||
<< " with parameterised volume instance: " << j
|
||||
<< G4endl
|
||||
<< " at local point " << md << ", "
|
||||
<< "overlapping by at least: "
|
||||
<< G4BestUnit(distout, "Length")
|
||||
<< ", related to volume instance: " << j << "." << G4endl;
|
||||
G4Exception("G4PVParameterised::CheckOverlaps()", "InvalidSetup",
|
||||
JustWarning, "Overlap within parameterised volumes !");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
G4cout << "OK! " << G4endl;
|
||||
if (verbose)
|
||||
{
|
||||
G4cout << "OK! " << G4endl;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4PVPlacement.cc,v 1.12 2006/11/10 09:42:27 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4PVPlacement.cc,v 1.16 2007/04/11 07:56:38 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
//
|
||||
//
|
||||
// class G4PVPlacement Implementation
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4VSolid.hh"
|
||||
|
||||
@@ -218,10 +219,10 @@ GetReplicationData( EAxis&, G4int&, G4double&, G4double&, G4bool& ) const
|
||||
// No-operations
|
||||
}
|
||||
|
||||
// The next methods are for specialised repeated volumes
|
||||
// (replicas, parameterised vol.) which are completely regular.
|
||||
// ----------------------------------------------------------------------
|
||||
// IsRegularRepeatedStructure()
|
||||
// IsRegularRepeatedStructure
|
||||
//
|
||||
// This is for specialised repeated volumes (replicas, parameterised vol.)
|
||||
//
|
||||
G4bool G4PVPlacement::IsRegularStructure() const
|
||||
{
|
||||
@@ -229,18 +230,19 @@ G4bool G4PVPlacement::IsRegularStructure() const
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// IsRegularRepeatedStructure()
|
||||
// IsRegularRepeatedStructure
|
||||
//
|
||||
// This is for specialised repeated volumes (replicas, parameterised vol.)
|
||||
//
|
||||
G4int G4PVPlacement::GetRegularStructureId() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
// This is for specialised repeated volumes (replicas, parameterised vol.)
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// CheckOverlaps
|
||||
//
|
||||
G4bool G4PVPlacement::CheckOverlaps(G4int res)
|
||||
G4bool G4PVPlacement::CheckOverlaps(G4int res, G4double tol, G4bool verbose)
|
||||
{
|
||||
if (res<=0) { return false; }
|
||||
|
||||
@@ -248,7 +250,12 @@ G4bool G4PVPlacement::CheckOverlaps(G4int res)
|
||||
G4LogicalVolume* motherLog = GetMotherLogical();
|
||||
if (!motherLog) { return false; }
|
||||
|
||||
G4cout << "Checking overlaps for volume " << GetName() << " ... ";
|
||||
G4VSolid* motherSolid = motherLog->GetSolid();
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
G4cout << "Checking overlaps for volume " << GetName() << " ... ";
|
||||
}
|
||||
|
||||
// Create the transformation from daughter to mother
|
||||
//
|
||||
@@ -266,26 +273,34 @@ G4bool G4PVPlacement::CheckOverlaps(G4int res)
|
||||
|
||||
// Checking overlaps with the mother volume
|
||||
//
|
||||
if (motherLog->GetSolid()->Inside(mp)==kOutside)
|
||||
if (motherSolid->Inside(mp)==kOutside)
|
||||
{
|
||||
G4cout << G4endl;
|
||||
G4cout << "WARNING - G4PVPlacement::CheckOverlaps()" << G4endl
|
||||
<< " Overlap is detected for volume "
|
||||
<< GetName() << G4endl
|
||||
<< " with its mother volume "
|
||||
<< motherLog->GetName() << G4endl
|
||||
<< " at mother local point " << mp << G4endl;
|
||||
G4Exception("G4PVPlacement::CheckOverlaps()", "InvalidSetup",
|
||||
JustWarning, "Overlap with mother volume !");
|
||||
return true;
|
||||
G4double distin = motherSolid->DistanceToIn(mp);
|
||||
if (distin > tol)
|
||||
{
|
||||
G4cout << G4endl;
|
||||
G4cout << "WARNING - G4PVPlacement::CheckOverlaps()" << G4endl
|
||||
<< " Overlap is detected for volume "
|
||||
<< GetName() << G4endl
|
||||
<< " with its mother volume "
|
||||
<< motherLog->GetName() << G4endl
|
||||
<< " at mother local point " << mp << ", "
|
||||
<< "overlapping by at least: " << G4BestUnit(distin, "Length")
|
||||
<< G4endl;
|
||||
G4Exception("G4PVPlacement::CheckOverlaps()", "InvalidSetup",
|
||||
JustWarning, "Overlap with mother volume !");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Checking overlaps with each 'sister' volume
|
||||
//
|
||||
for (G4int i=0; i<motherLog->GetNoDaughters()-1; i++)
|
||||
for (G4int i=0; i<motherLog->GetNoDaughters(); i++)
|
||||
{
|
||||
G4VPhysicalVolume* daughter = motherLog->GetDaughter(i);
|
||||
|
||||
if (daughter == this) { continue; }
|
||||
|
||||
// Create the transformation for daughter volume and transform point
|
||||
//
|
||||
G4AffineTransform Td( daughter->GetRotation(),
|
||||
@@ -295,19 +310,61 @@ G4bool G4PVPlacement::CheckOverlaps(G4int res)
|
||||
G4VSolid* daughterSolid = daughter->GetLogicalVolume()->GetSolid();
|
||||
if (daughterSolid->Inside(md)==kInside)
|
||||
{
|
||||
G4cout << G4endl;
|
||||
G4cout << "WARNING - G4PVPlacement::CheckOverlaps()" << G4endl
|
||||
<< " Overlap is detected for volume "
|
||||
<< GetName() << G4endl
|
||||
<< " with volume " << daughter->GetName() << G4endl
|
||||
<< " at daughter local point " << md << G4endl;
|
||||
G4Exception("G4PVPlacement::CheckOverlaps()", "InvalidSetup",
|
||||
JustWarning, "Overlap with volume already placed !");
|
||||
return true;
|
||||
G4double distout = daughterSolid->DistanceToOut(md);
|
||||
if (distout > tol)
|
||||
{
|
||||
G4cout << G4endl;
|
||||
G4cout << "WARNING - G4PVPlacement::CheckOverlaps()" << G4endl
|
||||
<< " Overlap is detected for volume "
|
||||
<< GetName() << G4endl
|
||||
<< " with " << daughter->GetName() << " volume's"
|
||||
<< G4endl
|
||||
<< " local point " << md << ", "
|
||||
<< "overlapping by at least: " << G4BestUnit(distout,"Length")
|
||||
<< G4endl;
|
||||
G4Exception("G4PVPlacement::CheckOverlaps()", "InvalidSetup",
|
||||
JustWarning, "Overlap with volume already placed !");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Now checking that 'sister' volume is not totally included and
|
||||
// overlapping. Do it only once, for the first point generated
|
||||
//
|
||||
if (n==0)
|
||||
{
|
||||
// Generate a single point on the surface of the 'sister' volume
|
||||
// and verify that the point is NOT inside the current volume
|
||||
|
||||
G4ThreeVector dPoint = daughterSolid->GetPointOnSurface();
|
||||
|
||||
// Transform the generated point to the mother's coordinate system
|
||||
// and finally to current volume's coordinate system
|
||||
//
|
||||
G4ThreeVector mp2 = Td.TransformPoint(dPoint);
|
||||
G4ThreeVector ms = Tm.Inverse().TransformPoint(mp2);
|
||||
|
||||
if (solid->Inside(ms)==kInside)
|
||||
{
|
||||
G4cout << G4endl;
|
||||
G4cout << "WARNING - G4PVPlacement::CheckOverlaps()" << G4endl
|
||||
<< " Overlap is detected for volume "
|
||||
<< GetName() << G4endl
|
||||
<< " apparently fully encapsulating volume "
|
||||
<< daughter->GetName() << G4endl
|
||||
<< " at the same level !" << G4endl;
|
||||
G4Exception("G4PVPlacement::CheckOverlaps()", "InvalidSetup",
|
||||
JustWarning, "Overlap with volume already placed !");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
G4cout << "OK! " << G4endl;
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
G4cout << "OK! " << G4endl;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user