Import Geant4 4.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:39:52 +02:00
parent 921d3b1cda
commit 330b82b769
4524 changed files with 178689 additions and 43575 deletions
+5 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.2 1999/04/15 12:23:41 johna Exp $
# $Id: GNUmakefile,v 1.3 2002/01/10 15:34:27 gcosmo Exp $
# ----------------------------------------------------------------
# GNUmakefile for geometry/CSG library. Gabriele Cosmo, 16/11/96.
# ----------------------------------------------------------------
@@ -19,4 +19,8 @@ CPPFLAGS += -I$(G4BASE)/intercoms/include \
-I$(G4BASE)/geometry/volumes/include \
-I$(G4BASE)/geometry/management/include
ifdef G4BOOLDEBUG
CPPFLAGS += -DG4BOOLDEBUG
endif
include $(G4INSTALL)/config/common.gmk
+27 -1
View File
@@ -1,5 +1,5 @@
$Id: History,v 1.24 2001/11/08 15:46:31 gcosmo Exp $
$Id: History,v 1.32 2002/05/13 06:56:49 gcosmo Exp $
-------------------------------------------------------------------
=========================================================
@@ -20,6 +20,32 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
May 11 2002 Vladimir Grichine geom-bool-V04-00-05
- G4ReflectedSolid.cc: bounding-box like algorithm for CalculateExtent().
Apr 16 2002 Vladimir Grichine geom-bool-V04-00-04
- G4ReflectedSolid.cc: enhanced algorithm for CalculateExtent(), now
passing all basic unit tests.
- Updated unit test for G4ReflectedSolid, testG4ReflectedSolid.cc
Mar 26 2002 Vladimir Grichine geom-bool-V04-00-03
- G4ReflectedSolid.cc: modified implementation of CalculateExtent() to
properly consider transformation of reflected extent.
Feb 15 2002 Vladimir Grichine geom-bool-V04-00-02
- G4ReflectedSolid[.hh.cc]:
o Defined new methods Set/GetTransform3D() and Set/GetDirectTransform3D()
for defining/accessing the real reflected transformation
o Moved methods for G4AffineTransform to protected.
Feb 07 2002 Gabriele Cosmo geom-bool-V04-00-01
- G4ReflectionFactory.cc: fixed bug causing repetition of daughter volumes.
Jan 10 2002 Gabriele Cosmo geom-solid-bool-V04-00-00
- Moved all verbosity mode warnings to G4BOOLDEBUG and commented exceptions.
- Activated G4BOOLDEBUG mechanism in GNUmakefile.
- Fixed unit tests.
Nov 08 2001 Gabriele Cosmo geom-solid-bool-V03-02-02
- Fix for verbosity in G4ReflectionFactory.cc. Reduced of one level.
@@ -22,7 +22,7 @@
//
//
// $Id: G4BooleanSolid.hh,v 1.5 2001/07/11 09:59:51 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// class G4BooleanSolid
@@ -22,7 +22,7 @@
//
//
// $Id: G4DisplacedSolid.hh,v 1.11 2001/07/11 09:59:51 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// class G4DisplacedSolid
@@ -22,7 +22,7 @@
//
//
// $Id: G4IntersectionSolid.hh,v 1.5 2001/07/11 09:59:51 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// class G4IntersectionSolid
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4ReflectedSolid.hh,v 1.2 2001/10/18 10:07:49 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-00 $
// $Id: G4ReflectedSolid.hh,v 1.5 2002/02/15 15:55:25 grichine Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// class G4ReflectedSolid
@@ -35,6 +35,7 @@
// History:
//
// 23.07.01 V.Grichine, creation according John/Gabriele recommendations
// 15.02.02 V.Grichine, get/set methods for fPtr(Direct)Transform3D
#ifndef G4ReflectedSolid_HH
#define G4ReflectedSolid_HH
@@ -98,12 +99,27 @@ class G4ReflectedSolid : public G4VSolid
// return a self pointer else return 0.
G4VSolid* GetConstituentMovedSolid() const;
G4Transform3D GetTransform3D() const;
void SetTransform3D(G4Transform3D&);
G4Transform3D GetDirectTransform3D() const;
void SetDirectTransform3D(G4Transform3D&);
// Accessors methods.
public: // without description
void DescribeYourselfTo ( G4VGraphicsScene& scene ) const ;
G4Polyhedron* CreatePolyhedron () const ;
G4NURBS* CreateNURBS () const ;
// For creating graphical representations (ie for visualisation).
protected:
G4AffineTransform GetTransform() const;
void SetTransform(G4AffineTransform&);
G4AffineTransform GetDirectTransform() const;
void SetDirectTransform(G4AffineTransform&);
// Accessors methods.
G4RotationMatrix GetFrameRotation() const;
void SetFrameRotation(const G4RotationMatrix&);
G4ThreeVector GetFrameTranslation() const;
@@ -117,15 +133,6 @@ class G4ReflectedSolid : public G4VSolid
void SetObjectTranslation(const G4ThreeVector&);
// Get/Set the rotation/translation, as applied to the object.
public: // without description
void DescribeYourselfTo ( G4VGraphicsScene& scene ) const ;
G4Polyhedron* CreatePolyhedron () const ;
G4NURBS* CreateNURBS () const ;
// For creating graphical representations (ie for visualisation).
protected:
G4VSolid* fPtrSolid ;
G4AffineTransform* fPtrTransform ;
G4AffineTransform* fDirectTransform ;
@@ -141,3 +148,11 @@ class G4ReflectedSolid : public G4VSolid
} ;
#endif
@@ -22,7 +22,7 @@
//
//
// $Id: G4ReflectionFactory.hh,v 1.1 2001/10/18 10:05:08 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-00 $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// class G4Reflection
@@ -22,7 +22,7 @@
//
//
// $Id: G4SubtractionSolid.hh,v 1.5 2001/07/11 09:59:51 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// class G4SubtractionSolid
@@ -22,7 +22,7 @@
//
//
// $Id: G4UnionSolid.hh,v 1.6 2001/07/11 09:59:51 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// class G4UnionSolid
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4BooleanSolid.cc,v 1.5 2001/07/11 09:59:52 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// $Id: G4BooleanSolid.cc,v 1.6 2002/01/10 15:34:27 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// Implementation for the abstract base class for solids created by boolean
// operations between other solids
@@ -106,7 +106,7 @@ const G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no) const
else if( no == 1 )
subSolid = fPtrSolidB;
else
G4Exception("G4BooleanSolid::GetConstituentSolid()const invalid subsolid index");
G4Exception("G4BooleanSolid::GetConstituentSolid() - invalid subsolid index");
return subSolid;
}
@@ -119,7 +119,7 @@ const G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no) const
else if( no == 1 )
subSolid = fPtrSolidB;
else
G4Exception("G4BooleanSolid::GetConstituentSolid invalid subsolid index");
G4Exception("G4BooleanSolid::GetConstituentSolid() - invalid subsolid index");
return subSolid;
}
@@ -22,7 +22,7 @@
//
//
// $Id: G4DisplacedSolid.cc,v 1.14 2001/07/11 09:59:52 gunter Exp $
// GEANT4 tag $Name: geant4-04-00 $
// GEANT4 tag $Name: geant4-04-01 $
//
// Implementation for G4DisplacedSolid class for boolean
// operations between other solids
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4IntersectionSolid.cc,v 1.16 2001/10/02 08:51:48 grichine Exp $
// GEANT4 tag $Name: geant4-04-00 $
// $Id: G4IntersectionSolid.cc,v 1.17 2002/01/10 15:34:27 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// Implementation of methods for the class G4IntersectionSolid
//
@@ -169,16 +169,16 @@ G4IntersectionSolid::SurfaceNormal( const G4ThreeVector& p ) const
insideA= fPtrSolidA->Inside(p);
insideB= fPtrSolidB->Inside(p);
#ifdef G4BOOLDEBUG
// if( Inside(p) == kOutside )
if( (insideA == kOutside) || (insideB == kOutside) )
{
G4cerr << "WARNING - Invalid call in G4IntersectionSolid::SurfaceNormal(p),"
G4cout << "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
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4IntersectionSolid::SurfaceNormal(p), p is outside") ;
}
#endif
// OLD: if(fPtrSolidA->DistanceToOut(p) <= fPtrSolidB->DistanceToOut(p) )
@@ -202,12 +202,12 @@ G4IntersectionSolid::SurfaceNormal( const G4ThreeVector& p ) const
normal= fPtrSolidA->SurfaceNormal(p) ;
else
normal= fPtrSolidB->SurfaceNormal(p) ;
G4cerr << "WARNING - Invalid call in G4IntersectionSolid::SurfaceNormal(p),"
#ifdef G4BOOLDEBUG
G4cout << "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
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4IntersectionSolid::SurfaceNormal(p), p is outsurface") ;
#endif
}
return normal;
@@ -224,13 +224,13 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p,
G4double dist = 0.0, disTmp = 0.0 ;
if( Inside(p) == kInside )
{
G4cerr << "WARNING - Invalid call in G4IntersectionSolid::DistanceToIn(p,v),"
#ifdef G4BOOLDEBUG
G4cout << "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
G4cout << " p = " << p << G4endl;
G4cout << " v = " << v << G4endl;
// G4Exception("Invalid call in G4IntersectionSolid::DistanceToIn(p,v), p is inside") ;
#endif
}
else
{
@@ -385,15 +385,15 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p,
G4double
G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p) const
{
#ifdef G4BOOLDEBUG
if( Inside(p) == kInside )
{
G4cerr << "WARNING - Invalid call in G4IntersectionSolid::DistanceToIn(p),"
G4cout << "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
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4IntersectionSolid::DistanceToIn(p), p is inside") ;
}
#endif
EInside sideA = fPtrSolidA->Inside(p) ;
EInside sideB = fPtrSolidB->Inside(p) ;
G4double dist ;
@@ -431,12 +431,9 @@ G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p,
G4bool validNormA, validNormB;
G4ThreeVector nA, nB;
#ifdef G4BOOLDEBUG
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;
@@ -445,10 +442,13 @@ G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p,
G4cout << "v.x() = " << v.x() << G4endl;
G4cout << "v.y() = " << v.y() << G4endl;
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
#ifdef G4BOOLDEBUG
G4Exception("Invalid call in G4IntersectionSolid::DistanceToOut(p,v), p is outside") ;
#endif
G4cout << "WARNING - Invalid call in G4IntersectionSolid::DistanceToOut(p,v),"
<< " point p is outside" << G4endl;
G4cout << " p = " << p << G4endl;
G4cout << " v = " << v << G4endl;
// 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) ;
@@ -476,16 +476,15 @@ G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p,
G4double
G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p ) const
{
#ifdef G4BOOLDEBUG
if( Inside(p) == kOutside )
{
G4cerr << "WARNING - Invalid call in G4IntersectionSolid::DistanceToOut(p),"
G4cout << "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
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4IntersectionSolid::DistanceToOut(p), p is outside") ;
}
#endif
return G4std::min(fPtrSolidA->DistanceToOut(p),
fPtrSolidB->DistanceToOut(p) ) ;
@@ -21,8 +21,9 @@
// ********************************************************************
//
//
// $Id: G4ReflectedSolid.cc,v 1.3 2001/10/18 10:07:50 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-00 $
// $Id: G4ReflectedSolid.cc,v 1.8 2002/05/11 14:10:38 grichine Exp $
//
// GEANT4 tag $Name: geant4-04-01 $
//
// Implementation for G4ReflectedSolid class for boolean
// operations between other solids
@@ -32,6 +33,7 @@
#include "G4ReflectedSolid.hh"
#include "G4Point3D.hh"
#include "G4Normal3D.hh"
#include "G4VSolid.hh"
#include "G4VoxelLimits.hh"
#include "G4AffineTransform.hh"
@@ -158,6 +160,38 @@ void G4ReflectedSolid::SetDirectTransform(G4AffineTransform& transform)
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
G4Transform3D G4ReflectedSolid::GetTransform3D() const
{
G4Transform3D aTransform = *fPtrTransform3D;
return aTransform;
}
void G4ReflectedSolid::SetTransform3D(G4Transform3D& transform)
{
fPtrTransform3D = &transform ;
}
//////////////////////////////////////////////////////////////////////////////
G4Transform3D G4ReflectedSolid::GetDirectTransform3D() const
{
G4Transform3D aTransform= *fDirectTransform3D;
return aTransform;
}
void G4ReflectedSolid::SetDirectTransform3D(G4Transform3D& transform)
{
fDirectTransform3D = &transform ;
}
/////////////////////////////////////////////////////////////////////////////
G4RotationMatrix G4ReflectedSolid::GetFrameRotation() const
{
G4RotationMatrix InvRotation= fDirectTransform->NetRotation();
@@ -217,24 +251,275 @@ G4ReflectedSolid::CalculateExtent( const EAxis pAxis,
G4double& pMin,
G4double& pMax ) const
{
G4VoxelLimits unLimit;
G4AffineTransform unTransform;
G4double x1 = -kInfinity, x2 = kInfinity,
y1 = -kInfinity, y2 = kInfinity,
z1 = -kInfinity, z2 = kInfinity;
G4bool existsAfterClip = false ;
existsAfterClip = fPtrSolid->CalculateExtent(kXAxis,unLimit,unTransform,x1,x2);
existsAfterClip = fPtrSolid->CalculateExtent(kYAxis,unLimit,unTransform,y1,y2);
existsAfterClip = fPtrSolid->CalculateExtent(kZAxis,unLimit,unTransform,z1,z2);
existsAfterClip = false;
pMin = +kInfinity ;
pMax = -kInfinity ;
G4Transform3D pTransform3D = G4Transform3D(pTransform.NetRotation().inverse(),
pTransform.NetTranslation());
G4Transform3D transform3D = pTransform3D*(*fDirectTransform3D);
G4Point3D tmpPoint;
// Calculate rotated vertex coordinates
G4ThreeVectorList* vertices = new G4ThreeVectorList();
vertices->reserve(8);
if (vertices)
{
G4ThreeVector vertex0(x1,y1,z1) ;
tmpPoint = transform3D*G4Point3D(vertex0);
vertex0 = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
vertices->push_back(vertex0);
G4ThreeVector vertex1(x2,y1,z1) ;
tmpPoint = transform3D*G4Point3D(vertex1);
vertex1 = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
vertices->push_back(vertex1);
G4ThreeVector vertex2(x2,y2,z1) ;
tmpPoint = transform3D*G4Point3D(vertex2);
vertex2 = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
vertices->push_back(vertex2);
G4ThreeVector vertex3(x1,y2,z1) ;
tmpPoint = transform3D*G4Point3D(vertex3);
vertex3 = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
vertices->push_back(vertex3);
G4ThreeVector vertex4(x1,y1,z2) ;
tmpPoint = transform3D*G4Point3D(vertex4);
vertex4 = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
vertices->push_back(vertex4);
G4ThreeVector vertex5(x2,y1,z2) ;
tmpPoint = transform3D*G4Point3D(vertex5);
vertex5 = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
vertices->push_back(vertex5);
G4ThreeVector vertex6(x2,y2,z2) ;
tmpPoint = transform3D*G4Point3D(vertex6);
vertex6 = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
vertices->push_back(vertex6);
G4ThreeVector vertex7(x1,y2,z2) ;
tmpPoint = transform3D*G4Point3D(vertex7);
vertex7 = G4ThreeVector(tmpPoint.x(),tmpPoint.y(),tmpPoint.z());
vertices->push_back(vertex7);
}
else
{
G4Exception("G4ReflectedSolid::CalculateExtent - Out of memory !");
}
ClipCrossSection(vertices,0,pVoxelLimit,pAxis,pMin,pMax) ;
ClipCrossSection(vertices,4,pVoxelLimit,pAxis,pMin,pMax) ;
ClipBetweenSections(vertices,0,pVoxelLimit,pAxis,pMin,pMax) ;
if (pVoxelLimit.IsLimited(pAxis) == false)
{
if ( pMin != kInfinity || pMax != -kInfinity )
{
existsAfterClip = true ;
// Add 2*tolerance to avoid precision troubles
pMin -= kCarTolerance;
pMax += kCarTolerance;
}
}
else
{
G4ThreeVector clipCentre(
( pVoxelLimit.GetMinXExtent()+pVoxelLimit.GetMaxXExtent())*0.5,
( pVoxelLimit.GetMinYExtent()+pVoxelLimit.GetMaxYExtent())*0.5,
( pVoxelLimit.GetMinZExtent()+pVoxelLimit.GetMaxZExtent())*0.5);
if ( pMin != kInfinity || pMax != -kInfinity )
{
existsAfterClip = true ;
// Check to see if endpoints are in the solid
clipCentre(pAxis) = pVoxelLimit.GetMinExtent(pAxis);
if (Inside(transform3D.inverse()*G4Point3D(clipCentre)) != kOutside)
// if (Inside(pTransform.Inverse().TransformPoint(clipCentre)) != kOutside)
{
pMin = pVoxelLimit.GetMinExtent(pAxis);
}
else
{
pMin -= kCarTolerance;
}
clipCentre(pAxis) = pVoxelLimit.GetMaxExtent(pAxis);
if (Inside(transform3D.inverse()*G4Point3D(clipCentre)) != kOutside)
// if (Inside(pTransform.Inverse().TransformPoint(clipCentre)) != kOutside)
{
pMax = pVoxelLimit.GetMaxExtent(pAxis);
}
else
{
pMax += kCarTolerance;
}
}
// Check for case where completely enveloping clipping volume
// If point inside then we are confident that the solid completely
// envelopes the clipping volume. Hence set min/max extents according
// to clipping volume extents along the specified axis.
else if (Inside(transform3D.inverse()*G4Point3D(clipCentre)) != kOutside)
// else if (Inside(pTransform.Inverse().TransformPoint(clipCentre)) != kOutside)
{
existsAfterClip = true ;
pMin = pVoxelLimit.GetMinExtent(pAxis) ;
pMax = pVoxelLimit.GetMaxExtent(pAxis) ;
}
}
delete vertices;
return existsAfterClip;
/* ******************************************
// General rotated case from G4Tube
G4int i, noEntries, noBetweenSections4 ;
G4bool existsAfterClip = false ;
G4Point3D refPoint;
G4ThreeVector point;
G4ThreeVectorList* vertices = new G4ThreeVectorList() ;
G4ThreeVectorList* tmpVertices = fPtrSolid->CreateRotatedVertices(pTransform) ;
pMin = +kInfinity ;
pMax = -kInfinity ;
noEntries = tmpVertices->size() ;
for(i = 0 ; i < noEntries ; i++ )
{
point = (*tmpVertices)[i];
// G4Point3D refPoint = (*fDirectTransform3D)*G4Point3D(point) ;
G4Point3D refPoint = (*fPtrTransform3D)*G4Point3D(point) ;
point = G4ThreeVector(refPoint.x(),refPoint.y(),refPoint.z());
vertices->push_back(point);
}
noBetweenSections4 = noEntries - 4 ;
G4cout<<G4endl;
for(i = 0 ; i < noBetweenSections4 ; i++ )
{
G4cout<<i<<"\t"<<"v.x = "<<((*vertices)[i]).x()<<"\t"
<<"v.y = "<<((*vertices)[i]).y()<<"\t"
<<"v.z = "<<((*vertices)[i]).z()<<"\t"
<<G4endl;
}
G4cout<<G4endl;
for (i = 0 ; i < noEntries ; i += 4 )
{
ClipCrossSection(vertices,i,pVoxelLimit,pAxis,pMin,pMax) ;
}
for (i = 0 ; i < noBetweenSections4 ; i += 4 )
{
ClipBetweenSections(vertices,i,pVoxelLimit,pAxis,pMin,pMax) ;
}
if (pMin != kInfinity || pMax != -kInfinity )
{
existsAfterClip = true ;
pMin -= kCarTolerance ; // Add 2*tolerance to avoid precision troubles
pMax += kCarTolerance ;
}
else
{
// Check for case where completely enveloping clipping volume
// If point inside then we are confident that the solid completely
// envelopes the clipping volume. Hence set min/max extents according
// to clipping volume extents along the specified axis.
G4ThreeVector clipCentre(
(pVoxelLimit.GetMinXExtent()+pVoxelLimit.GetMaxXExtent())*0.5,
(pVoxelLimit.GetMinYExtent()+pVoxelLimit.GetMaxYExtent())*0.5,
(pVoxelLimit.GetMinZExtent()+pVoxelLimit.GetMaxZExtent())*0.5 ) ;
if ( Inside(pTransform.Inverse().TransformPoint(clipCentre)) != kOutside )
{
existsAfterClip = true ;
pMin = pVoxelLimit.GetMinExtent(pAxis) ;
pMax = pVoxelLimit.GetMaxExtent(pAxis) ;
}
}
delete vertices;
delete tmpVertices;
return existsAfterClip;
/////////////////
G4AffineTransform sumTransform ;
G4bool extentR, extent ;
G4double min, max, minR, maxR ;
G4Transform3D sumT, pt3d ;
sumTransform.Product(*fDirectTransform,pTransform) ;
G4ReflectX3D tX ;
G4ReflectY3D tY ;
G4ReflectZ3D tZ ;
extent = fPtrSolid->CalculateExtent(pAxis,pVoxelLimit,pTransform,
min,max) ;
G4bool extentR ;
G4double minR, maxR ;
pt3d = G4Transform3D(pTransform.NetRotation().inverse(),
pTransform.NetTranslation() );
sumT = pt3d * (*fDirectTransform3D) ;
sumT = ((sumT*tX)*tY)*tZ;
sumTransform = G4AffineTransform( sumT.getRotation(),
// sumT.getRotation().inverse(),
sumT.getTranslation() );
// 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 ;
// Additional extension, just in case:
// if( maxR > 0 ) pMax = 2.0*maxR ;
// else pMax = 0.5*maxR ;
// if( minR > 0 ) pMin = 0.5*minR ;
// else pMin = 2.0*minR ;
// maxR = pMax;
// minR = pMin;
// and John's trick:
pMin = -maxR ; // minR ;
pMax = -minR ; // maxR ;
return extentR ;
****************************************** */
}
/////////////////////////////////////////////////////
//
@@ -242,9 +527,10 @@ G4ReflectedSolid::CalculateExtent( const EAxis pAxis,
EInside G4ReflectedSolid::Inside(const G4ThreeVector& p) const
{
// G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
G4Point3D newPoint = (*fDirectTransform3D)*G4Point3D(p) ;
// G4Point3D newPoint = (*fPtrTransform3D)*G4Point3D(p) ;
return fPtrSolid->Inside(G4ThreeVector(newPoint.x(),newPoint.y(),newPoint.z())) ;
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4ReflectionFactory.cc,v 1.2 2001/11/08 15:47:07 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-00 $
// $Id: G4ReflectionFactory.cc,v 1.3 2002/02/07 13:15:47 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// Author: Ivana Hrivnacova, 16.10.2001 (Ivana.Hrivnacova@cern.ch)
@@ -323,20 +323,23 @@ void G4ReflectionFactory::ReflectPVPlacement(G4VPhysicalVolume* dPV,
if (fVerboseLevel>0)
G4cout << " will be reflected." << G4endl;
// create new daughter solid and logical volume
refDLV = CreateReflectedLV(dLV);
// get reflected volume if already created
refDLV = GetReflectedLV(dLV);
if (!refDLV) {
// create new daughter solid and logical volume
refDLV = CreateReflectedLV(dLV);
// recursive call
ReflectDaughters(dLV, refDLV);
}
// 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);
new G4PVPlacement(dt, refDLV, dPV->GetName(), refLV,
dPV->IsMany(), dPV->GetCopyNo());
}
else {
if (fVerboseLevel>0)
@@ -344,11 +347,8 @@ void G4ReflectionFactory::ReflectPVPlacement(G4VPhysicalVolume* dPV,
refDLV = GetConstituentLV(dLV);
G4VPhysicalVolume* refDPV
= new G4PVPlacement(dt, refDLV, dPV->GetName(), refLV,
dPV->IsMany(), dPV->GetCopyNo());
refLV->AddDaughter(refDPV);
new G4PVPlacement(dt, refDLV, dPV->GetName(), refLV,
dPV->IsMany(), dPV->GetCopyNo());
}
}
@@ -381,20 +381,22 @@ void G4ReflectionFactory::ReflectPVReplica(G4VPhysicalVolume* dPV,
if (fVerboseLevel>0)
G4cout << " will be reflected." << G4endl;
// create new daughter solid and logical volume
refDLV = CreateReflectedLV(dLV);
// get reflected volume if already created
refDLV = GetReflectedLV(dLV);
if (!refDLV) {
// create new daughter solid and logical volume
refDLV = CreateReflectedLV(dLV);
// recursive call
ReflectDaughters(dLV, refDLV);
}
// create new daughter replica
G4VPhysicalVolume* refDPV
= new G4PVReplica(dPV->GetName(), refDLV, refLV,
axis, nofReplicas, width, offset);
refLV->AddDaughter(refDPV);
// recursive call
ReflectDaughters(dLV, refDLV);
new G4PVReplica(dPV->GetName(), refDLV, refLV,
axis, nofReplicas, width, offset);
}
else {
if (fVerboseLevel>0)
@@ -402,11 +404,8 @@ void G4ReflectionFactory::ReflectPVReplica(G4VPhysicalVolume* dPV,
refDLV = GetConstituentLV(dLV);
G4VPhysicalVolume* refDPV
= new G4PVReplica(dPV->GetName(), refDLV, refLV,
axis, nofReplicas, width, offset);
refLV->AddDaughter(refDPV);
new G4PVReplica(dPV->GetName(), refDLV, refLV,
axis, nofReplicas, width, offset);
}
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4SubtractionSolid.cc,v 1.15 2001/08/13 14:03:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-00 $
// $Id: G4SubtractionSolid.cc,v 1.16 2002/01/10 15:34:27 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// Implementation of methods for the class G4IntersectionSolid
//
@@ -156,13 +156,12 @@ G4SubtractionSolid::SurfaceNormal( const G4ThreeVector& p ) const
G4ThreeVector normal;
if( Inside(p) == kOutside )
{
G4cerr << "WARNING - Invalid call in G4SubtractionSolid::SurfaceNormal(p),"
#ifdef G4BOOLDEBUG
G4cout << "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
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4SubtractionSolid::SurfaceNormal(p), p is outside") ;
#endif
}
else
{
@@ -186,9 +185,9 @@ 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 ;
#ifdef G4BOOLDEBUG
G4cout << "G4SubtractionSolid::SurfaceNormal(p), point p is inside" << G4endl ;
#endif
}
}
return normal;
@@ -204,16 +203,16 @@ G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p,
{
G4double dist = 0.0,disTmp = 0.0 ;
#ifdef G4BOOLDEBUG
if( Inside(p) == kInside )
{
G4cerr << "WARNING - Invalid call in G4SubtractionSolid::DistanceToIn(p,v),"
G4cout << "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
G4cout << " p = " << p << G4endl;
G4cout << " v = " << v << G4endl;
// G4Exception("Invalid call in G4SubtractionSolid::DistanceToIn(p,v), p is inside") ;
}
#endif
if( // ( fPtrSolidA->Inside(p) != kOutside) && // case1:p in both A&B
@@ -286,15 +285,16 @@ G4double
G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p) const
{
G4double dist;
#ifdef G4BOOLDEBUG
if( Inside(p) == kInside )
{
G4cerr << "WARNING - Invalid call in G4SubtractionSolid::DistanceToIn(p),"
G4cout << "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
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4SubtractionSolid::DistanceToIn(p), p is inside") ;
}
#endif
if( ( fPtrSolidA->Inside(p) != kOutside) && // case 1
( fPtrSolidB->Inside(p) != kOutside) )
@@ -320,6 +320,7 @@ G4SubtractionSolid::DistanceToOut( const G4ThreeVector& p,
G4bool *validNorm,
G4ThreeVector *n ) const
{
#ifdef G4BOOLDEBUG
if( Inside(p) == kOutside )
{
G4cout << "Position:" << G4endl << G4endl;
@@ -330,14 +331,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;
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
G4cout << "WARNING - Invalid call in G4SubtractionSolid::DistanceToOut(p,v),"
<< " point p is outside" << G4endl;
G4cout << " p = " << p << G4endl;
G4cout << " v = " << v << G4endl;
// G4Exception("Invalid call in G4SubtractionSolid::DistanceToOut(p,v), p is outside") ;
}
#endif
G4double distout;
G4double distA = fPtrSolidA->DistanceToOut(p,v,calcNorm,validNorm,n) ;
@@ -369,12 +369,12 @@ G4SubtractionSolid::DistanceToOut( const G4ThreeVector& p ) const
if( Inside(p) == kOutside )
{
G4cerr << "WARNING - Invalid call in G4SubtractionSolid::DistanceToOut(p),"
#ifdef G4BOOLDEBUG
G4cout << "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
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4SubtractionSolid::DistanceToOut(p), p is outside") ;
#endif
}
else
{
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4UnionSolid.cc,v 1.19 2001/08/13 14:03:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-00 $
// $Id: G4UnionSolid.cc,v 1.20 2002/01/10 15:34:27 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// Implementation of methods for the class G4IntersectionSolid
//
@@ -168,15 +168,15 @@ G4UnionSolid::SurfaceNormal( const G4ThreeVector& p ) const
{
G4ThreeVector normal;
#ifdef G4BOOLDEBUG
if( Inside(p) == kOutside )
{
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
G4cout << "WARNING - Invalid call in G4UnionSolid::SurfaceNormal(p),"
<< " point p is outside" << G4endl;
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4UnionSolid::SurfaceNormal(p), p is outside") ;
}
#endif
if(fPtrSolidA->Inside(p) == kSurface && fPtrSolidB->Inside(p) != kInside)
{
@@ -190,12 +190,12 @@ G4UnionSolid::SurfaceNormal( const G4ThreeVector& p ) const
else
{
normal= fPtrSolidA->SurfaceNormal(p) ;
G4cerr << "WARNING - Invalid call in G4UnionSolid::SurfaceNormal(p),"
#ifdef G4BOOLDEBUG
G4cout << "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
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4UnionSolid::SurfaceNormal(p), p is inside") ;
#endif
}
return normal;
}
@@ -208,16 +208,17 @@ G4double
G4UnionSolid::DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const
{
#ifdef G4BOOLDEBUG
if( Inside(p) == kInside )
{
G4cerr << "WARNING - Invalid call in G4UnionSolid::DistanceToIn(p,v),"
G4cout << "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
G4cout << " p = " << p << G4endl;
G4cout << " v = " << v << G4endl;
// G4Exception("Invalid call in G4UnionSolid::DistanceToIn(p,v), point p is intside");
}
#endif
return G4std::min(fPtrSolidA->DistanceToIn(p,v),
fPtrSolidB->DistanceToIn(p,v) ) ;
}
@@ -230,16 +231,15 @@ G4UnionSolid::DistanceToIn( const G4ThreeVector& p,
G4double
G4UnionSolid::DistanceToIn( const G4ThreeVector& p) const
{
#ifdef G4BOOLDEBUG
if( Inside(p) == kInside )
{
G4cerr << "WARNING - Invalid call in G4UnionSolid::DistanceToIn(p),"
G4cout << "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
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4UnionSolid::DistanceToIn(p), p is inside") ;
}
#endif
G4double distA = fPtrSolidA->DistanceToIn(p) ;
G4double distB = fPtrSolidB->DistanceToIn(p) ;
G4double safety = G4std::min(distA,distB) ;
@@ -264,11 +264,7 @@ G4UnionSolid::DistanceToOut( const G4ThreeVector& p,
if( Inside(p) == kOutside )
{
G4cerr << "WARNING - Invalid call in G4UnionSolid::DistanceToOut(p,v),"
<< " point p is outside" << G4endl;
G4cerr << " p = " << p << G4endl;
G4cerr << " v = " << v << G4endl;
#ifdef G4BOOLDEBUG
#ifdef G4BOOLDEBUG
G4cout << "Position:" << G4endl << G4endl;
G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl;
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl;
@@ -277,8 +273,12 @@ G4UnionSolid::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 G4UnionSolid::DistanceToOut(p,v), point p is outside");
#endif
G4cout << "WARNING - Invalid call in G4UnionSolid::DistanceToOut(p,v),"
<< " point p is outside" << G4endl;
G4cout << " p = " << p << G4endl;
G4cout << " v = " << v << G4endl;
// G4Exception("Invalid call in G4UnionSolid::DistanceToOut(p,v), point p is outside");
#endif
}
else
{
@@ -342,12 +342,12 @@ G4UnionSolid::DistanceToOut( const G4ThreeVector& p ) const
G4double distout = kInfinity;
if( Inside(p) == kOutside )
{
G4cerr << "WARNING - Invalid call in G4UnionSolid::DistanceToOut(p),"
#ifdef G4BOOLDEBUG
G4cout << "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
G4cout << " p = " << p << G4endl;
// G4Exception("Invalid call in G4UnionSolid::DistanceToOut(p), p is outtside");
#endif
}
else
{