Import Geant4 9.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:25:56 +02:00
parent 74cad5e589
commit 89a9605df1
4440 changed files with 379508 additions and 189225 deletions
@@ -0,0 +1,18 @@
#------------------------------------------------------------------------------
# CMakeLists.txt
# Module : G4specsolids
# Package: Geant4.src.G4geometry..G4specsolids
#
# CMakeLists.txt for building a single granular library.
#
# Generated on : 24/9/2010
#
# $Id: CMakeLists.txt,v 1.1 2010/09/29 18:43:09 bmorgan Exp $
#
#------------------------------------------------------------------------------
if(GEANT4_BUILD_GRANULAR_LIBS)
include(Geant4MacroLibraryTargets)
GEANT4_GRANULAR_LIBRARY_TARGET(COMPONENT sources.cmake)
endif()
+1 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.6 2007/05/23 09:31:15 gcosmo Exp $
# $Id: GNUmakefile,v 1.8 2010/10/27 07:34:32 gcosmo Exp $
# ----------------------------------------------------------------------------
# GNUmakefile for geometry/solids/specific library. Gabriele Cosmo, 05/04/00.
# ----------------------------------------------------------------------------
+122 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.160 2009/11/11 12:25:46 gcosmo Exp $
$Id: History,v 1.186 2010/11/26 13:36:35 gcosmo Exp $
-------------------------------------------------------------------
=========================================================
@@ -17,6 +17,127 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
26-Nov-2010 T.Nikitina (geom-specific-V09-03-20)
- Fixes in G4GenericTrap reported by SBT unit test in SurfaceNormal(),
DistanceToPlane() and VisExtent().
16-Nov-2010 T.Nikitina (geom-specific-V09-03-19)
- G4EllipticalCone: fixes in DistanceToIn(p,v) and DistanceToOut(p,v) for
correct handling of point on the surface.
Corrected formula for SurfaceNormal(p).
10-Nov-2010 T.Nikitina (geom-specific-V09-03-18)
- Added checks on crossing of vertices and too big twisted angle in
G4GenericTrap.
- Fixed case of division by zero in G4TwistedTubs.
- Added unit test for G4Polyhedra.
02-Nov-2010 G.Cosmo (geom-specific-V09-03-17)
- More fixes on Coverity reports for G4TessellatedSolid and G4ReduciblePolygon.
20-Oct-2010 G.Cosmo (geom-specific-V09-03-16)
- Implemented Clone() virtual method for all solids, returning a pointer
to a dynamically allocated copy of the solid. To be used by Geant4-MT.
23-Sep-2010 G.Cosmo (geom-specific-V09-03-15)
- Initialize fpPolyhedron to zero in copy-ctor and operator=().
- Completed implementation of copy-ctor and operator=() for facets.
20-Sep-2010 G.Cosmo (geom-specific-V09-03-14)
- Implemented copy-constructor and assignment operator for all solids
to facilitate conversion to Geant4-MT.
08-Sep-2010 G.Cosmo (geom-specific-V09-03-13)
- Correction to previous fix in G4ReduciblePolygon to avoid deleting current
'vertexHead' pointer.
07-Sep-2010 G.Cosmo (geom-specific-V09-03-12)
- Fix within G4CSGDEBUG code for restoring cout precision.
- Fix in G4ReduciblePolygon::RemoveRedundantVertices() to avoid potential
case of dereferencing freed pointer.
19-Aug-2010 T.Nikitina (geom-specific-V09-03-11)
- G4EllipticalTube: extended implementation of SurfaceNormal(p) in agreement
with canonical form. Added unit test testG4EllipticalTube.cc.
16-Jul-2010 G.Cosmo (geom-specific-V09-03-10)
- Fixed cases of division by zero in G4VTwistSurface and G4TwistBoxSide.
- Use INT_MAX as initialisation for max limits in G4SolidExtentList.
12-Jul-2010 G.Cosmo (geom-specific-V09-03-09)
- Added dummy initialization to members in struct
G4PolyPhiFace::G4PolyPhiFaceEdge, struct G4ReduciblePolygon::ABVertex.
G4Ellipsoid, G4EllipticalTube, G4EnclosingCylinder, G4ExtrudedSolid, G4Hype,
G4IntersectingCone, G4Paraboloid, G4PolyPhiFace, G4Polycone, G4PolyconeSide,
G4Polyhedra, G4PolyhedraSide, G4QuadrangularFacet, G4ReduciblePolygon,
G4TessellatedSolid, G4TriangularFacet, G4TwistBoxSide, G4TwistTrapAlphaSide,
G4TwistTrapFlatSide, G4TwistTrapParallelSide, G4TwistTubsFlatSide,
G4TwistTubsHypeSide, G4TwistTubsSide, G4TwistedTubs, G4VCSGfaceted, G4VFacet,
G4VTwistSurface, G4VTwistedFaceted.
- Fixed case of dereferencing null pointer in methods
G4EllipticalTube::DistanceToOut(p,v), G4VCSGfaceted::DistanceToIn(p,v)
and G4VCSGfaceted::DistanceToOut(p,v).
- Fixed unecessary object copy as argument in method
G4PolyhedraSide::IntersectSidePlane().
- Avoid possible case of derefencing null pointer in G4ReduciblePolygon
RemoveDuplicateVertices() and RemoveRedundantVertices() methods.
- Replaced calls to std::abs() with std::fabs() where suitable.
16-Jun-2010 G.Cosmo (geom-specific-V09-03-08)
- Fixed deletion of internal arrays in CreatePolyhedron() for G4Polycone
and G4Polyhedra.
11-Jun-2010 T.Nikitina (geom-specific-V09-03-07)
- G4GenericTrap: fixed cases of zero dToIn/sToOut when vertices are collapsed
to triangle, line or point. Added new methods handling those specific cases.
- Added unit test for G4GenericTrap.
10-Jun-2010 I.Hrivnacova
- G4GenericTrap: fixed parameter names in CalculateExtent() for the test
case construction through tessellated facets.
09-Jun-2010 G.Cosmo
- G4GenericTrap: moved internal methods to private section and reordered
in source file. Added missing implementation for IsTwisted() method.
03-Jun-2010 T.Nikitina, G.Cosmo (geom-specific-V09-03-06)
- G4GenericTrap:
o Fixed initialization of fSurfaceArea and fCubicVolume and
calculation of surface area.
o Fixed error in Inside(p) function, and corrected use std::fabs() instead
of std::abs() for floating point values.
o Added missing initialisation of fpPolyhedron pointer.
o More corrected signatures for use of non-const references for vectors
passed as arguments to functions.
02-Jun-2010 G.Cosmo (geom-specific-V09-03-05)
- G4GenericTrap: use const reference for vector of vertices passed as argument
in constructor and accessor.
27-May-2010 T.Nikitina (geom-specific-V09-03-04)
- First implementation of G4GenericTrap shape, a new solid representing an
arbitrary trapezoid with up to 8 vertices standing on two parallel planes
perpendicular to the Z axis.
28-Apr-2010 P.R.Truscott (geom-specific-V09-03-03)
- Fix in G4TriangularFacet and G4TessellatedSolid to correct treatment of
optical photon transport related to internal reflection at surface.
Addresses problem report #1103.
15-Apr-2010 I.Hrivnacova (geom-specific-V09-03-02)
- G4ExtrudedSolid: eliminated requirement for clockwise ordering of polygon
vertices. Added a check for vertices ordering; if vertices are defined
anti-clockwise their ordering is reverted.
Fix in polygon facet triangularization for consequent concave vertices.
24-Feb-2010 G.Cosmo (geom-specific-V09-03-01)
- Adopt caching of Phi in G4PolyconeSide and G4PolyhedraSide to avoid
unnecessary consecutive computations on the same point.
10-Feb-2010 G.Cosmo (geom-specific-V09-03-00)
- Use kInfinity for initialising minimum and maximum allowed extent for
G4SolidExtentList of faceted solids.
11-Nov-2009 G.Cosmo (geom-specific-V09-02-08)
- Avoid fake (and redundant) assignment of value to 3-vector in
G4PolyconeSide and G4TwistTubsSide.
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4Ellipsoid.hh,v 1.12 2007/05/18 07:39:56 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4Ellipsoid.hh,v 1.14 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -98,6 +98,8 @@ class G4Ellipsoid : public G4VSolid
G4GeometryType GetEntityType() const;
G4VSolid* Clone() const;
std::ostream& StreamInfo(std::ostream& os) const;
G4ThreeVector GetPointOnSurface() const;
@@ -117,6 +119,10 @@ class G4Ellipsoid : public G4VSolid
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4Ellipsoid(const G4Ellipsoid& rhs);
G4Ellipsoid& operator=(const G4Ellipsoid& rhs);
// Copy constructor and assignment operator.
protected: // without description
G4ThreeVectorList* CreateRotatedVertices(const G4AffineTransform& pT,
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4EllipticalCone.hh,v 1.12 2008/11/21 09:26:22 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4EllipticalCone.hh,v 1.14 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -131,6 +131,8 @@ class G4EllipticalCone : public G4VSolid
G4GeometryType GetEntityType() const;
G4VSolid* Clone() const;
G4ThreeVector GetPointOnSurface() const;
std::ostream& StreamInfo(std::ostream& os) const;
@@ -150,6 +152,10 @@ class G4EllipticalCone : public G4VSolid
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4EllipticalCone(const G4EllipticalCone& rhs);
G4EllipticalCone& operator=(const G4EllipticalCone& rhs);
// Copy constructor and assignment operator.
protected: // without description
G4ThreeVectorList* CreateRotatedVertices(const G4AffineTransform& pT,
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4EllipticalTube.hh,v 1.18 2006/10/20 13:45:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4EllipticalTube.hh,v 1.22 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
@@ -87,6 +87,8 @@ class G4EllipticalTube : public G4VSolid
G4GeometryType GetEntityType() const;
G4VSolid* Clone() const;
std::ostream& StreamInfo(std::ostream& os) const;
G4double GetCubicVolume();
@@ -118,6 +120,10 @@ class G4EllipticalTube : public G4VSolid
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4EllipticalTube(const G4EllipticalTube& rhs);
G4EllipticalTube& operator=(const G4EllipticalTube& rhs);
// Copy constructor and assignment operator.
protected: // without description
G4double dx, dy, dz;
@@ -134,6 +140,10 @@ class G4EllipticalTube : public G4VSolid
private:
G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
// Algorithm for SurfaceNormal() following the original
// specification for points not on the surface.
G4double fCubicVolume;
G4double fSurfaceArea;
mutable G4Polyhedron* fpPolyhedron;
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4ExtrudedSolid.hh,v 1.7 2008/02/27 12:32:48 ivana Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4ExtrudedSolid.hh,v 1.10 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -44,7 +44,7 @@
// Parameters in the constructor:
// const G4String& pName - solid name
// std::vector<G4TwoVector> polygon - the vertices of the outlined polygon
// defined in clock-wise order
// defined in clockwise or anti-clockwise order
// std::vector<ZSection> - the z-sections defined by
// z position, offset and scale
// in increasing z-position order
@@ -120,6 +120,7 @@ class G4ExtrudedSolid : public G4TessellatedSolid
G4bool *validNorm=0, G4ThreeVector *n=0) const;
G4double DistanceToOut (const G4ThreeVector &p) const;
G4GeometryType GetEntityType () const;
G4VSolid* Clone() const;
std::ostream& StreamInfo(std::ostream &os) const;
@@ -130,6 +131,10 @@ class G4ExtrudedSolid : public G4TessellatedSolid
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4ExtrudedSolid(const G4ExtrudedSolid& rhs);
G4ExtrudedSolid& operator=(const G4ExtrudedSolid& rhs);
// Copy constructor and assignment operator.
private:
void ComputeProjectionParameters();
@@ -0,0 +1,223 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GenericTrap.hh,v 1.13 2010/11/10 10:00:16 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4GenericTrap
//
// Class description:
//
// G4GenericTrap is a solid which represents an arbitrary trapezoid with
// up to 8 vertices standing on two parallel planes perpendicular to Z axis.
//
// Parameters in the constructor:
// - name - solid name
// - hz - the solid half length in Z
// - vertices - the (x,y) coordinates of vertices:
// o first four points: vertices[i], i<4
// are the vertices sitting on the -hz plane;
// o last four points: vertices[i], i>=4
// are the vertices sitting on the +hz plane.
//
// The order of defining the vertices of the solid is the following:
// - point 0 is connected with points 1,3,4
// - point 1 is connected with points 0,2,5
// - point 2 is connected with points 1,3,6
// - point 3 is connected with points 0,2,7
// - point 4 is connected with points 0,5,7
// - point 5 is connected with points 1,4,6
// - point 6 is connected with points 2,5,7
// - point 7 is connected with points 3,4,6
// Points can be identical in order to create shapes with less than
// 8 vertices.
// Authors:
// Tatiana Nikitina, CERN; Ivana Hrivnacova, IPN Orsay
// Adapted from Root Arb8 implementation, author Andrea Gheata, CERN
// -------------------------------------------------------------------
#ifndef G4GenericTrap_HH
#define G4GenericTrap_HH
#include <vector>
#include "G4TwoVector.hh"
#include "G4VSolid.hh"
#include "globals.hh"
class G4VFacet;
class G4TessellatedSolid;
class G4GenericTrap : public G4VSolid
{
public: // with description
G4GenericTrap( const G4String& name, G4double hz,
const std::vector<G4TwoVector>& vertices );
// Constructor
~G4GenericTrap();
// Destructor
// Accessors
inline G4double GetZHalfLength() const;
inline G4int GetNofVertices() const;
inline G4TwoVector GetVertex(G4int index) const;
inline const std::vector<G4TwoVector>& GetVertices() const;
inline G4double GetTwistAngle(G4int index) const;
inline G4bool IsTwisted() const;
inline G4int GetVisSubdivisions() const;
inline void SetVisSubdivisions(G4int subdiv);
// Solid methods
EInside Inside(const G4ThreeVector& p) const;
G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const;
G4double DistanceToIn(const G4ThreeVector& p,
const G4ThreeVector& v) const;
G4double DistanceToIn(const G4ThreeVector& p) const;
G4double DistanceToOut(const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm = false,
G4bool *validNorm = 0,
G4ThreeVector *n = 0) const;
G4double DistanceToOut(const G4ThreeVector& p) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const;
G4GeometryType GetEntityType() const;
G4VSolid* Clone() const;
std::ostream& StreamInfo(std::ostream& os) const;
G4ThreeVector GetPointOnSurface() const ;
G4double GetCubicVolume();
G4double GetSurfaceArea();
// Visualisation functions
G4Polyhedron* GetPolyhedron () const;
void DescribeYourselfTo(G4VGraphicsScene& scene) const;
G4VisExtent GetExtent() const;
G4Polyhedron* CreatePolyhedron() const;
G4NURBS* CreateNURBS() const;
public: // without description
G4GenericTrap(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4GenericTrap(const G4GenericTrap& rhs);
G4GenericTrap& operator=(const G4GenericTrap& rhs);
// Copy constructor and assignment operator.
private:
// Internal methods
inline void SetTwistAngle(G4int index, G4double twist);
G4bool ComputeIsTwisted() ;
G4bool CheckOrder(const std::vector<G4TwoVector>& vertices) const;
G4bool IsSegCrossing(const G4TwoVector& a, const G4TwoVector& b,
const G4TwoVector& c, const G4TwoVector& d) const;
G4bool IsSegCrossingZ(const G4TwoVector& a, const G4TwoVector& b,
const G4TwoVector& c, const G4TwoVector& d) const;
G4ThreeVectorList* CreateRotatedVertices(const
G4AffineTransform& pTransform) const;
void ReorderVertices(std::vector<G4ThreeVector>& vertices) const;
void ComputeBBox();
inline G4ThreeVector GetMinimumBBox() const;
inline G4ThreeVector GetMaximumBBox() const;
G4VFacet* MakeDownFacet(const std::vector<G4ThreeVector>& fromVertices,
G4int ind1, G4int ind2, G4int ind3) const;
G4VFacet* MakeUpFacet(const std::vector<G4ThreeVector>& fromVertices,
G4int ind1, G4int ind2, G4int ind3) const;
G4VFacet* MakeSideFacet(const G4ThreeVector& downVertex0,
const G4ThreeVector& downVertex1,
const G4ThreeVector& upVertex1,
const G4ThreeVector& upVertex0) const;
G4TessellatedSolid* CreateTessellatedSolid() const;
EInside InsidePolygone(const G4ThreeVector& p,
const std::vector<G4TwoVector>& poly) const;
G4double DistToPlane(const G4ThreeVector& p,
const G4ThreeVector& v, const G4int ipl) const ;
G4double DistToTriangle(const G4ThreeVector& p,
const G4ThreeVector& v, const G4int ipl) const;
G4ThreeVector NormalToPlane(const G4ThreeVector& p,
const G4int ipl) const;
G4double SafetyToFace(const G4ThreeVector& p, const G4int iseg) const;
G4double GetFaceSurfaceArea(const G4ThreeVector& p0,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3) const;
protected:
mutable G4Polyhedron* fpPolyhedron;
private:
// static data members
static const G4int fgkNofVertices;
static const G4double fgkTolerance;
// data members
G4double fDz;
std::vector<G4TwoVector> fVertices;
G4bool fIsTwisted;
G4double fTwist[4];
G4TessellatedSolid* fTessellatedSolid;
G4ThreeVector fMinBBoxVector;
G4ThreeVector fMaxBBoxVector;
G4int fVisSubdivisions;
enum ESide {kUndefined,kXY0,kXY1,kXY2,kXY3,kMZ,kPZ};
// Codes for faces (kXY[num]=num of lateral face,kMZ= minus z face etc)
G4double fSurfaceArea;
G4double fCubicVolume;
// Surface and Volume
};
#include "G4GenericTrap.icc"
#endif
@@ -0,0 +1,145 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4GenericTrap.icc,v 1.5 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// --------------------------------------------------------------------
// GEANT 4 inline definitions file
//
// G4GenericTrap.icc
//
// Implementation of inline methods of G4GenericTrap
// --------------------------------------------------------------------
inline
G4double G4GenericTrap::GetZHalfLength() const
{
return fDz;
}
// --------------------------------------------------------------------
inline
G4int G4GenericTrap::GetNofVertices() const
{
return fVertices.size();
}
// --------------------------------------------------------------------
inline
G4TwoVector G4GenericTrap::GetVertex(G4int index) const
{
if ( index<0 || index >= G4int(fVertices.size()) )
{
G4Exception ("G4GenericTrap::GetVertex()", "InvalidInput",
FatalException, "Index outside range.");
return G4TwoVector();
}
return fVertices[index];
}
// --------------------------------------------------------------------
inline
const std::vector<G4TwoVector>& G4GenericTrap::GetVertices() const
{
return fVertices;
}
// --------------------------------------------------------------------
inline
G4double G4GenericTrap::GetTwistAngle(G4int index) const
{
if ( (index<0) || (index >= G4int(fVertices.size())) )
{
G4Exception ("G4GenericTrap::GetTwistAngle()", "InvalidInput",
FatalException, "Index outside range.");
return 0.;
}
return fTwist[index];
}
// --------------------------------------------------------------------
inline
G4bool G4GenericTrap::IsTwisted() const
{
return fIsTwisted;
}
// --------------------------------------------------------------------
inline
void G4GenericTrap::SetTwistAngle(G4int index, G4double twist)
{
if ( (index<0) || (index >= G4int(fVertices.size())) )
{
G4Exception ("G4GenericTrap::SetTwistAngle()", "InvalidInput",
FatalException, "Index outside range.");
}
else
{
fTwist[index]=twist;
}
}
// --------------------------------------------------------------------
inline
G4int G4GenericTrap::GetVisSubdivisions()const
{
return fVisSubdivisions;
}
// --------------------------------------------------------------------
inline
void G4GenericTrap::SetVisSubdivisions(G4int subdiv)
{
fVisSubdivisions=subdiv;
}
// --------------------------------------------------------------------
inline
G4ThreeVector G4GenericTrap::GetMinimumBBox() const
{
return fMinBBoxVector;
}
// --------------------------------------------------------------------
inline
G4ThreeVector G4GenericTrap::GetMaximumBBox() const
{
return fMaxBBoxVector;
}
// --------------------------------------------------------------------
@@ -24,9 +24,9 @@
// ********************************************************************
//
//
// $Id: G4Hype.hh,v 1.15 2006/10/20 13:45:20 gcosmo Exp $
// $Id: G4Hype.hh,v 1.17 2010/10/20 08:54:18 gcosmo Exp $
// $Original: G4Hype.hh,v 1.0 1998/06/09 16:57:50 safai Exp $
// GEANT4 tag $Name: geant4-09-02 $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -111,6 +111,8 @@ class G4Hype : public G4VSolid
G4GeometryType GetEntityType() const;
G4VSolid* Clone() const;
std::ostream& StreamInfo(std::ostream& os) const;
G4double GetCubicVolume();
@@ -131,6 +133,10 @@ class G4Hype : public G4VSolid
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4Hype(const G4Hype& rhs);
G4Hype& operator=(const G4Hype& rhs);
// Copy constructor and assignment operator.
protected: // without description
inline G4bool InnerSurfaceExists() const;
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4IntersectingCone.hh,v 1.11 2008/04/28 08:59:47 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4IntersectingCone.hh,v 1.13 2010/07/12 15:33:49 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -80,13 +80,11 @@ class G4IntersectingCone
rLo, rHi; // R bounds of side
G4bool type1; // True if cone is type 1
// (std::abs(z1-z2)>std::abs(r1-r2))
// (std::fabs(z1-z2)>std::fabs(r1-r2))
G4double A, B; // Cone radius parameter:
// type 1: r = A + B*z
// type 2: z = A + B*r
G4double half_kCarTolerance; // half of Surface Thickness
G4int LineHitsCone1( const G4ThreeVector &p, const G4ThreeVector &v,
G4double *s1, G4double *s2 );
G4int LineHitsCone2( const G4ThreeVector &p, const G4ThreeVector &v,
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4Paraboloid.hh,v 1.4 2008/01/22 17:42:09 tnikitin Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4Paraboloid.hh,v 1.6 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -110,6 +110,8 @@ class G4Paraboloid : public G4VSolid
G4GeometryType GetEntityType() const;
G4VSolid* Clone() const;
std::ostream& StreamInfo(std::ostream& os) const;
G4ThreeVector GetPointOnSurface() const;
@@ -128,6 +130,10 @@ class G4Paraboloid : public G4VSolid
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4Paraboloid(const G4Paraboloid& rhs);
G4Paraboloid& operator=(const G4Paraboloid& rhs);
// Copy constructor and assignment operator.
protected: // without description
mutable G4Polyhedron* fpPolyhedron;
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PolyPhiFace.hh,v 1.12 2008/05/15 11:41:58 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PolyPhiFace.hh,v 1.13 2010/07/12 15:25:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -76,7 +76,7 @@ struct G4PolyPhiFaceVertex
struct G4PolyPhiFaceEdge
{
G4PolyPhiFaceEdge(): v0(0), v1(0) {}
G4PolyPhiFaceEdge(): v0(0), v1(0), tr(.0), tz(0.), length(0.) {}
G4PolyPhiFaceVertex *v0, *v1; // Corners
G4double tr, tz, // Unit vector along edge
length; // Length of edge
@@ -211,7 +211,7 @@ class G4PolyPhiFace : public G4VCSGface
// For details see "Computational Geometry in C" by Joseph O'Rourke.
void Triangulate();
// Triangulisation by ear tips for Polycone or Polyhedra.
// Triangularisation by ear tips for Polycone or Polyhedra.
// For details see "Computational Geometry in C" by Joseph O'Rourke.
// NOTE: a copy of the shape is made and this copy is reordered in
// order to have a list of triangles. This list is used by the
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4Polycone.hh,v 1.22 2008/05/15 13:45:15 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4Polycone.hh,v 1.24 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -105,9 +105,6 @@ class G4Polycone : public G4VCSGfaceted
virtual ~G4Polycone();
G4Polycone( const G4Polycone &source );
const G4Polycone &operator=( const G4Polycone &source );
// Methods for solid
EInside Inside( const G4ThreeVector &p ) const;
@@ -122,6 +119,8 @@ class G4Polycone : public G4VCSGfaceted
G4GeometryType GetEntityType() const;
G4VSolid* Clone() const;
std::ostream& StreamInfo(std::ostream& os) const;
G4Polyhedron* CreatePolyhedron() const;
@@ -147,6 +146,10 @@ class G4Polycone : public G4VCSGfaceted
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4Polycone( const G4Polycone &source );
const G4Polycone &operator=( const G4Polycone &source );
// Copy constructor and assignment operator.
protected: // without description
// Generic initializer, called by all constructors
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PolyconeSide.hh,v 1.12 2008/05/15 11:41:58 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PolyconeSide.hh,v 1.13 2010/02/24 11:18:25 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
//
// --------------------------------------------------------------------
@@ -111,6 +111,25 @@ class G4PolyconeSide : public G4VCSGface
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
protected:
G4double DistanceAway( const G4ThreeVector &p, G4bool opposite,
G4double &distOutside2, G4double *rzNorm=0 );
G4bool PointOnCone( const G4ThreeVector &hit, G4double normSign,
const G4ThreeVector &p,
const G4ThreeVector &v, G4ThreeVector &normal );
void CopyStuff( const G4PolyconeSide &source );
static void FindLineIntersect( G4double x1, G4double y1,
G4double tx1, G4double ty1,
G4double x2, G4double y2,
G4double tx2, G4double ty2,
G4double &x, G4double &y );
G4double GetPhi( const G4ThreeVector& p );
protected:
G4double r[2], z[2]; // r, z parameters, in specified order
@@ -135,22 +154,9 @@ class G4PolyconeSide : public G4VCSGface
G4int ncorners;
G4ThreeVector *corners; // The coordinates of the corners (if phiIsOpen)
G4double DistanceAway( const G4ThreeVector &p, G4bool opposite,
G4double &distOutside2, G4double *rzNorm=0 );
G4bool PointOnCone( const G4ThreeVector &hit, G4double normSign,
const G4ThreeVector &p,
const G4ThreeVector &v, G4ThreeVector &normal );
void CopyStuff( const G4PolyconeSide &source );
static void FindLineIntersect( G4double x1, G4double y1,
G4double tx1, G4double ty1,
G4double x2, G4double y2,
G4double tx2, G4double ty2,
G4double &x, G4double &y );
private:
std::pair<G4ThreeVector, G4double> fPhi; // Cached value for phi
G4double kCarTolerance; // Geometrical surface thickness
G4double fSurfaceArea; // Used for surface calculation
};
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4Polyhedra.hh,v 1.20 2008/05/15 13:45:15 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4Polyhedra.hh,v 1.22 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -108,9 +108,6 @@ class G4Polyhedra : public G4VCSGfaceted
const G4double z[] ); // z coordinate of these corners
virtual ~G4Polyhedra();
G4Polyhedra( const G4Polyhedra &source );
const G4Polyhedra &operator=( const G4Polyhedra &source );
// Methods for solid
@@ -125,6 +122,8 @@ class G4Polyhedra : public G4VCSGfaceted
G4GeometryType GetEntityType() const;
G4VSolid* Clone() const;
G4ThreeVector GetPointOnSurface() const;
std::ostream& StreamInfo( std::ostream& os ) const;
@@ -158,6 +157,10 @@ class G4Polyhedra : public G4VCSGfaceted
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4Polyhedra( const G4Polyhedra &source );
const G4Polyhedra &operator=( const G4Polyhedra &source );
// Copy constructor and assignment operator.
protected: // without description
inline void SetOriginalParameters();
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PolyhedraSide.hh,v 1.11 2008/05/15 11:41:59 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PolyhedraSide.hh,v 1.13 2010/07/12 15:25:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -152,7 +152,7 @@ class G4PolyhedraSide : public G4VCSGface
} G4PolyhedraSideVec;
G4bool IntersectSidePlane( const G4ThreeVector &p, const G4ThreeVector &v,
const G4PolyhedraSideVec vec,
const G4PolyhedraSideVec& vec,
G4double normSign,
G4double surfTolerance,
G4double &distance,
@@ -165,7 +165,9 @@ class G4PolyhedraSide : public G4VCSGface
G4int ClosestPhiSegment( G4double phi );
G4int PhiSegment( G4double phi );
G4double GetPhi( const G4ThreeVector& p );
G4double DistanceToOneSide( const G4ThreeVector &p,
const G4PolyhedraSideVec &vec,
G4double *normDist );
@@ -196,6 +198,7 @@ class G4PolyhedraSide : public G4VCSGface
private:
std::pair<G4ThreeVector, G4double> fPhi; // Cached value for phi
G4double kCarTolerance; // Geometrical surface thickness
G4double fSurfaceArea; // Surface Area
};
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4ReduciblePolygon.hh,v 1.9 2006/06/29 18:47:29 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4ReduciblePolygon.hh,v 1.10 2010/07/12 15:25:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -141,7 +141,7 @@ class G4ReduciblePolygon
friend struct ABVertex; // protected nested structures
struct ABVertex
{
ABVertex() { next = 0; }
ABVertex() : a(0.), b(0.), next(0) {}
G4double a, b;
ABVertex *next;
};
@@ -24,8 +24,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TessellatedSolid.hh,v 1.10 2007/12/10 16:30:13 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TessellatedSolid.hh,v 1.11 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
@@ -159,6 +159,7 @@ class G4TessellatedSolid : public G4VSolid
G4bool *validNorm=0, G4ThreeVector *n=0) const;
virtual G4double DistanceToOut (const G4ThreeVector &p) const;
virtual G4GeometryType GetEntityType () const;
virtual G4VSolid* Clone() const;
void SetSolidClosed (const G4bool t);
G4bool GetSolidClosed () const;
@@ -28,8 +28,8 @@
// ********************************************************************
//
//
// $Id: G4Tet.hh,v 1.9 2006/11/13 08:58:03 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4Tet.hh,v 1.11 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -47,6 +47,7 @@
// 03.09.2004 - M.H.Mendenhall & R.A.Weller (Vanderbilt University, USA)
// 10.02.2005 - D.Anninos (CERN) - Added GetPointOnSurface() method.
// 12.11.2006 - M.H.Mendenhall - Added GetSurfaceArea() concrete implementation.
// 20.09.2010 - G.Cosmo (CERN) - Added copy-ctor and operator=().
// --------------------------------------------------------------------
#ifndef G4TET_HH
#define G4TET_HH
@@ -96,6 +97,8 @@ class G4Tet : public G4VSolid
G4GeometryType GetEntityType() const;
G4VSolid* Clone() const;
std::ostream& StreamInfo(std::ostream& os) const;
G4ThreeVector GetPointOnSurface() const;
@@ -115,8 +118,12 @@ class G4Tet : public G4VSolid
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4Tet(const G4Tet& rhs);
G4Tet& operator=(const G4Tet& rhs);
// Copy constructor and assignment operator.
const char* CVSHeaderVers()
{ return "$Id: G4Tet.hh,v 1.9 2006/11/13 08:58:03 gcosmo Exp $"; }
{ return "$Id: G4Tet.hh,v 1.11 2010/10/20 08:54:18 gcosmo Exp $"; }
const char* CVSFileVers()
{ return CVSVers; }
void PrintWarnings(G4bool flag)
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TwistedBox.hh,v 1.10 2006/06/29 18:48:00 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TwistedBox.hh,v 1.12 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -78,6 +78,8 @@ class G4TwistedBox : public G4VTwistedFaceted
G4GeometryType GetEntityType() const;
G4VSolid* Clone() const;
std::ostream& StreamInfo(std::ostream& os) const;
public: // without description
@@ -86,6 +88,10 @@ class G4TwistedBox : public G4VTwistedFaceted
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4TwistedBox(const G4TwistedBox& rhs);
G4TwistedBox& operator=(const G4TwistedBox& rhs);
// Copy constructor and assignment operator.
};
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TwistedTrap.hh,v 1.10 2006/06/29 18:48:02 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TwistedTrap.hh,v 1.12 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -113,6 +113,8 @@ class G4TwistedTrap : public G4VTwistedFaceted
G4GeometryType GetEntityType() const;
G4VSolid* Clone() const;
std::ostream &StreamInfo(std::ostream& os) const;
public: // without description
@@ -122,6 +124,10 @@ class G4TwistedTrap : public G4VTwistedFaceted
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4TwistedTrap(const G4TwistedTrap& rhs);
G4TwistedTrap& operator=(const G4TwistedTrap& rhs);
// Copy constructor and assignment operator.
} ;
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TwistedTrd.hh,v 1.6 2006/06/29 18:48:04 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TwistedTrd.hh,v 1.8 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -84,6 +84,8 @@ class G4TwistedTrd : public G4VTwistedFaceted
G4GeometryType GetEntityType() const;
G4VSolid* Clone() const;
std::ostream& StreamInfo(std::ostream& os) const;
public: // without description
@@ -93,6 +95,10 @@ class G4TwistedTrd : public G4VTwistedFaceted
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4TwistedTrd(const G4TwistedTrd& rhs);
G4TwistedTrd& operator=(const G4TwistedTrd& rhs);
// Copy constructor and assignment operator.
} ;
#endif
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TwistedTubs.hh,v 1.14 2007/05/23 09:32:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TwistedTubs.hh,v 1.16 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -166,6 +166,7 @@ class G4TwistedTubs : public G4VSolid
G4VisExtent GetExtent () const;
G4GeometryType GetEntityType() const;
G4VSolid* Clone() const;
G4double GetCubicVolume();
// Returns an estimation of the geometrical cubic volume of the
@@ -183,6 +184,10 @@ class G4TwistedTubs : public G4VSolid
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4TwistedTubs(const G4TwistedTubs& rhs);
G4TwistedTubs& operator=(const G4TwistedTubs& rhs);
// Copy constructor and assignment operator.
#ifdef G4TWISTDEBUG
G4VTwistSurface * GetOuterHype() const { return fOuterHype; }
#endif
@@ -247,9 +252,15 @@ class G4TwistedTubs : public G4VSolid
inside = kOutside;
}
~LastState(){}
LastState(const LastState& r) : p(r.p), inside(r.inside){}
LastState& operator=(const LastState& r)
{
p = r.p; inside = r.inside;
return *this;
}
public:
G4ThreeVector p;
EInside inside;
EInside inside;
};
class LastVector // last SurfaceNormal result
@@ -265,10 +276,22 @@ class G4TwistedTubs : public G4VSolid
{
delete [] surface;
}
LastVector(const LastVector& r) : p(r.p), vec(r.vec)
{
surface = new G4VTwistSurface*[1];
surface[0] = r.surface[0];
}
LastVector& operator=(const LastVector& r)
{
p = r.p; vec = r.vec;
delete [] surface; surface = new G4VTwistSurface*[1];
surface[0] = r.surface[0];
return *this;
}
public:
G4ThreeVector p;
G4ThreeVector vec;
G4VTwistSurface **surface;
G4VTwistSurface **surface;
};
class LastValue // last G4double value
@@ -280,6 +303,12 @@ class G4TwistedTubs : public G4VSolid
value = DBL_MAX;
}
~LastValue(){}
LastValue(const LastValue& r) : p(r.p), value(r.value){}
LastValue& operator=(const LastValue& r)
{
p = r.p; value = r.value;
return *this;
}
public:
G4ThreeVector p;
G4double value;
@@ -295,10 +324,17 @@ class G4TwistedTubs : public G4VSolid
value = DBL_MAX;
}
~LastValueWithDoubleVector(){}
public:
G4ThreeVector p;
G4ThreeVector vec;
G4double value;
LastValueWithDoubleVector(const LastValueWithDoubleVector& r)
: p(r.p), vec(r.vec), value(r.value){}
LastValueWithDoubleVector& operator=(const LastValueWithDoubleVector& r)
{
p = r.p; vec = r.vec; value = r.value;
return *this;
}
public:
G4ThreeVector p;
G4ThreeVector vec;
G4double value;
};
LastState fLastInside;
@@ -24,8 +24,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VFacet.hh,v 1.7 2008/12/18 12:57:30 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VFacet.hh,v 1.8 2010/09/23 10:27:25 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
@@ -102,6 +102,11 @@ class G4VFacet
virtual G4double GetArea() = 0;
virtual G4ThreeVector GetPointOnFace() const = 0;
public: // without description
G4VFacet (const G4VFacet &right);
const G4VFacet &operator=(G4VFacet &right);
protected:
G4GeometryType geometryType;
@@ -119,11 +124,6 @@ class G4VFacet
G4double dirTolerance;
G4double kCarTolerance;
G4double area;
private:
G4VFacet (const G4VFacet &right);
const G4VFacet &operator=(G4VFacet &right);
};
typedef std::vector<G4VFacet*>::iterator FacetI;
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4VTwistSurface.icc,v 1.3 2006/06/29 18:48:20 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VTwistSurface.icc,v 1.5 2010/07/16 15:58:59 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -49,7 +49,9 @@ G4double G4VTwistSurface::DistanceToPlaneWithV(const G4ThreeVector &p,
const G4ThreeVector &n0,
G4ThreeVector &xx)
{
G4double t = (n0 * (x0 - p)) / (n0 * v);
G4double q = n0 * v;
G4double t = kInfinity;
if (q) { t = (n0 * (x0 - p)) / q; }
xx = p + t * v;
return t;
}
@@ -80,7 +82,7 @@ G4double G4VTwistSurface::DistanceToPlane(const G4ThreeVector &p,
// xx = p - t*n
//
// where
// t = n * (p - x0) / std::abs(n)
// t = n * (p - x0) / std::fabs(n)
//
G4double t;
G4ThreeVector n = n0.unit();
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4VTwistedFaceted.hh,v 1.10 2006/10/20 13:45:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VTwistedFaceted.hh,v 1.12 2010/09/20 15:03:02 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
@@ -148,6 +148,10 @@ class G4VTwistedFaceted: public G4VSolid
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4VTwistedFaceted(const G4VTwistedFaceted& rhs);
G4VTwistedFaceted& operator=(const G4VTwistedFaceted& rhs);
// Copy constructor and assignment operator.
protected: // with description
G4ThreeVectorList*
@@ -185,8 +189,6 @@ class G4VTwistedFaceted: public G4VSolid
G4double fPhiTwist; // twist angle ( dphi in surface equation)
G4double fAngleSide;
G4VTwistSurface *fLowerEndcap ; // surface of -ve z
G4VTwistSurface *fUpperEndcap ; // surface of +ve z
@@ -205,13 +207,18 @@ class G4VTwistedFaceted: public G4VSolid
public:
LastState()
{
p.set(kInfinity,kInfinity,kInfinity);
inside = kOutside;
p.set(kInfinity,kInfinity,kInfinity); inside = kOutside;
}
~LastState(){}
LastState(const LastState& r) : p(r.p), inside(r.inside){}
LastState& operator=(const LastState& r)
{
p = r.p; inside = r.inside;
return *this;
}
public:
G4ThreeVector p;
EInside inside;
EInside inside;
};
class LastVector // last SurfaceNormal result
@@ -227,10 +234,22 @@ class G4VTwistedFaceted: public G4VSolid
{
delete [] surface;
}
LastVector(const LastVector& r) : p(r.p), vec(r.vec)
{
surface = new G4VTwistSurface*[1];
surface[0] = r.surface[0];
}
LastVector& operator=(const LastVector& r)
{
p = r.p; vec = r.vec;
delete [] surface; surface = new G4VTwistSurface*[1];
surface[0] = r.surface[0];
return *this;
}
public:
G4ThreeVector p;
G4ThreeVector vec;
G4VTwistSurface **surface;
G4VTwistSurface **surface;
};
class LastValue // last G4double value
@@ -242,6 +261,12 @@ class G4VTwistedFaceted: public G4VSolid
value = DBL_MAX;
}
~LastValue(){}
LastValue(const LastValue& r) : p(r.p), value(r.value){}
LastValue& operator=(const LastValue& r)
{
p = r.p; value = r.value;
return *this;
}
public:
G4ThreeVector p;
G4double value;
@@ -257,10 +282,17 @@ class G4VTwistedFaceted: public G4VSolid
value = DBL_MAX;
}
~LastValueWithDoubleVector(){}
public:
G4ThreeVector p;
G4ThreeVector vec;
G4double value;
LastValueWithDoubleVector(const LastValueWithDoubleVector& r)
: p(r.p), vec(r.vec), value(r.value){}
LastValueWithDoubleVector& operator=(const LastValueWithDoubleVector& r)
{
p = r.p; vec = r.vec; value = r.value;
return *this;
}
public:
G4ThreeVector p;
G4ThreeVector vec;
G4double value;
};
LastState fLastInside;
@@ -0,0 +1,142 @@
#------------------------------------------------------------------------------
# sources.cmake
# Module : G4specsolids
# Package: Geant4.src.G4geometry..G4specsolids
#
# Sources description for a library.
# Lists the sources and headers of the code explicitely.
# Lists include paths needed.
# Lists the internal granular and global dependencies of the library.
# Source specific properties should be added at the end.
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake,v 1.1 2010/09/29 18:43:17 bmorgan Exp $
#
#------------------------------------------------------------------------------
# List external includes needed.
include_directories(${CLHEP_INCLUDE_DIRS})
# List internal includes needed.
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/volumes/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPGeometry/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPNumerics/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPRandom/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/graphics_reps/include)
include_directories(${CMAKE_SOURCE_DIR}/source/intercoms/include)
#
# Define the Geant4 Module.
#
include(Geant4MacroDefineModule)
GEANT4_DEFINE_MODULE(NAME G4specsolids
HEADERS
G4ClippablePolygon.hh
G4ClippablePolygon.icc
G4Ellipsoid.hh
G4Ellipsoid.icc
G4EllipticalCone.hh
G4EllipticalCone.icc
G4EllipticalTube.hh
G4EllipticalTube.icc
G4EnclosingCylinder.hh
G4ExtrudedSolid.hh
G4ExtrudedSolid.icc
G4GenericTrap.hh
G4GenericTrap.icc
G4Hype.hh
G4Hype.icc
G4IntersectingCone.hh
G4Paraboloid.hh
G4Paraboloid.icc
G4PolyPhiFace.hh
G4PolyPhiFace.icc
G4Polycone.hh
G4Polycone.icc
G4PolyconeSide.hh
G4Polyhedra.hh
G4Polyhedra.icc
G4PolyhedraSide.hh
G4QuadrangularFacet.hh
G4ReduciblePolygon.hh
G4SolidExtentList.hh
G4TessellatedGeometryAlgorithms.hh
G4TessellatedGeometryAlgorithms.icc
G4TessellatedSolid.hh
G4Tet.hh
G4TriangularFacet.hh
G4TwistBoxSide.hh
G4TwistTrapAlphaSide.hh
G4TwistTrapFlatSide.hh
G4TwistTrapParallelSide.hh
G4TwistTubsFlatSide.hh
G4TwistTubsHypeSide.hh
G4TwistTubsSide.hh
G4TwistedBox.hh
G4TwistedTrap.hh
G4TwistedTrd.hh
G4TwistedTubs.hh
G4VCSGface.hh
G4VCSGfaceted.hh
G4VFacet.hh
G4VFacet.icc
G4VTwistSurface.hh
G4VTwistSurface.icc
G4VTwistedFaceted.hh
SOURCES
G4ClippablePolygon.cc
G4Ellipsoid.cc
G4EllipticalCone.cc
G4EllipticalTube.cc
G4EnclosingCylinder.cc
G4ExtrudedSolid.cc
G4GenericTrap.cc
G4Hype.cc
G4IntersectingCone.cc
G4Paraboloid.cc
G4PolyPhiFace.cc
G4Polycone.cc
G4PolyconeSide.cc
G4Polyhedra.cc
G4PolyhedraSide.cc
G4QuadrangularFacet.cc
G4ReduciblePolygon.cc
G4SolidExtentList.cc
G4TessellatedGeometryAlgorithms.cc
G4TessellatedSolid.cc
G4Tet.cc
G4TriangularFacet.cc
G4TwistBoxSide.cc
G4TwistTrapAlphaSide.cc
G4TwistTrapFlatSide.cc
G4TwistTrapParallelSide.cc
G4TwistTubsFlatSide.cc
G4TwistTubsHypeSide.cc
G4TwistTubsSide.cc
G4TwistedBox.cc
G4TwistedTrap.cc
G4TwistedTrd.cc
G4TwistedTubs.cc
G4VCSGfaceted.cc
G4VFacet.cc
G4VTwistSurface.cc
G4VTwistedFaceted.cc
GRANULAR_DEPENDENCIES
G4geometrymng
G4globman
G4graphics_reps
G4hepnumerics
G4intercoms
G4volumes
GLOBAL_DEPENDENCIES
G4global
G4graphics_reps
G4intercoms
LINK_LIBRARIES
)
# List any source specific properties here
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4Ellipsoid.cc,v 1.24 2009/09/24 15:51:02 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4Ellipsoid.cc,v 1.30 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// class G4Ellipsoid
//
@@ -77,11 +77,7 @@ G4Ellipsoid::G4Ellipsoid(const G4String& pName,
kRadTolerance = G4GeometryTolerance::GetInstance()->GetRadialTolerance();
// Check Semi-Axis
if ( (pxSemiAxis>0.) && (pySemiAxis>0.) && (pzSemiAxis>0.) )
{
SetSemiAxis(pxSemiAxis, pySemiAxis, pzSemiAxis);
}
else
if ( (pxSemiAxis<=0.) || (pySemiAxis<=0.) || (pzSemiAxis<=0.) )
{
G4cerr << "ERROR - G4Ellipsoid::G4Ellipsoid(): " << GetName() << G4endl
<< " Invalid semi-axis !"
@@ -89,6 +85,7 @@ G4Ellipsoid::G4Ellipsoid(const G4String& pName,
G4Exception("G4Ellipsoid::G4Ellipsoid()", "InvalidSetup",
FatalException, "Invalid semi-axis.");
}
SetSemiAxis(pxSemiAxis, pySemiAxis, pzSemiAxis);
if ( pzBottomCut == 0 && pzTopCut == 0 )
{
@@ -115,7 +112,9 @@ G4Ellipsoid::G4Ellipsoid(const G4String& pName,
// for usage restricted to object persistency.
//
G4Ellipsoid::G4Ellipsoid( __void__& a )
: G4VSolid(a), fpPolyhedron(0), fCubicVolume(0.), fSurfaceArea(0.)
: G4VSolid(a), fpPolyhedron(0), kRadTolerance(0.), fCubicVolume(0.),
fSurfaceArea(0.), xSemiAxis(0.), ySemiAxis(0.), zSemiAxis(0.),
semiAxisMax(0.), zBottomCut(0.), zTopCut(0.)
{
}
@@ -127,6 +126,45 @@ G4Ellipsoid::~G4Ellipsoid()
{
}
///////////////////////////////////////////////////////////////////////////////
//
// Copy constructor
G4Ellipsoid::G4Ellipsoid(const G4Ellipsoid& rhs)
: G4VSolid(rhs),
fpPolyhedron(0), kRadTolerance(rhs.kRadTolerance),
fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
xSemiAxis(rhs.xSemiAxis), ySemiAxis(rhs.ySemiAxis),
zSemiAxis(rhs.zSemiAxis), semiAxisMax(rhs.semiAxisMax),
zBottomCut(rhs.zBottomCut), zTopCut(rhs.zTopCut)
{
}
///////////////////////////////////////////////////////////////////////////////
//
// Assignment operator
G4Ellipsoid& G4Ellipsoid::operator = (const G4Ellipsoid& rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4VSolid::operator=(rhs);
// Copy data
//
fpPolyhedron = 0; kRadTolerance = rhs.kRadTolerance;
fCubicVolume = rhs.fCubicVolume; fSurfaceArea = rhs.fSurfaceArea;
xSemiAxis = rhs.xSemiAxis; ySemiAxis = rhs.ySemiAxis;
zSemiAxis = rhs.zSemiAxis; semiAxisMax = rhs.semiAxisMax;
zBottomCut = rhs.zBottomCut; zTopCut = rhs.zTopCut;
return *this;
}
///////////////////////////////////////////////////////////////////////////////
//
// Calculate extent under transform and specified limit
@@ -475,7 +513,7 @@ G4double G4Ellipsoid::DistanceToIn( const G4ThreeVector& p,
if ( (distZ > -halfRadTolerance) && (Inside(p+distZ*v) != kOutside) )
{
// early exit since can't intercept curved surface if we reach here
if ( std::abs(distZ) < halfRadTolerance ) { distZ=0.; }
if ( std::fabs(distZ) < halfRadTolerance ) { distZ=0.; }
return distMin= distZ;
}
}
@@ -486,7 +524,7 @@ G4double G4Ellipsoid::DistanceToIn( const G4ThreeVector& p,
if ( (distZ > -halfRadTolerance) && (Inside(p+distZ*v) != kOutside) )
{
// early exit since can't intercept curved surface if we reach here
if ( std::abs(distZ) < halfRadTolerance ) { distZ=0.; }
if ( std::fabs(distZ) < halfRadTolerance ) { distZ=0.; }
return distMin= distZ;
}
}
@@ -543,7 +581,7 @@ G4double G4Ellipsoid::DistanceToIn( const G4ThreeVector& p,
}
}
if (std::abs(distMin)<halfRadTolerance) { distMin=0.; }
if (std::fabs(distMin)<halfRadTolerance) { distMin=0.; }
return distMin;
}
@@ -687,8 +725,8 @@ G4double G4Ellipsoid::DistanceToOut(const G4ThreeVector& p,
truenorm *= 1.0/truenorm.mag();
*n= truenorm;
} break;
default:
G4cout.precision(16);
default: // Should never reach this case ...
G4int oldprc = G4cout.precision(16);
G4cout << G4endl;
DumpInfo();
G4cout << "Position:" << G4endl << G4endl;
@@ -701,6 +739,7 @@ G4double G4Ellipsoid::DistanceToOut(const G4ThreeVector& p,
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
G4cout << "Proposed distance :" << G4endl << G4endl;
G4cout << "distMin = " << distMin/mm << " mm" << G4endl << G4endl;
G4cout.precision(oldprc);
G4Exception("G4Ellipsoid::DistanceToOut(p,v,..)",
"Notification", JustWarning,
"Undefined side for valid surface normal to solid.");
@@ -723,13 +762,14 @@ G4double G4Ellipsoid::DistanceToOut(const G4ThreeVector& p) const
#ifdef G4SPECSDEBUG
if( Inside(p) == kOutside )
{
G4cout.precision(16) ;
G4int oldprc = G4cout.precision(16) ;
G4cout << G4endl ;
DumpInfo();
G4cout << "Position:" << G4endl << G4endl ;
G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl ;
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl ;
G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl ;
G4cout.precision(oldprc) ;
G4Exception("G4Ellipsoid::DistanceToOut(p)", "Notification", JustWarning,
"Point p is outside !?" );
}
@@ -793,16 +833,18 @@ G4Ellipsoid::CreateRotatedVertices(const G4AffineTransform& pTransform,
// Phi cross sections
//
noPhiCrossSections=G4int (twopi/kMeshAngleDefault)+1;
noPhiCrossSections=G4int (twopi/kMeshAngleDefault)+1; // = 9!
if (noPhiCrossSections<kMinMeshSections)
/*
if (noPhiCrossSections<kMinMeshSections) // <3
{
noPhiCrossSections=kMinMeshSections;
}
else if (noPhiCrossSections>kMaxMeshSections)
else if (noPhiCrossSections>kMaxMeshSections) // >37
{
noPhiCrossSections=kMaxMeshSections;
}
*/
meshAnglePhi=twopi/(noPhiCrossSections-1);
// Set start angle such that mesh will be at fRMax
@@ -812,16 +854,18 @@ G4Ellipsoid::CreateRotatedVertices(const G4AffineTransform& pTransform,
// Theta cross sections
noThetaSections = G4int(pi/kMeshAngleDefault)+3;
if (noThetaSections<kMinMeshSections)
noThetaSections = G4int(pi/kMeshAngleDefault)+3; // = 7!
/*
if (noThetaSections<kMinMeshSections) // <3
{
noThetaSections=kMinMeshSections;
}
else if (noThetaSections>kMaxMeshSections)
else if (noThetaSections>kMaxMeshSections) // >37
{
noThetaSections=kMaxMeshSections;
}
*/
meshTheta= pi/(noThetaSections-2);
// Set start angle such that mesh will be at fRMax
@@ -897,6 +941,15 @@ G4GeometryType G4Ellipsoid::GetEntityType() const
return G4String("G4Ellipsoid");
}
//////////////////////////////////////////////////////////////////////////
//
// Make a clone of the object
G4VSolid* G4Ellipsoid::Clone() const
{
return new G4Ellipsoid(*this);
}
//////////////////////////////////////////////////////////////////////////
//
// Stream object contents to an output stream
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EllipticalCone.cc,v 1.16 2008/04/25 08:45:26 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4EllipticalCone.cc,v 1.23 2010/11/16 11:46:11 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// Implementation of G4EllipticalCone class
//
@@ -77,13 +77,9 @@ G4EllipticalCone::G4EllipticalCone(const G4String& pName,
kRadTolerance = G4GeometryTolerance::GetInstance()->GetRadialTolerance();
// Check Semi-Axis
// Check Semi-Axis & Z-cut
//
if ( (pxSemiAxis > 0.) && (pySemiAxis > 0.) && (pzMax > 0.) )
{
SetSemiAxis( pxSemiAxis, pySemiAxis, pzMax );
}
else
if ( (pxSemiAxis <= 0.) || (pySemiAxis <= 0.) || (pzMax <= 0.) )
{
G4cerr << "ERROR - G4EllipticalCone::G4EllipticalCone(): "
<< GetName() << G4endl
@@ -91,12 +87,7 @@ G4EllipticalCone::G4EllipticalCone(const G4String& pName,
G4Exception("G4EllipticalCone::G4EllipticalCone()", "InvalidSetup",
FatalException, "Invalid semi-axis or height.");
}
if ( pzTopCut > 0 )
{
SetZCut(pzTopCut);
}
else
if ( pzTopCut <= 0 )
{
G4cerr << "ERROR - G4EllipticalCone::G4EllipticalCone(): "
<< GetName() << G4endl
@@ -104,6 +95,9 @@ G4EllipticalCone::G4EllipticalCone(const G4String& pName,
G4Exception("G4EllipticalCone::G4EllipticalCone()", "InvalidSetup",
FatalException, "Invalid z-coordinate for cutting plane.");
}
SetSemiAxis( pxSemiAxis, pySemiAxis, pzMax );
SetZCut(pzTopCut);
}
///////////////////////////////////////////////////////////////////////////////
@@ -112,8 +106,9 @@ G4EllipticalCone::G4EllipticalCone(const G4String& pName,
// for usage restricted to object persistency.
//
G4EllipticalCone::G4EllipticalCone( __void__& a )
: G4VSolid(a), fpPolyhedron(0), fCubicVolume(0.), fSurfaceArea(0.),
zTopCut(0.)
: G4VSolid(a), fpPolyhedron(0), kRadTolerance(0.), fCubicVolume(0.),
fSurfaceArea(0.), xSemiAxis(0.), ySemiAxis(0.), zheight(0.),
semiAxisMax(0.), zTopCut(0.)
{
}
@@ -125,6 +120,43 @@ G4EllipticalCone::~G4EllipticalCone()
{
}
///////////////////////////////////////////////////////////////////////////////
//
// Copy constructor
//
G4EllipticalCone::G4EllipticalCone(const G4EllipticalCone& rhs)
: G4VSolid(rhs),
fpPolyhedron(0), kRadTolerance(rhs.kRadTolerance),
fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
xSemiAxis(rhs.xSemiAxis), ySemiAxis(rhs.ySemiAxis), zheight(rhs.zheight),
semiAxisMax(rhs.semiAxisMax), zTopCut(rhs.zTopCut)
{
}
///////////////////////////////////////////////////////////////////////////////
//
// Assignment operator
//
G4EllipticalCone& G4EllipticalCone::operator = (const G4EllipticalCone& rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4VSolid::operator=(rhs);
// Copy data
//
fpPolyhedron = 0; kRadTolerance = rhs.kRadTolerance;
fCubicVolume = rhs.fCubicVolume; fSurfaceArea = rhs.fSurfaceArea;
xSemiAxis = rhs.xSemiAxis; ySemiAxis = rhs.ySemiAxis;
zheight = rhs.zheight; semiAxisMax = rhs.semiAxisMax; zTopCut = rhs.zTopCut;
return *this;
}
///////////////////////////////////////////////////////////////////////////////
//
// Calculate extent under transform and specified limit
@@ -256,17 +288,20 @@ EInside G4EllipticalCone::Inside(const G4ThreeVector& p) const
EInside in;
static const G4double halfRadTol = 0.5*kRadTolerance;
static const G4double halfCarTol = 0.5*kCarTolerance;
// check this side of z cut first, because that's fast
//
if ( (p.z() < -zTopCut - 0.5*kCarTolerance)
|| (p.z() > zTopCut + 0.5*kCarTolerance ) )
if ( (p.z() < -zTopCut - halfCarTol)
|| (p.z() > zTopCut + halfCarTol ) )
{
return in = kOutside;
}
rad2oo= sqr(p.x()/( xSemiAxis + 0.5*kRadTolerance ))
+ sqr(p.y()/( ySemiAxis + 0.5*kRadTolerance ));
rad2oo= sqr(p.x()/( xSemiAxis + halfRadTol ))
+ sqr(p.y()/( ySemiAxis + halfRadTol ));
if ( rad2oo > sqr( zheight-p.z() ) )
{
@@ -275,13 +310,13 @@ EInside G4EllipticalCone::Inside(const G4ThreeVector& p) const
// rad2oi= sqr( p.x()*(1.0 + 0.5*kRadTolerance/(xSemiAxis*xSemiAxis)) )
// + sqr( p.y()*(1.0 + 0.5*kRadTolerance/(ySemiAxis*ySemiAxis)) );
rad2oi = sqr(p.x()/( xSemiAxis - 0.5*kRadTolerance ))
+ sqr(p.y()/( ySemiAxis - 0.5*kRadTolerance ));
rad2oi = sqr(p.x()/( xSemiAxis - halfRadTol ))
+ sqr(p.y()/( ySemiAxis - halfRadTol ));
if (rad2oi < sqr( zheight-p.z() ) )
{
in = ( ( p.z() < -zTopCut + 0.5*kRadTolerance )
|| ( p.z() > zTopCut - 0.5*kRadTolerance ) ) ? kSurface : kInside;
in = ( ( p.z() < -zTopCut + halfRadTol )
|| ( p.z() > zTopCut - halfRadTol ) ) ? kSurface : kInside;
}
else
{
@@ -341,7 +376,7 @@ G4ThreeVector G4EllipticalCone::SurfaceNormal( const G4ThreeVector& p) const
norm = G4ThreeVector( p.x() < 0. ? -x : x,
p.y() < 0. ? -y : y,
zheight - zTopCut );
- ( zheight - zTopCut ) );
norm /= norm.mag();
norm += G4ThreeVector( 0., 0., 1. );
return norm /= norm.mag();
@@ -373,7 +408,7 @@ G4ThreeVector G4EllipticalCone::SurfaceNormal( const G4ThreeVector& p) const
norm = G4ThreeVector( p.x() < 0. ? -x : x,
p.y() < 0. ? -y : y,
zheight - zTopCut );
- ( zheight - zTopCut ) );
norm /= norm.mag();
norm += G4ThreeVector( 0., 0., -1. );
return norm /= norm.mag();
@@ -541,8 +576,8 @@ G4double G4EllipticalCone::DistanceToIn( const G4ThreeVector& p,
}
}
if (p.z() > zTopCut - 0.5*kCarTolerance
&& p.z() < zTopCut + 0.5*kCarTolerance )
if (p.z() > zTopCut - halfTol
&& p.z() < zTopCut + halfTol )
{
if (v.z() > 0.)
{ return kInfinity; }
@@ -550,8 +585,8 @@ G4double G4EllipticalCone::DistanceToIn( const G4ThreeVector& p,
return distMin = 0.;
}
if (p.z() < -zTopCut + 0.5*kCarTolerance
&& p.z() > -zTopCut - 0.5*kCarTolerance)
if (p.z() < -zTopCut + halfTol
&& p.z() > -zTopCut - halfTol)
{
if (v.z() < 0.)
{ return distMin = kInfinity; }
@@ -575,20 +610,37 @@ G4double G4EllipticalCone::DistanceToIn( const G4ThreeVector& p,
// if the discriminant is negative it never hits the curved object
//
if ( discr < -0.5*kCarTolerance )
if ( discr < -halfTol )
{ return distMin; }
//case below is when it hits or grazes the surface
//
if ( (discr >= - 0.5*kCarTolerance ) && (discr < 0.5*kCarTolerance ) )
if ( (discr >= - halfTol ) && (discr < halfTol ) )
{
return distMin = std::fabs(-B/(2.*A));
}
G4double plus = (-B+std::sqrt(discr))/(2.*A);
G4double minus = (-B-std::sqrt(discr))/(2.*A);
// G4double lambda = std::fabs(plus) < std::fabs(minus) ? plus : minus;
// Special case::Point on Surface, Check norm.dot(v)
if ( ( std::fabs(plus) < halfTol )||( std::fabs(minus) < halfTol ) )
{
G4ThreeVector truenorm(p.x()/(xSemiAxis*xSemiAxis),
p.y()/(ySemiAxis*ySemiAxis),
-( p.z() - zheight ));
if ( truenorm*v >= 0) // going outside the solid from surface
{
return kInfinity;
}
else
{
return 0;
}
}
// G4double lambda = std::fabs(plus) < std::fabs(minus) ? plus : minus;
G4double lambda = 0;
if ( minus > halfTol && minus < distMin )
@@ -620,14 +672,7 @@ G4double G4EllipticalCone::DistanceToIn( const G4ThreeVector& p,
distMin = lambda;
}
}
#ifdef G4SPECSDEBUG
// G4cout << "DToIn: plus,minus, lambda = " << plus
// << ", " << minus << ", " << lambda << G4endl ;
// G4cout << "DToIn: distMin = " << distMin << G4endl ;
#endif
if (distMin < halfTol) distMin=0.;
return distMin ;
}
@@ -774,8 +819,22 @@ G4double G4EllipticalCone::DistanceToOut(const G4ThreeVector& p,
if ( std::fabs(lambda) < distMin )
{
distMin = std::fabs(lambda);
surface = kCurvedSurf;
if( std::fabs(lambda) > 0.5*kCarTolerance)
{
distMin = std::fabs(lambda);
surface = kCurvedSurf;
}
else // Point is On the Surface, Check Normal
{
G4ThreeVector truenorm(p.x()/(xSemiAxis*xSemiAxis),
p.y()/(ySemiAxis*ySemiAxis),
-( p.z() - zheight ));
if( truenorm.dot(v) > 0 )
{
distMin = 0.0;
surface = kCurvedSurf;
}
}
}
}
@@ -801,16 +860,16 @@ G4double G4EllipticalCone::DistanceToOut(const G4ThreeVector& p,
case kCurvedSurf:
{
G4ThreeVector pexit = p + distMin*v;
G4ThreeVector truenorm(pexit.x()/(xSemiAxis*xSemiAxis),
pexit.y()/(ySemiAxis*ySemiAxis),
pexit.z() - zheight );
G4ThreeVector truenorm( pexit.x()/(xSemiAxis*xSemiAxis),
pexit.y()/(ySemiAxis*ySemiAxis),
-( pexit.z() - zheight ) );
truenorm /= truenorm.mag();
*n= truenorm;
}
break;
default:
G4cout.precision(16);
default: // Should never reach this case ...
G4int oldprc = G4cout.precision(16);
G4cout << G4endl;
DumpInfo();
G4cout << "Position:" << G4endl << G4endl;
@@ -823,6 +882,7 @@ G4double G4EllipticalCone::DistanceToOut(const G4ThreeVector& p,
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
G4cout << "Proposed distance :" << G4endl << G4endl;
G4cout << "distMin = " << distMin/mm << " mm" << G4endl << G4endl;
G4cout.precision(oldprc);
G4Exception("G4EllipticalCone::DistanceToOut(p,v,..)",
"Notification", JustWarning,
"Undefined side for valid surface normal to solid.");
@@ -831,6 +891,8 @@ G4double G4EllipticalCone::DistanceToOut(const G4ThreeVector& p,
}
}
if (distMin<0.5*kCarTolerance) { distMin=0; }
return distMin;
}
@@ -853,6 +915,7 @@ G4double G4EllipticalCone::DistanceToOut(const G4ThreeVector& p) const
G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl ;
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl ;
G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl ;
G4cout.precision(6) ;
G4Exception("G4Ellipsoid::DistanceToOut(p)", "Notification", JustWarning,
"Point p is outside !?" );
}
@@ -891,6 +954,15 @@ G4GeometryType G4EllipticalCone::GetEntityType() const
return G4String("G4EllipticalCone");
}
//////////////////////////////////////////////////////////////////////////
//
// Make a clone of the object
//
G4VSolid* G4EllipticalCone::Clone() const
{
return new G4EllipticalCone(*this);
}
//////////////////////////////////////////////////////////////////////////
//
// Stream object contents to an output stream
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4EllipticalTube.cc,v 1.27 2006/10/20 13:45:21 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4EllipticalTube.cc,v 1.33 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -75,7 +75,8 @@ G4EllipticalTube::G4EllipticalTube( const G4String &name,
// for usage restricted to object persistency.
//
G4EllipticalTube::G4EllipticalTube( __void__& a )
: G4VSolid(a), fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
: G4VSolid(a), dx(0.), dy(0.), dz(0.),
fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
{
}
@@ -89,6 +90,40 @@ G4EllipticalTube::~G4EllipticalTube()
}
//
// Copy constructor
//
G4EllipticalTube::G4EllipticalTube(const G4EllipticalTube& rhs)
: G4VSolid(rhs), dx(rhs.dx), dy(rhs.dy), dz(rhs.dz),
fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
fpPolyhedron(0)
{
}
//
// Assignment operator
//
G4EllipticalTube& G4EllipticalTube::operator = (const G4EllipticalTube& rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4VSolid::operator=(rhs);
// Copy data
//
dx = rhs.dx; dy = rhs.dy; dz = rhs.dz;
fCubicVolume = rhs.fCubicVolume; fSurfaceArea = rhs.fSurfaceArea;
fpPolyhedron = 0;
return *this;
}
//
// CalculateExtent
//
@@ -250,7 +285,52 @@ EInside G4EllipticalTube::Inside( const G4ThreeVector& p ) const
G4ThreeVector G4EllipticalTube::SurfaceNormal( const G4ThreeVector& p ) const
{
//
// Which of the three surfaces are we closest to (approximately)?
// SurfaceNormal for the point On the Surface, sum the normals on the Corners
//
static const G4double halfTol = 0.5*kCarTolerance;
G4int noSurfaces=0;
G4ThreeVector norm, sumnorm(0.,0.,0.);
G4double distZ = std::fabs(std::fabs(p.z()) - dz);
G4double distR1 = CheckXY( p.x(), p.y(),+ halfTol );
G4double distR2 = CheckXY( p.x(), p.y(),- halfTol );
if ( (distZ < halfTol ) && ( distR1 <= 1 ) )
{
noSurfaces++;
sumnorm=G4ThreeVector( 0.0, 0.0, p.z() < 0 ? -1.0 : 1.0 );
}
if( (distR1 <= 1 ) && ( distR2 >= 1 ) )
{
noSurfaces++;
norm= G4ThreeVector( p.x()*dy*dy, p.y()*dx*dx, 0.0 ).unit();
sumnorm+=norm;
}
if ( noSurfaces == 0 )
{
#ifdef G4SPECSDEBUG
G4Exception("G4EllipticalTube::SurfaceNormal(p)", "Notification",
JustWarning, "Point p is not on surface !?" );
#endif
norm = ApproxSurfaceNormal(p);
}
else if ( noSurfaces == 1 ) { norm = sumnorm; }
else { norm = sumnorm.unit(); }
return norm;
}
//
// ApproxSurfaceNormal
//
G4ThreeVector
G4EllipticalTube::ApproxSurfaceNormal( const G4ThreeVector& p ) const
{
//
// Which of the three surfaces are we closest to (approximatively)?
//
G4double distZ = std::fabs(p.z()) - dz;
@@ -260,8 +340,10 @@ G4ThreeVector G4EllipticalTube::SurfaceNormal( const G4ThreeVector& p ) const
//
// Closer to z?
//
if (distZ*distZ < distR2)
if (distZ*distZ < distR2)
{
return G4ThreeVector( 0.0, 0.0, p.z() < 0 ? -1.0 : 1.0 );
}
//
// Closer to x/y
@@ -515,10 +597,10 @@ G4double G4EllipticalTube::DistanceToOut( const G4ThreeVector& p,
//
// Our normal is always valid
//
if (calcNorm) *validNorm = true;
if (calcNorm) { *validNorm = true; }
G4double sBest = kInfinity;
const G4ThreeVector *nBest=0;
G4ThreeVector nBest(0,0,0);
//
// Might we intersect the -dz surface?
@@ -534,12 +616,15 @@ G4double G4EllipticalTube::DistanceToOut( const G4ThreeVector& p,
//
// Are we on the surface? If so, return zero
//
if (p.z() < -dz+halfTol) {
if (calcNorm) *norm = normHere;
if (p.z() < -dz+halfTol)
{
if (calcNorm) { *norm = normHere; }
return 0;
}
else
nBest = &normHere;
{
nBest = normHere;
}
}
//
@@ -556,15 +641,16 @@ G4double G4EllipticalTube::DistanceToOut( const G4ThreeVector& p,
//
// Are we on the surface? If so, return zero
//
if (p.z() > +dz-halfTol) {
if (calcNorm) *norm = normHere;
if (p.z() > +dz-halfTol)
{
if (calcNorm) { *norm = normHere; }
return 0;
}
//
// Best so far?
//
if (s < sBest) { sBest = s; nBest = &normHere; }
if (s < sBest) { sBest = s; nBest = normHere; }
}
//
@@ -590,15 +676,16 @@ G4double G4EllipticalTube::DistanceToOut( const G4ThreeVector& p,
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
G4cout << "Proposed distance :" << G4endl << G4endl;
G4cout << "snxt = " << sBest/mm << " mm" << G4endl << G4endl;
G4cout.precision(6) ;
G4Exception( "G4EllipticalTube::DistanceToOut(p,v,...)",
"Notification", JustWarning, "Point p is outside !?" );
}
if (calcNorm) *norm = *nBest;
if (calcNorm) { *norm = nBest; }
return sBest;
}
else if (s[n-1] > sBest)
{
if (calcNorm) *norm = *nBest;
if (calcNorm) { *norm = nBest; }
return sBest;
}
sBest = s[n-1];
@@ -765,6 +852,15 @@ G4GeometryType G4EllipticalTube::GetEntityType() const
}
//
// Make a clone of the object
//
G4VSolid* G4EllipticalTube::Clone() const
{
return new G4EllipticalTube(*this);
}
//
// GetCubicVolume
//
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4EnclosingCylinder.cc,v 1.10 2007/05/11 13:54:29 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4EnclosingCylinder.cc,v 1.11 2010/07/12 15:25:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -93,6 +93,9 @@ G4EnclosingCylinder::G4EnclosingCylinder( const G4ReduciblePolygon *rz,
// for usage restricted to object persistency.
//
G4EnclosingCylinder::G4EnclosingCylinder( __void__& )
: radius(0.), zLo(0.), zHi(0.), phiIsOpen(0.), startPhi(0.), totalPhi(0.),
rx1(0.), ry1(0.), dx1(0.), dy1(0.), rx2(0.), ry2(0.), dx2(0.), dy2(0.),
concave(false)
{
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4ExtrudedSolid.cc,v 1.18 2008/10/30 11:47:45 ivana Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4ExtrudedSolid.cc,v 1.22 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -39,6 +39,7 @@
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include "G4ExtrudedSolid.hh"
#include "G4TriangularFacet.hh"
@@ -93,11 +94,32 @@ G4ExtrudedSolid::G4ExtrudedSolid( const G4String& pName,
FatalException,
"Z-sections with the same z position are not supported.");
}
}
}
// Check if polygon vertices are defined clockwise
// (the area is positive if polygon vertices are defined anti-clockwise)
//
G4double area = 0.;
for ( G4int i=0; i<fNv; ++i ) {
G4int j = i+1;
if ( j == fNv ) j = 0;
area += 0.5 * ( polygon[i].x()*polygon[j].y() - polygon[j].x()*polygon[i].y());
}
// Copy polygon
//
for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[i]); }
if ( area < 0. ) {
// Polygon vertices are defined clockwise, we just copy the polygon
for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[i]); }
}
else {
// Polygon vertices are defined anti-clockwise, we revert them
//G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", errorDescription,
// JustWarning,
// "Polygon vertices defined anti-clockwise, reverting polygon");
for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[fNv-i-1]); }
}
// Copy z-sections
//
@@ -147,9 +169,33 @@ G4ExtrudedSolid::G4ExtrudedSolid( const G4String& pName,
FatalException, "Number of polygon vertices < 3");
}
// Check if polygon vertices are defined clockwise
// (the area is positive if polygon vertices are defined anti-clockwise)
G4double area = 0.;
for ( G4int i=0; i<fNv; ++i )
{
G4int j = i+1;
if ( j == fNv ) { j = 0; }
area += 0.5 * ( polygon[i].x()*polygon[j].y()
- polygon[j].x()*polygon[i].y());
}
// Copy polygon
//
for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[i]); }
if ( area < 0. )
{
// Polygon vertices are defined clockwise, we just copy the polygon
for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[i]); }
}
else
{
// Polygon vertices are defined anti-clockwise, we revert them
//G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", errorDescription,
// JustWarning,
// "Polygon vertices defined anti-clockwise, reverting polygon");
for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[fNv-i-1]); }
}
// Copy z-sections
//
@@ -170,12 +216,48 @@ G4ExtrudedSolid::G4ExtrudedSolid( const G4String& pName,
//_____________________________________________________________________________
G4ExtrudedSolid::G4ExtrudedSolid( __void__& a )
: G4TessellatedSolid(a)
: G4TessellatedSolid(a), fNv(0), fNz(0), fPolygon(), fZSections(),
fTriangles(), fIsConvex(false), fGeometryType("G4ExtrudedSolid")
{
// Fake default constructor - sets only member data and allocates memory
// for usage restricted to object persistency.
}
//_____________________________________________________________________________
G4ExtrudedSolid::G4ExtrudedSolid(const G4ExtrudedSolid& rhs)
: G4TessellatedSolid(rhs), fNv(rhs.fNv), fNz(rhs.fNz),
fPolygon(rhs.fPolygon), fZSections(rhs.fZSections),
fTriangles(rhs.fTriangles), fIsConvex(rhs.fIsConvex),
fGeometryType(rhs.fGeometryType), fKScales(rhs.fKScales),
fScale0s(rhs.fScale0s), fKOffsets(rhs.fKOffsets), fOffset0s(rhs.fOffset0s)
{
}
//_____________________________________________________________________________
G4ExtrudedSolid& G4ExtrudedSolid::operator = (const G4ExtrudedSolid& rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4TessellatedSolid::operator=(rhs);
// Copy data
//
fNv = rhs.fNv; fNz = rhs.fNz;
fPolygon = rhs.fPolygon; fZSections = rhs.fZSections;
fTriangles = rhs.fTriangles; fIsConvex = rhs.fIsConvex;
fGeometryType = rhs.fGeometryType; fKScales = rhs.fKScales;
fScale0s = rhs.fScale0s; fKOffsets = rhs.fKOffsets;
fOffset0s = rhs.fOffset0s;
return *this;
}
//_____________________________________________________________________________
@@ -452,8 +534,10 @@ G4bool G4ExtrudedSolid::AddGeneralPolygonFacets()
// skip concave vertices
//
G4double angle = GetAngle(c2->first, c3->first, c1->first);
//G4cout << "angle " << angle << G4endl;
if ( angle > pi )
G4int counter = 0;
while ( angle > pi )
{
// G4cout << "Skipping concave vertex " << c2->second << G4endl;
@@ -466,8 +550,18 @@ G4bool G4ExtrudedSolid::AddGeneralPolygonFacets()
// G4cout << "Looking at triangle : "
// << c1->second << " " << c2->second
// << " " << c3->second << G4endl;
// << " " << c3->second << G4endl;
angle = GetAngle(c2->first, c3->first, c1->first);
//G4cout << "angle " << angle << G4endl;
counter++;
if ( counter > fNv) {
G4Exception("G4ExtrudedSolid::AddGeneralPolygonFacets", "InvalidSetup" ,
FatalException, "Triangularisation has failed.");
break;
}
}
G4bool good = true;
@@ -634,6 +728,13 @@ G4GeometryType G4ExtrudedSolid::GetEntityType () const
//_____________________________________________________________________________
G4VSolid* G4ExtrudedSolid::Clone() const
{
return new G4ExtrudedSolid(*this);
}
//_____________________________________________________________________________
EInside G4ExtrudedSolid::Inside (const G4ThreeVector &p) const
{
// Override the base class function as it fails in case of concave polygon.
@@ -733,7 +834,6 @@ G4double G4ExtrudedSolid::DistanceToOut (const G4ThreeVector &p) const
return G4TessellatedSolid::DistanceToOut(p);
}
//_____________________________________________________________________________
std::ostream& G4ExtrudedSolid::StreamInfo(std::ostream &os) const
@@ -750,7 +850,8 @@ std::ostream& G4ExtrudedSolid::StreamInfo(std::ostream &os) const
for ( G4int i=0; i<fNv; ++i )
{
os << " vx = " << fPolygon[i].x()/mm << " mm"
os << std::setw(5) << "#" << i
<< " vx = " << fPolygon[i].x()/mm << " mm"
<< " vy = " << fPolygon[i].y()/mm << " mm" << G4endl;
}
@@ -763,5 +864,20 @@ std::ostream& G4ExtrudedSolid::StreamInfo(std::ostream &os) const
<< " scale= " << fZSections[iz].fScale << G4endl;
}
/*
// Triangles (for debogging)
os << G4endl;
os << " Triangles:" << G4endl;
os << " Triangle # vertex1 vertex2 vertex3" << G4endl;
G4int counter = 0;
std::vector< std::vector<G4int> >::const_iterator it;
for ( it = fTriangles.begin(); it != fTriangles.end(); it++ ) {
std::vector<G4int> triangle = *it;
os << std::setw(10) << counter++
<< std::setw(10) << triangle[0] << std::setw(10) << triangle[1] << std::setw(10) << triangle[2]
<< G4endl;
}
*/
return os;
}
File diff suppressed because it is too large Load Diff
+80 -31
View File
@@ -24,9 +24,9 @@
// ********************************************************************
//
//
// $Id: G4Hype.cc,v 1.27 2008/04/14 08:49:28 gcosmo Exp $
// $Id: G4Hype.cc,v 1.31 2010/10/20 08:54:18 gcosmo Exp $
// $Original: G4Hype.cc,v 1.0 1998/06/09 16:57:50 safai Exp $
// GEANT4 tag $Name: geant4-09-02 $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -80,11 +80,7 @@ G4Hype::G4Hype(const G4String& pName,
{
// Check z-len
//
if (newHalfLenZ>0)
{
halfLenZ=newHalfLenZ;
}
else
if (newHalfLenZ<=0)
{
G4cerr << "ERROR - G4Hype::G4Hype(): " << GetName() << G4endl
<< " Invalid Z half-length: "
@@ -92,32 +88,11 @@ G4Hype::G4Hype(const G4String& pName,
G4Exception("G4Hype::G4Hype()", "InvalidSetup", FatalException,
"Invalid Z half-length.");
}
halfLenZ=newHalfLenZ;
// Check radii
//
if (newInnerRadius>=0 && newOuterRadius>=0)
{
if (newInnerRadius < newOuterRadius)
{
innerRadius=newInnerRadius;
outerRadius=newOuterRadius;
}
else
{ // swapping radii (:-)
// innerRadius=newOuterRadius;
// outerRadius=newInnerRadius;
// DCW: swapping is fine, but what about the stereo angles???
G4cerr << "ERROR - G4Hype::G4Hype(): " << GetName() << G4endl
<< " Invalid radii ! Inner radius: "
<< newInnerRadius/mm << " mm" << G4endl
<< " Outer radius: "
<< newOuterRadius/mm << " mm" << G4endl;
G4Exception("G4Hype::G4Hype()", "InvalidSetup", FatalException,
"Error: outer > inner radius.");
}
}
else
if (newInnerRadius<0 || newOuterRadius<0)
{
G4cerr << "ERROR - G4Hype::G4Hype(): " << GetName() << G4endl
<< " Invalid radii ! Inner radius: "
@@ -127,6 +102,19 @@ G4Hype::G4Hype(const G4String& pName,
G4Exception("G4Hype::G4Hype()", "InvalidSetup", FatalException,
"Invalid radii.");
}
if (newInnerRadius >= newOuterRadius)
{
G4cerr << "ERROR - G4Hype::G4Hype(): " << GetName() << G4endl
<< " Invalid radii ! Inner radius: "
<< newInnerRadius/mm << " mm" << G4endl
<< " Outer radius: "
<< newOuterRadius/mm << " mm" << G4endl;
G4Exception("G4Hype::G4Hype()", "InvalidSetup", FatalException,
"Error: outer > inner radius.");
}
innerRadius=newInnerRadius;
outerRadius=newOuterRadius;
innerRadius2=innerRadius*innerRadius;
outerRadius2=outerRadius*outerRadius;
@@ -141,7 +129,11 @@ G4Hype::G4Hype(const G4String& pName,
// for usage restricted to object persistency.
//
G4Hype::G4Hype( __void__& a )
: G4VSolid(a), fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
: G4VSolid(a), innerRadius(0.), outerRadius(0.), halfLenZ(0.), innerStereo(0.),
outerStereo(0.), tanInnerStereo(0.), tanOuterStereo(0.), tanInnerStereo2(0.),
tanOuterStereo2(0.), innerRadius2(0.), outerRadius2(0.), endInnerRadius2(0.),
endOuterRadius2(0.), endInnerRadius(0.), endOuterRadius(0.),
fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
{
}
@@ -155,6 +147,54 @@ G4Hype::~G4Hype()
}
//
// Copy constructor
//
G4Hype::G4Hype(const G4Hype& rhs)
: G4VSolid(rhs), innerRadius(rhs.innerRadius),
outerRadius(rhs.outerRadius), halfLenZ(rhs.halfLenZ),
innerStereo(rhs.innerStereo), outerStereo(rhs.outerStereo),
tanInnerStereo(rhs.tanInnerStereo), tanOuterStereo(rhs.tanOuterStereo),
tanInnerStereo2(rhs.tanInnerStereo2), tanOuterStereo2(rhs.tanOuterStereo2),
innerRadius2(rhs.innerRadius2), outerRadius2(rhs.outerRadius2),
endInnerRadius2(rhs.endInnerRadius2), endOuterRadius2(rhs.endOuterRadius2),
endInnerRadius(rhs.endInnerRadius), endOuterRadius(rhs.endOuterRadius),
fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
fpPolyhedron(0)
{
}
//
// Assignment operator
//
G4Hype& G4Hype::operator = (const G4Hype& rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4VSolid::operator=(rhs);
// Copy data
//
innerRadius = rhs.innerRadius; outerRadius = rhs.outerRadius;
halfLenZ = rhs.halfLenZ;
innerStereo = rhs.innerStereo; outerStereo = rhs.outerStereo;
tanInnerStereo = rhs.tanInnerStereo; tanOuterStereo = rhs.tanOuterStereo;
tanInnerStereo2 = rhs.tanInnerStereo2; tanOuterStereo2 = rhs.tanOuterStereo2;
innerRadius2 = rhs.innerRadius2; outerRadius2 = rhs.outerRadius2;
endInnerRadius2 = rhs.endInnerRadius2; endOuterRadius2 = rhs.endOuterRadius2;
endInnerRadius = rhs.endInnerRadius; endOuterRadius = rhs.endOuterRadius;
fCubicVolume = rhs.fCubicVolume; fSurfaceArea = rhs.fSurfaceArea;
fpPolyhedron = 0;
return *this;
}
//
// Dispatch to parameterisation for replication mechanism dimension
// computation & modification.
@@ -1324,6 +1364,15 @@ G4GeometryType G4Hype::GetEntityType() const
}
//
// Clone
//
G4VSolid* G4Hype::Clone() const
{
return new G4Hype(*this);
}
//
// GetCubicVolume
//
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4IntersectingCone.cc,v 1.12 2008/04/28 08:59:47 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4IntersectingCone.cc,v 1.13 2010/07/12 15:25:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -47,10 +47,9 @@
G4IntersectingCone::G4IntersectingCone( const G4double r[2],
const G4double z[2] )
{
static const G4double halfCarTolerance
= 0.5 * G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
half_kCarTolerance = 0.5 * G4GeometryTolerance::GetInstance()
->GetSurfaceTolerance();
//
// What type of cone are we?
//
@@ -71,20 +70,20 @@ G4IntersectingCone::G4IntersectingCone( const G4double r[2],
//
if (r[0] < r[1])
{
rLo = r[0]-half_kCarTolerance; rHi = r[1]+half_kCarTolerance;
rLo = r[0]-halfCarTolerance; rHi = r[1]+halfCarTolerance;
}
else
{
rLo = r[1]-half_kCarTolerance; rHi = r[0]+half_kCarTolerance;
rLo = r[1]-halfCarTolerance; rHi = r[0]+halfCarTolerance;
}
if (z[0] < z[1])
{
zLo = z[0]-half_kCarTolerance; zHi = z[1]+half_kCarTolerance;
zLo = z[0]-halfCarTolerance; zHi = z[1]+halfCarTolerance;
}
else
{
zLo = z[1]-half_kCarTolerance; zHi = z[0]+half_kCarTolerance;
zLo = z[1]-halfCarTolerance; zHi = z[0]+halfCarTolerance;
}
}
@@ -94,6 +93,7 @@ G4IntersectingCone::G4IntersectingCone( const G4double r[2],
// for usage restricted to object persistency.
//
G4IntersectingCone::G4IntersectingCone( __void__& )
: zLo(0.), zHi(0.), rLo(0.), rHi(0.), type1(false), A(0.), B(0.)
{
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4Paraboloid.cc,v 1.9 2009/02/27 15:10:46 tnikitin Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4Paraboloid.cc,v 1.14 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// class G4Paraboloid
//
@@ -58,19 +58,13 @@ using namespace CLHEP;
// constructor - check parameters
G4Paraboloid::G4Paraboloid(const G4String& pName,
G4double pDz,
G4double pR1,
G4double pR2)
: G4VSolid(pName),fpPolyhedron(0), fCubicVolume(0.)
G4double pDz,
G4double pR1,
G4double pR2)
: G4VSolid(pName), fpPolyhedron(0), fSurfaceArea(0.), fCubicVolume(0.)
{
if(pDz > 0. && pR2 > pR1 && pR1 >= 0.)
{
r1 = pR1;
r2 = pR2;
dz = pDz;
}
else
if( (pDz <= 0.) || (pR2 <= pR1) || (pR1 < 0.) )
{
G4cerr << "Error - G4Paraboloid::G4Paraboloid(): " << GetName() << G4endl
<< "Z half-length must be larger than zero or R1>=R2 " << G4endl;
@@ -79,6 +73,10 @@ G4Paraboloid::G4Paraboloid(const G4String& pName,
"Invalid dimensions. Negative Input Values or R1>=R2.");
}
r1 = pR1;
r2 = pR2;
dz = pDz;
// r1^2 = k1 * (-dz) + k2
// r2^2 = k1 * ( dz) + k2
// => r1^2 + r2^2 = k2 + k2 => k2 = (r2^2 + r1^2) / 2
@@ -86,8 +84,6 @@ G4Paraboloid::G4Paraboloid(const G4String& pName,
k1 = (r2 * r2 - r1 * r1) / 2 / dz;
k2 = (r2 * r2 + r1 * r1) / 2;
fSurfaceArea = 0.;
}
///////////////////////////////////////////////////////////////////////////////
@@ -96,9 +92,9 @@ G4Paraboloid::G4Paraboloid(const G4String& pName,
// for usage restricted to object persistency.
//
G4Paraboloid::G4Paraboloid( __void__& a )
: G4VSolid(a), fpPolyhedron(0), fCubicVolume(0.)
: G4VSolid(a), fpPolyhedron(0), fSurfaceArea(0.), fCubicVolume(0.),
dz(0.), r1(0.), r2(0.), k1(0.), k2(0.)
{
fSurfaceArea = 0.;
}
///////////////////////////////////////////////////////////////////////////////
@@ -109,6 +105,41 @@ G4Paraboloid::~G4Paraboloid()
{
}
///////////////////////////////////////////////////////////////////////////////
//
// Copy constructor
G4Paraboloid::G4Paraboloid(const G4Paraboloid& rhs)
: G4VSolid(rhs), fpPolyhedron(0),
fSurfaceArea(rhs.fSurfaceArea), fCubicVolume(rhs.fCubicVolume),
dz(rhs.dz), r1(rhs.r1), r2(rhs.r2), k1(rhs.k1), k2(rhs.k2)
{
}
///////////////////////////////////////////////////////////////////////////////
//
// Assignment operator
G4Paraboloid& G4Paraboloid::operator = (const G4Paraboloid& rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4VSolid::operator=(rhs);
// Copy data
//
fpPolyhedron = 0;
fSurfaceArea = rhs.fSurfaceArea; fCubicVolume = rhs.fCubicVolume;
dz = rhs.dz; r1 = rhs.r1; r2 = rhs.r2; k1 = rhs.k1; k2 = rhs.k2;
return *this;
}
/////////////////////////////////////////////////////////////////////////
//
// Dispatch to parameterisation for replication mechanism dimension
@@ -898,13 +929,14 @@ G4double G4Paraboloid::DistanceToOut(const G4ThreeVector& p) const
#ifdef G4SPECSDEBUG
if( Inside(p) == kOutside )
{
G4cout.precision(16) ;
G4int oldprc = G4cout.precision(16) ;
G4cout << G4endl ;
DumpInfo();
G4cout << "Position:" << G4endl << G4endl ;
G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl ;
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl ;
G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl ;
G4cout.precision(oldprc) ;
G4Exception("G4Paraboloid::DistanceToOut(p)", "Notification", JustWarning,
"Point p is outside !?" );
}
@@ -933,6 +965,15 @@ G4GeometryType G4Paraboloid::GetEntityType() const
return G4String("G4Paraboloid");
}
//////////////////////////////////////////////////////////////////////////
//
// Make a clone of the object
G4VSolid* G4Paraboloid::Clone() const
{
return new G4Paraboloid(*this);
}
//////////////////////////////////////////////////////////////////////////
//
// Stream object contents to an output stream
@@ -1001,16 +1042,17 @@ G4Paraboloid::CreateRotatedVertices(const G4AffineTransform& pTransform,
// Phi cross sections
//
noPhiCrossSections = G4int(twopi/kMeshAngleDefault)+1;
if (noPhiCrossSections<kMinMeshSections)
noPhiCrossSections = G4int(twopi/kMeshAngleDefault)+1; // =9!
/*
if (noPhiCrossSections<kMinMeshSections) // <3
{
noPhiCrossSections=kMinMeshSections;
}
else if (noPhiCrossSections>kMaxMeshSections)
else if (noPhiCrossSections>kMaxMeshSections) // >37
{
noPhiCrossSections=kMaxMeshSections;
}
*/
meshAnglePhi=twopi/(noPhiCrossSections-1);
sAnglePhi = -meshAnglePhi*0.5*0;
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PolyPhiFace.cc,v 1.15 2008/05/15 11:41:59 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PolyPhiFace.cc,v 1.16 2010/07/12 15:25:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -63,9 +63,9 @@ G4PolyPhiFace::G4PolyPhiFace( const G4ReduciblePolygon *rz,
G4double phi,
G4double deltaPhi,
G4double phiOther )
: fSurfaceArea(0.), triangles(0)
{
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
fSurfaceArea = 0.;
numEdges = rz->NumVertices();
@@ -290,7 +290,8 @@ void G4PolyPhiFace::Diagnose( G4VSolid *owner )
// for usage restricted to object persistency.
//
G4PolyPhiFace::G4PolyPhiFace( __void__&)
: edges(0), corners(0)
: numEdges(0), edges(0), corners(0), rMin(0.), rMax(0.), zMin(0.), zMax(0.),
allBehind(false), kCarTolerance(0.), fSurfaceArea(0.), triangles(0)
{
}
@@ -320,7 +321,7 @@ G4PolyPhiFace::G4PolyPhiFace( const G4PolyPhiFace &source )
//
G4PolyPhiFace& G4PolyPhiFace::operator=( const G4PolyPhiFace &source )
{
if (this == &source) return *this;
if (this == &source) { return *this; }
delete [] edges;
delete [] corners;
@@ -348,6 +349,7 @@ void G4PolyPhiFace::CopyStuff( const G4PolyPhiFace &source )
zMin = source.zMin;
zMax = source.zMax;
allBehind = source.allBehind;
triangles = 0;
kCarTolerance = source.kCarTolerance;
fSurfaceArea = source.fSurfaceArea;
@@ -1300,4 +1302,5 @@ void G4PolyPhiFace::Triangulate()
} while( i<numEdges-2 );
delete [] tri_help;
tri_help = 0;
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4Polycone.cc,v 1.43 2008/05/15 13:45:15 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4Polycone.cc,v 1.47 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -313,7 +313,8 @@ void G4Polycone::Create( G4double phiStart,
// for usage restricted to object persistency.
//
G4Polycone::G4Polycone( __void__& a )
: G4VCSGfaceted(a), genericPcon(false), corners(0),
: G4VCSGfaceted(a), startPhi(0.), endPhi(0.), phiIsOpen(false),
genericPcon(false), numCorner(0), corners(0),
original_parameters(0), enclosingCylinder(0)
{
}
@@ -325,9 +326,8 @@ G4Polycone::G4Polycone( __void__& a )
G4Polycone::~G4Polycone()
{
delete [] corners;
if (original_parameters) delete original_parameters;
if (enclosingCylinder) delete enclosingCylinder;
delete original_parameters;
delete enclosingCylinder;
}
@@ -509,6 +509,14 @@ G4GeometryType G4Polycone::GetEntityType() const
return G4String("G4Polycone");
}
//
// Make a clone of the object
//
G4VSolid* G4Polycone::Clone() const
{
return new G4Polycone(*this);
}
//
// Stream object contents to an output stream
//
@@ -733,7 +741,7 @@ G4ThreeVector G4Polycone::GetPointOnRing(G4double fRMin1, G4double fRMax1,
else
{
rRand1 = RandFlat::shoot(fRMin1,fRMin2);
A1=std::abs(fRMin2*fRMin2-fRMin1*fRMin1);
A1=std::fabs(fRMin2*fRMin2-fRMin1*fRMin1);
}
if(fRMax1==fRMax2)
{
@@ -742,7 +750,7 @@ G4ThreeVector G4Polycone::GetPointOnRing(G4double fRMin1, G4double fRMax1,
else
{
rRand2 = RandFlat::shoot(fRMax1,fRMax2);
Atot = A1+std::abs(fRMax2*fRMax2-fRMax1*fRMax1);
Atot = A1+std::fabs(fRMax2*fRMax2-fRMax1*fRMax1);
}
rCh = RandFlat::shoot(0.,Atot);
@@ -1150,8 +1158,8 @@ G4Polyhedron* G4Polycone::CreatePolyhedron() const
}
G4Polyhedron* polyhedron = new G4Polyhedron;
G4int problem = polyhedron->createPolyhedron(nNodes, nFaces, xyz, faces_vec);
delete faces_vec;
delete xyz;
delete [] faces_vec;
delete [] xyz;
if (problem)
{
std::ostringstream oss;
@@ -1183,7 +1191,8 @@ G4NURBS *G4Polycone::CreateNURBS() const
//
G4PolyconeHistorical::G4PolyconeHistorical()
: Z_values(0), Rmin(0), Rmax(0)
: Start_angle(0.), Opening_angle(0.), Num_z_planes(0),
Z_values(0), Rmin(0), Rmax(0)
{
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PolyconeSide.cc,v 1.22 2009/11/11 12:23:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4PolyconeSide.cc,v 1.25 2010/07/12 15:25:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -66,6 +66,8 @@ G4PolyconeSide::G4PolyconeSide( const G4PolyconeSideRZ *prevRZ,
{
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
fSurfaceArea = 0.0;
fPhi.first = G4ThreeVector(0,0,0);
fPhi.second= 0.0;
//
// Record values
@@ -156,8 +158,15 @@ G4PolyconeSide::G4PolyconeSide( const G4PolyconeSideRZ *prevRZ,
// for usage restricted to object persistency.
//
G4PolyconeSide::G4PolyconeSide( __void__& )
: phiIsOpen(false), cone(0), ncorners(0), corners(0)
: startPhi(0.), deltaPhi(0.), phiIsOpen(false), allBehind(false),
cone(0), rNorm(0.), zNorm(0.), rS(0.), zS(0.), length(0.),
prevRS(0.), prevZS(0.), nextRS(0.), nextZS(0.), ncorners(0), corners(0),
kCarTolerance(0.), fSurfaceArea(0.)
{
r[0] = r[1] = 0.;
z[0] = z[1] = 0.;
rNormEdge[0]= rNormEdge[1] = 0.;
zNormEdge[0]= zNormEdge[1] = 0.;
}
@@ -167,7 +176,7 @@ G4PolyconeSide::G4PolyconeSide( __void__& )
G4PolyconeSide::~G4PolyconeSide()
{
delete cone;
if (phiIsOpen) delete [] corners;
if (phiIsOpen) { delete [] corners; }
}
@@ -175,7 +184,7 @@ G4PolyconeSide::~G4PolyconeSide()
// Copy constructor
//
G4PolyconeSide::G4PolyconeSide( const G4PolyconeSide &source )
: G4VCSGface()
: G4VCSGface(), ncorners(0), corners(0)
{
CopyStuff( source );
}
@@ -186,10 +195,10 @@ G4PolyconeSide::G4PolyconeSide( const G4PolyconeSide &source )
//
G4PolyconeSide& G4PolyconeSide::operator=( const G4PolyconeSide &source )
{
if (this == &source) return *this;
if (this == &source) { return *this; }
delete cone;
if (phiIsOpen) delete [] corners;
if (phiIsOpen) { delete [] corners; }
CopyStuff( source );
@@ -491,7 +500,7 @@ G4double G4PolyconeSide::Extent( const G4ThreeVector axis )
//
if (phiIsOpen)
{
G4double phi = axis.phi();
G4double phi = GetPhi(axis);
while( phi < startPhi ) phi += twopi;
if (phi > deltaPhi+startPhi)
@@ -852,6 +861,29 @@ void G4PolyconeSide::CalculateExtent( const EAxis axis,
return;
}
//
// GetPhi
//
// Calculate Phi for a given 3-vector (point), if not already cached for the
// same point, in the attempt to avoid consecutive computation of the same
// quantity
//
G4double G4PolyconeSide::GetPhi( const G4ThreeVector& p )
{
G4double val=0.;
if (fPhi.first != p)
{
val = p.phi();
fPhi.first = p;
fPhi.second = val;
}
else
{
val = fPhi.second;
}
return val;
}
//
// DistanceAway
@@ -921,7 +953,7 @@ G4double G4PolyconeSide::DistanceAway( const G4ThreeVector &p,
//
// Finally, check phi
//
G4double phi = p.phi();
G4double phi = GetPhi(p);
while( phi < startPhi ) phi += twopi;
if (phi > startPhi+deltaPhi)
@@ -977,7 +1009,7 @@ G4bool G4PolyconeSide::PointOnCone( const G4ThreeVector &hit,
// to use the standard method consistent with
// PolyPhiFace. See PolyPhiFace::InsideEdgesExact
//
G4double phi = hit.phi();
G4double phi = GetPhi(hit);
while( phi < startPhi-phiTolerant ) phi += twopi;
if (phi > startPhi+deltaPhi+phiTolerant) return false;
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4Polyhedra.cc,v 1.42 2008/05/15 13:45:15 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4Polyhedra.cc,v 1.45 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -365,7 +365,8 @@ void G4Polyhedra::Create( G4double phiStart,
// for usage restricted to object persistency.
//
G4Polyhedra::G4Polyhedra( __void__& a )
: G4VCSGfaceted(a), genericPgon(false), corners(0),
: G4VCSGfaceted(a), numSide(0), startPhi(0.), endPhi(0.),
phiIsOpen(false), genericPgon(false), numCorner(0), corners(0),
original_parameters(0), enclosingCylinder(0)
{
}
@@ -568,6 +569,15 @@ G4GeometryType G4Polyhedra::GetEntityType() const
}
//
// Make a clone of the object
//
G4VSolid* G4Polyhedra::Clone() const
{
return new G4Polyhedra(*this);
}
//
// Stream object contents to an output stream
//
@@ -1125,8 +1135,8 @@ G4Polyhedron* G4Polyhedra::CreatePolyhedron() const
}
G4Polyhedron* polyhedron = new G4Polyhedron;
G4int problem = polyhedron->createPolyhedron(nNodes, nFaces, xyz, faces_vec);
delete faces_vec;
delete xyz;
delete [] faces_vec;
delete [] xyz;
if (problem)
{
std::ostringstream oss;
@@ -1156,7 +1166,8 @@ G4NURBS *G4Polyhedra::CreateNURBS() const
// G4PolyhedraHistorical stuff
//
G4PolyhedraHistorical::G4PolyhedraHistorical()
: Z_values(0), Rmin(0), Rmax(0)
: Start_angle(0.), Opening_angle(0.), numSide(0), Num_z_planes(0),
Z_values(0), Rmin(0), Rmax(0)
{
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PolyhedraSide.cc,v 1.15 2008/05/15 11:41:59 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PolyhedraSide.cc,v 1.18 2010/07/12 15:25:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -63,9 +63,11 @@ G4PolyhedraSide::G4PolyhedraSide( const G4PolyhedraSideRZ *prevRZ,
G4bool thePhiIsOpen,
G4bool isAllBehind )
{
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
fSurfaceArea=0.;
fPhi.first = G4ThreeVector(0,0,0);
fPhi.second= 0.0;
//
// Record values
//
@@ -292,8 +294,13 @@ G4PolyhedraSide::G4PolyhedraSide( const G4PolyhedraSideRZ *prevRZ,
// for usage restricted to object persistency.
//
G4PolyhedraSide::G4PolyhedraSide( __void__&)
: cone(0), vecs(0), edges(0)
: numSide(0), startPhi(0.), deltaPhi(0.), endPhi(0.),
phiIsOpen(false), allBehind(false), cone(0), vecs(0), edges(0),
lenRZ(0.), edgeNorm(0.), kCarTolerance(0.), fSurfaceArea(0.)
{
r[0] = r[1] = 0.;
z[0] = z[1] = 0.;
lenPhi[0] = lenPhi[1] = 0.;
}
@@ -560,7 +567,7 @@ G4double G4PolyhedraSide::Distance( const G4ThreeVector &p, G4bool outgoing )
//
// Try the closest phi segment first
//
G4int iPhi = ClosestPhiSegment( p.phi() );
G4int iPhi = ClosestPhiSegment( GetPhi(p) );
G4ThreeVector pdotc = p - vecs[iPhi].center;
G4double normDist = pdotc.dot(vecs[iPhi].normal);
@@ -593,7 +600,7 @@ EInside G4PolyhedraSide::Inside( const G4ThreeVector &p,
//
// Which phi segment is closest to this point?
//
G4int iPhi = ClosestPhiSegment( p.phi() );
G4int iPhi = ClosestPhiSegment( GetPhi(p) );
G4double norm;
@@ -623,7 +630,7 @@ G4ThreeVector G4PolyhedraSide::Normal( const G4ThreeVector &p,
//
// Which phi segment is closest to this point?
//
G4int iPhi = ClosestPhiSegment( p.phi() );
G4int iPhi = ClosestPhiSegment( GetPhi(p) );
//
// Get distance to this segment
@@ -655,7 +662,7 @@ G4double G4PolyhedraSide::Extent( const G4ThreeVector axis )
//
// Which phi segment, if any, does the axis belong to
//
iPhi = PhiSegment( axis.phi() );
iPhi = PhiSegment( GetPhi(axis) );
if (iPhi < 0)
{
@@ -771,7 +778,7 @@ void G4PolyhedraSide::CalculateExtent( const EAxis axis,
//
G4bool G4PolyhedraSide::IntersectSidePlane( const G4ThreeVector &p,
const G4ThreeVector &v,
const G4PolyhedraSideVec vec,
const G4PolyhedraSideVec& vec,
G4double normSign,
G4double surfTolerance,
G4double &distance,
@@ -969,6 +976,31 @@ G4int G4PolyhedraSide::PhiSegment( G4double phi0 )
}
//
// GetPhi
//
// Calculate Phi for a given 3-vector (point), if not already cached for the
// same point, in the attempt to avoid consecutive computation of the same
// quantity
//
G4double G4PolyhedraSide::GetPhi( const G4ThreeVector& p )
{
G4double val=0.;
if (fPhi.first != p)
{
val = p.phi();
fPhi.first = p;
fPhi.second = val;
}
else
{
val = fPhi.second;
}
return val;
}
//
// DistanceToOneSide
//
@@ -25,8 +25,8 @@
// ********************************************************************
//
//
// $Id: G4QuadrangularFacet.cc,v 1.7 2008/12/18 12:57:34 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4QuadrangularFacet.cc,v 1.9 2010/09/23 10:27:25 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
@@ -59,7 +59,7 @@
G4QuadrangularFacet::G4QuadrangularFacet (const G4ThreeVector Pt0,
const G4ThreeVector vt1, const G4ThreeVector vt2,
const G4ThreeVector vt3, G4FacetVertexType vertexType)
: G4VFacet()
: G4VFacet(), facet1(0), facet2(0)
{
P0 = Pt0;
nVertices = 4;
@@ -136,14 +136,44 @@ G4QuadrangularFacet::G4QuadrangularFacet (const G4ThreeVector Pt0,
//
G4QuadrangularFacet::~G4QuadrangularFacet ()
{
if (facet1 != 0) delete facet1;
if (facet2 != 0) delete facet2;
delete facet1;
delete facet2;
P.clear();
E.clear();
I.clear();
}
///////////////////////////////////////////////////////////////////////////////
//
G4QuadrangularFacet::G4QuadrangularFacet (const G4QuadrangularFacet &rhs)
: G4VFacet(rhs)
{
facet1 = new G4TriangularFacet(*(rhs.facet1));
facet2 = new G4TriangularFacet(*(rhs.facet2));
}
///////////////////////////////////////////////////////////////////////////////
//
const G4QuadrangularFacet &
G4QuadrangularFacet::operator=(G4QuadrangularFacet &rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4VFacet::operator=(rhs);
// Copy data
//
delete facet1; facet1 = new G4TriangularFacet(*(rhs.facet1));
delete facet2; facet2 = new G4TriangularFacet(*(rhs.facet2));
return *this;
}
///////////////////////////////////////////////////////////////////////////////
//
G4VFacet *G4QuadrangularFacet::GetClone ()
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4ReduciblePolygon.cc,v 1.11 2006/06/29 18:48:53 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4ReduciblePolygon.cc,v 1.15 2010/11/02 11:28:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -139,7 +139,7 @@ void G4ReduciblePolygon::Create( const G4double a[],
// for usage restricted to object persistency.
//
G4ReduciblePolygon::G4ReduciblePolygon( __void__& )
: aMin(0.), aMax(0.), bMin(0.), bMax(0.), vertexHead(0)
: aMin(0.), aMax(0.), bMin(0.), bMax(0.), numVertices(0), vertexHead(0)
{
}
@@ -220,8 +220,7 @@ void G4ReduciblePolygon::ScaleB( G4double scale )
G4bool G4ReduciblePolygon::RemoveDuplicateVertices( G4double tolerance )
{
ABVertex *curr = vertexHead,
*prev = 0,
*next = curr->next; // A little dangerous
*prev = 0, *next = 0;
while( curr )
{
next = curr->next;
@@ -284,8 +283,7 @@ G4bool G4ReduciblePolygon::RemoveRedundantVertices( G4double tolerance )
//
// Loop over all vertices
//
ABVertex *curr = vertexHead,
*next = curr->next; // A little dangerous
ABVertex *curr = vertexHead, *next = 0;
while( curr )
{
next = curr->next;
@@ -340,7 +338,7 @@ G4bool G4ReduciblePolygon::RemoveRedundantVertices( G4double tolerance )
else
vertexHead = test; // New head
delete next;
if ((curr != next) && (next != test)) delete next;
numVertices--;
@@ -426,39 +424,43 @@ void G4ReduciblePolygon::ReverseOrder()
G4bool G4ReduciblePolygon::CrossesItself( G4double tolerance )
{
G4double tolerance2 = tolerance*tolerance;
G4double one = 1.0-tolerance,
zero = tolerance;
G4double one = 1.0-tolerance,
zero = tolerance;
//
// Top loop over line segments. By the time we finish
// with the second to last segment, we're done.
//
ABVertex *curr1 = vertexHead, *next1=0;
while (curr1->next) {
next1 = curr1->next;
while (curr1->next)
{
next1 = curr1->next;
G4double da1 = next1->a-curr1->a,
db1 = next1->b-curr1->b;
db1 = next1->b-curr1->b;
//
// Inner loop over subsequent line segments
//
ABVertex *curr2 = next1->next;
while( curr2 ) {
while( curr2 )
{
ABVertex *next2 = curr2->next;
if (next2==0) next2 = vertexHead;
G4double da2 = next2->a-curr2->a,
db2 = next2->b-curr2->b;
db2 = next2->b-curr2->b;
G4double a12 = curr2->a-curr1->a,
b12 = curr2->b-curr1->b;
b12 = curr2->b-curr1->b;
//
// Calculate intersection of the two lines
//
G4double deter = da1*db2 - db1*da2;
if (std::fabs(deter) > tolerance2) {
if (std::fabs(deter) > tolerance2)
{
G4double s1, s2;
s1 = (a12*db2-b12*da2)/deter;
if (s1 >= zero && s1 < one) {
if (s1 >= zero && s1 < one)
{
s2 = -(da1*b12-db1*a12)/deter;
if (s2 >= zero && s2 < one) return true;
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4SolidExtentList.cc,v 1.5 2007/05/11 13:54:29 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4SolidExtentList.cc,v 1.7 2010/07/16 15:59:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -50,8 +50,8 @@ G4SolidExtentList::G4SolidExtentList()
{
axis = kZAxis;
limited = false;
minLimit = -DBL_MAX;
maxLimit = +DBL_MAX;
minLimit = -INT_MAX/2;
maxLimit = INT_MAX/2;
}
@@ -71,8 +71,8 @@ G4SolidExtentList::G4SolidExtentList( const EAxis targetAxis,
}
else
{
minLimit = -DBL_MAX;
maxLimit = +DBL_MAX;
minLimit = -INT_MAX/2;
maxLimit = INT_MAX/2;
}
}
@@ -24,8 +24,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TessellatedSolid.cc,v 1.19 2009/04/27 08:06:27 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4TessellatedSolid.cc,v 1.27 2010/11/02 11:29:07 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
@@ -42,6 +42,10 @@
// CHANGE HISTORY
// --------------
//
// 12 April 2010 P R Truscott, QinetiQ, bug fixes to treat optical
// photon transport, in particular internal reflection
// at surface.
//
// 14 November 2007 P R Truscott, QinetiQ & Stan Seibert, U Texas
// Bug fixes to CalculateExtent
//
@@ -127,7 +131,7 @@ G4TessellatedSolid::G4TessellatedSolid( __void__& a )
geometryType("G4TessellatedSolid"), cubicVolume(0.), surfaceArea(0.),
vertexList(), xMinExtent(0.), xMaxExtent(0.),
yMinExtent(0.), yMaxExtent(0.), zMinExtent(0.), zMaxExtent(0.),
solidClosed(false)
solidClosed(false), dirTolerance(1.0E-14)
{
SetRandomVectorSet();
}
@@ -146,16 +150,17 @@ G4TessellatedSolid::~G4TessellatedSolid ()
// Define copy constructor.
//
G4TessellatedSolid::G4TessellatedSolid (const G4TessellatedSolid &s)
: G4VSolid(s)
: G4VSolid(s), fpPolyhedron(0)
{
if (&s == this) { return; }
dirTolerance = 1.0E-14;
geometryType = "G4TessellatedSolid";
facets.clear();
solidClosed = false;
cubicVolume = s.cubicVolume;
surfaceArea = s.surfaceArea;
xMinExtent = kInfinity;
xMaxExtent = -kInfinity;
yMinExtent = kInfinity;
@@ -177,6 +182,16 @@ G4TessellatedSolid::operator= (const G4TessellatedSolid &s)
{
if (&s == this) { return *this; }
// Copy base class data
//
G4VSolid::operator=(s);
// Copy data
//
cubicVolume = s.cubicVolume;
surfaceArea = s.surfaceArea;
fpPolyhedron = 0;
DeleteObjects ();
CopyObjects (s);
@@ -206,8 +221,6 @@ void G4TessellatedSolid::CopyObjects (const G4TessellatedSolid &s)
}
if ( s.GetSolidClosed() ) { SetSolidClosed(true); }
// cubicVolume = s.GetCubicVolume();
}
///////////////////////////////////////////////////////////////////////////////
@@ -508,8 +521,8 @@ EInside G4TessellatedSolid::Inside (const G4ThreeVector &p) const
crossingI = ((*f)->Intersect(p,v,false,distI,distFromSurfaceI,normalI));
if (crossingO || crossingI)
{
nearParallel = (crossingO && std::abs(normalO.dot(v))<dirTolerance) ||
(crossingI && std::abs(normalI.dot(v))<dirTolerance);
nearParallel = (crossingO && std::fabs(normalO.dot(v))<dirTolerance) ||
(crossingI && std::fabs(normalI.dot(v))<dirTolerance);
if (!nearParallel)
{
if (crossingO && distO > 0.0 && distO < distOut) distOut = distO;
@@ -652,7 +665,7 @@ G4double G4TessellatedSolid::DistanceToIn (const G4ThreeVector &p,
#if G4SPECSDEBUG
if ( Inside(p) == kInside )
{
G4cout.precision(16) ;
G4int oldprc = G4cout.precision(16) ;
G4cout << G4endl ;
// DumpInfo();
G4cout << "Position:" << G4endl << G4endl ;
@@ -660,6 +673,7 @@ G4double G4TessellatedSolid::DistanceToIn (const G4ThreeVector &p,
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl ;
G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl ;
G4cout << "DistanceToOut(p) == " << DistanceToOut(p) << G4endl;
G4cout.precision(oldprc) ;
G4Exception("G4TriangularFacet::DistanceToIn(p,v)", "Notification", JustWarning,
"Point p is already inside!?" );
}
@@ -669,10 +683,22 @@ G4double G4TessellatedSolid::DistanceToIn (const G4ThreeVector &p,
{
if ((*f)->Intersect(p,v,false,dist,distFromSurface,normal))
{
//
//
// Set minDist to the new distance to current facet if distFromSurface is in
// positive direction and point is not at surface. If the point is within
// 0.5*kCarTolerance of the surface, then force distance to be zero and
// leave member function immediately (for efficiency), as proposed by & credit
// to Akira Okumura.
//
if (distFromSurface > 0.5*kCarTolerance && dist >= 0.0 && dist < minDist)
{
minDist = dist;
}
else if (-0.5*kCarTolerance <= dist && dist <= 0.5*kCarTolerance)
{
return 0.0;
}
}
}
@@ -694,7 +720,7 @@ G4double G4TessellatedSolid::DistanceToIn (const G4ThreeVector &p) const
#if G4SPECSDEBUG
if ( Inside(p) == kInside )
{
G4cout.precision(16) ;
G4int oldprc = G4cout.precision(16) ;
G4cout << G4endl ;
// DumpInfo();
G4cout << "Position:" << G4endl << G4endl ;
@@ -702,6 +728,7 @@ G4double G4TessellatedSolid::DistanceToIn (const G4ThreeVector &p) const
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl ;
G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl ;
G4cout << "DistanceToOut(p) == " << DistanceToOut(p) << G4endl;
G4cout.precision(oldprc) ;
G4Exception("G4TriangularFacet::DistanceToIn(p)", "Notification", JustWarning,
"Point p is already inside!?" );
}
@@ -747,7 +774,7 @@ G4double G4TessellatedSolid::DistanceToOut (const G4ThreeVector &p,
#if G4SPECSDEBUG
if ( Inside(p) == kOutside )
{
G4cout.precision(16) ;
G4int oldprc = G4cout.precision(16) ;
G4cout << G4endl ;
// DumpInfo();
G4cout << "Position:" << G4endl << G4endl ;
@@ -755,6 +782,7 @@ G4double G4TessellatedSolid::DistanceToOut (const G4ThreeVector &p,
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl ;
G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl ;
G4cout << "DistanceToIn(p) == " << DistanceToIn(p) << G4endl;
G4cout.precision(oldprc) ;
G4Exception("G4TriangularFacet::DistanceToOut(p)", "Notification", JustWarning,
"Point p is already outside !?" );
}
@@ -820,7 +848,7 @@ G4double G4TessellatedSolid::DistanceToOut (const G4ThreeVector &p) const
#if G4SPECSDEBUG
if ( Inside(p) == kOutside )
{
G4cout.precision(16) ;
G4int oldprc = G4cout.precision(16) ;
G4cout << G4endl ;
// DumpInfo();
G4cout << "Position:" << G4endl << G4endl ;
@@ -828,6 +856,7 @@ G4double G4TessellatedSolid::DistanceToOut (const G4ThreeVector &p) const
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl ;
G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl ;
G4cout << "DistanceToIn(p) == " << DistanceToIn(p) << G4endl;
G4cout.precision(oldprc) ;
G4Exception("G4TriangularFacet::DistanceToOut(p)", "Notification", JustWarning,
"Point p is already outside !?" );
}
@@ -854,6 +883,15 @@ G4GeometryType G4TessellatedSolid::GetEntityType () const
return geometryType;
}
///////////////////////////////////////////////////////////////////////////////
//
// Make a clone of the object
//
G4VSolid* G4TessellatedSolid::Clone() const
{
return new G4TessellatedSolid(*this);
}
///////////////////////////////////////////////////////////////////////////////
//
void G4TessellatedSolid::DescribeYourselfTo (G4VGraphicsScene& scene) const
+76 -14
View File
@@ -27,8 +27,8 @@
// * *
// ********************************************************************
//
// $Id: G4Tet.cc,v 1.11 2006/11/13 08:58:03 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4Tet.cc,v 1.16 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// class G4Tet
//
@@ -51,12 +51,13 @@
// 20041103 - MHM removed many unused variables from class
// 20040803 - Dionysios Anninos, added GetPointOnSurface() method
// 20061112 - MHM added code for G4VSolid GetSurfaceArea()
// 20100920 - Gabriele Cosmo added copy-ctor and operator=()
//
// --------------------------------------------------------------------
#include "G4Tet.hh"
const char G4Tet::CVSVers[]="$Id: G4Tet.cc,v 1.11 2006/11/13 08:58:03 gcosmo Exp $";
const char G4Tet::CVSVers[]="$Id: G4Tet.cc,v 1.16 2010/10/20 08:54:18 gcosmo Exp $";
#include "G4VoxelLimits.hh"
#include "G4AffineTransform.hh"
@@ -111,7 +112,7 @@ G4Tet::G4Tet(const G4String& pName,
fV41=fV31;
fV31=temp;
}
fCubicVolume = std::abs(signed_vol) / 6.;
fCubicVolume = std::fabs(signed_vol) / 6.;
G4ThreeVector fV24=p2-p4;
G4ThreeVector fV43=p4-p3;
@@ -132,7 +133,7 @@ G4Tet::G4Tet(const G4String& pName,
(p3-fMiddle).mag()),
(p4-fMiddle).mag());
G4bool degenerate=std::abs(signed_vol) < 1e-9*fMaxSize*fMaxSize*fMaxSize;
G4bool degenerate=std::fabs(signed_vol) < 1e-9*fMaxSize*fMaxSize*fMaxSize;
if(degeneracyFlag) *degeneracyFlag=degenerate;
else if (degenerate)
@@ -141,8 +142,8 @@ G4Tet::G4Tet(const G4String& pName,
"Degenerate tetrahedron not allowed.");
}
fTol=1e-9*(std::abs(fXMin)+std::abs(fXMax)+std::abs(fYMin)
+std::abs(fYMax)+std::abs(fZMin)+std::abs(fZMax));
fTol=1e-9*(std::fabs(fXMin)+std::fabs(fXMax)+std::fabs(fYMin)
+std::fabs(fYMax)+std::fabs(fZMin)+std::fabs(fZMax));
//fTol=kCarTolerance;
fAnchor=anchor;
@@ -206,6 +207,58 @@ G4Tet::~G4Tet()
delete fpPolyhedron;
}
///////////////////////////////////////////////////////////////////////////////
//
// Copy constructor
G4Tet::G4Tet(const G4Tet& rhs)
: G4VSolid(rhs),
fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
fpPolyhedron(0), fAnchor(rhs.fAnchor),
fP2(rhs.fP2), fP3(rhs.fP3), fP4(rhs.fP4), fMiddle(rhs.fMiddle),
fNormal123(rhs.fNormal123), fNormal142(rhs.fNormal142),
fNormal134(rhs.fNormal134), fNormal234(rhs.fNormal234),
warningFlag(rhs.warningFlag), fCdotN123(rhs.fCdotN123),
fCdotN142(rhs.fCdotN142), fCdotN134(rhs.fCdotN134),
fCdotN234(rhs.fCdotN234), fXMin(rhs.fXMin), fXMax(rhs.fXMax),
fYMin(rhs.fYMin), fYMax(rhs.fYMax), fZMin(rhs.fZMin), fZMax(rhs.fZMax),
fDx(rhs.fDx), fDy(rhs.fDy), fDz(rhs.fDz), fTol(rhs.fTol),
fMaxSize(rhs.fMaxSize)
{
}
///////////////////////////////////////////////////////////////////////////////
//
// Assignment operator
G4Tet& G4Tet::operator = (const G4Tet& rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4VSolid::operator=(rhs);
// Copy data
//
fCubicVolume = rhs.fCubicVolume; fSurfaceArea = rhs.fSurfaceArea;
fpPolyhedron = 0; fAnchor = rhs.fAnchor;
fP2 = rhs.fP2; fP3 = rhs.fP3; fP4 = rhs.fP4; fMiddle = rhs.fMiddle;
fNormal123 = rhs.fNormal123; fNormal142 = rhs.fNormal142;
fNormal134 = rhs.fNormal134; fNormal234 = rhs.fNormal234;
warningFlag = rhs.warningFlag; fCdotN123 = rhs.fCdotN123;
fCdotN142 = rhs.fCdotN142; fCdotN134 = rhs.fCdotN134;
fCdotN234 = rhs.fCdotN234; fXMin = rhs.fXMin; fXMax = rhs.fXMax;
fYMin = rhs.fYMin; fYMax = rhs.fYMax; fZMin = rhs.fZMin; fZMax = rhs.fZMax;
fDx = rhs.fDx; fDy = rhs.fDy; fDz = rhs.fDz; fTol = rhs.fTol;
fMaxSize = rhs.fMaxSize;
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// CheckDegeneracy
@@ -364,10 +417,10 @@ EInside G4Tet::Inside(const G4ThreeVector& p) const
G4ThreeVector G4Tet::SurfaceNormal( const G4ThreeVector& p) const
{
G4double r123=std::abs(p.dot(fNormal123)-fCdotN123);
G4double r134=std::abs(p.dot(fNormal134)-fCdotN134);
G4double r142=std::abs(p.dot(fNormal142)-fCdotN142);
G4double r234=std::abs(p.dot(fNormal234)-fCdotN234);
G4double r123=std::fabs(p.dot(fNormal123)-fCdotN123);
G4double r134=std::fabs(p.dot(fNormal134)-fCdotN134);
G4double r142=std::fabs(p.dot(fNormal142)-fCdotN142);
G4double r234=std::fabs(p.dot(fNormal234)-fCdotN234);
if( (r123<=r134) && (r123<=r142) && (r123<=r234) ) { return fNormal123; }
else if ( (r134<=r142) && (r134<=r234) ) { return fNormal134; }
@@ -566,10 +619,10 @@ G4ThreeVectorList*
G4Tet::CreateRotatedVertices(const G4AffineTransform& pTransform) const
{
G4ThreeVectorList* vertices = new G4ThreeVectorList();
vertices->reserve(4);
if (vertices)
{
vertices->reserve(4);
G4ThreeVector vertex0(fAnchor);
G4ThreeVector vertex1(fP2);
G4ThreeVector vertex2(fP3);
@@ -584,8 +637,8 @@ G4Tet::CreateRotatedVertices(const G4AffineTransform& pTransform) const
{
DumpInfo();
G4Exception("G4Tet::CreateRotatedVertices()",
"FatalError", FatalException,
"Error in allocation of vertices. Out of memory !");
"FatalError", FatalException,
"Error in allocation of vertices. Out of memory !");
}
return vertices;
}
@@ -599,6 +652,15 @@ G4GeometryType G4Tet::GetEntityType() const
return G4String("G4Tet");
}
//////////////////////////////////////////////////////////////////////////
//
// Make a clone of the object
G4VSolid* G4Tet::Clone() const
{
return new G4Tet(*this);
}
//////////////////////////////////////////////////////////////////////////
//
// Stream object contents to an output stream
@@ -24,8 +24,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TriangularFacet.cc,v 1.12 2008/11/13 08:25:07 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TriangularFacet.cc,v 1.16 2010/09/23 10:27:25 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
@@ -55,6 +55,9 @@
// function to correctly treat rays nearly parallel to the
// plane of the triangle.
//
// 12 April 2010 P R Truscott, QinetiQ, bug fixes to treat optical
// photon transport, in particular internal reflection
// at surface.
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#include "G4TriangularFacet.hh"
@@ -72,7 +75,7 @@
G4TriangularFacet::G4TriangularFacet (const G4ThreeVector Pt0,
const G4ThreeVector vt1, const G4ThreeVector vt2,
G4FacetVertexType vertexType)
: G4VFacet()
: G4VFacet(), sMin(0.), sMax(1.), tMin(0.), sqrDist(0.)
{
tGeomAlg = G4TessellatedGeometryAlgorithms::GetInstance();
P0 = Pt0;
@@ -128,7 +131,7 @@ G4TriangularFacet::G4TriangularFacet (const G4ThreeVector Pt0,
a = E[0].mag2();
b = E[0].dot(E[1]);
c = E[1].mag2();
det = std::abs(a*c - b*b);
det = std::fabs(a*c - b*b);
sMin = -0.5*kCarTolerance/std::sqrt(a);
sMax = 1.0 - sMin;
@@ -160,6 +163,40 @@ G4TriangularFacet::~G4TriangularFacet ()
I.clear();
}
///////////////////////////////////////////////////////////////////////////////
//
// Copy constructor
//
G4TriangularFacet::G4TriangularFacet (const G4TriangularFacet &rhs)
: G4VFacet(rhs), a(rhs.a), b(rhs.b), c(rhs.c), det(rhs.det),
sMin(rhs.sMin), sMax(rhs.sMax), tMin(rhs.tMin), sqrDist(rhs.sqrDist)
{
tGeomAlg = G4TessellatedGeometryAlgorithms::GetInstance();
}
///////////////////////////////////////////////////////////////////////////////
//
// Assignment operator
//
const G4TriangularFacet &G4TriangularFacet::operator=(G4TriangularFacet &rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4VFacet::operator=(rhs);
// Copy data
//
a = rhs.a; b = rhs.b; c = rhs.c; det = rhs.det;
sMin = rhs.sMin; sMax = rhs.sMax; tMin = rhs.tMin; sqrDist = rhs.sqrDist;
tGeomAlg = G4TessellatedGeometryAlgorithms::GetInstance();
return *this;
}
///////////////////////////////////////////////////////////////////////////////
//
// GetClone
@@ -349,11 +386,31 @@ G4ThreeVector G4TriangularFacet::Distance (const G4ThreeVector &p)
}
//
//
// Do a heck for rounding errors in the distance-squared.
// Do a check for rounding errors in the distance-squared. It appears that
// the conventional methods for calculating sqrDist breaks down when very near
// to or at the surface (as required by transport). We'll therefore also use
// the magnitude-squared of the vector displacement. (Note that I've also
// tried to get around this problem by using the existing equations for
//
// sqrDist = function(a,b,c,d,s,t)
//
// and use a more accurate addition process which minimises errors and
// breakdown of cummutitivity [where (A+B)+C != A+(B+C)] but this still
// doesn't work.
// Calculation from u = D + s*E[0] + t*E[1] is less efficient, but appears
// more robust.
//
if (sqrDist < 0.0) { sqrDist = 0.0; }
G4ThreeVector u = D + s*E[0] + t*E[1];
G4double u2 = u.mag2();
//
//
// The following (part of the roundoff error check) is from Oliver Merle's
// updates.
//
if ( sqrDist > u2 ) sqrDist = u2;
return D + s*E[0] + t*E[1];
return u;
}
///////////////////////////////////////////////////////////////////////////////
@@ -541,7 +598,8 @@ G4bool G4TriangularFacet::Intersect (const G4ThreeVector &p,
// We're very close. Therefore return a small negative number to pretend
// we intersect.
//
distance = -0.5*kCarTolerance;
// distance = -0.5*kCarTolerance;
distance = 0.0;
normal = surfaceNormal;
return true;
}
@@ -610,7 +668,7 @@ G4bool G4TriangularFacet::Intersect (const G4ThreeVector &p,
else
{
G4double dnormDist = normDist1-normDist0;
if (std::abs(dnormDist) < DBL_EPSILON)
if (std::fabs(dnormDist) < DBL_EPSILON)
{
distance = s0;
normal = surfaceNormal;
@@ -727,3 +785,5 @@ G4double G4TriangularFacet::GetArea()
{
return area;
}
////////////////////////////////////////////////////////////////////////
//
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TwistBoxSide.cc,v 1.6 2007/05/23 09:31:02 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TwistBoxSide.cc,v 1.8 2010/07/16 15:58:59 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -131,7 +131,11 @@ G4TwistBoxSide::G4TwistBoxSide(const G4String &name,
//* Fake default constructor ------------------------------------------
G4TwistBoxSide::G4TwistBoxSide( __void__& a )
: G4VTwistSurface(a)
: G4VTwistSurface(a), fTheta(0.), fPhi(0.), fDy1(0.), fDx1(0.), fDx2(0.),
fDy2(0.), fDx3(0.), fDx4(0.), fDz(0.), fAlph(0.), fTAlph(0.), fPhiTwist(0.),
fAngleSide(0.), fdeltaX(0.), fdeltaY(0.), fDx4plus2(0.), fDx4minus2(0.),
fDx3plus1(0.), fDx3minus1(0.), fDy2plus1(0.), fDy2minus1(0.), fa1md1(0.),
fa2md2(0.)
{
}
@@ -240,7 +244,7 @@ G4int G4TwistBoxSide::DistanceToSurface(const G4ThreeVector &gp,
G4cout << "Local direction v = " << v << G4endl ;
#endif
G4double phi,u ; // parameters
G4double phi=0.,u=0.,q=0.; // parameters
// temporary variables
@@ -263,11 +267,19 @@ G4int G4TwistBoxSide::DistanceToSurface(const G4ThreeVector &gp,
if ( v.z() == 0. ) {
if ( std::fabs(p.z()) <= L ) { // intersection possible in z
if ( (std::fabs(p.z()) <= L) && fPhiTwist ) { // intersection possible in z
phi = p.z() * fPhiTwist / L ; // phi is determined by the z-position
u = (2*(-(fdeltaY*phi*v.x()) + fPhiTwist*p.y()*v.x() + fdeltaX*phi*v.y() - fPhiTwist*p.x()*v.y()) + (fDx4plus2*fPhiTwist + 2*fDx4minus2*phi)*(v.y()*std::cos(phi) - v.x()*std::sin(phi)))/(2.* fPhiTwist*((v.x() - fTAlph*v.y())*std::cos(phi) + (fTAlph*v.x() + v.y())*std::sin(phi))) ;
q = (2.* fPhiTwist*((v.x() - fTAlph*v.y())*std::cos(phi)
+ (fTAlph*v.x() + v.y())*std::sin(phi)));
if (q) {
u = (2*(-(fdeltaY*phi*v.x()) + fPhiTwist*p.y()*v.x()
+ fdeltaX*phi*v.y() - fPhiTwist*p.x()*v.y())
+ (fDx4plus2*fPhiTwist + 2*fDx4minus2*phi)
* (v.y()*std::cos(phi) - v.x()*std::sin(phi))) / q;
}
xbuftmp.phi = phi ;
xbuftmp.u = u ;
@@ -329,13 +341,17 @@ G4int G4TwistBoxSide::DistanceToSurface(const G4ThreeVector &gp,
for (G4int i = 0 ; i<num ; i++ ) { // loop over all mathematical solutions
if ( si[i]==0.0 ) { // only real solutions
if ( (si[i]==0.0) && fPhiTwist ) { // only real solutions
#ifdef G4TWISTDEBUG
G4cout << "Solution " << i << " : " << sr[i] << G4endl ;
#endif
phi = std::fmod(sr[i] , pihalf) ;
u = (2*phiyz + 4*fDz*phi*v.y() - 2*fdeltaY*phi*v.z() - fDx4plus2*fPhiTwist*v.z()*std::sin(phi) - 2*fDx4minus2*phi*v.z()*std::sin(phi))/(2*fPhiTwist*v.z()*std::cos(phi) + 2*fPhiTwist*fTAlph*v.z()*std::sin(phi)) ;
u = (2*phiyz + 4*fDz*phi*v.y() - 2*fdeltaY*phi*v.z()
- fDx4plus2*fPhiTwist*v.z()*std::sin(phi)
- 2*fDx4minus2*phi*v.z()*std::sin(phi))
/(2*fPhiTwist*v.z()*std::cos(phi)
+ 2*fPhiTwist*fTAlph*v.z()*std::sin(phi)) ;
xbuftmp.phi = phi ;
xbuftmp.u = u ;
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TwistTrapAlphaSide.cc,v 1.8 2007/05/23 13:26:06 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TwistTrapAlphaSide.cc,v 1.9 2010/07/12 15:25:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -122,7 +122,11 @@ G4TwistTrapAlphaSide(const G4String &name,
//* Fake default constructor ------------------------------------------
G4TwistTrapAlphaSide::G4TwistTrapAlphaSide( __void__& a )
: G4VTwistSurface(a)
: G4VTwistSurface(a), fTheta(0.), fPhi(0.), fDy1(0.), fDx1(0.), fDx2(0.),
fDy2(0.), fDx3(0.), fDx4(0.), fDz(0.), fAlph(0.), fTAlph(0.), fPhiTwist(0.),
fAngleSide(0.), fDx4plus2(0.), fDx4minus2(0.), fDx3plus1(0.), fDx3minus1(0.),
fDy2plus1(0.), fDy2minus1(0.), fa1md1(0.), fa2md2(0.), fdeltaX(0.),
fdeltaY(0.)
{
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TwistTrapFlatSide.cc,v 1.6 2007/05/23 09:31:02 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TwistTrapFlatSide.cc,v 1.7 2010/07/12 15:25:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -105,7 +105,8 @@ G4TwistTrapFlatSide::G4TwistTrapFlatSide( const G4String &name,
//* Fake default constructor ------------------------------------------
G4TwistTrapFlatSide::G4TwistTrapFlatSide( __void__& a )
: G4VTwistSurface(a)
: G4VTwistSurface(a), fDx1(0.), fDx2(0.), fDy(0.), fDz(0.), fPhiTwist(0.),
fAlpha(0.), fTAlph(0.), fPhi(0.), fTheta(0.), fdeltaX(0.), fdeltaY(0.)
{
}
@@ -25,7 +25,7 @@
//
//
// $Id: G4TwistTrapParallelSide.cc,v
// GEANT4 tag $Name: geant4-09-02 $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -61,7 +61,8 @@ G4TwistTrapParallelSide::G4TwistTrapParallelSide(const G4String &name,
G4double pDx4, // half x length at +pDz,+pDy
G4double pAlph, // tilt angle at +pDz
G4double AngleSide // parity
) : G4VTwistSurface(name)
)
: G4VTwistSurface(name), fDy(0.)
{
fAxis[0] = kXAxis; // in local coordinate system
@@ -119,7 +120,11 @@ G4TwistTrapParallelSide::G4TwistTrapParallelSide(const G4String &name,
//* Fake default constructor ------------------------------------------
G4TwistTrapParallelSide::G4TwistTrapParallelSide( __void__& a )
: G4VTwistSurface(a)
: G4VTwistSurface(a), fTheta(0.), fPhi(0.), fDy1(0.), fDx1(0.), fDx2(0.),
fDy2(0.), fDx3(0.), fDx4(0.), fDz(0.), fAlph(0.), fTAlph(0.), fPhiTwist(0.),
fAngleSide(0.), fdeltaX(0.), fdeltaY(0.), fDx4plus2(0.), fDx4minus2(0.),
fDx3plus1(0.), fDx3minus1(0.), fDy2plus1(0.), fDy2minus1(0.), fa1md1(0.),
fa2md2(0.), fDy(0.)
{
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TwistTubsFlatSide.cc,v 1.7 2007/05/23 09:31:02 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TwistTubsFlatSide.cc,v 1.8 2010/07/12 15:25:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -115,7 +115,7 @@ G4TwistTubsFlatSide::G4TwistTubsFlatSide( const G4String &name,
//* Fake default constructor ------------------------------------------
G4TwistTubsFlatSide::G4TwistTubsFlatSide( __void__& a )
: G4VTwistSurface(a)
: G4VTwistSurface(a), fSurfaceArea(0.)
{
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TwistTubsHypeSide.cc,v 1.6 2007/05/18 07:39:56 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TwistTubsHypeSide.cc,v 1.8 2010/07/12 15:33:49 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -62,11 +62,12 @@ G4TwistTubsHypeSide::G4TwistTubsHypeSide(const G4String &name,
G4double axis0max,
G4double axis1max )
: G4VTwistSurface(name, rot, tlate, handedness, axis0, axis1,
axis0min, axis1min, axis0max, axis1max),
axis0min, axis1min, axis0max, axis1max),
fKappa(kappa), fTanStereo(tanstereo),
fTan2Stereo(tanstereo*tanstereo), fR0(r0), fR02(r0*r0)
fTan2Stereo(tanstereo*tanstereo), fR0(r0), fR02(r0*r0), fDPhi(twopi)
{
if (axis0 == kZAxis && axis1 == kPhi) {
if ( (axis0 == kZAxis) && (axis1 == kPhi) )
{
G4Exception("G4TwistTubsHypeSide::G4TwistTubsHypeSide()", "InvalidSetup",
FatalException, "Should swap axis0 and axis1!");
}
@@ -130,7 +131,8 @@ G4TwistTubsHypeSide::G4TwistTubsHypeSide(const G4String &name,
//* Fake default constructor ------------------------------------------
G4TwistTubsHypeSide::G4TwistTubsHypeSide( __void__& a )
: G4VTwistSurface(a)
: G4VTwistSurface(a), fKappa(0.), fTanStereo(0.), fTan2Stereo(0.),
fR0(0.), fR02(0.), fDPhi(0.)
{
}
@@ -325,7 +327,7 @@ G4int G4TwistTubsHypeSide::DistanceToSurface(const G4ThreeVector &gp,
//
G4double vz = v.z();
G4double absvz = std::abs(vz);
G4double absvz = std::fabs(vz);
G4double vrho = v.getRho();
G4double vslope = vrho/vz;
G4double vslope2 = vslope * vslope;
@@ -376,7 +378,8 @@ G4int G4TwistTubsHypeSide::DistanceToSurface(const G4ThreeVector &gp,
G4double a = v.x()*v.x() + v.y()*v.y() - v.z()*v.z()*fTan2Stereo;
G4double b = 2.0 * ( p.x() * v.x() + p.y() * v.y() - p.z() * v.z() * fTan2Stereo );
G4double c = p.x()*p.x() + p.y()*p.y() - fR02 - p.z()*p.z()*fTan2Stereo;
G4double D = b*b - 4*a*c; //discriminant
G4double D = b*b - 4*a*c; //discriminant
G4int vout = 0;
if (std::fabs(a) < DBL_MIN) {
if (std::fabs(b) > DBL_MIN) { // single solution
@@ -402,7 +405,7 @@ G4int G4TwistTubsHypeSide::DistanceToSurface(const G4ThreeVector &gp,
fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
isvalid[0], 1, validate, &gp, &gv);
return 1;
vout = 1;
} else {
// if a=b=0 and c != 0, p is origin and v is parallel to asymptotic line.
@@ -412,7 +415,7 @@ G4int G4TwistTubsHypeSide::DistanceToSurface(const G4ThreeVector &gp,
fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
isvalid[0], 0, validate, &gp, &gv);
return 0;
vout = 0;
}
} else if (D > DBL_MIN) { // double solutions
@@ -477,7 +480,7 @@ G4int G4TwistTubsHypeSide::DistanceToSurface(const G4ThreeVector &gp,
isvalid[0], 2, validate, &gp, &gv);
fCurStatWithV.SetCurrentStatus(1, gxx[1], distance[1], areacode[1],
isvalid[1], 2, validate, &gp, &gv);
return 2;
vout = 2;
} else {
// if D<0, no solution
@@ -485,11 +488,9 @@ G4int G4TwistTubsHypeSide::DistanceToSurface(const G4ThreeVector &gp,
fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
isvalid[0], 0, validate, &gp, &gv);
return 0;
vout = 0;
}
G4Exception("G4TwistTubsHypeSide::DistanceToSurface(p,v)",
"InvalidCondition", FatalException, "Illegal operation !");
return 1;
return vout;
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TwistTubsSide.cc,v 1.6 2009/11/11 12:23:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4TwistTubsSide.cc,v 1.7 2010/07/12 15:25:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -108,7 +108,7 @@ G4TwistTubsSide::G4TwistTubsSide(const G4String &name,
//* Fake default constructor ------------------------------------------
G4TwistTubsSide::G4TwistTubsSide( __void__& a )
: G4VTwistSurface(a)
: G4VTwistSurface(a), fKappa(0.)
{
}
@@ -262,6 +262,7 @@ G4int G4TwistTubsSide::DistanceToSurface(const G4ThreeVector &gp,
G4double b = fKappa * (v.x() * p.z() + v.z() * p.x()) - v.y();
G4double c = fKappa * p.x() * p.z() - p.y();
G4double D = b * b - 4 * a * c; // discriminant
G4int vout = 0;
if (std::fabs(a) < DBL_MIN) {
if (std::fabs(b) > DBL_MIN) {
@@ -292,13 +293,13 @@ G4int G4TwistTubsSide::DistanceToSurface(const G4ThreeVector &gp,
fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0],
areacode[0], isvalid[0],
0, validate, &gp, &gv);
return 0;
return vout;
}
}
fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
isvalid[0], 1, validate, &gp, &gv);
return 1;
vout = 1;
} else {
// if a=b=0 , v.y=0 and (v.x=0 && p.x=0) or (v.z=0 && p.z=0) .
@@ -310,8 +311,6 @@ G4int G4TwistTubsSide::DistanceToSurface(const G4ThreeVector &gp,
fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
isvalid[0], 0, validate, &gp, &gv);
return 0;
}
} else if (D > DBL_MIN) {
@@ -439,19 +438,16 @@ G4int G4TwistTubsSide::DistanceToSurface(const G4ThreeVector &gp,
}
}
return 2;
vout = 2;
} else {
// if D<0, no solution
// if D=0, just grazing the surfaces, return kInfinity
fCurStatWithV.SetCurrentStatus(0, gxx[0], distance[0], areacode[0],
isvalid[0], 0, validate, &gp, &gv);
return 0;
}
G4Exception("G4TwistTubsSide::DistanceToSurface(p,v)",
"InvalidCondition", FatalException, "Illegal operation !");
return 1;
return vout;
}
//=====================================================================
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TwistedBox.cc,v 1.12 2006/06/29 18:49:20 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TwistedBox.cc,v 1.14 2010/10/20 08:54:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -65,6 +65,31 @@ G4TwistedBox::~G4TwistedBox()
{
}
// Copy constructor
//
G4TwistedBox::G4TwistedBox(const G4TwistedBox& rhs)
: G4VTwistedFaceted(rhs)
{
}
// Assignment operator
//
G4TwistedBox& G4TwistedBox::operator = (const G4TwistedBox& rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4VTwistedFaceted::operator=(rhs);
return *this;
}
std::ostream& G4TwistedBox::StreamInfo(std::ostream& os) const
{
//
@@ -92,3 +117,11 @@ G4GeometryType G4TwistedBox::GetEntityType() const
{
return G4String("G4TwistedBox");
}
//=====================================================================
//* Clone -------------------------------------------------------------
G4VSolid* G4TwistedBox::Clone() const
{
return new G4TwistedBox(*this);
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TwistedTrap.cc,v 1.14 2006/06/29 18:49:23 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TwistedTrap.cc,v 1.16 2010/10/20 08:54:19 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -85,6 +85,28 @@ G4TwistedTrap::~G4TwistedTrap()
{
}
// Copy constructor
//
G4TwistedTrap::G4TwistedTrap(const G4TwistedTrap& rhs)
: G4VTwistedFaceted(rhs)
{
}
// Assignment operator
//
G4TwistedTrap& G4TwistedTrap::operator = (const G4TwistedTrap& rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4VTwistedFaceted::operator=(rhs);
return *this;
}
std::ostream& G4TwistedTrap::StreamInfo(std::ostream& os) const
{
//
@@ -123,3 +145,11 @@ G4GeometryType G4TwistedTrap::GetEntityType() const
{
return G4String("G4TwistedTrap");
}
//=====================================================================
//* Clone -------------------------------------------------------------
G4VSolid* G4TwistedTrap::Clone() const
{
return new G4TwistedTrap(*this);
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TwistedTrd.cc,v 1.7 2006/06/29 18:49:25 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TwistedTrd.cc,v 1.9 2010/10/20 08:54:19 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -67,6 +67,28 @@ G4TwistedTrd::~G4TwistedTrd()
{
}
// Copy constructor
//
G4TwistedTrd::G4TwistedTrd(const G4TwistedTrd& rhs)
: G4VTwistedFaceted(rhs)
{
}
// Assignment operator
//
G4TwistedTrd& G4TwistedTrd::operator = (const G4TwistedTrd& rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4VTwistedFaceted::operator=(rhs);
return *this;
}
std::ostream& G4TwistedTrd::StreamInfo(std::ostream& os) const
{
//
@@ -96,3 +118,11 @@ G4GeometryType G4TwistedTrd::GetEntityType() const
{
return G4String("G4TwistedTrd");
}
//=====================================================================
//* Clone -------------------------------------------------------------
G4VSolid* G4TwistedTrd::Clone() const
{
return new G4TwistedTrd(*this);
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TwistedTubs.cc,v 1.24 2007/05/18 07:39:56 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TwistedTubs.cc,v 1.30 2010/11/10 10:00:16 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -192,10 +192,18 @@ G4TwistedTubs::G4TwistedTubs(const G4String &pname,
//* Fake default constructor ------------------------------------------
G4TwistedTubs::G4TwistedTubs( __void__& a )
: G4VSolid(a), fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0),
fFormerTwisted(0), fInnerHype(0), fOuterHype(0), fCubicVolume(0.),
fSurfaceArea(0.), fpPolyhedron(0)
: G4VSolid(a), fPhiTwist(0.), fInnerRadius(0.), fOuterRadius(0.), fDPhi(0.),
fZHalfLength(0.), fInnerStereo(0.), fOuterStereo(0.), fTanInnerStereo(0.),
fTanOuterStereo(0.), fKappa(0.), fInnerRadius2(0.), fOuterRadius2(0.),
fTanInnerStereo2(0.), fTanOuterStereo2(0.), fLowerEndcap(0), fUpperEndcap(0),
fLatterTwisted(0), fFormerTwisted(0), fInnerHype(0), fOuterHype(0),
fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
{
fEndZ[0] = 0.; fEndZ[1] = 0.;
fEndInnerRadius[0] = 0.; fEndInnerRadius[1] = 0.;
fEndOuterRadius[0] = 0.; fEndOuterRadius[1] = 0.;
fEndPhi[0] = 0.; fEndPhi[1] = 0.;
fEndZ2[0] = 0.; fEndZ2[1] = 0.;
}
//=====================================================================
@@ -212,6 +220,86 @@ G4TwistedTubs::~G4TwistedTubs()
if (fpPolyhedron) { delete fpPolyhedron; }
}
//=====================================================================
//* Copy constructor --------------------------------------------------
G4TwistedTubs::G4TwistedTubs(const G4TwistedTubs& rhs)
: G4VSolid(rhs), fPhiTwist(rhs.fPhiTwist),
fInnerRadius(rhs.fInnerRadius), fOuterRadius(rhs.fOuterRadius),
fDPhi(rhs.fDPhi), fZHalfLength(rhs.fZHalfLength),
fInnerStereo(rhs.fInnerStereo), fOuterStereo(rhs.fOuterStereo),
fTanInnerStereo(rhs.fTanInnerStereo), fTanOuterStereo(rhs.fTanOuterStereo),
fKappa(rhs.fKappa), fInnerRadius2(rhs.fInnerRadius2),
fOuterRadius2(rhs.fOuterRadius2), fTanInnerStereo2(rhs.fTanInnerStereo2),
fTanOuterStereo2(rhs.fTanOuterStereo2),
fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0), fFormerTwisted(0),
fInnerHype(0), fOuterHype(0),
fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
fpPolyhedron(0), fLastInside(rhs.fLastInside), fLastNormal(rhs.fLastNormal),
fLastDistanceToIn(rhs.fLastDistanceToIn),
fLastDistanceToOut(rhs.fLastDistanceToOut),
fLastDistanceToInWithV(rhs.fLastDistanceToInWithV),
fLastDistanceToOutWithV(rhs.fLastDistanceToOutWithV)
{
for (size_t i=0; i<2; ++i)
{
fEndZ[i] = rhs.fEndZ[i];
fEndInnerRadius[i] = rhs.fEndInnerRadius[i];
fEndOuterRadius[i] = rhs.fEndOuterRadius[i];
fEndPhi[i] = rhs.fEndPhi[i];
fEndZ2[i] = rhs.fEndZ2[i];
}
CreateSurfaces();
}
//=====================================================================
//* Assignment operator -----------------------------------------------
G4TwistedTubs& G4TwistedTubs::operator = (const G4TwistedTubs& rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4VSolid::operator=(rhs);
// Copy data
//
fPhiTwist= rhs.fPhiTwist;
fInnerRadius= rhs.fInnerRadius; fOuterRadius= rhs.fOuterRadius;
fDPhi= rhs.fDPhi; fZHalfLength= rhs.fZHalfLength;
fInnerStereo= rhs.fInnerStereo; fOuterStereo= rhs.fOuterStereo;
fTanInnerStereo= rhs.fTanInnerStereo; fTanOuterStereo= rhs.fTanOuterStereo;
fKappa= rhs.fKappa; fInnerRadius2= rhs.fInnerRadius2;
fOuterRadius2= rhs.fOuterRadius2; fTanInnerStereo2= rhs.fTanInnerStereo2;
fTanOuterStereo2= rhs.fTanOuterStereo2;
fLowerEndcap= fUpperEndcap= fLatterTwisted= fFormerTwisted= 0;
fInnerHype= fOuterHype= 0;
fCubicVolume= rhs.fCubicVolume; fSurfaceArea= rhs.fSurfaceArea;
fpPolyhedron= 0;
fLastInside= rhs.fLastInside; fLastNormal= rhs.fLastNormal;
fLastDistanceToIn= rhs.fLastDistanceToIn;
fLastDistanceToOut= rhs.fLastDistanceToOut;
fLastDistanceToInWithV= rhs.fLastDistanceToInWithV;
fLastDistanceToOutWithV= rhs.fLastDistanceToOutWithV;
for (size_t i=0; i<2; ++i)
{
fEndZ[i] = rhs.fEndZ[i];
fEndInnerRadius[i] = rhs.fEndInnerRadius[i];
fEndOuterRadius[i] = rhs.fEndOuterRadius[i];
fEndPhi[i] = rhs.fEndPhi[i];
fEndZ2[i] = rhs.fEndZ2[i];
}
CreateSurfaces();
return *this;
}
//=====================================================================
//* ComputeDimensions -------------------------------------------------
@@ -298,6 +386,7 @@ G4bool G4TwistedTubs::CalculateExtent( const EAxis axis,
G4ClippablePolygon endPoly1, endPoly2;
G4double phimax = maxphi + 0.5*fDPhi;
if ( phimax > pi/2) { phimax = pi-phimax; }
G4double phimin = - phimax;
G4ThreeVector v0, v1, v2, v3, v4, v5, v6; // -ve phi verticies for polygon
@@ -309,7 +398,7 @@ G4bool G4TwistedTubs::CalculateExtent( const EAxis axis,
G4double cosPhi = std::cos(phimin);
G4double sinPhi = std::sin(phimin);
// Outer hyperbolic surface
v0 = transform.TransformPoint(
@@ -366,7 +455,7 @@ G4bool G4TwistedTubs::CalculateExtent( const EAxis axis,
cosPhi = std::cos(phimax);
sinPhi = std::sin(phimax);
// Outer hyperbolic surface
w0 = transform.TransformPoint(
@@ -1128,6 +1217,14 @@ G4GeometryType G4TwistedTubs::GetEntityType() const
return G4String("G4TwistedTubs");
}
//=====================================================================
//* Clone -------------------------------------------------------------
G4VSolid* G4TwistedTubs::Clone() const
{
return new G4TwistedTubs(*this);
}
//=====================================================================
//* GetCubicVolume ----------------------------------------------------
@@ -29,8 +29,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4VCSGfaceted.cc,v 1.26 2009/05/08 14:29:56 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4VCSGfaceted.cc,v 1.29 2010/09/23 10:27:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -97,6 +97,10 @@ G4VCSGfaceted::~G4VCSGfaceted()
G4VCSGfaceted::G4VCSGfaceted( const G4VCSGfaceted &source )
: G4VSolid( source )
{
fStatistics = source.fStatistics;
fCubVolEpsilon = source.fCubVolEpsilon;
fAreaAccuracy = source.fAreaAccuracy;
CopyStuff( source );
}
@@ -108,6 +112,16 @@ const G4VCSGfaceted &G4VCSGfaceted::operator=( const G4VCSGfaceted &source )
{
if (&source == this) { return *this; }
// Copy base class data
//
G4VSolid::operator=(source);
// Copy data
//
fStatistics = source.fStatistics;
fCubVolEpsilon = source.fCubVolEpsilon;
fAreaAccuracy = source.fAreaAccuracy;
DeleteStuff();
CopyStuff( source );
@@ -134,7 +148,8 @@ void G4VCSGfaceted::CopyStuff( const G4VCSGfaceted &source )
*face = (*sourceFace)->Clone();
} while( ++sourceFace, ++face < faces+numFace );
fCubicVolume = source.fCubicVolume;
fpPolyhedron = source.fpPolyhedron;
fSurfaceArea = source.fSurfaceArea;
fpPolyhedron = 0;
}
@@ -245,8 +260,8 @@ G4double G4VCSGfaceted::DistanceToIn( const G4ThreeVector &p,
{
G4double distance = kInfinity;
G4double distFromSurface = kInfinity;
G4VCSGface *bestFace=0;
G4VCSGface **face = faces;
G4VCSGface *bestFace = *face;
do
{
G4double faceDistance,
@@ -301,9 +316,9 @@ G4double G4VCSGfaceted::DistanceToOut( const G4ThreeVector &p,
G4double distance = kInfinity;
G4double distFromSurface = kInfinity;
G4ThreeVector normal;
G4VCSGface *bestFace=0;
G4VCSGface **face = faces;
G4VCSGface *bestFace = *face;
do
{
G4double faceDistance,
@@ -25,8 +25,8 @@
// ********************************************************************
//
//
// $Id: G4VFacet.cc,v 1.8 2008/12/18 12:57:38 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VFacet.cc,v 1.11 2010/09/23 10:30:07 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
@@ -54,17 +54,15 @@
///////////////////////////////////////////////////////////////////////////////
//
G4VFacet::G4VFacet ()
: geometryType("G4VFacet"), isDefined(false), nVertices(0),
radius(0.), radiusSqr(0.), dirTolerance(1.0E-14), area(0.)
{
dirTolerance = 1.0E-14;
kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
P.clear();
E.clear();
circumcentre = G4ThreeVector(0.0,0.0,0.0);
radius = 0.0;
radiusSqr = 0.0;
area = 0.0;
}
///////////////////////////////////////////////////////////////////////////////
@@ -75,6 +73,38 @@ G4VFacet::~G4VFacet ()
E.clear();
}
///////////////////////////////////////////////////////////////////////////////
//
G4VFacet::G4VFacet (const G4VFacet &rhs)
: geometryType(rhs.geometryType), isDefined(rhs.isDefined),
nVertices(rhs.nVertices), P0(rhs.P0), P(rhs.P), E(rhs.E), I(rhs.I),
surfaceNormal(rhs.surfaceNormal), circumcentre(rhs.circumcentre),
radius(rhs.radius), radiusSqr(rhs.radiusSqr),
dirTolerance(rhs.dirTolerance), kCarTolerance(rhs.kCarTolerance),
area(rhs.area)
{
}
///////////////////////////////////////////////////////////////////////////////
//
const G4VFacet &G4VFacet::operator=(G4VFacet &rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy data
//
geometryType = rhs.geometryType; isDefined = rhs.isDefined;
nVertices = rhs.nVertices; P0 = rhs.P0; P = rhs.P; E = rhs.E; I = rhs.I;
surfaceNormal = rhs.surfaceNormal; circumcentre = rhs.circumcentre;
radius = rhs.radius; radiusSqr = rhs.radiusSqr;
dirTolerance = rhs.dirTolerance; kCarTolerance = rhs.kCarTolerance;
area = rhs.area;
return *this;
}
///////////////////////////////////////////////////////////////////////////////
//
G4bool G4VFacet::operator== (const G4VFacet &right) const
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4VTwistSurface.cc,v 1.9 2007/05/31 13:52:48 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VTwistSurface.cc,v 1.10 2010/07/12 15:25:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -74,7 +74,7 @@ const G4int G4VTwistSurface::sAreaMask = 0XF0000000;
//* constructors ------------------------------------------------------
G4VTwistSurface::G4VTwistSurface(const G4String &name)
: fName(name)
: fIsValidNorm(false), fName(name)
{
fAxis[0] = kUndefined;
@@ -85,8 +85,8 @@ G4VTwistSurface::G4VTwistSurface(const G4String &name)
fAxisMax[1] = kInfinity;
fHandedness = 1;
G4int i;
for (i=0; i<4; i++) {
for (G4int i=0; i<4; i++)
{
fCorners[i].set(kInfinity, kInfinity, kInfinity);
fNeighbours[i] = 0;
}
@@ -108,7 +108,7 @@ G4VTwistSurface::G4VTwistSurface(const G4String &name,
G4double axis1min,
G4double axis0max,
G4double axis1max )
: fName(name)
: fIsValidNorm(false), fName(name)
{
fAxis[0] = axis0;
fAxis[1] = axis1;
@@ -120,8 +120,8 @@ G4VTwistSurface::G4VTwistSurface(const G4String &name,
fRot = rot;
fTrans = tlate;
G4int i;
for (i=0; i<4; i++) {
for (G4int i=0; i<4; i++)
{
fCorners[i].set(kInfinity, kInfinity, kInfinity);
fNeighbours[i] = 0;
}
@@ -137,8 +137,13 @@ G4VTwistSurface::G4VTwistSurface(const G4String &name,
//* Fake default constructor ------------------------------------------
G4VTwistSurface::G4VTwistSurface( __void__& )
: fName("")
: fHandedness(0), fIsValidNorm(false), kCarTolerance(0.),
fName("")
{
fAxis[0] = fAxis[1] = kXAxis;
fAxisMin[0] = fAxisMin[1] = 0.;
fAxisMax[0] = fAxisMax[1] = 0.;
fNeighbours[0] = fNeighbours[1] = fNeighbours[2] = fNeighbours[3] = 0;
}
//=====================================================================
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VTwistedFaceted.cc,v 1.18 2007/05/25 09:42:34 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VTwistedFaceted.cc,v 1.22 2010/09/23 10:27:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
// --------------------------------------------------------------------
@@ -200,10 +200,11 @@ G4VTwistedFaceted( const G4String &pname, // Name of instance
//* Fake default constructor ------------------------------------------
G4VTwistedFaceted::G4VTwistedFaceted( __void__& a )
: G4VSolid(a),
fLowerEndcap(0), fUpperEndcap(0), fSide0(0),
fSide90(0), fSide180(0), fSide270(0),
fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
: G4VSolid(a), fTheta(0.), fPhi(0.), fDy1(0.), fDx1(0.), fDx2(0.),
fDy2(0.), fDx3(0.), fDx4(0.), fDz(0.), fDx(0.), fDy(0.), fAlph(0.),
fTAlph(0.), fdeltaX(0.), fdeltaY(0.), fPhiTwist(0.),
fLowerEndcap(0), fUpperEndcap(0), fSide0(0), fSide90(0), fSide180(0),
fSide270(0), fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
{
}
@@ -222,6 +223,62 @@ G4VTwistedFaceted::~G4VTwistedFaceted()
if (fpPolyhedron) delete fpPolyhedron;
}
//=====================================================================
//* Copy constructor --------------------------------------------------
G4VTwistedFaceted::G4VTwistedFaceted(const G4VTwistedFaceted& rhs)
: G4VSolid(rhs), fTheta(rhs.fTheta), fPhi(rhs.fPhi),
fDy1(rhs.fDy1), fDx1(rhs.fDx1), fDx2(rhs.fDx2), fDy2(rhs.fDy2),
fDx3(rhs.fDx3), fDx4(rhs.fDx4), fDz(rhs.fDz), fDx(rhs.fDx), fDy(rhs.fDy),
fAlph(rhs.fAlph), fTAlph(rhs.fTAlph), fdeltaX(rhs.fdeltaX),
fdeltaY(rhs.fdeltaY), fPhiTwist(rhs.fPhiTwist), fLowerEndcap(0),
fUpperEndcap(0), fSide0(0), fSide90(0), fSide180(0), fSide270(0),
fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
fpPolyhedron(0),
fLastInside(rhs.fLastInside), fLastNormal(rhs.fLastNormal),
fLastDistanceToIn(rhs.fLastDistanceToIn),
fLastDistanceToOut(rhs.fLastDistanceToOut),
fLastDistanceToInWithV(rhs.fLastDistanceToInWithV),
fLastDistanceToOutWithV(rhs.fLastDistanceToOutWithV)
{
CreateSurfaces();
}
//=====================================================================
//* Assignment operator -----------------------------------------------
G4VTwistedFaceted& G4VTwistedFaceted::operator = (const G4VTwistedFaceted& rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4VSolid::operator=(rhs);
// Copy data
//
fTheta = rhs.fTheta; fPhi = rhs.fPhi;
fDy1= rhs.fDy1; fDx1= rhs.fDx1; fDx2= rhs.fDx2; fDy2= rhs.fDy2;
fDx3= rhs.fDx3; fDx4= rhs.fDx4; fDz= rhs.fDz; fDx= rhs.fDx; fDy= rhs.fDy;
fAlph= rhs.fAlph; fTAlph= rhs.fTAlph; fdeltaX= rhs.fdeltaX;
fdeltaY= rhs.fdeltaY; fPhiTwist= rhs.fPhiTwist; fLowerEndcap= 0;
fUpperEndcap= 0; fSide0= 0; fSide90= 0; fSide180= 0; fSide270= 0;
fCubicVolume= rhs.fCubicVolume; fSurfaceArea= rhs.fSurfaceArea;
fpPolyhedron= 0;
fLastInside= rhs.fLastInside; fLastNormal= rhs.fLastNormal;
fLastDistanceToIn= rhs.fLastDistanceToIn;
fLastDistanceToOut= rhs.fLastDistanceToOut;
fLastDistanceToInWithV= rhs.fLastDistanceToInWithV;
fLastDistanceToOutWithV= rhs.fLastDistanceToOutWithV;
CreateSurfaces();
return *this;
}
//=====================================================================
//* ComputeDimensions -------------------------------------------------
@@ -427,10 +484,10 @@ CreateRotatedVertices(const G4AffineTransform& pTransform) const
{
G4ThreeVectorList* vertices = new G4ThreeVectorList();
vertices->reserve(8);
if (vertices)
{
vertices->reserve(8);
G4double maxRad = std::sqrt( fDx*fDx + fDy*fDy);
@@ -926,9 +983,9 @@ G4double G4VTwistedFaceted::DistanceToOut( const G4ThreeVector& p ) const
// checking last value
//
G4ThreeVector *tmpp;
G4double *tmpdist;
if (fLastDistanceToOut.p == p)
{
return fLastDistanceToOut.value;
@@ -945,73 +1002,79 @@ G4double G4VTwistedFaceted::DistanceToOut( const G4ThreeVector& p ) const
//
EInside currentside = Inside(p);
G4double retval = kInfinity;
switch (currentside)
{
case (kOutside) :
{
#ifdef G4SPECSDEBUG
G4cout.precision(16) ;
G4int oldprc = G4cout.precision(16) ;
G4cout << G4endl ;
DumpInfo();
G4cout << "Position:" << G4endl << G4endl ;
G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl ;
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl ;
G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl ;
G4cout.precision(oldprc) ;
G4Exception("G4VTwistedFaceted::DistanceToOut(p)", "Notification",
JustWarning, "Point p is outside !?" );
#endif
break;
}
case (kSurface) :
{
*tmpdist = 0.;
return fLastDistanceToOut.value;
retval = fLastDistanceToOut.value;
break;
}
case (kInside) :
{
// Initialize
//
G4double distance = kInfinity;
// Initialize
//
G4double distance = kInfinity;
// find intersections and choose nearest one
//
G4VTwistSurface *surfaces[6];
// find intersections and choose nearest one
//
G4VTwistSurface *surfaces[6];
surfaces[0] = fSide0;
surfaces[1] = fSide90 ;
surfaces[2] = fSide180 ;
surfaces[3] = fSide270 ;
surfaces[4] = fLowerEndcap;
surfaces[5] = fUpperEndcap;
surfaces[0] = fSide0;
surfaces[1] = fSide90 ;
surfaces[2] = fSide180 ;
surfaces[3] = fSide270 ;
surfaces[4] = fLowerEndcap;
surfaces[5] = fUpperEndcap;
G4int i;
G4int besti = -1;
G4ThreeVector xx;
G4ThreeVector bestxx;
for (i=0; i< 6; i++)
{
G4double tmpdistance = surfaces[i]->DistanceTo(p, xx);
if (tmpdistance < distance)
{
distance = tmpdistance;
bestxx = xx;
besti = i;
}
}
*tmpdist = distance;
G4int i;
G4int besti = -1;
G4ThreeVector xx;
G4ThreeVector bestxx;
for (i=0; i< 6; i++)
{
G4double tmpdistance = surfaces[i]->DistanceTo(p, xx);
if (tmpdistance < distance)
{
distance = tmpdistance;
bestxx = xx;
besti = i;
}
}
*tmpdist = distance;
return fLastDistanceToOut.value;
retval = fLastDistanceToOut.value;
break;
}
default :
{
G4Exception("G4VTwistedFaceted::DistanceToOut(p)", "InvalidCondition",
FatalException, "Unknown point location!");
G4Exception("G4VTwistedFaceted::DistanceToOut(p)", "InvalidCondition",
FatalException, "Unknown point location!");
break;
}
} // switch end
return kInfinity;
return retval;
}