Import Geant4 7.1.0 source tree
This commit is contained in:
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4BooleanSolid.cc,v 1.14 2004/10/13 13:19:06 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
// $Id: G4BooleanSolid.cc,v 1.16 2005/04/04 09:44:56 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
//
|
||||
// Implementation for the abstract base class for solids created by boolean
|
||||
// operations between other solids
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
#include "G4BooleanSolid.hh"
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -91,6 +92,7 @@ G4BooleanSolid::~G4BooleanSolid()
|
||||
{
|
||||
((G4DisplacedSolid*)fPtrSolidB)->CleanTransformations();
|
||||
}
|
||||
delete fpPolyhedron;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
@@ -171,9 +173,12 @@ std::ostream& G4BooleanSolid::StreamInfo(std::ostream& os) const
|
||||
|
||||
G4Polyhedron* G4BooleanSolid::GetPolyhedron () const
|
||||
{
|
||||
if (!fpPolyhedron)
|
||||
{
|
||||
fpPolyhedron = CreatePolyhedron();
|
||||
}
|
||||
if (!fpPolyhedron ||
|
||||
fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
|
||||
fpPolyhedron->GetNumberOfRotationSteps())
|
||||
{
|
||||
delete fpPolyhedron;
|
||||
fpPolyhedron = CreatePolyhedron();
|
||||
}
|
||||
return fpPolyhedron;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4DisplacedSolid.cc,v 1.21 2004/10/13 13:19:06 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
// $Id: G4DisplacedSolid.cc,v 1.23 2005/03/23 17:16:31 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
//
|
||||
// Implementation for G4DisplacedSolid class for boolean
|
||||
// operations between other solids
|
||||
@@ -103,6 +103,7 @@ G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
G4DisplacedSolid::~G4DisplacedSolid()
|
||||
{
|
||||
CleanTransformations();
|
||||
delete fpPolyhedron;
|
||||
}
|
||||
|
||||
G4GeometryType G4DisplacedSolid::GetEntityType() const
|
||||
@@ -361,7 +362,7 @@ std::ostream& G4DisplacedSolid::StreamInfo(std::ostream& os) const
|
||||
void
|
||||
G4DisplacedSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
{
|
||||
scene.AddThis (*this);
|
||||
scene.AddSolid (*this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
@@ -395,9 +396,12 @@ G4DisplacedSolid::CreateNURBS () const
|
||||
|
||||
G4Polyhedron* G4DisplacedSolid::GetPolyhedron () const
|
||||
{
|
||||
if (!fpPolyhedron)
|
||||
{
|
||||
fpPolyhedron = CreatePolyhedron();
|
||||
}
|
||||
if (!fpPolyhedron ||
|
||||
fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
|
||||
fpPolyhedron->GetNumberOfRotationSteps())
|
||||
{
|
||||
delete fpPolyhedron;
|
||||
fpPolyhedron = CreatePolyhedron();
|
||||
}
|
||||
return fpPolyhedron;
|
||||
}
|
||||
|
||||
@@ -21,17 +21,19 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4IntersectionSolid.cc,v 1.21 2003/11/03 17:48:45 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
// $Id: G4IntersectionSolid.cc,v 1.24 2005/03/03 16:04:14 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
//
|
||||
// Implementation of methods for the class G4IntersectionSolid
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 12.09.98 V.Grichine: first implementation
|
||||
// 29.07.99 V.Grichine: modifications in DistanceToIn(p,v)
|
||||
// 16.03.01 V.Grichine: modifications in CalculateExtent() and Inside()
|
||||
// 17.02.05 V.Grichine: bug was fixed in DistanceToIn(p,v) based on algorithm
|
||||
// proposed by Dino Bazzacco <dino.bazzacco@pd.infn.it>
|
||||
// 29.05.01 V.Grichine: bug was fixed in DistanceToIn(p,v)
|
||||
// 16.03.01 V.Grichine: modifications in CalculateExtent() and Inside()
|
||||
// 29.07.99 V.Grichine: modifications in DistanceToIn(p,v)
|
||||
// 12.09.98 V.Grichine: first implementation
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -218,7 +220,7 @@ G4double
|
||||
G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v ) const
|
||||
{
|
||||
G4double dist = 0.0, disTmp = 0.0 ;
|
||||
G4double dist = 0.0;
|
||||
if( Inside(p) == kInside )
|
||||
{
|
||||
#ifdef G4BOOLDEBUG
|
||||
@@ -234,146 +236,77 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p,
|
||||
G4cerr << " v = " << v << G4endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
else // if( Inside(p) == kSurface )
|
||||
{
|
||||
if( fPtrSolidA->Inside(p) != kOutside )
|
||||
EInside wA = fPtrSolidA->Inside(p);
|
||||
EInside wB = fPtrSolidB->Inside(p);
|
||||
|
||||
G4ThreeVector pA = p, pB = p;
|
||||
G4double dA = 0., dA1=0., dA2=0.;
|
||||
G4double dB = 0., dB1=0., dB2=0.;
|
||||
G4bool doA = true, doB = true;
|
||||
|
||||
while(true)
|
||||
{
|
||||
do
|
||||
if(doA)
|
||||
{
|
||||
if( fPtrSolidB->Inside(p+dist*v) == kInside )
|
||||
// find next valid range for A
|
||||
|
||||
dA1 = 0.;
|
||||
|
||||
if( wA != kInside )
|
||||
{
|
||||
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
|
||||
dA1 = fPtrSolidA->DistanceToIn(pA, v);
|
||||
|
||||
if( dA1 == kInfinity ) return kInfinity;
|
||||
|
||||
pA += dA1*v;
|
||||
}
|
||||
else
|
||||
{
|
||||
disTmp = fPtrSolidB->DistanceToIn(p+dist*v,v) ;
|
||||
}
|
||||
if( disTmp != kInfinity )
|
||||
{
|
||||
dist += disTmp ;
|
||||
if(Inside(p+dist*v) == kOutside )
|
||||
{
|
||||
if( fPtrSolidA->Inside(p+dist*v) == kInside )
|
||||
{
|
||||
disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
|
||||
}
|
||||
if( disTmp != kInfinity )
|
||||
{
|
||||
dist += disTmp ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kInfinity ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return kInfinity ;
|
||||
}
|
||||
dA2 = dA1 + fPtrSolidA->DistanceToOut(pA, v);
|
||||
}
|
||||
while( Inside(p+dist*v) == kOutside ) ;
|
||||
// while( fPtrSolidB->Inside(p) != kOutside ) ;
|
||||
}
|
||||
else if( fPtrSolidB->Inside(p) != kOutside )
|
||||
{
|
||||
do
|
||||
dA1 += dA;
|
||||
dA2 += dA;
|
||||
|
||||
if(doB)
|
||||
{
|
||||
if( fPtrSolidA->Inside(p+dist*v) == kInside )
|
||||
// find next valid range for B
|
||||
|
||||
dB1 = 0.;
|
||||
if(wB != kInside)
|
||||
{
|
||||
disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v) ;
|
||||
dB1 = fPtrSolidB->DistanceToIn(pB, v);
|
||||
|
||||
if(dB1 == kInfinity) return kInfinity;
|
||||
|
||||
pB += dB1*v;
|
||||
}
|
||||
else
|
||||
{
|
||||
disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
|
||||
}
|
||||
if( disTmp != kInfinity )
|
||||
{
|
||||
dist += disTmp ;
|
||||
if(Inside(p+dist*v) == kOutside )
|
||||
{
|
||||
if( fPtrSolidB->Inside(p+dist*v) == kInside )
|
||||
{
|
||||
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
disTmp = fPtrSolidB->DistanceToIn(p+dist*v,v) ;
|
||||
}
|
||||
if( disTmp != kInfinity )
|
||||
{
|
||||
dist += disTmp ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kInfinity ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return kInfinity ;
|
||||
}
|
||||
dB2 = dB1 + fPtrSolidB->DistanceToOut(pB, v);
|
||||
}
|
||||
while( Inside(p+dist*v) == kOutside ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
dB1 += dB;
|
||||
dB2 += dB;
|
||||
|
||||
// check if they overlap
|
||||
|
||||
if( dA1 < dB1 )
|
||||
{
|
||||
if( fPtrSolidB->Inside(p+dist*v) == kInside )
|
||||
{
|
||||
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
disTmp = fPtrSolidB->DistanceToIn(p+dist*v,v) ;
|
||||
}
|
||||
if( disTmp != kInfinity )
|
||||
{
|
||||
dist += disTmp ;
|
||||
if(Inside(p+dist*v) == kOutside )
|
||||
{
|
||||
if( fPtrSolidA->Inside(p+dist*v) == kInside )
|
||||
{
|
||||
disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
|
||||
}
|
||||
if( disTmp != kInfinity )
|
||||
{
|
||||
dist += disTmp ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kInfinity ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return kInfinity ;
|
||||
}
|
||||
if( dB1 < dA2 ) return dB1;
|
||||
|
||||
dA = dA2;
|
||||
pA = p + dA*v; // continue from here
|
||||
wA = kSurface;
|
||||
doA = true;
|
||||
doB = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( dA1 < dB2 ) return dA1;
|
||||
|
||||
dB = dB2;
|
||||
pB = p + dB*v; // continue from here
|
||||
wB = kSurface;
|
||||
doB = true;
|
||||
doA = false;
|
||||
}
|
||||
while( Inside(p+dist*v) == kOutside ) ;
|
||||
}
|
||||
}
|
||||
return dist ;
|
||||
@@ -535,7 +468,7 @@ G4GeometryType G4IntersectionSolid::GetEntityType() const
|
||||
void
|
||||
G4IntersectionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
{
|
||||
scene.AddThis (*this);
|
||||
scene.AddSolid (*this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
@@ -545,11 +478,9 @@ G4IntersectionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
G4Polyhedron*
|
||||
G4IntersectionSolid::CreatePolyhedron () const
|
||||
{
|
||||
G4Polyhedron* pA = fPtrSolidA->CreatePolyhedron();
|
||||
G4Polyhedron* pB = fPtrSolidB->CreatePolyhedron();
|
||||
G4Polyhedron* pA = fPtrSolidA->GetPolyhedron();
|
||||
G4Polyhedron* pB = fPtrSolidB->GetPolyhedron();
|
||||
G4Polyhedron* resultant = new G4Polyhedron (pA->intersect(*pB));
|
||||
delete pB;
|
||||
delete pA;
|
||||
return resultant;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4SubtractionSolid.cc,v 1.21 2004/02/27 08:38:09 grichine Exp $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
// $Id: G4SubtractionSolid.cc,v 1.25 2005/05/09 13:44:58 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
//
|
||||
// Implementation of methods for the class G4IntersectionSolid
|
||||
//
|
||||
@@ -116,8 +116,8 @@ G4SubtractionSolid::CalculateExtent( const EAxis pAxis,
|
||||
|
||||
EInside G4SubtractionSolid::Inside( const G4ThreeVector& p ) const
|
||||
{
|
||||
EInside positionA = fPtrSolidA->Inside(p) ;
|
||||
EInside positionB = fPtrSolidB->Inside(p) ;
|
||||
EInside positionA = fPtrSolidA->Inside(p);
|
||||
EInside positionB = fPtrSolidB->Inside(p);
|
||||
|
||||
if(positionA == kInside && positionB == kOutside)
|
||||
{
|
||||
@@ -125,16 +125,13 @@ EInside G4SubtractionSolid::Inside( const G4ThreeVector& p ) const
|
||||
}
|
||||
else
|
||||
{
|
||||
if((positionA == kInside && positionB == kSurface) ||
|
||||
(positionB == kOutside && positionA == kSurface) ||
|
||||
(positionA == kSurface && positionB == kSurface) )
|
||||
{
|
||||
return kSurface ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kOutside ;
|
||||
}
|
||||
if(( positionA == kInside && positionB == kSurface) ||
|
||||
( positionB == kOutside && positionA == kSurface) ||
|
||||
( positionA == kSurface && positionB == kSurface &&
|
||||
( fPtrSolidA->SurfaceNormal(p) -
|
||||
fPtrSolidB->SurfaceNormal(p) ).mag2() >
|
||||
1000*kRadTolerance ) ) return kSurface;
|
||||
else return kOutside;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,7 +429,7 @@ G4SubtractionSolid::ComputeDimensions( G4VPVParameterisation*,
|
||||
void
|
||||
G4SubtractionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
{
|
||||
scene.AddThis (*this);
|
||||
scene.AddSolid (*this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
@@ -442,11 +439,9 @@ G4SubtractionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
G4Polyhedron*
|
||||
G4SubtractionSolid::CreatePolyhedron () const
|
||||
{
|
||||
G4Polyhedron* pA = fPtrSolidA->CreatePolyhedron();
|
||||
G4Polyhedron* pB = fPtrSolidB->CreatePolyhedron();
|
||||
G4Polyhedron* pA = fPtrSolidA->GetPolyhedron();
|
||||
G4Polyhedron* pB = fPtrSolidB->GetPolyhedron();
|
||||
G4Polyhedron* resultant = new G4Polyhedron (pA->subtract(*pB));
|
||||
delete pB;
|
||||
delete pA;
|
||||
return resultant;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UnionSolid.cc,v 1.25 2004/02/27 08:38:09 grichine Exp $
|
||||
// GEANT4 tag $Name: geant4-07-00-cand-01 $
|
||||
// $Id: G4UnionSolid.cc,v 1.29 2005/05/09 13:44:58 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
//
|
||||
// Implementation of methods for the class G4IntersectionSolid
|
||||
//
|
||||
@@ -130,25 +130,20 @@ G4UnionSolid::CalculateExtent( const EAxis pAxis,
|
||||
|
||||
EInside G4UnionSolid::Inside( const G4ThreeVector& p ) const
|
||||
{
|
||||
EInside positionA = fPtrSolidA->Inside(p) ;
|
||||
EInside positionB = fPtrSolidB->Inside(p) ;
|
||||
|
||||
if( positionA == kInside || positionB == kInside )
|
||||
{
|
||||
return kInside ;
|
||||
}
|
||||
EInside positionA = fPtrSolidA->Inside(p);
|
||||
EInside positionB = fPtrSolidB->Inside(p);
|
||||
|
||||
if( positionA == kInside || positionB == kInside ||
|
||||
( positionA == kSurface && positionB == kSurface &&
|
||||
( fPtrSolidA->SurfaceNormal(p) +
|
||||
fPtrSolidB->SurfaceNormal(p) ).mag2() <
|
||||
1000*kRadTolerance ) ) return kInside;
|
||||
else
|
||||
{
|
||||
if((positionA != kInside && positionB == kSurface) ||
|
||||
(positionB != kInside && positionA == kSurface) ||
|
||||
(positionA == kSurface && positionB == kSurface) )
|
||||
{
|
||||
return kSurface ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kOutside ;
|
||||
}
|
||||
if( ( positionA != kInside && positionB == kSurface ) ||
|
||||
( positionB != kInside && positionA == kSurface ) ||
|
||||
( positionA == kSurface && positionB == kSurface ) ) return kSurface;
|
||||
else return kOutside;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,7 +423,7 @@ G4UnionSolid::ComputeDimensions( G4VPVParameterisation*,
|
||||
void
|
||||
G4UnionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
{
|
||||
scene.AddThis (*this);
|
||||
scene.AddSolid (*this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
@@ -438,11 +433,9 @@ G4UnionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
G4Polyhedron*
|
||||
G4UnionSolid::CreatePolyhedron () const
|
||||
{
|
||||
G4Polyhedron* pA = fPtrSolidA->CreatePolyhedron();
|
||||
G4Polyhedron* pB = fPtrSolidB->CreatePolyhedron();
|
||||
G4Polyhedron* pA = fPtrSolidA->GetPolyhedron();
|
||||
G4Polyhedron* pB = fPtrSolidB->GetPolyhedron();
|
||||
G4Polyhedron* resultant = new G4Polyhedron (pA->add(*pB));
|
||||
delete pB;
|
||||
delete pA;
|
||||
return resultant;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user