Import Geant4 4.0.0 source tree
This commit is contained in:
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4BooleanSolid.cc,v 1.4.4.1 2001/06/28 19:08:57 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4BooleanSolid.cc,v 1.5 2001/07/11 09:59:52 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
// Implementation for the abstract base class for solids created by boolean
|
||||
// operations between other solids
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4DisplacedSolid.cc,v 1.13.4.1 2001/06/28 19:08:57 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4DisplacedSolid.cc,v 1.14 2001/07/11 09:59:52 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
// Implementation for G4DisplacedSolid class for boolean
|
||||
// operations between other solids
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4IntersectionSolid.cc,v 1.12.2.1 2001/06/28 19:08:57 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4IntersectionSolid.cc,v 1.16 2001/10/02 08:51:48 grichine Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
// Implementation of methods for the class G4IntersectionSolid
|
||||
//
|
||||
@@ -164,7 +164,7 @@ G4ThreeVector
|
||||
G4IntersectionSolid::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
{
|
||||
G4ThreeVector normal;
|
||||
G4bool insideA, insideB;
|
||||
EInside insideA, insideB;
|
||||
|
||||
insideA= fPtrSolidA->Inside(p);
|
||||
insideB= fPtrSolidB->Inside(p);
|
||||
@@ -172,7 +172,12 @@ G4IntersectionSolid::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
// if( Inside(p) == kOutside )
|
||||
if( (insideA == kOutside) || (insideB == kOutside) )
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::SurfaceNormal(p), point p is outside") ;
|
||||
G4cerr << "WARNING - Invalid call in G4IntersectionSolid::SurfaceNormal(p),"
|
||||
<< " point p is outside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4IntersectionSolid::SurfaceNormal(p), p is outside") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
// OLD: if(fPtrSolidA->DistanceToOut(p) <= fPtrSolidB->DistanceToOut(p) )
|
||||
@@ -193,13 +198,16 @@ G4IntersectionSolid::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
// We are on neither surface, so we should generate an exception
|
||||
else
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::SurfaceNormal(p), point p is not on the surface of the volume.") ;
|
||||
|
||||
// Or else
|
||||
if(fPtrSolidA->DistanceToOut(p) <= fPtrSolidB->DistanceToOut(p) )
|
||||
normal= fPtrSolidA->SurfaceNormal(p) ;
|
||||
else
|
||||
normal= fPtrSolidB->SurfaceNormal(p) ;
|
||||
G4cerr << "WARNING - Invalid call in G4IntersectionSolid::SurfaceNormal(p),"
|
||||
<< " point p is outsurface" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4IntersectionSolid::SurfaceNormal(p), p is outsurface") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
return normal;
|
||||
@@ -216,7 +224,13 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p,
|
||||
G4double dist = 0.0, disTmp = 0.0 ;
|
||||
if( Inside(p) == kInside )
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToIn(p,v), point p is inside") ;
|
||||
G4cerr << "WARNING - Invalid call in G4IntersectionSolid::DistanceToIn(p,v),"
|
||||
<< " point p is inside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
G4cerr << " v = " << v << G4endl;
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToIn(p,v), p is inside") ;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -373,7 +387,12 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p) const
|
||||
{
|
||||
if( Inside(p) == kInside )
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToIn(p), point p is inside") ;
|
||||
G4cerr << "WARNING - Invalid call in G4IntersectionSolid::DistanceToIn(p),"
|
||||
<< " point p is inside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToIn(p), p is inside") ;
|
||||
#endif
|
||||
}
|
||||
EInside sideA = fPtrSolidA->Inside(p) ;
|
||||
EInside sideB = fPtrSolidB->Inside(p) ;
|
||||
@@ -414,6 +433,10 @@ G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p,
|
||||
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
G4cerr << "WARNING - Invalid call in G4IntersectionSolid::DistanceToOut(p,v),"
|
||||
<< " point p is outside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
G4cerr << " v = " << v << G4endl;
|
||||
G4cout << "Position:" << G4endl << G4endl;
|
||||
G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl;
|
||||
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl;
|
||||
@@ -422,7 +445,9 @@ G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p,
|
||||
G4cout << "v.x() = " << v.x() << G4endl;
|
||||
G4cout << "v.y() = " << v.y() << G4endl;
|
||||
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToOut(p,v), point p is outside") ;
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToOut(p,v), p is outside") ;
|
||||
#endif
|
||||
}
|
||||
G4double distA = fPtrSolidA->DistanceToOut(p,v,calcNorm,&validNormA,&nA) ;
|
||||
G4double distB = fPtrSolidB->DistanceToOut(p,v,calcNorm,&validNormB,&nB) ;
|
||||
@@ -453,7 +478,12 @@ G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p ) const
|
||||
{
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToOut(p), point p is outside") ;
|
||||
G4cerr << "WARNING - Invalid call in G4IntersectionSolid::DistanceToOut(p),"
|
||||
<< " point p is outside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToOut(p), p is outside") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,387 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ReflectedSolid.cc,v 1.3 2001/10/18 10:07:50 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
// Implementation for G4ReflectedSolid class for boolean
|
||||
// operations between other solids
|
||||
//
|
||||
// Author: Vladimir Grichine, 23.07.01 (Vladimir.Grichine@cern.ch)
|
||||
|
||||
#include "G4ReflectedSolid.hh"
|
||||
#include "G4Point3D.hh"
|
||||
#include "G4Normal3D.hh"
|
||||
|
||||
#include "G4VoxelLimits.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
|
||||
#include "G4VPVParameterisation.hh"
|
||||
|
||||
#include "G4VGraphicsScene.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "G4NURBS.hh"
|
||||
#include "G4NURBSbox.hh"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Constructor using HepTransform3D, in fact HepReflect3D
|
||||
|
||||
G4ReflectedSolid::G4ReflectedSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
const G4Transform3D& transform ) :
|
||||
G4VSolid(pName)
|
||||
{
|
||||
fPtrSolid = pSolid ;
|
||||
G4RotationMatrix rotMatrix ;
|
||||
|
||||
fDirectTransform = new G4AffineTransform(rotMatrix, transform.getTranslation()) ;
|
||||
|
||||
fPtrTransform = new G4AffineTransform(rotMatrix, transform.getTranslation()) ;
|
||||
fPtrTransform->Invert() ;
|
||||
|
||||
fDirectTransform3D = new G4Transform3D(transform) ;
|
||||
fPtrTransform3D = new G4Transform3D(transform.inverse()) ;
|
||||
}
|
||||
|
||||
/* **************************************************************
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Constractor for transformation like rotation of frame then translation
|
||||
// in new frame. It is similar to 1st constractor in G4PVPlacement
|
||||
|
||||
G4ReflectedSolid::
|
||||
G4ReflectedSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
G4RotationMatrix* rotMatrix,
|
||||
const G4ThreeVector& transVector )
|
||||
: G4VSolid(pName)
|
||||
{
|
||||
fPtrSolid = pSolid ;
|
||||
fPtrTransform = new G4AffineTransform(rotMatrix,transVector) ;
|
||||
fPtrTransform->Invert() ;
|
||||
fDirectTransform = new G4AffineTransform(rotMatrix,transVector) ;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor for use with creation of Transient object from Persistent object
|
||||
//
|
||||
|
||||
G4ReflectedSolid::G4ReflectedSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
const G4AffineTransform directTransform ) :
|
||||
G4VSolid(pName)
|
||||
{
|
||||
fPtrSolid = pSolid ;
|
||||
fDirectTransform = new G4AffineTransform( directTransform );
|
||||
fPtrTransform = new G4AffineTransform( directTransform.Inverse() ) ;
|
||||
}
|
||||
|
||||
********************************************************** */
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
G4ReflectedSolid::~G4ReflectedSolid()
|
||||
{
|
||||
if(fPtrTransform)
|
||||
{
|
||||
delete fPtrTransform ;
|
||||
delete fDirectTransform;
|
||||
}
|
||||
}
|
||||
|
||||
G4GeometryType G4ReflectedSolid::GetEntityType() const
|
||||
{
|
||||
return G4String("G4ReflectedSolid");
|
||||
}
|
||||
|
||||
const G4ReflectedSolid* G4ReflectedSolid::GetReflectedSolidPtr() const
|
||||
{ return this; }
|
||||
|
||||
G4ReflectedSolid* G4ReflectedSolid::GetReflectedSolidPtr()
|
||||
{ return this; }
|
||||
|
||||
G4VSolid* G4ReflectedSolid::GetConstituentMovedSolid() const
|
||||
{
|
||||
return fPtrSolid;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
G4AffineTransform G4ReflectedSolid::GetTransform() const
|
||||
{
|
||||
G4AffineTransform aTransform = *fPtrTransform;
|
||||
return aTransform;
|
||||
}
|
||||
|
||||
void G4ReflectedSolid::SetTransform(G4AffineTransform& transform)
|
||||
{
|
||||
fPtrTransform = &transform ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
G4AffineTransform G4ReflectedSolid::GetDirectTransform() const
|
||||
{
|
||||
G4AffineTransform aTransform= *fDirectTransform;
|
||||
return aTransform;
|
||||
}
|
||||
|
||||
void G4ReflectedSolid::SetDirectTransform(G4AffineTransform& transform)
|
||||
{
|
||||
fDirectTransform = &transform ;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
G4RotationMatrix G4ReflectedSolid::GetFrameRotation() const
|
||||
{
|
||||
G4RotationMatrix InvRotation= fDirectTransform->NetRotation();
|
||||
return InvRotation;
|
||||
}
|
||||
|
||||
void G4ReflectedSolid::SetFrameRotation(const G4RotationMatrix& matrix)
|
||||
{
|
||||
fDirectTransform->SetNetRotation(matrix);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
G4ThreeVector G4ReflectedSolid::GetFrameTranslation() const
|
||||
{
|
||||
return fPtrTransform->NetTranslation();
|
||||
}
|
||||
|
||||
void G4ReflectedSolid::SetFrameTranslation(const G4ThreeVector& vector)
|
||||
{
|
||||
fPtrTransform->SetNetTranslation(vector);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
G4RotationMatrix G4ReflectedSolid::GetObjectRotation() const
|
||||
{
|
||||
G4RotationMatrix Rotation= fPtrTransform->NetRotation();
|
||||
return Rotation;
|
||||
}
|
||||
|
||||
void G4ReflectedSolid::SetObjectRotation(const G4RotationMatrix& matrix)
|
||||
{
|
||||
fPtrTransform->SetNetRotation(matrix);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
G4ThreeVector G4ReflectedSolid::GetObjectTranslation() const
|
||||
{
|
||||
return fDirectTransform->NetTranslation();
|
||||
}
|
||||
|
||||
void G4ReflectedSolid::SetObjectTranslation(const G4ThreeVector& vector)
|
||||
{
|
||||
fDirectTransform->SetNetTranslation(vector);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4bool
|
||||
G4ReflectedSolid::CalculateExtent( const EAxis pAxis,
|
||||
const G4VoxelLimits& pVoxelLimit,
|
||||
const G4AffineTransform& pTransform,
|
||||
G4double& pMin,
|
||||
G4double& pMax ) const
|
||||
{
|
||||
G4AffineTransform sumTransform ;
|
||||
G4bool extentR, extent ;
|
||||
G4double min, max, minR, maxR ;
|
||||
|
||||
sumTransform.Product(*fDirectTransform,pTransform) ;
|
||||
|
||||
extent = fPtrSolid->CalculateExtent(pAxis,pVoxelLimit,pTransform,
|
||||
min,max) ;
|
||||
extentR = fPtrSolid->CalculateExtent(pAxis,pVoxelLimit,sumTransform,
|
||||
minR,maxR) ;
|
||||
if( maxR > 0 ) pMax = 2.0*maxR ;
|
||||
else pMax = 0.5*maxR ;
|
||||
|
||||
if( minR > 0 ) pMin = 0.5*minR ;
|
||||
else pMin = 2.0*minR ;
|
||||
|
||||
return extentR ;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
EInside G4ReflectedSolid::Inside(const G4ThreeVector& p) const
|
||||
{
|
||||
// G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
|
||||
|
||||
G4Point3D newPoint = (*fDirectTransform3D)*G4Point3D(p) ;
|
||||
return fPtrSolid->Inside(G4ThreeVector(newPoint.x(),newPoint.y(),newPoint.z())) ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4ThreeVector
|
||||
G4ReflectedSolid::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
{
|
||||
G4Point3D newPoint = (*fDirectTransform3D)*G4Point3D(p) ;
|
||||
G4ThreeVector normal = fPtrSolid->SurfaceNormal(G4ThreeVector(newPoint.x(),
|
||||
newPoint.y(),
|
||||
newPoint.z() ) ) ;
|
||||
G4Point3D newN = (*fDirectTransform3D)*G4Point3D(normal) ;
|
||||
newN.unit() ;
|
||||
|
||||
return G4ThreeVector(newN.x(),newN.y(),newN.z()) ;
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The same algorithm as in DistanceToIn(p)
|
||||
|
||||
G4double
|
||||
G4ReflectedSolid::DistanceToIn( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v ) const
|
||||
{
|
||||
G4Point3D newPoint = (*fDirectTransform3D)*G4Point3D(p) ;
|
||||
G4Point3D newDirection = (*fDirectTransform3D)*G4Point3D(v) ;
|
||||
newDirection.unit() ;
|
||||
return fPtrSolid->DistanceToIn(
|
||||
G4ThreeVector(newPoint.x(),newPoint.y(),newPoint.z()),
|
||||
G4ThreeVector(newDirection.x(),newDirection.y(),newDirection.z())) ;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// Approximate nearest distance from the point p to the intersection of
|
||||
// two solids
|
||||
|
||||
G4double
|
||||
G4ReflectedSolid::DistanceToIn( const G4ThreeVector& p) const
|
||||
{
|
||||
G4Point3D newPoint = (*fDirectTransform3D)*G4Point3D(p) ;
|
||||
return fPtrSolid->DistanceToIn(
|
||||
G4ThreeVector(newPoint.x(),newPoint.y(),newPoint.z())) ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
// The same algorithm as DistanceToOut(p)
|
||||
|
||||
G4double
|
||||
G4ReflectedSolid::DistanceToOut( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm,
|
||||
G4bool *validNorm,
|
||||
G4ThreeVector *n ) const
|
||||
{
|
||||
G4ThreeVector solNorm ;
|
||||
|
||||
G4Point3D newPoint = (*fDirectTransform3D)*G4Point3D(p) ;
|
||||
G4Point3D newDirection = (*fDirectTransform3D)*G4Point3D(v) ;
|
||||
newDirection.unit() ;
|
||||
|
||||
G4double dist = fPtrSolid->DistanceToOut(
|
||||
G4ThreeVector(newPoint.x(),newPoint.y(),newPoint.z()),
|
||||
G4ThreeVector(newDirection.x(),newDirection.y(),newDirection.z()),
|
||||
calcNorm,validNorm,&solNorm) ;
|
||||
if(calcNorm)
|
||||
{
|
||||
G4Point3D newN = (*fDirectTransform3D)*G4Point3D(solNorm) ;
|
||||
newN.unit() ;
|
||||
*n = G4ThreeVector(newN.x(),newN.y(),newN.z()) ;
|
||||
}
|
||||
return dist ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Inverted algorithm of DistanceToIn(p)
|
||||
|
||||
G4double
|
||||
G4ReflectedSolid::DistanceToOut( const G4ThreeVector& p ) const
|
||||
{
|
||||
G4Point3D newPoint = (*fDirectTransform3D)*G4Point3D(p) ;
|
||||
return fPtrSolid->DistanceToOut(
|
||||
G4ThreeVector(newPoint.x(),newPoint.y(),newPoint.z())) ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
void
|
||||
G4ReflectedSolid::ComputeDimensions( G4VPVParameterisation* p,
|
||||
const G4int n,
|
||||
const G4VPhysicalVolume* pRep )
|
||||
{
|
||||
// fPtrSolid->ComputeDimensions(p,n,pRep);
|
||||
|
||||
G4Exception("ERROR: ComputeDimensions has no meaning for a G4ReflectedSolid. It cannot be called.");
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
void
|
||||
G4ReflectedSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
{
|
||||
scene.AddThis (*this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4Polyhedron*
|
||||
G4ReflectedSolid::CreatePolyhedron () const
|
||||
{
|
||||
G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron();
|
||||
polyhedron->Transform(*fDirectTransform3D);
|
||||
|
||||
return polyhedron;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4NURBS*
|
||||
G4ReflectedSolid::CreateNURBS () const
|
||||
{
|
||||
// Take into account local transformation - see CreatePolyhedron.
|
||||
// return fPtrSolid->CreateNURBS() ;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,537 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * 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. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ReflectionFactory.cc,v 1.2 2001/11/08 15:47:07 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 16.10.2001 (Ivana.Hrivnacova@cern.ch)
|
||||
|
||||
//
|
||||
// Class G4ReflectionFactory Implementation
|
||||
//
|
||||
// Decomposition of a general transformation
|
||||
// that can include reflection in a "reflection-free" transformation:
|
||||
//
|
||||
// x(inM') = TG*x(inM) TG - general transformation
|
||||
// = T*(R*x(inM)) T - "reflection-free" transformation
|
||||
// = T* x(inReflM)
|
||||
//
|
||||
// Daughters transformation:
|
||||
// When a volume V containing daughter D with transformation TD
|
||||
// is placed in mother M with a general tranformation TGV,
|
||||
// the TGV is decomposed,
|
||||
// new reflected volume ReflV containing a new daughter ReflD
|
||||
// with reflected transformation ReflTD is created:
|
||||
//
|
||||
// x(inV) = TD * x(inD);
|
||||
// x(inM) = TGV * x(inV)
|
||||
// = TV * R * x(inV)
|
||||
// = TV * R * TD * x(inD)
|
||||
// = TV * R*TD*R-1 * R*x(inD)
|
||||
// = TV * ReflTD * x(inReflD)
|
||||
|
||||
|
||||
#include "G4ReflectionFactory.hh"
|
||||
#include "G4ReflectedSolid.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4PVReplica.hh"
|
||||
|
||||
G4ReflectionFactory* G4ReflectionFactory::fInstance = 0;
|
||||
const G4String G4ReflectionFactory::fNameExtension = "_refl";
|
||||
const G4Scale3D G4ReflectionFactory::fScale = G4ScaleZ3D(-1.0);
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4ReflectionFactory* G4ReflectionFactory::Instance()
|
||||
{
|
||||
// Static singleton access method.
|
||||
// ---
|
||||
|
||||
if (!fInstance) new G4ReflectionFactory();
|
||||
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4ReflectionFactory::G4ReflectionFactory()
|
||||
: fVerboseLevel(0)
|
||||
{
|
||||
// Protected singleton constructor.
|
||||
// ---
|
||||
|
||||
fInstance = this;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4ReflectionFactory::~G4ReflectionFactory() {
|
||||
}
|
||||
|
||||
//
|
||||
// public methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4PhysicalVolumesPair G4ReflectionFactory::Place(
|
||||
const G4Transform3D& transform3D,
|
||||
const G4String& name,
|
||||
G4LogicalVolume* LV,
|
||||
G4LogicalVolume* motherLV,
|
||||
G4bool isMany,
|
||||
G4int copyNo)
|
||||
{
|
||||
// Evaluates the passed transformation; if it contains reflection
|
||||
// it performs its decomposition, creates new reflected solid and
|
||||
// logical volume (or retrieves them from a map if the reflected
|
||||
// objects were already created), transforms the daughters (if present)
|
||||
// and place it in the given mother.
|
||||
// The result is a pair of physical volumes;
|
||||
// the second physical volume is a placement in a reflected mother
|
||||
// - or 0 if mother LV was not reflected.
|
||||
// ---
|
||||
|
||||
if (fVerboseLevel>0) {
|
||||
G4cout << "Place " << name << " lv " << LV << " "
|
||||
<< LV->GetName() << G4endl;
|
||||
}
|
||||
|
||||
// decompose transformation
|
||||
G4Scale3D scale;
|
||||
G4Rotate3D rotation;
|
||||
G4Translate3D translation;
|
||||
|
||||
transform3D.getDecomposition(scale, rotation, translation);
|
||||
G4Transform3D pureTransform3D = translation * rotation;
|
||||
|
||||
//PrintTransform(transform3D);
|
||||
//PrintTransform(pureTransform3D);
|
||||
|
||||
// check that scale correspond to fScale
|
||||
CheckScale(scale);
|
||||
|
||||
//
|
||||
// reflection IS NOT present in transform3D
|
||||
//
|
||||
|
||||
if (! IsReflection(scale)) {
|
||||
if (fVerboseLevel>0)
|
||||
G4cout << "scale positive" << G4endl;
|
||||
|
||||
G4VPhysicalVolume* pv1
|
||||
= new G4PVPlacement(pureTransform3D, LV, name, motherLV, isMany, copyNo);
|
||||
|
||||
G4VPhysicalVolume* pv2 = 0;
|
||||
if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV)) {
|
||||
|
||||
// if mother was reflected
|
||||
// reflect this LV and place it in reflected mother
|
||||
|
||||
pv2 = new G4PVPlacement(
|
||||
fScale * (pureTransform3D * fScale.inverse()),
|
||||
ReflectLV(LV), name, reflMotherLV, isMany, copyNo);
|
||||
}
|
||||
|
||||
return G4PhysicalVolumesPair(pv1, pv2);
|
||||
}
|
||||
|
||||
//
|
||||
// reflection IS present in transform3D
|
||||
//
|
||||
|
||||
if (fVerboseLevel>0)
|
||||
G4cout << "scale negative" << G4endl;
|
||||
|
||||
G4VPhysicalVolume* pv1
|
||||
= new G4PVPlacement(pureTransform3D,
|
||||
ReflectLV(LV), name, motherLV, isMany, copyNo);
|
||||
|
||||
G4VPhysicalVolume* pv2 = 0;
|
||||
if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV)) {
|
||||
|
||||
// if mother was reflected
|
||||
// place the refLV consituent in reflected mother
|
||||
|
||||
pv2 = new G4PVPlacement(fScale * (pureTransform3D * fScale.inverse()),
|
||||
LV, name, reflMotherLV, isMany, copyNo);
|
||||
}
|
||||
|
||||
return G4PhysicalVolumesPair(pv1, pv2);
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4PhysicalVolumesPair G4ReflectionFactory::Replicate(const G4String& name,
|
||||
G4LogicalVolume* LV,
|
||||
G4LogicalVolume* motherLV,
|
||||
EAxis axis,
|
||||
G4int nofReplicas,
|
||||
G4double width,
|
||||
G4double offset)
|
||||
{
|
||||
// Creates replica in given mother.
|
||||
// The result is a pair of physical volumes;
|
||||
// the second physical volume is a replica in a reflected mother
|
||||
// - or 0 if mother LV was not reflected.
|
||||
// ---
|
||||
|
||||
if (fVerboseLevel>0) {
|
||||
G4cout << "Replicate " << name << " lv " << LV << " "
|
||||
<< LV->GetName() << G4endl;
|
||||
}
|
||||
|
||||
G4VPhysicalVolume* pv1
|
||||
= new G4PVReplica(name, LV, motherLV, axis, nofReplicas, width, offset);
|
||||
|
||||
G4VPhysicalVolume* pv2 = 0;
|
||||
if (G4LogicalVolume* reflMotherLV = GetReflectedLV(motherLV)) {
|
||||
|
||||
// if mother was reflected
|
||||
// reflect the LV and replicate it in reflected mother
|
||||
|
||||
pv2 = new G4PVReplica(name, ReflectLV(LV), reflMotherLV,
|
||||
axis, nofReplicas, width, offset);
|
||||
}
|
||||
|
||||
return G4PhysicalVolumesPair(pv1, pv2);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// private methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4LogicalVolume* G4ReflectionFactory::ReflectLV(G4LogicalVolume* LV)
|
||||
{
|
||||
// Gets/creates the reflected solid and logical volume
|
||||
// and copies + transforms LV daughters.
|
||||
// ---
|
||||
|
||||
G4LogicalVolume* refLV = GetReflectedLV(LV);
|
||||
|
||||
if (!refLV) {
|
||||
|
||||
// create new (reflected) objects
|
||||
refLV = CreateReflectedLV(LV);
|
||||
|
||||
// process daughters
|
||||
ReflectDaughters(LV, refLV);
|
||||
}
|
||||
|
||||
return refLV;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4LogicalVolume* G4ReflectionFactory::CreateReflectedLV(G4LogicalVolume* LV)
|
||||
{
|
||||
// Creates the reflected solid and logical volume
|
||||
// and add the logical volumes pair in the maps.
|
||||
// ---
|
||||
|
||||
// consistency check
|
||||
if (fReflectedLVMap.find(LV) != fReflectedLVMap.end()) {
|
||||
G4Exception(
|
||||
"G4ReflectionFactory::CreateReflectedLV: called for already reflected volume!");
|
||||
}
|
||||
|
||||
G4VSolid* refSolid
|
||||
= new G4ReflectedSolid(LV->GetSolid()->GetName() + fNameExtension,
|
||||
LV->GetSolid(), fScale);
|
||||
|
||||
G4LogicalVolume* refLV
|
||||
= new G4LogicalVolume(refSolid,
|
||||
LV->GetMaterial(),
|
||||
LV->GetName() + fNameExtension,
|
||||
LV->GetFieldManager(),
|
||||
LV->GetSensitiveDetector(),
|
||||
LV->GetUserLimits());
|
||||
|
||||
fConstituentLVMap[LV] = refLV;
|
||||
fReflectedLVMap[refLV] = LV;
|
||||
|
||||
return refLV;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4ReflectionFactory::ReflectDaughters(G4LogicalVolume* LV,
|
||||
G4LogicalVolume* refLV)
|
||||
{
|
||||
// Reflects daughters recursively.
|
||||
// ---
|
||||
|
||||
if (fVerboseLevel>0) {
|
||||
G4cout << "G4ReflectionFactory::ReflectDaughters: "
|
||||
<< LV->GetNoDaughters() << " of " << LV->GetName() << G4endl;
|
||||
}
|
||||
|
||||
for (G4int i=0; i<LV->GetNoDaughters(); i++) {
|
||||
|
||||
G4VPhysicalVolume* dPV = LV->GetDaughter(i);
|
||||
|
||||
if (! dPV->IsReplicated()) {
|
||||
ReflectPVPlacement(dPV, refLV);
|
||||
}
|
||||
else if (! dPV->GetParameterisation()) {
|
||||
ReflectPVReplica(dPV, refLV);
|
||||
}
|
||||
else {
|
||||
ReflectPVParameterised(dPV, refLV);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4ReflectionFactory::ReflectPVPlacement(G4VPhysicalVolume* dPV,
|
||||
G4LogicalVolume* refLV)
|
||||
{
|
||||
// Copies and transforms daughter of PVPlacement type of
|
||||
// a constituent volume into a reflected volume.
|
||||
// ---
|
||||
|
||||
G4LogicalVolume* dLV = dPV->GetLogicalVolume();
|
||||
|
||||
// update daughter transformation
|
||||
G4Transform3D dt(dPV->GetObjectRotationValue(), dPV->GetObjectTranslation());
|
||||
dt = fScale * (dt * fScale.inverse());
|
||||
|
||||
G4LogicalVolume* refDLV;
|
||||
|
||||
if (fVerboseLevel>0)
|
||||
G4cout << "Daughter: " << dPV << " " << dLV->GetName();
|
||||
|
||||
if (!IsReflected(dLV)) {
|
||||
|
||||
if (fVerboseLevel>0)
|
||||
G4cout << " will be reflected." << G4endl;
|
||||
|
||||
// create new daughter solid and logical volume
|
||||
refDLV = CreateReflectedLV(dLV);
|
||||
|
||||
// create new daughter physical volume
|
||||
// with updated transformation
|
||||
|
||||
G4VPhysicalVolume* refDPV
|
||||
= new G4PVPlacement(dt, refDLV, dPV->GetName(), refLV,
|
||||
dPV->IsMany(), dPV->GetCopyNo());
|
||||
|
||||
refLV->AddDaughter(refDPV);
|
||||
|
||||
// recursive call
|
||||
ReflectDaughters(dLV, refDLV);
|
||||
}
|
||||
else {
|
||||
if (fVerboseLevel>0)
|
||||
G4cout << " will be reconstited." << G4endl;
|
||||
|
||||
refDLV = GetConstituentLV(dLV);
|
||||
|
||||
G4VPhysicalVolume* refDPV
|
||||
= new G4PVPlacement(dt, refDLV, dPV->GetName(), refLV,
|
||||
dPV->IsMany(), dPV->GetCopyNo());
|
||||
|
||||
refLV->AddDaughter(refDPV);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4ReflectionFactory::ReflectPVReplica(G4VPhysicalVolume* dPV,
|
||||
G4LogicalVolume* refLV)
|
||||
{
|
||||
// Copies and transforms daughter of PVReplica type of
|
||||
// a constituent volume into a reflected volume.
|
||||
// ---
|
||||
|
||||
G4LogicalVolume* dLV = dPV->GetLogicalVolume();
|
||||
|
||||
// get replication data
|
||||
EAxis axis;
|
||||
G4int nofReplicas;
|
||||
G4double width;
|
||||
G4double offset;
|
||||
G4bool consuming;
|
||||
|
||||
dPV->GetReplicationData(axis, nofReplicas, width, offset, consuming);
|
||||
|
||||
G4LogicalVolume* refDLV;
|
||||
|
||||
if (fVerboseLevel>0)
|
||||
G4cout << "Daughter: " << dPV << " " << dLV->GetName();
|
||||
|
||||
if (!IsReflected(dLV)) {
|
||||
|
||||
if (fVerboseLevel>0)
|
||||
G4cout << " will be reflected." << G4endl;
|
||||
|
||||
// create new daughter solid and logical volume
|
||||
refDLV = CreateReflectedLV(dLV);
|
||||
|
||||
// create new daughter replica
|
||||
|
||||
G4VPhysicalVolume* refDPV
|
||||
= new G4PVReplica(dPV->GetName(), refDLV, refLV,
|
||||
axis, nofReplicas, width, offset);
|
||||
|
||||
|
||||
refLV->AddDaughter(refDPV);
|
||||
|
||||
// recursive call
|
||||
ReflectDaughters(dLV, refDLV);
|
||||
}
|
||||
else {
|
||||
if (fVerboseLevel>0)
|
||||
G4cout << " will be reconstited." << G4endl;
|
||||
|
||||
refDLV = GetConstituentLV(dLV);
|
||||
|
||||
G4VPhysicalVolume* refDPV
|
||||
= new G4PVReplica(dPV->GetName(), refDLV, refLV,
|
||||
axis, nofReplicas, width, offset);
|
||||
|
||||
refLV->AddDaughter(refDPV);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4ReflectionFactory::ReflectPVParameterised(G4VPhysicalVolume* dPV,
|
||||
G4LogicalVolume* refLV)
|
||||
{
|
||||
// Not implemented.
|
||||
// Should copy and transform daughter of PVReplica type of
|
||||
// a constituent volume into a reflected volume.
|
||||
// ---
|
||||
|
||||
G4Exception(
|
||||
"G4ReflectionFactory: Parameterised volumes cannot be reflected yet.");
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4LogicalVolume* G4ReflectionFactory::GetConstituentLV(
|
||||
G4LogicalVolume* reflLV) const
|
||||
{
|
||||
// Returns the consituent volume of the given reflected volume,
|
||||
// 0 if the given reflected volume was not found.
|
||||
// ---
|
||||
|
||||
LogicalVolumesMapIterator it = fReflectedLVMap.find(reflLV);
|
||||
|
||||
if (it == fReflectedLVMap.end()) return 0;
|
||||
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4LogicalVolume* G4ReflectionFactory::GetReflectedLV(
|
||||
G4LogicalVolume* lv) const
|
||||
{
|
||||
// Returns the reflected volume of the given consituent volume,
|
||||
// 0 if the given volume was not reflected.
|
||||
// ---
|
||||
|
||||
LogicalVolumesMapIterator it = fConstituentLVMap.find(lv);
|
||||
|
||||
if (it == fConstituentLVMap.end()) return 0;
|
||||
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4ReflectionFactory::IsConstituent(G4LogicalVolume* lv) const
|
||||
{
|
||||
// Returns true if the given volume has been already reflected
|
||||
// (is in the map of constituent volumes).
|
||||
// ---
|
||||
|
||||
return (fConstituentLVMap.find(lv) != fConstituentLVMap.end());
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4ReflectionFactory::IsReflected(G4LogicalVolume* lv) const
|
||||
{
|
||||
// Returns true if the given volume is a reflected volume
|
||||
// (is in the map reflected volumes).
|
||||
// ---
|
||||
|
||||
return (fReflectedLVMap.find(lv) != fReflectedLVMap.end());
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4ReflectionFactory::IsReflection(const G4Scale3D& scale) const
|
||||
{
|
||||
// Returns true if the scale is negative, false otherwise.
|
||||
// ---
|
||||
|
||||
if (scale(0,0)*scale(1,1)*scale(2,2) < 0.)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4ReflectionFactory::PrintConstituentLVMap()
|
||||
{
|
||||
// temporary - for debugging purpose
|
||||
// ---
|
||||
|
||||
LogicalVolumesMapIterator it;
|
||||
for (it = fConstituentLVMap.begin(); it != fConstituentLVMap.end(); it++) {
|
||||
G4cout << "lv: " << (*it).first << " lv_refl: " << (*it).second << G4endl;
|
||||
}
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4ReflectionFactory::CheckScale(const G4Scale3D& scale) const
|
||||
{
|
||||
// Check if scale correspond to fScale,
|
||||
// if not give exception.
|
||||
// ---
|
||||
|
||||
if (!IsReflection(scale)) return;
|
||||
|
||||
G4double diff = 0.;
|
||||
for (G4int i=0; i<4; i++)
|
||||
for (G4int j=0; j<4; j++)
|
||||
diff += abs(scale(i,j) - fScale(i,j));
|
||||
|
||||
if (diff > kCarTolerance)
|
||||
G4Exception("G4ReflectionFactory::CheckScale: unexpected scale has occured.");
|
||||
}
|
||||
|
||||
void G4ReflectionFactory::SetVerboseLevel(G4int verboseLevel)
|
||||
{
|
||||
fVerboseLevel = verboseLevel;
|
||||
}
|
||||
|
||||
G4int G4ReflectionFactory::GetVerboseLevel() const
|
||||
{
|
||||
return fVerboseLevel;
|
||||
}
|
||||
|
||||
/*
|
||||
// placement with decomposed transformation
|
||||
|
||||
G4VPhysicalVolume* pv1
|
||||
= new G4PVPlacement(new G4RotationMatrix(rotation.getRotation().inverse()),
|
||||
translation.getTranslation(),
|
||||
refLV, name, motherLV, isMany, copyNo);
|
||||
*/
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4SubtractionSolid.cc,v 1.12.2.1 2001/06/28 19:08:58 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4SubtractionSolid.cc,v 1.15 2001/08/13 14:03:38 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
// Implementation of methods for the class G4IntersectionSolid
|
||||
//
|
||||
@@ -156,7 +156,13 @@ G4SubtractionSolid::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
G4ThreeVector normal;
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
G4Exception("Invalid call in G4SubtractionSolid::SurfaceNormal(p), point p is outside") ;
|
||||
G4cerr << "WARNING - Invalid call in G4SubtractionSolid::SurfaceNormal(p),"
|
||||
<< " point p is inside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4SubtractionSolid::SurfaceNormal(p), p is outside") ;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -181,6 +187,8 @@ G4SubtractionSolid::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
normal = -fPtrSolidB->SurfaceNormal(p) ;
|
||||
}
|
||||
G4cerr<<"G4SubtractionSolid::SurfaceNormal(p), point p is inside"<<G4endl ;
|
||||
// G4cout<<"Warning: G4SubtractionSolid::SurfaceNormal(p), point p is inside"
|
||||
// <<G4endl ;
|
||||
}
|
||||
}
|
||||
return normal;
|
||||
@@ -198,7 +206,13 @@ G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p,
|
||||
|
||||
if( Inside(p) == kInside )
|
||||
{
|
||||
G4Exception("Invalid call in G4SubtractionSolid::DistanceToIn(p,v), point p is inside") ;
|
||||
G4cerr << "WARNING - Invalid call in G4SubtractionSolid::DistanceToIn(p,v),"
|
||||
<< " point p is inside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
G4cerr << " v = " << v << G4endl;
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4SubtractionSolid::DistanceToIn(p,v), p is inside") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
if( // ( fPtrSolidA->Inside(p) != kOutside) && // case1:p in both A&B
|
||||
@@ -274,7 +288,12 @@ G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p) const
|
||||
G4double dist;
|
||||
if( Inside(p) == kInside )
|
||||
{
|
||||
G4Exception("Invalid call in G4SubtractionSolid::DistanceToIn(p), point p is inside") ;
|
||||
G4cerr << "WARNING - Invalid call in G4SubtractionSolid::DistanceToIn(p),"
|
||||
<< " point p is inside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4SubtractionSolid::DistanceToIn(p), p is inside") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
if( ( fPtrSolidA->Inside(p) != kOutside) && // case 1
|
||||
@@ -311,7 +330,13 @@ G4SubtractionSolid::DistanceToOut( const G4ThreeVector& p,
|
||||
G4cout << "v.x() = " << v.x() << G4endl;
|
||||
G4cout << "v.y() = " << v.y() << G4endl;
|
||||
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
|
||||
G4Exception("Invalid call in G4SubtractionSolid::DistanceToOut(p,v), point p is outside") ;
|
||||
G4cerr << "WARNING - Invalid call in G4SubtractionSolid::DistanceToOut(p,v),"
|
||||
<< " point p is outside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
G4cerr << " v = " << v << G4endl;
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4SubtractionSolid::DistanceToOut(p,v), p is outside") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
G4double distout;
|
||||
@@ -344,7 +369,12 @@ G4SubtractionSolid::DistanceToOut( const G4ThreeVector& p ) const
|
||||
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
G4Exception("Invalid call in G4SubtractionSolid::DistanceToOut(p), point p is outside") ;
|
||||
G4cerr << "WARNING - Invalid call in G4SubtractionSolid::DistanceToOut(p),"
|
||||
<< " point p is outside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4SubtractionSolid::DistanceToOut(p), p is outside") ;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UnionSolid.cc,v 1.16.2.1 2001/06/28 19:08:58 gunter Exp $
|
||||
// GEANT4 tag $Name: $
|
||||
// $Id: G4UnionSolid.cc,v 1.19 2001/08/13 14:03:38 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
//
|
||||
// Implementation of methods for the class G4IntersectionSolid
|
||||
//
|
||||
@@ -170,7 +170,12 @@ G4UnionSolid::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
G4Exception("Invalid call in G4UnionSolid::SurfaceNormal(p), point p is outside") ;
|
||||
G4cerr << "WARNING - Invalid call in G4UnionSolid::SurfaceNormal(p),"
|
||||
<< " point p is outside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4UnionSolid::SurfaceNormal(p), p is outside") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
if(fPtrSolidA->Inside(p) == kSurface && fPtrSolidB->Inside(p) != kInside)
|
||||
@@ -184,9 +189,14 @@ G4UnionSolid::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
}
|
||||
else
|
||||
{
|
||||
G4Exception("Invalid call in G4UnionSolid::SurfaceNormal(p), point p is inside") ;
|
||||
normal= fPtrSolidA->SurfaceNormal(p) ;
|
||||
G4cerr << "WARNING - Invalid call in G4UnionSolid::SurfaceNormal(p),"
|
||||
<< " point p is inside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4UnionSolid::SurfaceNormal(p), p is inside") ;
|
||||
#endif
|
||||
}
|
||||
|
||||
return normal;
|
||||
}
|
||||
|
||||
@@ -200,7 +210,13 @@ G4UnionSolid::DistanceToIn( const G4ThreeVector& p,
|
||||
{
|
||||
if( Inside(p) == kInside )
|
||||
{
|
||||
G4Exception("Invalid call in G4UnionSolid::DistanceToIn(p,v), point p is inside") ;
|
||||
G4cerr << "WARNING - Invalid call in G4UnionSolid::DistanceToIn(p,v),"
|
||||
<< " point p is inside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
G4cerr << " v = " << v << G4endl;
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4UnionSolid::DistanceToIn(p,v), point p is intside");
|
||||
#endif
|
||||
}
|
||||
return G4std::min(fPtrSolidA->DistanceToIn(p,v),
|
||||
fPtrSolidB->DistanceToIn(p,v) ) ;
|
||||
@@ -216,12 +232,19 @@ G4UnionSolid::DistanceToIn( const G4ThreeVector& p) const
|
||||
{
|
||||
if( Inside(p) == kInside )
|
||||
{
|
||||
G4Exception("Invalid call in G4UnionSolid::DistanceToIn(p), point p is inside") ;
|
||||
G4cerr << "WARNING - Invalid call in G4UnionSolid::DistanceToIn(p),"
|
||||
<< " point p is inside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4UnionSolid::DistanceToIn(p), p is inside") ;
|
||||
#endif
|
||||
}
|
||||
G4double distA = fPtrSolidA->DistanceToIn(p) ;
|
||||
G4double distB = fPtrSolidB->DistanceToIn(p) ;
|
||||
|
||||
return G4std::min(distA,distB) ;
|
||||
G4double safety = G4std::min(distA,distB) ;
|
||||
if(safety < 0.0) safety = 0.0 ;
|
||||
return safety ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
@@ -241,15 +264,21 @@ G4UnionSolid::DistanceToOut( const G4ThreeVector& p,
|
||||
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
G4cout << "Position:" << G4endl << G4endl;
|
||||
G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl;
|
||||
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl;
|
||||
G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl;
|
||||
G4cout << "Direction:" << G4endl << G4endl;
|
||||
G4cout << "v.x() = " << v.x() << G4endl;
|
||||
G4cout << "v.y() = " << v.y() << G4endl;
|
||||
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
|
||||
G4Exception("Invalid call in G4UnionSolid::DistanceToOut(p,v), point p is outside") ;
|
||||
G4cerr << "WARNING - Invalid call in G4UnionSolid::DistanceToOut(p,v),"
|
||||
<< " point p is outside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
G4cerr << " v = " << v << G4endl;
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4cout << "Position:" << G4endl << G4endl;
|
||||
G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl;
|
||||
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl;
|
||||
G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl;
|
||||
G4cout << "Direction:" << G4endl << G4endl;
|
||||
G4cout << "v.x() = " << v.x() << G4endl;
|
||||
G4cout << "v.y() = " << v.y() << G4endl;
|
||||
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
|
||||
G4Exception("Invalid call in G4UnionSolid::DistanceToOut(p,v), point p is outside");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -313,7 +342,12 @@ G4UnionSolid::DistanceToOut( const G4ThreeVector& p ) const
|
||||
G4double distout = kInfinity;
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
G4Exception("Invalid call in G4UnionSolid::DistanceToOut(p), point p is outside") ;
|
||||
G4cerr << "WARNING - Invalid call in G4UnionSolid::DistanceToOut(p),"
|
||||
<< " point p is outside" << G4endl;
|
||||
G4cerr << " p = " << p << G4endl;
|
||||
#ifdef G4BOOLDEBUG
|
||||
G4Exception("Invalid call in G4UnionSolid::DistanceToOut(p), p is outtside");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user