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
+23
View File
@@ -0,0 +1,23 @@
# $Id: GNUmakefile,v 2.1 1998/12/01 21:08:49 japost Exp $
# ------------------------------------------------------------
# GNUmakefile for BREPS library. Gabriele Cosmo, 15/11/96.
# ------------------------------------------------------------
name := G4brep
ifndef G4INSTALL
G4INSTALL = ../../../..
endif
include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += \
-I$(G4BASE)/geometry/solids/STEP/include \
-I$(G4BASE)/geometry/management/include \
-I$(G4BASE)/geometry/volumes/include \
-I$(G4BASE)/global/management/include \
-I$(G4BASE)/global/HEPGeometry/include \
-I$(G4BASE)/graphics_reps/include
include $(G4INSTALL)/config/common.gmk
+225
View File
@@ -0,0 +1,225 @@
History file for geometry/solids/BREPS
November 11, 1998 : L. Broglia
- correct Inside function for G4SphericalSurface
- create (but now is empty) Inside function for
G4CylindricalSurface
- new implementation into G4CylindricalSurface::Intersect
November 04, 1998 L. Broglia geometry-00-03-04
- Cleaned up trivial errors on DEC (undefined loop variables).
- Removed old CurveTest, now separate in G4BREPSolidxxxTest files
- Changing the name of the output files. All the tests run correctly with
Linux, Sun, HP and DEC compilers
------------------------------------------------------------------------------
date: 1998/10/30 22:20:16; author: japost; state: Exp; lines: +11 -5
Changed
< HitDistance = closest_point.distance2(RayStart);
to
> HitDistance = closest_point.distance2((G4Point3D &)RayStart);
because
distance2( HepPoint3D &p )
in CLHEP/Point3D
should be
distance2( const HepPoint3D &p )
as it is const!
October 29, 1998 L. Broglia
- Changed all the occurences of G4Placement into G4Axis2Placement3D.
- Modified G4FPlane - new implementation, inheriting from G4Axis2Placement3D
- Create in G4PointRat INFINITY which is a double and PINFINITY which is a
HepVector3D
- Corrected a bug into G4BREPSolidCylinder
- Created a test for the curves
- Created tests for all BREP solids.
For the moment, only test for the sphere and test for the torus
run correctly
- Created a test which read a STEP file and created the BREP solid
October 20, 1998 L. Broglia Breps-lionel-tag1-point3D
- Changed all the occurences of G4Point3d, G4Point2d into G4Point3D, which
is a HepPoint3D.
- Modified G4PointRat - new implementation, inheriting from G4Point3D.
- Changed ThreeVec into Vector3D or Point3D, depending on its use.
------------------------------------------------------------------------------
October 13, 1998 J. Apostolakis geometry-00-03-01
- Tag created.
October 12, 1998 J. Apostolakis geometry-00-03-01
- Small (cosmetic) changes to aid in compilation on Sun, HP.
Renamed local variables, whose name was the same as a class variable or method.
July 9, 1998: J. Apostolakis breps-00-01-02
- Fixes to G4Assembly, to aid STEPinterface. (Jari).
- Fix to G4Placement equality operator. (J.A.)
Compiles on AIX.
July 8, 1998: J. Apostolakis breps-00-01-01
- Tagged.
July 5, 1998: P. Urban
- Fixes to compile on AIX-AFS.
July 2, 1998: J. Apostolakis (for P. Urban)
- All of Peter Urban's development of Curves is added from
the head of the alpha repository.
July 1, 1998: J. Apostolakis (pre-beta01-01)
- Geant4beta created from alpha07 tag (which was on a branch).
-----------------------------------------------------------------
These fixes were added to alpha07 - which was on a branch from
the head
June 12, 1998: J. Apostolakis (for J. Sulkimo)
- Correction to constructor of BREPSolidPCone.
(An out-of-date version was mistakenly included in fix to
Conical Surface).
June 10, 1998: J. Apostolakis (for J. Sulkimo)
- Bug fixes to Conical Surface (FConical and Conical) to get
PCone to work.
------------------------------------------------------------------
June 8, 1998: J. Apostolakis breps-00-06-01
- Tagged what seems to be the last version before the merge
of Peter Urban's code. Found this by using day before merge,
May 27th.
April 28, 1998: G. Cosmo, breps-00-05-07
- Cleaned up trivial warnings on DEC (Extraneous semicolons).
- Removed -cfront option from GNUmakefile for DEC. -cfront
overrides ANSI standard rules in cxx-6.0.
April 24, 1998: J. Sulkimo, breps-00-05-06
- fixed scope bugs in for loops
April 24, 1998: J. Sulkimo, breps-00-05-05-assembly
- G4Assembly.cc bug fixes in STEP file interaction & placed solids
creation. Heavy changes in method G4Assembly::CopySTEPData
April 24, 1998: J. Sulkimo, breps-00-05-05-point3d
- rerenamed G4Point3d.hh to G4Point3d.h to avoid file name conflict on
NT
April 23, 1998: G. Cosmo
- Added missing canonical implementation of operator== in G4PlacedSolid.hh
April 22, 1998: J. Sulkimo, breps-00-05-03-assembly (recorded by J.Apostolakis)
- Bug Fixes to G4Assembly, requiring changes to the files:
include/G4Assembly.hh
include/G4PlacedSolid.hh
include/G4StepFileReader.hh
src/G4Assembly.cc
src/G4BREPSolid.cc
src/G4CurveBoundary.cc
src/G4PlacedSolid.cc
src/G4Surface.cc
March 18, 1998: P. Urban, breps-00-05-02
- Names of lots of member functions changed:
BoxOrNo to IsBox
ConvexOrConcave to IsConvex
+ removing _ and capitalization.
Cleanup of the code will continue later.
March 18, 1998: P. Urban, breps-00-05-01d
- Some member functions were removed. Renamed G4B_SplineCurve.
March 18, 1998: P. Urban, breps-00-05-01c
- the following classes have been renamed:
from to
G4B_SplineCurve G4BSplineCurve
G4B_SplineCurve_With_Knots G4BSplineCurveWithKnots
G4B_SplineSurface G4BSplineSurface
G4Conic G4ConicalSurface
G4Cylinder G4CylindricalSurface
G4EllipticCurve G4Ellipse
G4FConic G4FConicalSurface
G4FCylinder G4FCylindricalSurface
G4HyperbolicCurve G4Hyperbola
G4ParabolicCurve G4Parabola
G4PlaneSurface G4FPlane
G4Rational_B_SplineCurve G4RationalBSplineCurve
G4SpheShell G4SphericalSurface
plane G4Plane
uv_hit G4UVHit
March 18, 1998: P. Urban, breps-00-05-01b
- some class names will be changed; renaming the files (but not the classes!)
was done.
March 18, 1998: P. Urban, breps-00-05-01a
- *.h files renamed to *.hh.
March 18, 1998: P. Urban, breps-00-05-01
- Modifications made before alpha05 which are not part of alpha05
for some reason.
@@ -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
@@ -0,0 +1,167 @@
#include "G4Assembly.hh"
G4Assembly::G4Assembly()
{
// ReadSTEPFile();
// CopySTEPData();
}
G4Assembly::~G4Assembly()
{
for(G4int a=0;a<numberOfSolids;a++)
delete placedVec[a];
}
void G4Assembly::SetPlacedVector(G4PlacedVector& pVec)
{
numberOfSolids = pVec.entries();
for(G4int a=0;a<numberOfSolids;a++)
placedVec.append( pVec[a]);
}
@@ -0,0 +1,116 @@
#include "G4Axis2Placement3D.hh"
//G4Axis2Placement3D
G4Axis2Placement3D::G4Axis2Placement3D(){}
G4Axis2Placement3D::~G4Axis2Placement3D(){}
// this function is used in STEPinterface directory
G4Axis2Placement3D::G4Axis2Placement3D(const G4Axis2Placement3D& place)
{
refDirection = place.GetRefDirection();
axis = place.GetAxis();
location = place.GetLocation();
pX = place.GetPX();
pY = place.GetPY();
pZ = place.GetPZ();
toPlacementCoordinates = GetToPlacementCoordinates();
fromPlacementCoordinates = GetFromPlacementCoordinates();
}
/*
G4Axis2Placement3D::G4Axis2Placement3D(const G4ThreeVec Dir,
const G4ThreeVec Axis,
const G4Point3d Pt )
{
dir=Dir;
axis=Axis;
srf_point=Pt;
ComputeNormal();
G4Point3d Pt2 = Pt+Dir;
G4Point3d Pt3 = Pt+Axis;
G4Ray::CalcPlane3Pts(Pl, Pt, Pt2, Pt3);
}
G4Axis2Placement3D::G4Axis2Placement3D(const G4ThreeVec Dir, const G4ThreeVec Axis, const G4Point3d Pt1, const G4Point3d Pt2, const G4Point3d Pt3)
{
dir=Dir;
axis=Axis;
srf_point=Pt1;
ComputeNormal();
G4Ray::CalcPlane3Pts(Pl, Pt1, Pt2, Pt3);
}
*/
/*
void G4Axis2Placement3D::ProjectPlacement(const G4Plane& Pl1, const G4Plane& Pl2)
{
Project(ProjectedDir, dir, Pl1, Pl2);
Project(ProjectedAxis, axis, Pl1, Pl2);
Project(ProjectedSrfPoint, srf_point, Pl1, Pl2);
Project(ProjectedNormal, Normal, Pl1, Pl2);
}
void G4Axis2Placement3D::ComputeNormal()
{
if(dir == axis)
Normal = dir;
else
{
Normal.X(dir.Y()*axis.Z() - dir.Z()*axis.Y());
Normal.Y(dir.X()*axis.Z()- dir.Z()*axis.X());
Normal.Z(dir.X()*axis.Y() - dir.Y()*axis.X());
}
}
G4Point3d G4Axis2Placement3D::EvaluateIntersection(register const G4Ray& rray)
{
// s is solution, line is p + tq, n is G4Plane Normal, r is point on G4Plane
// all parameters are pointers to arrays of three elements
register G4double a, b, t;
register const G4ThreeVec& RayDir = rray.GetDir();
register const G4Point3d& RayStart = rray.GetStart();
G4double dirx = RayDir.X();
G4double diry = RayDir.Y();
G4double dirz = RayDir.Z();
b = Normal.X() * dirx + Normal.Y() * diry + Normal.Z() * dirz;
if (fabs(b) < 0.001)//== 0.0) // or some better test involving a small positive e
// if (b == 0.0) // or some better test involving a small positive e
{
// G4cout << "\nLine is parallel to G4Plane.No Hit.";
G4Point3d hit_point( kInfinity, kInfinity, kInfinity);
return hit_point;
}
G4double startx = RayStart.X();
G4double starty = RayStart.Y();
G4double startz = RayStart.Z();
a = Normal.X() * (srf_point.X() - startx) + Normal.Y() * (srf_point.Y() - starty)
+ Normal.Z() * (srf_point.Z() - startz);
t = a/b;
// substitute t into line equation
// to calculate final solution
G4Point3d hit_point(startx + t * dirx,starty + t * diry,startz + t * dirz);
// G4cout << "\nPLANE HIT POINT :" << hit_point.X() << " " << hit_point.Y() << " " << hit_point.Z();
return hit_point;
}
*/
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,98 @@
// 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.cc,v 2.3 1998/10/20 16:33:37 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4BREPSolidBox.hh"
#include "G4FPlane.hh"
#include "G4Point3DVector.hh"
G4BREPSolidBox::G4BREPSolidBox(G4String name,
const G4Point3D& Pt1,
const G4Point3D& Pt2,
const G4Point3D& Pt3,
const G4Point3D& Pt4,
const G4Point3D& Pt5,
const G4Point3D& Pt6,
const G4Point3D& Pt7,
const G4Point3D& Pt8): G4BREPSolid(name)
{
nb_of_surfaces=6;
active=1;PlaneSolid=1;
SurfaceVec = new G4Surface*[6];
G4Point3DVector PVec(4);
PVec[0] = Pt1;
PVec[1] = Pt2;
PVec[2] = Pt3;
PVec[3] = Pt4;
SurfaceVec[0] = new G4FPlane(&PVec);
PVec[2] = Pt6;
PVec[3] = Pt5;
SurfaceVec[1] = new G4FPlane(&PVec);
PVec[0] = Pt2;
PVec[1] = Pt6;
PVec[2] = Pt7;
PVec[3] = Pt3;
SurfaceVec[2] = new G4FPlane(&PVec);
PVec[0] = Pt3;
PVec[1] = Pt7;
PVec[2] = Pt8;
PVec[3] = Pt4;
SurfaceVec[3] = new G4FPlane(&PVec);
PVec[0] = Pt1;
PVec[1] = Pt5;
PVec[2] = Pt8;
PVec[3] = Pt4;
SurfaceVec[4] = new G4FPlane(&PVec);
PVec[0] = Pt5;
PVec[1] = Pt6;
PVec[2] = Pt7;
PVec[3] = Pt8;
SurfaceVec[5] = new G4FPlane(&PVec);
Initialize();
}
EInside G4BREPSolidBox::Inside(register const G4ThreeVector& Pt) const
{
G4Point3D Point(Pt);
// Get the bounding box extent
G4Point3D min = bbox->GetBoxMin();
min = min + -(0.5*kCarTolerance);
G4Point3D max = bbox->GetBoxMax();
max = max + (0.5*kCarTolerance);
if( (Point.x() < min.x() || Point.x() > max.x()) ||
(Point.y() < min.y() || Point.y() > max.y()) ||
(Point.z() < min.z() || Point.z() > max.z()) )
return kOutside;
if( (Point.x() > min.x() && Point.x() < max.x())&&
(Point.y() > min.y() && Point.y() < max.y())&&
(Point.z() > min.z() && Point.z() < max.z()) )
return kInside;
return kSurface;
}
@@ -0,0 +1,181 @@
// 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.cc,v 2.5 1998/10/29 17:49:33 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4BREPSolidCone.hh"
#include "G4FPlane.hh"
#include "G4FConicalSurface.hh"
#include "G4FCylindricalSurface.hh"
#include "G4CircularCurve.hh"
G4BREPSolidCone::G4BREPSolidCone(G4String name,
const G4ThreeVector& origin,
const G4ThreeVector& axis,
const G4ThreeVector& direction,
const G4double length,
const G4double radius,
const G4double large_radius):G4BREPSolid(name)
{
SurfaceVec = new G4Surface*[3];
G4Point3D ArcStart1 = origin + (radius*direction);
G4Vector3D tmpaxis(axis);
G4Vector3D tmporigin(origin);
G4Point3D paska;
paska= origin + (length*tmpaxis);
G4Point3D origin2(paska.x(), paska.y(), paska.z());
paska= origin2 + (large_radius*tmpaxis);
G4Point3D ArcStart2(paska.x(), paska.y(), paska.z());
G4Ray::Vcross(tmpaxis, axis, direction);
G4ThreeVector axis2(tmpaxis.x(),tmpaxis.y(), tmpaxis.z());
G4CurveVector CVec;
G4CircularCurve* tmp;
tmp = new G4CircularCurve();
tmp->Init(G4Axis2Placement3D(direction, axis2, origin) , large_radius);
tmp->SetBounds(ArcStart1, ArcStart1);
CVec.insert(tmp);
tmp = new G4CircularCurve();
tmp->Init(G4Axis2Placement3D(direction, axis2, origin2), large_radius);
tmp->SetBounds(ArcStart2, ArcStart2);
CVec.insert(tmp);
SurfaceVec[0] = new G4FConicalSurface(tmporigin, axis,
length, radius, large_radius);
SurfaceVec[0]->SetBoundaries(&CVec);
// new G4AdvancedFace("G4FConicalSurface", tmporigin, direction,
// axis, CVec, 1, 0,0,length, radius, large_radius);
// Create end planes & boundaries for cone solid
G4CurveVector CVec2;
tmp = new G4CircularCurve();
tmp->Init(G4Axis2Placement3D(direction, axis2, origin), radius);
tmp->SetBounds(ArcStart1, ArcStart1);
CVec2.insert(tmp);
SurfaceVec[1] = new G4FPlane(tmpaxis, direction, origin2);
//new G4AdvancedFace("G4FPlane" , origin2, direction, tmpaxis, CVec2, 1);
SurfaceVec[1]->SetBoundaries(&CVec2);
CVec2[0] = tmp = new G4CircularCurve();
tmp->Init(G4Axis2Placement3D(direction, axis2, origin2), large_radius);
tmp->SetBounds(ArcStart2, ArcStart2);
SurfaceVec[2] = new G4FPlane(tmpaxis, direction, origin);
//new G4AdvancedFace("G4FPlane", origin, direction, tmpaxis, CVec2, 1);
SurfaceVec[2]->SetBoundaries(&CVec2);
nb_of_surfaces = 3;
active=1;
Initialize();
}
void G4BREPSolidCone::Initialize()
{
// Calc bounding box for solids and surfaces
// Convert concave planes to convex
ShortestDistance=1000000;
CheckSurfaceNormals();
if(!Box || !AxisBox)
IsConvex();
CalcBBoxes();
}
EInside G4BREPSolidCone::Inside(register const G4ThreeVector& Pt) const
{
G4double dist1 = SurfaceVec[0]->HowNear(Pt);
G4double dist2 = SurfaceVec[1]->ClosestDistanceToPoint(Pt);
G4double dist3 = SurfaceVec[2]->ClosestDistanceToPoint(Pt);
if(dist1 > dist2) dist1 = dist2;
if(dist1 > dist3) dist1 = dist3;
if(dist1 > 0) return kInside;
if(dist1 < 0) return kOutside;
return kSurface;
}
G4ThreeVector G4BREPSolidCone::SurfaceNormal(const G4ThreeVector& Pt) const
{
G4Vector3D n = SurfaceVec[0]->Normal(Pt);
G4ThreeVector norm(n.x(), n.y(), n.z());
return norm;
}
G4double G4BREPSolidCone::DistanceToIn(const G4ThreeVector& Pt) const
{
G4double dist1 = fabs(SurfaceVec[0]->HowNear(Pt));
G4double dist2 = fabs(SurfaceVec[1]->ClosestDistanceToPoint(Pt));
G4double dist3 = fabs(SurfaceVec[2]->ClosestDistanceToPoint(Pt));
if(dist1 > dist2) dist1 = dist2;
if(dist1 > dist3) dist1 = dist3;
return dist1;
}
G4double G4BREPSolidCone::DistanceToIn(register const G4ThreeVector& Pt,
register const G4ThreeVector& V) const
{
Reset();
G4Vector3D Pttmp(Pt);
G4Vector3D Vtmp(V);
// G4double kInfinity = 10e20;
G4Ray r(Pttmp, Vtmp);
if(SurfaceVec[0]->Intersect( r ))
{
ShortestDistance = SurfaceVec[0]->Distance();
return ShortestDistance;
}
return kInfinity;
}
G4double G4BREPSolidCone::DistanceToOut(register const G4ThreeVector& Pt,
register const G4ThreeVector& V,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n) const
{
if(validNorm)
*validNorm = false;
Reset();
G4Vector3D Pttmp(Pt);
G4Vector3D Vtmp(V);
// G4double kInfinity = 10e20;
G4Ray r(Pttmp, Vtmp);
if(SurfaceVec[0]->Intersect( r ))
{
ShortestDistance = SurfaceVec[0]->Distance();
return ShortestDistance;
}
return kInfinity;
}
G4double G4BREPSolidCone::DistanceToOut(const G4ThreeVector& Pt) const
{
G4double dist1 = fabs(SurfaceVec[0]->HowNear(Pt));
G4double dist2 = fabs(SurfaceVec[1]->ClosestDistanceToPoint(Pt));
G4double dist3 = fabs(SurfaceVec[2]->ClosestDistanceToPoint(Pt));
if(dist1 > dist2) dist1 = dist2;
if(dist1 > dist3) dist1 = dist3;
return dist1;
}
@@ -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: G4BREPSolidCylinder.cc,v 2.6 1998/11/27 17:41:38 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4BREPSolidCylinder.hh"
#include "G4CircularCurve.hh"
#include "G4FPlane.hh"
#include "G4FCylindricalSurface.hh"
G4BREPSolidCylinder::G4BREPSolidCylinder(G4String name,
const G4ThreeVector& origin,
const G4ThreeVector& axis,
const G4ThreeVector& direction,
const G4double& radius,
const G4double& length)
:G4BREPSolid(name)
{
SurfaceVec = new G4Surface*[3];
G4CurveVector cv;
G4CircularCurve* tmp;
// Creation of the cylindrical surface
SurfaceVec[0] = new G4FCylindricalSurface(origin, axis, radius , length);
//SurfaceVec[0]->SetBoundaries(&cv);
//cv.clear();
// Creation of the first circlular surface, which origin is origin
G4Point3D ArcStart1 = origin + ( radius*direction );
G4Vector3D axis1 = axis.cross( direction );
tmp = new G4CircularCurve;
tmp->Init( G4Axis2Placement3D(direction, axis1, origin), radius );
tmp->SetBounds(ArcStart1, ArcStart1);
cv.insert(tmp);
SurfaceVec[1] = new G4FPlane(direction, axis1, origin);
SurfaceVec[1]->SetBoundaries(&cv);
cv.clear();
// Creation of the second circlular surfac
G4Point3D origin2 = origin + ( length*axis );
G4Point3D ArcStart2 = origin2 + ( radius*direction );
G4Vector3D axis2 = axis1;
tmp = new G4CircularCurve;
tmp->Init( G4Axis2Placement3D(direction, axis2, origin2), radius);
tmp->SetBounds(ArcStart2, ArcStart2);
cv.insert(tmp);
SurfaceVec[2] = new G4FPlane(direction, axis2, origin2);
SurfaceVec[2]->SetBoundaries(&cv);
cv.clear();
nb_of_surfaces = 3;
active=1;
Initialize();
}
@@ -0,0 +1,641 @@
// 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.cc,v 2.27 1998/12/11 13:40:43 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4BREPSolidPCone.hh"
#include "G4FCylindricalSurface.hh"
#include "G4FConicalSurface.hh"
#include "G4CircularCurve.hh"
#include "G4FPlane.hh"
G4BREPSolidPCone::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[]
): G4BREPSolid(name)
{
const int sections= num_z_planes-1;
nb_of_surfaces = 2*sections+2;
SurfaceVec = new G4Surface*[nb_of_surfaces];
G4ThreeVector Axis(0,0,1);
G4ThreeVector Origin(0,0,z_start);
G4double Length;
G4ThreeVector LocalOrigin(0,0,z_start);
G4int a, b = 0;
G4ThreeVector PlaneAxis(0, 0, 1);
G4ThreeVector PlaneDir (0, 1, 0);
///////////////////////////////////////////////////
// Temporary
for (G4int x = 0; x <= sections; x++)
{
G4cout<<"Z"<<x<<"="<<z_values[x];
G4cout<<" Rmin"<<x<<"="<<RMIN[x];
G4cout<<" Rmax"<<x<<"="<<RMAX[x]<<endl;
}
G4cout<<"start angle ="<<start_angle<<endl;
G4cout<<"open angle ="<<opening_angle<<endl;
G4cout<<"zstart ="<<z_start<<endl;
///////////////////////////////////////////////////
// Test the validity of the R values
// RMIN[0] and RMIN[num_z_planes-1] cannot be = 0
// when RMIN[0] or RMIN[num_z_planes-1] are = 0
if( ((RMIN[0] == 0) && (RMAX[0] == 0)) ||
((RMIN[num_z_planes-1] == 0) && (RMAX[num_z_planes-1] == 0)) )
G4Exception("RMIN at the extremities can not be nul when RMAX = 0");
// only RMAX[0] and RMAX[num_z_planes-1] can be = 0
for(a = 1; a < num_z_planes-1; a++)
if (RMAX[a] == 0)
G4Exception("RMAX inside the solid can not be nul");
// RMAX[a] must be greater than RMIN[a]
for(a = 0; a < num_z_planes; a++)
if (RMIN[a] >= RMAX[a])
G4Exception("RMAX must be greater than RMIN");
///////////////////////////////////////////////////
// Create cylindrical et conical surfaces
for(a=0; a<sections; a++)
{
// Surface length
Length = z_values[a+1] - z_values[a];
if (Length == 0)
{
// The surface to create is planar
G4double R1, R2;
// test where is the plane surface
if(RMAX[a] != RMAX[a+1])
{
R1 = RMAX[a];
R2 = RMAX[a+1];
}
else if(RMIN[a] != RMIN[a+1])
{
R1 = RMIN[a];
R2 = RMIN[a+1];
}
else
{
G4cerr << "Error in construction of G4BREPSolidPCone: "
<< "Exactly the same z, rmin and rmax given for "
<< "consecutive indices, " << a << " and " << a+1 << endl;
// G4Exception("G4BREPSolidPCone constructor: Error in parameter values");
continue;
}
// Create plane surface
G4Point3D ArcStart1 = LocalOrigin + (R1*PlaneDir);
G4Point3D ArcStart2 = LocalOrigin + (R2*PlaneDir);
G4CurveVector cv1;
G4CircularCurve *tmp1, *tmp2;
if(R1 != 0)
{
tmp1 = new G4CircularCurve;
tmp1->Init(G4Axis2Placement3D(PlaneDir, PlaneAxis, LocalOrigin), R1);
tmp1->SetBounds(ArcStart1, ArcStart1);
if(R1>R2)
tmp1->SetSameSense(1);
else
tmp1->SetSameSense(0);
cv1.append(tmp1);
}
if(R2 != 0)
{
tmp2 = new G4CircularCurve;
tmp2->Init(G4Axis2Placement3D(PlaneDir, PlaneAxis, LocalOrigin), R2);
tmp2->SetBounds(ArcStart2, ArcStart2);
if(R1>R2)
tmp2->SetSameSense(0);
else
tmp2->SetSameSense(1);
cv1.append(tmp2);
}
SurfaceVec[b] = new G4FPlane(PlaneDir, PlaneAxis, LocalOrigin);
SurfaceVec[b]->SetBoundaries(&cv1);
nb_of_surfaces--;
b++;
}
else
{
// The surface to create is conical or cylindrical
// Inner PCone
if(RMIN[a] != RMIN[a+1])
{
// Create cone
if(RMIN[a] > RMIN[a+1])
{
G4Vector3D ConeOrigin = LocalOrigin ;
SurfaceVec[b] = new G4FConicalSurface(ConeOrigin, Axis, Length,
RMIN[a+1], RMIN[a]);
}
else
{
G4Vector3D Axis2 = (-1*Axis);
G4Vector3D LocalOrigin2 = LocalOrigin + (Length*Axis);
G4Vector3D ConeOrigin = LocalOrigin2 ;
SurfaceVec[b] = new G4FConicalSurface(ConeOrigin, Axis2,
Length, RMIN[a], RMIN[a+1]);
}
b++;
}
else
{
if (RMIN[a] == 0)
{
// Do not create any surface
// and decrease nb_of_surfaces
nb_of_surfaces--;
}
else
{
// Create cylinder
G4Vector3D CylOrigin = LocalOrigin ;
SurfaceVec[b] = new G4FCylindricalSurface(CylOrigin, Axis,
RMIN[a], Length );
b++;
}
}
// Outer PCone
if(RMAX[a] != RMAX[a+1])
{
// Create cone
if(RMAX[a] > RMAX[a+1])
{
G4Vector3D ConeOrigin = LocalOrigin ;
SurfaceVec[b] = new G4FConicalSurface(ConeOrigin, Axis,
Length, RMAX[a+1], RMAX[a]);
}
else
{
G4Vector3D Axis2 = (-1*Axis);
G4Vector3D LocalOrigin2 = LocalOrigin + (Length*Axis);
G4Vector3D ConeOrigin = LocalOrigin2 ;
SurfaceVec[b] = new G4FConicalSurface(ConeOrigin, Axis2,
Length, RMAX[a], RMAX[a+1]);
}
b++;
}
else
{
// Create cylinder
G4Vector3D CylOrigin = LocalOrigin ;
if (RMAX[a] == 0)
{
// Do not create any surface
// and decrease nb_of_surfaces
nb_of_surfaces--;
}
else
{
// Create cylinder
G4Vector3D CylOrigin = LocalOrigin ;
SurfaceVec[b] = new G4FCylindricalSurface(CylOrigin, Axis,
RMAX[a], Length );
b++;
}
}
}
// Move surface origin to next section
LocalOrigin = LocalOrigin + (Length*Axis);
}
///////////////////////////////////////////////////
// Create two end planes
// Create start G4Plane & boundaries
G4Point3D ArcStart1a = Origin + (RMIN[0]*PlaneDir);
G4Point3D ArcStart1b = Origin + (RMAX[0]*PlaneDir);
G4CurveVector cv;
G4CircularCurve* tmp;
tmp = new G4CircularCurve;
tmp->Init(G4Axis2Placement3D(PlaneDir, PlaneAxis, Origin), RMIN[0]);
tmp->SetBounds(ArcStart1a, ArcStart1a);
tmp->SetSameSense(0);
cv.append(tmp);
tmp = new G4CircularCurve;
tmp->Init(G4Axis2Placement3D(PlaneDir, PlaneAxis, Origin), RMAX[0]);
tmp->SetBounds(ArcStart1b, ArcStart1b);
tmp->SetSameSense(1);
cv.append(tmp);
SurfaceVec[nb_of_surfaces-2] = new G4FPlane(PlaneDir, PlaneAxis, Origin);
SurfaceVec[nb_of_surfaces-2]->SetBoundaries(&cv);
// Create end G4Plane & boundaries
G4Point3D ArcStart2a = LocalOrigin + (RMIN[sections]*PlaneDir);
G4Point3D ArcStart2b = LocalOrigin + (RMAX[sections]*PlaneDir);
cv.clear();
tmp = new G4CircularCurve;
tmp->Init(G4Axis2Placement3D(PlaneDir, PlaneAxis, LocalOrigin),
RMIN[sections]);
tmp->SetBounds(ArcStart2a, ArcStart2a);
tmp->SetSameSense(0);
cv.append(tmp);
tmp = new G4CircularCurve;
tmp->Init(G4Axis2Placement3D(PlaneDir, PlaneAxis, LocalOrigin),
RMAX[sections]);
tmp->SetBounds(ArcStart2b, ArcStart2b);
tmp->SetSameSense(1);
cv.append(tmp);
SurfaceVec[nb_of_surfaces-1]= new G4FPlane(PlaneDir, PlaneAxis, LocalOrigin);
SurfaceVec[nb_of_surfaces-1]->SetBoundaries(&cv);
active=1;
Initialize();
// Store the original parameters, to be used in visualisation
original_parameters.Start_angle= start_angle;
original_parameters.Opening_angle= opening_angle;
original_parameters.Num_z_planes= num_z_planes;
// original_parameters.z_start= z_start;
original_parameters.Z_values= new G4double[num_z_planes];
original_parameters.Rmin= new G4double[nb_of_surfaces];
original_parameters.Rmax= new G4double[nb_of_surfaces];
for(int is=0;is<num_z_planes;is++)
{
original_parameters.Z_values[is]= z_values[is];
original_parameters.Rmin[is]= RMIN[is];
original_parameters.Rmax[is]= RMAX[is];
}
// z_values[0] should be equal to z_start, for consistency
// with what the constructor does.
// Otherwise the z_values that are given are used
// shifted by z_values[0] - z_start:
// (because z_values are only used in
// line 26: Length = z_values[a+1] - z_values[a];
// ) // JA Apr 2, 97
/*
if( z_values[0] != z_start )
{
G4cerr << "ERROR in creating G4BREPSolidPCone: "
<< " z_values[0]= " << z_values[0] << " is not equal to "
<< " z_start= " , z_start;
// G4Exception(" Error in creating G4BREPSolidPCone: z_values[0] must be equal to z_start" );
original_parameters.Z_values[0]= z_start;
}
*/
}
G4BREPSolidPCone::~G4BREPSolidPCone()
{
delete[] original_parameters.Z_values;
delete[] original_parameters.Rmin;
delete[] original_parameters.Rmax;
}
void G4BREPSolidPCone::Initialize()
{
// Calc bounding box for solids and surfaces
// Convert concave planes to convex
ShortestDistance=1000000;
CheckSurfaceNormals();
if(!Box || !AxisBox)
IsConvex();
CalcBBoxes();
}
EInside G4BREPSolidPCone::Inside(register const G4ThreeVector& Pt) const
{
// Check if point lies between end planes of PCone
G4double dist1 = SurfaceVec[nb_of_surfaces-1]->ClosestDistanceToPoint(Pt);
G4double dist2 = SurfaceVec[nb_of_surfaces-2]->ClosestDistanceToPoint(Pt);
if((dist1 < -kCarTolerance && dist2 <-kCarTolerance)||
(dist1 > kCarTolerance && dist2 >kCarTolerance) )
return kOutside;
G4Vector3D v(1,0,0);
G4double Dist;
G4double halfTolerance = kCarTolerance*0.5;
G4Vector3D Pttmp(Pt);
G4Vector3D Vtmp(v);
G4Ray r(Pttmp, Vtmp);
TestSurfaceBBoxes(r);
G4int hits=0;
for(G4int a=0; a < nb_of_surfaces; a++)
{
if(SurfaceVec[a]->Active())
if(SurfaceVec[a]->Intersect(r))
{
if(SurfaceVec[a]->Distance() < kCarTolerance)
return kSurface;
hits++;
}
}
// Set the surfaces to active again
for(G4int b=0; b < nb_of_surfaces; b++)
SurfaceVec[b]->Reset();
if(hits&1)
return kInside;
return kOutside;
}
G4ThreeVector G4BREPSolidPCone::SurfaceNormal(const G4ThreeVector& Pt) const
{
G4cout<<" SurfaceNormal() of G4BREPSolidPCone modified by L. Broglia";
G4Vector3D Ptv = Pt;
G4Vector3D n(0,0,0);
G4double zCoord = Pt.z();
const G4int num_z_planes = original_parameters.Num_z_planes;
G4int iplane;
// Find the appropriate z "slice"
//
for(iplane=0; iplane< num_z_planes; iplane++)
if ( (zCoord < original_parameters.Z_values[iplane+1]) &&
(zCoord >= original_parameters.Z_values[iplane]) )
break;
G4Vector3D norm;
G4Ray r( Pt, G4Vector3D(1, 0, 0) );
// We must find which is the correct surface, the inner or the outer one
// (if they exist)
for(iplane = 0; iplane < num_z_planes; iplane++)
{
// check if the point is on the surface
if(SurfaceVec[iplane]->Intersect(r))
if(SurfaceVec[iplane]->Distance() < kCarTolerance)
// the point is on the surface
break;
}
norm = SurfaceVec[iplane]->SurfaceNormal(Pt);
n = G4ThreeVector ( norm.x(), norm.y(), norm.z());
n = n.unit();
/*
if ( SurfaceVec[innerSurface]->WithinBoundary(Ptv) == 1 )
{
norm = SurfaceVec[ innersurface ]->SurfaceNormal(Pt);
}
else if ( SurfaceVec[outerSurface]->WithinBoundary(Ptv) == 1 )
{
norm = SurfaceVec[ outerSurface]->SurfaceNormal(Pt);
}
// Check if it is on one of the top/bottom planes
//
if ( fabs(zCoord - original_parameters.Z_values[0]) < kCarTolerance )
{
// n = G4ThreeVector (0., 0., sign( original_parameters.Z_values[0]
// -original_parameters.Z_values[1]) );
n = G4ThreeVector (0., 0., original_parameters.Z_values[0]
-original_parameters.Z_values[1] );
n = n.unit();
}
else if (fabs(zCoord - original_parameters.Z_values[num_z_planes-1]) <
kCarTolerance)
{
n = G4ThreeVector(0., 0., original_parameters.Z_values[num_z_planes]
-original_parameters.Z_values[num_z_planes-1] );
n = n.unit();
}
*/
return n;
}
G4double G4BREPSolidPCone::DistanceToIn(const G4ThreeVector& Pt) const
{
G4double *dists = new G4double[nb_of_surfaces];
G4double halfTolerance = kCarTolerance*0.5;
G4int a;
for(a=0; a< nb_of_surfaces;a++)
dists[a] = fabs(SurfaceVec[a]->HowNear(Pt));
G4double Dist=kInfinity;
for(a=0; a< nb_of_surfaces;a++)
if(Dist>dists[a]) Dist = dists[a];
delete[] dists;
// Set the surfaces to active again
for(G4int b=0; b < nb_of_surfaces; b++)
SurfaceVec[b]->Reset();
return Dist;
}
G4double G4BREPSolidPCone::DistanceToIn(register const G4ThreeVector& Pt,
register const G4ThreeVector& V) const
{
int a;
Reset();
G4double halfTolerance = kCarTolerance*0.5;
G4Vector3D Pttmp(Pt);
G4Vector3D Vtmp(V);
// G4double kInfinity = ;
G4Ray r(Pttmp, Vtmp);
TestSurfaceBBoxes(r);
ShortestDistance = kInfinity;
for(a=0; a< nb_of_surfaces;a++)
{
if(SurfaceVec[a]->Active())
if(SurfaceVec[a]->Intersect( r ))
{
if(ShortestDistance > SurfaceVec[a]->Distance())
if(SurfaceVec[a]->Distance()> halfTolerance)
{
ShortestDistance = SurfaceVec[a]->Distance();
}
else
{
G4Vector3D Norm = SurfaceVec[a]->SurfaceNormal(Pttmp);
if((Norm * Vtmp)<0)
ShortestDistance = SurfaceVec[a]->Distance();
}
}
}
// Set the surfaces to active again
for(G4int b=0; b < nb_of_surfaces; b++)
SurfaceVec[b]->Reset();
if(ShortestDistance != kInfinity)
return sqrt(ShortestDistance);
return kInfinity;
}
G4double G4BREPSolidPCone::DistanceToOut(register const G4ThreeVector& Pt,
register const G4ThreeVector& V,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n ) const
{
const G4double halfTolerance = kCarTolerance*0.5;
G4Vector3D Ptv = Pt;
G4double wb = 0.0;
G4int a;
for( a=0; a< nb_of_surfaces-2; a++)
{
wb = fabs( SurfaceVec[a]->HowNear(Ptv) );
// If we are on a surface and exiting it return Zero
if ( (wb < halfTolerance) && (V.dot(SurfaceVec[a]->Normal(Ptv))>0) )
{
return (0.0);
}
}
if(validNorm)
*validNorm=false;
Reset();
G4Vector3D Pttmp(Pt);
G4Vector3D Vtmp(V);
// G4double kInfinity = 10e20;
G4Ray r(Pttmp, Vtmp);
TestSurfaceBBoxes(r);
ShortestDistance = kInfinity;
for(a=0; a< nb_of_surfaces;a++)
if(SurfaceVec[a]->Active())
if(SurfaceVec[a]->Intersect( r ))
if(ShortestDistance > SurfaceVec[a]->Distance()&&
SurfaceVec[a]->Distance()> halfTolerance)
ShortestDistance = SurfaceVec[a]->Distance();
// Set the surfaces to active again
for(G4int b=0; b < nb_of_surfaces; b++)
SurfaceVec[b]->Reset();
if(ShortestDistance != kInfinity)
return sqrt(ShortestDistance);
return kInfinity;
}
G4double G4BREPSolidPCone::DistanceToOut(const G4ThreeVector& Pt) const
{
int a;
G4double *dists = new G4double[nb_of_surfaces];
G4double halfTolerance = kCarTolerance*0.5;
for(a=0; a< nb_of_surfaces; a++)
dists[a] = fabs(SurfaceVec[a]->HowNear(Pt));
G4double Dist=kInfinity;
for(a=0; a< nb_of_surfaces;a++)
if( Dist>dists[a] ) Dist = dists[a];
// Set the surfaces to active again
for(G4int b=0; b < nb_of_surfaces; b++)
SurfaceVec[b]->Reset();
// If we are on a surface, the return value Dist must be zero!
delete[] dists;
return Dist;
}
// In graphics_reps:
#include "G4Polyhedron.hh"
G4Polyhedron* G4BREPSolidPCone::CreatePolyhedron() const
{
return new G4PolyhedronPcon( original_parameters.Start_angle,
original_parameters.Opening_angle,
original_parameters.Num_z_planes,
original_parameters.Z_values,
original_parameters.Rmin,
original_parameters.Rmax);
}
@@ -0,0 +1,484 @@
// 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.cc,v 2.11 1998/12/11 13:40:46 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4BREPSolidPolyhedra.hh"
#include "G4FPlane.hh"
G4BREPSolidPolyhedra::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[]
) : G4BREPSolid(name)
{
const int sections= num_z_planes - 1;
if(dphi == 2*pi)
nb_of_surfaces = 2*(sections * sides) + 2;
else
nb_of_surfaces = 2*(sections * sides) + 4;
SurfaceVec = new G4Surface*[nb_of_surfaces];
G4Vector3D Axis(0,0,1);
G4Vector3D YAxis(0,1,0);
G4Vector3D TmpAxis;
G4Point3D Origin(0,0,z_start);
G4Point3D LocalOrigin(0,0,z_start);
G4double Length;
int Count =0;
G4double PartAngle = (dphi - phi1)/sides;
///////////////////////////////////////////////////
// Temporary
for (G4int x = 0; x <= sections; x++)
{
cout<<"Z"<<x<<"="<<z_values[x];
cout<<" Rmin"<<x<<"="<<RMIN[x];
cout<<" Rmax"<<x<<"="<<RMAX[x]<<endl;
}
cout<<"phi1 ="<<phi1<<endl;
cout<<"dphi ="<<dphi<<endl;
cout<<"sides ="<<sides<<endl;
cout<<"zstart ="<<z_start<<endl;
///////////////////////////////////////////////////
for(G4int a=0;a<sections;a++)
{
TmpAxis= YAxis;
TmpAxis.rotateZ(phi1);
Length = z_values[a+1] - z_values[a];
// Create sides
for(int b=0;b<sides;b++)
{
G4Point3DVector PointList(4);
// Create inner side
// Calc points for the planar surface boundary
PointList[0] = LocalOrigin + (RMIN[a] * TmpAxis);
PointList[1] = LocalOrigin + (Length*Axis) + (RMIN[a+1] * TmpAxis);
TmpAxis.rotateZ(PartAngle);
PointList[2] = LocalOrigin + (Length*Axis) + (RMIN[a+1] * TmpAxis);
PointList[3] = LocalOrigin + (RMIN[a] * TmpAxis);
SurfaceVec[Count] = new G4FPlane( &PointList);
Count++;
// Rotate axis back for the other surface point calculation
TmpAxis.rotateZ(-PartAngle);
// Calc points for the planar surface boundary
G4Point3DVector PointList2(4);
PointList2[0] = LocalOrigin + (RMAX[a] * TmpAxis);
PointList2[1] = LocalOrigin + (Length*Axis) + (RMAX[a+1] * TmpAxis);
TmpAxis.rotateZ(PartAngle);
PointList2[2] = LocalOrigin + (Length*Axis) + (RMAX[a+1] * TmpAxis);
PointList2[3] = LocalOrigin + (RMAX[a] * TmpAxis);
SurfaceVec[Count] = new G4FPlane(&PointList2);
Count++;
}
LocalOrigin = LocalOrigin + (Length*Axis);
}
// Create end planes
if(dphi == 2*pi)
{
// Create only end planes
G4Point3DVector EndPointList(sides);
G4Point3DVector InnerPointList(sides);
G4Point3DVector EndPointList2(sides);
G4Point3DVector InnerPointList2(sides);
TmpAxis = YAxis;
TmpAxis.rotateZ(phi1);
TmpAxis.rotateZ(dphi);
for(int c=0;c<sides;c++)
{
// outer polyline for origin end
EndPointList[c] = Origin + (RMAX[0] * TmpAxis);
InnerPointList[c] = Origin + (RMIN[0] * TmpAxis);
EndPointList2[c] = LocalOrigin + (RMAX[sections] * TmpAxis);
InnerPointList2[c] = LocalOrigin + (RMIN[sections] * TmpAxis);
TmpAxis.rotateZ(-PartAngle);
}
SurfaceVec[nb_of_surfaces-2] =
new G4FPlane(&EndPointList, &InnerPointList);
SurfaceVec[nb_of_surfaces-1] =
new G4FPlane(&EndPointList2, &InnerPointList2);
}
else
{
TmpAxis = YAxis;
TmpAxis.rotateZ(phi1);
TmpAxis.rotateZ(dphi);
// Create end planes & two planes for the "missing" part
G4Point3DVector EndPointList(sides+2);
G4Point3DVector InnerPointList(sides+2);
G4Point3DVector EndPointList2(sides+2);
G4Point3DVector InnerPointList2(sides+2);
TmpAxis = YAxis;
for(int c=0;c<sides+1;c++)
{
// outer polyline for origin end
EndPointList[c] = Origin + (RMAX[0] * TmpAxis);
InnerPointList[c] = Origin + (RMIN[0] * TmpAxis);
EndPointList2[c] = LocalOrigin + (RMAX[sections] * TmpAxis);
InnerPointList2[c] = LocalOrigin + (RMIN[sections] * TmpAxis);
TmpAxis.rotateZ(-PartAngle);
}
// Create the extra points on the axis
TmpAxis = YAxis;
TmpAxis.rotateZ(phi1);
EndPointList[sides+1] = Origin;
InnerPointList[sides+1] = Origin;
EndPointList2[sides+1] = LocalOrigin;
InnerPointList2[sides+1] = LocalOrigin;
int points = sides+2;
SurfaceVec[nb_of_surfaces-4] =
new G4FPlane(&EndPointList, &InnerPointList);
SurfaceVec[nb_of_surfaces-3] =
new G4FPlane(&EndPointList2, &InnerPointList2);
// Create the planars for the "gap"
TmpAxis = YAxis;
G4ThreeVector TmpAxis2 = YAxis;
TmpAxis.rotateZ(phi1);
TmpAxis2.rotateZ(phi1);
TmpAxis2.rotateZ(dphi);
LocalOrigin=Origin;
points = sections*2+2;
G4Point3DVector GapPointList(points);
G4Point3DVector GapPointList2(points);
Count=0;
for(int d=0;d<sections+1;d++)
{
GapPointList[Count] = LocalOrigin + (RMAX[d]*TmpAxis);
GapPointList[points-1-Count] = LocalOrigin + (RMIN[d]*TmpAxis);
GapPointList2[Count] = LocalOrigin + (RMAX[d]*TmpAxis2);
GapPointList2[points-1-Count] = LocalOrigin + (RMIN[d]*TmpAxis2);
Count++;
Length = z_values[d+1] - z_values[d];
LocalOrigin = LocalOrigin+(Length*Axis);
}
SurfaceVec[nb_of_surfaces-2] = new G4FPlane(&GapPointList);
SurfaceVec[nb_of_surfaces-1] = new G4FPlane(&GapPointList2);
}
// Store the original parameters, to be used in visualisation
// Note radii are scaled because this BREP uses the radius of the
// inscribed circle but graphics_reps/G4Polyhedron uses the radius of
// the circumscribed circle.
original_parameters.Start_angle= phi1;
original_parameters.Opening_angle= dphi;
original_parameters.Sides= sides;
original_parameters.Num_z_planes= num_z_planes;
original_parameters.Z_values= new G4double[num_z_planes];
original_parameters.Rmin= new G4double[num_z_planes];
original_parameters.Rmax= new G4double[num_z_planes];
G4double rFactor = cos(dphi/(2*sides));
for(int is=0;is<num_z_planes;is++)
{
original_parameters.Z_values[is]= z_values[is];
original_parameters.Rmin[is]= RMIN[is]/rFactor;
original_parameters.Rmax[is]= RMAX[is]/rFactor;
}
// z_values[0] should be equal to z_start, for consistency
// with what the constructor does.
// Otherwise the z_values that are shifted by (z_values[0] - z_start) ,
// because z_values are only used in the form
// length = z_values[d+1] - z_values[d]; // JA Apr 2, 97
if( z_values[0] != z_start )
{
G4cerr << "ERROR in creating G4BREPSolidPolyhedra: " <<
" z_values[0]= " << z_values[0] << " is not equal to " <<
" z_start= " , z_start;
// G4Exception(" Error in creating G4BREPSolidPolyhedra: z_values[0] must be equal to z_start" );
original_parameters.Z_values[0]= z_start;
}
active=1;
Initialize();
}
G4BREPSolidPolyhedra::~G4BREPSolidPolyhedra()
{
delete[] original_parameters.Z_values;
delete[] original_parameters.Rmin;
delete[] original_parameters.Rmax;
}
void G4BREPSolidPolyhedra::Initialize()
{
// Calc bounding box for solids and surfaces
// Convert concave planes to convex
ShortestDistance=1000000;
CheckSurfaceNormals();
if(!Box || !AxisBox)
IsConvex();
CalcBBoxes();
}
EInside G4BREPSolidPolyhedra::Inside(register const G4ThreeVector& Pt) const
{
G4double *dists = new G4double[nb_of_surfaces];
G4double Dist = kInfinity;
G4double tmpdist=kInfinity;
G4double halfTolerance = kCarTolerance*0.5;
for(int a=0; a< nb_of_surfaces;a++)
{
tmpdist = (SurfaceVec[a]->HowNear(Pt));
if(fabs(Dist) > fabs(tmpdist))
Dist = tmpdist;
}
if(Dist > halfTolerance)
return kOutside;
if(Dist < -halfTolerance)
return kInside;
return kSurface;
}
G4ThreeVector G4BREPSolidPolyhedra::SurfaceNormal
(const G4ThreeVector& Pt) const
{
G4cout<<" SurfaceNormal() of G4BREPSolidPolyhedra modified by L. Broglia";
/*
//G4Exception(" SurfaceNormal() of G4BREPSolidPolyhedra is not yet implemented." );
#ifdef WILL_IMPLEMENT
G4double zCoord= Pt.z();
G4int a, zSlice, phiSlice;
// Try to find the appropriate z "slice"
for(a=0; a< nb_of_surfaces-2;a++)
if ( (zCoord < original_parameters.Z_values[a+1])
&&(zCoord >= original_parameters.Z_values[a]) )
break;
zSlice= a;
// Try to find the appropriate phi plane
phiSlice = 0;
unsigned int isurface=0;
G4ThreeVec norm = SurfaceVec[isurface]->SurfaceNormal(Pt);
G4ThreeVector normalVector = G4ThreeVector ( norm.GetX(),
norm.GetY(),
norm.GetZ());
#else
G4ThreeVector normalVector = G4ThreeVector ( 0.0, 0.0, 1.0);
#endif
*/
G4Vector3D Ptv = Pt;
G4Vector3D n(0,0,0);
G4double zCoord = Pt.z();
const G4int num_z_planes = original_parameters.Num_z_planes;
G4int iplane;
// Find the appropriate z "slice"
//
for(iplane=0; iplane< num_z_planes; iplane++)
if ( (zCoord < original_parameters.Z_values[iplane+1]) &&
(zCoord >= original_parameters.Z_values[iplane]) )
break;
G4Vector3D norm;
G4Ray r( Pt, G4Vector3D(1, 0, 0) );
// We must find which is the correct surface, the inner or the outer one
// (if they exist)
for(iplane = 0; iplane < num_z_planes; iplane++)
{
// check if the point is on the surface
if(SurfaceVec[iplane]->Intersect(r))
if(SurfaceVec[iplane]->Distance() < kCarTolerance)
// the point is on the surface
break;
}
norm = SurfaceVec[iplane]->SurfaceNormal(Pt);
n = G4ThreeVector ( norm.x(), norm.y(), norm.z());
n = n.unit();
return n;
}
G4double G4BREPSolidPolyhedra::DistanceToIn(const G4ThreeVector& Pt) const
{
G4double Dist=kInfinity;
G4double tmpdist=kInfinity;
G4double halfTolerance = kCarTolerance*0.5;
for(int a=0; a< nb_of_surfaces;a++)
{
tmpdist = fabs(SurfaceVec[a]->HowNear(Pt));
if(Dist>tmpdist && tmpdist> halfTolerance) Dist = tmpdist;
}
return Dist;
}
G4double G4BREPSolidPolyhedra::DistanceToIn(register const G4ThreeVector& Pt,
register const G4ThreeVector& V
) const
{
Reset();
G4Point3D Pttmp(Pt);
G4Vector3D Vtmp(V);
G4double halfTolerance = kCarTolerance*0.5;
// G4double kInfinity = kInfinity;
G4Ray r(Pttmp, Vtmp);
TestSurfaceBBoxes(r);
QuickSort(SurfaceVec, 0, nb_of_surfaces-1);
ShortestDistance = kInfinity;
for(int a=0; a< nb_of_surfaces;a++)
{
if(SurfaceVec[a]->Active())
// L. Broglia : old
// if(SurfaceVec[a]->Intersect(r))
if( (G4FPlane*)(SurfaceVec[a])->Evaluate(r) )
if(ShortestDistance > SurfaceVec[a]->Distance())
if(SurfaceVec[a]->Distance() > halfTolerance)
ShortestDistance = SurfaceVec[a]->Distance();
else
{
G4ThreeVector Norm = SurfaceVec[a]->SurfaceNormal(Pttmp);
if((Norm * Vtmp)<0)
ShortestDistance = SurfaceVec[a]->Distance();
}
}
if(ShortestDistance != kInfinity)
return sqrt(ShortestDistance);
return kInfinity;
}
G4double G4BREPSolidPolyhedra::DistanceToOut(register const G4ThreeVector& Pt,
register const G4ThreeVector& V,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n) const
{
if(validNorm)
*validNorm = false;
Reset();
G4double halfTolerance = kCarTolerance*0.5;
G4Point3D Pttmp(Pt);
G4Vector3D Vtmp(V);
// G4double kInfinity = 10e20;
G4Ray r(Pttmp, Vtmp);
TestSurfaceBBoxes(r);
QuickSort(SurfaceVec, 0, nb_of_surfaces-1);
ShortestDistance = kInfinity;
for(int a=0; a< nb_of_surfaces;a++)
{
if(SurfaceVec[a]->Active())
if(SurfaceVec[a]->Intersect(r))
if(ShortestDistance > SurfaceVec[a]->Distance()&&
SurfaceVec[a]->Distance() > halfTolerance)
ShortestDistance = SurfaceVec[a]->Distance();
}
if(ShortestDistance != kInfinity)
return sqrt(ShortestDistance);
return kInfinity;
}
G4double G4BREPSolidPolyhedra::DistanceToOut(const G4ThreeVector& Pt) const
{
G4double Dist=kInfinity;
G4double tmpdist=kInfinity;
G4double halfTolerance = kCarTolerance*0.5;
for(int a=0; a< nb_of_surfaces;a++)
{
tmpdist = fabs(SurfaceVec[a]->HowNear(Pt));
if(Dist>tmpdist && tmpdist> halfTolerance)
Dist = tmpdist;
}
return Dist;
}
// In graphics_reps:
#include "G4Polyhedron.hh"
G4Polyhedron* G4BREPSolidPolyhedra::CreatePolyhedron() const
{
return new G4PolyhedronPgon( original_parameters.Start_angle,
original_parameters.Opening_angle,
original_parameters.Sides,
original_parameters.Num_z_planes,
original_parameters.Z_values,
original_parameters.Rmin,
original_parameters.Rmax);
}
@@ -0,0 +1,110 @@
// 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.cc,v 2.2 1998/10/20 16:33:39 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4BREPSolidSphere.hh"
#include "G4SphericalSurface.hh"
G4BREPSolidSphere::G4BREPSolidSphere(const G4String name,
const G4Vector3D& o,
const G4Vector3D& xhat,
const G4Vector3D& zhat,
G4double r): G4BREPSolid(name)
{
SurfaceVec = new G4Surface*[1];
G4double ph1 = 0;
G4double ph2 = 2*M_PI;
G4double th1 = 0;
G4double th2 = M_PI;
SurfaceVec[0] = new G4SphericalSurface(o, xhat, zhat, r, ph1, ph2, th1, th2);
nb_of_surfaces = 1;
active=1;
Initialize();
}
EInside G4BREPSolidSphere::Inside(register const G4ThreeVector& Pt) const
{
G4double Dist = SurfaceVec[0]->HowNear(Pt);
if(Dist > 0+kCarTolerance) return kInside;
if(Dist < 0-kCarTolerance) return kOutside;
return kSurface;
}
G4ThreeVector G4BREPSolidSphere::SurfaceNormal(const G4ThreeVector& Pt) const
{
G4Vector3D n = SurfaceVec[0]->Normal(Pt);
G4ThreeVector norm(n.x(), n.y(), n.z());
return norm;
}
G4double G4BREPSolidSphere::DistanceToIn(const G4ThreeVector& Pt) const
{
return fabs(SurfaceVec[0]->HowNear(Pt));
}
G4double G4BREPSolidSphere::DistanceToIn(register const G4ThreeVector& Pt,
register const G4ThreeVector& V) const
{
SphReset();
G4Vector3D Pttmp(Pt);
G4Vector3D Vtmp(V);
G4Ray r(Pttmp, Vtmp);
int Result = SurfaceVec[0]->Intersect( r );
if(Result>0)
{
ShortestDistance = SurfaceVec[0]->Distance();
return sqrt(ShortestDistance);
}
return kInfinity;
}
G4double G4BREPSolidSphere::DistanceToOut(register const G4ThreeVector& Pt,
register const G4ThreeVector& V,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n) const
{
if(validNorm)
*validNorm = false;
SphReset();
G4Vector3D Pttmp(Pt);
G4Vector3D Vtmp(V);
G4Ray r(Pttmp, Vtmp);
if(SurfaceVec[0]->Intersect( r ))
{
if(calcNorm)
{
*validNorm = true;
*n = SurfaceNormal(Pt);
}
ShortestDistance = SurfaceVec[0]->Distance();
return sqrt(ShortestDistance);
}
return kInfinity;
}
G4double G4BREPSolidSphere::DistanceToOut(const G4ThreeVector& Pt) const
{
return fabs(SurfaceVec[0]->HowNear(Pt));
}
@@ -0,0 +1,28 @@
// 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.cc,v 2.1 1998/10/20 16:33:39 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4BREPSolidTorus.hh"
#include "G4ToroidalSurface.hh"
G4BREPSolidTorus::G4BREPSolidTorus(const G4String name,
const G4ThreeVector& origin,
const G4ThreeVector& axis,
const G4ThreeVector& direction,
G4double MinRadius,
G4double MaxRadius): G4BREPSolid(name)
{
SurfaceVec = new G4Surface*[1];
SurfaceVec[0] = new G4ToroidalSurface( origin, axis, direction,
MinRadius, MaxRadius);
nb_of_surfaces = 1;
active = 1;
Initialize();
}
@@ -0,0 +1,240 @@
// 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.cc,v 2.8 1998/12/15 15:45:15 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4BSplineCurve.hh"
#include "G4ControlPoints.hh"
#include "G4KnotVector.hh"
G4BSplineCurve::G4BSplineCurve()
{
}
void G4BSplineCurve::Init(G4int degree0, G4Point3DVector* controlPointsList0,
G4doubleVector* knots0,
G4doubleVector* weightsData0)
{
degree= degree0;
G4int nbpoints = controlPointsList0->length();
controlPointsList = new G4Point3DVector(nbpoints);
G4int a;
for(a = 0; a < nbpoints; a++)
{
(*controlPointsList)[a] = (*controlPointsList0)[a];
}
G4int nbknots = knots0->length();
knots = new G4doubleVector(nbknots);
for(a = 0; a < nbknots; a++)
{
(*knots)[a] = (*knots0)[a];
}
G4int nbweights = weightsData0->length();
weightsData = new G4doubleVector(nbweights);
for(a = 0; a < nbweights; a++)
{
(*weightsData)[a] = (*weightsData0)[a];
}
SetBounds((*knots)[0], (*knots)[knots->length()-1]);
}
G4BSplineCurve::~G4BSplineCurve()
{
delete controlPointsList;
delete knots;
if (weightsData) delete weightsData;
}
/*
void G4BSplineCurve::CalcCurvePlaneNormal()
{
//Calc Normal for surface which is used for the projection
G4ThreeVec norm;
G4Point3d Pt1 = ControlPointList->get(0,0);
G4Point3d Pt2 = ControlPointList->get(0,1);
G4Point3d Pt3 = ControlPointList->get(0,2);
G4Point3d a(Pt2.X()-Pt1.X(), Pt2.Y()-Pt1.Y(), Pt2.Z()-Pt1.Z());
G4Point3d b(Pt3.X()-Pt1.X(), Pt3.Y()-Pt1.Y(), Pt3.Z()-Pt1.Z());
norm.X((a.Y()*b.Z() - a.Z()*b.Y()));
norm.Y((a.X()*b.Z() - a.Z()*b.X()));
norm.Z((a.X()*b.Y() - a.Y()*b.X()));
}
*/
G4Curve* G4BSplineCurve::Project(const G4Transform3D& tr)
{
// just transform + project all control points
// what about self intersections?
G4int n = controlPointsList->length();
G4Point3DVector* newControlPointsList = new G4Point3DVector(n);
for (G4int i=0; i<n; i++)
{
G4Point3D& p= (*newControlPointsList)(i);
p= tr*(*controlPointsList)(i);
p.setZ(0);
}
G4doubleVector* newKnots= new G4doubleVector(*knots);
G4doubleVector* newWeightsData=
weightsData ? new G4doubleVector(*weightsData) : 0;
G4BSplineCurve* r= new G4BSplineCurve;
r->Init(degree, newControlPointsList, newKnots, newWeightsData);
if (IsBounded())
{
r->SetBounds(GetPStart(), GetPEnd());
}
return r;
}
/*
void G4BSplineCurve::ProjectCurve(const G4Plane& Pl1, const G4Plane& Pl2)
{
int rows = ControlPointList->GetRows();
int cols = ControlPointList->GetCols();
int NumberOfPoints = cols * rows;
ProjectedControlPoints = new G4Point2d*[NumberOfPoints];
// Loop through points and do projection
for(int a = 0; a<NumberOfPoints;a++)
{
// Create 2d-point
ProjectedControlPoints[a] = new G4Point2d;
// Project 3d points into 2d
Project((*ProjectedControlPoints[a]), ControlPointList->get(0,a), Pl1, Pl2);
}
}
*/
/*
int G4BSplineCurve::Inside( const G4Point3d& Hit, const G4Ray& rayref)
{
const G4Plane& Pl1 = rayref.GetPlane(0);
const G4Plane& Pl2 = rayref.GetPlane(1);
register G4double DistA1, DistA2, DistB1, DistB2;
// Calc distance from Start point to ray planes
DistA1 = Start.PlaneDistance(Pl1);
// Calc distance from End point to ray planes
DistB1 = End.PlaneDistance(Pl1);
if((DistA1<0 && DistB1>0)||(DistA1>0 && DistB1 <0))
{
DistA2 = Start.PlaneDistance(Pl2);
DistB2 = End.PlaneDistance(Pl2);
// This checks the line Start-End of the convex hull
if(DistA2<0&&DistB2<0)
return 1;
}
// Test for the other lines of the convex hull
// If one of them is on a different side than the
// previously checked line, the curve has to be evaluated
// against the G4Plane.
int Points = ControlPointList->GetCols();
G4Point *CPoint1, *CPoint2;
register G4double CDistA1,CDistA2, CDistB1, CDistB2;
int Flag=0;
for(int a=0;a<Points-1;a++)
{
CPoint1 = &ControlPointList->get(0,a);
CPoint2 = &ControlPointList->get(0,a+1);
CDistA1 = CPoint1->PlaneDistance(Pl1);
CDistB1 = CPoint2->PlaneDistance(Pl1);
if((CDistA1<0 && CDistB1>0)||(CDistA1>0 && CDistB1<0))
{
CDistA2 = CPoint1->PlaneDistance(Pl2);
CDistB2 = CPoint2->PlaneDistance(Pl2);
if (!(CDistA2<0&&CDistB2<0))
{
Flag=1;
break;
}
}
}
if(!Flag)
return 1;
else
{
// Evaluate curve & Pl1 intersection, Calc the intersections distance
// from Pl2 to check which side it lies on.
G4Point3d IntPoint;
// G4cout << "\nG4B_SplineCurve.cc:Inside - Evaluation not yet implemented!!!\n";
// IntPoint = ...
G4double IntDist = IntPoint.PlaneDistance(Pl2);
if(IntDist<0)
return 1;
}
return 0;
}
*/
void G4BSplineCurve::InitBounded()
{
// just like in the old functions
G4int pointCount = controlPointsList->length();
bBox.Init( (*controlPointsList)(0) );
for (G4int i=1; i<pointCount; i++)
{
bBox.Extend( (*controlPointsList)(i) );
}
}
/*
G4Point3d G4BSplineCurve::GetBoundMin()
{
G4Point3d Min = PINFINITY;
int PointCount = ControlPointList->GetCols();
G4Point3d Tmp;
for(int a=0;a<PointCount;a++)
{
Tmp = ControlPointList->get(0,a);
Min > Tmp;
}
return Min;
}
G4Point3d G4BSplineCurve::GetBoundMax()
{
G4Point3d Max = -PINFINITY;
G4Point3d Tmp;
int PointCount = ControlPointList->GetCols();
for(int a=0;a<PointCount;a++)
{
Tmp = ControlPointList->get(0,a);
Max > Tmp;
}
return Max;
}
*/
G4bool G4BSplineCurve::Tangent(G4CurvePoint& cp, G4Vector3D& v)
{
G4Exception("G4BSplineCurve::Tangent");
return false;
}
@@ -0,0 +1,12 @@
// 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.cc,v 2.1 1998/07/02 17:53:59 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4BSplineCurveWithKnots.hh"
@@ -0,0 +1,626 @@
// 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.cc,v 2.10 1998/11/24 16:41:23 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "EntityInst.h"
#include "G4BSplineSurface.hh"
#include "G4BezierSurface.hh"
class G4ControlPoints;
class G4BoundingBox;
G4BSplineSurface::G4BSplineSurface()
{
distance = kInfinity;
dir=ROW;
first_hit = Hit=(G4UVHit*)0;
ctl_points = (G4ControlPoints*)0;
}
G4BSplineSurface::G4BSplineSurface(char* nurbfilename, G4Ray& rayref)
{
distance = kInfinity;
Hit=(G4UVHit*)0;
first_hit = Hit;
}
G4BSplineSurface::G4BSplineSurface(const G4BSplineSurface &tmp)
{
distance = tmp.distance;
Hit=(G4UVHit*)0;
first_hit=Hit;
// next=this;
order[0] = tmp.order[0];
order[1] = tmp.order[1];
dir = tmp.dir;
u_knots = new G4KnotVector(*tmp.u_knots);
v_knots = new G4KnotVector(*tmp.v_knots);
ctl_points = new G4ControlPoints(*tmp.ctl_points);
}
G4BSplineSurface::G4BSplineSurface(G4int u, G4int v, G4KnotVector& u_kv,
G4KnotVector& v_kv,G4ControlPoints& cp)
{
order[0] = u+1;
order[1] = v+1;
u_knots = new G4KnotVector(u_kv);
v_knots = new G4KnotVector(v_kv);
ctl_points = new G4ControlPoints(cp);
}
G4BSplineSurface::~G4BSplineSurface()
{
delete u_knots;
delete v_knots;
delete ctl_points;
G4UVHit* temphit=Hit;
while(Hit!=(G4UVHit*)0)
{
Hit=Hit->next;
delete temphit;
temphit=Hit;
}
delete temphit;// remove last
}
int G4BSplineSurface::Intersect(const G4Ray& rayref)
{
Intersected = 1;
FindIntersections(rayref);
G4BezierSurface *bez_ptr;
bezier_list.MoveToFirst();
distance = kInfinity;
while( bezier_list.index != (G4Surface*)0)
{
bez_ptr = (G4BezierSurface*)bezier_list.GetSurface();
if(bez_ptr->Active())
if(distance > bez_ptr->Distance())
{
// Put data from closest bezier to b-spline data struct
closest_hit = bez_ptr->AveragePoint();
distance = bez_ptr->Distance();
}
else
{
// Set other beziers as inactive
bez_ptr->Active(0);
// Remove beziers that are not closest
// bezier_list.RemoveSurface(bez_ptr);
}
bezier_list.Step();
}
bezier_list.MoveToFirst();
if(bezier_list.number_of_elements)
return 1;
else
{
active=0;
return 0;
}
}
G4Point3D G4BSplineSurface::FinalIntersection()
{
// Compute the real intersection point.
G4BezierSurface* bez_ptr;
while ( bezier_list.number_of_elements > 0 &&
bezier_list.index != (G4Surface*)0)
{
bez_ptr = (G4BezierSurface*)bezier_list.GetSurface();
int tmp = 0;
// L. Broglia
// Modify G4BezierSurface intersection function name
// tmp = bez_ptr->Intersect( bezier_list);
tmp = bez_ptr->BIntersect( bezier_list);
if(!tmp)
{
bezier_list.RemoveSurface(bez_ptr);
if(bezier_list.index != (G4Surface*)0)
bezier_list.index->Active(1);
}
else
if(tmp==1)
{
active=1;
// Hit found
AddHit(bez_ptr->GetU(), bez_ptr->GetV());
// Delete beziers
bezier_list.EmptyList();
}
else
if(tmp==2)
{
// The bezier was split so the last
// two surfaces in the List should
// be bbox tested and if passed
// clipped in both dirs.
// Move to first
bezier_list.MoveToFirst();
// Find the second last.
if(bezier_list.index != bezier_list.last)
while ( ((G4SurfaceList*)bezier_list.index)->next !=
bezier_list.last) bezier_list.Step();
G4BezierSurface* tmp = (G4BezierSurface*) bezier_list.GetSurface();
tmp->CalcBBox();
// L. Broglia tmp->bbox->Test();
int result=0;
if(tmp->bbox->GetTestResult())
{
// Clip
while(!result)
result = tmp->ClipBothDirs();
}
else
{
bezier_list.RemoveSurface(tmp);
}
// Second surface
tmp = (G4BezierSurface*) bezier_list.GetLastSurface();
tmp->CalcBBox();
// L. Broglia tmp->bbox->Test();
if(tmp->bbox->GetTestResult())
{
result = 0;
while(!result)
result = tmp->ClipBothDirs();
}
else
{
bezier_list.RemoveSurface(tmp);
}
bezier_list.RemoveSurface(bez_ptr);
bezier_list.MoveToFirst();
}
bezier_list.Step();
}//While....
Hit = first_hit;
G4Point3D result;
if(Hit == (G4UVHit*)0)
active = 0;
else
{
while(Hit != (G4UVHit*)0)
{
// L. Broglia
// Modify function name
// result = Evaluate();
result = BSEvaluate();
Hit = Hit->next;
}
Hit = first_hit;
}
return result;
}
void G4BSplineSurface::CalcBBox()
{
// Finds the bounds of the b-spline surface iow
// calculates the bounds for a bounding box
// to the surface. The bounding box is used
// for a preliminary check of intersection.
register G4Point3D box_min = PINFINITY;
register G4Point3D box_max =-PINFINITY;
// Loop to search the whole control point mesh
// for the minimum and maximum values for x, y and z.
for(register int a = ctl_points->GetRows()-1; a>=0;a--)
for(register int b = ctl_points->GetCols()-1; b>=0;b--)
{
G4Point3D tmp = ctl_points->Get3D(a,b);
if((box_min.x()) > (tmp.x())) box_min.setX(tmp.x());
if((box_min.y()) > (tmp.y())) box_min.setY(tmp.y());
if((box_min.z()) > (tmp.z())) box_min.setZ(tmp.z());
if((box_max.x()) < (tmp.x())) box_max.setX(tmp.x());
if((box_max.y()) < (tmp.y())) box_max.setY(tmp.y());
if((box_max.z()) < (tmp.z())) box_max.setZ(tmp.z());
}
bbox = new G4BoundingBox3D( box_min, box_max);
}
G4ProjectedSurface* G4BSplineSurface::CopyToProjectedSurface
(const G4Ray& rayref)
{
G4ProjectedSurface* proj_srf = new G4ProjectedSurface() ;
proj_srf->PutOrder(0,GetOrder(0));
proj_srf->PutOrder(1,GetOrder(1));
proj_srf->dir = dir;
proj_srf->u_knots = new G4KnotVector(*u_knots);
proj_srf->v_knots = new G4KnotVector(*v_knots);
proj_srf->ctl_points = new G4ControlPoints
(2, ctl_points->GetRows(), ctl_points->GetCols());
const G4Plane& plane1 = rayref.GetPlane(1);
const G4Plane& plane2 = rayref.GetPlane(2);
ProjectNURBSurfaceTo2D(plane1, plane2, proj_srf);
return proj_srf;
}
void G4BSplineSurface::FindIntersections(const G4Ray& rayref)
{
// Do the projection to 2D
G4ProjectedSurface* proj_srf = CopyToProjectedSurface(rayref);
// Put surface in projected List
projected_list.AddSurface(proj_srf);
// Loop through List of projected surfaces
while(projected_list.number_of_elements > 0)
{
// Get first in List
proj_srf = (G4ProjectedSurface*)projected_list.GetSurface();
// Create the bounding box for the projected surface.
proj_srf->CalcBBox();
// L. Broglia proj_srf->bbox->Test();
// Check bbox test result is ok
if(proj_srf->bbox->GetTestResult())
// Convert the projected surface to a bezier. Split if necessary.
proj_srf->ConvertToBezier(projected_list, bezier_list);
// Remove projected surface
projected_list.RemoveSurface(proj_srf);
}
// Loop through the bezier List
G4BezierSurface* bez_ptr;
distance = INFINITY;
while(bezier_list.index != (G4Surface*)0)
{
bez_ptr = (G4BezierSurface*)bezier_list.GetSurface();
// Add a temporary Hit
AddHit(bez_ptr->UAverage(), bez_ptr->VAverage());
// Evaluate Hit
// L. Broglia
// Modify function name
// bez_ptr->SetAveragePoint(Evaluate());
bez_ptr->SetAveragePoint(BSEvaluate());
// Calculate distance to ray origin
bez_ptr->CalcDistance(rayref.GetStart());
// Put closest to b_splines distance value
if(bez_ptr->Distance() < distance) distance = bez_ptr->Distance();
// Remove the temporary Hit
delete Hit;
first_hit = Hit = (G4UVHit*)0;
// Move to next in the List
bezier_list.Step();
}
bezier_list.MoveToFirst();
if(bezier_list.number_of_elements == 0)
{
active=0;
return;
}
// Check that approx Hit is in direction of ray
const G4Point3D& Pt = rayref.GetStart();
const G4Vector3D& Dir = rayref.GetDir();
G4Point3D TestPoint = (0.00001*Dir) + Pt;
G4BezierSurface* Bsrf = (G4BezierSurface*)bezier_list.GetSurface(0);
G4Point3D AveragePoint = Bsrf->AveragePoint();
G4double TestDistance = TestPoint.distance2(AveragePoint);
if(TestDistance > distance)
// Hit behind ray starting point, no intersection.
active=0;
}
void G4BSplineSurface::AddHit(G4double u, G4double v)
{
if(Hit == (G4UVHit*)0)
{
first_hit = new G4UVHit(u,v);
first_hit->next = (G4UVHit*)0;
Hit = first_hit;
}
else
{
Hit->next = new G4UVHit(u,v);
Hit = Hit->next;
Hit->next=(G4UVHit*)0;
}
}
void G4BSplineSurface::ProjectNURBSurfaceTo2D
(const G4Plane& plane1, const G4Plane& plane2,
register G4ProjectedSurface* proj_srf)
{
// Projects the nurb surface so that the z-axis = ray.
/* L. Broglia
G4Point* tmp = (G4Point*)&ctl_points->get(0,0);
*/
G4PointRat tmp = ctl_points->GetRat(0,0);
int rational = tmp.GetType();// Get the type of control point
register G4Point3D psrfcoords;
register int rows = ctl_points->GetRows();
register int cols = ctl_points->GetCols();
for (register int i=0; i< rows; i++)
for(register int j=0; j < cols;j++)
{
if ( rational==4 ) // 4 coordinates
{
G4PointRat& srfcoords = ctl_points->GetRat(i, j);
// L. Broglia
// Changes for new G4PointRat
// Calculate the x- and y-coordinates for the new
// 2-D surface.
psrfcoords.setX(( srfcoords.x() * plane1.a
+srfcoords.y() * plane1.b
+srfcoords.z() * plane1.c
-srfcoords.w() * plane1.d));
psrfcoords.setY(( srfcoords.x() * plane2.a
+srfcoords.y() * plane2.b
+srfcoords.z() * plane2.c
-srfcoords.w() * plane2.d));
proj_srf->ctl_points->put(i,j,psrfcoords);
}
else // 3 coordinates
{
G4Point3D srfcoords = ctl_points->Get3D(i, j);
psrfcoords.setX(( srfcoords.x() * plane1.a
+srfcoords.y() * plane1.b
+srfcoords.z() * plane1.c
- plane1.d));
psrfcoords.setY(( srfcoords.x() * plane2.a
+srfcoords.y() * plane2.b
+srfcoords.z() * plane2.c
- plane2.d));
proj_srf->ctl_points->put(i,j,psrfcoords);
}
}
}
/* L. Broglia
Changes for new G4PointRat
G4Point& G4BSplineSurface::InternalEvalCrv(int i, G4ControlPoints* crv)*/
G4PointRat& G4BSplineSurface::InternalEvalCrv(int i, G4ControlPoints* crv)
{
if ( ord <= 1 )
return crv->GetRat(i, k_index);
register int j = k_index;
while ( j > (k_index - ord + 1))
{
register G4double k1, k2;
k1 = tmp_knots->GetKnot((j + ord - 1));
k2 = tmp_knots->GetKnot(j);
if ((abs(k1 - k2)) > kCarTolerance )
{
/* L. Broglia
register G4PointRat* pts1 = &crv->get(i,j-1);
register G4PointRat* pts2 = &crv->get(i,j );
if(pts1->GetType()==3)
{
crv->CalcValues(k1, param, *(G4Point3D*)pts1, k2, *(G4Point3D*)pts2);
crv->put(0, j, *(G4Point3D*)pts2);
}
else
{
crv->CalcValues(k1, param, *(G4PointRat*)pts1, k2, *(G4PointRat*)pts2);
crv->put(0, j, *(G4PointRat*)pts2);
}
*/
register G4PointRat* pts1 = &crv->GetRat(i,j-1);
register G4PointRat* pts2 = &crv->GetRat(i,j );
}
j--;
}
ord = ord-1;
return InternalEvalCrv(0, crv); // Recursion
}
G4Point3D G4BSplineSurface::BSEvaluate()
{
register int i;
register int row_size = ctl_points->GetRows();
register G4ControlPoints *diff_curve;
register G4ControlPoints* curves;
G4Point3D result;
/* L. Broglia
G4Point* tmp = (G4Point*)&ctl_points->get(0,0);
*/
G4PointRat* tmp = &ctl_points->GetRat(0,0);
register int point_type = tmp->GetType();
diff_curve = new G4ControlPoints(point_type, row_size, 1);
k_index = u_knots->GetKnotIndex(Hit->u, GetOrder(ROW) );
ord = GetOrder(ROW);
if(k_index==-1)
{
delete diff_curve;
active = 0;
return result;
}
curves=new G4ControlPoints(*ctl_points);
tmp_knots = u_knots;
param = Hit->u;
if(point_type == 4)
{
for ( i = 0; i < row_size; i++)
{
ord = GetOrder(ROW);
register G4PointRat rtr_pt = (G4PointRat&) InternalEvalCrv(i, curves);
diff_curve->put(0,i,rtr_pt);
}
k_index = v_knots->GetKnotIndex( Hit->v, GetOrder(COL) );
if(k_index==-1)
{
delete diff_curve;
delete curves;
active = 0;
return result;
}
ord = GetOrder(COL);
tmp_knots = v_knots;
param = Hit->v;
// Evaluate the diff_curve...
G4PointRat rat_result = (G4PointRat&) InternalEvalCrv(0, diff_curve);
// Calc the 3D values.
// L. Broglia
// Changes for new G4PointRat
result.setX(rat_result.x()/rat_result.w());
result.setY(rat_result.y()/rat_result.w());
result.setZ(rat_result.z()/rat_result.w());
}
else
if(point_type == 3)
{
for ( i = 0; i < row_size; i++)
{
ord = GetOrder(ROW);
G4Point3D rtr_pt = (G4Point3D&) InternalEvalCrv(i, curves);
diff_curve->put(0,i,rtr_pt);
}
k_index = v_knots->GetKnotIndex( Hit->v, GetOrder(COL) );
if(k_index==-1)
{
delete diff_curve;
delete curves;
active = 0;
return result;
}
ord = GetOrder(COL);
tmp_knots = v_knots;
param = Hit->v;
// Evaluate the diff_curve...
result = (G4Point3D&) InternalEvalCrv(0, diff_curve);
}
delete diff_curve;
delete curves;
closest_hit = result;
return result;
}
G4Point3D G4BSplineSurface::Evaluation(const G4Ray& rayref)
{
// Delete old UVhits
G4UVHit* temphit=Hit;
while(Hit!=(G4UVHit*)0)
{
Hit=Hit->next;
delete temphit;
temphit=Hit;
}
delete temphit;
// Get the real Hit point
closest_hit = FinalIntersection();
// The following part (commented out) is old bullshit
// Chech that Hit is not in a void i.e. InnerBoundary.
// for(int a=0; a<NumberOfInnerBoundaries;a++)
// if(InnerBoundary[a]->Inside(closest_hit, rayref))
// {
// Active(0);
// Distance(kInfinity);
// return closest_hit;
// }
return closest_hit;
}
G4double G4BSplineSurface::ClosestDistanceToPoint(const G4Point3D& Pt)
{
G4double PointDistance=0;
PointDistance = ctl_points->ClosestDistanceToPoint(Pt);
return PointDistance;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,12 @@
// 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.cc,v 2.3 1998/10/20 16:33:42 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4BoundedSurface.hh"
@@ -0,0 +1,322 @@
#include "G4BoundingBox3D.hh"
#include "geomdefs.hh"
const G4BoundingBox3D G4BoundingBox3D::
space( G4Point3D(-kInfinity, -kInfinity, -kInfinity),
G4Point3D(+kInfinity, +kInfinity, +kInfinity) );
/////////////////////////////////////////////////////////////////////////////
G4BoundingBox3D::G4BoundingBox3D() { distance =0; }
G4BoundingBox3D::G4BoundingBox3D(const G4Point3D& p1, const G4Point3D& p2)
{
Init(p1, p2);
}
G4BoundingBox3D::G4BoundingBox3D(const G4Point3D& p)
{
Init(p);
}
G4BoundingBox3D::~G4BoundingBox3D() {}
void G4BoundingBox3D::Init(const G4Point3D& p1, const G4Point3D& p2)
{
// L. Broglia
// Maybe temporary
// Create a BBox bigger than the reality
box_min.setX( min(p1.x(), p2.x()) - kCarTolerance );
box_min.setY( min(p1.y(), p2.y()) - kCarTolerance );
box_min.setZ( min(p1.z(), p2.z()) - kCarTolerance );
box_max.setX( max(p1.x(), p2.x()) + kCarTolerance );
box_max.setY( max(p1.y(), p2.y()) + kCarTolerance );
box_max.setZ( max(p1.z(), p2.z()) + kCarTolerance );
// Calc half spaces
GeantBox = (box_max - box_min)*0.5;
MiddlePoint = (box_min + box_max)*0.5;
distance = 0;
}
void G4BoundingBox3D::Init(const G4Point3D& p)
{
box_min= box_max= MiddlePoint= p;
GeantBox= G4Point3D(0, 0, 0);
distance= 0;
}
/////////////////////////////////////////////////////////////////////////////
void G4BoundingBox3D::Extend(const G4Point3D& p)
{
// L. Broglia
// Maybe temporary
// Create a BBox bigger than the reality
if (p.x() < box_min.x())
box_min.setX( p.x() - kCarTolerance );
else if (p.x() > box_max.x())
box_max.setX( p.x() + kCarTolerance );
if (p.y() < box_min.y())
box_min.setY( p.y() - kCarTolerance );
else if (p.y() > box_max.y())
box_max.setY( p.y() + kCarTolerance );
if (p.z() < box_min.z())
box_min.setZ( p.z() - kCarTolerance );
else if (p.z() > box_max.z())
box_max.setZ( p.z() + kCarTolerance );
// L. Broglia
// Now re-calculate GeantBox and MiddlePoint
GeantBox = (box_max - box_min)*0.5;
MiddlePoint = (box_min + box_max)*0.5;
}
////////////////////////////////////////////////////////////////////////////
int G4BoundingBox3D::Test(const G4Ray& rayref)
{
const G4Point3D& tmp_ray_start = rayref.GetStart();
const G4Vector3D& tmp_ray_dir = rayref.GetDir();
G4Point3D ray_start = tmp_ray_start ;
G4Vector3D ray_dir = tmp_ray_dir ;
G4double rayx,rayy,rayz;
rayx = ray_start.x();
rayy = ray_start.y();
rayz = ray_start.z();
// Test if ray starting point is in the bbox or not
if((rayx < box_min.x()) || (rayx > box_max.x()) ||
(rayy < box_min.y()) || (rayy > box_max.y()) ||
(rayz < box_min.z()) || (rayz > box_max.z()) )
{
// Outside, check for intersection with bbox
// Adapt ray_starting point to box
const G4Point3D ray_start2 = ray_start - MiddlePoint;
distance = DistanceToIn(ray_start2, ray_dir);
if(!distance)
test_result = 0; // Miss
else
test_result = 1; // Starting point outside box & hits box
}
else
{
// Inside
// G4cout << "\nRay starting point Inside bbox.";
test_result = 1;
distance = 0;
}
return test_result;
}
///////////////////////////////////////////////////////////////////////////////
// Does an intersection exist?
//
// ALGORITHM:
//
// Check that if point lies outside x/y/z extent of box, travel is towards
// the box (ie. there is a possiblity of an intersection)
int G4BoundingBox3D::BoxIntersect(const G4Point3D& gbox,
const G4Point3D& p ,
const G4Vector3D& v ) const
{
G4double safx, safy, safz;
G4double fdx, fdy, fdz;
fdx = GeantBox.x();
fdy = GeantBox.y();
fdz = GeantBox.z();
safx=fabs(p.x())-fdx; // minimum distance to x surface of shape
safy=fabs(p.y())-fdy;
safz=fabs(p.z())-fdz;
// Will we Intersect?
// If safx/y/z is >=0 the point is outside/on the box's x/y/z extent.
// If both p.X()/y/z and v.X()/y/z repectively are both positive/negative,
// travel is in a G4ThreeVec away from the shape.
if ( ( (p.x()*v.x()>=0.0 ) && safx>0.0 ) ||
( (p.y()*v.y()>=0.0 ) && safy>0.0 ) ||
( (p.z()*v.z()>=0.0 ) && safz>0.0 ) )
return 0; // No intersection
else
return 1; // Possible intersection
}
///////////////////////////////////////////////////////////////////////////////
// Distance to in
// Calculate distance to box from outside - return kBig if no intersection
//
// ALGORITHM:
//
// Check that if point lies outside x/y/z extent of box, travel is towards
// the box (ie. there is a possiblity of an intersection)
//
// Calculate pairs of minimum and maximum distances for x/y/z travel for
// intersection with the box's x/y/z extent.
// If there is a valid intersection, it is given by the maximum min distance
// (ie. distance to satisfy x/y/z intersections) *if* <= minimum max distance
// (ie. distance after which 1+ of x/y/z intersections not satisfied)
//
// NOTE:
//
// `Inside' safe - meaningful answers given if point is Inside the exact
// shape.
//G4double G4BoundingBox::distance_to_in(const G4Point3d& gbox, const G4Point3d& p, const G4ThreeVec& v) const
G4double G4BoundingBox3D::DistanceToIn(const G4Point3D& p,
const G4Vector3D& v) const
{
G4double safx, safy, safz, snxt = 0; // snxt = default return value
G4double smin, sminx, sminy, sminz;
G4double smax, smaxx, smaxy, smaxz;
G4double stmp;
G4double kBig = 10e20;
G4double fdx,fdy,fdz;
fdx = GeantBox.x();
fdy = GeantBox.y();
fdz = GeantBox.z();
safx = fabs(p.x())-fdx; // minimum distance to x surface of shape
safy = fabs(p.y())-fdy;
safz = fabs(p.z())-fdz;
// Will we Intersect?
// If safx/y/z is >=0 the point is outside/on the box's x/y/z extent.
// If both p.X()/y/z and v.X()/y/z repectively are both positive/negative,
// travel is in a G4ThreeVec away from the shape.
if ( ( ( p.x()*v.x()>=0.0 ) && safx>0.0) ||
( ( p.y()*v.y()>=0.0 ) && safy>0.0) ||
( ( p.z()*v.z()>=0.0 ) && safz>0.0) )
return snxt;
// Compute min / max distance for x/y/z travel:
if (safx<0.0)
{
// Inside x extent => Calc distance until trajectory leaves extent
sminx=0.0;
if (v.x())
smaxx = fdx/fabs(v.x()) - p.x()/v.x();
else
smaxx = kBig;
}
else
{
// Outside extent or on boundary
if (v.x()==0)
return snxt; // Travel parallel
else
{
stmp = fabs(v.x());
sminx = safx/stmp;
smaxx = (fdx+fabs(p.x()))/stmp;
}
}
if (safy<0.0)
{
// Inside y extent => Calc distance until trajectory leaves extent
sminy=0.0;
if (v.y())
smaxy = fdy/fabs(v.y()) - p.y()/v.y();
else
smaxy = kBig;
}
else
{
// Outside extent or on boundary
if (v.y()==0)
return snxt; // Travel parallel
else
{
stmp = fabs(v.y());
sminy = safy/stmp;
smaxy = (fdy+fabs(p.y()))/stmp;
}
}
if (safz<0.0)
{
// Inside z extent => Calc distance until trajectory leaves extent
sminz=0.0;
if (v.z())
smaxz = fdz/fabs(v.z()) - p.z()/v.z();
else
smaxz = kBig;
}
else
{
// Outside extent or on boundary
if (v.z()==0)
return snxt; // Travel parallel
else
{
stmp = fabs(v.z());
sminz = safz/stmp;
smaxz = (fdz+fabs(p.z()))/stmp;
}
}
// Find minimum allowed Dist given min/max pairs
if (sminx>sminy)
smin = sminx; // MAX(sminx,sminy,sminz)
else
smin = sminy;
if (sminz>smin)
smin=sminz;
if (smaxx<smaxy)
smax = smaxx; // MIN(smaxx,smaxy,smaxz)
else
smax = smaxy;
if (smaxz<smax)
smax = smaxz;
// If smin <= kCarTolerance then only clipping `tolerant' Area
// -> no intersection
G4double kCarTolerance = 0;
if (smin>kCarTolerance && smin<=smax)
snxt=smin;
return snxt;
}
@@ -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: G4CircularCurve.cc,v 2.4 1998/10/20 16:33:43 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4CircularCurve.hh"
#include "G4Ellipse.hh"
// G4CircularCurve
G4CircularCurve::G4CircularCurve() {}
G4CircularCurve::~G4CircularCurve() {}
//////////////////////////////////////////////////////////////////////////////
void G4CircularCurve::InitBounded()
{
// the bbox must include the start and endpoints as well as the
// extreme points if they lie on the curve
bBox.Init(GetStart(), GetEnd());
// the parameter values
// belonging to the points with an extreme x, y and z coordinate
for (G4int i=0; i<3; i++)
{
G4double u = atan2(position.GetPY()(i), position.GetPX()(i));
if (IsPOn(u))
bBox.Extend(GetPoint(u));
if (IsPOn(u+pi))
bBox.Extend(GetPoint(u+pi));
}
}
//////////////////////////////////////////////////////////////////////////////
G4Curve* G4CircularCurve::Project(const G4Transform3D& tr)
{
G4Ellipse e;
e.Init(position, radius, radius);
e.SetBounds(GetPStart(), GetPEnd());
return e.Project(tr);
}
//////////////////////////////////////////////////////////////////////////////
G4bool G4CircularCurve::Tangent(G4CurvePoint& cp, G4Vector3D& v)
{
// The tangent is computed from the 3D point representation
// for all conics. An alternaive implementation (based on
// the parametric point) might be worthwhile adding
// for efficiency.
const G4Axis2Placement3D& pos= *(GetPosition());
G4Point3D p= pos.GetToPlacementCoordinates() * cp.GetPoint();
v= -p.y()*pos.GetPX() + p.x()*pos.GetPY();
return true;
}
@@ -0,0 +1,107 @@
#include "G4CompositeCurve.hh"
#include "G4Line.hh"
G4CompositeCurve::G4CompositeCurve(){}
G4CompositeCurve::G4CompositeCurve(const G4Point3DVector& vertices)
{
G4CurveVector cv;
G4Line* l;
for (G4int i=0; i<vertices.length(); i++)
{
G4Point3D p1= vertices[i];
G4Point3D p2= vertices[(i+1) % vertices.length()];
G4Line* l= new G4Line;
l->Init(p1, p2-p1);
l->SetBounds(p1, p2);
cv.insert(l);
}
Init(cv);
}
G4CompositeCurve::~G4CompositeCurve(){}
G4Curve* G4CompositeCurve::Project(const G4Transform3D& tr)
{
G4CurveVector newSegments;
for (G4int i=0; i<segments.entries(); i++)
{
G4Curve* c= segments[i]->Project(tr);
if (c==0)
{
newSegments.clearAndDestroy();
return 0;
}
newSegments.insert(c);
}
G4CompositeCurve* r= new G4CompositeCurve;
r->Init(newSegments);
return r;
}
void G4CompositeCurve::IntersectRay2D(const G4Ray& ray,
G4CurveRayIntersection& is)
{
is.Reset();
for (G4int i=0; i<segments.entries(); i++)
{
G4Curve& c= *(segments(i));
G4CurveRayIntersection isTmp(c, ray);
c.IntersectRay2D(ray, isTmp);
if (isTmp.GetDistance() < is.GetDistance())
is= isTmp;
}
lastIntersection= is;
}
G4bool G4CompositeCurve::Tangent(G4CurvePoint& cp, G4Vector3D& v)
{
if (lastIntersection.GetDistance() == kInfinity)
return false;
return lastIntersection.GetCurve().Tangent(lastIntersection, v);
// should be true
// cp is ignored for the moment
}
void G4CompositeCurve::InitBounded()
{
const G4BoundingBox3D* b= segments[0]->BBox();
bBox.Init(b->GetBoxMin(), b->GetBoxMax());
for (G4int i=1; i<segments.entries(); i++)
{
b= segments[i]->BBox();
bBox.Extend(b->GetBoxMin());
bBox.Extend(b->GetBoxMax());
}
// init for efficient parameter <-> 3D point conversions
}
@@ -0,0 +1,34 @@
#include "G4Conic.hh"
// G4Conic
G4Conic::G4Conic (): pShift(0) {}
G4Conic::G4Conic (STEPentity& Ent){};
G4Conic::~G4Conic() {}
/*
void G4ConicalCurve::ProjectCurve(const G4Plane& Pl1, const G4Plane& Pl2)
{
// Curve start
Project(ProjStart, Start, Pl1, Pl2);
// Curve end
Project(ProjEnd, End, Pl1, Pl2);
// Placement
Position.ProjectPlacement(Pl1,Pl2);
}
int G4ConicalCurve::HitPartOfCurve(G4double Angle, G4double Solution, const G4Point2d& ProjHit)
{
// Check if Solution1 is part of the curve i.e. in the "pie"
G4double TmpSol1 = Solution - ProjHit.X();
G4Point2d ArcHit1(TmpSol1, ProjHit.Y());
G4double Cross1 = CrossProduct( ProjStart, ArcHit1);
G4double Cross2 = CrossProduct( ArcHit1 , ProjEnd);
if( (Angle<=0 && Cross1<=0 && Cross2 <=0) ||
(Angle> 0 && !(Cross1>=0 && Cross2 >=0)) )
// Solution1 is on the curve
return 1;
return 0;
}
*/
@@ -0,0 +1,552 @@
// 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.cc,v 2.6 1998/11/13 13:58:30 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
/* /usr/local/gismo/repo/geometry/G4ConicalSurface.cc,v 1.6 1994/08/03 17:15:01 burnett Exp */
// File: G4ConicalSurface.cc
// Author: Alan Breakstone
// Contents ----------------------------------------------------------
//
// G4ConicalSurface::G4ConicalSurface()
// G4ConicalSurface::G4ConicalSurface( const G4Vector3D& o,
// const G4Vector3D& a, G4double e )
// G4ConicalSurface::PrintOn( ostream& os ) const
// G4ConicalSurface::HowNear( const G4Vector3D& x ) const
// G4ConicalSurface::distanceAlongRay( int which_way, const Ray* ry,
// G4Vector3D& p ) const
// G4ConicalSurface::Inside( const G4Vector3D& x ) const
// G4ConicalSurface::WithinBoundary( const G4Vector3D& x ) const
// G4ConicalSurface::SetAngle( G4double e )
//
// End ---------------------------------------------------------------
#include "G4ConicalSurface.hh"
#include "G4Sort.hh"
#include "G4Globals.hh"
G4ConicalSurface::G4ConicalSurface() : G4Surface()
{
// default constructor
// default axis is ( 1.0, 0.0, 0.0 ), default angle is 1.0 radians
axis = G4Vector3D( 1.0, 0.0, 0.0 );
angle = 1.0;
}
G4ConicalSurface::G4ConicalSurface( const G4Point3D& o,
const G4Vector3D& a,
G4double e ) //: G4Surface( o )
{
// Normal constructor
// require axis to be a unit vector
/* L. Broglia
G4double amag = a.Magnitude();
include/G4ThreeVec.hh: G4double Magnitude() const
{ return sqrt( x*x + y*y + z*z ); }
This function is mag2 for HepThreeVector
*/
G4double amag = a.mag2();
if ( amag != 0.0 )
/* L. Broglia
axis = a / amag; // this makes the axis a unit vector
*/
axis = a*(1/amag);
else {
G4cerr << "Error in G4ConicalSurface::G4ConicalSurface"
<<"--axis has zero length\n"
<< "\tDefault axis ( 1.0, 0.0, 0.0 ) is used.\n";
axis = G4Vector3D( 1.0, 0.0, 0.0 );
}
// Require angle to range from 0 to PI/2
if ( ( e > 0.0 ) && ( e < ( 0.5 * M_PI ) ) )
angle = e;
else {
G4cerr << "Error in G4ConicalSurface::G4ConicalSurface"
<< "--asked for angle out of allowed range of 0 to PI/2\n"
<< "\tDefault angle of 1.0 is used.\n";
angle = 1.0;
}
}
void G4ConicalSurface::CalcBBox()
{
// Created by L. Broglia
// copy of G4FPlane::CalcBBox()
bbox= new G4BoundingBox3D(surfaceBoundary.BBox().GetBoxMin(),
surfaceBoundary.BBox().GetBoxMax());
}
void G4ConicalSurface::PrintOn( ostream& os ) const
{
// printing function using C++ ostream class
os << "G4ConicalSurface surface with origin: " << origin << "\t"
<< "angle: " << angle << " radians \tand axis " << axis << "\n";
}
G4double G4ConicalSurface::HowNear( const G4Vector3D& x ) const
{
// Distance from the point x to the semi-infinite G4ConicalSurface.
// The distance will be positive if the point is Inside the G4ConicalSurface,
// negative if the point is outside.
// Note that this may not be correct for a bounded conical object
// subclassed to G4ConicalSurface.
G4Vector3D d = x - origin;
G4double l = d * axis;
G4Vector3D q = origin + l * axis;
G4Vector3D v = x - q;
/* L. Broglia
G4double Dist = ( l * tan( angle ) - v.Magnitude() ) * cos ( angle );
*/
G4double Dist = ( l*tan(angle) - v.mag2() ) * cos(angle);
return Dist;
}
int G4ConicalSurface::Intersect( const G4Ray& ry )
{
// Distance along a Ray (straight line with G4Vector3D) to leave or enter
// a G4ConicalSurface. The input variable which_way should be set to +1 to
// indicate leaving a G4ConicalSurface, -1 to indicate entering a
// G4ConicalSurface.
// p is the point of intersection of the Ray with the G4ConicalSurface.
// If the G4Vector3D of the Ray is opposite to that of the Normal to
// the G4ConicalSurface at the intersection point, it will not leave the
// G4ConicalSurface.
// Similarly, if the G4Vector3D of the Ray is along that of the Normal
// to the G4ConicalSurface at the intersection point, it will not enter the
// G4ConicalSurface.
// This method is called by all finite shapes sub-classed to
// G4ConicalSurface.
// Use the virtual function table to check if the intersection point
// is within the boundary of the finite shape.
// A negative result means no intersection.
// If no valid intersection point is found, set the distance
// and intersection point to large numbers.
int which_way = -1; //Originally a parameter.Read explanation above.
distance = FLT_MAXX;
// G4Vector3D lv ( FLT_MAXX, FLT_MAXX, FLT_MAXX );
G4Vector3D lv ( FLT_MAXX, FLT_MAXX, FLT_MAXX );
// p = lv;
closest_hit = lv;
// Origin and G4Vector3D unit vector of Ray.
// G4Vector3D x = ry->position();
G4Vector3D x = ry.GetStart();
// G4Vector3D dhat = ry->direction( 0.0 );
G4Vector3D dhat = ry.GetDir();
// Cone angle and axis unit vector.
G4double ta = tan( GetAngle() );
G4Vector3D ahat = GetAxis();
int isoln = 0,
maxsoln = 2;
// array of solutions in distance along the Ray
// G4double s[2] = { -1.0, -1.0 };
G4double s[2];
s[0] = -1.0;
s[1] = -1.0 ;
// calculate the two solutions (quadratic equation)
G4Vector3D gamma = x - GetOrigin();
G4double T = 1.0 + ta * ta;
G4double ga = gamma * ahat;
G4double da = dhat * ahat;
G4double A = 1.0 - T * da * da;
G4double B = 2.0 * ( gamma * dhat - T * ga * da );
G4double C = gamma * gamma - T * ga * ga;
// if quadratic term vanishes, just do the simple solution
if ( fabs( A ) < FLT_EPSILO )
{
if ( B == 0.0 )
return 1;
else
s[0] = -C / B;
}
// Normal quadratic case, no intersection if radical is less than zero
else
{
G4double radical = B * B - 4.0 * A * C;
if ( radical < 0.0 )
return 1;
else
{
G4double root = sqrt( radical );
s[0] = ( - B + root ) / ( 2. * A );
s[1] = ( - B - root ) / ( 2. * A );
}
}
// order the possible solutions by increasing distance along the Ray
// (G4Sorting routines are in support/G4Sort.h)
G4Sort_double( s, isoln, maxsoln-1 );
// now loop over each positive solution, keeping the first one (smallest
// distance along the Ray) which is within the boundary of the sub-shape
// and which also has the correct G4Vector3D with respect to the Normal to
// the G4ConicalSurface at the intersection point
for ( isoln = 0; isoln < maxsoln; isoln++ )
{
if ( s[isoln] >= 0.0 )
{
if ( s[isoln] >= FLT_MAXX ) // quit if too large
return 1;
distance = s[isoln];
closest_hit = ry.GetPoint( distance );
// Following line necessary to select non-reflective solutions.
if (( ahat * ( closest_hit - GetOrigin() ) > 0.0 ) &&
((( dhat * SurfaceNormal( closest_hit ) * which_way )) >= 0.0 ) &&
( fabs(HowNear( closest_hit )) < 0.1) )
return 1;
}
}
// get here only if there was no solution within the boundary, Reset
// distance and intersection point to large numbers
distance = FLT_MAXX;
closest_hit = lv;
return 0;
}
/*
G4double G4ConicalSurface::distanceAlongHelix(int which_way, const Helix* hx,
G4Vector3D& p ) const
{ // Distance along a Helix to leave or enter a G4ConicalSurface.
// The input variable which_way should be set to +1 to
// indicate leaving a G4ConicalSurface, -1 to indicate entering a
// G4ConicalSurface.
// p is the point of intersection of the Helix with the G4ConicalSurface.
// If the G4Vector3D of the Helix is opposite to that of the Normal to
// the G4ConicalSurface at the intersection point, it will not leave the
// G4ConicalSurface.
// Similarly, if the G4Vector3D of the Helix is along that of the Normal
// to the G4ConicalSurface at the intersection point, it will not enter the
// G4ConicalSurface.
// This method is called by all finite shapes sub-classed to
// G4ConicalSurface.
// Use the virtual function table to check if the intersection point
// is within the boundary of the finite shape.
// If no valid intersection point is found, set the distance
// and intersection point to large numbers.
// Possible negative distance solutions are discarded.
G4double Dist = FLT_MAXX;
G4Vector3D lv ( FLT_MAXX, FLT_MAXX, FLT_MAXX );
p = lv;
int isoln = 0, maxsoln = 4;
// Array of solutions in turning angle
// G4double s[4] = { -1.0, -1.0, -1.0, -1.0 };
G4double s[4];s[0] = -1.0; s[1]= -1.0 ;s[2] = -1.0; s[3]= -1.0 ;
// Flag set to 1 if exact solution is found
int exact = 0;
// Helix parameters
G4double rh = hx->GetRadius(); // radius of Helix
G4Vector3D oh = hx->position(); // origin of Helix
G4Vector3D dh = hx->direction( 0.0 ); // initial G4Vector3D of Helix
G4Vector3D prp = hx->getPerp(); // perpendicular vector
G4double prpmag = prp.Magnitude();
G4double rhp = rh / prpmag;
// G4ConicalSurface parameters
G4double ta = tan( GetAngle() ); // tangent of angle of G4ConicalSurface
G4Vector3D oc = GetOrigin(); // origin of G4ConicalSurface
G4Vector3D ac = GetAxis(); // axis of G4ConicalSurface
// Calculate quantities of use later on
G4Vector3D alpha = rhp * prp;
G4Vector3D beta = rhp * dh;
G4Vector3D gamma = oh - oc;
G4double T = 1.0 + ta * ta;
G4double gc = gamma * ac;
G4double bc = beta * ac;
// General approximate solution for sin(s)-->s and cos(s)-->1-s**2/2,
// keeping only terms to second order in s
G4double A = gamma * alpha - T * ( gc * alpha * ac - bc * bc ) +
beta * beta;
G4double B = 2.0 * ( gamma * beta - gc * bc * T );
G4double C = gamma * gamma - gc * gc * T;
// Solution for no quadratic term
if ( fabs( A ) < FLT_EPSILO )
{
if ( B == 0.0 )
return Dist;
else
s[0] = -C / B;
}
// General quadratic solutions
else {
G4double radical = B * B - 4.0 * A * C;
if ( radical < 0.0 )
// Radical is less than zero, either there is no intersection, or the
// approximation doesn't hold, so try a cruder technique to find a
// possible intersection point using the gropeAlongHelix function.
s[0] = gropeAlongHelix( hx );
// Normal non-negative radical solutions
else {
G4double root = sqrt( radical );
s[0] = ( -B + root ) / ( 2.0 * A );
s[1] = ( -B - root ) / ( 2.0 * A );
if ( rh < 0.0 ) {
s[0] = -s[0];
s[1] = -s[1];
}
s[2] = s[0] + 2.0 * M_PI;
s[3] = s[1] + 2.0 * M_PI;
}
}
//
// Order the possible solutions by increasing turning angle
// (G4Sorting routines are in support/G4Sort.h).
G4Sort_double( s, isoln, maxsoln-1 );
//
// Now loop over each positive solution, keeping the first one (smallest
// distance along the Helix) which is within the boundary of the sub-shape.
for ( isoln = 0; isoln < maxsoln; isoln++ ) {
if ( s[isoln] >= 0.0 ) {
// Calculate distance along Helix and position and G4Vector3D vectors.
Dist = s[isoln] * fabs( rhp );
p = hx->position( Dist );
G4Vector3D d = hx->direction( Dist );
if ( exact == 0 ) { // only for approximate solns
// Now do approximation to get remaining distance to correct this solution.
// Iterate it until the accuracy is below the user-set surface precision.
G4double delta = 0.;
G4double delta0 = FLT_MAXX;
int dummy = 1;
int iter = 0;
int in0 = Inside( hx->position() );
int in1 = Inside( p );
G4double sc = Scale();
while ( dummy ) {
iter++;
// Terminate loop after 50 iterations and Reset distance to large number,
// indicating no intersection with G4ConicalSurface.
// This generally occurs if the Helix curls too tightly to Intersect it.
if ( iter > 50 ) {
Dist = FLT_MAXX;
p = lv;
break;
}
// Find distance from the current point along the above-calculated
// G4Vector3D using a Ray.
// The G4Vector3D of the Ray and the Sign of the distance are determined
// by whether the starting point of the Helix is Inside or outside of
// the G4ConicalSurface.
in1 = Inside( p );
if ( in1 ) { // current point Inside
if ( in0 ) { // starting point Inside
Ray* r = new Ray( p, d );
delta =
distanceAlongRay( 1, r, p );
delete r;
}
else { // starting point outside
Ray* r = new Ray( p, -d );
delta =
-distanceAlongRay( 1, r, p );
delete r;
}
}
else { // current point outside
if ( in0 ) { // starting point Inside
Ray* r = new Ray( p, -d );
delta =
-distanceAlongRay( -1, r, p );
delete r;
}
else { // starting point outside
Ray* r = new Ray( p, d );
delta =
distanceAlongRay( -1, r, p );
delete r;
}
}
// Test if distance is less than the surface precision, if so Terminate loop.
if ( fabs( delta / sc ) <= SURFACE_PRECISION )
break;
// If delta has not changed sufficiently from the previous iteration,
// skip out of this loop.
if ( fabs( ( delta - delta0 ) / sc ) <=
SURFACE_PRECISION )
break;
// If delta has increased in absolute value from the previous iteration
// either the Helix doesn't Intersect the G4ConicalSurface or the approximate solution
// is too far from the real solution. Try groping for a solution. If not
// found, Reset distance to large number, indicating no intersection with
// the G4ConicalSurface.
if ( fabs( delta ) > fabs( delta0 ) ) {
Dist = fabs( rhp ) *
gropeAlongHelix( hx );
if ( Dist < 0.0 ) {
Dist = FLT_MAXX;
p = lv;
}
else
p = hx->position( Dist );
break;
}
// Set old delta to new one.
delta0 = delta;
// Add distance to G4ConicalSurface to distance along Helix.
Dist += delta;
// Negative distance along Helix means Helix doesn't Intersect G4ConicalSurface.
// Reset distance to large number, indicating no intersection with G4ConicalSurface.
if ( Dist < 0.0 ) {
Dist = FLT_MAXX;
p = lv;
break;
}
// Recalculate point along Helix and the G4Vector3D.
p = hx->position( Dist );
d = hx->direction( Dist );
} // end of while loop
} // end of exact == 0 condition
// Now have best value of distance along Helix and position for this
// solution, so test if it is within the boundary of the sub-shape
// and require that it point in the correct G4Vector3D with respect to
// the Normal to the G4ConicalSurface.
if ( ( Dist < FLT_MAXX ) &&
( ( hx->direction( Dist ) * Normal( p ) *
which_way ) >= 0.0 ) &&
( WithinBoundary( p ) == 1 ) )
return Dist;
} // end of if s[isoln] >= 0.0 condition
} // end of for loop over solutions
// If one gets here, there is no solution, so set distance along Helix
// and position to large numbers.
Dist = FLT_MAXX;
p = lv;
return Dist;
}
*/
G4Vector3D G4ConicalSurface::SurfaceNormal( const G4Point3D& p ) const
{
// return the Normal unit vector to the G4ConicalSurface at a point p
// on (or nearly on) the G4ConicalSurface
G4Vector3D s = p - origin;
/* L. Broglia
G4double smag = s.Magnitude();
*/
G4double smag = s.mag2();
// if the point happens to be at the origin, calculate a unit vector Normal
// to the axis, with zero z component
if ( smag == 0.0 )
{
G4double ax = axis.x();
G4double ay = axis.y();
G4double ap = sqrt( ax * ax + ay * ay );
if ( ap == 0.0 )
return G4Vector3D( 1.0, 0.0, 0.0 );
else
return G4Vector3D( ay / ap, -ax / ap, 0.0 );
}
// otherwise do the calculation of the Normal to the conical surface
else
{
G4double l = s * axis;
/* L. Broglia
s = s / smag;
*/
s = s*(1/smag);
G4Vector3D q = origin + l * axis;
G4Vector3D v = p - q;
/* L. Broglia
G4double sl = v.Magnitude() * sin( angle );
*/
G4double sl = v.mag2() * sin( angle );
G4Vector3D n = v - sl * s;
/* L. Broglia
G4double nmag = n.Magnitude();
*/
G4double nmag = n.mag2();
if ( nmag != 0.0 )
/* L. Broglia
n = n / nmag;
*/
n=n*(1/nmag);
return n;
}
}
int G4ConicalSurface::Inside ( const G4Vector3D& x ) const
{
// Return 0 if point x is outside G4ConicalSurface, 1 if Inside.
// Outside means that the distance to the G4ConicalSurface would be negative.
// Use the HowNear function to calculate this distance.
if ( HowNear( x ) >= -0.5*kCarTolerance )
return 1;
else
return 0;
}
int G4ConicalSurface::WithinBoundary( const G4Vector3D& x ) const
{
// return 1 if point x is on the G4ConicalSurface, otherwise return zero
// base this on the surface precision factor set in support/globals.h
if ( fabs( HowNear( x ) / Scale() ) <= SURFACE_PRECISION )
return 1;
else
return 0;
}
void G4ConicalSurface::SetAngle( G4double e )
{
// Reset the angle of the G4ConicalSurface
// Require angle to range from 0 to PI/2
// if ( ( e > 0.0 ) && ( e < ( 0.5 * M_PI ) ) )
if ( (e > 0.0) && (e <= ( 0.5 * M_PI)) )
angle = e;
// use old value (do not change angle) if out of the range,
//but Print message
else
{
G4cerr << "Error in G4ConicalSurface::SetAngle"
<< "--asked for angle out of allowed range of 0 to PI/2\n"
<< "\tDefault angle of " << angle << " is used.\n";
}
}
@@ -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: G4ControlPoints.cc,v 2.6 1998/11/04 14:49:55 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
//
#include "G4ControlPoints.hh"
G4ControlPoints::G4ControlPoints()
{
nr=nc=0;
data=(G4PointRat**)0;
}
G4ControlPoints::G4ControlPoints( int rows, int columns)
{
nr=rows;
nc=columns;
data = (G4PointRat**) new G4PointRat *[nr*nc];
for(int a =0; a<nr*nc;a++)
data[a]=new G4PointRat;
}
G4ControlPoints::G4ControlPoints( int point_type, int rows, int columns)
{
// point_type is maintained only for compatibility
// G4ControlPoints is now a array of G4pointRat only
nr=rows;
nc=columns;
data = (G4PointRat**)new G4PointRat *[nr*nc];
for(int a = 0; a < nr*nc ; a++ )
data[a]=new G4PointRat;
}
G4ControlPoints::G4ControlPoints(const G4ControlPoints& old_points)
{
// copy constructor
nr = old_points.GetRows(); nc=old_points.GetCols();
data = (G4PointRat**)new G4PointRat *[nr*nc];
G4int a, b;
for (a = 0; a < nr*nc ; a++ )
data[a] = new G4PointRat;
for ( a = 0; a < nr ; a++ )
for ( b = 0; b < nc ; b++ )
put( a, b, old_points.GetRat(a,b));
}
G4ControlPoints::~G4ControlPoints()
{
for( int a = 0; a < nr*nc; a++)
delete data[a];
delete[] data;
}
void G4ControlPoints::SetWeights(G4double* weights)
{
for ( int a = 0; a < nr*nc; a++ )
(data[a])->setW(weights[a]);
}
void G4ControlPoints::CalcValues ( G4double k1, G4double param,
G4PointRat& pts1, G4double k2,
G4PointRat& pts2 )
{
pts2.setX(Calc(k1,param,pts1.x(),k2,pts2.x()));
pts2.setY(Calc(k1,param,pts1.y(),k2,pts2.y()));
pts2.setZ(Calc(k1,param,pts1.z(),k2,pts2.z()));
pts2.setW(Calc(k1,param,pts1.w(),k2,pts2.w()));
}
void G4ControlPoints::CalcValues(G4double k1, G4double param, G4Point3D& pts1,
G4double k2, G4Point3D& pts2)
{
pts2.setX(Calc(k1,param,pts1.x(),k2,pts2.x()));
pts2.setY(Calc(k1,param,pts1.y(),k2,pts2.y()));
pts2.setZ(Calc(k1,param,pts1.z(),k2,pts2.z()));
}
G4double G4ControlPoints::ClosestDistanceToPoint( const G4Point3D& Pt)
{
// Square distance
G4double PointDist=1.e20;
G4double TmpDist;
G4Point3D Pt2;
for(int a=0;a<nr;a++)
for(int b=0;b<nc;b++)
{
Pt2 = Get3D(a,b);
TmpDist = Pt.distance2(Pt2);
PointDist = ( PointDist > TmpDist ) ? TmpDist : PointDist;
}
return PointDist;
}
@@ -0,0 +1,17 @@
// 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.cc,v 2.3 1998/11/06 15:31:26 broglia Exp $
// GEANT4 tag $Name: geant4-00 $
//
#include "G4Curve.hh"
G4Curve::G4Curve():bounded(false),bBox(G4BoundingBox3D::space),
sameSense(true){}
G4Curve::~G4Curve(){}
@@ -0,0 +1,5 @@
#include "G4CurvePoint.hh"
const G4int G4CurvePoint::pFlag= 1;
const G4int G4CurvePoint::uFlag= 2;
const G4int G4CurvePoint::allFlags= 0xFF; // lots of bits...
@@ -0,0 +1,3 @@
#include "G4CurveRayIntersection.hh"
const G4int G4CurveRayIntersection::dFlag= 4;

Some files were not shown because too many files have changed in this diff Show More