Import Geant4 2.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 15:42:07 +02:00
parent 103bda00c8
commit e7d7193284
3106 changed files with 171117 additions and 90550 deletions
@@ -0,0 +1,81 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4ClippablePolygon.hh,v 1.2 2000/04/18 19:06:38 davidw Exp $
// GEANT4 tag $Name: geant4-02-00 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// G4ClippablePolygon
//
// Class description:
//
// Declaration of a utility class of a polygon that can be
// clipped by a voxel.
// --------------------------------------------------------------------
#ifndef G4ClippablePolygon_hh
#define G4ClippablePolygon_hh
#include "globals.hh"
#include "geomdefs.hh"
#include "G4ThreeVector.hh"
class G4VoxelLimits;
class G4AffineTransform;
class G4AffineTransform;
class G4VoxelLimits;
#include "g4rw/tvordvec.h"
typedef G4RWTValOrderedVector<G4ThreeVector> G4ThreeVectorList;
class G4ClippablePolygon {
public:
G4ClippablePolygon() {;}
virtual ~G4ClippablePolygon() {;}
virtual void AddVertexInOrder( const G4ThreeVector vertex );
virtual void ClearAllVertices();
virtual void SetNormal( const G4ThreeVector &newNormal ) { normal = newNormal; }
virtual const G4ThreeVector GetNormal() const { return normal; }
virtual G4bool Clip( const G4VoxelLimits &voxelLimit );
virtual G4bool PartialClip( const G4VoxelLimits &voxelLimit, const EAxis IgnoreMe );
virtual void ClipAlongOneAxis( const G4VoxelLimits &voxelLimit, const EAxis axis );
virtual G4bool GetExtent( const EAxis axis,
G4double &min, G4double &max ) const;
virtual const G4ThreeVector *GetMinPoint( const EAxis axis ) const;
virtual const G4ThreeVector *GetMaxPoint( const EAxis axis ) const;
virtual G4int GetNumVertices() const { return vertices.entries(); }
virtual G4bool Empty() const { return vertices.entries()==0; }
virtual G4bool InFrontOf( const G4ClippablePolygon &other, EAxis axis ) const;
virtual G4bool BehindOf( const G4ClippablePolygon &other, EAxis axis ) const;
virtual G4bool GetPlanerExtent( const G4ThreeVector &pointOnPlane,
const G4ThreeVector &planeNormal,
G4double &min, G4double &max ) const;
protected:
G4ThreeVectorList vertices;
G4ThreeVector normal;
void ClipToSimpleLimits( G4ThreeVectorList& pPolygon,
G4ThreeVectorList& outputPolygon,
const G4VoxelLimits& pVoxelLimit );
};
#endif
@@ -0,0 +1,94 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4EllipticalTube.hh,v 1.6 2000/04/19 19:08:58 davidw Exp $
// GEANT4 tag $Name: geant4-02-00 $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// G4EllipticalTube
//
// Class description:
//
// Declaration of a CSG volume representing a tube with elliptical
// cross section (geant3 solid 'ELTU')
//
// The equation of the surface in x/y is 1.0 = (x/dx)**2 + (y/dy)**2
// --------------------------------------------------------------------
#ifndef G4EllipticalTube_hh
#define G4EllipticalTube_hh
#include "G4VSolid.hh"
class G4EllipticalTube : public G4VSolid {
public:
G4EllipticalTube( const G4String &name,
const G4double theDx, const G4double theDy, const G4double theDz );
virtual ~G4EllipticalTube();
//
// Standard CSG inherited methods
//
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("G4EllipticalTube"); }
virtual G4Polyhedron* CreatePolyhedron() const;
virtual void DescribeYourselfTo( G4VGraphicsScene& scene ) const;
virtual G4VisExtent GetExtent() const;
//
// Parameter access
//
G4double GetDx() const { return dx; }
G4double GetDy() const { return dy; }
G4double GetDz() const { return dz; }
void SetDx( const G4double newDx ) { dx = newDx; }
void SetDy( const G4double newDy ) { dy = newDy; }
void SetDz( const G4double newDz ) { dz = newDz; }
protected:
G4double dx, dy, dz;
//
// Utility
//
inline G4double CheckXY( const G4double x, const G4double y, const G4double toler ) const {
G4double rx = x/(dx+toler), ry = y/(dy+toler);
return rx*rx + ry*ry;
}
inline G4double CheckXY( const G4double x, const G4double y ) const {
G4double rx = x/dx, ry = y/dy;
return rx*rx + ry*ry;
}
G4int IntersectXY( const G4ThreeVector &p,
const G4ThreeVector &v, G4double s[2] ) const;
};
#endif
@@ -0,0 +1,61 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4EnclosingCylinder.hh,v 1.1 2000/04/07 10:55:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-02-00 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// G4EnclosingCylinder
//
// Class description:
//
// Definition of a utility class for quickly deciding if a point
// is clearly outside a polyhedra or polycone or deciding if
// a trajectory is clearly going to miss those shapes.
// --------------------------------------------------------------------
#ifndef G4EnclosingCylinder_hh
#define G4EnclosingCylinder_hh
#include "globals.hh"
#include "geomdefs.hh"
#include "G4ThreeVector.hh"
class G4ReduciblePolygon;
class G4EnclosingCylinder {
public:
G4EnclosingCylinder( const G4ReduciblePolygon *rz,
const G4bool phiIsOpen,
const G4double startPhi, const G4double totalPhi );
~G4EnclosingCylinder();
G4bool MustBeOutside( const G4ThreeVector &p ) const;
G4bool ShouldMiss( 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;
G4bool concave; // True, if x/y cross section is concave
};
#endif
@@ -0,0 +1,209 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4Hype.hh,v 1.3 2000/04/19 17:56:27 davidw Exp $
// $Original: G4Hype.hh,v 1.0 1998/06/09 16:57:50 safai Exp $
// GEANT4 tag $Name: geant4-02-00 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4Hype
//
// Class description:
//
// This class implements in G4 the volume equivalent to the
// HYPE volume in Geant 3.21, i.e. a tube with hyperbolic profile.
//
// 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.
// 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.
//
// History:
// Updated Feb 2000 D.C. Williams
//
// --------------------------------------------------------------------
#ifndef G4HYPE_HH
#define G4HYPE_HH
#include "G4VSolid.hh"
#include "G4ThreeVector.hh"
class G4SolidExtentList;
class G4ClippablePolygon;
class G4Hype : public G4VSolid {
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= fabs(newISte);
tanInnerStereo=tan(innerStereo);
tanInnerStereo2=tanInnerStereo*tanInnerStereo;
endInnerRadius2=HypeInnerRadius2(halfLenZ);
endInnerRadius=sqrt(endInnerRadius2);
}
void SetOuterStereo (G4double newOSte)
{
outerStereo= fabs(newOSte);
tanOuterStereo=tan(outerStereo);
tanOuterStereo2=tanOuterStereo*tanOuterStereo;
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:
// whether we have an inner surface or not
G4bool InnerSurfaceExists() const { return (innerRadius > DBL_MIN) || (innerStereo != 0); }
// approximate isotropic distance to hyperbolic surface
static G4double ApproxDistOutside( const G4double pr, const G4double pz,
const G4double r0, const G4double tanPhi );
static G4double ApproxDistInside( const G4double pr, const G4double pz,
const G4double r0, const G4double tan2Phi );
// values of hype radius at a given Z
G4double HypeInnerRadius2(const G4double zVal) const { return (tanInnerStereo2*zVal*zVal+innerRadius2); }
G4double HypeOuterRadius2(const G4double zVal) const { return (tanOuterStereo2*zVal*zVal+outerRadius2); }
// intersection with hyperbolic surface
static G4int IntersectHype( const G4ThreeVector &p, const G4ThreeVector &v,
const G4double r2, const G4double tan2Phi, G4double s[2] );
static void AddPolyToExtent( const G4ThreeVector &v0,
const G4ThreeVector &v1,
const G4ThreeVector &w1,
const G4ThreeVector &w0,
const G4VoxelLimits &voxelLimit,
const EAxis axis,
G4SolidExtentList &extentList );
G4double innerRadius; // variable names are quite self explanative
G4double outerRadius;
G4double halfLenZ;
G4double innerStereo;
G4double outerStereo;
// precalculated parameters, squared quantities
G4double tanInnerStereo;
G4double tanOuterStereo;
G4double tanInnerStereo2; // squared tan of Inner Stereo angle
G4double tanOuterStereo2; // squared tan of Outer Stereo angle
G4double innerRadius2; // squared Inner Radius
G4double outerRadius2; // squared Outer Radius
G4double endInnerRadius2; // squared endcap Inner Radius
G4double endOuterRadius2; // squared endcap Outer Radius
G4double endInnerRadius; // endcap Inner Radius
G4double endOuterRadius; // endcap Outer Radius
// Used by distanceToOut
enum ESide {outerFace,innerFace,leftCap, rightCap};
};
#endif
@@ -0,0 +1,63 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4IntersectingCone.hh,v 1.1 2000/04/07 10:56:27 gcosmo Exp $
// GEANT4 tag $Name: geant4-02-00 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4IntersectingCone
//
// Class description:
//
// 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,114 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PolyPhiFace.hh,v 1.1 2000/04/07 10:56:52 gcosmo Exp $
// GEANT4 tag $Name: geant4-02-00 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4PolyPhiFace
//
// Class description:
//
// 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"
class G4ReduciblePolygon;
typedef struct {
G4double x, y, 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 G4ReduciblePolygon *rz,
const G4double phi, const G4double deltaPhi, const G4double phiOther );
virtual ~G4PolyPhiFace();
G4PolyPhiFace( const G4PolyPhiFace &source );
G4PolyPhiFace *operator=( const G4PolyPhiFace &source );
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,
G4SolidExtentList &extentList );
G4VCSGface *Clone() { return new G4PolyPhiFace(*this); }
void Diagnose( G4VSolid *solid );
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 allBehind; // True if the entire polycone/polyhedra is behind the place
// of this face
G4bool InsideEdgesExact( const G4double r, const G4double z,
const G4double normSign, const G4ThreeVector &p, const G4ThreeVector &v );
G4bool InsideEdges( const G4double r, const G4double z );
G4bool InsideEdges( const G4double r, const G4double z,
G4double *distRZ2, G4PolyPhiFaceVertex **base3Dnorm=0,
G4ThreeVector **head3Dnorm=0 );
inline G4double ExactZOrder( const G4double z,
const G4double qx, const G4double qy, const G4double qz,
const G4ThreeVector &v,
const G4double normSign,
const G4PolyPhiFaceVertex *vert ) const;
void CopyStuff( const G4PolyPhiFace &source );
};
#include "G4PolyPhiFace.icc"
#endif
@@ -0,0 +1,48 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PolyPhiFace.icc,v 1.1 2000/04/07 10:57:03 gcosmo Exp $
// GEANT4 tag $Name: geant4-02-00 $
//
//
// --------------------------------------------------------------------
// GEANT 4 inline definitions file
//
// G4PolyPhiFace.icc
//
// Implementation of inline methods of G4PolyPhiFace
// --------------------------------------------------------------------
// ExactZOrder
//
// Decide precisely whether a trajectory passes to the left, right, or exactly
// passes through the z position of a vertex point in our face.
//
// Result is only determined within an arbitrary (positive) factor.
// > 0 to the right
// < 0 to the left
// = 0 exactly on top of
// In 99.9999% of the cases, a trivial calculation is used. In difficult
// cases, a precise, compliant calculation is relied on.
//
inline G4double G4PolyPhiFace::ExactZOrder( const G4double z,
const G4double qx, const G4double qy, const G4double qz,
const G4ThreeVector &v,
const G4double normSign,
const G4PolyPhiFaceVertex *vert ) const {
G4double answer = vert->z - z;
if (fabs(answer) < kCarTolerance) {
G4ThreeVector qa( qx - vert->x + radial.x(),
qy - vert->y + radial.y(), qz - vert->z ),
qb( qx - vert->x, qy - vert->y, qz - vert->z );
G4ThreeVector qacb = qa.cross(qb);
answer = normSign*qacb.dot(v)*(normal.y()*radial.x()-normal.x()*radial.y());
}
return answer;
}
@@ -0,0 +1,131 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4Polycone.hh,v 1.3 2000/06/27 16:20:11 gcosmo Exp $
// GEANT4 tag $Name: geant4-02-00 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4Polycone
//
// Class description:
//
// Class implementing a CSG type "PCON" Geant 3.21 volume,
// inherited from class G4VCSGSolid.
// --------------------------------------------------------------------
#ifndef G4Polycone_hh
#define G4Polycone_hh
#include "G4VCSGfaceted.hh"
#include "G4PolyconeSide.hh"
class G4EnclosingCylinder;
class G4ReduciblePolygon;
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();
G4Polycone( const G4Polycone &source );
const G4Polycone &operator=( const G4Polycone &source );
//
// 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); }
//
// The usual G4VCSGface stuff
//
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep);
virtual G4GeometryType GetEntityType() const { return G4String("G4Polycone"); }
G4Polyhedron* CreatePolyhedron() const;
G4NURBS* CreateNURBS() const;
//
// Access routines
//
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
//
class G4PolyconeHistorical
{
public:
G4PolyconeHistorical() {;}
~G4PolyconeHistorical();
G4PolyconeHistorical( const G4PolyconeHistorical &source );
G4double Start_angle;
G4double Opening_angle;
G4int Num_z_planes;
G4double *Z_values;
G4double *Rmin;
G4double *Rmax;
};
G4PolyconeHistorical *original_parameters;
//
// Our quick test
//
G4EnclosingCylinder *enclosingCylinder;
//
// Generic initializer, called by all constructors
//
void Create( const G4double phiStart, // initial phi starting angle
const G4double phiTotal, // total phi angle
G4ReduciblePolygon *rz ); // r/z coordinate of these corners
void CopyStuff( const G4Polycone &source );
};
#endif
@@ -0,0 +1,108 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PolyconeSide.hh,v 1.1 2000/04/07 10:57:41 gcosmo Exp $
// GEANT4 tag $Name: geant4-02-00 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4PolyconeSide
//
// Class description:
//
// Class implmenting 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, const G4bool isAllBehind=false );
virtual ~G4PolyconeSide();
G4PolyconeSide( const G4PolyconeSide &source );
G4PolyconeSide *operator=( const G4PolyconeSide &source );
G4bool Intersect( const G4ThreeVector &p, const G4ThreeVector &v,
const G4bool outgoing, const G4double surfTolerance,
G4double &distance, G4double &distFromSurface,
G4ThreeVector &normal, G4bool &isAllBehind );
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,
G4SolidExtentList &extentList );
G4VCSGface *Clone() { return new G4PolyconeSide( *this ); }
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
G4bool allBehind; // True if the entire solid is "behind" this face
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 prevRS,
prevZS; // Unit vector along previous polyconeSide
G4double nextRS,
nextZS; // Unit vector along next polyconeSide
G4double rNormEdge[2],
zNormEdge[2]; // Normal to edges
G4ThreeVector *corners; // The coordinates of the corners (if phiIsOpen)
G4double DistanceAway( const G4ThreeVector &p, const G4bool opposite,
G4double &distOutside2, G4double *rzNorm=0 );
G4bool PointOnCone( const G4ThreeVector &hit, const G4double normSign,
const G4ThreeVector &p, const G4ThreeVector &v, G4ThreeVector &normal );
void CopyStuff( const G4PolyconeSide &source );
static void FindLineIntersect( const G4double x1, const G4double y1,
const G4double tx1, const G4double ty1,
const G4double x2, const G4double y2,
const G4double tx2, const G4double ty2,
G4double &x, G4double &y );
};
#endif
@@ -0,0 +1,128 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4Polyhedra.hh,v 1.2 2000/06/26 09:54:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-02-00 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4Polyhedra.hh
//
// Class description:
//
// Class implementing a CSG type "PGON" Geant 3.21 volume,
// inherited from class G4CSGSolid.
// --------------------------------------------------------------------
#ifndef G4Polyhedra_hh
#define G4Polyhedra_hh
#include "G4VCSGfaceted.hh"
#include "G4PolyhedraSide.hh"
class G4EnclosingCylinder;
class G4ReduciblePolygon;
class G4Polyhedra : public G4VCSGfaceted {
public:
G4Polyhedra( G4String name,
const G4double phiStart, // initial phi starting angle
const G4double phiTotal, // total phi angle
const G4int 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 G4int 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();
G4Polyhedra( const G4Polyhedra &source );
const G4Polyhedra &operator=( const G4Polyhedra &source );
//
// 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; // our corners
//
// The following is temporary until graphics_reps is brought up to this design
//
struct G4PolyhedraHistorical {
G4PolyhedraHistorical() {;}
~G4PolyhedraHistorical();
G4PolyhedraHistorical( const G4PolyhedraHistorical &source );
G4double Start_angle;
G4double Opening_angle;
G4int numSide;
G4int Num_z_planes;
G4double *Z_values;
G4double *Rmin;
G4double *Rmax;
};
G4PolyhedraHistorical *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 G4int numSide, // number sides
G4ReduciblePolygon *rz ); // rz coordinates
void CopyStuff( const G4Polyhedra &source );
void DeleteStuff();
};
#endif
@@ -0,0 +1,135 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PolyhedraSide.hh,v 1.1 2000/04/07 10:58:14 gcosmo Exp $
// GEANT4 tag $Name: geant4-02-00 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4PolyhedraSide
//
// Class description:
//
// Class implementing 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, const G4bool isAllBehind=false );
virtual ~G4PolyhedraSide();
G4PolyhedraSide( const G4PolyhedraSide &source );
G4PolyhedraSide *operator=( const G4PolyhedraSide &source );
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,
G4SolidExtentList &extentList );
G4VCSGface *Clone() { return new G4PolyhedraSide( *this ); }
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
endPhi; // End phi (>startPhi), if phiIsOpen
G4bool phiIsOpen; // True if there is a phi slice
G4bool allBehind; // True if the entire solid is "behind" this face
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 );
void CopyStuff( const G4PolyhedraSide &source );
};
#endif
@@ -0,0 +1,143 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4ReduciblePolygon.hh,v 1.1 2000/04/07 10:58:32 gcosmo Exp $
// GEANT4 tag $Name: geant4-02-00 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4ReduciblePolygon.hh
//
// Class description:
//
// Utility class used to specify, test, reduce, and/or otherwise
// manipulate a 2D polygon.
//
// For this class, a polygon consists of n > 2 points in 2D
// space (a,b). The polygon is always closed by connecting the
// last point to the first. A G4ReduciblePolygon is guaranteed
// to fulfill this definition in all instances.
//
// Illegal manipulations (such that a valid polygon would be
// produced) result in an error return if possible and
// otherwise a G4Exception.
//
// The set of manipulations is limited currently to what
// is needed for G4Polycone and G4Polyhedra.
// --------------------------------------------------------------------
#ifndef G4ReduciblePolygon_hh
#define G4ReduciblePolygon_hh
#include "globals.hh"
class G4ReduciblePolygon {
friend class G4ReduciblePolygonIterator;
public:
//
// Creator: via simple a/b arrays
//
G4ReduciblePolygon( const G4double a[], const G4double b[], const G4int n );
//
// Creator: a special version for G4Polygon and G4Polycone
// that takes two a points at planes of b
// (where a==r and b==z for the GEANT3 classic PCON and PGON)
//
G4ReduciblePolygon( const G4double rmin[], const G4double rmax[], const G4double z[], const G4int n );
virtual ~G4ReduciblePolygon();
//
// Queries
//
inline G4int NumVertices() const { return numVertices; }
inline G4double Amin() const { return aMin; }
inline G4double Amax() const { return aMax; }
inline G4double Bmin() const { return bMin; }
inline G4double Bmax() const { return bMax; }
void CopyVertices( G4double a[], G4double b[] ) const;
//
// Manipulations
//
void ScaleA( const G4double scale );
void ScaleB( const G4double scale );
G4bool RemoveDuplicateVertices( const G4double tolerance );
G4bool RemoveRedundantVertices( const G4double tolerance );
void ReverseOrder();
//
// Tests
//
G4double Area();
G4bool CrossesItself( const G4double tolerance );
G4bool BisectedBy( const G4double a1, const G4double b1,
const G4double a2, const G4double b2, const G4double tolerance );
void Print(); // Debugging only
protected:
void Create( const G4double a[], const G4double b[], const G4int n );
void CalculateMaxMin();
//
// Below are member values that are *always* kept up to date (please!)
//
G4double aMin, aMax, bMin, bMax;
G4int numVertices;
//
// A subclass which holds the vertices in a single-linked list
//
// Yeah, call me an old-fashioned c hacker, but I cannot make
// myself use the rogue tools for this trivial list.
//
struct ABVertex;
friend struct ABVertex;
struct ABVertex {
G4double a, b;
ABVertex *next;
};
ABVertex *vertexHead;
};
//
// A companion class for iterating over the vertices of our polygon.
// It is simple enough that all routines are declared inline here.
//
class G4ReduciblePolygonIterator {
public:
G4ReduciblePolygonIterator( const G4ReduciblePolygon *theSubject ) { subject = theSubject; current=0; }
inline void Begin() { current = subject->vertexHead; }
inline G4bool Next() { if (current) current = current->next; return Valid(); }
inline G4bool Valid() const { return current!=0; }
inline G4double GetA() const { return current->a; }
inline G4double GetB() const { return current->b; }
protected:
const G4ReduciblePolygon *subject; // Who are we iterating over
G4ReduciblePolygon::ABVertex *current; // Current vertex
};
#endif
@@ -0,0 +1,61 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4SolidExtentList.hh,v 1.1 2000/04/07 10:58:50 gcosmo Exp $
// GEANT4 tag $Name: geant4-02-00 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4SolidExtentList
//
// Class description:
//
// Defines a list of (voxel) extents along one axis.
//
// This utility class is designed for one specific purpose:
// to calculate the extent of a CSG solid for a voxel
// (G4VSolid::CalculateExtent).
// --------------------------------------------------------------------
#ifndef G4SolidExtentList_hh
#define G4SolidExtentList_hh
#include "globals.hh"
#include "G4ClippablePolygon.hh"
class G4SolidExtentList {
public:
G4SolidExtentList();
G4SolidExtentList( const EAxis targetAxis, const G4VoxelLimits &voxelLimits );
~G4SolidExtentList();
void AddSurface( const G4ClippablePolygon &surface );
G4bool GetExtent( G4double &min, G4double &max ) const;
protected:
EAxis axis; // Target axis
G4bool limited; // True if limited
G4double minLimit; // ... min limit
G4double maxLimit; // ... max limit
G4ClippablePolygon minSurface, // Minimum surface within limits
maxSurface, // Maximum
minAbove, // Minimum surface totally above max limit
maxBelow; // Maximum surface totally below min limit
};
#endif
@@ -0,0 +1,283 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4VCSGface.hh,v 1.1 2000/04/07 10:59:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-02-00 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4VCSGface
//
// Class description:
//
// 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 - (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.
// Undefined if the return value is false.
// max - (out) Same as min, except for the largest
// point.
// Undefined if the return value is false.
//
// return value = true if anything remains of the face
//
// 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. For each part of the face that remains (there could
// be many separate pieces in general):
// 4. Check to see if the piece overlaps the currently
// existing limits along axis pAxis. For
// pVoxelLimit.IsLimited(pAxis) = false, there are
// no limits.
// 5. For a piece that does overlap, update min/max
// accordingly (within confines of pre-existing
// limits) along the direction pAxis.
// 6. If min/max were updated, return true
//
// -------------------------------------------------------------------
// G3VCSGface *Clone()
//
// This method is invoked by G4CSGfaceted during the copy constructor
// or the assignment operator. Its purpose is to return a pointer
// (of type G4VCSGface) to a duplicate copy of the face.
// The implementation is straight forward for inherited classes. Example:
//
// G4VCSGface G4PolySideFace::Clone() { return new G4PolySideFace(*this); }
//
// Of course, this assumes the copy constructor of G4PolySideFace is
// correctly implemented.
//
// 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 G: 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.
// --------------------------------------------------------------------
#ifndef G4VCSGface_hh
#define G4VCSGface_hh
#include "G4VSolid.hh"
#include "globals.hh"
#include "G4ThreeVector.hh"
#include "geomdefs.hh"
class G4VoxelLimits;
class G4AffineTransform;
class G4SolidExtentList;
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,
G4SolidExtentList &extentList ) = 0;
virtual G4VCSGface* Clone() = 0;
};
#endif
@@ -0,0 +1,76 @@
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4VCSGfaceted.hh,v 1.3 2000/04/19 17:56:29 davidw Exp $
// GEANT4 tag $Name: geant4-02-00 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4VCSGfaceted
//
// Class description:
//
// Virtual class defining CSG type shape that is built entire
// of G4CSGface faces.
// --------------------------------------------------------------------
#ifndef G4VCSGfaceted_hh
#define G4VCSGfaceted_hh
#include "G4VSolid.hh"
class G4VCSGface;
class G4VisExtent;
class G4VCSGfaceted : public G4VSolid
{
public:
G4VCSGfaceted( G4String name) : G4VSolid(name) {;}
virtual ~G4VCSGfaceted();
G4VCSGfaceted( const G4VCSGfaceted &source );
const G4VCSGfaceted &operator=( const G4VCSGfaceted &source );
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;
void CopyStuff( const G4VCSGfaceted &source );
void DeleteStuff();
};
#endif