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
@@ -0,0 +1,65 @@
// Contents ---------------------------------------------------------
//
// G4Assembly
//
// Description:
//
// C++ header file for ...
// Uses the xxxxx classes.
// A G4Assembly is ...
// End --------------------------------------------------------------
// Interface Dependencies -------------------------------------------
#ifndef G4ASSEMBLY_HH
#define G4ASSEMBLY_HH
#include "G4PlacedSolid.hh"
#include "G4OrderedTable.hh"
#include "G4BREPSolid.hh"
typedef RWTPtrOrderedVector<G4PlacedSolid> G4PlacedVector;
// End Interface Dependencies ---------------------------------------
// Class //
class G4Assembly
{
public:
G4Assembly();
~G4Assembly();
void SetPlacedVector(G4PlacedVector&);
G4PlacedSolid* GetPlacedSolid(G4int solidNumber)
{
return placedVec[solidNumber];
}
G4int GetNumberOfSolids()
{
return numberOfSolids;
}
private:
G4int numberOfSolids;
G4PlacedVector placedVec;
};
#endif
@@ -0,0 +1,76 @@
#ifndef __G4Placement3D_h
#define __G4Placement3D_h 1
#include "G4Point3D.hh"
#include "G4Vector3D.hh"
#include "G4Transform3D.hh"
#include "G4PointRat.hh"
#include "G4Ray.hh"
class G4Axis2Placement3D
{
public:
G4Axis2Placement3D();
~G4Axis2Placement3D();
G4Axis2Placement3D(const G4Axis2Placement3D& place);
//inline void Project (G4ThreeVec& Coord, const G4ThreeVec& Pt2,
// const G4Plane& Pl1, const G4Plane& Pl2)
// {
// Coord.X(Pt2.X()*Pl1.a + Pt2.Y()*Pl1.b + Pt2.Z()*Pl1.c - Pl1.d);
// Coord.Y(Pt2.X()*Pl2.a + Pt2.Y()*Pl2.b + Pt2.Z()*Pl2.c - Pl2.d);
// Coord.Z(0);
// }
// Get/Set for geometric data
void Init( const G4Vector3D& refDirection0 ,
const G4Vector3D& axis0 ,
const G4Point3D& location0 );
G4Axis2Placement3D( const G4Vector3D& refDirection0 ,
const G4Vector3D& axis0 ,
const G4Point3D& location0 );
G4Point3D GetLocation() const;
G4Vector3D GetAxis() const;
G4Vector3D GetRefDirection() const;
// placement coordinate axes
G4Vector3D GetPX() const;
G4Vector3D GetPY() const;
G4Vector3D GetPZ() const;
// transformation from/to the placement coordinate system
const G4Transform3D& GetToPlacementCoordinates() const;
const G4Transform3D& GetFromPlacementCoordinates() const;
virtual G4bool operator==(const G4Axis2Placement3D& other) const
{
return (this==&other) ? true : false;
}
private:
// geometric data
G4Point3D location;
G4Vector3D axis;
G4Vector3D refDirection;
// placement coordinate axes
G4Vector3D pX, pY, pZ;
G4Transform3D toPlacementCoordinates;
G4Transform3D fromPlacementCoordinates;
};
#include "G4Axis2Placement3D.icc"
#endif
@@ -0,0 +1,66 @@
inline void G4Axis2Placement3D::Init( const G4Vector3D& refDirection0 ,
const G4Vector3D& axis0 ,
const G4Point3D& location0 )
{
refDirection = refDirection0;
axis = axis0;
location = location0;
// get the axes of the placement coordinate system
// (p[] of the STEP standard)
pZ = axis.unit();
pX = (refDirection-(refDirection*pZ)*pZ).unit();
pY = pZ.cross(pX); // normalized
// basis transformation
fromPlacementCoordinates= HepTranslate3D(location)
* G4Transform3D(HepXHat, HepYHat, HepZHat,
pX, pY, pZ);
toPlacementCoordinates= fromPlacementCoordinates.inverse();
}
inline G4Axis2Placement3D::G4Axis2Placement3D(const G4Vector3D& refDirection0,
const G4Vector3D& axis0 ,
const G4Point3D& location0 )
{
Init( refDirection0, axis0, location0);
}
inline G4Point3D G4Axis2Placement3D::GetLocation() const { return location; }
inline G4Vector3D G4Axis2Placement3D::GetAxis() const { return axis; }
inline G4Vector3D G4Axis2Placement3D::GetRefDirection() const
{
return refDirection;
}
/////////////////////////////////////////////////////////////////////////////
inline const G4Transform3D&
G4Axis2Placement3D::GetToPlacementCoordinates() const
{
return toPlacementCoordinates;
}
inline const G4Transform3D&
G4Axis2Placement3D::GetFromPlacementCoordinates() const
{
return fromPlacementCoordinates;
}
inline G4Vector3D G4Axis2Placement3D::GetPX() const { return pX; }
inline G4Vector3D G4Axis2Placement3D::GetPY() const { return pY; }
inline G4Vector3D G4Axis2Placement3D::GetPZ() const { return pZ; }
@@ -0,0 +1,187 @@
#ifndef __SOLID_H
#define __SOLID_H
#include "G4VSolid.hh"
#include "G4VisExtent.hh"
#include "G4Surface.hh"
#include "G4Axis2Placement3D.hh"
#include "G4PointRat.hh"
#include "G4BoundingBox3D.hh"
class STEPentity;
class InstMgr;
class G4Ray;
class G4BREPSolid : public G4VSolid
{
public:
G4BREPSolid(const G4String name);
G4BREPSolid(const G4String, G4Surface**, G4int);
~G4BREPSolid();
virtual G4String GetEntityType() const {return "Closed_Shell";}
virtual void Initialize();
G4int CreateSTEPData(); // not yet implemented
G4bool CalculateExtent(const EAxis pAxis ,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform ,
G4double& pMin ,
G4double& pMax ) const;
virtual EInside Inside(register const G4ThreeVector&) const;
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector&) const;
virtual G4double DistanceToIn(const G4ThreeVector&) const;
virtual G4double DistanceToIn(register const G4ThreeVector&,
register const G4ThreeVector&) const;
virtual G4double DistanceToOut(const G4ThreeVector&) const;
virtual G4double DistanceToOut(register const G4ThreeVector&,
register const G4ThreeVector&,
const G4bool calcNorm=false ,
G4bool *validNorm=0 ,
G4ThreeVector *n=0 ) const;
G4Point3D Scope(); // ???
void DescribeYourselfTo (G4VGraphicsScene& scene) const;
G4VisExtent GetExtent () const;
G4Polyhedron* CreatePolyhedron () const;
G4NURBS* CreateNURBS () const;
G4int Intersect(register const G4Ray&)const;
inline G4double IntersectionDistance()const{return intersectionDistance;}
void IntersectionDistance(const G4double d)const
{
((G4BREPSolid*)this)->intersectionDistance=d;
}
G4Surface* GetSurface(G4int nr)
{
return SurfaceVec[nr];
}
inline void Active(const G4int x)const
{
((G4BREPSolid*)this)->active=x;
}
inline G4int Active() const {return active;}
virtual inline void Reset() const
{
((G4BREPSolid*)this)->active=1;
((G4BREPSolid*)this)->intersectionDistance=kInfinity;
((G4BREPSolid*)this)->startInside=0;
for(register G4int a=0;a<nb_of_surfaces;a++)
SurfaceVec[a]->Reset();
ShortestDistance = kInfinity;
}
static G4int NumberOfSolids;
static InstMgr InstanceList;
G4double GetShortestDistance() const {return ShortestDistance;}
G4int GetId() const {return Id;}
void SetId(G4int id) {Id = id;}
G4String GetName() const {return solidname;}
void SetName(G4String name) {solidname = name;}
G4int NumberOfFaces() const {return nb_of_surfaces;}
// Add by L. Broglia
G4Axis2Placement3D* GetPlace() { return place; }
G4BoundingBox3D* GetBBox() { return bbox; }
protected:
G4bool IsConvex();
virtual void CalcBBoxes();
void CheckSurfaceNormals();
void RemoveHiddenFaces(register const G4Ray& G4Rayref, G4int)const;
void TestSurfaceBBoxes(register const G4Ray&) const;
inline G4int StartInside() const
{
return startInside;
}
inline void StartInside(const G4int si) const
{
((G4BREPSolid*)this)->startInside=si;
}
private:
G4int IsBox();
G4int FinalEvaluation(register const G4Ray&, const G4int =0) const;
protected:
G4Axis2Placement3D* place;
static G4Ray Track;
static G4double ShortestDistance;
G4int Box, Convex, AxisBox, PlaneSolid;
G4BoundingBox3D* bbox;
G4double intersectionDistance;
G4int active;
G4int startInside;
G4int nb_of_surfaces;
G4Point3D intersection_point;
G4Surface** SurfaceVec;
G4double RealDist;
G4String solidname;
G4int Id;
void QuickSort( register G4Surface** SrfVec,
register G4int left, register G4int right) const
{
register G4int i=left;
register G4int j=right;
register G4Surface* elem1;
register G4Surface* elem2 = SrfVec[(left+right)/2];
register G4double tmpdistance;
do
{
tmpdistance = elem2->Distance();
while ( SrfVec[i]->Distance() < tmpdistance && i < right ) i++;
while (tmpdistance < SrfVec[j]->Distance() && j > left ) j--;
if(i<=j)
{
elem1 = SrfVec[i];
SrfVec[i] = SrfVec[j];
SrfVec[j] = elem1;
i++;j--;
}
} while (i<=j);
if( left < j ) QuickSort(SrfVec,left, j );
if( i < right ) QuickSort(SrfVec,i, right);
}
};
#endif
@@ -0,0 +1,32 @@
// 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: G4BREPSolidBox.hh,v 2.2 1998/10/20 16:31:05 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __G4BREPSolidBOX
#define __G4BREPSolidBOX
#include "G4BREPSolid.hh"
#include "G4RotationMatrix.hh"
class G4BREPSolidBox: public G4BREPSolid
{
public:
G4BREPSolidBox(G4String,const G4Point3D&, const G4Point3D&,
const G4Point3D&, const G4Point3D&, const G4Point3D&,
const G4Point3D&, const G4Point3D&, const G4Point3D& );
EInside Inside(register const G4ThreeVector&) const;
private:
G4RotationMatrix Rotation;
};
#endif
@@ -0,0 +1,60 @@
// 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: G4BREPSolidCone.hh,v 2.1 1998/10/20 16:31:05 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __G4BREPSolidCone
#define __G4BREPSolidCone
#include "G4BREPSolid.hh"
//#include "G4Axis2Placement3D.hh"
class G4BREPSolidCone : public G4BREPSolid
{
public:
G4BREPSolidCone(G4String,
const G4ThreeVector&,
const G4ThreeVector&,
const G4ThreeVector&,
const G4double,
const G4double,
const G4double);
void Initialize();
EInside Inside(register const G4ThreeVector&) const;
G4ThreeVector SurfaceNormal(const G4ThreeVector&) const;
G4double DistanceToIn(const G4ThreeVector&) const;
G4double DistanceToIn(register const G4ThreeVector&,
register const G4ThreeVector&) const;
G4double DistanceToOut(register const G4ThreeVector&,
register const G4ThreeVector&,
const G4bool calcNorm=false,
G4bool *validNorm=0, G4ThreeVector *n=0) const;
G4double DistanceToOut(const G4ThreeVector&) const;
};
#endif
@@ -0,0 +1,26 @@
// 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: G4BREPSolidCylinder.hh,v 2.1 1998/10/20 16:31:07 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __G4BREPSolidCylinder
#define __G4BREPSolidCylinder
#include "G4BREPSolid.hh"
class G4BREPSolidCylinder : public G4BREPSolid
{
public:
G4BREPSolidCylinder(G4String name,
const G4ThreeVector&,
const G4ThreeVector&,
const G4ThreeVector&,
const G4double&,
const G4double&);
};
#endif
@@ -0,0 +1,71 @@
// 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: G4BREPSolidPCone.hh,v 2.1 1998/10/20 16:31:07 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __G4BREPSolidPCone
#define __G4BREPSolidPCone
#include "G4BREPSolid.hh"
class G4BREPSolidPCone : public G4BREPSolid
{
public:
G4BREPSolidPCone( G4String name,
const G4double start_angle,
const G4double opening_angle,
const int num_z_planes, // sections,
const G4double z_start,
const G4double z_values[],
const G4double RMIN[],
const G4double RMAX[]
);
inline void Reset() const
{
Active(1);
((G4BREPSolidPCone*)this)->intersectionDistance=kInfinity;
StartInside(0);
for(register int a=0;a<nb_of_surfaces;a++)
SurfaceVec[a]->Reset();
ShortestDistance = kInfinity;
}
void Initialize();
EInside Inside(register const G4ThreeVector&) const;
G4ThreeVector SurfaceNormal(const G4ThreeVector&) const;
G4double DistanceToIn(const G4ThreeVector&) const;
G4double DistanceToIn(register const G4ThreeVector&,
register const G4ThreeVector&) const;
G4double DistanceToOut(register const G4ThreeVector&,
register const G4ThreeVector&,
const G4bool calcNorm=false,
G4bool *validNorm=0, G4ThreeVector *n=0) const;
G4double DistanceToOut(const G4ThreeVector&) const;
~G4BREPSolidPCone();
G4Polyhedron* CreatePolyhedron () const;
private:
// The following is only utilised in storing the shape parameters for
// use in visualising this shape. J.A. Feb 24, 1997
//
struct PConeParameters {
G4double Start_angle;
G4double Opening_angle;
int Num_z_planes;
// G4double z_start;
G4double *Z_values;
G4double *Rmin;
G4double *Rmax;
} original_parameters;
};
#endif
@@ -0,0 +1,79 @@
// 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: G4BREPSolidPolyhedra.hh,v 2.1 1998/10/20 16:31:08 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __G4BREPPOLYHEDRA
#define __G4BREPPOLYHEDRA
#include "G4BREPSolid.hh"
class G4BREPSolidPolyhedra: public G4BREPSolid
{
public:
// Constructor for Geant3 PGon shape
G4BREPSolidPolyhedra(
G4String name,
const G4double phi1,
const G4double dphi,
const int sides,
const int num_z_planes,
const G4double z_start,
const G4double z_values[],
const G4double RMIN[],
const G4double RMAX[]
);
void Initialize();
inline void Reset() const
{
Active(1);
((G4BREPSolidPolyhedra*)this)->intersectionDistance=kInfinity;
StartInside(0);
for(register int a=0;a<nb_of_surfaces;a++)
SurfaceVec[a]->Reset();
ShortestDistance = kInfinity;
}
EInside Inside(register const G4ThreeVector&) const;
G4ThreeVector SurfaceNormal(const G4ThreeVector&) const;
G4double DistanceToIn(const G4ThreeVector&) const;
G4double DistanceToIn(register const G4ThreeVector&,
register const G4ThreeVector&) const;
G4double DistanceToOut(register const G4ThreeVector&,
register const G4ThreeVector&,
const G4bool calcNorm=false,
G4bool *validNorm=0, G4ThreeVector *n=0) const;
G4double DistanceToOut(const G4ThreeVector&) const;
~G4BREPSolidPolyhedra();
G4Polyhedron* CreatePolyhedron () const;
private:
// The following is only utilised in storing the shape parameters for
// use in visualising this shape. J.A. Feb 24, 1997
//
struct PGonParameters {
G4double Start_angle;
G4double Opening_angle;
int Sides;
int Num_z_planes;
// G4double z_start;
G4double *Z_values;
G4double *Rmin;
G4double *Rmax;
} original_parameters;
};
#endif
@@ -0,0 +1,49 @@
// 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: G4BREPSolidSphere.hh,v 2.1 1998/10/20 16:31:08 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __G4BREPSolidSphere
#define __G4BREPSolidSphere
#include "G4BREPSolid.hh"
class G4BREPSolidSphere: public G4BREPSolid
{
public:
G4BREPSolidSphere(const G4String,
const G4Vector3D&,
const G4Vector3D&,
const G4Vector3D&,
G4double);
inline void SphReset()const
{
((G4BREPSolidSphere*)this)->active=1;
}
EInside Inside(register const G4ThreeVector&) const;
G4ThreeVector SurfaceNormal(const G4ThreeVector&) const;
G4double DistanceToIn(const G4ThreeVector&) const;
G4double DistanceToIn(register const G4ThreeVector&,
register const G4ThreeVector&) const;
G4double DistanceToOut(register const G4ThreeVector&,
register const G4ThreeVector&,
const G4bool calcNorm=false,
G4bool *validNorm=0, G4ThreeVector *n=0) const;
G4double DistanceToOut(const G4ThreeVector&) const;
};
#endif
@@ -0,0 +1,26 @@
// 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: G4BREPSolidTorus.hh,v 2.1 1998/10/20 16:31:08 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __G4BREPSolidTorus
#define __G4BREPSolidTorus
#include "G4BREPSolid.hh"
class G4BREPSolidTorus: public G4BREPSolid
{
public:
G4BREPSolidTorus(const G4String ,
const G4ThreeVector&,
const G4ThreeVector&,
const G4ThreeVector&,
G4double,
G4double);
};
#endif
@@ -0,0 +1,81 @@
// 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: G4BSplineCurve.hh,v 2.4 1998/10/20 16:31:09 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __BSPLINECURVE_H
#define __BSPLINECURVE_H
#include <rw/tvvector.h>
#include "G4BoundedCurve.hh"
class G4ControlPoints;
class G4KnotVector;
class G4BSplineCurve : public G4BoundedCurve
{
public:
typedef RWTValVector<G4double> G4doubleVector;
typedef RWTValVector<G4Point3D> G4Point3DVector;
public:
G4BSplineCurve();
~G4BSplineCurve();
virtual G4Curve* Project(const G4Transform3D& tr=
G4Transform3D::Identity);
virtual G4bool Tangent(G4CurvePoint& cp, G4Vector3D& v);
virtual void IntersectRay2D(const G4Ray& ray, G4CurveRayIntersection& is);
virtual G4double GetPMax();
virtual G4Point3D GetPoint(G4double param);
virtual G4double GetPPoint(const G4Point3D& p);
// Get/Set for the geometric data
//
// knots contains each knot multiplicity Times,
// thus knot_multiplicities is not needed
// weightsData might be 0
// curve_form, closed_curve, self_intersect is not used,
// as they are unreliable sources of information
//
// the object is responsible for deleting the containers passed to Init
void Init(G4int degree0, G4Point3DVector* controlPointsList0,
G4doubleVector* knots0, G4doubleVector* weightsData0);
G4int GetDegree() const;
const G4Point3DVector* GetControlPointsList() const;
const G4doubleVector* GetKnots() const;
const G4doubleVector* GetWeightsData() const;
protected:
virtual void InitBounded();
//public:
//void ProjectCurve(const G4Plane&, const G4Plane&);
//int Inside(const G4Point3d&, const G4Ray&);
//void CalcCurvePlaneNormal();
protected:
// geometric data
G4int degree;
G4Point3DVector* controlPointsList;
G4doubleVector* knots;
G4doubleVector* weightsData;
};
#include "G4BSplineCurve.icc"
#endif
@@ -0,0 +1,45 @@
inline G4int G4BSplineCurve::GetDegree() const {
return degree;
}
inline const G4BSplineCurve::G4Point3DVector*
G4BSplineCurve::GetControlPointsList() const {
return controlPointsList;
}
inline const G4BSplineCurve::G4doubleVector*
G4BSplineCurve::GetKnots() const {
return knots;
}
inline const G4BSplineCurve::G4doubleVector*
G4BSplineCurve::GetWeightsData() const {
return weightsData;
}
// add by L. Broglia to pass linkage
inline G4double G4BSplineCurve::GetPMax()
{
return 0.0;
}
inline G4Point3D G4BSplineCurve::GetPoint(G4double param)
{
return G4Point3D(0, 0, 0);
}
inline G4double G4BSplineCurve::GetPPoint(const G4Point3D& p)
{
return 0.0;
}
//////////////////////////////////////////////////////////////////////
#include "G4CurveRayIntersection.hh"
inline void G4BSplineCurve::IntersectRay2D(const G4Ray& ray,
G4CurveRayIntersection& is)
{
}
@@ -0,0 +1,21 @@
// 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: G4BSplineCurveWithKnots.hh,v 2.2 1998/10/20 16:31:10 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __B_SPLINECURVEWITHKNOTS_H
#define __B_SPLINECURVEWITHKNOTS_H
#include "G4BSplineCurve.hh"
class G4BSplineCurveWithKnots : public G4BSplineCurve
{
};
#endif
@@ -0,0 +1,123 @@
// 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: G4BSplineSurface.hh,v 2.8 1998/11/24 16:41:12 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __BSPLINESURFACE_H
#define __BSPLINESURFACE_H
#include "G4Point3D.hh"
#include "G4PointRat.hh"
#include "G4Surface.hh"
#include "G4ProjectedSurface.hh"
//#ifdef WIN32
//# include "G4ios.hh"
//#else
//# include <stream.h>
//#endif
class G4BSplineSurface : public G4Surface
{
public:
G4BSplineSurface();
G4BSplineSurface(char*, G4Ray&);
G4BSplineSurface(const G4BSplineSurface &tmp);
G4BSplineSurface(G4int, G4int, G4KnotVector&, G4KnotVector&,
G4ControlPoints&);
~G4BSplineSurface();
int Intersect(const G4Ray&);
void CalcBBox();
G4double GetUHit() { return Hit->u; }
G4double GetVHit() { return Hit->v; }
inline int MyType()const {return 2;}
G4double ClosestDistanceToPoint(const G4Point3D&);
inline void Reset()
{
active=1;
bezier_list.EmptyList();
projected_list.EmptyList();
Intersected=0;
distance = INFINITY;
}
// get for controlpoints
G4int GetRows() { return ctl_points->GetRows(); }
G4int GetCols() { return ctl_points->GetCols(); }
G4Point3D GetControlPoint(G4int a, G4int b) { return ctl_points->Get3D(a,b);}
private:
G4SurfaceList bezier_list;
G4SurfaceList projected_list;
short dir;
int order[2];
G4KnotVector *u_knots;
G4KnotVector *v_knots;
G4KnotVector *tmp_knots;
G4ControlPoints *ctl_points;
G4UVHit* Hit;
G4UVHit* first_hit;
int ord;
int k_index;
G4double param;
int Rational;
void FindIntersections(const G4Ray&);
inline int GetOrder(int direction) { return order[direction]; }
inline void PutOrder(int direction, int value) { order[direction]=value; }
void AddHit(G4double u, G4double v);
void ProjectNURBSurfaceTo2D( const G4Plane& ,const G4Plane&,
G4ProjectedSurface*);
G4ProjectedSurface* CopyToProjectedSurface(const G4Ray&);
G4Point3D FinalIntersection();
// L. Broglia
// Because G4BSplineSurface::Evaluate hides the virtual function
// G4Surface::Evaluate(const G4Ray&), I modified the function name
// G4Point3D Evaluate();
G4Point3D BSEvaluate();
G4PointRat& InternalEvalCrv(int i, G4ControlPoints *crv);
G4Point3D Evaluation(const G4Ray&);
G4Vector3D SurfaceNormal(const G4Point3D& Pt)const
{
return G4Vector3D(0,0,0);
}
};
#endif
@@ -0,0 +1,186 @@
// 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: G4BezierSurface.hh,v 2.5 1998/11/24 16:41:13 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __BEZIERSURFACE_H
#define __BEZIERSURFACE_H
#include "G4Ray.hh"
#include "G4ControlPoints.hh"
#include "G4SurfaceList.hh"
#include "G4PointRat.hh"
#include "G4OsloMatrix.hh"
#include "G4KnotVector.hh"
class G4ProjectedSurface;
class G4BezierSurface : public G4Surface
{
friend class G4BSplineSurface;
friend class G4ProjectedSurface;
public:
// Test variables
static int Clips;
static int Splits;
G4BezierSurface();
G4BezierSurface(const G4BezierSurface &tmp);
~G4BezierSurface();
friend void CopySurface(G4BezierSurface& bez);
static G4double Tolerance;
inline G4Point3D AveragePoint() { return average_pt; };
inline void SetAveragePoint(G4Point3D p) { average_pt=p; }
inline G4double UAverage() { return average_u; }
inline G4double VAverage() { return average_v; }
inline void Dir(int d) { dir=d; }
inline void ChangeDir() { dir=!dir; }
inline G4double SMin() {return smin; }
inline G4double SMax() {return smax; }
inline int GetOrder(int direction) { return order[direction]; }
inline void PutOrder(int direction, int value){ order[direction]=value; }
inline G4double GetU() { return (u_min + u_max)/2.0;}
inline G4double GetV() { return (v_min + v_max)/2.0;}
void CalcBBox();
// L. Broglia
// Because G4BezierSurface::Intersect hides the virtual function
// G4Surface::Intersect(const G4Ray&), I changed the name of this
// function
// G4int Intersect(G4SurfaceList&);
G4int BIntersect(G4SurfaceList&);
G4SurfaceList* bezier_list;
int ClipBothDirs();
void ClipSurface();
virtual G4Vector3D SurfaceNormal(const G4Point3D& Pt)const
{
return G4Vector3D(0,0,0);
}
private:
int order[2];
G4double smin;
G4double smax;
G4Point3D line;
G4double average_u;
G4double average_v;
G4Point3D average_pt;
int dir;
G4KnotVector *u_knots;
G4KnotVector *v_knots;
G4ControlPoints *ctl_points;
void CalcAverage();
void CalcDistance(const G4Point3D&);
void SetValues();
inline void LocalizeClipValues()
{
if ( dir == ROW)
{
smin = (1.0 - smin) * u_knots->GetKnot(0) +
smin * u_knots->GetKnot(u_knots->GetSize() - 1);
smax = (1.0 - smax) * u_knots->GetKnot(0) +
smax * u_knots->GetKnot(u_knots->GetSize() - 1);
}
else
{
smin = (1.0 - smin) * v_knots->GetKnot(0) +
smin * v_knots->GetKnot(v_knots->GetSize() - 1);
smax = (1.0 - smax) * v_knots->GetKnot(0) +
smax * v_knots->GetKnot(v_knots->GetSize() - 1);
}
}
G4KnotVector *new_knots;
int ord;
G4OsloMatrix * oslo_m;
int lower,upper;
G4double u[2];
G4double v[2];
G4double u_min;
G4double u_max;
G4double v_min;
G4double v_max;
G4ControlPoints* old_points;
void SplitNURBSurface();
void GetClippedRegionFromSurface();
void RefineSurface();
void CalcOsloMatrix();
void MapSurface(G4Surface*);
// For ClipSurface...
inline G4double Findzero(G4double x0,G4double x1,G4double y0,G4double y1)
{
return(x0 - y0 * ( x1 - x0) / (y1-y0));
};
inline int Sign(G4double a)
{
return((a < 0.0)? -1 : 1) ;
};
// For calc_G4OsloMatrix...
inline int Amax(int i, int j) {return( (i) > (j) ? (i) : (j) );};
inline int Amin(int i, int j) {return( (i) < (j) ? (i) : (j) );};
inline int AhIndex(int j,int t, int iorder)
{
return(( (j) * ((j)+1)/2) + (t) - ((iorder-1) - (j)));
};
};
#endif
@@ -0,0 +1,24 @@
// 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: G4BoundedCurve.hh,v 2.1 1998/10/20 16:31:11 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __BOUNDEDCURVE_H
#define __BOUNDEDCURVE_H
#include "G4Curve.hh"
class G4BoundedCurve : public G4Curve
{
public:
//int Inside(G4Point3d&, G4Ray&);
};
#endif
@@ -0,0 +1,29 @@
// 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: G4BoundedSurface.hh,v 2.2 1998/10/20 16:31:12 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4Surface.hh"
class G4BoundedSurface: public G4Surface
{
public:
G4BoundedSurface() {};
/* L. Broglia
G4BoundedSurface(STEPentity& Ent, InstMgr&) {};
*/
~G4BoundedSurface() {};
virtual char *Name() const
{
return "G4BoundedSurface";
}
};
@@ -0,0 +1,61 @@
#ifndef __G4BoundingBox3D_h
#define __G4BoundingBox3D_h 1
#include "G4Ray.hh"
#include "G4Point3D.hh"
#include "G4Vector3D.hh"
class G4BoundingBox3D
{
public:
G4BoundingBox3D();
G4BoundingBox3D(const G4Point3D&);
G4BoundingBox3D(const G4Point3D&, const G4Point3D&);
~G4BoundingBox3D();
void Init(const G4Point3D&);
void Init(const G4Point3D&, const G4Point3D&);
void Extend(const G4Point3D&);
G4Point3D GetBoxMin() const;
G4Point3D GetBoxMax() const;
G4double GetDistance() const;
void SetDistance(G4double distance0);
int GetTestResult() const;
int Test(const G4Ray&);
static const G4BoundingBox3D space;
private:
G4Point3D box_min;
G4Point3D box_max;
G4double distance;
int test_result;
G4Point3D MiddlePoint;
G4Vector3D GeantBox;
int BoxIntersect(const G4Point3D&,
const G4Point3D&,
const G4Vector3D&) const;
G4double DistanceToIn(const G4Point3D&,
const G4Vector3D&) const;
};
#include "G4BoundingBox3D.icc"
#endif
@@ -0,0 +1,30 @@
inline G4Point3D G4BoundingBox3D::GetBoxMin() const
{
return box_min;
}
inline G4Point3D G4BoundingBox3D::GetBoxMax() const
{
return box_max;
}
inline G4double G4BoundingBox3D::GetDistance() const
{
return distance;
}
inline void G4BoundingBox3D::SetDistance(G4double distance0)
{
distance = distance0;
}
inline int G4BoundingBox3D::GetTestResult() const
{
return test_result;
}
@@ -0,0 +1,59 @@
// 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: G4CircularCurve.hh,v 2.3 1998/10/20 16:31:14 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __CIRCULARCURVE_H
#define __CIRCULARCURVE_H
// should be G4Circle, but there is one in graphics_reps already
#include "G4Conic.hh"
class G4CircularCurve : public G4Conic
{
public:
G4CircularCurve();
~G4CircularCurve();
virtual G4Curve* Project(const G4Transform3D& tr=
G4Transform3D::Identity);
virtual G4bool Tangent(G4CurvePoint& cp, G4Vector3D& v);
virtual void IntersectRay2D(const G4Ray& ray, G4CurveRayIntersection& is);
virtual G4double GetPMax();
virtual G4Point3D GetPoint(G4double param);
virtual G4double GetPPoint(const G4Point3D& p);
// Get/Set for the geometric data
void Init(const G4Axis2Placement3D& position0, G4double radius0);
G4double GetRadius() const;
protected:
virtual void InitBounded();
private:
// geometric data
G4double radius;
};
#include "G4CircularCurve.icc"
#endif
@@ -0,0 +1,38 @@
inline void G4CircularCurve::Init(const G4Axis2Placement3D& position0,
G4double radius0) {
position= position0;
radius= radius0;
}
inline G4double G4CircularCurve::GetRadius() const {
return radius;
}
/////////////////////////////////////////////////////////////////////////////
inline G4double G4CircularCurve::GetPMax() {
return twopi;
}
inline G4Point3D G4CircularCurve::GetPoint(G4double param) {
return position.GetLocation()+radius*
( cos(param)*position.GetPX() + sin(param)*position.GetPY() );
}
inline G4double G4CircularCurve::GetPPoint(const G4Point3D& pt) {
G4Point3D ptLocal= position.GetToPlacementCoordinates()*pt;
G4double angle= atan2(ptLocal.y(), ptLocal.x());
return (angle<0)? angle+twopi: angle;
}
////////////////////////////////////////////////////////////////////////////
#include "G4CurveRayIntersection.hh"
inline void G4CircularCurve::IntersectRay2D(const G4Ray& ray,
G4CurveRayIntersection& is)
{
G4Exception("G4CircularCurve is always 3D!");
exit(1);
}
@@ -0,0 +1,70 @@
#ifndef included_G4CompositeCurve
#define included_G4CompositeCurve
#include "G4Curve.hh"
#include "G4CurveVector.hh"
#include "G4CurveRayIntersection.hh"
#include "G4Point3DVector.hh"
class G4CompositeCurve : public G4Curve
{
public:
G4CompositeCurve();
~G4CompositeCurve();
// the following is a constructor creating closed polygons,
// given the vertices.
// No call to Init and SetBounds is needed after calling this constructor.
G4CompositeCurve(const G4Point3DVector& vertices);
virtual G4String GetEntityType() const
{
return "G4CompositeCurve";
}
virtual G4Curve* Project(const G4Transform3D& tr = G4Transform3D::Identity);
virtual G4bool Tangent(G4CurvePoint& cp, G4Vector3D& v);
virtual void IntersectRay2D(const G4Ray& ray, G4CurveRayIntersection& is);
virtual G4double GetPMax();
virtual G4Point3D GetPoint(G4double param);
virtual G4double GetPPoint(const G4Point3D& p);
// Get/Set for the geometric data
// the class is not responsible for deleting the curves;
// only a shallow copy of the CurveVector is made
void Init(const G4CurveVector& segments0);
const G4CurveVector& GetSegments() const;
protected:
virtual void InitBounded();
private:
// geometric data
G4CurveVector segments;
G4CurveRayIntersection lastIntersection;
};
#include "G4CompositeCurve.icc"
#endif
@@ -0,0 +1,36 @@
inline void G4CompositeCurve::Init(const G4CurveVector& segments0)
{
segments= segments0;
lastIntersection.Reset();
InitBounded();
}
inline const G4CurveVector& G4CompositeCurve::GetSegments() const
{
return segments;
}
/////////////////////////////////////////////////////////////////////////////
inline G4double G4CompositeCurve::GetPMax()
{
G4Exception("G4CompositeCurve::GetPMax");
return 0;
}
inline G4Point3D G4CompositeCurve::GetPoint(G4double param)
{
G4Exception("G4CompositeCurve::GetPoint");
// Fake return value
return G4Point3D();
}
inline G4double G4CompositeCurve::GetPPoint(const G4Point3D& pt)
{
G4Exception("G4CompositeCurve::GetPPoint");
return 0;
}
////////////////////////////////////////////////////////////////////////////
@@ -0,0 +1,43 @@
#ifndef __CONIC_H
#define __CONIC_H
#include "G4Curve.hh"
#include "G4Axis2Placement3D.hh"
class G4Conic: public G4Curve
{
public:
G4Conic();
G4Conic(STEPentity& Ent);
~G4Conic();
// Get/Set to geometric data
const G4Axis2Placement3D* GetPosition() const;
// pShift must be added/subtracted from the parameter
// no STEP I/O if not 0!!!
// set by Project members
G4double GetPShift() const;
void SetPShift(G4double pShift0);
//inline G4Placement GetPosition() {return Position;}
//virtual const char *Name(){return "G4ConicalCurve";}
protected:
//void ProjectCurve(const G4Plane&, const G4Plane&);
//int HitPartOfCurve(G4double, G4double, const G4Point2d&);
//G4Placement Position;
// geometric data
G4Axis2Placement3D position;
private:
G4double pShift;
};
#include "G4Conic.icc"
#endif
@@ -0,0 +1,13 @@
inline const G4Axis2Placement3D* G4Conic::GetPosition() const {
return &position;
}
inline G4double G4Conic::GetPShift() const {
return pShift;
}
inline void G4Conic::SetPShift(G4double pShift0) {
pShift= pShift0;
}
@@ -0,0 +1,227 @@
// 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: G4ConicalSurface.hh,v 2.5 1998/10/20 16:31:15 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
/* /usr/local/gismo/repo/geometry/G4ConicalSurface.h,v 1.5 1993/12/30 02:13:59 rensing Exp */
// File: G4ConicalSurface.h
// Author: Alan Breakstone
// Contents ---------------------------------------------------------
//
// G4ConicalSurface
//
// Description:
//
// C++ header file for the Gismo G4ConicalSurface class, derived from
// Surface class.
// Uses the GmsListLink, G4ThreeVec, G4ThreeMat, Ray, Helix, and Surface
// classes.
// A G4ConicalSurface is a semi-infinite conical surface defined by
// an axis and an opening angle, defined as the angle between the axis
// and the conical surface, with the origin being the apex of the cone.
//
// End --------------------------------------------------------------
// Interface Dependencies -------------------------------------------
#ifndef __CONICALSURFACE_H
#define __CONICALSURFACE_H
#include "G4Surface.hh"
class G4ThreeMat;
// End Interface Dependencies ---------------------------------------
// Class //
class G4ConicalSurface: public G4Surface
{
private:
G4Vector3D axis; // direction of axis of G4ConicalSurface (unit vector)
G4double angle; // half opening angle of G4ConicalSurface, in radians
// range is 0 < angle < PI/2
public:
G4ConicalSurface();
G4ConicalSurface( const G4Point3D& o, const G4Vector3D& a, G4double e );
virtual ~G4ConicalSurface() {}
G4String GetEntityType() { return G4String("Conical_Surface"); }
// G4ConicalSurface( const G4ConicalSurface& c ): G4Surface( c.origin )
// { axis = c.axis; angle = c.angle; }
virtual char *NameOf() const { return "G4ConicalSurface"; }
virtual void PrintOn( ostream& os = G4cout ) const;
int operator==( const G4ConicalSurface& c )
{
return origin == c.origin && axis == c.axis && angle == c.angle;
}
virtual G4double HowNear( const G4Vector3D& x ) const;
// virtual G4double distanceAlongRay( int which_way, const G4Ray* ry,
// G4Vector3D& p ) const;
// Added 18.7-95
void CalcBBox();
// Added 18.7-95 , same as distanceAlongRay, but uses G4Ray.h
int Intersect( const G4Ray& ry );
// virtual G4double distanceAlongHelix( int which_way,
// const Helix* hx, G4Vector3D& p ) const;
// G4Vector3D Normal( const G4Vector3D& p ) const;
virtual G4Vector3D SurfaceNormal( const G4Point3D& p ) const;
virtual int Inside( const G4Vector3D& x ) const;
virtual int WithinBoundary( const G4Vector3D& x ) const;
virtual G4double Scale() const { return 1.0; }
// virtual void rotate( G4double alpha, G4double beta,
// G4double gamma, G4ThreeMat& m, int inverse );
// virtual void rotate( G4double alpha, G4double beta,
// G4double gamma, int inverse );
G4Vector3D GetAxis() const { return axis; }
G4double GetAngle() const { return angle; }
void SetAngle( G4double e );
private:
// virtual G4double gropeAlongHelix( const Helix* hx ) const;
//
// Description of functions -----------------------------------------
//
// default constructor
//----->G4ConicalSurface();
//
// Normal constructor: first argument is the origin of the G4ConicalSurface
// second argument is the axis of the G4ConicalSurface
// third argument is the angle of the G4ConicalSurface
//----->G4ConicalSurface(const G4Vector3D& o, const G4Vector3D& a, G4double e);
//
// destructor
//----->virtual ~G4ConicalSurface() {}
//
// copy constructor
//----->G4ConicalSurface( const G4ConicalSurface& c ): Surface( c.origin )
//-----> { axis = c.axis; angle = c.angle; }
//
// function to return class name
//----->virtual char *NameOf() const { return "G4ConicalSurface"; }
//
// printing function
//----->virtual void PrintOn( ostream& os = G4cout ) const;
//
// equality operator
//----->int operator==( const G4ConicalSurface& c )
//-----> { return origin == c.origin && axis == c.axis
//-----> && angle == c.angle; }
//
// function which returns the distance from a point to a G4ConicalSurface
// the (input) argument is the point x
// the distance is positive if the point is Inside,
// negative if it is outside
//----->virtual G4double HowNear( const G4Vector3D& x ) const;
//
// function which returns the distance along a Ray to enter or leave a
// G4ConicalSurface.
// the first (input) argument is +1 to leave or -1 to enter
// the second (input) argument is a pointer to the Ray
// the third (output) argument returns the intersection point
//----->virtual G4double distanceAlongRay( int which_way, const Ray* ry,
//-----> G4Vector3D& p ) const;
//
// function which returns the distance along a Helix to enter or leave a
// G4ConicalSurface.
// the first (input) argument is +1 to leave or -1 to enter
// the second (input) argument is a pointer to the Helix
// the third (output) argument returns the intersection point
//----->virtual G4double distanceAlongHelix( int which_way, const Helix* hx,
//-----> G4Vector3D& p ) const;
//
// function which returns the Normal unit vector to a G4ConicalSurface
// at a point p on (or nearly on) the G4ConicalSurface
//----->virtual G4Vector3D Normal( const G4Vector3D& p ) const;
//
// function which returns
// true (1) if the point x is Inside the G4ConicalSurface,
// false (0) otherwise
//----->virtual int Inside( const G4Vector3D& x ) const;
//
// function overwritten by finite-sized derived classes which returns
// true (1) if the point x is within the boundary, false (0)
// otherwise.
// Since a G4ConicalSurface is infinite in extent, the function
// will just check if the point is on the G4ConicalSurface
// (to the surface precision).
//----->virtual int WithinBoundary( const G4Vector3D& x ) const;
//
// function overwritten by finite-sized derived classes which returns
// a radius, unless it is zero, in which case it returns
// the smallest non-zero dimension.
// Since a semi-infinite cone has no Scale associated with it,
// returns the arbitrary number 1.0.
// Used for Scale-invariant tests of surface thickness.
//----->virtual G4double Scale() const { return 1.0; }
//
// function to rotate the G4ConicalSurface (4 input arguments)
// first about global x-axis by angle alpha,
// second about global y-axis by angle beta,
// third about global z-axis by angle gamma
// the angles are assumed to be given in radians
// the fourth (output) argument gives the calculated rotation
// matrix
// the fifth (input) argument is an integer flag which if
// non-zero reverses the order of the rotations
//----->virtual void rotate( G4double alpha, G4double beta,
//-----> G4double gamma, G4ThreeMat& m, int inverse );
//
// function to rotate the G4ConicalSurface (4 input arguments)
// first about global x-axis by angle alpha,
// second about global y-axis by angle beta,
// third about global z-axis by angle gamma
// the angles are assumed to be given in radians
// the fourth (input) argument is an integer flag which if
// non-zero reverses the order of the rotations
//----->virtual void rotate( G4double alpha, G4double beta,
//-----> G4double gamma, int inverse );
//
// functions to return the axis and angle of the G4ConicalSurface
//----->direction GetAxis() const { return axis; }
//----->G4double GetAngle() const { return angle; }
//
// function to change the angle of the G4ConicalSurface
//----->void SetAngle( G4double e );
//
//
// Private function to use a crude technique to find the intersection
// of a Helix with a G4ConicalSurface. It returns the turning angle along the
// Helix at which the intersection occurs or -1.0 if no intersection
// point is found. The argument to the call is the pointer to the Helix.
//----->virtual G4double gropeAlongHelix( const Helix* hx ) const;
};
#endif
@@ -0,0 +1,105 @@
// 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: G4ControlPoints.hh,v 2.3 1998/10/20 16:31:16 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Modif 8 oct 98 : A.Floquet
// G4PointRat datas are made of
// . a point 3D
// . a additional value : the scale factor which is set to 1 by default
//
// G4ControlPoints includes only G4PointRat which in turn are made
// of G4Point3D
#ifndef __G4ControlPoints_h
#define __G4ControlPoints_h 1
#include "G4PointRat.hh"
class G4ControlPoints
{
public:
// Constructors
G4ControlPoints();
G4ControlPoints(const STEPaggregate& Aggr, const int Rational);
G4ControlPoints( int, int);
G4ControlPoints( int , int , int );
G4ControlPoints(const G4ControlPoints&);
// Destructor
~G4ControlPoints();
void SetWeights(G4double*);
void CalcValues(G4double k1, G4double param, G4Point3D& pts1,
G4double k2, G4Point3D& pts2);
void CalcValues(G4double k1, G4double param, G4PointRat& pts1,
G4double k2, G4PointRat& pts2);
inline int GetRows() const {return nr;}
inline int GetCols() const {return nc;}
// Puts control point into matrix location (i,j)
inline void put(const int i, const int j, const G4Point3D &tmp)
{
*data[i*nc+j]=tmp; // tmp is converted to a PointRat
// by the member affectation function
// of the G4PointRat class
}
inline void put(const int i, const int j, const G4PointRat& tmp)
{
*data[i*nc+j]=tmp;
}
// Retrieves control point from matrix location (i,j)
inline G4Point3D Get3D(const int i, const int j) const
{
return (data[i*nc+j])->pt();
}
inline G4PointRat& GetRat(const int i, const int j) const
{
return *data[i*nc+j];
}
G4double ClosestDistanceToPoint(const G4Point3D&);
private:
inline G4double Calc(const G4double k1, const G4double par,
const G4double old_val, const G4double k2,
const G4double new_val )
{
return (((k1 - par) * old_val +(par - k2) * new_val) / (k1-k2));
}
G4PointRat** data;
int nr, nc;
};
#endif
@@ -0,0 +1,37 @@
// 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: G4ConvexHull.hh,v 2.1 1998/10/20 16:31:16 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __CONVEXHULL_H
#define __CONVEXHULL_H
class G4ConvexHull
{
public:
G4ConvexHull *next;
G4double param;
G4double min;
G4double max;
G4ConvexHull(){};
G4ConvexHull(G4double pparam, G4double mmin, G4double mmax)
{
next = this;
param = pparam;
min = mmin;
max = mmax;
}
~G4ConvexHull(){}
};
#endif
@@ -0,0 +1,177 @@
// 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: G4Curve.hh,v 2.6 1998/12/07 17:09:05 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __CURVE_H
#define __CURVE_H
#include "geomdefs.hh"
#include "G4Point3D.hh"
#include "G4Vector3D.hh"
#include "G4BoundingBox3D.hh"
#include "G4Transform3D.hh"
#include "G4Ray.hh"
class G4Ray;
class G4CurveRayIntersection;
class G4CurvePoint;
class G4Surface;
class G4Curve
{
public:
// The right way to Initialize objects derived from G4Curve is:
// . Construct (the constructor takes no parameters)
// . call Init()
// . call one of the SetBounds(), if the curve is bounded (most are)
G4Curve();
virtual ~G4Curve();
virtual G4String GetEntityType() const { return "G4Curve"; }
private:
G4Curve(const G4Curve&);
G4Curve& operator=(const G4Curve&);
public:
// transformation of the curve
// virtual void Transform(const G4Transform3D& tr);
// projection onto the xy plane after transformation tr
// the returned object is allocated dynamically;
// it is the caller's responsibility to delete it
// in case the projection maps two distinct points into one,
// 0 is returned
// NOTE: this should not occur when using projection
// with G4SurfaceOfRevolution.
// For other uses this might be too restrictive...
virtual G4Curve* Project(const G4Transform3D& tr=G4Transform3D::Identity)= 0;
// tangent vector to a curve at the point with parameter u
// true if exists
// vector comes into v
virtual G4bool Tangent(G4CurvePoint& cp, G4Vector3D& v)= 0;
// intersect a 2D curve (probably obtained with Project) with a ray.
// the ray is projected onto the xy plane.
// no intersection: return false
// intersection: return true, and set intersection0
// the intersection point is ray.start+ray.dir*intersection0
virtual void IntersectRay2D(const G4Ray& ray, G4CurveRayIntersection& is)= 0;
// start and endpoints
// in 3D space
const G4Point3D& GetStart() const;
const G4Point3D& GetEnd() const;
// in parameter space
G4double GetPStart() const;
G4double GetPEnd() const;
// set start and endpoints
// four versions, as both points can be given as parameter values
// or 3D points
void SetBounds(G4double p1, G4double p2);
void SetBounds(G4double p1, const G4Point3D& p2);
void SetBounds(const G4Point3D& p1, G4double p2);
void SetBounds(const G4Point3D& p1, const G4Point3D& p2);
// returns if the curve is bounded
G4bool IsBounded() const;
// returns if the parameter is on the curve
G4bool IsPOn(G4double param);
// the sameSense flag can be used to reverse the orientation
// of the curve (value false).
// the curves themselves never use the value of this flag;
// this is just a convenient means of storing
// this piece of topological information.
void SetSameSense(G4int sameSense0);
G4int GetSameSense() const;
// if the parameter space is closed, return the max value
// if not, return <=0
virtual G4double GetPMax()= 0;
// parameter -> point
virtual G4Point3D GetPoint(G4double param)= 0;
// point -> parameter
// result is undefined
// if the point is further off the curve than some tolerance
virtual G4double GetPPoint(const G4Point3D& p)= 0;
// get the bounding box for the curve
// this function only works when the curve is bounded!
// otherwise, the result is undefined.
const G4BoundingBox3D* BBox() const;
// To be moved to a derived class
// really needed?
virtual void SetParentSrfPtr(const G4Surface* srf){}
virtual const char* Name(){return "G4Curve";}
G4bool operator==(const G4Curve& right) const
{
return this == &right;
}
protected:
G4BoundingBox3D bBox;
// This function will be called after the bounds are set:
virtual void InitBounded()= 0;
private:
void SetStart(const G4Point3D& pt);
void SetStart(G4double p);
void SetEnd(const G4Point3D& p);
void SetEnd(G4double p);
void SetBoundsRest();
G4Point3D start;
G4Point3D end;
G4double pStart;
G4double pEnd;
G4double pRange;
G4bool bounded;
G4int sameSense;
};
#include "G4Curve.icc"
#endif
@@ -0,0 +1,123 @@
// inline members of G4Curve
inline const G4BoundingBox3D* G4Curve::BBox() const
{
return &bBox;
}
// bounds related
inline const G4Point3D& G4Curve::GetStart() const
{
return start;
}
inline const G4Point3D& G4Curve::GetEnd() const
{
// workaround for an xlC bug
const G4Point3D& lof= end;
return lof;
}
inline G4double G4Curve::GetPStart() const
{
return pStart;
}
inline G4double G4Curve::GetPEnd() const
{
return pEnd;
}
inline void G4Curve::SetStart(const G4Point3D& pt)
{
start= pt;
pStart= GetPPoint(pt);
}
inline void G4Curve::SetStart(G4double p)
{
pStart= p;
start= GetPoint(p);
}
inline void G4Curve::SetEnd(const G4Point3D& pt)
{
end= pt;
pEnd= GetPPoint(pt);
}
inline void G4Curve::SetEnd(G4double p)
{
pEnd= p;
end= GetPoint(p);
}
inline void G4Curve::SetBoundsRest()
{
pRange= pEnd-pStart;
G4double pMax= GetPMax();
if (pMax>0)
{
// Find the range in the first determination
pRange-= (ceil(pRange/pMax)-1)*pMax;
}
bounded= true;
InitBounded();
}
inline void G4Curve::SetBounds(G4double p1, G4double p2)
{
SetStart(p1);
SetEnd(p2);
SetBoundsRest();
}
inline void G4Curve::SetBounds(G4double p1, const G4Point3D& p2)
{
SetStart(p1);
SetEnd(p2);
SetBoundsRest();
}
inline void G4Curve::SetBounds(const G4Point3D& p1, G4double p2)
{
SetStart(p1);
SetEnd(p2);
SetBoundsRest();
}
inline void G4Curve::SetBounds(const G4Point3D& p1, const G4Point3D& p2)
{
SetStart(p1);
SetEnd(p2);
SetBoundsRest();
}
inline G4bool G4Curve::IsPOn(G4double param)
{
G4double diff= param-pStart;
G4double pMax= GetPMax();
if (pMax>0)
diff-= floor(diff/pMax)*pMax;
return diff<=pRange;
}
inline G4bool G4Curve::IsBounded() const
{
return bounded;
}
inline void G4Curve::SetSameSense(G4int sameSense0)
{
sameSense= sameSense0;
}
inline G4int G4Curve::GetSameSense() const
{
return sameSense;
}
@@ -0,0 +1,53 @@
#ifndef included_G4CurvePoint
#define included_G4CurvePoint
// A class capable of storing both the parametric and the non-parametric
// representation of a point on a curve.
// The representation is evaluated lazily for efficiency.
#include "G4Curve.hh"
#include "G4Point3D.hh"
class G4CurvePoint
{
public:
G4CurvePoint(G4Curve& c0);
void Init(G4Curve& c0);
G4Curve& GetCurve() const;
void Reset();
void Reset(G4double u0);
void Reset(const G4Point3D& p0);
void Reset(G4double u0, const G4Point3D& p0);
G4double GetPPoint();
const G4Point3D& GetPoint();
protected:
G4CurvePoint() { }
G4Curve* c;
G4Point3D p;
G4double u;
G4int notComputed;
static const G4int pFlag;
static const G4int uFlag;
static const G4int allFlags;
};
#include "G4CurvePoint.icc"
#endif
@@ -0,0 +1,62 @@
inline void G4CurvePoint::Init(G4Curve& c0)
{
c= &c0;
notComputed= allFlags;
}
inline G4CurvePoint::G4CurvePoint(G4Curve& c0)
{
Init(c0);
}
inline G4Curve& G4CurvePoint::GetCurve() const
{
return *c;
}
/////////////////////////////////////////////////////////////////////////////
inline void G4CurvePoint::Reset()
{
notComputed= allFlags;
}
inline void G4CurvePoint::Reset(G4double u0)
{
u= u0;
notComputed= pFlag;
}
inline void G4CurvePoint::Reset(const G4Point3D& p0)
{
p= p0;
notComputed= uFlag;
}
inline void G4CurvePoint::Reset(G4double u0, const G4Point3D& p0)
{
u= u0;
p= p0;
notComputed= 0;
}
/////////////////////////////////////////////////////////////////////////////
inline G4double G4CurvePoint::GetPPoint()
{
if (notComputed & uFlag) {
u= c->GetPPoint(p);
notComputed &= ~uFlag;
}
return u;
}
inline const G4Point3D& G4CurvePoint::GetPoint()
{
if (notComputed & pFlag) {
p= c->GetPoint(u);
notComputed &= ~pFlag;
}
return p;
}
@@ -0,0 +1,65 @@
#ifndef included_G4CurveRayIntersection
#define included_G4CurveRayIntersection
#include "G4CurvePoint.hh"
#include "G4Ray.hh"
class G4CurveRayIntersection: public G4CurvePoint {
// at first, the interface similar to that of G4CurvePoint:
public:
G4CurveRayIntersection();
// must be followed by Init!
// only the distance is set (to infinity)
G4CurveRayIntersection(G4Curve& c0, const G4Ray& r0);
void Init(G4Curve& c0, const G4Ray& r0);
const G4Ray& GetRay() const;
void Reset();
void ResetPPoint(G4double u0);
void Reset(const G4Point3D& p0);
void Reset(G4double u0, const G4Point3D& p0);
void ResetDistance(G4double d0);
void Reset(G4double u0, G4double d0);
void Reset(const G4Point3D& p0, G4double d0);
void Reset(G4double u0, const G4Point3D& p0, G4double d0);
G4double GetPPoint();
const G4Point3D& GetPoint();
G4double GetDistance();
protected:
const G4Ray* r;
G4double d;
static const G4int dFlag;
// now the additional functionality
public:
void Update(G4CurveRayIntersection& is);
void UpdateWithPointOnCurve(G4CurveRayIntersection& is);
};
#include "G4CurveRayIntersection.icc"
#endif
@@ -0,0 +1,152 @@
inline void G4CurveRayIntersection::Init(G4Curve& c0, const G4Ray& r0)
{
c= &c0;
r= &r0;
d= kInfinity;
notComputed= allFlags;
}
inline G4CurveRayIntersection::G4CurveRayIntersection(G4Curve& c0, const G4Ray& r0)
{
Init(c0, r0);
}
inline G4CurveRayIntersection::G4CurveRayIntersection()
{
d= kInfinity;
}
//////////////////////////////////////////////////////////////////////////////
inline const G4Ray& G4CurveRayIntersection::GetRay() const
{
return *r;
}
//////////////////////////////////////////////////////////////////////////////
inline void G4CurveRayIntersection::Reset()
{
d= +kInfinity;
notComputed= uFlag|pFlag;
}
inline void G4CurveRayIntersection::ResetPPoint(G4double u0)
{
d= 0;
u= u0;
notComputed= pFlag|dFlag;
}
inline void G4CurveRayIntersection::Reset(const G4Point3D& p0)
{
d= 0;
p= p0;
notComputed= uFlag|dFlag;
}
inline void G4CurveRayIntersection::Reset(G4double u0, const G4Point3D& p0)
{
d= 0;
u= u0;
p= p0;
notComputed= dFlag;
}
inline void G4CurveRayIntersection::ResetDistance(G4double d0)
{
d= d0;
notComputed= uFlag|pFlag;
}
inline void G4CurveRayIntersection::Reset(G4double u0, G4double d0)
{
d= d0;
u= u0;
notComputed= pFlag;
}
inline void G4CurveRayIntersection::Reset(const G4Point3D& p0, G4double d0)
{
d= d0;
p= p0;
notComputed= uFlag;
}
inline void G4CurveRayIntersection::Reset(G4double u0, const G4Point3D& p0, G4double d0)
{
d= d0;
u= u0;
p= p0;
notComputed= 0;
}
//////////////////////////////////////////////////////////////////////////////
inline G4double G4CurveRayIntersection::GetPPoint()
{
if (notComputed & uFlag) {
if (notComputed & pFlag) {
p= r->GetPoint(d);
notComputed &= ~pFlag;
}
u= c->GetPPoint(p);
notComputed &= ~uFlag;
}
return u;
}
inline const G4Point3D& G4CurveRayIntersection::GetPoint()
{
if (notComputed & pFlag) {
if (notComputed & dFlag) {
p= c->GetPoint(u);
} else {
p= r->GetPoint(d);
}
notComputed &= ~pFlag;
}
return p;
}
inline G4double G4CurveRayIntersection::GetDistance()
{
if (notComputed & dFlag) {
if (notComputed & pFlag) {
p= c->GetPoint(u);
notComputed &= ~pFlag;
}
d= r->GetPPoint(p);
notComputed &= ~dFlag;
}
return d;
}
//////////////////////////////////////////////////////////////////////////////
inline void G4CurveRayIntersection::UpdateWithPointOnCurve(
G4CurveRayIntersection& is)
{
if (d!=kInfinity) {
// not the first intersection
G4double dTmp= is.GetDistance();
if (dTmp < kCarTolerance || GetDistance() <= dTmp) {
// not on ray or not the closest intersection
return;
}
}
// accepted
*this= is;
}
inline void G4CurveRayIntersection::Update(G4CurveRayIntersection& is)
{
if (c->IsBounded()) {
if (!c->IsPOn(is.GetPPoint())) {
return;
}
}
UpdateWithPointOnCurve(is);
}
@@ -0,0 +1,21 @@
#ifndef included_G4CurveVector
#define included_G4CurveVector
#include <rw/tpordvec.h>
#include "G4Curve.hh"
typedef RWTPtrOrderedVector<G4Curve> G4CurveVector;
#endif
@@ -0,0 +1,226 @@
// 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: G4CylindricalSurface.hh,v 2.5 1998/11/11 18:42:25 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
/* /usr/local/gismo/repo/geometry/G4CylindricalSurface.h,v 1.16 1993/12/30 02:14:08 rensing Exp */
// File: G4CylindricalSurface.h
// Author: Alan Breakstone
// Contents ---------------------------------------------------------
//
// G4CylindricalSurface
//
// Description:
//
// C++ header file for Gismo G4CylindricalSurface class, derived from Surface class.
// Uses the GmsListLink, G4ThreeVec, G4ThreeMat, Ray, Helix, and Surface
// classes.
//
// End --------------------------------------------------------------
// Interface Dependencies -------------------------------------------
#ifndef __CYLINDER_H
#define __CYLINDER_H
#include "G4Surface.hh"
class G4ThreeMat;
// End Interface Dependencies ---------------------------------------
// Class //
// class G4Surface;
class G4CylindricalSurface: public G4Surface
{
protected: // make available to derived classes
G4Vector3D axis; // direction of axis of G4CylindricalSurface
// (unit vector)
G4double radius; // radius of G4CylindricalSurface
public:
G4CylindricalSurface();
G4CylindricalSurface( const G4Vector3D& o,
const G4Vector3D& a,
G4double r );
virtual ~G4CylindricalSurface() {}
// G4CylindricalSurface( const G4CylindricalSurface& c ):
// G4Surface( c.origin )
// { axis = c.axis; radius = c.radius; }
//
G4String GetEntityType(){return G4String("Cylindrical_Surface");}
virtual char *NameOf() const { return "G4CylindricalSurface"; }
virtual void PrintOn( ostream& os = G4cout ) const;
int operator==( const G4CylindricalSurface& c )
{
return ( origin == c.origin &&
axis == c.axis &&
radius == c.radius );
}
virtual G4double HowNear( const G4Vector3D& x ) const;
// virtual G4double distanceAlongRay( int which_way, const G4Ray* ry,
// G4Vector3D& p ) const;
// virtual G4double distanceAlongHelix( int which_way,
// const Helix* hx, G4Vector3D& p ) const;
virtual G4Vector3D Normal( const G4Vector3D& p ) const;
virtual G4Vector3D SurfaceNormal( const G4Point3D& p ) const;
virtual int Inside( const G4Vector3D& x ) const;
virtual int WithinBoundary( const G4Vector3D& x ) const;
virtual G4double Scale() const;
// virtual void rotate( G4double alpha, G4double beta,
// G4double gamma, G4ThreeMat& m, int inverse );
// virtual void rotate( G4double alpha, G4double beta,
// G4double gamma, int inverse );
int Intersect(const G4Ray& ry);
G4Vector3D GetAxis() const { return axis; }
G4double GetRadius() const { return radius; }
void SetRadius( G4double r );
private:
// virtual G4double gropeAlongHelix( const Helix* hx ) const;
//
//
// Description of functions -----------------------------------------
//
// default constructor
//----->G4CylindricalSurface();
//
// Normal constructor:first argument is the origin of the G4CylindricalSurface
// second argument is the axis of the G4CylindricalSurface
// third argument is the radius of the G4CylindricalSurface
//----->G4CylindricalSurface( const G4Vector3D& o,
// const G4Vector3D& a, G4double r );
//
// destructor
//----->virtual ~G4CylindricalSurface() {}
//
// copy constructor
//----->G4CylindricalSurface( const G4CylindricalSurface& c ):
// Surface( c.origin )
//-----> { axis = c.axis; radius = c.radius; }
//
// function to return class name
//----->virtual char *NameOf() const { return "G4CylindricalSurface"; }
//
// printing function
//----->virtual void PrintOn( ostream& os = G4cout ) const;
//
// equality operator
//----->int operator==( const G4CylindricalSurface& c )
//-----> { return origin == c.origin && axis == c.axis
//-----> && radius == c.radius; }
//
// function which returns the distance from a point to a G4CylindricalSurface
// the (input) argument is the point x
// the distance is positive if the point is Inside,
// negative if it is outside
//----->virtual G4double HowNear( const G4Vector3D& x ) const;
//
// function which returns the distance along a Ray to enter or leave a
// G4CylindricalSurface.
// the first (input) argument is +1 to leave or -1 to enter
// the second (input) argument is a pointer to the Ray
// the third (output) argument returns the intersection point
//----->virtual G4double distanceAlongRay( int which_way, const Ray* ry,
//-----> G4Vector3D& p ) const;
//
// function which returns the distance along a Helix to enter or leave a
// G4CylindricalSurface.
// the first (input) argument is +1 to leave or -1 to enter
// the second (input) argument is a pointer to the Helix
// the third (output) argument returns the intersection point
//----->virtual G4double distanceAlongHelix( int which_way, const Helix* hx,
//-----> G4Vector3D& p ) const;
//
// function which returns the Normal unit vector to a
// G4CylindricalSurface at a point p
// on (or nearly on) the G4CylindricalSurface
//----->virtual G4Vector3D Normal( const G4Vector3D& p ) const;
//
// function which
// returns true (1) if the point x is Inside the G4CylindricalSurface,
// returns false (0) otherwise
//----->virtual int Inside( const G4Vector3D& x ) const;
//
// function overwritten by finite-sized derived classes which returns
// true (1) if the point x is within the boundary, false (0)
// otherwise.
// Since a G4CylindricalSurface is infinite in extent, the
// function will just check if the point is on the
// G4CylindricalSurface (to the surface precision).
//----->virtual int WithinBoundary( const G4Vector3D& x ) const;
//
// function overwritten by finite-sized derived classes which returns
// the radius, unless it is zero, in which case it returns
// the smallest non-zero dimension.
// Used for Scale-invariant tests of surface thickness.
//----->virtual G4double Scale() const;
//
// function to rotate the G4CylindricalSurface (4 input arguments)
// first about global x-axis by angle alpha,
// second about global y-axis by angle beta,
// third about global z-axis by angle gamma
// the angles are assumed to be given in radians
// the fourth (output) argument gives the calculated rotation
// matrix
// the fifth (input) argument is an integer flag which if
// non-zero reverses the order of the rotations
//----->virtual void rotate( G4double alpha, G4double beta,
//-----> G4double gamma, G4ThreeMat& m, int inverse );
//
// function to rotate the G4CylindricalSurface (4 input arguments)
// first about global x-axis by angle alpha,
// second about global y-axis by angle beta,
// third about global z-axis by angle gamma
// the angles are assumed to be given in radians
// the fourth (input) argument is an integer flag which if
// non-zero reverses the order of the rotations
//----->virtual void rotate( G4double alpha, G4double beta,
//-----> G4double gamma, int inverse );
//
// functions to return the axis and radius of the G4CylindricalSurface
//----->direction GetAxis() const { return axis; }
//----->G4double GetRadius() const { return radius; }
//
// function to change the radius of the G4CylindricalSurface
//----->void SetRadius( G4double r );
//
//
// Private function to use a crude technique to find the intersection
// of a Helix with a G4CylindricalSurface. It returns the turning angle along
// the Helix at which the intersection occurs or -1.0 if no intersection
// point is found. The argument to the call is the pointer to the Helix.
//----->virtual G4double gropeAlongHelix( const Helix* hx ) const;
};
#endif
@@ -0,0 +1,16 @@
// 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: G4ElementarySurface.hh,v 2.0 1998/07/02 16:58:32 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4Surface.hh"
class G4ElementarySurface: public G4Surface
{
G4Surface* Srf;
};
@@ -0,0 +1,67 @@
// 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: G4Ellipse.hh,v 2.4 1998/10/20 16:31:20 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __ELLIPTICCURVE_H
#define __ELLIPTICCURVE_H
#include "G4CircularCurve.hh"
class G4Ellipse : public G4Conic
{
public:
G4Ellipse();
~G4Ellipse();
virtual G4Curve* Project(const G4Transform3D& tr = G4Transform3D::Identity);
virtual G4bool Tangent(G4CurvePoint& cp, G4Vector3D& v);
virtual void IntersectRay2D(const G4Ray& ray, G4CurveRayIntersection& is);
virtual G4double GetPMax();
virtual G4Point3D GetPoint(G4double param);
virtual G4double GetPPoint(const G4Point3D& p);
// STEP
G4Ellipse(STEPentity& Ent, InstMgr&);
G4Ellipse(STEPentity& Ent);
// Get/Set for the geometric data
void Init(const G4Axis2Placement3D& position0,
G4double semiAxis10, G4double semiAxis20);
G4double GetSemiAxis1() const;
G4double GetSemiAxis2() const;
protected:
virtual void InitBounded();
private:
// geometric data
G4double semiAxis1;
G4double semiAxis2;
G4double ratioAxis2Axis1;
G4Transform3D toUnitCircle;
G4double forTangent; // -R_1^2/R_2^2
};
#include "G4Ellipse.icc"
#endif
@@ -0,0 +1,87 @@
inline void G4Ellipse::Init(const G4Axis2Placement3D& position0,
G4double semiAxis10, G4double semiAxis20) {
position= position0;
semiAxis1= semiAxis10;
semiAxis2= semiAxis20;
ratioAxis2Axis1= semiAxis2/semiAxis1;
SetBounds(0, 0);
// needed only for 2D ellipses
toUnitCircle = G4Scale3D(1/semiAxis1, 1/semiAxis2, 0)
* position.GetToPlacementCoordinates();
forTangent= -semiAxis1*semiAxis1/(semiAxis2*semiAxis2);
}
inline G4double G4Ellipse::GetSemiAxis1() const {
return semiAxis1;
}
inline G4double G4Ellipse::GetSemiAxis2() const {
return semiAxis2;
}
/////////////////////////////////////////////////////////////////////////////
inline G4double G4Ellipse::GetPMax() {
return twopi;
}
inline G4Point3D G4Ellipse::GetPoint(G4double param) {
param-= GetPShift();
return position.GetLocation()
+ semiAxis1*cos(param)*position.GetPX()
+ semiAxis2*sin(param)*position.GetPY();
}
inline G4double G4Ellipse::GetPPoint(const G4Point3D& pt) {
G4Point3D ptLocal= position.GetToPlacementCoordinates()*pt;
G4double angle= atan2(ptLocal.y(), ptLocal.x()*ratioAxis2Axis1);
G4double r= (angle<0)? angle+twopi: angle;
return r+GetPShift();
}
/////////////////////////////////////////////////////////////////////////////
#include "G4CurveRayIntersection.hh"
inline void G4Ellipse::IntersectRay2D(const G4Ray& ray,
G4CurveRayIntersection& is)
{
is.Init(*this, ray);
// transform s.t. the ellipse becomes the unit circle
// with the center at the origin
// 2D operations would be faster
G4Point3D s= toUnitCircle*ray.GetStart();
G4Vector3D d= toUnitCircle*ray.GetDir();
// solve (s+i*t)^2 = 1 for i (the distance)
G4double sd= s*d;
G4double dd= d.mag2(); // never 0
G4double ss= s.mag2();
G4double discr= sd*sd-dd*(ss-1);
if (discr >= 0) {
// 2 intersections (maybe 1, but this case is rare)
G4double sqrtdiscr= sqrt(discr);
// find the smallest positive i
G4double i= -sd-sqrtdiscr;
if (i<kCarTolerance) {
i= -sd+sqrtdiscr;
if (i<kCarTolerance) {
return;
}
}
i/= dd;
G4CurveRayIntersection isTmp(*this, ray);
isTmp.ResetDistance(i);
is.Update(isTmp);
}
}
@@ -0,0 +1,172 @@
// 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: G4FConicalSurface.hh,v 2.8 1998/12/03 17:21:46 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __FCONIC_H
#define __FCONIC_H
#include "G4PointRat.hh"
#include "G4Axis2Placement3D.hh"
#include "G4Surface.hh"
// Position.axis|
// |
// -- ---|--- small_radius
// l | / | \
// e | / | \
// n | / | \
// g | / | \
// t | / | \
// h | / | \
// -- ---------|--------- large_radius
// Position
class G4FConicalSurface: public G4Surface //: public G4ConicalSurface
{
protected:
G4double length; // length of G4FConicalSurface
G4double small_radius;// small radius of G4FConicalSurface, can be zero
G4double large_radius;// large radius of G4FConicalSurface, must be
// greater than the small radius
// Note that the angle of the G4ConicalSurface is
// calculated from these three quantities.
G4Axis2Placement3D Position;
// Add by L. Broglia
G4double tan_angle;
public:
G4FConicalSurface() //: G4ConicalSurface()
{
length = 1.0;
small_radius = 0.0;
large_radius = 1.0;
// Add by L. Broglia
tan_angle = (large_radius-small_radius)/length;
}
G4FConicalSurface( const G4Point3D& o, const G4Vector3D& a,
G4double l, G4double sr, G4double lr );
G4FConicalSurface( const G4FConicalSurface& c );
~G4FConicalSurface() {}
virtual G4Vector3D SurfaceNormal( const G4Point3D& p ) const;
virtual int Inside( const G4Vector3D& x ) const;
G4String GetEntityType(){return G4String("FConical_Surface");}
// STEP additions
virtual char *Name() const { return "G4FConicalSurface"; }
virtual void PrintOn( ostream& os = G4cout ) const;
int operator==( const G4FConicalSurface& c );
int Intersect( const G4Ray& ry ) ;
void CalcBBox();
// Add by L. Broglia
virtual G4double HowNear( const G4Vector3D& x ) const;
inline void Comp( G4Vector3D& v, G4Point3D& min , G4Point3D& max)
{
if(v.x() > max.x() ) max.setX(v.x());
if(v.y() > max.y() ) max.setY(v.y());
if(v.z() > max.z() ) max.setZ(v.z());
if(v.x() < min.x()) min.setX(v.x());
if(v.y() < min.y()) min.setY(v.y());
if(v.z() < min.z()) min.setZ(v.z());
}
virtual int WithinBoundary( const G4Vector3D& x ) const;
virtual G4double Scale() const;
virtual G4double Area() const;
virtual void resize( G4double l, G4double sr, G4double lr );
G4double GetLength() const { return length; }
G4double GetSmallRadius() const { return small_radius; }
G4double GetLargeRadius() const { return large_radius; }
G4double GetTan_Angle() const { return tan_angle; }
// Description of functions -----------------------------------------
//
// default constructor
//----->G4FConicalSurface() : G4ConicalSurface() { length = 1.0;
//-----> small_radius = 0.0;
//-----> large_radius = 1.0; }
//
// Normal constructor: first argument is the origin of the G4FConicalSurface
// second argument is the axis of the G4FConicalSurface
// third argument is the length of the G4FConicalSurface
// fourth argument is the small radius of the
// G4FConicalSurface
// fifth argument is the large radius of the
// G4FConicalSurface
//----->G4FConicalSurface( const G4ThreeVec& o, const G4ThreeVec& a,
//-----> G4double l, G4double sr, G4double lr );
//
// destructor
//----->virtual ~G4FConicalSurface() {}
//
// copy constructor
//----->G4FConicalSurface( const G4FConicalSurface& c );
//
// function to return class name
//----->virtual char *NameOf() const { return "G4FConicalSurface"; }
//
// printing function
//----->virtual void PrintOn( ostream& os = G4cout ) const;
//
// equality operator
//----->int operator==( const G4FConicalSurface& c );
//
// function which returns true (1) if the point x is within the boundary
// returns false (0) otherwise
//----->virtual int WithinBoundary( const G4ThreeVec& x ) const;
//
// function to return the size of a G4FConicalSurface.
// Used for Scale-invariant tests of surface thickness.
// If the small radius is zero, returns the large radius.
//----->virtual G4double Scale() const;
//
// function to calculate the Area of a G4FConicalSurface
//----->virtual G4double Area() const;
//
// function to change the radii and length of the G4FConicalSurface
// the first (input) argument is the new length
// the second (input) argument is the new small radius
// the third (input) argument is the new large radius
//----->virtual void resize( G4double l, G4double sr, G4double lr );
//
// functions to return the dimensions of the G4FConicalSurface
//----->G4double GetLength() const { return length; }
//----->G4double GetSmallRadius() const { return small_radius; }
//----->G4double GetLargeRadius() const { return large_radius; }
};
#endif
@@ -0,0 +1,141 @@
// 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: G4FCylindricalSurface.hh,v 2.7 1998/12/10 11:00:52 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __FCYLINDER_H
#define __FCYLINDER_H
#include "G4FConicalSurface.hh"
//#include "G4CylindricalSurface.hh"
class G4FCylindricalSurface: public G4Surface
{
protected:
G4Axis2Placement3D Position;
G4double radius;
G4double length;
public:
// default constructor
G4FCylindricalSurface()
{
length = 1.0;
}
// Normal constructor:
// first argument is the origin of the G4FCylindricalSurface
// second argument is the axis of the G4FCylindricalSurface
// third argument is the radius of the G4FCylindricalSurface
// fourth argument is the length of the G4FCylindricalSurface
G4FCylindricalSurface(const G4Point3D& o,
const G4Vector3D& a,
const G4double r,
const G4double l );
// destructor
~G4FCylindricalSurface() {}
// copy constructor
G4FCylindricalSurface(const G4FCylindricalSurface& c);
virtual G4Vector3D SurfaceNormal( const G4Point3D& p ) const;
virtual int Inside( const G4Vector3D& x ) const;
//
G4String GetEntityType()
{
return G4String("Cylindrical_Surface");
}
//
int Intersect(const G4Ray&);
/* L. Broglia
this function is already declared in G4Surface
G4double ClosestDistanceToPoint(const G4Vector3D& Pt)
{
return HowNear(Pt);
}
*/
virtual G4double HowNear( const G4Vector3D& x ) const;
//
void CalcBBox();
//
inline void Comp( G4Vector3D& v, G4Point3D& min , G4Point3D& max)
{
if(v.x() > max.x()) max.setX(v.x());
if(v.y() > max.y()) max.setY(v.y());
if(v.z() > max.z()) max.setZ(v.z());
if(v.x() < min.x()) min.setX(v.x());
if(v.y() < min.y()) min.setY(v.y());
if(v.z() < min.z()) min.setZ(v.z());
}
// function to return class name
virtual char *NameOf() const
{
return "G4FCylindricalSurface";
}
// printing function
virtual void PrintOn( ostream& os = G4cout ) const;
// equality operator
int operator==( const G4FCylindricalSurface& c );
// function which returns true (1) if the point x is within the boundary
// returns false (0) otherwise
virtual int WithinBoundary( const G4Vector3D& x ) const;
// function to return the radius of a G4FCylindricalSurface.
// Used for Scale-invariant tests of surface thickness.
// If the radius is zero, returns the length.
virtual G4double Scale() const;
// function to calculate the Area of a G4FCylindricalSurface
virtual G4double Area() const
{
return ( 2.0 * M_PI * radius * length );
}
// function to change the radius and length of the G4FCylindricalSurface
// the first (input) argument is the new radius
// the second (input) argument is the new length
virtual void resize( G4double r, G4double l );
// function to return the length of the G4FCylindricalSurface
G4double GetLength() const
{
return length;
}
G4Vector3D GetAxis() const { return Position.GetAxis(); }
G4double GetRadius() const { return radius; }
void SetRadius( G4double r );
};
#endif
@@ -0,0 +1,141 @@
// 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: G4FPlane.hh,v 2.15 1998/12/09 14:49:17 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
// L. Broglia
//
// A G4FPlane is a plane created by 3 points or by an origin, an axis and
// a direction. The plane created is a G4Plane, where his coefficient a, b,
// c and d are stored. Be carreful that the equation of the plane is :
// ax + by + cz = d
//
// This class contain 2 intersection functions :
// - closest intersection
// - intersection by a ray
//
//
#ifndef __PLANESURFACE_H
#define __PLANESURFACE_H
#include "G4Axis2Placement3D.hh"
#include "G4Plane.hh"
#include "G4Surface.hh"
class G4FPlane:public G4Surface
{
public:
// Default constructor - destructor
G4FPlane();
~G4FPlane() { delete NormalX; }
// Normal constructor
G4FPlane( const G4Vector3D& direction,
const G4Vector3D& axis ,
const G4Point3D& Pt0 );
// Constructor used by G4BREPSolidBox and G4BREPSolidPolyhedra
G4FPlane(const G4Point3DVector* pVec,
const G4Point3DVector* iVec= 0);
// hit point of the ray on the surface
G4Point3D hitpoint;
// calculate the intersection of the plane and a ray
int Intersect(const G4Ray& G4Rayref);
//int Evaluate(const G4Ray& ray) { return Intersect(ray); }
// Calculate bounding box
void CalcBBox();
// Calculate the projection of the plane
void Project();
// return the type, used in G4BREPSolid
inline int MyType()const { return 1; }
// return the convexity or not
int GetConvex() { return Convex; }
// is convex ?
int IsConvex();
// deactive, used in G4Surface
inline void Deactivate() { active=0; }
// get the number of the points on the surface boundary
inline int GetNumberOfPoints()
{
return (surfaceBoundary.GetNumberOfPoints());
}
// get the location point
G4Point3D GetSrfPoint() { return pplace.GetLocation(); }
// get a surface boundary point
inline const G4Point3D& GetPoint(const int Count)
{
return surfaceBoundary.GetPoint(Count);
}
void CalcNormal();
// return the normal, used in BREPSolid
G4Ray* Norm() { return NormalX; }
G4Vector3D SurfaceNormal(const G4Point3D& Pt)const
{
return NormalX->GetDir();
}
virtual char *Name() const { return "G4FPlane"; }
G4double ClosestDistanceToPoint(const G4Point3D& Pt);
// L. Broglia : create this Surface function
virtual G4double HowNear( const G4Vector3D& x ) const ;
inline G4Axis2Placement3D GetPplace() const { return pplace; }
inline G4Plane GetPplane() const { return Pl; }
private:
G4Axis2Placement3D pplace;
G4Plane Pl;
G4Ray *NormalX;
int Convex;
G4SurfaceBoundary* projectedBoundary;
inline int Sign(const G4double a)
{
register int i=1;
if(a<0)
i= -1;
return i;
}
protected:
// P. Urban
virtual void InitBounded();
};
#endif
@@ -0,0 +1,42 @@
// 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: G4Globals.hh,v 2.1 1998/10/20 16:31:22 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
/* /usr/local/gismo/repo/support/globals.h,v 1.8 1994/04/18 18:29:03 atwood Exp */
// File: globals.h
// Author: Alan Breakstone
//
// Description
//
// Defines global variables and declarations for Gismo
//
//
#ifndef __GLOBALS_H
#define __GLOBALS_H
//
// Define a C preprocessor constant for a Scale factor to apply to
// various dimensionless tests in the geometry routines which test
// if a point is on a surface. This number is an effective thickness
// of a surface divided by a relevant dimension, such as the radius of
// a cylinder. The default value is 0.0001.
#define SURFACE_PRECISION 0.0001
//
// Define a C preprocessor constant for the maximum number of turns
// allowed for a Helix, which is used in some of the geometry routines
// to limit the size of for or while loops. The default value is 50.
#define HELIX_MAX_TURNS 50
// Define some geometric constants of use
// These should be gotten via math.h ... see M_PI etc....
//#define PI 3.14159265358979323846
//#define TWO_PI 6.2831853071795862
#endif
@@ -0,0 +1,84 @@
// 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: G4Hyperbola.hh,v 2.4 1998/10/20 16:31:23 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __HYPERBOLICCURVE_H
#define __HYPERBOLICCURVE_H
#include "G4Conic.hh"
class G4Hyperbola : public G4Conic
{
public:
G4Hyperbola();
~G4Hyperbola();
virtual G4Curve* Project(const G4Transform3D& tr= G4Transform3D::Identity);
virtual G4bool Tangent(G4CurvePoint& cp, G4Vector3D& v);
virtual void IntersectRay2D(const G4Ray& ray, G4CurveRayIntersection& is);
virtual G4double GetPMax();
virtual G4Point3D GetPoint(G4double param);
virtual G4double GetPPoint(const G4Point3D& p);
// STEP
G4Hyperbola(STEPentity& Ent);
G4Hyperbola(STEPentity& Ent, InstMgr&);
//G4Hyperbola(G4Point3d, G4Point3d, G4Point3d,
// G4Point3d,G4double, G4double );
//G4Point3d EvaluateByParameterValue(const G4double u);
//G4Point3d GetBoundMax();
//G4Point3d GetBoundMin();
// Get/Set for the geometric data
void Init(G4Axis2Placement3D position0,
G4double semiAxis0, G4double semiImagAxis0);
G4double GetSemiAxis() const;
G4double GetSemiImagAxis() const;
protected:
virtual void InitBounded();
private:
int Inside(const G4Point3D&, const G4Ray&);
/* L. Broglia
G4Point3d Focus1;
G4Point3d Focus2;
G4Point2d ProjFocus1;
G4Point2d ProjFocus2;
*/
G4Point3D Focus1;
G4Point3D Focus2;
G4Point3D ProjFocus1;
G4Point3D ProjFocus2;
// geometric data
G4double semiAxis;
G4double semiImagAxis;
G4double ratioAxisImagAxis;
G4Transform3D toUnitHyperbola;
G4double forTangent; // R_1^2/R_2^2
};
#include "G4Hyperbola.icc"
#endif
@@ -0,0 +1,98 @@
inline void G4Hyperbola::Init(G4Axis2Placement3D position0,
G4double semiAxis0, G4double semiImagAxis0) {
position= position0;
semiAxis= semiAxis0;
semiImagAxis= semiImagAxis0;
ratioAxisImagAxis= semiAxis/semiImagAxis;
// needed only for 2D hyperbolas
toUnitHyperbola = G4Scale3D(1/semiAxis, 1/semiImagAxis, 0)
* position.GetToPlacementCoordinates();
forTangent= semiAxis*semiAxis/(semiImagAxis*semiImagAxis);
}
inline G4double G4Hyperbola::GetSemiAxis() const {
return semiAxis;
}
inline G4double G4Hyperbola::GetSemiImagAxis() const {
return semiImagAxis;
}
//////////////////////////////////////////////////////////////////////////////
inline G4double G4Hyperbola::GetPMax() {
return -1;
}
inline G4Point3D G4Hyperbola::GetPoint(G4double param) {
return position.GetLocation()
+ semiAxis*cosh(param)*position.GetPX()
+ semiImagAxis*sinh(param)*position.GetPY();
}
inline G4double G4Hyperbola::GetPPoint(const G4Point3D& pt) {
G4Point3D ptLocal= position.GetToPlacementCoordinates()*pt;
G4double xval= ptLocal.y()/ptLocal.x()*ratioAxisImagAxis;
#ifdef WIN32
G4double ppoint= 0.5*log((1+xval)/(1-xval));
#else
G4double ppoint= atanh(xval);
#endif
return ppoint;
}
/////////////////////////////////////////////////////////////////////////////
#include "G4CurveRayIntersection.hh"
inline void G4Hyperbola::IntersectRay2D(const G4Ray& ray,
G4CurveRayIntersection& is)
{
is.Init(*this, ray);
// similar to G4Ellipse::IntersectRay2D
// 2D operations would be faster
G4Point3D s= toUnitHyperbola*ray.GetStart();
G4Vector3D d= toUnitHyperbola*ray.GetDir();
// solve (s+i*t)^2 = 1 for i (the distance)
G4double sd= s.x()*d.x()-s.y()*d.y();
G4double dd= d.x()*d.x()-d.y()*d.y(); // can be 0
G4double ss= s.x()*s.x()-s.y()*s.y();
if (abs(dd) < kCarTolerance*kCarTolerance) {
// coeff of i^2 == 0
G4double i= (1-ss)/(2*sd);
G4CurveRayIntersection isTmp(*this, ray);
isTmp.ResetDistance(i);
is.Update(isTmp);
return;
}
G4double discr= sd*sd-dd*(ss-1);
if (discr >= 0) {
// 2 intersections (maybe 1, but this case is rare)
G4double sqrtdiscr= sqrt(discr);
// find the smallest positive i
G4double i= -sd-sqrtdiscr;
if (i<kCarTolerance) {
i= -sd+sqrtdiscr;
if (i<kCarTolerance) {
return;
}
}
i/= dd;
G4CurveRayIntersection isTmp(*this, ray);
isTmp.ResetDistance(i);
is.Update(isTmp);
}
}
@@ -0,0 +1,111 @@
// 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: G4KnotVector.hh,v 2.4 1998/12/11 15:38:26 stesting Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __KNOTVECTOR_H
#define __KNOTVECTOR_H
#include <math.h>
#include "STEPaggregate.h"
#include "geomdefs.hh"
class G4KnotVector
{
public:
G4KnotVector();
G4KnotVector(const int Size, const int* MultiList, STEPaggregate& Aggr);
G4KnotVector(const int Size, STEPaggregate& Aggr);
G4KnotVector(const int sz);
G4KnotVector(const G4KnotVector& old_kv);
~G4KnotVector();
// Gets number of knots
inline int GetSize()const {return k_size;};
// Retrieves knot from knot vector index knot_number
inline G4double GetKnot(const int knot_number){return knots[knot_number];}
// Sets knot vector index knot_number to value
inline void PutKnot(const int knot_number, const G4double value)
{
knots[knot_number]=value;
}
// Adds the internal knots to the new knot vector
G4KnotVector* MultiplyKnotVector( const int num, const G4double value);
// Creates the new vector by merging the old vector with the
// knots in the vector knots_to_add
G4double* MergeKnotVector( const G4double *knots_to_add, const int add_size);
// Finds out how many Times val occurs in the knot vector
int CheckKnotVector(const G4double val);
// Copies either the first half or the second half of
// the new knot vector values to the knot vectors of the
// new surfaces created by splitting
void ExtractKnotVector( G4KnotVector* kv, const int upper, const int lower);
// Searches the knot vector for the value and returns the index
// This is used in the Evaluation of the intersection to find
// out between which knots the intersection point is on the b-spline
// surface
int GetKnotIndex(G4double k_value, const int order);
private:
// Number of knots
int k_size;
// Knot vector
G4double *knots;
inline G4double ApxEq(const G4double x,const G4double y)
{
return (fabs(x - y) < kCarTolerance);
}
};
#endif
@@ -0,0 +1,58 @@
// 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: G4Line.hh,v 2.6 1998/11/24 16:41:14 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __LINE_H
#define __LINE_H
#include "G4Curve.hh"
class G4Line : public G4Curve
{
public:
G4Line ();
virtual ~G4Line ();
virtual G4Curve* Project(const G4Transform3D& tr = G4Transform3D::Identity);
virtual G4bool Tangent(G4CurvePoint& cp, G4Vector3D& vec);
virtual void IntersectRay2D(const G4Ray& ray, G4CurveRayIntersection& is);
virtual G4double GetPMax();
virtual G4Point3D GetPoint(G4double param);
virtual G4double GetPPoint(const G4Point3D& pt);
// Get/Set for the geometric data
void Init(const G4Point3D& pnt0, const G4Vector3D& dir0);
G4Point3D GetPnt() const;
G4Vector3D GetDir() const;
protected:
virtual void InitBounded();
private:
// For the Inside function
//inline int Sign(G4double a, G4double b){return((a>=0&&b>=0)||(a<0&&b<0));}
// geometric data
G4Point3D pnt;
G4Vector3D dir;
G4Vector3D invDir; // dir / |dir|^2 always
G4Vector3D v; // dir / |dir| always
};
#include "G4Line.icc"
#endif
@@ -0,0 +1,75 @@
inline G4double G4Line::GetPMax() { return -1; }
inline G4Point3D G4Line::GetPoint(G4double param) { return pnt+param*dir; }
inline G4double G4Line::GetPPoint(const G4Point3D& pt)
{
return (pt-pnt)*invDir;
}
////////////////////////////////////////////////////////////////////////////
inline void G4Line::Init(const G4Point3D& pnt0, const G4Vector3D& dir0) {
pnt= pnt0;
dir= dir0;
invDir= dir*(1/dir.mag2());
v= dir.unit();
}
inline G4Point3D G4Line::GetPnt() const {
return pnt;
}
inline G4Vector3D G4Line::GetDir() const {
return dir;
}
///////////////////////////////////////////////////////////////////////////
inline void G4Line::InitBounded() {
bBox.Init(GetStart(), GetEnd());
}
///////////////////////////////////////////////////////////////////////////
#include "G4CurveRayIntersection.hh"
inline void G4Line::IntersectRay2D(const G4Ray& ray,
G4CurveRayIntersection& is)
{
is.Init(*this, ray);
G4CurveRayIntersection isTmp(*this, ray);
const G4Point3D& s= ray.GetStart();
const G4Vector3D& d= ray.GetDir();
G4double num= (s.x()-pnt.x())*v.y()-(s.y()-pnt.y())*v.x();
G4double denom= d.y()*v.x()-d.x()*v.y();
if (denom < kAngTolerance) {
if (num < kCarTolerance) {
// identical lines
isTmp.ResetDistance(kCarTolerance);
is.Update(isTmp);
isTmp.Reset(GetPStart(), GetStart());
is.UpdateWithPointOnCurve(isTmp);
isTmp.Reset(GetPEnd(), GetEnd());
is.UpdateWithPointOnCurve(isTmp);
} else {
// parallel lines
}
} else {
// properly intersecting lines
isTmp.ResetDistance(num/denom);
is.Update(isTmp);
}
}
@@ -0,0 +1,88 @@
// 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: G4NISTStepReader.hh,v 2.2 1998/10/20 16:31:25 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef G4NISTSTEPFILEREADER_HH
#define G4NISTSTEPFILEREADER_HH
#include "G4StepFileReader.hh"
#include "STEPfile.h" /* STEPfile class and others used by SCL */
#include "sdai.h" /* definitions of for EXRPESS built-in types */
#include "schema.h"
#include "instmgr.h"
//#include "G4StepFile.h" /* or suitable substitute */
#ifdef __O3DB__
#include <OpenOODB.h>
#endif
#include "instmgr.h"
#include "Registry.h"
//#include "STEPfile.h"
#include "STEPentity.h"
#include "STEPaggregate.h"
///////////////////////////////////////////////////////////////////////////////
// Function defined as a stub (necessary to use the scl)
// The purpose of this function is to allow the DisplayNode object to delete
// an object that it knows nothing about. It was made generic so that the scl
// could be used with any display toolkit.
//
// This function is called by the DisplayNode object
// This function needs to be defined outside the SCL libraries. It needs to do
// two things:
// 1) unmap the StepEntityEditor window if it is mapped.
// 2) delete the StepEntityEditor window
// To see an example of this function used with the Data Probe look in
// ../clprobe-ui/StepEntEditor.cc Look at DeleteSEE() and ~StepEntityEditor().
///////////////////////////////////////////////////////////////////////////////
// this function illustrates a good way to Generate and assign file identifiers
/*
void AssignFileId (STEPentity *se, InstMgr& instance_list)
{
int fId = instance_list.MaxFileId() + 1;
se->STEPfile_id = (fId > 0) ? fId : 1;
}
*/
// define this to be the name of the display window object for
// STEP entity instance editing or define your own.
// This is only needed as there's a link to these from the toolkit
class STEPentity;
class InstMgr;
class StepEntityEditor
{
public:
StepEntityEditor() {};
~StepEntityEditor() {};
};
extern void AssignFileId (STEPentity *se, InstMgr& instance_list);
extern STEPentity *GetEntity (STEPnode *node, InstMgr *im);
// This needs to be defined for the STEPfile reader
extern void SchemaInit (Registry &);
class G4NISTStepReader: public G4StepFileReader
{
public:
void ReadSTEPFile(G4String);
void SaveSTEPFile();
void UpdateSTEPFile();
InstMgr GetInstanceManager(){return InstanceList;}
private:
InstMgr InstanceList;
};
#endif
@@ -0,0 +1,85 @@
// 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: G4OsloMatrix.hh,v 2.2 1998/10/20 16:31:26 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __G4OsloMatrix_h
#define __G4OsloMatrix_h 1
#include "G4KnotVector.hh"
class G4OsloMatrix
{
public:
G4OsloMatrix()
{
o_vec = (G4KnotVector*)0;
next = (G4OsloMatrix*)0;
};
G4OsloMatrix(int vec_size, int offsetparam, int osizeparam)
{
next = (G4OsloMatrix*)0;
o_vec = new G4KnotVector(vec_size);
offset = offsetparam;
osize = osizeparam;
}
~G4OsloMatrix() { delete o_vec; }
G4OsloMatrix * next;
int offset;
int osize;
G4KnotVector *o_vec;
};
class Matrix
{
public:
// Constructors
Matrix();
Matrix(int, int);
Matrix(G4double[]);
// Destructor
~Matrix();
inline int GetRows() const { return nr; }
inline int GetCols() const { return nc; }
// Puts control point into matrix location (i,j)
inline void put(int i,int j, G4double x){ data[i*nc+j]=x; }
// Retrieves control point from matrix location (i,j)
inline G4double get(int i, int j) const
{
return data[i*nc+j];
}
private:
G4double* data;
int nr, nc;
};
#endif
@@ -0,0 +1,64 @@
// 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: G4Parabola.hh,v 2.3 1998/10/20 16:31:26 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __PARABOLICCURVE_H
#define __PARABOLICCURVE_H
#include "G4Conic.hh"
class G4Parabola : public G4Conic
{
public:
G4Parabola();
~G4Parabola();
virtual G4Curve* Project(const G4Transform3D& tr = G4Transform3D::Identity);
virtual G4bool Tangent(G4CurvePoint& cp, G4Vector3D& v);
virtual void IntersectRay2D(const G4Ray& ray, G4CurveRayIntersection& is);
virtual G4double GetPMax();
virtual G4Point3D GetPoint(G4double param);
virtual G4double GetPPoint(const G4Point3D& p);
// STEP
G4Parabola(STEPentity& Ent);
G4Parabola(STEPentity& Ent, InstMgr&);
//G4Parabola(G4Point3d, G4Point3d, G4double );
//G4Point3d EvaluateByParameterValue(const G4double u);
//G4Point3d GetBoundMax();
//G4Point3d GetBoundMin();
// Get/Set for the geometric data
void Init(const G4Axis2Placement3D& position0, G4double focalDist0);
double GetFocalDist() const;
protected:
virtual void InitBounded();
private:
// geometric data
double focalDist;
// for the intersection
G4Point3D F;
G4Point3D L0;
};
#include "G4Parabola.icc"
#endif
@@ -0,0 +1,70 @@
inline void G4Parabola::Init(const G4Axis2Placement3D& position0,
G4double focalDist0) {
position= position0;
focalDist= focalDist0;
// focus
F= position.GetLocation()+focalDist*position.GetPX();
// line
L0= position.GetLocation()-focalDist*position.GetPX();
//l= position.GetPY();
}
inline double G4Parabola::GetFocalDist() const {
return focalDist;
}
//////////////////////////////////////////////////////////////////////////////
inline G4double G4Parabola::GetPMax() {
return -1;
}
inline G4Point3D G4Parabola::GetPoint(G4double param) {
return position.GetLocation()
+ focalDist* (param*param*position.GetPX() + 2*param*position.GetPY());
}
inline G4double G4Parabola::GetPPoint(const G4Point3D& pt) {
G4Point3D ptLocal= position.GetToPlacementCoordinates()*pt;
return ptLocal.y()/(2*focalDist);
}
//////////////////////////////////////////////////////////////////////////////
#include "G4CurveRayIntersection.hh"
inline void G4Parabola::IntersectRay2D(const G4Ray& ray,
G4CurveRayIntersection& is)
{
is.Init(*this, ray);
const G4Point3D& S= ray.GetStart();
const G4Vector3D& d= ray.GetDir();
const G4Vector3D& l= position.GetPY();
// a == 1
G4Vector3D SMinusF= S-F;
G4double bHalf= SMinusF*d - (d.x()*l.y()-d.y()*l.x());
G4double c= SMinusF.mag2() + ( (S.x()-L0.x())*l.y() - (S.y()-L0.y())*l.x() );
G4double discr= bHalf*bHalf-c;
if (discr >= 0) {
// 2 intersections (maybe 1, but this case is rare)
G4double sqrtdiscr= sqrt(discr);
// find the smallest positive i
G4double i= -bHalf-sqrtdiscr;
if (i<kCarTolerance) {
i= -bHalf+sqrtdiscr;
if (i<kCarTolerance) {
return;
}
}
G4CurveRayIntersection isTmp(*this, ray);
isTmp.ResetDistance(i);
is.Update(isTmp);
}
}
@@ -0,0 +1,47 @@
// 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: G4PlacedSolid.hh,v 2.3 1998/11/11 11:20:05 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef G4PLACEDSOLID_HH
#define G4PLACEDSOLID_HH
#include "G4BREPSolid.hh"
class G4PlacedSolid
{
public:
G4PlacedSolid();
G4PlacedSolid(G4BREPSolid*, G4Axis2Placement3D* =0);
~G4PlacedSolid();
G4VSolid* GetSolid() { return solid; }
HepRotation* GetRotation() { return solidRotation; }
G4ThreeVector* GetTranslation() { return solidTranslation; }
G4bool operator==(const G4PlacedSolid& ps) const
{
return (this==&ps) ? true : false;
}
private:
G4BREPSolid* solid;
HepRotation* solidRotation;
G4ThreeVector* solidTranslation;
};
#endif
@@ -0,0 +1,9 @@
#ifndef included_G4PlacementVector
#define included_G4PlacementVector
#include <rw/tpordvec.h>
#include "G4Axis2Placement3D.hh"
typedef RWTPtrOrderedVector<G4Axis2Placement3D> G4PlacementVector;
#endif
@@ -0,0 +1,21 @@
// 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: G4Plane.hh,v 2.1 1998/10/20 16:31:28 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __G4Plane
#define __G4Plane
#include "globals.hh"
class G4Plane
{
public:
G4Plane(){a=b=c=d=0;}
G4double a,b,c,d;
};
#endif
@@ -0,0 +1,19 @@
// 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: G4Point3DVector.hh,v 2.3 1998/10/20 16:31:29 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef included_G4Point3DVector
#define included_G4Point3DVector
#include <rw/tvvector.h>
#include "G4Point3D.hh"
typedef RWTValVector<G4Point3D> G4Point3DVector;
#endif
@@ -0,0 +1,125 @@
// 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: G4PointRat.hh,v 2.5 1998/11/13 11:29:09 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Modif 8 oct 98 : A.Floquet
// G4PointRat datas are made of
// . a point 3D
// . a additional value : the scale factor which is set to 1 by default
//
#ifndef __G4POINT_RAT
#define __G4POINT_RAT
#include "G4Point3D.hh"
#include "G4Plane3D.hh"
// L. Broglia
// Before included in G4Point.hh
#include "STEPentity.h"
#include "STEPaggregate.h"
#include "STEPcomplex.h"
#include "instmgr.h"
#include "G4Plane.hh"
#include "G4UVHit.hh"
#define SQRT_SMALL_FASTF 1.0e-18
#define SMALL SQRT_SMALL_FASTF
#define ROW 0
#define COL 1
const G4double INFINITY = 9.0e+99;
const G4Point3D PINFINITY(INFINITY, INFINITY, INFINITY );
class G4Plane;
class G4PointRat
{
public:
G4PointRat();
G4PointRat(const G4Point3D&);
~G4PointRat();
void CopyRationalValue(const RealNode& Rnode);
int GetType(void)const { return 4; } // This function should be removed
// if calls to this are also removed
void operator=(const G4Point3D&);
void operator=(const G4PointRat&);
inline G4double x() const {return pt3d.x();}
inline void setX (const G4double Value) { pt3d.setX ( Value );}
inline G4double y() const {return pt3d.y();}
inline void setY (const G4double Value) { pt3d.setY ( Value );}
inline G4double z() const {return pt3d.z();}
inline void setZ (const G4double Value) { pt3d.setZ ( Value );}
inline G4double w() const {return s;}
inline void setW(const G4double Value) {s=Value;}
inline G4Point3D pt() const { return pt3d; }
inline G4double PlaneDistance(const G4Plane3D& Pl)
{
return ((Pl.a()*pt3d.x() + Pl.b()*pt3d.y() + Pl.c()*pt3d.z()) - Pl.d());
}
private:
G4Point3D pt3d;
G4double s;
public :
// L. Broglia
/*
inline G4Point3D Min(const G4Point3D& p)
{
if(pt3d.x() < p.x()) pt3d.setX(p.x());
if(pt3d.y() < p.y()) pt3d.setY(p.y());
if(pt3d.z() < p.z()) pt3d.setZ(p.z());
}
inline G4Point3D Max(const G4Point3D& p)
{
if(pt3d.x() > p.x()) pt3d.setX(p.x());
if(pt3d.y() > p.y()) pt3d.setY(p.y());
if(pt3d.z() > p.z()) pt3d.setZ(p.z());
}
*/
/*
inline G4Point3D Min(const G4Vector3D& v)
{
if(pt3d.x() < v.x()) pt3d.setX(v.x());
if(pt3d.y() < v.y()) pt3d.setY(v.y());
if(pt3d.z() < v.z()) pt3d.setZ(v.z());
}
inline G4Point3D Max(const G4Vector3D& v)
{
if(pt3d.x() > v.x()) pt3d.setX(v.x());
if(pt3d.y() > v.y()) pt3d.setY(v.y());
if(pt3d.z() > v.z()) pt3d.setZ(v.z());
}
*/
};
#endif
@@ -0,0 +1,94 @@
// 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: G4ProjectedSurface.hh,v 2.3 1998/10/20 16:31:30 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __G4ProjectedSurface_h
#define __G4ProjectedSurface_h 1
#include "G4BezierSurface.hh"
class G4ProjectedSurface : public G4Surface
{
friend class G4BSplineSurface;
friend void CopySurface(G4ProjectedSurface& proj);
public:
//Default constructor
G4ProjectedSurface();
~G4ProjectedSurface();
// Copy-constructor
G4ProjectedSurface(const G4ProjectedSurface &tmp);
// Test variables
static int Splits;
void CalcBBox();
G4ControlPoints *ctl_points;
virtual G4Vector3D SurfaceNormal(const G4Point3D& Pt)const
{
return G4Vector3D(0,0,0);
}
private:
short dir;
G4KnotVector *u_knots;
G4KnotVector *v_knots;
void CopySurface();
void ConvertToBezier ( G4SurfaceList&, G4SurfaceList&);
inline int GetOrder(int direction)
{
return order[direction];
}
inline void PutOrder(int direction, int value)
{
order[direction]=value;
}
G4SurfaceList* projected_list;
G4SurfaceList* bezier_list;
int order[2];
G4KnotVector *new_knots;
int ord;
int lower,upper;
G4OsloMatrix* oslo_m;
G4Point3D vmin;
G4Point3D vmax;
void SplitNURBSurface();
int CheckBezier();
void CalcOsloMatrix();
void MapSurface(G4ProjectedSurface* srf);
inline int Amax(int i, int j)
{
return( (i) > (j) ? (i) : (j) );
}
inline int Amin(int i, int j)
{
return( (i) < (j) ? (i) : (j) );
}
inline int AhIndex(int j,int t, int iorder)
{
return(( (j) * ((j)+1)/2) + (t) - ((iorder-1) - (j)));
}
};
#endif
@@ -0,0 +1,166 @@
// 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: G4Ray.hh,v 2.4 1998/10/29 17:48:14 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __G4Ray_h
#define __G4Ray_h 1
#include "G4Point3D.hh"
#include "G4PointRat.hh"
#include "G4Vector3D.hh"
#include "G4Plane.hh"
class G4Ray
{
public:
G4Ray();
G4Ray(const G4Point3D& start0, const G4Vector3D& dir0);
void Init(const G4Point3D& start0, const G4Vector3D& dir0);
G4Point3D GetPoint(G4double i) const;
G4double GetPPoint(const G4Point3D& p) const;
const G4Vector3D& GetDir() const;
const G4Point3D& GetStart() const;
void SetDir(const G4Vector3D& dir0);
void SetStart(const G4Point3D& start0);
private:
G4Point3D start;
G4Vector3D dir;
G4double r_min; // entry Dist to bounding sphere
G4double r_max; // exit Dist from bounding sphere
G4Plane plane1, plane2;
public:
const G4Plane& GetPlane(const int number_of_plane)const;//1 or 2
void RayCheck();
void CreatePlanes();
static int CalcPlane3Pts( G4Plane &plane1, const G4Point3D& a,
const G4Point3D& b, const G4Point3D& c );
inline G4double P2(const G4double x) {return(x*x);};
void MatVecOrtho( register G4Vector3D &out, register const G4Vector3D in );
inline int NearZero(const G4double val, const G4double epsilon)
{
return ( ((val) > -epsilon) && ((val) < epsilon) );
}
static inline void Vcross(G4Plane &a,
const G4Vector3D &b, const G4Vector3D &c)
{
a.a = b.y() * c.z() - b.z() * c.y() ;
a.b = b.z() * c.x() - b.x() * c.z() ;
a.c = b.x() * c.y() - b.y() * c.x() ;
}
static inline void Vcross(G4Vector3D &a,
const G4Vector3D &b, const G4Vector3D &c)
{
a.setX(b.y() * c.z() - b.z() * c.y()) ;
a.setY(b.z() * c.x() - b.x() * c.z()) ;
a.setZ(b.x() * c.y() - b.y() * c.x()) ;
}
inline void Vmove(G4Point3D &a, const G4Point3D &b)
{
a.setX(b.x());
a.setY(b.y());
a.setZ(b.z());
}
inline void Vadd2(G4Point3D &a, const G4Point3D &b, const G4Vector3D &c )
{
a.setX(b.x() + c.x()) ;
a.setY(b.y() + c.y()) ;
a.setZ(b.z() + c.z()) ;
}
static inline void Vsub2(G4Vector3D &a,
const G4Point3D &b, const G4Point3D &c)
{
a.setX(b.x() - c.x());
a.setY(b.y() - c.y());
a.setZ(b.z() - c.z());
}
// Set all elements of vector to same scalar value
inline void Vsetall(G4Vector3D &a, G4double s)
{
a.setX(s); a.setY(s); a.setZ(s);
}
// Scale vector at `b' by scalar `c', Store result at `a'
static inline void Vscale(G4Plane& a, const G4Plane& b, const G4double c)
{
a.a = b.a * c;
a.b = b.b * c;
a.c = b.c * c;
}
// Compute dot product of vectors at `a' and `b'
static inline G4double Vdot(const G4Plane &a, const G4Point3D &b)
{
return (a.a * b.x() +
a.b * b.y() +
a.c * b.z());
}
// Return scalar Magnitude squared of vector at `a'
static inline G4double Magsq(const G4Plane &a)
{
return ( a.a * a.a + a.b * a.b + a.c *a.c );
}
// Return scalar Magnitude of vector at `a'
static inline G4double Magnitude(const G4Plane &a)
{
return (sqrt( Magsq( a )) );
}
};
#include "G4Ray.icc"
#endif
@@ -0,0 +1,41 @@
inline G4Point3D G4Ray::GetPoint(G4double i) const {
return start+i*dir;
}
inline G4double G4Ray::GetPPoint(const G4Point3D& p) const {
// |dir|==1
return (p-start)*dir;
}
inline const G4Vector3D& G4Ray::GetDir() const {
return dir;
}
inline const G4Point3D& G4Ray::GetStart() const {
return start;
}
inline void G4Ray::SetDir(const G4Vector3D& dir0) {
dir= dir0.unit();
}
inline void G4Ray::SetStart(const G4Point3D& start0) {
start= start0;
}
inline void G4Ray::Init(const G4Point3D& start0, const G4Vector3D& dir0)
{
start= start0;
dir= dir0;
RayCheck();
CreatePlanes();
}
inline G4Ray::G4Ray(const G4Point3D& start0, const G4Vector3D& dir0) {
Init(start0, dir0);
}
inline G4Ray::G4Ray()
{
}
@@ -0,0 +1,40 @@
// 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: G4RectangularTrimmedSurface.hh,v 2.2 1998/10/20 16:31:32 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4FCylindricalSurface.hh"
class G4RectangularTrimmedSurface: public G4Surface
{
public:
G4RectangularTrimmedSurface();
~G4RectangularTrimmedSurface();
int Intersect(const G4Ray&);
void CalcBBox();
virtual char *Name() const { return "G4RectangularTrimmedSurface"; }
private:
G4Surface* BasisSurface;
G4double TrimU1,TrimU2;
G4double TrimV1,TrimV2;
G4Point3D TrimPointU1, TrimPointU2;
G4Point3D TrimPointV1, TrimPointV2;
};
@@ -0,0 +1,14 @@
#ifndef __G4STEPENTITY
#define __G4STEPENTITY
#include "globals.hh"
#include "G4OrderedTable.hh"
class G4STEPEntity
{
public:
virtual G4String GetEntityType()=0;
};
#endif
@@ -0,0 +1,31 @@
// 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: G4Sort.hh,v 2.1 1998/10/20 16:31:33 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
// File: G4Sort.h
// Author: Alan Breakstone
//
// Description
//
// Routines to G4Sort arG4Rays of various kinds of numbers
//
#ifndef __SORT_H
#define __SORT_H
#include "globals.hh"
void G4Sort_double( G4double [], int, int );
void swap_double( G4double [], int, int );
void G4Sort_float( float [], int, int );
void swap_float( float [], int, int );
#endif
@@ -0,0 +1,289 @@
// 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: G4SphericalSurface.hh,v 2.5 1998/10/20 16:31:33 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __G4SpheShell_H
#define __G4SpheShell_H
#include "G4Surface.hh"
#include "G4ThreeMat.hh"
// #include "G4Vector3D.hh" already included in G4ThreeMat
class G4SphericalSurface: public G4Surface
{
protected:
G4Vector3D x_axis; // direction (unit vector) of axis of G4SphericalSurface
// which defines azimuthal angle of zero
G4Vector3D z_axis; // direction (unit vector) of axis of G4SphericalSurface
// which defines polar angle of zero
G4double radius; // radius of G4SphericalSurface
G4double phi_1; // lower azimuthal angle limit of G4SphericalSurface
// (in radians). Allowed range 0 <= phi_1 < 2*PI
G4double phi_2; // upper azimuthal angle limit of G4SphericalSurface
// (in radians). Allowed range
// phi_1 < phi_2 <= phi_1 + 2*PI
G4double theta_1; // lower polar angle limit of G4SphericalSurface
// (in radians). Allowed range 0 <= theta_1 < PI
G4double theta_2; // upper polar angle limit of G4SphericalSurface
// (in radians). Allowed range
// theta_1 < theta_2 <= theta_1 + PI
public:
G4SphericalSurface();
G4SphericalSurface( const G4Vector3D& o,
const G4Vector3D& xhat, const G4Vector3D& zhat,
G4double r,
G4double ph1, G4double ph2,
G4double th1, G4double th2 );
~G4SphericalSurface() {}
G4String GetEntityType() { return G4String("Spherical_Surface"); }
// G4SphericalSurface( const G4SphericalSurface& s ): G4Surface( s.origin )
// { x_axis = s.x_axis;
// z_axis = s.z_axis;
// radius = s.radius;
// phi_1 = s.phi_1;
// phi_2 = s.phi_2;
// theta_1 = s.theta_1;
// theta_2 = s.theta_2; }
int Intersect(const G4Ray&);
void CalcBBox();
inline void Comp( G4Vector3D& v, G4Point3D& min , G4Point3D& max)
{
// Compares the x,y and z values of v and min
// / v and max. min/max-values are replaced if
// greater/smaller than v-values.
if(v.x() > max.x()) max.setX(v.x());
if(v.y() > max.y()) max.setY(v.y());
if(v.z() > max.z()) max.setZ(v.z());
if(v.x() < min.x()) min.setX(v.x());
if(v.y() < min.y()) min.setY(v.y());
if(v.z() < min.z()) min.setZ(v.z());
}
virtual char *NameOf() const { return "G4SphericalSurface"; }
virtual void PrintOn( ostream& os = G4cout ) const;
int operator==( const G4SphericalSurface& s )
{ return origin == s.origin &&
x_axis == s.x_axis &&
z_axis == s.z_axis &&
radius == s.radius &&
phi_1 == s.phi_1 &&
phi_2 == s.phi_2 &&
theta_1 == s.theta_1 &&
theta_2 == s.theta_2; }
virtual G4double HowNear( const G4Vector3D& x ) const;
//virtual G4double distanceAlongRay( int which_way, const G4Ray* ry,
// G4ThreeVec& p ) const;
// virtual G4double distanceAlongHelix( int which_way, const Helix* hx,
// G4ThreeVec& p ) const;
// virtual G4Vector3D Normal( const G4Point3D& p ) const;
virtual G4Vector3D Normal( const G4Vector3D& p ) const;
virtual G4Vector3D SurfaceNormal( const G4Point3D& p ) const;
virtual int Inside( const G4Vector3D& x ) const;
virtual int WithinBoundary( const G4Vector3D& x ) const;
virtual G4double Scale() const;
virtual G4double Area() const;
virtual void resize( G4double r, G4double ph1, G4double ph2,
G4double th1, G4double th2);
// virtual void rotate( G4double alpha, G4double beta,
// G4double gamma, G4ThreeMat& m, int inverse );
// virtual void rotate( G4double alpha, G4double beta,
// G4double gamma, int inverse );
//
G4Vector3D GetXAxis() const { return x_axis; }
G4Vector3D GetZAxis() const { return z_axis; }
G4double GetRadius() const { return radius; }
G4double GetPhi1() const { return phi_1; }
G4double GetPhi2() const { return phi_2; }
G4double GetTheta1() const { return theta_1; }
G4double GetTheta2() const { return theta_2; }
private:
// virtual G4double gropeAlongHelix( const Helix* hx ) const;
//
// Description of functions -----------------------------------------
//
// default constructor
//----->G4SphericalSurface();
//
// Normal constructor: first argument is the origin of the G4SphericalSurface
// second argument is the axis of the G4SphericalSurface
// which defines azimuthal angle equals zero
// third argument is the axis of the G4SphericalSurface
// which defines polar angle equals zero
// fourth argument is the radius of the G4SphericalSurface
// fifth argument is the lower azimuthal angle limit of
// the G4SphericalSurface
// sixth argument is the upper azimuthal angle limit of
// the G4SphericalSurface
// seventh argument is the lower polar angle limit of
// the G4SphericalSurface
// eigth argument is the upper polar angle limit of
// the G4SphericalSurface
//----->G4SphericalSurface( const G4ThreeVec& o, const G4ThreeVec& xhat,
//-----> const G4ThreeVec& zhat,
//-----> G4double r, G4double ph1, G4double ph2,
//-----> G4double th1, G4double th2 );
//
// destructor
//----->virtual ~G4SphericalSurface() {}
//
// copy constructor
//----->G4SphericalSurface( const G4SphericalSurface& s ): Surface( s.origin )
//-----> { x_axis = s.X()_axis;
//-----> z_axis = s.Z()_axis;
//-----> radius = s.radius;
//-----> phi_1 = s.phi_1;
//-----> phi_2 = s.phi_2;
//-----> theta_1 = s.theta_1;
//-----> theta_2 = s.theta_2; }
//
// function to return class name
//----->virtual char *NameOf() const { return "G4SphericalSurface"; }
//
// printing function
//----->virtual void PrintOn( ostream& os = G4cout ) const;
//
// equality operator
//----->int operator==( const G4SphericalSurface& s )
//-----> { return origin == s.origin &&
//-----> x_axis == s.X()_axis &&
//-----> z_axis == s.Z()_axis &&
//-----> radius == s.radius &&
//-----> phi_1 == s.phi_1 &&
//-----> phi_2 == s.phi_2 &&
//-----> theta_1 == s.theta_1 &&
//-----> theta_2 == s.theta_2; }
//
// function which returns the distance from a point to a G4SphericalSurface
// the (input) argument is the point x
// the distance is positive if the point is Inside,
// negative if it is outside
//----->virtual G4double HowNear( const G4ThreeVec& x ) const;
//
// function which returns the distance along a Ray to enter or leave a
// G4SphericalSurface.
// the first (input) argument is +1 to leave or -1 to enter
// the second (input) argument is a pointer to the Ray
// the third (output) argument returns the intersection point
//----->virtual G4double distanceAlongRay( int which_way, const Ray* ry,
//-----> G4ThreeVec& p ) const;
//
// function which returns the distance along a Helix to enter or leave a
// G4SphericalSurface.
// the first (input) argument is +1 to leave or -1 to enter
// the second (input) argument is a pointer to the Helix
// the third (output) argument returns the intersection point
//----->virtual G4double distanceAlongHelix( int which_way, const Helix* hx,
//-----> G4ThreeVec& p ) const;
//
// function which returns the Normal unit vector to a G4SphericalSurface at a point p
// on (or nearly on) the G4SphericalSurface
//----->virtual G4ThreeVec Normal( const G4ThreeVec& p ) const;
//
// function which returns true (1) if the point x is Inside the
// G4SphericalSurface, returns false (0) otherwise
//----->virtual int Inside( const G4ThreeVec& x ) const;
//
// function which returns true (1) if the point x is within the boundary,
// false (0) otherwise.
//----->virtual int WithinBoundary( const G4ThreeVec& x ) const;
//
// function which returns the radius, unless it is zero, in which case it
// returns 1. Used for Scale-invariant tests of surface thickness.
//----->virtual G4double Scale() const;
//
// function to calculate the Area of a G4SphericalSurface
//----->virtual G4double Area() const;
//
// function to resize the G4SphericalSurface to new radius and angle limits
// first argument is the radius of the G4SphericalSurface
// second argument is the lower azimuthal angle limit of
// the G4SphericalSurface
// third argument is the upper azimuthal angle limit of
// the G4SphericalSurface
// fourth argument is the lower polar angle limit of
// the G4SphericalSurface
// fifth argument is the upper polar angle limit of
// the G4SphericalSurface
//----->virtual void resize( G4double r, G4double ph1, G4double ph2,
//-----> G4double th1, G4double th2);
//
// function to rotate the G4SphericalSurface (4 input arguments)
// first about global x_axis by angle alpha,
// second about global y-axis by angle beta,
// third about global z_axis by angle gamma
// the angles are assumed to be given in radians
// the fourth (output) argument gives the calculated rotation
// matrix
// the fifth (input) argument is an integer flag which if
// non-zero reverses the order of the rotations
//----->virtual void rotate( G4double alpha, G4double beta,
//-----> G4double gamma, G4ThreeMat& m, int inverse );
//
// function to rotate the G4SphericalSurface (4 input arguments)
// first about global x_axis by angle alpha,
// second about global y-axis by angle beta,
// third about global z_axis by angle gamma
// the angles are assumed to be given in radians
// the fourth (input) argument is an integer flag which if
// non-zero reverses the order of the rotations
//----->virtual void rotate( G4double alpha, G4double beta,
//-----> G4double gamma, int inverse );
//
// functions to return the axes, radius, and angles of the G4SphericalSurface
//----->direction GetXAxis() const { return x_axis; }
//----->direction GetZAxis() const { return z_axis; }
//----->G4double GetRadius() const { return radius; }
//----->G4double GetPhi1() const { return phi_1; }
//----->G4double GetPhi2() const { return phi_2; }
//----->G4double GetTheta1() const { return theta_1; }
//----->G4double GetTheta2() const { return theta_2; }
//
//
// Private function to use a crude technique to find the intersection
// of a Helix with a G4SphericalSurface. It returns the turning angle
// along the Helix at which the intersection occurs or -1.0 if no intersection
// point is found. The argument to the call is the pointer to the Helix.
//----->virtual G4double gropeAlongHelix( const Helix* hx ) const;
};
#endif
@@ -0,0 +1,26 @@
// 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: G4StepFileReader.hh,v 2.2 1998/10/20 16:31:34 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef G4STEPFILEREADER_HH
#define G4STEPFILEREADER_HH
#include "globals.hh"
#include "instmgr.h"
class G4StepFileReader
{
public:
virtual void ReadSTEPFile(G4String)=0;
virtual void SaveSTEPFile()=0;
virtual void UpdateSTEPFile()=0;
virtual InstMgr GetInstanceManager()=0;
};
#endif
@@ -0,0 +1,189 @@
#ifndef __surface_h
#define __surface_h 1
#include "geomdefs.hh"
#include "G4CurveVector.hh"
#include "G4PointRat.hh"
#include "G4Ray.hh"
#include "G4BoundingBox3D.hh"
#include "G4STEPEntity.hh"
#include "G4SurfaceBoundary.hh"
// This is the combined G4Surface class
class G4Surface: public G4STEPEntity
{
public:
G4Surface();
virtual ~G4Surface();
// sets the boundaries of the surface.
// The curves in the CurveVector must be non-intersecting
// closed curves.
void SetBoundaries(G4CurveVector*);
// It calls InitBounded -- empty by default
protected:
virtual void InitBounded() { }
public:
// type information, needed for STEP output (see STEPinterface)
virtual G4String GetEntityType(){return G4String("Surface");}
// The origin should move to the derived classes
int operator==( const G4Surface& s ) { return origin == s.origin; }
// such a function is needed
// (see G4VSolid::DistanceToIn(const G4ThreeVector&) )
// but the G4surface implementation is useless.
// Overriding functions don't take the surface
// boundary into account.
virtual G4double HowNear( const G4Vector3D& x ) const;
//virtual G4double distanceAlongRay( int which_way, const G4Ray* ry,
// G4Vector3D& p ) const;
// unnecessary -- origin should move to descendants
G4Vector3D GetOrigin() const { return origin; }
// Gerep members
// bad function names -- use Set and Get
// ??
inline G4double Distance() { return distance; }
inline void Distance(const G4double Dist) { distance=Dist; }
// a boolean flag, not used by the surfaces themselves
virtual inline int Active(){return active;}
virtual inline void Active(const int act){active=act;}
// Isn't this the same as HowNear? (This one is used by G4BREPSolid.)
virtual G4double ClosestDistanceToPoint(const G4Point3D&);
// uhit and vhit are never set.
// Only BSplineSurface overrides.
// There is a G4UVHit class.
virtual G4double GetUHit() { return uhit; }
virtual G4double GetVHit() { return vhit; }
// Intersection with a ray. the result is put into
// some data members.
virtual int Intersect(const G4Ray&);
// Surface normal calculation.
virtual G4Vector3D Normal( const G4Vector3D& p ) const;
// Bounding box calculation.
virtual void CalcBBox();
// For NURBS, there is a two pass intersection algorithm.
// Sometimes, the result of the cheap one tells us
// that execution of the expensive one is not necessary.
// Evaluation (Evaluate?) is one of them.
// better names wanted!
virtual G4Point3D Evaluation(const G4Ray& G4Rayref);
virtual int Evaluate(register const G4Ray& Rayref);
// There is Active(int) instead.
virtual inline void Deactivate(){active=0;}
// Distance(kInfinity); bbox->SetDistance(kInfinity);};
virtual inline void Reset(){Intersected=0;active = 1; distance = kInfinity;};
// one function for type info (GetEntityType) should be enough
virtual char *Name() const { return "G4Surface"; }
virtual int MyType() const { return Type; }
// To be replaced by a CLHEP vector operation
inline static void Project (G4double& Coord, const G4Point3D& Pt2,
const G4Plane& Pl1 )
{
Coord = Pt2.x()*Pl1.a + Pt2.y()*Pl1.b + Pt2.z()*Pl1.c - Pl1.d;
}
// Used by BREPSolid. Thus it's probably needed.
virtual void Project(){}
// Only in G4FPlane. Should be private to that class?
virtual void CalcNormal(){}
// Only in G4FPlane. BREPSolid::IsConvex uses it.
// But who uses BREPSolid::IsConvex?
// Thus: probably not needed. But knowing
// if the surface is convex could be used for optimization.
virtual int IsConvex(){return -1;}
// Only in G4FPlane, but G4BREPSolid uses them.
virtual int GetConvex(){return 0;}
virtual int GetNumberOfPoints(){return 0;}
virtual const G4Point3D& GetPoint(const int Count)
{
const G4Point3D* tmp= new G4Point3D(0,0,0);
return *tmp;
}
// L. Broglia
void SetSameSense(G4int sameSense0) { sameSense = sameSense0; }
G4int GetSameSense() { return sameSense ; }
G4BoundingBox3D* GetBBox() { return bbox; }
// there is Normal as well -- so what do these do?
virtual G4Ray* Norm(){return (G4Ray*)0;}
virtual G4Vector3D SurfaceNormal(const G4Point3D& Pt) const =0;
// should be at least protected, but BREPSolid uses these data members.
// So why not a Get function?
public:
G4BoundingBox3D* bbox;
G4Point3D closest_hit;
protected:
// The boundaries of the surface.
G4SurfaceBoundary surfaceBoundary;
// BSplineSurface anf FPlane sets it, no one gets it
int Intersected;
// see Get... members
G4Vector3D origin; // origin of Surface
int Type;
int AdvancedFace;
int active;
G4double distance;
G4double uhit,vhit;
// L. Broglia
G4int sameSense;
protected:
// Maybe kInfinity instead?
const G4double FLT_MAXX;
// Maybe kCarTolerance instead?
const G4double FLT_EPSILO;
// temporary solution so that G4SurfaceList sees this member
// but G4SurfaceList should go.
public:
G4Surface* next;
};
#endif
@@ -0,0 +1,104 @@
#ifndef included_G4SurfaceBoundary
#define included_G4SurfaceBoundary
#include "G4Point3D.hh"
#include "G4Point3DVector.hh"
#include "G4Vector3D.hh"
#include "G4Transform3D.hh"
#include "G4Curve.hh"
#include "G4CurveVector.hh"
#include "G4CurveRayIntersection.hh"
class G4Ray;
class G4CylindricalSurface;
class G4SurfaceBoundary {
public:
// Initialize with a set of closed curves,
// each of which is an (inner or outer) boundary.
// no responsibility to delete the curves is taken.
// shallow copy of G4Curve-s.
G4SurfaceBoundary();
void Init(const G4CurveVector& bounds0);
const G4CurveVector& GetBounds() const { return bounds; }
virtual ~G4SurfaceBoundary();
// projection onto the xy plane after transformation tr
// the returned object is allocated dynamically;
// it is the caller's responsibility to delete it
// in case the projection maps a line into a point,
// 0 is returned
G4SurfaceBoundary* Project(const G4Transform3D& tr=G4Transform3D::Identity);
// intersect a 2D boundary (probably obtained with Project) with a ray.
// the ray is projected onto the xy plane.
// no intersection: return false
// intersection: return true, and set intersection0
// the intersection point is ray.start+ray.dir*intersection0
void IntersectRay2D(const G4Ray& ray, G4CurveRayIntersection& is);
// tangent vector to a curve at the point with parameter u
// true if exists
// vector comes into v
G4bool Tangent(G4CurvePoint& cp, G4Vector3D& v);
// split a boundary with a plane containing p0 with normal n.
// pointers to the resulting boundaries are put into new1 and new2.
// it is the caller's responsibility to delete them.
void SplitWithPlane(const G4Point3D& p0,
const G4Vector3D& n,
G4SurfaceBoundary*& new1,
G4SurfaceBoundary*& new2 );
void SplitWithCylinder(const G4CylindricalSurface& c,
G4SurfaceBoundary*& new1,
G4SurfaceBoundary*& new2 );
const G4BoundingBox3D& BBox() const { return bBox; }
// the following functions are probably not used
// and should be removed in the future
G4Point3DVector points;
inline int GetNumberOfPoints(){return points.length();}
inline const G4Point3D& GetPoint(const int Count){return points.ref(Count);}
private:
// copy disabled
G4SurfaceBoundary(const G4SurfaceBoundary&);
G4SurfaceBoundary& operator=(const G4SurfaceBoundary&);
private:
G4CurveVector bounds;
G4BoundingBox3D bBox;
// to speed up the tangent computation
G4CurveRayIntersection lastIntersection;
};
#endif
@@ -0,0 +1,59 @@
// 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: G4SurfaceList.hh,v 2.2 1998/10/20 16:31:35 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __G4SurfaceList_h
#define __G4SurfaceList_h 1
#include "G4Surface.hh"
class G4SurfaceList
{
public:
G4SurfaceList();
~G4SurfaceList();
int number_of_elements;
G4Surface* first;
G4Surface* next;
G4Surface* last;
G4Surface* temp;
G4Surface* index;
void MoveToFirst(G4Surface *srf);
void AddSurface(G4Surface *srf);
G4Surface* GetSurface();
G4Surface* GetSurface(int number);
G4Surface* GetLastSurface();
void RemoveSurface(G4Surface* srf);
void RemovePointer();
void MoveToFirst();
void Step();
void EmptyList();
void G4SortList();
void QuickG4Sort(G4Surface**, int, int);
};
#endif
@@ -0,0 +1,26 @@
#ifndef included_G4SurfaceOfLinearExtrusion
#define included_G4SurfaceOfLinearExtrusion
// surface of linear extrusion
#include "G4Surface.hh"
class G4SurfaceOfLinearExtrusion: public G4Surface
{
public:
G4SurfaceOfLinearExtrusion();
virtual ~G4SurfaceOfLinearExtrusion();
private:
G4SurfaceOfLinearExtrusion(const G4SurfaceOfLinearExtrusion &);
G4SurfaceOfLinearExtrusion& operator=(const G4SurfaceOfLinearExtrusion &);
};
#endif
@@ -0,0 +1,28 @@
#ifndef included_G4SurfaceOfRevolution
#define included_G4SurfaceOfRevolution
// surface of linear extrusion
#include "G4Surface.hh"
class G4SurfaceOfRevolution: public G4Surface
{
public:
G4SurfaceOfRevolution();
virtual ~G4SurfaceOfRevolution();
private:
G4SurfaceOfRevolution(const G4SurfaceOfRevolution &);
G4SurfaceOfRevolution& operator=(const G4SurfaceOfRevolution &);
};
#endif
@@ -0,0 +1,80 @@
// 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: G4ThreeMat.hh,v 2.3 1998/10/20 16:31:36 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
/* G4ThreeMat.h,v 1.7 1993/12/30 02:15:55 rensing Exp */
// File: G4ThreeMat.h
// Author: Alan Breakstone
// Contents ---------------------------------------------------------------
//
// G4ThreeMat
//
// Description
//
// Defines the class G4ThreeMat for three by three matrices
//
//
// End --------------------------------------------------------------------
// Interface Dependencies -------------------------------------------------
#ifndef __THREEMAT_H
#define __THREEMAT_H
#include "G4Vector3D.hh"
// End Interface Dependencies -------------------------------------------
// Class //
class G4ThreeMat
{
// The elements exist individually and are also aggregated into
// rows and columns to use operations already written for the G4Vector3Dc
// class.
G4double element[3][3];
G4Vector3D row[3], column[3];
public:
// default constructor
G4ThreeMat();
// Normal constructors with a 3 x 3 arG4Ray argument
G4ThreeMat( G4double a[3][3] );
// destructor
virtual ~G4ThreeMat() {};
// copy constructor
G4ThreeMat( const G4ThreeMat& m );
// function to return class name
virtual char *NameOf() const { return "G4ThreeMat"; }
// printing functions (derived classes do not need to overwrite operator <<)
friend ostream& operator<<( ostream& os, const G4ThreeMat& m );
virtual void PrintOn( ostream& os = G4cout ) const;
// equality operator
int operator==( const G4ThreeMat& m );
//
// overload operators =, +, -, +=, -=, *
//
void operator=( const G4ThreeMat& m );
G4ThreeMat operator+() const { return *this; };
G4ThreeMat operator-();
G4ThreeMat operator+=( const G4ThreeMat& m2 );
G4ThreeMat operator-=( const G4ThreeMat& m2 );
friend G4ThreeMat operator+( const G4ThreeMat& m1, const G4ThreeMat& m2 );
friend G4ThreeMat operator-( const G4ThreeMat& m1, const G4ThreeMat& m2 );
friend G4ThreeMat operator*( G4double x, const G4ThreeMat& m );
friend G4Vector3D operator*( const G4ThreeMat& m, const G4Vector3D& v );
friend G4ThreeMat operator*( const G4ThreeMat& m1, const G4ThreeMat& m2 );
//
// Determinant of matrix
G4double Determinant();
};
#endif
@@ -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: G4ToroidalSurface.hh,v 2.4 1998/10/29 17:48:15 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __G4TOROIDALSURAFCE
#define __G4TOROIDALSURAFCE
#include "G4FPlane.hh"
#include "G4OsloMatrix.hh"
class G4ToroidalSurface:public G4Surface
{
public:
G4ToroidalSurface();
G4ToroidalSurface(const G4Vector3D&,
const G4Vector3D&,
const G4Vector3D&,
const G4double,
const G4double);
~G4ToroidalSurface();
G4String GetEntityType(){return G4String("Toroidal_Surface");}
int Intersect(const G4Ray&);
void CalcBBox();
inline G4Vector3D GetDirection(){return Placement.GetRefDirection();}
inline G4Vector3D GetAxis() {return Placement.GetAxis();}
inline G4Point3D GetLocation() {return Placement.GetLocation();}
inline G4double GetMinRadius(){return MinRadius;}
inline G4double GetMaxRadius(){return MaxRadius;}
G4double ClosestDistanceToPoint(const G4Point3D&);
G4Vector3D SurfaceNormal(const G4Point3D& Pt)const
{return G4Vector3D(0,0,0);}
inline void MultiplyPointByMatrix(G4Point3D& Base)
{
Base.setX((Base.x() * TransMatrix->get(0,0)) +
(Base.y() * TransMatrix->get(1,0)) +
(Base.z() * TransMatrix->get(2,0)));
Base.setY((Base.x() * TransMatrix->get(0,1)) +
(Base.y() * TransMatrix->get(1,1)) +
(Base.z() * TransMatrix->get(2,1)));
Base.setZ((Base.x() * TransMatrix->get(0,2)) +
(Base.y() * TransMatrix->get(1,2)) +
(Base.z() * TransMatrix->get(2,2)));
}
inline void MultiplyVectorByMatrix(G4Vector3D& DCos)
{
G4double w;
DCos.setX((DCos.x() * TransMatrix->get(0,0)) +
(DCos.y() * TransMatrix->get(1,0)) +
(DCos.z() * TransMatrix->get(2,0)) + TransMatrix->get(3,0));
DCos.setY((DCos.x() * TransMatrix->get(0,1)) +
(DCos.y() * TransMatrix->get(1,1)) +
(DCos.z() * TransMatrix->get(2,1)) + TransMatrix->get(3,1));
DCos.setY((DCos.x() * TransMatrix->get(0,2)) +
(DCos.y() * TransMatrix->get(1,2)) +
(DCos.z() * TransMatrix->get(2,2)) + TransMatrix->get(3,2));
w = ((DCos.x() * TransMatrix->get(0,3)) +
(DCos.y() * TransMatrix->get(1,3)) +
(DCos.z() * TransMatrix->get(2,3)) + TransMatrix->get(3,3));
if (w != 0.0)
{
DCos.setX(DCos.x() / w);
DCos.setY(DCos.y() / w);
DCos.setZ(DCos.z() / w);
}
}
private:
G4Axis2Placement3D Placement;
G4double MinRadius;
G4double MaxRadius;
Matrix* TransMatrix; // transformation matrix
G4Point3D hitpoint;
const G4double EQN_EPS;
int SolveQuartic(G4double c[], G4double s[]);
inline int IsZero(G4double x)
{
if((x) > -EQN_EPS && (x) < EQN_EPS)
return 1;
else return 0;
}
int SolveCubic(G4double c[], G4double s[]);
int SolveQuadric(G4double c[], G4double s[]);
};
#endif
@@ -0,0 +1,26 @@
// 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: G4UVHit.hh,v 2.2 1998/10/20 16:31:37 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#ifndef __G4UV_Hit
#define __G4UV_Hit
#include "globals.hh"
class G4UVHit
{
public:
G4UVHit * next;
int sub;
G4double u, v;
G4UVHit(){u=-1;next=this;}
G4UVHit(G4double u_hit, G4double v_hit){u = u_hit; v = v_hit;}
};
#endif