Import Geant4 0.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-01 15:25:35 +02:00
parent 54d6b71f95
commit b97f8d0df7
3237 changed files with 807095 additions and 0 deletions
+132
View File
@@ -0,0 +1,132 @@
// This code implementation is the intellectual property of
// the RD44 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: G4Box.hh,v 2.1 1998/07/12 02:56:49 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4Box
//
// A Box is a cuboid of given half lengths dx,dy,dz. The Box is
// centred on the origin with sides parallel to the x/y/z axes.
//
// Member functions:
//
// As inherited from G4CSGSolid +
//
// G4Box(const G4String& pName, G4double pX,
// G4double pY, G4double pZ)
// Construct a box with name, and half lengths pX,pY,pZ
//
// G4double GetXHalfLength() const
// G4double GetYHalfLength() const
// G4double GetZHalfLength() const
//
// Return the respective parameter
//
// Protected:
//
// G4ThreeVectorList*
// CreateRotatedVertices(const G4AffineTransform& pTransform) const
//
// Create the List of transformed vertices in the format required
// for G4VSolid:: ClipCrossSection and ClipBetweenSections.
//
// Member Data: (private)
//
// fDx,fDy,fDz - The box's half-widths
//
// History:
// 30.06.95 P.Kent Converted from source code developed end 94
// 27.03.96 J.Allison Added virtual functions DescribeYourselfTo and
// SendWireframeTo (G4VGraphicsModel&).
// 22.07.96 J.Allison Changed G4VGraphicsModel to G4VGraphicsScene.
// and SendPolyhedronTo to CreatePolyhedron.
// 27.03.98 J.Apostolakis Inherit from G4CSGSolid (not G4VSolid).
#ifndef G4BOX_HH
#define G4BOX_HH
#include "G4CSGSolid.hh"
class G4Box : public G4CSGSolid {
public:
G4Box(const G4String& pName, G4double pX,
G4double pY, G4double pZ);
virtual ~G4Box();
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep);
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const;
// Access functions
G4double GetXHalfLength() const
{
return fDx;
}
G4double GetYHalfLength() const
{
return fDy;
}
G4double GetZHalfLength() const
{
return fDz;
}
void SetXHalfLength(G4double dx)
{
fDx=dx;
}
void SetYHalfLength(G4double dy)
{
fDy=dy;
}
void SetZHalfLength(G4double dz)
{
fDz=dz;
}
EInside Inside(const G4ThreeVector& p) const;
G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
G4double DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) const;
G4double DistanceToIn(const G4ThreeVector& p) const;
G4double DistanceToOut(const G4ThreeVector& p,const G4ThreeVector& v,
const G4bool calcNorm=false,
G4bool *validNorm=0,G4ThreeVector *n=0) const;
G4double DistanceToOut(const G4ThreeVector& p) const;
virtual G4GeometryType GetEntityType() const { return G4String("G4Box"); }
void DescribeYourselfTo (G4VGraphicsScene& scene) const;
G4VisExtent GetExtent () const;
G4Polyhedron* CreatePolyhedron () const;
G4NURBS* CreateNURBS () const;
protected:
G4ThreeVectorList*
CreateRotatedVertices(const G4AffineTransform& pTransform) const;
// Codes for faces (kPX=plus x face,kMY= minus y face etc)
enum ESide {kPX,kMX,kPY,kMY,kPZ,kMZ};
private:
G4double fDx,fDy,fDz;
};
#endif
@@ -0,0 +1,36 @@
// This code implementation is the intellectual property of
// the RD44 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: G4CSGSolid.hh,v 2.0 1998/07/02 17:01:58 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4CSGSolid
//
// An abstract class for Constructed Solids. Used primarily to
// simplify inheritance tree.
//
// Member functions:
//
// As inherited from G4VSolid
//
// History:
// 27.03.98 J.Apostolakis Created first version.
#ifndef G4CSGSOLID_HH
#define G4CSGSOLID_HH
#include "G4VSolid.hh"
class G4CSGSolid : public G4VSolid {
public:
G4CSGSolid(const G4String& pName);
virtual ~G4CSGSolid();
};
#endif
@@ -0,0 +1,45 @@
//
// G4ClippablePolygon.hh
//
// Declaration of a utility class of a polycon that can be clipped
// by a voxel
//
#ifndef G4ClippablePolycon_hh
#define G4ClippablePolycon_hh
#include "globals.hh"
#include "geomdefs.hh"
#include "G4ThreeVector.hh"
class G4VoxelLimits;
class G4AffineTransform;
class G4AffineTransform;
class G4VoxelLimits;
#include <rw/tvordvec.h>
typedef RWTValOrderedVector<G4ThreeVector> G4ThreeVectorList;
class G4ClippablePolygon {
public:
G4ClippablePolygon() {;}
~G4ClippablePolygon() {;}
void AddVertexInOrder( const G4ThreeVector vertex );
void ClearAllVertices();
void Clip( const G4VoxelLimits &voxelLimit );
void GetExtent( const EAxis axis,
G4double &min, G4double &max );
private:
G4ThreeVectorList vertices;
void ClipToSimpleLimits( G4ThreeVectorList& pPolygon,
G4ThreeVectorList& outputPolygon,
const G4VoxelLimits& pVoxelLimit );
};
#endif
@@ -0,0 +1,145 @@
// This code implementation is the intellectual property of
// the RD44 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: G4Cons.hh,v 2.0 1998/07/02 17:01:56 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4Cons
//
// A G4Cons is, in the general case, a Phi segment of a cone, with half-length
// fDz, inner and outer radii specified at -fDz and +fDz. The Phi segment is
// described by a starting fSPhi angle, and the +fDPhi delta angle for the shape.
// If the delta angle is >=2*M_PI, the shape is treated as continuous in Phi
//
// Member Data:
//
// fRmin1 inside radius at -fDz
// fRmin2 inside radius at +fDz
// fRmax1 outside radius at -fDz
// fRmax2 outside radius at +fDz
// fDz half length in z
//
// fSPhi starting angle of the segment in radians
// fDPhi delta angle of the segment in radians
//
// Note:
// Internally fSPhi & fDPhi are adjusted so that fDPhi<=2PI,
// and fDPhi+fSPhi<=2PI. This enables simpler comparisons to be
// made with (say) Phi of a point.
//
// History:
// 19.3.94 P.Kent Old C++ code converted to tolerant geometry
// 13.9.96 V.Grichine Final modifications to commit
#ifndef G4Cons_HH
#define G4Cons_HH
#include "G4CSGSolid.hh"
class G4Cons : public G4CSGSolid
{
public:
G4Cons(const G4String& pName,
G4double pRmin1, G4double pRmax1,
G4double pRmin2, G4double pRmax2,
G4double pDz,
G4double pSPhi, G4double pDPhi);
virtual ~G4Cons() ;
// Access functions
G4double GetInnerRadiusMinusZ() const { return fRmin1 ; }
G4double GetOuterRadiusMinusZ() const { return fRmax1 ; }
G4double GetInnerRadiusPlusZ() const { return fRmin2 ; }
G4double GetOuterRadiusPlusZ() const { return fRmax2 ; }
G4double GetZHalfLength() const { return fDz ; }
G4double GetStartPhiAngle () const { return fSPhi; }
G4double GetDeltaPhiAngle () const { return fDPhi; }
// Modifier functions
void SetInnerRadiusMinusZ( G4double Rmin1 ) { fRmin1= Rmin1 ; }
void SetOuterRadiusMinusZ( G4double Rmax1 ) { fRmax1= Rmax1 ; }
void SetInnerRadiusPlusZ ( G4double Rmin2 ) { fRmin2= Rmin2 ; }
void SetOuterRadiusPlusZ ( G4double Rmax2 ) { fRmax2= Rmax2 ; }
void SetZHalfLength ( G4double newDz ) { fDz= newDz ; }
void SetStartPhiAngle ( G4double newSPhi) { fSPhi= newSPhi; }
void SetDeltaPhiAngle ( G4double newDPhi) { fDPhi= newDPhi; }
// Other methods
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep);
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const;
EInside Inside(const G4ThreeVector& p) const;
G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
G4double DistanceToIn(const G4ThreeVector& p,
const G4ThreeVector& v) const;
G4double DistanceToIn(const G4ThreeVector& p) const;
G4double DistanceToOut(const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm=G4bool(false),
G4bool *validNorm=0,
G4ThreeVector *n=0) const;
G4double DistanceToOut(const G4ThreeVector& p) const ;
virtual G4GeometryType GetEntityType() const { return G4String("G4Cons"); }
void DescribeYourselfTo(G4VGraphicsScene& scene) const;
G4VisExtent GetExtent() const;
G4Polyhedron* CreatePolyhedron() const;
G4NURBS* CreateNURBS() const;
// Old access functions
G4double GetRmin1() const { return GetInnerRadiusMinusZ(); }
G4double GetRmax1() const { return GetOuterRadiusMinusZ(); }
G4double GetRmin2() const { return GetInnerRadiusPlusZ(); }
G4double GetRmax2() const { return GetOuterRadiusPlusZ(); }
G4double GetDz() const { return GetZHalfLength() ; } // fDz
G4double GetSPhi() const { return GetStartPhiAngle(); } // fSPhi
G4double GetDPhi() const { return GetDeltaPhiAngle(); } // fDPhi
protected:
G4ThreeVectorList*
CreateRotatedVertices(const G4AffineTransform& pTransform) const;
// Used by distanceToOut
enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPZ,kMZ};
// used by normal
enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNZ};
private:
G4double fRmin1,fRmin2,
fRmax1,fRmax2,
fDz,
fSPhi,fDPhi;
};
#endif
@@ -0,0 +1,40 @@
//
// G4EnclosingCylinder.hh
//
// Definition of a utility class for quickly deciding if a point
// is clearly outside a polyhedra or ploycone or deciding if
// a trajectory is clearly going to miss said shapes.
//
#ifndef G4EnclosingCylinder_hh
#define G4EnclosingCylinder_hh
#include "globals.hh"
#include "geomdefs.hh"
#include "G4ThreeVector.hh"
class G4EnclosingCylinder {
public:
G4EnclosingCylinder( const G4double r[], const G4double z[], const G4int n,
const G4bool phiIsOpen,
const G4double startPhi, const G4double totalPhi );
~G4EnclosingCylinder();
G4bool Outside( const G4ThreeVector &p ) const;
G4bool Misses( const G4ThreeVector &p, const G4ThreeVector &v ) const;
protected:
G4double radius; // radius of our cylinder
G4double zLo, zHi; // z extent
G4bool phiIsOpen; // true if there is a phi segment
G4double startPhi, // for isPhiOpen==true, starting of phi segment
totalPhi; // for isPhiOpen==true, size of phi segment
G4double rx1, ry1,
dx1, dy1;
G4double rx2, ry2,
dx2, dy2;
};
#endif
@@ -0,0 +1,211 @@
// This code implementation is the intellectual property of
// the RD44 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: G4Hype.hh,v 2.1 1998/07/12 02:56:49 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//
// class G4Hype: this class implements in G4 the volume equivalent
// to the HYPE volume in Geant 3, i.e. a tube with
// hyperbolic profile.
//
// Authors:
// Ernesto Lamanna (Ernesto.Lamanna@roma1.infn.it) &
// Francesco Safai Tehrani (Francesco.SafaiTehrani@roma1.infn.it)
// Rome, INFN & University of Rome "La Sapienza", 9 June 1998.
//
// $ Original: G4Hype.hh,v 1.0 1998/06/09 16:57:50 safai Exp $
//
// For further informations, please read G4Hype.history and G4Hype.doc.
//
// An hyperbolic volume with curved sides parallel to
// the z-axis. The Hype has a specified half-length along
// the z axis, about which it is centred, and a given
// minimum and maximum radius. A minimum radius of 0
// signifies a filled Hype (with hyperbolical inner surface).
// To have a filled Hype the user must specify
// inner radius = 0 AND inner stereo angle = 0.
//
// The inner and outer hyperbolical surfaces can have different
// stereo angles.
// A stereo angle of 0 gives a cylindrical surface.
//
// Member functions:
//
// As inherited from G4VSolid,
//
// G4Hype(const G4String &pName
// const G4double innerRadius
// const G4double outerRadius
// const G4double innerStereo
// const G4double outerStereo
// const G4double halfLenZ )
//
// Construct an hype with the given name and dimensions.
// The provided angles are in radians.
//
//
// Protected:
//
// G4ThreeVectorList*
// CreateRotatedVertices(const G4AffineTransform& pTransform) const
//
// Create the List of transformed vertices in the format required
// for G4VSolid:: ClipCrossSection and ClipBetweenSections.
//
#ifndef G4HYPE_HH
#define G4HYPE_HH
#include "G4CSGSolid.hh"
#include "G4ThreeVector.hh"
class G4Hype : public G4CSGSolid {
public:
G4Hype(const G4String &pName,
const G4double newInnerRadius,
const G4double newOuterRadius,
const G4double newInnerStereo,
const G4double newOuterStereo,
const G4double newHalfLenZ);
virtual ~G4Hype();
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep);
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const;
G4double GetInnerRadius () const { return innerRadius; }
G4double GetOuterRadius () const { return outerRadius; }
G4double GetZHalfLength () const { return halfLenZ; }
G4double GetInnerStereo () const { return innerStereo; }
G4double GetOuterStereo () const { return outerStereo; }
void SetInnerRadius (G4double newIRad)
{
innerRadius= newIRad;
innerRadius2= newIRad*newIRad;
endInnerRadius2=HypeInnerRadius2(halfLenZ);
endInnerRadius=sqrt(endInnerRadius2);
}
void SetOuterRadius (G4double newORad)
{
outerRadius= newORad;
outerRadius2=newORad*newORad;
endOuterRadius2=HypeOuterRadius2(halfLenZ);
endOuterRadius=sqrt(endOuterRadius2);
}
void SetZHalfLength (G4double newHLZ) { halfLenZ = newHLZ ; }
void SetInnerStereo (G4double newISte)
{
innerStereo= newISte;
tanInnerStereo2=tan(innerStereo)*tan(innerStereo);
endInnerRadius2=HypeInnerRadius2(halfLenZ);
endInnerRadius=sqrt(endInnerRadius2);
}
void SetOuterStereo (G4double newOSte)
{
outerStereo= newOSte;
tanOuterStereo2=tan(outerStereo)*tan(outerStereo);
endOuterRadius2=HypeOuterRadius2(halfLenZ);
endOuterRadius=sqrt(endOuterRadius2);
}
EInside Inside(const G4ThreeVector& p) const;
G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const;
G4double DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) const;
G4double DistanceToIn(const G4ThreeVector& p) const;
G4double DistanceToOut(const G4ThreeVector& p,const G4ThreeVector& v,
const G4bool calcNorm=G4bool(false),
G4bool *validNorm=0,G4ThreeVector *n=0) const;
G4double DistanceToOut(const G4ThreeVector& p) const;
virtual G4GeometryType GetEntityType() const { return G4String("G4Hype"); }
void DescribeYourselfTo (G4VGraphicsScene& scene) const;
G4VisExtent GetExtent () const;
G4Polyhedron* CreatePolyhedron () const;
G4NURBS* CreateNURBS () const;
protected:
G4ThreeVectorList*
CreateRotatedVertices(const G4AffineTransform& pTransform) const;
// values of hype radius at a given Z
double HypeInnerRadius2(double zVal) const { return (tanInnerStereo2*zVal*zVal+innerRadius2); }
double HypeOuterRadius2(double zVal) const { return (tanOuterStereo2*zVal*zVal+outerRadius2); }
G4double innerRadius; // variable names are quite self explanative
G4double outerRadius;
G4double halfLenZ;
G4double innerStereo;
G4double outerStereo;
// precalculated parameters, squared quantities
double tanInnerStereo2; // squared tan of Inner Stereo angle
double tanOuterStereo2; // squared tan of Outer Stereo angle
double innerRadius2; // squared Inner Radius
double outerRadius2; // squared Outer Radius
double endInnerRadius2; // squared endcap Inner Radius
double endOuterRadius2; // squared endcap Outer Radius
double endInnerRadius; // endcap Inner Radius
double endOuterRadius; // endcap Outer Radius
// Used by distanceToOut
enum ESide {outerFace,innerFace,leftCap, rightCap};
};
#endif
@@ -0,0 +1,45 @@
//
// G4IntersectingCone.hh
//
// Declaration of a utility class which calculates the intersection
// of an arbitrary line with a fixed cone
//
#ifndef G4IntersectingCone_hh
#define G4IntersectingCone_hh
#include "globals.hh"
#include "geomdefs.hh"
#include "G4ThreeVector.hh"
class G4IntersectingCone {
public:
G4IntersectingCone( const G4double r[2], const G4double z[2] );
virtual ~G4IntersectingCone();
G4int LineHitsCone( const G4ThreeVector &p, const G4ThreeVector &v,
G4double *s1, G4double *s2 );
G4bool HitOn( const G4double r, const G4double z );
inline G4double RLo() const { return rLo; }
inline G4double RHi() const { return rHi; }
inline G4double ZLo() const { return zLo; }
inline G4double ZHi() const { return zHi; }
protected:
G4double zLo, zHi, // Z bounds of side
rLo, rHi; // R bounds of side
G4bool type1; // True if cone is type 1 (abs(z1-z2)>abs(r1-r2))
G4double A, B; // Cone radius parameter:
// type 1: r = A + B*z
// type 2: z = A + B*r
G4int LineHitsCone1( const G4ThreeVector &p, const G4ThreeVector &v,
G4double *s1, G4double *s2 );
G4int LineHitsCone2( const G4ThreeVector &p, const G4ThreeVector &v,
G4double *s1, G4double *s2 );
};
#endif
@@ -0,0 +1,169 @@
// This code implementation is the intellectual property of
// the RD44 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: G4Para.hh,v 2.0 1998/07/02 17:01:59 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4Para
//
// A G4Parallepiped, essentially a box with half lengths dx,dy,dz `skewed'
// so that there are angles theta & phi of the polar line joining the faces at
// +-dz in z, and alpha formed by the y axis and the plane joinng the
// centre of the faces G4Parallel to the z-x plane at -dy and +dy.
//
// A G4Para is defined by:
// dx,dy,dz Half-length in x,y,z
// alpha Angle formed by the y axis and by the plane joining
// the centre of the faces G4Parallel to the z-x plane
// at -dy and +dy
// theta Polar angle of the line joining the centres of the
// faces at -dz and +dz in z
// phi Azimuthal angle of the line joining the centres of the
// faces at -dz and +dz in z
// Member data:
//
// Note that the angles parameters are not stored - precomputed trig is
// stored instead.
//
// fDx Half-length in x
// fDy Half-length in y
// fDz Half-length in z
//
// fTalpha Tan of alpha
// fTthetaCphi Tan theta * Cos phi
// fTthetaSphi Tan theta * Sin phi
//
// History:
// 21.3.94 P.Kent Old C++ code converted to tolerant geometry
// 31.10.96 V.Grichine Modifications according G4Box/Tubs before to commit
#ifndef G4Para_HH
#define G4Para_HH
#include "G4CSGSolid.hh"
class G4Para : public G4CSGSolid {
public:
G4Para(const G4String& pName,
G4double pDx, G4double pDy, G4double pDz,
G4double pAlpha, G4double pTheta, G4double pPhi);
G4Para( const G4String& pName,
const G4ThreeVector pt[8]) ;
virtual ~G4Para() ;
// Access functions
G4double GetZHalfLength() const
{
return fDz ;
}
G4ThreeVector GetSymAxis() const
{
G4double cosTheta = 1.0/sqrt(1+fTthetaCphi*fTthetaCphi+fTthetaSphi*fTthetaSphi) ;
return G4ThreeVector(fTthetaCphi*cosTheta,fTthetaSphi*cosTheta,cosTheta) ;
}
G4double GetYHalfLength() const
{
return fDy ;
}
G4double GetXHalfLength() const
{
return fDx ;
}
G4double GetTanAlpha() const
{
return fTalpha ;
}
// Set functions
void SetXHalfLength(G4double val)
{
fDx= val;
}
void SetYHalfLength(G4double val)
{
fDy= val;
}
void SetZHalfLength(G4double val)
{
fDz= val;
}
void SetAlpha(double alpha)
{
fTalpha= tan(alpha);
}
void SetTanAlpha(double val)
{
fTalpha= val;
}
void SetThetaAndPhi(double pTheta, double pPhi)
{
fTthetaCphi=tan(pTheta)*cos(pPhi);
fTthetaSphi=tan(pTheta)*sin(pPhi);
}
void SetAllParameters(G4double pDx, G4double pDy, G4double pDz,
G4double pAlpha, G4double pTheta, G4double pPhi);
// Methods
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep);
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const;
EInside Inside(const G4ThreeVector& p) const;
G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
G4double DistanceToIn(const G4ThreeVector& p,
const G4ThreeVector& v) const;
G4double DistanceToIn(const G4ThreeVector& p) const;
G4double DistanceToOut(const G4ThreeVector& p,const G4ThreeVector& v,
const G4bool calcNorm=G4bool(false),
G4bool *validNorm=0,G4ThreeVector *n=0) const;
G4double DistanceToOut(const G4ThreeVector& p) const;
// Naming method (pseudo-RTTI : run-time type identification
virtual G4GeometryType GetEntityType() const { return G4String("G4Para"); }
// Visualisation functions
void DescribeYourselfTo (G4VGraphicsScene& scene) const;
G4VisExtent GetExtent () const;
G4Polyhedron* CreatePolyhedron () const;
G4NURBS* CreateNURBS () const;
protected:
G4ThreeVectorList*
CreateRotatedVertices(const G4AffineTransform& pTransform) const;
private:
G4double fDx,fDy,fDz;
G4double fTalpha,fTthetaCphi,fTthetaSphi;
};
#endif
@@ -0,0 +1,72 @@
//
// G4PolyPhiFace.hh
//
// Definition of a face that bounds a polycone or polyhedra when it has a phi
// opening.
//
// Specifically: a face that lies on a plane that passes through
// the z axis. It has boundaries that are straight lines of arbitrary length
// and direction, but with corners aways on the same side of the z axis.
//
#ifndef G4PolyPhiFace_hh
#define G4PolyPhiFace_hh
#include "G4VCSGface.hh"
typedef struct {
G4double r, z; // position
G4double rNorm,
zNorm; // r/z normal
G4ThreeVector norm3D; // 3D normal
} G4PolyPhiFaceVertex;
typedef struct {
G4PolyPhiFaceVertex *v0, *v1; // Corners
G4double tr, tz, // Unit vector along edge
length; // Length of edge
G4ThreeVector norm3D; // 3D edge normal vector
} G4PolyPhiFaceEdge;
class G4PolyPhiFace : public G4VCSGface {
public:
G4PolyPhiFace( const G4double *r, const G4double *z, const G4int n,
const G4double phi, const G4double deltaPhi, const G4bool start );
virtual ~G4PolyPhiFace();
G4bool Intersect( const G4ThreeVector &p, const G4ThreeVector &v,
const G4bool outgoing, const G4double surfTolerance,
G4double &distance, G4double &distFromSurface,
G4ThreeVector &normal, G4bool &allBehind );
G4double Distance( const G4ThreeVector &p, const G4bool outgoing );
EInside Inside( const G4ThreeVector &p, const G4double tolerance,
G4double *bestDistance );
G4ThreeVector Normal( const G4ThreeVector &p, G4double *bestDistance );
G4double Extent( const G4ThreeVector axis );
void CalculateExtent( const EAxis axis,
const G4VoxelLimits &voxelLimit,
const G4AffineTransform &tranform,
G4double &min, G4double &max );
protected:
G4PolyPhiFaceEdge *edges; // The edges of the face
G4PolyPhiFaceVertex *corners; // And the corners
G4int numEdges; // Number of edges
G4ThreeVector normal; // Normal unit vector
G4ThreeVector radial; // Unit vector along radial direction
G4ThreeVector surface; // Point on surface
G4double rMin, rMax, // Extent in r
zMin, zMax; // Extent in z
G4bool InsideEdges( const G4double r, const G4double z );
G4bool InsideEdges( const G4double r, const G4double z,
G4double *distRZ2, G4PolyPhiFaceVertex **base3Dnorm=0,
G4ThreeVector **head3Dnorm=0 );
};
#endif
@@ -0,0 +1,87 @@
//
// G4Polycone.hh
//
// Declaration of a CSG type "PCON" geant volume, inherited from
// class G4CSGSolid
//
#ifndef G4Polycone_hh
#define G4Polycone_hh
#include "G4VCSGfaceted.hh"
#include "G4PolyconeSide.hh"
class G4VCSGface;
class G4Polycone : public G4VCSGfaceted
{
public:
G4Polycone( G4String name,
const G4double phiStart, // initial phi starting angle
const G4double phiTotal, // total phi angle
const G4int numZPlanes, // number of z planes
const G4double zPlane[], // position of z planes
const G4double rInner[], // tangent distance to inner surface
const G4double rOuter[] ); // tangent distance to outer surface
G4Polycone( G4String name,
const G4double phiStart, // initial phi starting angle
const G4double phiTotal, // total phi angle
const G4int numRZ, // number corners in r,z space
const G4double r[], // r coordinate of these corners
const G4double z[] ); // z coordinate of these corners
virtual ~G4Polycone();
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep);
virtual G4GeometryType GetEntityType() const { return G4String("G4Polycone"); }
G4Polyhedron* CreatePolyhedron() const;
G4NURBS* CreateNURBS() const;
inline G4double GetStartPhi() const { return startPhi; }
inline G4double GetEndPhi() const { return endPhi; }
inline G4bool IsOpen() const { return phiIsOpen; }
inline G4int GetNumRZCorner() const { return numCorner;}
inline G4PolyconeSideRZ GetCorner( const G4int index ) const { return corners[index]; }
protected:
//
// Here are our parameters
//
G4double startPhi; // Starting phi value (0 < phiStart < 2pi)
G4double endPhi; // end phi value (0 < endPhi-phiStart < 2pi)
G4bool phiIsOpen; // true if there is a phi segment
G4int numCorner; // number RZ points
G4PolyconeSideRZ *corners; // corner r,z points
//
// The following is temporary until graphics_reps is brought up to this design
//
typedef struct {
G4double Start_angle;
G4double Opening_angle;
G4int Num_z_planes;
G4double *Z_values;
G4double *Rmin;
G4double *Rmax;
G4bool exist;
} G4PolyconeKluge;
G4PolyconeKluge original_parameters;
//
// Generic initializer, call by all constructors
//
void Create( const G4double phiStart, // initial phi starting angle
const G4double phiTotal, // total phi angle
const G4int numRZ, // number corners in r,z space
const G4double r[], // r coordinate of these corners
const G4double z[] ); // z coordinate of these corners
};
#endif
@@ -0,0 +1,68 @@
//
// G4PolyconeSide
//
// Declaration of a face that represents one conical side of a polycone
//
#ifndef G4PolyconeSide_hh
#define G4PolyconeSide_hh
#include "G4VCSGface.hh"
class G4IntersectingCone;
typedef struct {
G4double r, z; // start of vector
} G4PolyconeSideRZ;
class G4PolyconeSide : public G4VCSGface {
public:
G4PolyconeSide( const G4PolyconeSideRZ *prevRZ,
const G4PolyconeSideRZ *tail,
const G4PolyconeSideRZ *head,
const G4PolyconeSideRZ *nextRZ,
const G4double phiStart, const G4double deltaPhi,
const G4bool phiIsOpen );
virtual ~G4PolyconeSide();
G4bool Intersect( const G4ThreeVector &p, const G4ThreeVector &v,
const G4bool outgoing, const G4double surfTolerance,
G4double &distance, G4double &distFromSurface,
G4ThreeVector &normal, G4bool &allBehind );
G4double Distance( const G4ThreeVector &p, const G4bool outgoing );
EInside Inside( const G4ThreeVector &p, const G4double tolerance,
G4double *bestDistance );
G4ThreeVector Normal( const G4ThreeVector &p, G4double *bestDistance );
G4double Extent( const G4ThreeVector axis );
void CalculateExtent( const EAxis axis,
const G4VoxelLimits &voxelLimit,
const G4AffineTransform &tranform,
G4double &min, G4double &max );
protected:
G4double r[2], z[2]; // r, z parameters, in specified order
G4double startPhi, // Start phi (0 to 2pi), if phiIsOpen
deltaPhi; // Delta phi (0 to 2pi), if phiIsOpen
G4bool phiIsOpen; // True if there is a phi slice
G4IntersectingCone *cone; // Our intersecting utility class
G4double rNorm, zNorm; // Normal to surface in r,z space
G4double rS, zS; // Unit vector along surface in r,z space
G4double length; // Length of face in r,z space
G4double rNormEdge[2],
zNormEdge[2]; // Normal to edges
G4double DistanceAway( const G4ThreeVector &p, const G4bool opposite,
G4double &distOutside2, G4double *rzNorm );
G4bool PointOnCone( const G4ThreeVector &p, G4ThreeVector &normal );
};
#endif
@@ -0,0 +1,103 @@
//
// G4Polyhedra.hh
//
// Declaration of a CSG type "PCON" geant volume, inherited from
// class G4CSGSolid
//
#ifndef G4Polyhedra_hh
#define G4Polyhedra_hh
#include "G4VCSGfaceted.hh"
#include "G4PolyhedraSide.hh"
class G4EnclosingCylinder;
class G4Polyhedra : public G4VCSGfaceted {
public:
G4Polyhedra( G4String name,
const G4double phiStart, // initial phi starting angle
const G4double phiTotal, // total phi angle
const G4double numSide, // number sides
const G4int numZPlanes, // number of z planes
const G4double zPlane[], // position of z planes
const G4double rInner[], // tangent distance to inner surface
const G4double rOuter[] ); // tangent distance to outer surface
G4Polyhedra( G4String name,
const G4double phiStart, // initial phi starting angle
const G4double phiTotal, // total phi angle
const G4double numSide, // number sides
const G4int numRZ, // number corners in r,z space
const G4double r[], // r coordinate of these corners
const G4double z[] ); // z coordinate of these corners
virtual ~G4Polyhedra();
//
// A couple overrides to speed things up
//
EInside Inside( const G4ThreeVector &p ) const;
G4double DistanceToIn( const G4ThreeVector &p, const G4ThreeVector &v ) const;
G4double DistanceToIn( const G4ThreeVector &p ) const { return G4VCSGfaceted::DistanceToIn(p); }
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep);
virtual G4GeometryType GetEntityType() const { return G4String("G4Polyhedra"); }
G4Polyhedron* CreatePolyhedron() const;
G4NURBS* CreateNURBS() const;
inline G4int GetNumSIde() const { return numSide; }
inline G4double GetStartPhi() const { return startPhi; }
inline G4double GetEndPhi() const { return endPhi; }
inline G4bool IsOpen() const { return phiIsOpen; }
inline G4int GetNumRZCorner() const { return numCorner;}
inline G4PolyhedraSideRZ GetCorner( const G4int index ) const { return corners[index]; }
protected:
//
// Here are our parameters
//
G4int numSide; // Number of sides
G4double startPhi; // Starting phi value (0 < phiStart < 2pi)
G4double endPhi; // end phi value (0 < endPhi-phiStart < 2pi)
G4bool phiIsOpen; // true if there is a phi segment
G4int numCorner; // number RZ points
G4PolyhedraSideRZ *corners; // corner r,z points
//
// The following is temporary until graphics_reps is brought up to this design
//
typedef struct {
G4double Start_angle;
G4double Opening_angle;
G4int numSide;
G4int Num_z_planes;
G4double *Z_values;
G4double *Rmin;
G4double *Rmax;
G4bool exist;
} G4PolyhedraKluge;
G4PolyhedraKluge original_parameters;
//
// Our quick test
//
G4EnclosingCylinder *enclosingCylinder;
//
// Generic initializer, call by all constructors
//
void Create( const G4double phiStart, // initial phi starting angle
const G4double phiTotal, // total phi angle
const G4double numSide, // number sides
const G4int numRZ, // number corners in r,z space
const G4double r[], // r coordinate of these corners
const G4double z[] ); // z coordinate of these corners
};
#endif
@@ -0,0 +1,107 @@
//
// G4PolyhedraSide
//
// Declaration of a face that represents one segmented side of a polyhedra
//
#ifndef G4PolyhedraSide_hh
#define G4PolyhedraSide_hh
#include "G4VCSGface.hh"
class G4IntersectingCone;
typedef struct {
G4double r, z; // start of vector
} G4PolyhedraSideRZ;
class G4PolyhedraSide : public G4VCSGface {
public:
G4PolyhedraSide( const G4PolyhedraSideRZ *prevRZ,
const G4PolyhedraSideRZ *tail,
const G4PolyhedraSideRZ *head,
const G4PolyhedraSideRZ *nextRZ,
const G4int numSide,
const G4double phiStart, const G4double phiTotal,
const G4bool phiIsOpen );
virtual ~G4PolyhedraSide();
G4bool Intersect( const G4ThreeVector &p, const G4ThreeVector &v,
const G4bool outgoing, const G4double surfTolerance,
G4double &distance, G4double &distFromSurface,
G4ThreeVector &normal, G4bool &allBehind );
G4double Distance( const G4ThreeVector &p, const G4bool outgoing );
EInside Inside( const G4ThreeVector &p, const G4double tolerance,
G4double *bestDistance );
G4ThreeVector Normal( const G4ThreeVector &p, G4double *bestDistance );
G4double Extent( const G4ThreeVector axis );
void CalculateExtent( const EAxis axis,
const G4VoxelLimits &voxelLimit,
const G4AffineTransform &tranform,
G4double &min, G4double &max );
protected:
//
// A couple internal data structures
//
struct sG4PolyhedraSideVec; // Secret recipe for allowing
friend struct sG4PolyhedraSideVec; // protected nested structures
typedef struct sG4PolyhedraSideEdge {
G4ThreeVector normal; // Unit normal to this edge
G4ThreeVector corner[2]; // The two corners of this phi edge
G4ThreeVector cornNorm[2]; // The normals of these corners
} G4PolyhedraSideEdge;
typedef struct sG4PolyhedraSideVec {
G4ThreeVector normal, // Normal (point out of the shape)
center, // Point in center of side
surfPhi, // Unit vector on surface pointing along phi
surfRZ; // Unit vector on surface pointing along R/Z
G4PolyhedraSideEdge *edges[2]; // The phi boundary edges to this side
// [0]=low phi [1]=high phi
G4ThreeVector edgeNorm[2]; // RZ edge normals [i] at {r[i],z[i]}
} G4PolyhedraSideVec;
G4int numSide; // Number sides
G4double r[2], z[2]; // r, z parameters, in specified order
G4double startPhi, // Start phi (0 to 2pi), if phiIsOpen
deltaPhi; // Delta phi (0 to 2pi), if phiIsOpen
G4bool phiIsOpen; // True if there is a phi slice
G4IntersectingCone *cone; // Our intersecting cone
G4PolyhedraSideVec *vecs; // Vector set for each facet of our face
G4PolyhedraSideEdge *edges; // The edges belong to vecs
G4double lenRZ, // RZ length of each side
lenPhi[2]; // Phi dimensions of each side
G4double edgeNorm; // Normal in RZ/Phi space to each side
G4bool IntersectSidePlane( const G4ThreeVector &p, const G4ThreeVector &v,
const G4PolyhedraSideVec vec,
const G4double normSign,
const G4double surfTolerance,
G4double &distance, G4double &distFromSurface );
G4int LineHitsSegments( const G4ThreeVector &p, const G4ThreeVector &v,
G4int *i1, G4int *i2 );
G4int ClosestPhiSegment( const G4double phi );
G4int PhiSegment( const G4double phi );
G4double DistanceToOneSide( const G4ThreeVector &p,
const G4PolyhedraSideVec vec,
G4double *normDist );
G4double DistanceAway( const G4ThreeVector &p,
const G4PolyhedraSideVec vec,
G4double *normDist );
};
#endif
@@ -0,0 +1,147 @@
// This code implementation is the intellectual property of
// the RD44 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: G4Sphere.hh,v 2.0 1998/07/02 17:02:02 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4Sphere
//
// A G4Sphere is, in the general case, section of a spherical shell, between
// specified phii and theta angles
//
// The phi and theta segments are described by a starting angle,
// and the +ve delta angle for the shape.
// If the delta angle is >=2*M_PI, or >=M_PI the shape is treated as
// continuous in phi or theta respectively.
//
// Theta must lie between 0-PI (incl).
//
// Member Data:
//
// fRmin inner radius
// fRmax outer radius
//
// fSPhi starting angle of the segment in radians
// fDPhi delta angle of the segment in radians
//
// fSTheta starting angle of the segment in radians
// fDTheta delta angle of the segment in radians
//
//
//
// Note:
// Internally fSPhi & fDPhi are adjusted so that fDPhi<=2PI,
// and fDPhi+fSPhi<=2PI. This enables simpler comparisons to be
// made with (say) Phi of a point.
//
//
//
// History:
// 28.3.94 P.Kent Old C++ code converted to tolerant geometry
// 17.9.96 V.Grichine Final modifications to commit
#ifndef G4Sphere_HH
#define G4Sphere_HH
#include "G4CSGSolid.hh"
class G4Sphere : public G4CSGSolid {
public:
G4Sphere(const G4String& pName,
G4double pRmin, G4double pRmax,
G4double pSPhi, G4double pDPhi,
G4double pSTheta, G4double pDTheta);
virtual ~G4Sphere() ;
// Access functions
G4double GetInsideRadius () const { return fRmin; }
G4double GetOuterRadius () const { return fRmax; }
G4double GetStartPhiAngle () const { return fSPhi; }
G4double GetDeltaPhiAngle () const { return fDPhi; }
G4double GetStartThetaAngle() const { return fSTheta; }
G4double GetDeltaThetaAngle() const { return fDTheta; }
void SetInsideRadius (G4double newRmin) { fRmin= newRmin; }
void SetOuterRadius (G4double newRmax) { fRmax= newRmax; }
void SetStartPhiAngle (G4double newSphi) { fSPhi= newSphi; }
void SetDeltaPhiAngle (G4double newDphi) { fDPhi= newDphi; }
void SetStartThetaAngle(G4double newSTheta) { fSTheta=newSTheta; }
void SetDeltaThetaAngle(G4double newDTheta) { fDTheta=newDTheta; }
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep);
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const;
EInside Inside(const G4ThreeVector& p) const;
G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
G4double DistanceToIn(const G4ThreeVector& p,
const G4ThreeVector& v) const;
G4double DistanceToIn(const G4ThreeVector& p) const;
G4double DistanceToOut(const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm=G4bool(false),
G4bool *validNorm=0,
G4ThreeVector *n=0) const;
G4double DistanceToOut(const G4ThreeVector& p) const;
// Naming method (pseudo-RTTI : run-time type identification)
virtual G4GeometryType GetEntityType() const { return G4String("G4Sphere"); }
// Visualisation functions
void DescribeYourselfTo(G4VGraphicsScene& scene) const;
G4VisExtent GetExtent() const;
G4Polyhedron* CreatePolyhedron() const;
G4NURBS* CreateNURBS() const;
// Old access functions
G4double GetRmin() const { return GetInsideRadius (); }
G4double GetRmax() const { return GetOuterRadius (); }
G4double GetSPhi() const { return GetStartPhiAngle (); }
G4double GetDPhi() const { return GetDeltaPhiAngle (); }
G4double GetSTheta() const { return GetStartThetaAngle(); }
G4double GetDTheta() const { return GetDeltaThetaAngle(); }
protected:
G4ThreeVectorList*
CreateRotatedVertices(const G4AffineTransform& pTransform,
G4int& noPolygonVertices) const;
// Used by distanceToOut
enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kSTheta,kETheta};
// used by normal
enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNSTheta,kNETheta};
private:
G4double fRmin,fRmax,
fSPhi,fDPhi,
fSTheta,fDTheta;
};
#endif
@@ -0,0 +1,148 @@
// This code implementation is the intellectual property of
// the RD44 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: G4Torus.hh,v 2.1 1998/07/12 02:56:50 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4Torus
//
// A torus or torus segment with curved sides parallel to
// the z-axis. The torus has a specified swept radius
// about which it is centred, and a given
// minimum and maximum radius. A minimum radius of 0
// signifies a filled torus . The torus segment is
// specified by starting and delta
// angles for phi, with 0 being the +x axis, PI/2
// the +y axis. A delta angle of 2PI signifies a
// complete, unsegmented torus/cylindr.
//
// Member functions:
//
// As inherited from G4CSGSolid+
//
// G4Torus(const G4String &pName
// G4double pRmin
// G4double pRmax
// G4double pRtor
// G4double pSPhi
// G4double pDPhi )
//
// Construct a torus with the given name and dimensions.
// The angles are provided is radians. pRtor >= pRmax
//
//
// Protected:
//
// G4ThreeVectorList*
// CreateRotatedVertices(const G4AffineTransform& pTransform) const
//
// Create the List of transformed vertices in the format required
// for G4VSolid:: ClipCrossSection and ClipBetweenSections.
//
// Member Data:
//
// fRmin Inside radius
// fRmax Outside radius
// fRtor swept radius of torus
//
// fSPhi The starting phi angle in radians,
// adjusted such the fSPhi+fDPhi<=2PI,
// fSPhi>-2PI
//
// fDPhi Delta angle of the segment in radians
//
// You could find very often in G4Torus:: functions the values like pt or
// it . These are the distances from p or i G4ThreeVector points in the
// plane (Z axis points p or i) to fRtor point in XY plane. This value is
// similar to rho for G4Tubs and is used for definiton of the point
// relative to fRmin and fRmax, i.e. for solution of inside/outside
// problems
//
//
// History:
// 30.10.96 V.Grichine First version of G4Torus
// 21.04.98 J.Apostolakis Added SetAllParameters function
#ifndef G4Torus_HH
#define G4Torus_HH
#include "G4CSGSolid.hh"
class G4Torus : public G4CSGSolid {
public:
G4Torus(const G4String &pName,
G4double pRmin,
G4double pRmax,
G4double pRtor,
G4double pSPhi,
G4double pDPhi);
virtual ~G4Torus();
void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor,
G4double pSPhi, G4double pDPhi);
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep);
G4int TorusRoots(G4double Ri,
const G4ThreeVector& p,
const G4ThreeVector& v) const ;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const;
G4double GetRmin() const { return fRmin ; }
G4double GetRmax() const { return fRmax ; }
G4double GetRtor () const { return fRtor ; }
G4double GetSPhi() const { return fSPhi ; }
G4double GetDPhi() const { return fDPhi ; }
EInside Inside(const G4ThreeVector& p) const;
G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
G4double DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) const;
G4double DistanceToIn(const G4ThreeVector& p) const;
G4double DistanceToOut(const G4ThreeVector& p,const G4ThreeVector& v,
const G4bool calcNorm=G4bool(false),
G4bool *validNorm=0,G4ThreeVector *n=0) const;
G4double DistanceToOut(const G4ThreeVector& p) const;
// Naming method (pseudo-RTTI : run-time type identification)
virtual G4GeometryType GetEntityType() const { return G4String("G4Torus"); }
// Visualisation functions
void DescribeYourselfTo (G4VGraphicsScene& scene) const;
G4VisExtent GetExtent () const;
G4Polyhedron* CreatePolyhedron () const;
G4NURBS* CreateNURBS () const;
protected:
G4int SolveBiQuadratic(double c[], double s[] ) const ;
G4int SolveCubic(double c[], double s[] ) const ;
G4int SolveQuadratic(double c[], double s[] ) const ;
G4ThreeVectorList*
CreateRotatedVertices(const G4AffineTransform& pTransform,
G4int& noPolygonVertices) const;
G4double fRmin,fRmax,fRtor,fSPhi,fDPhi;
// Used by distanceToOut
enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi};
// used by normal
enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi};
};
#endif
@@ -0,0 +1,329 @@
// This code implementation is the intellectual property of
// the RD44 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: G4Trap.hh,v 2.1 1998/07/12 02:56:50 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4Trap
//
// A G4Trap is a general trapezoid: The faces perpendicular to the z planes
// are tapezia, and their centres are not necessarily on a line parallel to
// the z axis.
//
// Note that of the 11 parameters desribed below, only 9 are really
// independent - a check for planarity is made in the calculation of the
// equation for each plane. If the planes are not parallel, a call to
// G4Exception is made.
//
// pDz Half-length along the z-axis
// pTheta Polar angle of the line joining the centres of the faces
// at -/+pDz
// pPhi Azimuthal angle of the line joing the centre of the face at
// -pDz to the centre of the face at +pDz
// pDy1 Half-length along y of the face at -pDz
// pDx1 Half-length along x of the side at y=-pDy1 of the face at -pDz
// pDx2 Half-length along x of the side at y=+pDy1 of the face at -pDz
// pAlp1 Angle with respect to the y axis from the centre of the side
// at y=-pDy1 to the centre at y=+pDy1 of the face at -pDz
//
// pDy2 Half-length along y of the face at +pDz
// pDx3 Half-length along x of the side at y=-pDy2 of the face at +pDz
// pDx4 Half-length along x of the side at y=+pDy2 of the face at +pDz
// pAlp2 Angle with respect to the y axis from the centre of the side
// at y=-pDy2 to the centre at y=+pDy2 of the face at +pDz
//
//
// Member Data:
//
// fDz Half-length along the z axis
// fTthetaCphi = tan(pTheta)*cos(pPhi) These combinations are suitable for
// fTthetaSphi = tan(pTheta)*sin(pPhi) creation of the trapezoid corners
//
// fDy1 Half-length along y of the face at -fDz
// fDx1 Half-length along x of the side at y=-fDy1 of the face at -fDz
// fDx2 Half-length along x of the side at y=+fDy1 of the face at -fDz
// fTalpha1 Tan of Angle with respect to the y axis from the centre of
// the side at y=-fDy1 to the centre at y=+fDy1 of the face at -fDz
//
// fDy2 Half-length along y of the face at +fDz
// fDx3 Half-length along x of the side at y=-fDy2 of the face at +fDz
// fDx4 Half-length along x of the side at y=+fDy2 of the face at +fDz
// fTalpha2 Tan of Angle with respect to the y axis from the centre of
// the side at y=-fDy1 to the centre at y=+fDy1 of the face at -fDz
//
// TrapSidePlane fPlanes[4] Plane equations of the faces not at +/-fDz
// *** order is important !!! :
//
//
// Member functions:
//
// As inherited from G4CSGSolid + Constructors
//
// G4Trap( const G4String& pName,
// G4double pDz,
// G4double pTheta, G4double pPhi,
// G4double pDy1, G4double pDx1, G4double pDx2,
// G4double pAlp1,
// G4double pDy2, G4double pDx3, G4double pDx4,
// G4double pAlp2)
// which prepare plane equations and corner coordinates from parameters
// &
// G4Trap( const G4string& pName,
// const G4ThreeVector pt[8])
// which prepare plane equations and parameters from corner coordinates
// &
// G4Trap( const G4String& pName,
// G4double pZ,
// G4double pY,
// G4double pX, G4double pLTX);
// for Right Angular Wedge from STEP
//
// & Constructor for G4Trd
//
// G4Trap( const G4String& pName,
// G4double pDx1, G4double pDx2,
// G4double pDy1, G4double pDy2,
// G4double pDz);
//
// & Constructor for G4Para
//
// G4Trap(const G4String& pName,
// G4double pDx, G4double pDy, G4double pDz,
// G4double pAlpha, G4double pTheta, G4double pPhi);
//
// + Access functions that return the respective parameter
//
// G4double GetZHalfLength() const
// G4ThreeVector GetSymAxis() const Returns coordinates of unit vector along straight
// line joining centers of -/+fDz planes
// G4double GetYHalfLength1() const
// G4double GetXHalfLength1() const
// G4double GetXHalfLength2() const
// G4double GetTanAlpha1() const
//
// G4double GetYHalfLength2() const
// G4double GetXHalfLength3() const
// G4double GetXHalfLength4() const
// G4double GetTanAlpha2() const
//
// TrapSidePlane GetSidePlane(G4int n ) const ; n = 0,1,2,3
//
// Protected:
// G4bool MakePlane( G4ThreeVector& p1,
// G4ThreeVector& p2,
// G4ThreeVector& p3,
// G4ThreeVector& p4,
// TrapSidePlane& plane )
//
//
// G4ThreeVectorList*
// CreateRotatedVertices(const G4Transform& pTransform) const
//
// Create the List of transformed vertices in the format required
// for G4CSGSolid:: ClipCrossSection and ClipBetweenSections.
//
//
// History:
//
// 23.3.94 P.Kent: Old C++ code converted to tolerant geometry
// 9.9.96 V.Grichine: Final modifications before to commit
// 1.11.96 V.Grichine Costructors for Right Angular Wedge from STEP & G4Trd/Para
// 8.12.97 J.Allison Added "nominal" contructor and method SetAllParameters.
#ifndef G4Trap_HH
#define G4Trap_HH
#include "G4CSGSolid.hh"
struct TrapSidePlane
{
G4double a,b,c,d; // Normal unit vector (a,b,c) and offset (d)
// => Ax+By+Cz+D=0
};
class G4Trap : public G4CSGSolid {
public:
// The most general constructor for G4Trap
G4Trap( const G4String& pName,
G4double pDz,
G4double pTheta, G4double pPhi,
G4double pDy1, G4double pDx1, G4double pDx2,
G4double pAlp1,
G4double pDy2, G4double pDx3, G4double pDx4,
G4double pAlp2);
G4Trap( const G4String& pName,
const G4ThreeVector pt[8]) ;
// Constructor for Right Angular Wedge from STEP
G4Trap( const G4String& pName,
G4double pZ,
G4double pY,
G4double pX, G4double pLTX);
// Constructor for G4Trd
G4Trap( const G4String& pName,
G4double pDx1, G4double pDx2,
G4double pDy1, G4double pDy2,
G4double pDz);
// Constructor for G4Para
G4Trap(const G4String& pName,
G4double pDx, G4double pDy, G4double pDz,
G4double pAlpha, G4double pTheta, G4double pPhi);
virtual ~G4Trap() ;
// Constructor for "nominal" G4Trap whose parameters are to be set
// by a G4VPramaterisation later.
G4Trap(const G4String& pName);
// Access functions
G4double GetZHalfLength() const
{
return fDz ;
}
G4ThreeVector GetSymAxis() const
{
G4double cosTheta = 1.0/sqrt(1+fTthetaCphi*fTthetaCphi+fTthetaSphi*fTthetaSphi) ;
return G4ThreeVector(fTthetaCphi*cosTheta,fTthetaSphi*cosTheta,cosTheta) ;
}
G4double GetYHalfLength1() const
{
return fDy1 ;
}
G4double GetXHalfLength1() const
{
return fDx1 ;
}
G4double GetXHalfLength2() const
{
return fDx2 ;
}
G4double GetTanAlpha1() const
{
return fTalpha1 ;
}
G4double GetYHalfLength2() const
{
return fDy2 ;
}
G4double GetXHalfLength3() const
{
return fDx3 ;
}
G4double GetXHalfLength4() const
{
return fDx4 ;
}
G4double GetTanAlpha2() const
{
return fTalpha2 ;
}
TrapSidePlane GetSidePlane(G4int n ) const
{
return fPlanes[n] ;
}
// Set Methods
void SetAllParameters ( G4double pDz,
G4double pTheta,
G4double pPhi,
G4double pDy1,
G4double pDx1,
G4double pDx2,
G4double pAlp1,
G4double pDy2,
G4double pDx3,
G4double pDx4,
G4double pAlp2);
// Methods
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep);
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const;
EInside Inside(const G4ThreeVector& p) const;
G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
G4double DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) const;
G4double DistanceToIn(const G4ThreeVector& p) const;
G4double DistanceToOut(const G4ThreeVector& p,const G4ThreeVector& v,
const G4bool calcNorm=false,
G4bool *validNorm=0,G4ThreeVector *n=0) const;
G4double DistanceToOut(const G4ThreeVector& p) const;
// Naming method (pseudo-RTTI : run-time type identification
virtual G4GeometryType GetEntityType() const { return G4String("G4Trap"); }
// Visualisation functions
void DescribeYourselfTo (G4VGraphicsScene& scene) const;
G4VisExtent GetExtent () const;
G4Polyhedron* CreatePolyhedron () const;
G4NURBS* CreateNURBS () const;
protected:
G4bool MakePlanes();
G4bool MakePlane( const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3,
const G4ThreeVector& p4,
TrapSidePlane& plane ) ;
G4ThreeVectorList*
CreateRotatedVertices(const G4AffineTransform& pTransform) const;
private:
G4double fDz,fTthetaCphi,fTthetaSphi;
G4double fDy1,fDx1,fDx2,fTalpha1;
G4double fDy2,fDx3,fDx4,fTalpha2;
TrapSidePlane fPlanes[4];
};
#endif
// **************************** End of G4Trap.hh *****************************************
+193
View File
@@ -0,0 +1,193 @@
// This code implementation is the intellectual property of
// the RD44 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: G4Trd.hh,v 2.1 1998/07/12 02:56:51 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4Trd
//
// A Trd is a trapezoid with the x and y dimensions varying along z
// functions:
//
// As inherited from G4CSGSolid +
//
// G4Trd( const G4String& pName,
// G4double pdx1, G4double pdx2,
// G4double pdy1, G4double pdy2,
// G4double pdz )
// Construct a trapezoid with name, and half lengths dpx1,dpx2,dpy1,
// dpy2,dpz
//
// G4double GetXHalfLength1() const
// G4double GetXHalfLength2() const
// G4double GetYHalfLength1() const
// G4double GetYHalfLength2() const
// G4double GetZHalfLength() const
//
// Return the respective parameter
//
// void SetXHalfLength1(G4double)
// void SetXHalfLength2(G4double)
// void SetYHalfLength1(G4double)
// void SetYHalfLength2(G4double)
// void SetZHalfLength(G4double)
//
// Set the respective parameter
//
// Protected:
//
// G4ThreeVectorList*
// CreateRotatedVertices(const G4AffineTransform& pTransform) const
//
// Create the List of transformed vertices in the format required
// for G4CSGSolid:: ClipCrossSection and ClipBetweenSections.
//
// Member Data:
// fDx1 Half-length along x at the surface positioned at -dz
// fDx2 Half-length along x at the surface positioned at +dz
// fDy1 Half-length along y at the surface positioned at -dz
// fDy2 Half-length along y at the surface positioned at +dz
// fDz Half-length along z axis
//
// History:
// 21.04.97 J. Apostolakis Added Set Methods.
// 19.08.96 P. Kent, V. Grichine ->Fs in accordance with G4Box
// 17.02.95 P.Kent Exiting normal return
// 12.01.95 P.Kent Old prototype code converted to thick geometry
#ifndef G4TRD_HH
#define G4TRD_HH
#include "G4CSGSolid.hh"
class G4Trd : public G4CSGSolid {
public:
G4Trd( const G4String& pName,
G4double pdx1, G4double pdx2,
G4double pdy1, G4double pdy2,
G4double pdz);
virtual ~G4Trd();
// Access functions
G4double GetXHalfLength1() const
{
return fDx1;
}
G4double GetXHalfLength2() const
{
return fDx2;
}
G4double GetYHalfLength1() const
{
return fDy1;
}
G4double GetYHalfLength2() const
{
return fDy2;
}
G4double GetZHalfLength() const
{
return fDz;
}
void SetXHalfLength1(G4double val)
{
fDx1= val;
}
void SetXHalfLength2(G4double val)
{
fDx2= val;
}
void SetYHalfLength1(G4double val)
{
fDy1= val;
}
void SetYHalfLength2(G4double val)
{
fDy2= val;
}
void SetZHalfLength(G4double val)
{
fDz= val;
}
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep);
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const;
EInside Inside(const G4ThreeVector& p) const;
G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
G4double DistanceToIn(const G4ThreeVector& p,
const G4ThreeVector& v) const;
G4double DistanceToIn(const G4ThreeVector& p) const;
G4double DistanceToOut(const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm=false,
G4bool *validNorm=0,
G4ThreeVector *n=0) const;
G4double DistanceToOut(const G4ThreeVector& p) const;
// Naming method (pseudo-RTTI : run-time type identification
virtual G4GeometryType GetEntityType() const { return G4String("G4Trd"); }
// Visualisation functions
void DescribeYourselfTo (G4VGraphicsScene& scene) const;
G4VisExtent GetExtent () const;
G4Polyhedron* CreatePolyhedron () const;
G4NURBS* CreateNURBS () const;
void CheckAndSetAllParameters (G4double pdx1, G4double pdx2,
G4double pdy1, G4double pdy2,
G4double pdz);
void SetAllParameters (G4double pdx1, G4double pdx2,
G4double pdy1, G4double pdy2,
G4double pdz);
protected:
G4ThreeVectorList*
CreateRotatedVertices(const G4AffineTransform& pTransform) const;
G4double fDx1,fDx2,fDy1,fDy2,fDz;
// Codes for faces (kPX=plus x face,kMY= minus y face etc)
enum ESide {kPX,kMX,kPY,kMY,kPZ,kMZ};
};
#endif
@@ -0,0 +1,144 @@
// This code implementation is the intellectual property of
// the RD44 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: G4Tubs.hh,v 2.1 1998/07/12 02:56:52 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4Tubs
//
// A tube or tube segment with curved sides parallel to
// the z-axis. The tube has a specified half-length along
// the z axis, about which it is centred, and a given
// minimum and maximum radius. A minimum radius of 0
// signifies a filled tube /cylinder. The tube segment is
// specified by starting and delta
// angles for phi, with 0 being the +x axis, PI/2
// the +y axis. A delta angle of 2PI signifies a
// complete, unsegmented tube/cylinder.
//
// Member functions:
//
// As inherited from G4VSolid+
//
// G4Tubs(const G4String &pName
// G4double pRMin
// G4double pRMax
// G4double pDz
// G4double pSPhi
// G4double pDPhi )
//
// Construct a tubs with the given name and dimensions.
// The angles are provided is radians.
//
//
// Protected:
//
// G4ThreeVectorList*
// CreateRotatedVertices(const G4AffineTransform& pTransform) const
//
// Create the List of transformed vertices in the format required
// for G4VSolid:: ClipCrossSection and ClipBetweenSections.
//
// Member Data:
//
// fRMin Inner radius
// fRMax Outer radius
// fDz half length in z
//
// fSPhi The starting phi angle in radians,
// adjusted such the fSPhi+fDPhi<=2PI,
// fSPhi>-2PI
//
// fDPhi Delta angle of the segment in radians
//
//
// History:
// 10.8.95 P.Kent General cleanup, use G4VSolid extent helper functions
// to CaluclateExtent
// 23.1.94 P.Kent Converted to `tolerant' geometry
// 19.07.96 J.Allison G4GraphicsScene - see G4Box.
// 22.07.96 J.Allison Changed SendPolyhedronTo to CreatePolyhedron.
#ifndef G4TUBS_HH
#define G4TUBS_HH
#include "G4CSGSolid.hh"
class G4Tubs : public G4CSGSolid {
public:
G4Tubs(const G4String &pName,
G4double pRMin,
G4double pRMax,
G4double pDz,
G4double pSPhi,
G4double pDPhi);
virtual ~G4Tubs();
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep);
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const;
G4double GetInnerRadius () const { return fRMin; }
G4double GetOuterRadius () const { return fRMax; }
G4double GetZHalfLength () const { return fDz ; }
G4double GetStartPhiAngle () const { return fSPhi; }
G4double GetDeltaPhiAngle () const { return fDPhi; }
void SetInnerRadius (G4double newRMin) { fRMin= newRMin; }
void SetOuterRadius (G4double newRMax) { fRMax= newRMax; }
void SetZHalfLength (G4double newDz) { fDz= newDz ; }
void SetStartPhiAngle (G4double newSPhi) { fSPhi= newSPhi; }
void SetDeltaPhiAngle (G4double newDPhi) { fDPhi= newDPhi; }
EInside Inside(const G4ThreeVector& p) const;
G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
G4double DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) const;
G4double DistanceToIn(const G4ThreeVector& p) const;
G4double DistanceToOut(const G4ThreeVector& p,const G4ThreeVector& v,
const G4bool calcNorm=G4bool(false),
G4bool *validNorm=0,G4ThreeVector *n=0) const;
G4double DistanceToOut(const G4ThreeVector& p) const;
// Naming method (pseudo-RTTI : run-time type identification)
virtual G4GeometryType GetEntityType() const { return G4String("G4Tubs"); }
// Visualisation functions
void DescribeYourselfTo (G4VGraphicsScene& scene) const;
G4VisExtent GetExtent () const;
G4Polyhedron* CreatePolyhedron () const;
G4NURBS* CreateNURBS () const;
// Older names for access functions
G4double GetRMin() const { return GetInnerRadius(); } // fRMin
G4double GetRMax() const { return GetOuterRadius(); } // fRMax
G4double GetDz () const { return GetZHalfLength() ; } // fDz
G4double GetSPhi() const { return GetStartPhiAngle(); } // fSPhi
G4double GetDPhi() const { return GetDeltaPhiAngle(); } // fDPhi
protected:
G4ThreeVectorList*
CreateRotatedVertices(const G4AffineTransform& pTransform) const;
G4double fRMin,fRMax,fDz,fSPhi,fDPhi;
// Used by distanceToOut
enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPZ,kMZ};
// used by normal
enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNZ};
};
#endif
@@ -0,0 +1,239 @@
//
// G4VCSGface.hh
//
#ifndef G4VCSGface_hh
#define G4VCSGface_hh
//
// Definition of the virtual base class G4VCSGface, one side (or face)
// of a CSG solid. It should be possible to build a CSG entirely out of connecting
// CSG faces.
//
// Each face has an inside and outside surface, the former represents the inside
// of the volume, the latter, the outside.
//
// Virtual members:
//
// -------------------------------------------------------------------
// Intersect( const G4ThreeVector &p, const G4ThreeVector &v, const G4bool outGoing, const G4double surfTolerance,
// const G4bool outgoing, const G4double surfTolerance,
// G4double &distance, G4double &distFromSurface,
// G4ThreeVector &normal, G4bool &allBehind );
//
// p - (in) position
// v - (in) direction (assumed to be a unit vector)
// outgoing - (in) true, to consider only inside surfaces
// false, to consider only outside surfaces
// distance - (out) distance to intersection
// distFromSurface - (out) distance from surface (along surface normal),
// < 0 if the point is in front of the surface
// normal - (out) normal of surface at intersection point
// allBehind - (out) true, if entire surface is behind normal
//
// return value = true if there is an intersection,
// false if there is no intersection (all output arguments undefined)
//
// Determine the distance along a line to the face.
//
// -------------------------------------------------------------------
// Distance( const G4ThreeVector &p, const G4bool outgoing );
//
// p - (in) position
// outgoing - (in) true, to consider only inside surfaces
// false, to consider only outside surfaces
//
// return value = distance to closest surface satisifying requirements,
// or kInfinity if no such surface exists
//
// Determine the distance of a point from either the inside or outside
// surfaces of the face.
//
// -------------------------------------------------------------------
// Inside( const G4ThreeVector &p, const G4double tolerance,
// G4double *bestDistance );
//
// p - (in) position
// tolerance - (in) tolerance defining the bounds of the "kSurface",
// nominally equal to kCarTolerance/2
// bestDistance - (out) distance to closest surface (in or out)
//
// return value = kInside if the point is closest to the inside surface
// kOutside if the point is closest to the outside surface
// kSurface if the point is withing tolerance of the surface
//
// Determine whether a point is inside, outside, or on the surface of
// the face.
//
// -------------------------------------------------------------------
// Normal( const G4ThreeVector &p, G4double *bestDistance );
//
// p - (in) position
// bestDistance - (out) distance to closest surface (in or out)
//
// return value = the normal of the surface nearest the point
//
// Return normal of surface closest to the point.
//
// -------------------------------------------------------------------
// Extent( const G4ThreeVector axis );
//
// axis - (in) unit vector defining direction
//
// return value = the largest point along the given axis of the
// the face's extent.
//
// -------------------------------------------------------------------
// CalculateExtent( const EAxis pAxis,
// const G4VoxelLimit &pVoxelLimit,
// const G4AffineTransform &pTransform,
// G4double &min, G4double &max )
//
// pAxis - (in) The x,y, or z axis in which to check
// the shapes 3D extent against
// pVoxelLimit - (in) Limits along x, y, and/or z axes
// pTransform - (in) A coordinate transformation on which
// to apply to the shape before testing
// min - (in/out) If the face has any point on its
// surface after tranformation and limits
// along pAxis
// that is smaller than the value of min,
// than it is used to replace min.
// max - (in/out) Same as min, except for the largest
// point.
//
// Calculate the extent of the face for the voxel navigator.
// In analogy with CalculateExtent for G4VCSGfaceted, this is
// done in the following steps:
//
// 1. Transform the face using pTranform, an arbitrary 3D
// rotation/offset/reflection
// 2. Clip the face to those boundaries as specified in
// pVoxelLimit. This may include limits in any number
// of x, y, or z axes.
// 3. If nothing remains of the face after clipping, return.
// 4. Check the extent of the remaining surface along
// axis pAxis and check these values against min and max,
// modifying them as necessary.
//
//
// Implementation notes:
// * distance.
// The meaning of distance includes the boundaries of the face. For example.
// for a rectangular, planer face:
//
// A | B | C
// | |
// -------+--------------+-----
// D | I | E
// | |
// -------+--------------+-----
// F | G | H
// | |
//
// A, C, F, and H: closest distance is the distance to
// the adjacent corner.
//
// B, D, E, and F: closest distance is the distance to
// the adjacent line.
//
// I: normal distance to plane
//
// For non-planer faces, one can use the normal to decide when
// a point falls off the edge and then act accordingly.
//
//
// Usage:
//
// A CSG shape can be defined by putting together any number of generic faces,
// as long as the faces cover the entire surface of the shape without overlapping.
//
// G4VSolid::CalculateExtent
//
// Define unit vectors along the specified transform axis. Use the inverse of the
// specified coordinate transformation to rotate these unit vectors. Loop over
// each face, call face->Extent, and save the maximum value.
//
// G4VSolid::Inside
//
// To decide if a point is inside, outside, or on the surface of the shape,
// loop through all faces, and find the answer from face->Inside which gives
// a value of "bestDistance" smaller than any other. While looping, if any
// face->Inside returns kSurface, this value can be returned immediately.
//
// EInside answer;
// G4VCSGface *face = faces;
// G4double best = kInfinity;
// do {
// G4double distance;
// EInside result = (*face)->Inside( p, kCarTolerance/2, distance );
// if (result == kSurface) return kSurface;
// if (distance < best) {
// best = distance;
// answer = result;
// }
// } while( ++face < faces + numFaces );
//
// return(answer);
//
// G4VSolid::SurfaceNormal
//
// Loop over all faces, call face->Normal, and return the normal to the face
// that is closest to the point.
//
// G4VSolid::DistanceToIn(p)
//
// Loop over all faces, invoking face->Distance with outgoing = false,
// and save the answer that is smallest.
//
// G4VSolid::DistanceToIn(p,v)
//
// Loop over all faces, invoking face->Intersect with outgoing = false,
// and save the answer that is smallest.
//
// G4VSolid::DistanceToOut(p)
//
// Loop over all faces, invoking face->Distance with outgoing = true,
// and save the answer that is smallest.
//
// G4VSolid::DistanceToOut(p,v)
//
// Loop over all faces, invoking face->Intersect with outgoing = true,
// and save the answer that is smallest. If there is more than one answer,
// or if allBehind is false for the one answer, return validNorm as false.
//
#include "G4VSolid.hh"
#include "globals.hh"
#include "G4ThreeVector.hh"
#include "geomdefs.hh"
class G4VoxelLimits;
class G4AffineTransform;
class G4VCSGface {
public:
G4VCSGface() {;}
virtual ~G4VCSGface() {;}
virtual G4bool Intersect( const G4ThreeVector &p, const G4ThreeVector &v,
const G4bool outgoing, const G4double surfTolerance,
G4double &distance, G4double &distFromSurface,
G4ThreeVector &normal, G4bool &allBehind ) = 0;
virtual G4double Distance( const G4ThreeVector &p, const G4bool outgoing ) = 0;
virtual EInside Inside( const G4ThreeVector &p, const G4double tolerance,
G4double *bestDistance ) = 0;
virtual G4ThreeVector Normal( const G4ThreeVector &p, G4double *bestDistance ) = 0;
virtual G4double Extent( const G4ThreeVector axis ) = 0;
virtual void CalculateExtent( const EAxis axis,
const G4VoxelLimits &voxelLimit,
const G4AffineTransform &tranform,
G4double &min, G4double &max ) = 0;
};
#endif
@@ -0,0 +1,52 @@
//
// G4VCSGfaceted.hh
//
// Declaration of a virtual class CSG type shape that is built entire of G4CSGface faces.
//
#ifndef G4VCSGfaceted_hh
#define G4VCSGfaceted_hh
#include "G4CSGSolid.hh"
class G4VCSGface;
class G4VCSGfaceted : public G4CSGSolid
{
public:
G4VCSGfaceted( G4String name) : G4CSGSolid(name) {;}
virtual ~G4VCSGfaceted();
virtual G4bool CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const;
virtual EInside Inside( const G4ThreeVector& p) const;
virtual G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
virtual G4double DistanceToIn( const G4ThreeVector& p,const G4ThreeVector& v ) const;
virtual G4double DistanceToIn( const G4ThreeVector& p ) const;
virtual G4double DistanceToOut( const G4ThreeVector& p,const G4ThreeVector& v,
const G4bool calcNorm=false,
G4bool *validNorm=0,G4ThreeVector *n=0 ) const;
virtual G4double DistanceToOut( const G4ThreeVector& p ) const;
virtual G4GeometryType GetEntityType() const { return G4String("G4CSGfaceted"); }
virtual G4Polyhedron* CreatePolyhedron() const = 0;
virtual void DescribeYourselfTo( G4VGraphicsScene& scene ) const;
virtual G4VisExtent GetExtent() const;
protected:
G4int numFace;
G4VCSGface **faces;
virtual G4double DistanceTo( const G4ThreeVector &p, const G4bool outgoing ) const;
};
#endif