Import Geant4 10.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2016-06-30 14:12:05 +02:00
parent a654a7ab1f
commit 4ec577e5c4
2021 changed files with 100995 additions and 78277 deletions
+40 -1
View File
@@ -1,5 +1,5 @@
$Id: History 93153 2015-10-08 11:54:58Z gcosmo $
$Id: History 97695 2016-06-07 09:54:49Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -20,6 +20,45 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
June 6, 2016 E. Tcherniaev geom-bool-V10-02-08
- Reimplemented CalculateExtent() in G4ScaledSolid to use new class
G4BoundingEnvelope. Use accessors in implementation.
June 1, 2016 G. Cosmo geom-bool-V10-02-07
- Corrected treatment of polyhedron for G4DiplacedSolid and G4ScaledSolid
to avoid thread contention.
- Added warning in G4BooleanSolid::GetPointOnSurface() in case of non
convergence after fixed number of trials.
May 27, 2016 G. Cosmo geom-bool-V10-02-06
- Fixed Coverity defects for uninitialised data in G4BooleanSolid.
May 26, 2016 E. Tcherniaev
- Replaced while loop for for-loop in G4BooleanSolid::GetPointOnSurface().
May 20, 2016 G. Cosmo geom-bool-V10-02-05
- Moved accessors and modifiers in UMultiUnion wrapper to be not inlined.
Required modification in order to allow correct dispatching to VecGeom
types.
May 17, 2016 E. Tcherniaev geom-bool-V10-02-04
- Boosted computation of GetPointOnSurface() for G4BooleanSolid;
reimplemented algorithm, using cached list of primitives.
May 13, 2016 G.Cosmo geom-bool-V10-02-03
- Fixed GetPolyhedron() in G4ScaledSolid and G4DisplacedSolid for MT.
May 12, 2016 E.Tcherniaev geom-bool-V10-02-02
- Use transformations for normals from G4ScaleTransform in G4ScaledSolid.
March 16, 2016 G.Cosmo geom-bool-V10-02-01
- Added new class G4ScaledSolid providing ability to scale dimensions of
a shape in X, Y or Z.
Requires tag "geommng-V10-02-00".
February 8, 2016 G.Cosmo geom-bool-V10-02-00
- Minor optimisation in Inside(p) for G4UnionSolid and G4SubtractionSolid.
October 7, 2015 G.Cosmo geom-bool-V10-01-02
- Protected compilation of USolid wrappers with G4GEOM_USE_USOLIDS flag.
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4BooleanSolid.hh 83572 2014-09-01 15:23:27Z gcosmo $
// $Id: G4BooleanSolid.hh 96960 2016-05-18 14:59:54Z gcosmo $
//
//
// class G4BooleanSolid
@@ -34,9 +34,7 @@
// Abstract base class for solids created by boolean operations
// between other solids.
// History:
//
// 10.09.98 V.Grichine, created
// 10.09.98 V.Grichine - created
//
// --------------------------------------------------------------------
#ifndef G4BOOLEANSOLID_HH
@@ -110,20 +108,19 @@ class G4BooleanSolid : public G4VSolid
protected:
void GetListOfPrimitives(std::vector<std::pair<G4VSolid *,G4Transform3D>>&,
const G4Transform3D&) const;
// Get list of constituent primitives of the solid and their placements.
G4Polyhedron* StackPolyhedron(HepPolyhedronProcessor&,
const G4VSolid*) const;
// Stack polyhedra for processing. Return top polyhedron.
inline G4double GetAreaRatio() const;
// Ratio of surface areas of SolidA to total A+B
protected:
G4VSolid* fPtrSolidA;
G4VSolid* fPtrSolidB;
mutable G4double fAreaRatio; // Calculation deferred to GetPointOnSurface()
private:
G4int fStatistics;
@@ -135,6 +132,9 @@ class G4BooleanSolid : public G4VSolid
mutable G4bool fRebuildPolyhedron;
mutable G4Polyhedron* fpPolyhedron;
mutable std::vector<std::pair<G4VSolid *,G4Transform3D>> fPrimitives;
mutable G4double fPrimitivesSurfaceArea;
G4bool createdDisplacedSolid;
// If & only if this object created it, it must delete it
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4BooleanSolid.icc 66356 2012-12-18 09:02:32Z gcosmo $
// $Id: G4BooleanSolid.icc 96960 2016-05-18 14:59:54Z gcosmo $
//
// --------------------------------------------------------------------
// GEANT 4 inline definitions file
@@ -101,14 +101,3 @@ G4double G4BooleanSolid::GetSurfaceArea()
else { fSurfaceArea = EstimateSurfaceArea(fStatistics,fAreaAccuracy); }
return fSurfaceArea;
}
inline
G4double G4BooleanSolid::GetAreaRatio() const
{
if (fAreaRatio <= 0.)
{
fAreaRatio = fPtrSolidA->GetSurfaceArea() /
(fPtrSolidA->GetSurfaceArea()+fPtrSolidB->GetSurfaceArea());
}
return fAreaRatio;
}
@@ -0,0 +1,126 @@
//
// ********************************************************************
// * 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:$
//
//
// class G4ScaledSolid
//
// Class description:
//
// A scaled solid is a solid that has been scaled in dimensions
// in X, Y or Z, from its original description.
// History:
//
// 27.10.15 G.Cosmo: created
//
// --------------------------------------------------------------------
#ifndef G4ScaledSolid_HH
#define G4ScaledSolid_HH
#include "G4VSolid.hh"
#include "G4ThreeVector.hh"
#include "G4Transform3D.hh"
#include "G4AffineTransform.hh"
class G4ScaleTransform;
class G4ScaledSolid : public G4VSolid
{
public: // with description
G4ScaledSolid( const G4String& pName,
G4VSolid* pSolid ,
const G4Scale3D& pScale );
virtual ~G4ScaledSolid();
EInside Inside( const G4ThreeVector& p ) const;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) 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;
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep );
void CleanTransformations();
G4ThreeVector GetPointOnSurface() const;
G4Scale3D GetScaleTransform() const;
void SetScaleTransform(const G4Scale3D& scale);
G4VSolid* GetUnscaledSolid() const;
G4GeometryType GetEntityType() const;
G4VSolid* Clone() const;
std::ostream& StreamInfo(std::ostream& os) const;
public: // without description
G4ScaledSolid(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4ScaledSolid(const G4ScaledSolid& rhs);
G4ScaledSolid& operator=(const G4ScaledSolid& rhs);
// Copy constructor and assignment operator.
void DescribeYourselfTo ( G4VGraphicsScene& scene ) const;
G4Polyhedron* CreatePolyhedron () const;
G4Polyhedron* GetPolyhedron () const;
// For creating graphical representations (i.e. for visualisation).
private:
G4VSolid* fPtrSolid;
G4ScaleTransform* fScale;
mutable G4bool fRebuildPolyhedron;
mutable G4Polyhedron* fpPolyhedron;
} ;
#endif
@@ -62,12 +62,13 @@ class G4UMultiUnion : public G4USolid
inline UMultiUnion* GetShape() const;
inline void AddNode(G4VSolid& solid, G4Transform3D& trans);
void AddNode(G4VSolid& solid, G4Transform3D& trans);
// Build the multiple union by adding nodes
inline G4Transform3D* GetTransformation(G4int index) const;
inline G4VSolid* GetSolid(G4int index) const;
inline int GetNumberOfSolids()const;
inline void Voxelize();
G4Transform3D* GetTransformation(G4int index) const;
G4VSolid* GetSolid(G4int index) const;
G4int GetNumberOfSolids()const;
void Voxelize();
public: // without description
G4UMultiUnion(__void__&);
@@ -92,53 +93,6 @@ inline UMultiUnion* G4UMultiUnion::GetShape() const
return (UMultiUnion*) fShape;
}
inline void G4UMultiUnion::AddNode(G4VSolid& solid, G4Transform3D& trans)
{
HepGeom::Rotate3D rot;
HepGeom::Translate3D transl ;
HepGeom::Scale3D scale;
trans.getDecomposition(scale,rot,transl);
G4ThreeVector pos = transl.getTranslation();
UTransform3D tr;
tr.fRot[0] = rot.xx(); tr.fRot[1] = rot.xy(); tr.fRot[2] = rot.xz();
tr.fRot[3] = rot.yx(); tr.fRot[4] = rot.yy(); tr.fRot[5] = rot.yz();
tr.fRot[6] = rot.zx(); tr.fRot[7] = rot.zy(); tr.fRot[8] = rot.zz();
tr.fTr = UVector3(pos.x(), pos.y(), pos.z());
GetShape()->AddNode(*(static_cast<G4USolid&>(solid).GetSolid()), tr);
}
inline G4Transform3D* G4UMultiUnion::GetTransformation(G4int index) const
{
UTransform3D tr = GetShape()->GetTransformation(index);
G4RotationMatrix
rot(CLHEP::HepRep3x3(tr.fRot[0], tr.fRot[1], tr.fRot[2],
tr.fRot[3], tr.fRot[4], tr.fRot[5],
tr.fRot[6], tr.fRot[7], tr.fRot[8]));
G4ThreeVector transl(tr.fTr.x(), tr.fTr.y(), tr.fTr.z());
return new G4Transform3D(rot, transl);
}
inline G4VSolid* G4UMultiUnion::GetSolid(G4int index) const
{
VUSolid* solid = GetShape()->GetSolid(index);
return new G4USolid(solid->GetName(), solid);
}
inline int G4UMultiUnion::GetNumberOfSolids()const
{
return GetShape()->GetNumberOfSolids();
}
inline void G4UMultiUnion::Voxelize()
{
GetShape()->Voxelize();
}
#endif // G4GEOM_USE_USOLIDS
#endif
+3 -1
View File
@@ -11,7 +11,7 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake 85608 2014-10-31 11:23:30Z gcosmo $
# $Id: sources.cmake 96129 2016-03-16 22:05:08Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -39,6 +39,7 @@ GEANT4_DEFINE_MODULE(NAME G4geomBoolean
G4DisplacedSolid.hh
G4IntersectionSolid.hh
G4MultiUnion.hh
G4ScaledSolid.hh
G4SubtractionSolid.hh
G4UMultiUnion.hh
G4UnionSolid.hh
@@ -46,6 +47,7 @@ GEANT4_DEFINE_MODULE(NAME G4geomBoolean
G4BooleanSolid.cc
G4DisplacedSolid.cc
G4IntersectionSolid.cc
G4ScaledSolid.cc
G4SubtractionSolid.cc
G4UMultiUnion.cc
G4UnionSolid.cc
@@ -24,19 +24,25 @@
// ********************************************************************
//
//
// $Id: G4BooleanSolid.cc 92010 2015-08-13 10:07:52Z gcosmo $
// $Id: G4BooleanSolid.cc 97300 2016-06-01 09:27:19Z gcosmo $
//
// Implementation for the abstract base class for solids created by boolean
// operations between other solids
//
// History:
//
// 10.09.98 V.Grichine, created
// 2016.03.16 E.Tcherniaev - added GetListOfPrimitives(),
// reimplemented GetPointOnSurface()
//
// 1998.09.10 V.Grichine - created
//
// --------------------------------------------------------------------
#include "G4BooleanSolid.hh"
#include "G4VSolid.hh"
#include "G4DisplacedSolid.hh"
#include "G4ReflectedSolid.hh"
#include "G4ScaledSolid.hh"
#include "G4Polyhedron.hh"
#include "HepPolyhedronProcessor.h"
#include "Randomize.hh"
@@ -55,9 +61,10 @@ namespace
G4BooleanSolid::G4BooleanSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ) :
G4VSolid(pName), fAreaRatio(0.), fStatistics(1000000), fCubVolEpsilon(0.001),
G4VSolid(pName), fStatistics(1000000), fCubVolEpsilon(0.001),
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
fRebuildPolyhedron(false), fpPolyhedron(0), createdDisplacedSolid(false)
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
createdDisplacedSolid(false)
{
fPtrSolidA = pSolidA ;
fPtrSolidB = pSolidB ;
@@ -72,9 +79,10 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
G4VSolid* pSolidB ,
G4RotationMatrix* rotMatrix,
const G4ThreeVector& transVector ) :
G4VSolid(pName), fAreaRatio(0.), fStatistics(1000000), fCubVolEpsilon(0.001),
G4VSolid(pName), fStatistics(1000000), fCubVolEpsilon(0.001),
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
fRebuildPolyhedron(false), fpPolyhedron(0), createdDisplacedSolid(true)
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
createdDisplacedSolid(true)
{
fPtrSolidA = pSolidA ;
fPtrSolidB = new G4DisplacedSolid("placedB",pSolidB,rotMatrix,transVector) ;
@@ -88,9 +96,10 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ,
const G4Transform3D& transform ) :
G4VSolid(pName), fAreaRatio(0.), fStatistics(1000000), fCubVolEpsilon(0.001),
G4VSolid(pName), fStatistics(1000000), fCubVolEpsilon(0.001),
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
fRebuildPolyhedron(false), fpPolyhedron(0), createdDisplacedSolid(true)
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
createdDisplacedSolid(true)
{
fPtrSolidA = pSolidA ;
fPtrSolidB = new G4DisplacedSolid("placedB",pSolidB,transform) ;
@@ -102,10 +111,11 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
// for usage restricted to object persistency.
G4BooleanSolid::G4BooleanSolid( __void__& a )
: G4VSolid(a), fPtrSolidA(0), fPtrSolidB(0), fAreaRatio(0.),
: G4VSolid(a), fPtrSolidA(0), fPtrSolidB(0),
fStatistics(1000000), fCubVolEpsilon(0.001),
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
fRebuildPolyhedron(false), fpPolyhedron(0), createdDisplacedSolid(false)
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
createdDisplacedSolid(false)
{
}
@@ -128,12 +138,12 @@ G4BooleanSolid::~G4BooleanSolid()
G4BooleanSolid::G4BooleanSolid(const G4BooleanSolid& rhs)
: G4VSolid (rhs), fPtrSolidA(rhs.fPtrSolidA), fPtrSolidB(rhs.fPtrSolidB),
fAreaRatio(rhs.fAreaRatio),
fStatistics(rhs.fStatistics), fCubVolEpsilon(rhs.fCubVolEpsilon),
fAreaAccuracy(rhs.fAreaAccuracy), fCubicVolume(rhs.fCubicVolume),
fSurfaceArea(rhs.fSurfaceArea), fRebuildPolyhedron(false), fpPolyhedron(0),
createdDisplacedSolid(rhs.createdDisplacedSolid)
{
fPrimitives.resize(0); fPrimitivesSurfaceArea = 0.;
}
///////////////////////////////////////////////////////////////
@@ -153,21 +163,21 @@ G4BooleanSolid& G4BooleanSolid::operator = (const G4BooleanSolid& rhs)
// Copy data
//
fPtrSolidA= rhs.fPtrSolidA; fPtrSolidB= rhs.fPtrSolidB;
fAreaRatio= rhs.fAreaRatio;
fStatistics= rhs.fStatistics; fCubVolEpsilon= rhs.fCubVolEpsilon;
fAreaAccuracy= rhs.fAreaAccuracy; fCubicVolume= rhs.fCubicVolume;
fSurfaceArea= rhs.fSurfaceArea; fpPolyhedron= 0;
fSurfaceArea= rhs.fSurfaceArea;
createdDisplacedSolid= rhs.createdDisplacedSolid;
fRebuildPolyhedron = false;
delete fpPolyhedron; fpPolyhedron = 0;
fPrimitives.resize(0); fPrimitivesSurfaceArea = 0.;
return *this;
}
///////////////////////////////////////////////////////////////
//
// If Solid is made up from a Boolean operation of two solids,
// return the corresponding solid (for no=0 and 1)
// If solid is made up from a Boolean operation of two solids,
// return the corresponding solid (for no=0 and 1)
// If the solid is not a "Boolean", return 0
const G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no) const
@@ -189,8 +199,8 @@ const G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no) const
///////////////////////////////////////////////////////////////
//
// If Solid is made up from a Boolean operation of two solids,
// return the corresponding solid (for no=0 and 1)
// If solid is made up from a Boolean operation of two solids,
// return the corresponding solid (for no=0 and 1)
// If the solid is not a "Boolean", return 0
G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no)
@@ -240,23 +250,114 @@ std::ostream& G4BooleanSolid::StreamInfo(std::ostream& os) const
//////////////////////////////////////////////////////////////////////////
//
// Returns a point (G4ThreeVector) randomly and uniformly selected
// on the solid surface
// Creates list of constituent primitives of and their placements
void G4BooleanSolid::GetListOfPrimitives(
std::vector<std::pair<G4VSolid *,G4Transform3D>>& primitives,
const G4Transform3D& curPlacement) const
{
G4Transform3D transform;
G4VSolid* solid;
G4String type;
// Repeat two times, first time for fPtrSolidA and then for fPtrSolidB
//
for (G4int i=0; i<2; i++)
{
transform = curPlacement;
solid = (i == 0) ? fPtrSolidA : fPtrSolidB;
type = solid->GetEntityType();
// While current solid is a trasformed solid just modify transform
//
while (type == "G4DisplacedSolid" ||
type == "G4ReflectedSolid" ||
type == "G4ScaledSolid")
{
if (type == "G4DisplacedSolid")
{
transform = transform * G4Transform3D(
((G4DisplacedSolid*)solid)->GetObjectRotation(),
((G4DisplacedSolid*)solid)->GetObjectTranslation());
solid = ((G4DisplacedSolid*)solid)->GetConstituentMovedSolid();
}
else if (type == "G4ReflectedSolid")
{
transform= transform*((G4ReflectedSolid*)solid)->GetDirectTransform3D();
solid = ((G4ReflectedSolid*)solid)->GetConstituentMovedSolid();
}
else if (type == "G4ScaledSolid")
{
transform = transform * ((G4ScaledSolid*)solid)->GetScaleTransform();
solid = ((G4ScaledSolid*)solid)->GetUnscaledSolid();
}
type = solid->GetEntityType();
}
// If current solid is a Boolean solid then continue recursion,
// otherwise add it to the list of primitives
//
if (type == "G4UnionSolid" ||
type == "G4SubtractionSolid" ||
type == "G4IntersectionSolid" ||
type == "G4BooleanSolid")
{
((G4BooleanSolid *)solid)->GetListOfPrimitives(primitives,transform);
}
else
{
primitives.push_back(std::pair<G4VSolid*,G4Transform3D>(solid,transform));
}
}
}
//////////////////////////////////////////////////////////////////////////
//
// Returns a point (G4ThreeVector) randomly and uniformly selected
// on the surface of the solid
G4ThreeVector G4BooleanSolid::GetPointOnSurface() const
{
G4double rand;
G4ThreeVector p;
G4int nprims = fPrimitives.size();
std::pair<G4VSolid *, G4Transform3D> prim;
do // Loop checking, 13.08.2015, G.Cosmo
// Get list of primitives and find the total area of their surfaces
//
if (nprims == 0)
{
rand = G4UniformRand();
if (rand < GetAreaRatio()) { p = fPtrSolidA->GetPointOnSurface(); }
else { p = fPtrSolidB->GetPointOnSurface(); }
} while (Inside(p) != kSurface);
GetListOfPrimitives(fPrimitives, G4Transform3D());
nprims = fPrimitives.size();
fPrimitivesSurfaceArea = 0.;
for (G4int i=0; i<nprims; i++)
{
fPrimitivesSurfaceArea += fPrimitives[i].first->GetSurfaceArea();
}
}
// Select random primitive, get random point on its surface and
// check that the point belongs to the surface of the solid
//
G4ThreeVector p;
for (G4int k=0; k<1000000; k++) // try 1000000 times
{
G4double rand = fPrimitivesSurfaceArea * G4UniformRand();
G4double area = 0.;
for (G4int i=0; i<nprims; i++)
{
prim = fPrimitives[i];
area += prim.first->GetSurfaceArea();
if (rand < area) break;
}
p = prim.first->GetPointOnSurface();
p = prim.second * G4Point3D(p);
if (Inside(p) == kSurface) return p;
}
std::ostringstream message;
message << "Solid - " << GetName() << "\n"
<< "All attempts to generate a point on the surface have failed.\n"
<< "Returning point from the last unsuccessful attempt!";
G4Exception("G4BooleanSolid::GetPointOnSurface()",
"GeomSolids1001", JustWarning, message);
return p;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4DisplacedSolid.cc 84211 2014-10-10 14:47:30Z gcosmo $
// $Id: G4DisplacedSolid.cc 97300 2016-06-01 09:27:19Z gcosmo $
//
// Implementation for G4DisplacedSolid class for boolean
// operations between other solids
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4IntersectionSolid.cc 92010 2015-08-13 10:07:52Z gcosmo $
// $Id: G4IntersectionSolid.cc 95390 2016-02-08 14:46:28Z gcosmo $
//
// Implementation of methods for the class G4IntersectionSolid
//
@@ -158,10 +158,6 @@ G4IntersectionSolid::CalculateExtent(const EAxis pAxis,
pMin = std::max( minA, minB );
pMax = std::min( maxA, maxB );
out = (pMax > pMin); // true;
#ifdef G4BOOLDEBUG
// G4cout.precision(16);
// G4cout<<"pMin = "<<pMin<<"; pMax = "<<pMax<<G4endl;
#endif
}
else out = false;
@@ -0,0 +1,403 @@
//
// ********************************************************************
// * 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:$
//
// Implementation for G4ScaledSolid class
//
// History:
//
// 27.10.15 G.Cosmo: created, based on implementation also provided in Root
//
// --------------------------------------------------------------------
#include "G4ScaledSolid.hh"
#include "G4BoundingEnvelope.hh"
#include "G4VPVParameterisation.hh"
#include "G4ScaleTransform.hh"
#include "G4VGraphicsScene.hh"
#include "G4Polyhedron.hh"
///////////////////////////////////////////////////////////////////
//
// Constructor
//
G4ScaledSolid::G4ScaledSolid( const G4String& pName,
G4VSolid* pSolid ,
const G4Scale3D& pScale )
: G4VSolid(pName), fPtrSolid(pSolid),
fRebuildPolyhedron(false), fpPolyhedron(0)
{
fScale = new G4ScaleTransform(pScale);
}
///////////////////////////////////////////////////////////////////
//
// Fake default constructor - sets only member data and allocates memory
// for usage restricted to object persistency.
//
G4ScaledSolid::G4ScaledSolid( __void__& a )
: G4VSolid(a), fPtrSolid(0), fScale(0),
fRebuildPolyhedron(false), fpPolyhedron(0)
{
}
///////////////////////////////////////////////////////////////////
//
// Destructor
//
G4ScaledSolid::~G4ScaledSolid()
{
delete fpPolyhedron; fpPolyhedron= 0;
delete fScale; fScale= 0;
}
///////////////////////////////////////////////////////////////
//
// Copy constructor
//
G4ScaledSolid::G4ScaledSolid(const G4ScaledSolid& rhs)
: G4VSolid (rhs), fPtrSolid(rhs.fPtrSolid),
fRebuildPolyhedron(false), fpPolyhedron(0)
{
fScale = new G4ScaleTransform(*(rhs.fScale));
}
///////////////////////////////////////////////////////////////
//
// Assignment operator
//
G4ScaledSolid& G4ScaledSolid::operator = (const G4ScaledSolid& rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4VSolid::operator=(rhs);
// Copy data
//
fPtrSolid = rhs.fPtrSolid;
delete fScale;
fScale = new G4ScaleTransform(*(rhs.fScale));
fRebuildPolyhedron = false;
delete fpPolyhedron; fpPolyhedron= 0;
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Return original solid not scaled
//
G4VSolid* G4ScaledSolid::GetUnscaledSolid() const
{
return fPtrSolid;
}
///////////////////////////////////////////////////////////////
//
// CalculateExtent
//
G4bool
G4ScaledSolid::CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin,
G4double& pMax ) const
{
G4VoxelLimits unLimit;
G4AffineTransform unTransform;
// Find bounding box of unscaled solid
G4double x1,x2,y1,y2,z1,z2;
fPtrSolid->CalculateExtent(kXAxis,unLimit,unTransform,x1,x2);
fPtrSolid->CalculateExtent(kYAxis,unLimit,unTransform,y1,y2);
fPtrSolid->CalculateExtent(kZAxis,unLimit,unTransform,z1,z2);
G4BoundingEnvelope bbox(G4Point3D(x1,y1,z1),
G4Point3D(x2,y2,z2),kCarTolerance);
// Set combined transformation
G4Transform3D transform3D =
G4Transform3D(pTransform.NetRotation().inverse(),
pTransform.NetTranslation())*GetScaleTransform();
// Find extent
return bbox.CalculateExtent(pAxis,pVoxelLimit,transform3D,pMin,pMax);
}
/////////////////////////////////////////////////////
//
// Inside
//
EInside G4ScaledSolid::Inside(const G4ThreeVector& p) const
{
return fPtrSolid->Inside(fScale->Transform(p));
}
//////////////////////////////////////////////////////////////
//
// SurfaceNormal
//
G4ThreeVector
G4ScaledSolid::SurfaceNormal( const G4ThreeVector& p ) const
{
// Transform point to unscaled shape frame
G4ThreeVector newPoint;
fScale->Transform(p, newPoint);
// Compute normal in unscaled frame
G4ThreeVector newNormal = fPtrSolid->SurfaceNormal(newPoint);
G4ThreeVector normal;
// Convert normal to scaled frame
fScale->InverseTransformNormal(newNormal, normal);
return normal/normal.mag();
}
/////////////////////////////////////////////////////////////
//
// The same algorithm as in DistanceToIn(p)
//
G4double
G4ScaledSolid::DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const
{
// Transform point and direction to unscaled shape frame
G4ThreeVector newPoint;
fScale->Transform(p, newPoint);
// Direction is un-normalized after scale transformation
G4ThreeVector newDirection;
fScale->Transform(v, newDirection);
newDirection = newDirection/newDirection.mag();
// Compute distance in unscaled system
G4double dist = fPtrSolid->DistanceToIn(newPoint,newDirection);
// Return converted distance to global
return fScale->InverseTransformDistance(dist, newDirection);
}
////////////////////////////////////////////////////////
//
// Approximate nearest distance from the point p to the solid from outside
//
G4double
G4ScaledSolid::DistanceToIn( const G4ThreeVector& p ) const
{
// Transform point to unscaled shape frame
G4ThreeVector newPoint;
fScale->Transform(p, newPoint);
// Compute unscaled safety, then scale it.
G4double dist = fPtrSolid->DistanceToIn(newPoint);
return fScale->InverseTransformDistance(dist);
}
//////////////////////////////////////////////////////////
//
// The same algorithm as DistanceToOut(p)
//
G4double
G4ScaledSolid::DistanceToOut( const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n ) const
{
// Transform point and direction to unscaled shape frame
G4ThreeVector newPoint;
fScale->Transform(p, newPoint);
// Direction is un-normalized after scale transformation
G4ThreeVector newDirection;
fScale->Transform(v, newDirection);
newDirection = newDirection/newDirection.mag();
// Compute distance in unscaled system
G4ThreeVector solNorm;
G4double dist = fPtrSolid->DistanceToOut(newPoint,newDirection,
calcNorm,validNorm,&solNorm);
if(calcNorm)
{
G4ThreeVector normal;
fScale->TransformNormal(solNorm, normal);
*n = normal/normal.mag();
}
// Return distance converted to global
return fScale->InverseTransformDistance(dist, newDirection);
}
//////////////////////////////////////////////////////////////
//
// Approximate nearest distance from the point p to the solid from inside
//
G4double
G4ScaledSolid::DistanceToOut( const G4ThreeVector& p ) const
{
// Transform point to unscaled shape frame
G4ThreeVector newPoint;
fScale->Transform(p, newPoint);
// Compute unscaled safety, then scale it.
G4double dist = fPtrSolid->DistanceToOut(newPoint);
return fScale->InverseTransformDistance(dist);
}
//////////////////////////////////////////////////////////////
//
// ComputeDimensions
//
void
G4ScaledSolid::ComputeDimensions( G4VPVParameterisation*,
const G4int,
const G4VPhysicalVolume* )
{
DumpInfo();
G4Exception("G4ScaledSolid::ComputeDimensions()",
"GeomSolids0001", FatalException,
"Method not applicable in this context!");
}
//////////////////////////////////////////////////////////////////////////
//
// Returns a point (G4ThreeVector) randomly and uniformly selected
// on the solid surface
//
G4ThreeVector G4ScaledSolid::GetPointOnSurface() const
{
return fScale->InverseTransform(fPtrSolid->GetPointOnSurface());
}
//////////////////////////////////////////////////////////////////////////
//
// Return object type name
//
G4GeometryType G4ScaledSolid::GetEntityType() const
{
return G4String("G4ScaledSolid");
}
//////////////////////////////////////////////////////////////////////////
//
// Make a clone of the object
//
G4VSolid* G4ScaledSolid::Clone() const
{
return new G4ScaledSolid(*this);
}
//////////////////////////////////////////////////////////////////////////
//
// Returning the scaling transformation
//
G4Scale3D G4ScaledSolid::GetScaleTransform() const
{
return G4Scale3D(fScale->GetScale().x(),
fScale->GetScale().y(),
fScale->GetScale().z());
}
//////////////////////////////////////////////////////////////////////////
//
// Setting the scaling transformation
//
void G4ScaledSolid::SetScaleTransform(const G4Scale3D& scale)
{
if (fScale) { delete fScale; }
fScale = new G4ScaleTransform(scale);
fRebuildPolyhedron = true;
}
//////////////////////////////////////////////////////////////////////////
//
// Stream object contents to an output stream
//
std::ostream& G4ScaledSolid::StreamInfo(std::ostream& os) const
{
os << "-----------------------------------------------------------\n"
<< " *** Dump for Scaled solid - " << GetName() << " ***\n"
<< " ===================================================\n"
<< " Solid type: " << GetEntityType() << "\n"
<< " Parameters of constituent solid: \n"
<< "===========================================================\n";
fPtrSolid->StreamInfo(os);
os << "===========================================================\n"
<< " Scaling: \n"
<< " Scale transformation : \n"
<< " " << fScale->GetScale().x() << ", "
<< fScale->GetScale().y() << ", "
<< fScale->GetScale().z() << "\n"
<< "===========================================================\n";
return os;
}
//////////////////////////////////////////////////////////////////////////
//
// DescribeYourselfTo
//
void
G4ScaledSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
{
scene.AddSolid (*this);
}
//////////////////////////////////////////////////////////////////////////
//
// CreatePolyhedron
//
G4Polyhedron*
G4ScaledSolid::CreatePolyhedron () const
{
G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron();
polyhedron->Transform(GetScaleTransform());
return polyhedron;
}
//////////////////////////////////////////////////////////////////////////
//
// GetPolyhedron
//
G4Polyhedron* G4ScaledSolid::GetPolyhedron () const
{
if (!fpPolyhedron ||
fRebuildPolyhedron ||
fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
fpPolyhedron->GetNumberOfRotationSteps())
{
fpPolyhedron = CreatePolyhedron();
fRebuildPolyhedron = false;
}
return fpPolyhedron;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4SubtractionSolid.cc 92010 2015-08-13 10:07:52Z gcosmo $
// $Id: G4SubtractionSolid.cc 95390 2016-02-08 14:46:28Z gcosmo $
//
// Implementation of methods for the class G4IntersectionSolid
//
@@ -169,12 +169,13 @@ EInside G4SubtractionSolid::Inside( const G4ThreeVector& p ) const
}
else
{
static const G4double rtol
= 1000.0*G4GeometryTolerance::GetInstance()->GetRadialTolerance();
if(( positionA == kInside && positionB == kSurface) ||
( positionB == kOutside && positionA == kSurface) ||
( positionA == kSurface && positionB == kSurface &&
( fPtrSolidA->SurfaceNormal(p) -
fPtrSolidB->SurfaceNormal(p) ).mag2() >
1000.0*G4GeometryTolerance::GetInstance()->GetRadialTolerance() ) )
fPtrSolidB->SurfaceNormal(p) ).mag2() > rtol ) )
{
return kSurface;
}
@@ -92,6 +92,58 @@ G4UMultiUnion& G4UMultiUnion::operator=(const G4UMultiUnion &source)
}
//////////////////////////////////////////////////////////////////////////
//
// Accessors & modifiers
//
void G4UMultiUnion::AddNode(G4VSolid& solid, G4Transform3D& trans)
{
HepGeom::Rotate3D rot;
HepGeom::Translate3D transl ;
HepGeom::Scale3D scale;
trans.getDecomposition(scale,rot,transl);
G4ThreeVector pos = transl.getTranslation();
UTransform3D tr;
tr.fRot[0] = rot.xx(); tr.fRot[1] = rot.xy(); tr.fRot[2] = rot.xz();
tr.fRot[3] = rot.yx(); tr.fRot[4] = rot.yy(); tr.fRot[5] = rot.yz();
tr.fRot[6] = rot.zx(); tr.fRot[7] = rot.zy(); tr.fRot[8] = rot.zz();
tr.fTr = UVector3(pos.x(), pos.y(), pos.z());
GetShape()->AddNode(*(static_cast<G4USolid&>(solid).GetSolid()), tr);
}
G4Transform3D* G4UMultiUnion::GetTransformation(G4int index) const
{
UTransform3D tr = GetShape()->GetTransformation(index);
G4RotationMatrix
rot(CLHEP::HepRep3x3(tr.fRot[0], tr.fRot[1], tr.fRot[2],
tr.fRot[3], tr.fRot[4], tr.fRot[5],
tr.fRot[6], tr.fRot[7], tr.fRot[8]));
G4ThreeVector transl(tr.fTr.x(), tr.fTr.y(), tr.fTr.z());
return new G4Transform3D(rot, transl);
}
G4VSolid* G4UMultiUnion::GetSolid(G4int index) const
{
VUSolid* solid = GetShape()->GetSolid(index);
return new G4USolid(solid->GetName(), solid);
}
G4int G4UMultiUnion::GetNumberOfSolids()const
{
return GetShape()->GetNumberOfSolids();
}
void G4UMultiUnion::Voxelize()
{
GetShape()->Voxelize();
}
//////////////////////////////////////////////////////////////////////////
//
// CreatePolyhedron
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4UnionSolid.cc 92010 2015-08-13 10:07:52Z gcosmo $
// $Id: G4UnionSolid.cc 95390 2016-02-08 14:46:28Z gcosmo $
//
// Implementation of methods for the class G4IntersectionSolid
//
@@ -173,13 +173,14 @@ EInside G4UnionSolid::Inside( const G4ThreeVector& p ) const
EInside positionA = fPtrSolidA->Inside(p);
if (positionA == kInside) { return kInside; }
static const G4double rtol
= 1000*G4GeometryTolerance::GetInstance()->GetRadialTolerance();
EInside positionB = fPtrSolidB->Inside(p);
if( positionB == kInside ||
( positionA == kSurface && positionB == kSurface &&
( fPtrSolidA->SurfaceNormal(p) +
fPtrSolidB->SurfaceNormal(p) ).mag2() <
1000*G4GeometryTolerance::GetInstance()->GetRadialTolerance() ) )
fPtrSolidB->SurfaceNormal(p) ).mag2() < rtol ) )
{
return kInside;
}
+19 -1
View File
@@ -1,4 +1,4 @@
$Id: History 93494 2015-10-23 10:05:09Z gcosmo $
$Id: History 97008 2016-05-20 08:57:10Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -17,6 +17,24 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
May 20, 2016 G.Cosmo geom-csg-V10-02-04
- Moved accessors and modifiers in USolids wrappers to be not inlined.
Required modification in order to allow correct dispatching to VecGeom
types.
April 15, 2016 G.Cosmo geom-csg-V10-02-03
- Added flag in USolids wrappers for partial use of USolids/VecGeom types.
April 5, 2016 J.Allison geom-csg-V10-02-02
- G4Orb.cc: Fixed typo in G4Exception message.
March 31, 2016 G.Cosmo geom-csg-V10-02-01
- Added overloaded CreatePolyhedron() method to USolids wrappers.
It is now possible to visualize supported VecGeom shapes.
March 10, 2016 G.Cosmo geom-csg-V10-02-00
- Added overloaded GetEntityType() method to USolids wrappers.
October 23, 2015 G.Cosmo geom-csg-V10-01-10
- Fixed Coverity defect in G4CutTubs::GetMaxMinZ().
+14 -33
View File
@@ -44,9 +44,10 @@
#include "G4USolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UBox.hh"
#include "G4Polyhedron.hh"
class G4UBox : public G4USolid
@@ -66,13 +67,17 @@ class G4UBox : public G4USolid
inline UBox* GetShape() const;
inline G4double GetXHalfLength() const;
inline G4double GetYHalfLength() const;
inline G4double GetZHalfLength() const;
G4double GetXHalfLength() const;
G4double GetYHalfLength() const;
G4double GetZHalfLength() const;
inline void SetXHalfLength(G4double dx);
inline void SetYHalfLength(G4double dy);
inline void SetZHalfLength(G4double dz);
void SetXHalfLength(G4double dx);
void SetYHalfLength(G4double dy);
void SetZHalfLength(G4double dz);
inline G4GeometryType GetEntityType() const;
G4Polyhedron* CreatePolyhedron() const;
public: // without description
@@ -95,33 +100,9 @@ inline UBox* G4UBox::GetShape() const
return (UBox*) fShape;
}
inline G4double G4UBox::GetXHalfLength() const
inline G4GeometryType G4UBox::GetEntityType() const
{
return GetShape()->GetXHalfLength();
}
inline G4double G4UBox::GetYHalfLength() const
{
return GetShape()->GetYHalfLength();
}
inline G4double G4UBox::GetZHalfLength() const
{
return GetShape()->GetZHalfLength();
}
inline void G4UBox::SetXHalfLength(G4double dx)
{
GetShape()->SetXHalfLength(dx);
fRebuildPolyhedron = true;
}
inline void G4UBox::SetYHalfLength(G4double dy)
{
GetShape()->SetYHalfLength(dy);
fRebuildPolyhedron = true;
}
inline void G4UBox::SetZHalfLength(G4double dz)
{
GetShape()->SetZHalfLength(dz);
fRebuildPolyhedron = true;
return "G4Box";
}
#endif // G4GEOM_USE_USOLIDS
+22 -77
View File
@@ -45,9 +45,10 @@
#include "G4USolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UCons.hh"
#include "G4Polyhedron.hh"
class G4UCons : public G4USolid
@@ -71,21 +72,25 @@ class G4UCons : public G4USolid
inline UCons* GetShape() const;
inline G4double GetInnerRadiusMinusZ() const;
inline G4double GetOuterRadiusMinusZ() const;
inline G4double GetInnerRadiusPlusZ() const;
inline G4double GetOuterRadiusPlusZ() const;
inline G4double GetZHalfLength() const;
inline G4double GetStartPhiAngle() const;
inline G4double GetDeltaPhiAngle() const;
G4double GetInnerRadiusMinusZ() const;
G4double GetOuterRadiusMinusZ() const;
G4double GetInnerRadiusPlusZ() const;
G4double GetOuterRadiusPlusZ() const;
G4double GetZHalfLength() const;
G4double GetStartPhiAngle() const;
G4double GetDeltaPhiAngle() const;
inline void SetInnerRadiusMinusZ (G4double Rmin1 );
inline void SetOuterRadiusMinusZ (G4double Rmax1 );
inline void SetInnerRadiusPlusZ (G4double Rmin2 );
inline void SetOuterRadiusPlusZ (G4double Rmax2 );
inline void SetZHalfLength (G4double newDz );
inline void SetStartPhiAngle (G4double newSPhi, G4bool trig=true);
inline void SetDeltaPhiAngle (G4double newDPhi);
void SetInnerRadiusMinusZ (G4double Rmin1 );
void SetOuterRadiusMinusZ (G4double Rmax1 );
void SetInnerRadiusPlusZ (G4double Rmin2 );
void SetOuterRadiusPlusZ (G4double Rmax2 );
void SetZHalfLength (G4double newDz );
void SetStartPhiAngle (G4double newSPhi, G4bool trig=true);
void SetDeltaPhiAngle (G4double newDPhi);
inline G4GeometryType GetEntityType() const;
G4Polyhedron* CreatePolyhedron() const;
public: // without description
@@ -108,69 +113,9 @@ inline UCons* G4UCons::GetShape() const
return (UCons*) fShape;
}
inline G4double G4UCons::GetInnerRadiusMinusZ() const
inline G4GeometryType G4UCons::GetEntityType() const
{
return GetShape()->GetInnerRadiusMinusZ();
}
inline G4double G4UCons::GetOuterRadiusMinusZ() const
{
return GetShape()->GetOuterRadiusMinusZ();
}
inline G4double G4UCons::GetInnerRadiusPlusZ() const
{
return GetShape()->GetInnerRadiusPlusZ();
}
inline G4double G4UCons::GetOuterRadiusPlusZ() const
{
return GetShape()->GetOuterRadiusPlusZ();
}
inline G4double G4UCons::GetZHalfLength() const
{
return GetShape()->GetZHalfLength();
}
inline G4double G4UCons::GetStartPhiAngle() const
{
return GetShape()->GetStartPhiAngle();
}
inline G4double G4UCons::GetDeltaPhiAngle() const
{
return GetShape()->GetDeltaPhiAngle();
}
inline void G4UCons::SetInnerRadiusMinusZ(G4double Rmin1)
{
GetShape()->SetInnerRadiusMinusZ(Rmin1);
fRebuildPolyhedron = true;
}
inline void G4UCons::SetOuterRadiusMinusZ(G4double Rmax1)
{
GetShape()->SetOuterRadiusMinusZ(Rmax1);
fRebuildPolyhedron = true;
}
inline void G4UCons::SetInnerRadiusPlusZ(G4double Rmin2)
{
GetShape()->SetInnerRadiusPlusZ(Rmin2);
fRebuildPolyhedron = true;
}
inline void G4UCons::SetOuterRadiusPlusZ(G4double Rmax2)
{
GetShape()->SetOuterRadiusPlusZ(Rmax2);
fRebuildPolyhedron = true;
}
inline void G4UCons::SetZHalfLength(G4double newDz)
{
GetShape()->SetZHalfLength(newDz);
fRebuildPolyhedron = true;
}
inline void G4UCons::SetStartPhiAngle(G4double newSPhi, G4bool trig)
{
GetShape()->SetStartPhiAngle(newSPhi, trig);
fRebuildPolyhedron = true;
}
inline void G4UCons::SetDeltaPhiAngle(G4double newDPhi)
{
GetShape()->SetDeltaPhiAngle(newDPhi);
fRebuildPolyhedron = true;
return "G4Cons";
}
#endif // G4GEOM_USE_USOLIDS
+10 -11
View File
@@ -44,9 +44,10 @@
#include "G4USolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UOrb.hh"
#include "G4Polyhedron.hh"
class G4UOrb : public G4USolid
@@ -65,8 +66,12 @@ class G4UOrb : public G4USolid
inline UOrb* GetShape() const;
inline G4double GetRadius() const;
inline void SetRadius(G4double newRmax);
G4double GetRadius() const;
void SetRadius(G4double newRmax);
inline G4GeometryType GetEntityType() const;
G4Polyhedron* CreatePolyhedron() const;
public: // without description
@@ -89,15 +94,9 @@ inline UOrb* G4UOrb::GetShape() const
return (UOrb*) fShape;
}
inline G4double G4UOrb::GetRadius() const
inline G4GeometryType G4UOrb::GetEntityType() const
{
return GetShape()->GetRadius();
}
inline void G4UOrb::SetRadius(G4double newRmax)
{
GetShape()->SetRadius(newRmax);
fRebuildPolyhedron = true;
return "G4Orb";
}
#endif // G4GEOM_USE_USOLIDS
+21 -67
View File
@@ -44,9 +44,10 @@
#include "G4USolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "USphere.hh"
#include "G4Polyhedron.hh"
class G4USphere : public G4USolid
@@ -69,20 +70,24 @@ class G4USphere : public G4USolid
G4VSolid* Clone() const;
inline USphere* GetShape() const;
inline G4double GetInnerRadius () const;
inline G4double GetOuterRadius () const;
inline G4double GetStartPhiAngle () const;
inline G4double GetDeltaPhiAngle () const;
inline G4double GetStartThetaAngle() const;
inline G4double GetDeltaThetaAngle() const;
inline void SetInnerRadius (G4double newRMin);
inline void SetOuterRadius (G4double newRmax);
inline void SetStartPhiAngle (G4double newSphi, G4bool trig=true);
inline void SetDeltaPhiAngle (G4double newDphi);
inline void SetStartThetaAngle(G4double newSTheta);
inline void SetDeltaThetaAngle(G4double newDTheta);
G4double GetInnerRadius () const;
G4double GetOuterRadius () const;
G4double GetStartPhiAngle () const;
G4double GetDeltaPhiAngle () const;
G4double GetStartThetaAngle() const;
G4double GetDeltaThetaAngle() const;
void SetInnerRadius (G4double newRMin);
void SetOuterRadius (G4double newRmax);
void SetStartPhiAngle (G4double newSphi, G4bool trig=true);
void SetDeltaPhiAngle (G4double newDphi);
void SetStartThetaAngle(G4double newSTheta);
void SetDeltaThetaAngle(G4double newDTheta);
inline G4GeometryType GetEntityType() const;
G4Polyhedron* CreatePolyhedron() const;
public: // without description
@@ -106,60 +111,9 @@ inline USphere* G4USphere::GetShape() const
return (USphere*) fShape;
}
inline G4double G4USphere::GetInnerRadius() const
inline G4GeometryType G4USphere::GetEntityType() const
{
return GetShape()->GetInnerRadius();
}
inline G4double G4USphere::GetOuterRadius() const
{
return GetShape()->GetOuterRadius();
}
inline G4double G4USphere::GetStartPhiAngle() const
{
return GetShape()->GetStartPhiAngle();
}
inline G4double G4USphere::GetDeltaPhiAngle() const
{
return GetShape()->GetDeltaPhiAngle();
}
inline G4double G4USphere::GetStartThetaAngle() const
{
return GetShape()->GetStartThetaAngle();
}
inline G4double G4USphere::GetDeltaThetaAngle() const
{
return GetShape()->GetDeltaThetaAngle();
}
inline void G4USphere::SetInnerRadius(G4double newRMin)
{
GetShape()->SetInnerRadius(newRMin);
fRebuildPolyhedron = true;
}
inline void G4USphere::SetOuterRadius(G4double newRmax)
{
GetShape()->SetOuterRadius(newRmax);
fRebuildPolyhedron = true;
}
inline void G4USphere::SetStartPhiAngle(G4double newSphi, G4bool trig)
{
GetShape()->SetStartPhiAngle(newSphi, trig);
fRebuildPolyhedron = true;
}
inline void G4USphere::SetDeltaPhiAngle(G4double newDphi)
{
GetShape()->SetDeltaPhiAngle(newDphi);
fRebuildPolyhedron = true;
}
inline void G4USphere::SetStartThetaAngle(G4double newSTheta)
{
GetShape()->SetStartThetaAngle(newSTheta);
fRebuildPolyhedron = true;
}
inline void G4USphere::SetDeltaThetaAngle(G4double newDTheta)
{
GetShape()->SetDeltaThetaAngle(newDTheta);
fRebuildPolyhedron = true;
return "G4Sphere";
}
#endif // G4GEOM_USE_USOLIDS
+20 -76
View File
@@ -44,9 +44,10 @@
#include "G4USolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UTorus.hh"
#include "G4Polyhedron.hh"
class G4UTorus : public G4USolid
@@ -68,20 +69,24 @@ class G4UTorus : public G4USolid
inline UTorus* GetShape() const;
inline G4double GetRmin() const;
inline G4double GetRmax() const;
inline G4double GetRtor() const;
inline G4double GetSPhi() const;
inline G4double GetDPhi() const;
G4double GetRmin() const;
G4double GetRmax() const;
G4double GetRtor() const;
G4double GetSPhi() const;
G4double GetDPhi() const;
inline void SetRmin(G4double arg);
inline void SetRmax(G4double arg);
inline void SetRtor(G4double arg);
inline void SetSPhi(G4double arg);
inline void SetDPhi(G4double arg);
void SetRmin(G4double arg);
void SetRmax(G4double arg);
void SetRtor(G4double arg);
void SetSPhi(G4double arg);
void SetDPhi(G4double arg);
inline void SetAllParameters(G4double arg1, G4double arg2,
G4double arg3, G4double arg4, G4double arg5);
void SetAllParameters(G4double arg1, G4double arg2,
G4double arg3, G4double arg4, G4double arg5);
inline G4GeometryType GetEntityType() const;
G4Polyhedron* CreatePolyhedron() const;
public: // without description
@@ -104,70 +109,9 @@ inline UTorus* G4UTorus::GetShape() const
return (UTorus*) fShape;
}
inline G4double G4UTorus::GetRmin() const
inline G4GeometryType G4UTorus::GetEntityType() const
{
return GetShape()->GetRmin();
}
inline G4double G4UTorus::GetRmax() const
{
return GetShape()->GetRmax();
}
inline G4double G4UTorus::GetRtor() const
{
return GetShape()->GetRtor();
}
inline G4double G4UTorus::GetSPhi() const
{
return GetShape()->GetSPhi();
}
inline G4double G4UTorus::GetDPhi() const
{
return GetShape()->GetDPhi();
}
inline void G4UTorus::SetRmin(G4double arg)
{
GetShape()->SetRmin(arg);
fRebuildPolyhedron = true;
}
inline void G4UTorus::SetRmax(G4double arg)
{
GetShape()->SetRmax(arg);
fRebuildPolyhedron = true;
}
inline void G4UTorus::SetRtor(G4double arg)
{
GetShape()->SetRtor(arg);
fRebuildPolyhedron = true;
}
inline void G4UTorus::SetSPhi(G4double arg)
{
GetShape()->SetSPhi(arg);
fRebuildPolyhedron = true;
}
inline void G4UTorus::SetDPhi(G4double arg)
{
GetShape()->SetDPhi(arg);
fRebuildPolyhedron = true;
}
inline void G4UTorus::SetAllParameters(G4double arg1, G4double arg2,
G4double arg3, G4double arg4, G4double arg5)
{
GetShape()->SetRmin(arg1);
GetShape()->SetRmax(arg2);
GetShape()->SetRtor(arg3);
GetShape()->SetSPhi(arg4);
GetShape()->SetDPhi(arg5);
fRebuildPolyhedron = true;
return "G4Torus";
}
#endif // G4GEOM_USE_USOLIDS
+25 -90
View File
@@ -44,11 +44,11 @@
#include "G4USolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UTrap.hh"
class G4Polyhedron;
#include "G4Polyhedron.hh"
class G4UTrap : public G4USolid
{
@@ -105,24 +105,28 @@ class G4UTrap : public G4USolid
inline UTrap* GetShape() const;
inline G4double GetZHalfLength() const;
inline G4double GetYHalfLength1() const;
inline G4double GetXHalfLength1() const;
inline G4double GetXHalfLength2() const;
inline G4double GetTanAlpha1() const;
inline G4double GetYHalfLength2() const;
inline G4double GetXHalfLength3() const;
inline G4double GetXHalfLength4() const;
inline G4double GetTanAlpha2() const;
inline TrapSidePlane GetSidePlane(G4int n) const;
inline G4ThreeVector GetSymAxis() const;
G4double GetZHalfLength() const;
G4double GetYHalfLength1() const;
G4double GetXHalfLength1() const;
G4double GetXHalfLength2() const;
G4double GetTanAlpha1() const;
G4double GetYHalfLength2() const;
G4double GetXHalfLength3() const;
G4double GetXHalfLength4() const;
G4double GetTanAlpha2() const;
TrapSidePlane GetSidePlane(G4int n) const;
G4ThreeVector GetSymAxis() const;
inline void SetAllParameters(G4double pDz, G4double pTheta, G4double pPhi,
G4double pDy1, G4double pDx1, G4double pDx2,
G4double pAlp1,
G4double pDy2, G4double pDx3, G4double pDx4,
G4double pAlp2);
inline void SetPlanes(const G4ThreeVector pt[8]);
void SetAllParameters(G4double pDz, G4double pTheta, G4double pPhi,
G4double pDy1, G4double pDx1, G4double pDx2,
G4double pAlp1,
G4double pDy2, G4double pDx3, G4double pDx4,
G4double pAlp2);
void SetPlanes(const G4ThreeVector pt[8]);
inline G4GeometryType GetEntityType() const;
G4Polyhedron* CreatePolyhedron() const;
public: // without description
@@ -134,8 +138,6 @@ class G4UTrap : public G4USolid
G4UTrap(const G4UTrap& rhs);
G4UTrap& operator=(const G4UTrap& rhs);
// Copy constructor and assignment operator.
G4Polyhedron* CreatePolyhedron () const;
};
// --------------------------------------------------------------------
@@ -147,76 +149,9 @@ inline UTrap* G4UTrap::GetShape() const
return (UTrap*) fShape;
}
inline G4double G4UTrap::GetZHalfLength() const
inline G4GeometryType G4UTrap::GetEntityType() const
{
return GetShape()->GetZHalfLength();
}
inline G4double G4UTrap::GetYHalfLength1() const
{
return GetShape()->GetYHalfLength1();
}
inline G4double G4UTrap::GetXHalfLength1() const
{
return GetShape()->GetXHalfLength1();
}
inline G4double G4UTrap::GetXHalfLength2() const
{
return GetShape()->GetXHalfLength2();
}
inline G4double G4UTrap::GetTanAlpha1() const
{
return GetShape()->GetTanAlpha1();
}
inline G4double G4UTrap::GetYHalfLength2() const
{
return GetShape()->GetYHalfLength2();
}
inline G4double G4UTrap::GetXHalfLength3() const
{
return GetShape()->GetXHalfLength3();
}
inline G4double G4UTrap::GetXHalfLength4() const
{
return GetShape()->GetXHalfLength4();
}
inline G4double G4UTrap::GetTanAlpha2() const
{
return GetShape()->GetTanAlpha2();
}
inline TrapSidePlane G4UTrap::GetSidePlane(G4int n) const
{
UTrapSidePlane iplane = GetShape()->GetSidePlane(n);
TrapSidePlane oplane = {iplane.a, iplane.b, iplane.c, iplane.d };
return oplane;
}
inline G4ThreeVector G4UTrap::GetSymAxis() const
{
UVector3 axis = GetShape()->GetSymAxis();
return G4ThreeVector(axis.x(), axis.y(), axis.z());
}
inline
void G4UTrap::SetAllParameters(G4double pDz, G4double pTheta, G4double pPhi,
G4double pDy1, G4double pDx1, G4double pDx2,
G4double pAlp1,
G4double pDy2, G4double pDx3, G4double pDx4,
G4double pAlp2)
{
GetShape()->SetAllParameters(pDz, pTheta, pPhi,
pDy1, pDx1, pDx2, pAlp1,
pDy2, pDx3, pDx4, pAlp2);
fRebuildPolyhedron = true;
}
inline void G4UTrap::SetPlanes(const G4ThreeVector pt[8])
{
UVector3 upt[8];
for (unsigned int i=0; i<8; ++i)
{
upt[i] = UVector3(pt[i].x(), pt[i].y(), pt[i].z());
}
GetShape()->SetPlanes(upt);
fRebuildPolyhedron = true;
return "G4Trap";
}
#endif // G4GEOM_USE_USOLIDS
+20 -65
View File
@@ -44,9 +44,10 @@
#include "G4USolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UTrd.hh"
#include "G4Polyhedron.hh"
class G4UTrd : public G4USolid
@@ -69,21 +70,24 @@ class G4UTrd : public G4USolid
inline UTrd* GetShape() const;
inline G4double GetXHalfLength1() const;
inline G4double GetXHalfLength2() const;
inline G4double GetYHalfLength1() const;
inline G4double GetYHalfLength2() const;
inline G4double GetZHalfLength() const;
G4double GetXHalfLength1() const;
G4double GetXHalfLength2() const;
G4double GetYHalfLength1() const;
G4double GetYHalfLength2() const;
G4double GetZHalfLength() const;
inline void SetXHalfLength1(G4double val);
inline void SetXHalfLength2(G4double val);
inline void SetYHalfLength1(G4double val);
inline void SetYHalfLength2(G4double val);
inline void SetZHalfLength(G4double val);
void SetXHalfLength1(G4double val);
void SetXHalfLength2(G4double val);
void SetYHalfLength1(G4double val);
void SetYHalfLength2(G4double val);
void SetZHalfLength(G4double val);
inline void SetAllParameters(G4double pdx1, G4double pdx2,
G4double pdy1, G4double pdy2,
G4double pdz);
void SetAllParameters(G4double pdx1, G4double pdx2,
G4double pdy1, G4double pdy2, G4double pdz);
inline G4GeometryType GetEntityType() const;
G4Polyhedron* CreatePolyhedron() const;
public: // without description
@@ -106,58 +110,9 @@ inline UTrd* G4UTrd::GetShape() const
return (UTrd*) fShape;
}
inline G4double G4UTrd::GetXHalfLength1() const
inline G4GeometryType G4UTrd::GetEntityType() const
{
return GetShape()->GetXHalfLength1();
}
inline G4double G4UTrd::GetXHalfLength2() const
{
return GetShape()->GetXHalfLength2();
}
inline G4double G4UTrd::GetYHalfLength1() const
{
return GetShape()->GetYHalfLength1();
}
inline G4double G4UTrd::GetYHalfLength2() const
{
return GetShape()->GetYHalfLength2();
}
inline G4double G4UTrd::GetZHalfLength() const
{
return GetShape()->GetZHalfLength();
}
inline void G4UTrd::SetXHalfLength1(G4double val)
{
GetShape()->SetXHalfLength1(val);
fRebuildPolyhedron = true;
}
inline void G4UTrd::SetXHalfLength2(G4double val)
{
GetShape()->SetXHalfLength2(val);
fRebuildPolyhedron = true;
}
inline void G4UTrd::SetYHalfLength1(G4double val)
{
GetShape()->SetYHalfLength1(val);
fRebuildPolyhedron = true;
}
inline void G4UTrd::SetYHalfLength2(G4double val)
{
GetShape()->SetYHalfLength2(val);
fRebuildPolyhedron = true;
}
inline void G4UTrd::SetZHalfLength(G4double val)
{
GetShape()->SetZHalfLength(val);
fRebuildPolyhedron = true;
}
inline void G4UTrd::SetAllParameters(G4double pdx1, G4double pdx2,
G4double pdy1, G4double pdy2,
G4double pdz)
{
GetShape()->SetAllParameters(pdx1, pdx2, pdy1, pdy2, pdz);
fRebuildPolyhedron = true;
return "G4Trd";
}
#endif // G4GEOM_USE_USOLIDS
+18 -55
View File
@@ -46,9 +46,10 @@
#include "G4USolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UTubs.hh"
#include "G4Polyhedron.hh"
class G4UTubs : public G4USolid
@@ -73,18 +74,22 @@ class G4UTubs : public G4USolid
inline UTubs* GetShape() const;
inline G4double GetInnerRadius () const;
inline G4double GetOuterRadius () const;
inline G4double GetZHalfLength () const;
inline G4double GetStartPhiAngle () const;
inline G4double GetDeltaPhiAngle () const;
G4double GetInnerRadius () const;
G4double GetOuterRadius () const;
G4double GetZHalfLength () const;
G4double GetStartPhiAngle () const;
G4double GetDeltaPhiAngle () const;
inline void SetInnerRadius (G4double newRMin);
inline void SetOuterRadius (G4double newRMax);
inline void SetZHalfLength (G4double newDz);
inline void SetStartPhiAngle (G4double newSPhi, G4bool trig=true);
inline void SetDeltaPhiAngle (G4double newDPhi);
void SetInnerRadius (G4double newRMin);
void SetOuterRadius (G4double newRMax);
void SetZHalfLength (G4double newDz);
void SetStartPhiAngle (G4double newSPhi, G4bool trig=true);
void SetDeltaPhiAngle (G4double newDPhi);
inline G4GeometryType GetEntityType() const;
G4Polyhedron* CreatePolyhedron() const;
public: // without description
G4UTubs(__void__&);
@@ -107,51 +112,9 @@ inline UTubs* G4UTubs::GetShape() const
return (UTubs*) fShape;
}
inline G4double G4UTubs::GetInnerRadius() const
inline G4GeometryType G4UTubs::GetEntityType() const
{
return GetShape()->GetInnerRadius();
}
inline G4double G4UTubs::GetOuterRadius() const
{
return GetShape()->GetOuterRadius();
}
inline G4double G4UTubs::GetZHalfLength() const
{
return GetShape()->GetZHalfLength();
}
inline G4double G4UTubs::GetStartPhiAngle() const
{
return GetShape()->GetStartPhiAngle();
}
inline G4double G4UTubs::GetDeltaPhiAngle() const
{
return GetShape()->GetDeltaPhiAngle();
}
inline void G4UTubs::SetInnerRadius(G4double newRMin)
{
GetShape()->SetInnerRadius(newRMin);
fRebuildPolyhedron = true;
}
inline void G4UTubs::SetOuterRadius(G4double newRMax)
{
GetShape()->SetOuterRadius(newRMax);
fRebuildPolyhedron = true;
}
inline void G4UTubs::SetZHalfLength(G4double newDz)
{
GetShape()->SetZHalfLength(newDz);
fRebuildPolyhedron = true;
}
inline void G4UTubs::SetStartPhiAngle(G4double newSPhi, G4bool trig)
{
GetShape()->SetStartPhiAngle(newSPhi, trig);
fRebuildPolyhedron = true;
}
inline void G4UTubs::SetDeltaPhiAngle(G4double newDPhi)
{
GetShape()->SetDeltaPhiAngle(newDPhi);
fRebuildPolyhedron = true;
return "G4Tubs";
}
#endif // G4GEOM_USE_USOLIDS
+2 -2
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4Orb.cc 83572 2014-09-01 15:23:27Z gcosmo $
// $Id: G4Orb.cc 96318 2016-04-06 07:26:42Z gcosmo $
//
// class G4Orb
//
@@ -83,7 +83,7 @@ G4Orb::G4Orb( const G4String& pName, G4double pRmax )
if ( pRmax < 10*kCarTolerance )
{
G4Exception("G4Orb::G4Orb()", "GeomSolids0002", FatalException,
"Invalid radius > 10*kCarTolerance.");
"Invalid radius < 10*kCarTolerance.");
}
fRmaxTolerance = std::max( kRadTolerance, fEpsilon*fRmax);
+45 -1
View File
@@ -33,7 +33,7 @@
#include "G4Box.hh"
#include "G4UBox.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4VPVParameterisation.hh"
@@ -94,6 +94,39 @@ G4UBox& G4UBox::operator = (const G4UBox& rhs)
return *this;
}
////////////////////////////////////////////////////////////////////////
//
// Accessors & modifiers
G4double G4UBox::GetXHalfLength() const
{
return GetShape()->GetXHalfLength();
}
G4double G4UBox::GetYHalfLength() const
{
return GetShape()->GetYHalfLength();
}
G4double G4UBox::GetZHalfLength() const
{
return GetShape()->GetZHalfLength();
}
void G4UBox::SetXHalfLength(G4double dx)
{
GetShape()->SetXHalfLength(dx);
fRebuildPolyhedron = true;
}
void G4UBox::SetYHalfLength(G4double dy)
{
GetShape()->SetYHalfLength(dy);
fRebuildPolyhedron = true;
}
void G4UBox::SetZHalfLength(G4double dz)
{
GetShape()->SetZHalfLength(dz);
fRebuildPolyhedron = true;
}
////////////////////////////////////////////////////////////////////////
//
// Dispatch to parameterisation for replication mechanism dimension
@@ -115,4 +148,15 @@ G4VSolid* G4UBox::Clone() const
return new G4UBox(*this);
}
//////////////////////////////////////////////////////////////////////////
//
// Create polyhedron for visualization
G4Polyhedron* G4UBox::CreatePolyhedron() const
{
return new G4PolyhedronBox(GetXHalfLength(),
GetYHalfLength(),
GetZHalfLength());
}
#endif // G4GEOM_USE_USOLIDS
+86 -2
View File
@@ -33,10 +33,10 @@
#include "G4Cons.hh"
#include "G4UCons.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4VPVParameterisation.hh"
//////////////////////////////////////////////////////////////////////////
//
// constructor - check parameters, convert angles so 0<sphi+dpshi<=2_PI
@@ -96,6 +96,75 @@ G4UCons& G4UCons::operator = (const G4UCons& rhs)
return *this;
}
/////////////////////////////////////////////////////////////////////////
//
// Accessors and modifiers
G4double G4UCons::GetInnerRadiusMinusZ() const
{
return GetShape()->GetInnerRadiusMinusZ();
}
G4double G4UCons::GetOuterRadiusMinusZ() const
{
return GetShape()->GetOuterRadiusMinusZ();
}
G4double G4UCons::GetInnerRadiusPlusZ() const
{
return GetShape()->GetInnerRadiusPlusZ();
}
G4double G4UCons::GetOuterRadiusPlusZ() const
{
return GetShape()->GetOuterRadiusPlusZ();
}
G4double G4UCons::GetZHalfLength() const
{
return GetShape()->GetZHalfLength();
}
G4double G4UCons::GetStartPhiAngle() const
{
return GetShape()->GetStartPhiAngle();
}
G4double G4UCons::GetDeltaPhiAngle() const
{
return GetShape()->GetDeltaPhiAngle();
}
void G4UCons::SetInnerRadiusMinusZ(G4double Rmin1)
{
GetShape()->SetInnerRadiusMinusZ(Rmin1);
fRebuildPolyhedron = true;
}
void G4UCons::SetOuterRadiusMinusZ(G4double Rmax1)
{
GetShape()->SetOuterRadiusMinusZ(Rmax1);
fRebuildPolyhedron = true;
}
void G4UCons::SetInnerRadiusPlusZ(G4double Rmin2)
{
GetShape()->SetInnerRadiusPlusZ(Rmin2);
fRebuildPolyhedron = true;
}
void G4UCons::SetOuterRadiusPlusZ(G4double Rmax2)
{
GetShape()->SetOuterRadiusPlusZ(Rmax2);
fRebuildPolyhedron = true;
}
void G4UCons::SetZHalfLength(G4double newDz)
{
GetShape()->SetZHalfLength(newDz);
fRebuildPolyhedron = true;
}
void G4UCons::SetStartPhiAngle(G4double newSPhi, G4bool trig)
{
GetShape()->SetStartPhiAngle(newSPhi, trig);
fRebuildPolyhedron = true;
}
void G4UCons::SetDeltaPhiAngle(G4double newDPhi)
{
GetShape()->SetDeltaPhiAngle(newDPhi);
fRebuildPolyhedron = true;
}
/////////////////////////////////////////////////////////////////////////
//
// Dispatch to parameterisation for replication mechanism dimension
@@ -117,4 +186,19 @@ G4VSolid* G4UCons::Clone() const
return new G4UCons(*this);
}
//////////////////////////////////////////////////////////////////////////
//
// Create polyhedron for visualization
G4Polyhedron* G4UCons::CreatePolyhedron() const
{
return new G4PolyhedronCons(GetInnerRadiusMinusZ(),
GetOuterRadiusMinusZ(),
GetInnerRadiusPlusZ(),
GetOuterRadiusPlusZ(),
GetZHalfLength(),
GetStartPhiAngle(),
GetDeltaPhiAngle());
}
#endif // G4GEOM_USE_USOLIDS
+26 -1
View File
@@ -32,9 +32,10 @@
#include "G4Orb.hh"
#include "G4UOrb.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4VPVParameterisation.hh"
#include "G4PhysicalConstants.hh"
////////////////////////////////////////////////////////////////////////
//
@@ -90,6 +91,21 @@ G4UOrb& G4UOrb::operator = (const G4UOrb& rhs)
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Accessors & modifiers
G4double G4UOrb::GetRadius() const
{
return GetShape()->GetRadius();
}
void G4UOrb::SetRadius(G4double newRmax)
{
GetShape()->SetRadius(newRmax);
fRebuildPolyhedron = true;
}
//////////////////////////////////////////////////////////////////////////
//
// Dispatch to parameterisation for replication mechanism dimension
@@ -111,4 +127,13 @@ G4VSolid* G4UOrb::Clone() const
return new G4UOrb(*this);
}
//////////////////////////////////////////////////////////////////////////
//
// Create polyhedron for visualization
G4Polyhedron* G4UOrb::CreatePolyhedron() const
{
return new G4PolyhedronSphere(0., GetRadius(), 0., twopi, 0., pi);
}
#endif // G4GEOM_USE_USOLIDS
+75 -1
View File
@@ -33,7 +33,7 @@
#include "G4Sphere.hh"
#include "G4USphere.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4VPVParameterisation.hh"
@@ -95,6 +95,66 @@ G4USphere& G4USphere::operator = (const G4USphere& rhs)
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Accessors & modifiers
G4double G4USphere::GetInnerRadius() const
{
return GetShape()->GetInnerRadius();
}
G4double G4USphere::GetOuterRadius() const
{
return GetShape()->GetOuterRadius();
}
G4double G4USphere::GetStartPhiAngle() const
{
return GetShape()->GetStartPhiAngle();
}
G4double G4USphere::GetDeltaPhiAngle() const
{
return GetShape()->GetDeltaPhiAngle();
}
G4double G4USphere::GetStartThetaAngle() const
{
return GetShape()->GetStartThetaAngle();
}
G4double G4USphere::GetDeltaThetaAngle() const
{
return GetShape()->GetDeltaThetaAngle();
}
void G4USphere::SetInnerRadius(G4double newRMin)
{
GetShape()->SetInnerRadius(newRMin);
fRebuildPolyhedron = true;
}
void G4USphere::SetOuterRadius(G4double newRmax)
{
GetShape()->SetOuterRadius(newRmax);
fRebuildPolyhedron = true;
}
void G4USphere::SetStartPhiAngle(G4double newSphi, G4bool trig)
{
GetShape()->SetStartPhiAngle(newSphi, trig);
fRebuildPolyhedron = true;
}
void G4USphere::SetDeltaPhiAngle(G4double newDphi)
{
GetShape()->SetDeltaPhiAngle(newDphi);
fRebuildPolyhedron = true;
}
void G4USphere::SetStartThetaAngle(G4double newSTheta)
{
GetShape()->SetStartThetaAngle(newSTheta);
fRebuildPolyhedron = true;
}
void G4USphere::SetDeltaThetaAngle(G4double newDTheta)
{
GetShape()->SetDeltaThetaAngle(newDTheta);
fRebuildPolyhedron = true;
}
//////////////////////////////////////////////////////////////////////////
//
// Dispatch to parameterisation for replication mechanism dimension
@@ -116,4 +176,18 @@ G4VSolid* G4USphere::Clone() const
return new G4USphere(*this);
}
//////////////////////////////////////////////////////////////////////////
//
// Create polyhedron for visualization
G4Polyhedron* G4USphere::CreatePolyhedron() const
{
return new G4PolyhedronSphere(GetInnerRadius(),
GetOuterRadius(),
GetStartPhiAngle(),
GetDeltaPhiAngle(),
GetStartThetaAngle(),
GetDeltaThetaAngle());
}
#endif // G4GEOM_USE_USOLIDS
+84 -1
View File
@@ -35,7 +35,7 @@
#include "G4Torus.hh"
#include "G4UTorus.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4VPVParameterisation.hh"
@@ -90,6 +90,76 @@ G4UTorus& G4UTorus::operator = (const G4UTorus& rhs)
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Accessors & modifiers
G4double G4UTorus::GetRmin() const
{
return GetShape()->GetRmin();
}
G4double G4UTorus::GetRmax() const
{
return GetShape()->GetRmax();
}
G4double G4UTorus::GetRtor() const
{
return GetShape()->GetRtor();
}
G4double G4UTorus::GetSPhi() const
{
return GetShape()->GetSPhi();
}
G4double G4UTorus::GetDPhi() const
{
return GetShape()->GetDPhi();
}
void G4UTorus::SetRmin(G4double arg)
{
GetShape()->SetRmin(arg);
fRebuildPolyhedron = true;
}
void G4UTorus::SetRmax(G4double arg)
{
GetShape()->SetRmax(arg);
fRebuildPolyhedron = true;
}
void G4UTorus::SetRtor(G4double arg)
{
GetShape()->SetRtor(arg);
fRebuildPolyhedron = true;
}
void G4UTorus::SetSPhi(G4double arg)
{
GetShape()->SetSPhi(arg);
fRebuildPolyhedron = true;
}
void G4UTorus::SetDPhi(G4double arg)
{
GetShape()->SetDPhi(arg);
fRebuildPolyhedron = true;
}
void G4UTorus::SetAllParameters(G4double arg1, G4double arg2,
G4double arg3, G4double arg4, G4double arg5)
{
GetShape()->SetRmin(arg1);
GetShape()->SetRmax(arg2);
GetShape()->SetRtor(arg3);
GetShape()->SetSPhi(arg4);
GetShape()->SetDPhi(arg5);
fRebuildPolyhedron = true;
}
////////////////////////////////////////////////////////////////////////
//
// Dispatch to parameterisation for replication mechanism dimension
@@ -111,4 +181,17 @@ G4VSolid* G4UTorus::Clone() const
return new G4UTorus(*this);
}
//////////////////////////////////////////////////////////////////////////
//
// Create polyhedron for visualization
G4Polyhedron* G4UTorus::CreatePolyhedron() const
{
return new G4PolyhedronTorus(GetRmin(),
GetRmax(),
GetRtor(),
GetSPhi(),
GetDPhi());
}
#endif // G4GEOM_USE_USOLIDS
+77 -3
View File
@@ -33,10 +33,9 @@
#include "G4Trap.hh"
#include "G4UTrap.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4VPVParameterisation.hh"
#include "G4Polyhedron.hh"
/////////////////////////////////////////////////////////////////////////
//
@@ -133,6 +132,81 @@ G4UTrap& G4UTrap::operator = (const G4UTrap& rhs)
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Accessors & modifiers
G4double G4UTrap::GetZHalfLength() const
{
return GetShape()->GetZHalfLength();
}
G4double G4UTrap::GetYHalfLength1() const
{
return GetShape()->GetYHalfLength1();
}
G4double G4UTrap::GetXHalfLength1() const
{
return GetShape()->GetXHalfLength1();
}
G4double G4UTrap::GetXHalfLength2() const
{
return GetShape()->GetXHalfLength2();
}
G4double G4UTrap::GetTanAlpha1() const
{
return GetShape()->GetTanAlpha1();
}
G4double G4UTrap::GetYHalfLength2() const
{
return GetShape()->GetYHalfLength2();
}
G4double G4UTrap::GetXHalfLength3() const
{
return GetShape()->GetXHalfLength3();
}
G4double G4UTrap::GetXHalfLength4() const
{
return GetShape()->GetXHalfLength4();
}
G4double G4UTrap::GetTanAlpha2() const
{
return GetShape()->GetTanAlpha2();
}
TrapSidePlane G4UTrap::GetSidePlane(G4int n) const
{
UTrapSidePlane iplane = GetShape()->GetSidePlane(n);
TrapSidePlane oplane = {iplane.a, iplane.b, iplane.c, iplane.d };
return oplane;
}
G4ThreeVector G4UTrap::GetSymAxis() const
{
UVector3 axis = GetShape()->GetSymAxis();
return G4ThreeVector(axis.x(), axis.y(), axis.z());
}
void G4UTrap::SetAllParameters(G4double pDz, G4double pTheta, G4double pPhi,
G4double pDy1, G4double pDx1, G4double pDx2,
G4double pAlp1,
G4double pDy2, G4double pDx3, G4double pDx4,
G4double pAlp2)
{
GetShape()->SetAllParameters(pDz, pTheta, pPhi,
pDy1, pDx1, pDx2, pAlp1,
pDy2, pDx3, pDx4, pAlp2);
fRebuildPolyhedron = true;
}
void G4UTrap::SetPlanes(const G4ThreeVector pt[8])
{
UVector3 upt[8];
for (unsigned int i=0; i<8; ++i)
{
upt[i] = UVector3(pt[i].x(), pt[i].y(), pt[i].z());
}
GetShape()->SetPlanes(upt);
fRebuildPolyhedron = true;
}
/////////////////////////////////////////////////////////////////////////
//
// Dispatch to parameterisation for replication mechanism dimension
@@ -156,7 +230,7 @@ G4VSolid* G4UTrap::Clone() const
//////////////////////////////////////////////////////////////////////////
//
// CreatePolyhedron()
// Create polyhedron for visualization
//
G4Polyhedron* G4UTrap::CreatePolyhedron() const
{
+71 -1
View File
@@ -33,7 +33,7 @@
#include "G4Trd.hh"
#include "G4UTrd.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4VPVParameterisation.hh"
@@ -93,6 +93,63 @@ G4UTrd& G4UTrd::operator = (const G4UTrd& rhs)
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Accessors & modifiers
G4double G4UTrd::GetXHalfLength1() const
{
return GetShape()->GetXHalfLength1();
}
G4double G4UTrd::GetXHalfLength2() const
{
return GetShape()->GetXHalfLength2();
}
G4double G4UTrd::GetYHalfLength1() const
{
return GetShape()->GetYHalfLength1();
}
G4double G4UTrd::GetYHalfLength2() const
{
return GetShape()->GetYHalfLength2();
}
G4double G4UTrd::GetZHalfLength() const
{
return GetShape()->GetZHalfLength();
}
void G4UTrd::SetXHalfLength1(G4double val)
{
GetShape()->SetXHalfLength1(val);
fRebuildPolyhedron = true;
}
void G4UTrd::SetXHalfLength2(G4double val)
{
GetShape()->SetXHalfLength2(val);
fRebuildPolyhedron = true;
}
void G4UTrd::SetYHalfLength1(G4double val)
{
GetShape()->SetYHalfLength1(val);
fRebuildPolyhedron = true;
}
void G4UTrd::SetYHalfLength2(G4double val)
{
GetShape()->SetYHalfLength2(val);
fRebuildPolyhedron = true;
}
void G4UTrd::SetZHalfLength(G4double val)
{
GetShape()->SetZHalfLength(val);
fRebuildPolyhedron = true;
}
void G4UTrd::SetAllParameters(G4double pdx1, G4double pdx2,
G4double pdy1, G4double pdy2, G4double pdz)
{
GetShape()->SetAllParameters(pdx1, pdx2, pdy1, pdy2, pdz);
fRebuildPolyhedron = true;
}
/////////////////////////////////////////////////////////////////////////
//
// Dispatch to parameterisation for replication mechanism dimension
@@ -114,4 +171,17 @@ G4VSolid* G4UTrd::Clone() const
return new G4UTrd(*this);
}
//////////////////////////////////////////////////////////////////////////
//
// Create polyhedron for visualization
//
G4Polyhedron* G4UTrd::CreatePolyhedron() const
{
return new G4PolyhedronTrd2(GetXHalfLength1(),
GetXHalfLength2(),
GetYHalfLength1(),
GetYHalfLength2(),
GetZHalfLength());
}
#endif // G4GEOM_USE_USOLIDS
+65 -1
View File
@@ -33,7 +33,7 @@
#include "G4Tubs.hh"
#include "G4UTubs.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4VPVParameterisation.hh"
@@ -94,6 +94,57 @@ G4UTubs& G4UTubs::operator = (const G4UTubs& rhs)
return *this;
}
/////////////////////////////////////////////////////////////////////////
//
// Accessors and modifiers
G4double G4UTubs::GetInnerRadius() const
{
return GetShape()->GetInnerRadius();
}
G4double G4UTubs::GetOuterRadius() const
{
return GetShape()->GetOuterRadius();
}
G4double G4UTubs::GetZHalfLength() const
{
return GetShape()->GetZHalfLength();
}
G4double G4UTubs::GetStartPhiAngle() const
{
return GetShape()->GetStartPhiAngle();
}
G4double G4UTubs::GetDeltaPhiAngle() const
{
return GetShape()->GetDeltaPhiAngle();
}
void G4UTubs::SetInnerRadius(G4double newRMin)
{
GetShape()->SetInnerRadius(newRMin);
fRebuildPolyhedron = true;
}
void G4UTubs::SetOuterRadius(G4double newRMax)
{
GetShape()->SetOuterRadius(newRMax);
fRebuildPolyhedron = true;
}
void G4UTubs::SetZHalfLength(G4double newDz)
{
GetShape()->SetZHalfLength(newDz);
fRebuildPolyhedron = true;
}
void G4UTubs::SetStartPhiAngle(G4double newSPhi, G4bool trig)
{
GetShape()->SetStartPhiAngle(newSPhi, trig);
fRebuildPolyhedron = true;
}
void G4UTubs::SetDeltaPhiAngle(G4double newDPhi)
{
GetShape()->SetDeltaPhiAngle(newDPhi);
fRebuildPolyhedron = true;
}
/////////////////////////////////////////////////////////////////////////
//
// Dispatch to parameterisation for replication mechanism dimension
@@ -115,4 +166,17 @@ G4VSolid* G4UTubs::Clone() const
return new G4UTubs(*this);
}
//////////////////////////////////////////////////////////////////////////
//
// Create polyhedron for visualization
//
G4Polyhedron* G4UTubs::CreatePolyhedron() const
{
return new G4PolyhedronTubs(GetInnerRadius(),
GetOuterRadius(),
GetZHalfLength(),
GetStartPhiAngle(),
GetDeltaPhiAngle());
}
#endif // G4GEOM_USE_USOLIDS
+60 -2
View File
@@ -1,4 +1,4 @@
$Id: History 94457 2015-11-18 14:35:46Z gcosmo $
$Id: History 97069 2016-05-24 08:47:21Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -17,12 +17,70 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
24-May-2016 G.Cosmo (geom-specific-V10-02-11)
- Correction in G4UExtrudedSolid for definition of CreatePolyhedron().
20-May-2016 G.Cosmo (geom-specific-V10-02-10)
- Moved accessors and modifiers in USolids wrappers to be not inlined.
Required modification in order to allow correct dispatching to VecGeom
types.
15-Apr-2016 G.Cosmo (geom-specific-V10-02-09)
- Added flag in USolids wrappers for partial use of USolids/VecGeom types.
31-Mar-2016 G.Cosmo (geom-specific-V10-02-08, 07)
- Added overloaded CreatePolyhedron() method to USolids wrappers.
It is now possible to visualize supported VecGeom shapes.
- Added implementation of CreatePolyhedron() in UExtrudedSolid wrapper.
10-Mar-2016 G.Cosmo (geom-specific-V10-02-06)
- Added overloaded GetEntityType() method to USolids wrappers.
07-Mar-2016 E.Tcherniaev (geom-specific-V10-02-05)
- Fix in G4IntersectingCone for smaller precision constant in LineHitsCone1()
and LineHitsCone2(). Fixes issue observed in G4GenericPolycone.
Addressing problem report #1794.
03-Mar-2016 G.Cosmo (geom-specific-V10-02-04)
- Fixed compilation warnings for potential uninitialised values in
G4ExtrudedSolid::CheckPolygon() function introduced in previous tag.
03-Mar-2016 E.Tcherniaev (geom-specific-V10-02-03)
- Added 'const' qualifier for methods in G4ExtrudedSolid.
Added CheckPolygon() to remove collinear and coincident points from polygons.
- G4QuadrangularFacet: added exhaustive tests in constructor to catch potential
problems with a quadrangular facet: collinear vertices, non planar surface,
degenerate, concave or self intersecting quadrilateral.
- G4TriangularFacet: Improved test in constructor to detect degenerate (too
small or too narrow) triangles.
25-Feb-2016 E.Tcherniaev (geom-specific-V10-02-02)
- Correction in G4ExtrudedSolid::AddGeneralPolygonFacets() for precision
treatment in construction of tessels to avoid cases of collinear points
and consequent degenerating triangles.
Address problem report #1777.
- Use pre-computed kCarToleranceHalf constant in G4ExtrudedSolid, now
protected in G4TessellatedSolid.
- Improved algorithms for computation of area in G4TriangularFacet and
G4QuadrangularFacet. Added post-const qualifier to GetArea().
16-Feb-2016 G.Cosmo (geom-specific-V10-02-01)
- Revised implementation for GetSurfaceArea() and GetCubicVolume() in
G4GenericTrap (E.Tcherniaev).
- Protected debug warning in G4GenericTrap::SurfaceNormal() within G4SPECSDEBUG.
02-Feb-2016 E.Tcherniaev (geom-specific-V10-02-00)
- Fix in G4GenericTrap for compuation of extent.
Addressing problem report #1809.
- Use dot() in formula for computation of GetCubicVolume() in
G4TessellatedSolid.
18-Nov-2015 G.Cosmo (geom-specific-V10-01-15)
- Added specialised implementation for GetCubicVolume() in
G4TessellatedSolid (J.Allison).
29-Oct-2015 G.Cosmo (geom-specific-V10-01-14)
- Added debug printouts withing G4SPECSDEBUG in G4TessellatedSolid for
- Added debug printouts within G4SPECSDEBUG in G4TessellatedSolid for
DistanceToIn/Out(p,v) to identify potential wrong responses.
26-Oct-2015 G.Cosmo (geom-specific-V10-01-13)
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ExtrudedSolid.hh 83851 2014-09-19 10:12:12Z gcosmo $
// $Id: G4ExtrudedSolid.hh 95945 2016-03-03 09:54:38Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -57,6 +57,7 @@
// Author:
// Ivana Hrivnacova, IPN Orsay
//
// --------------------------------------------------------------------
#ifndef G4ExtrudedSolid_HH
@@ -86,7 +87,7 @@ class G4ExtrudedSolid : public G4TessellatedSolid
struct ZSection
{
ZSection(G4double z, G4TwoVector offset, G4double scale)
ZSection(G4double z, const G4TwoVector& offset, G4double scale)
: fZ(z), fOffset(offset), fScale(scale) {}
G4double fZ;
@@ -97,15 +98,15 @@ class G4ExtrudedSolid : public G4TessellatedSolid
public: // with description
G4ExtrudedSolid( const G4String& pName,
std::vector<G4TwoVector> polygon,
std::vector<ZSection> zsections);
const std::vector<G4TwoVector>& polygon,
const std::vector<ZSection>& zsections);
// General constructor
G4ExtrudedSolid( const G4String& pName,
std::vector<G4TwoVector> polygon,
const std::vector<G4TwoVector>& polygon,
G4double halfZ,
G4TwoVector off1, G4double scale1,
G4TwoVector off2, G4double scale2 );
const G4TwoVector& off1, G4double scale1,
const G4TwoVector& off2, G4double scale2 );
// Special constructor for solid with 2 z-sections
virtual ~G4ExtrudedSolid();
@@ -142,25 +143,34 @@ class G4ExtrudedSolid : public G4TessellatedSolid
// persistifiable objects.
G4ExtrudedSolid(const G4ExtrudedSolid& rhs);
G4ExtrudedSolid& operator=(const G4ExtrudedSolid& rhs);
G4ExtrudedSolid& operator=(const G4ExtrudedSolid& rhs);
// Copy constructor and assignment operator.
private:
void CheckPolygon(G4String& removedVertices);
void ComputeProjectionParameters();
G4ThreeVector GetVertex(G4int iz, G4int ind) const;
G4TwoVector ProjectPoint(const G4ThreeVector& point) const;
G4bool IsSameLine(G4TwoVector p,
G4TwoVector l1, G4TwoVector l2) const;
G4bool IsSameLineSegment(G4TwoVector p,
G4TwoVector l1, G4TwoVector l2) const;
G4bool IsSameSide(G4TwoVector p1, G4TwoVector p2,
G4TwoVector l1, G4TwoVector l2) const;
G4bool IsPointInside(G4TwoVector a, G4TwoVector b, G4TwoVector c,
G4TwoVector p) const;
G4double GetAngle(G4TwoVector p0, G4TwoVector pa, G4TwoVector pb) const;
G4bool IsSameLine(const G4TwoVector& p,
const G4TwoVector& l1,
const G4TwoVector& l2) const;
G4bool IsSameLineSegment(const G4TwoVector& p,
const G4TwoVector& l1,
const G4TwoVector& l2) const;
G4bool IsSameSide(const G4TwoVector& p1,
const G4TwoVector& p2,
const G4TwoVector& l1,
const G4TwoVector& l2) const;
G4bool IsPointInside(const G4TwoVector& a,
const G4TwoVector& b,
const G4TwoVector& c,
const G4TwoVector& p) const;
G4double GetAngle(const G4TwoVector& p0,
const G4TwoVector& pa,
const G4TwoVector& pb) const;
G4VFacet* MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const;
G4VFacet* MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const;
@@ -169,7 +179,6 @@ class G4ExtrudedSolid : public G4TessellatedSolid
G4bool MakeFacets();
G4bool IsConvex() const;
private:
G4int fNv;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GenericTrap.hh 83851 2014-09-19 10:12:12Z gcosmo $
// $Id: G4GenericTrap.hh 95592 2016-02-16 10:48:01Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -195,6 +195,10 @@ class G4GenericTrap : public G4VSolid
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3) const;
G4double GetFaceCubicVolume(const G4ThreeVector& p0,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3) const;
protected:
mutable G4bool fRebuildPolyhedron;
@@ -24,7 +24,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4QuadrangularFacet.hh 66356 2012-12-18 09:02:32Z gcosmo $
// $Id: G4QuadrangularFacet.hh 95801 2016-02-25 10:59:41Z gcosmo $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
@@ -90,7 +90,7 @@ class G4QuadrangularFacet : public G4VFacet
G4double &distFromSurface, G4ThreeVector &normal);
G4ThreeVector GetSurfaceNormal () const;
G4double GetArea ();
G4double GetArea () const;
G4ThreeVector GetPointOnFace () const;
G4GeometryType GetEntityType () const;
@@ -24,7 +24,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TessellatedSolid.hh 83572 2014-09-01 15:23:27Z gcosmo $
// $Id: G4TessellatedSolid.hh 95801 2016-02-25 10:59:41Z gcosmo $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
@@ -264,6 +264,10 @@ class G4TessellatedSolid : public G4VSolid
inline G4bool OutsideOfExtent(const G4ThreeVector &p,
G4double tolerance=0) const;
protected:
G4double kCarToleranceHalf;
private:
mutable G4bool fRebuildPolyhedron;
@@ -287,8 +291,6 @@ class G4TessellatedSolid : public G4VSolid
std::vector<G4ThreeVector> fRandir;
G4double kCarToleranceHalf;
G4int fMaxTries;
G4SurfaceVoxelizer fVoxels; // Pointer to the voxelized solid
@@ -24,7 +24,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TriangularFacet.hh 66356 2012-12-18 09:02:32Z gcosmo $
// $Id: G4TriangularFacet.hh 95801 2016-02-25 10:59:41Z gcosmo $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
@@ -86,7 +86,7 @@ class G4TriangularFacet : public G4VFacet
G4bool Intersect (const G4ThreeVector &p, const G4ThreeVector &v,
const G4bool outgoing, G4double &distance,
G4double &distFromSurface, G4ThreeVector &normal);
G4double GetArea ();
G4double GetArea () const;
G4ThreeVector GetPointOnFace () const;
G4ThreeVector GetSurfaceNormal () const;
@@ -45,10 +45,11 @@
#include "G4USolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UExtrudedSolid.hh"
#include "G4TwoVector.hh"
#include "G4Polyhedron.hh"
class G4UExtrudedSolid : public G4USolid
{
@@ -85,13 +86,15 @@ class G4UExtrudedSolid : public G4USolid
inline UExtrudedSolid* GetShape() const;
inline G4int GetNofVertices() const;
inline G4TwoVector GetVertex(G4int index) const;
inline std::vector<G4TwoVector> GetPolygon() const;
inline G4int GetNofZSections() const;
inline ZSection GetZSection(G4int index) const;
inline std::vector<ZSection> GetZSections() const;
G4int GetNofVertices() const;
G4TwoVector GetVertex(G4int index) const;
std::vector<G4TwoVector> GetPolygon() const;
G4int GetNofZSections() const;
ZSection GetZSection(G4int index) const;
std::vector<ZSection> GetZSections() const;
inline G4GeometryType GetEntityType() const;
public: // without description
G4UExtrudedSolid(__void__&);
@@ -102,6 +105,7 @@ class G4UExtrudedSolid : public G4USolid
G4UExtrudedSolid( const G4UExtrudedSolid& source );
G4UExtrudedSolid &operator=(const G4UExtrudedSolid& source);
// Copy constructor and assignment operator.
G4Polyhedron* CreatePolyhedron() const;
};
// --------------------------------------------------------------------
@@ -113,44 +117,11 @@ inline UExtrudedSolid* G4UExtrudedSolid::GetShape() const
return (UExtrudedSolid*) fShape;
}
inline G4int G4UExtrudedSolid::GetNofVertices() const
inline G4GeometryType G4UExtrudedSolid::GetEntityType() const
{
return GetShape()->GetNofVertices();
return "G4ExtrudedSolid";
}
inline G4TwoVector G4UExtrudedSolid::GetVertex(G4int i) const
{
UVector2 v = GetShape()->GetVertex(i);
return G4TwoVector(v.x, v.y);
}
inline std::vector<G4TwoVector> G4UExtrudedSolid::GetPolygon() const
{
std::vector<UVector2> pol = GetShape()->GetPolygon();
std::vector<G4TwoVector> v;
for (unsigned int i=0; i<pol.size(); ++i)
{
v.push_back(G4TwoVector(pol[i].x, pol[i].y));
}
return v;
}
inline G4int G4UExtrudedSolid::GetNofZSections() const
{
return GetShape()->GetNofZSections();
}
inline G4UExtrudedSolid::ZSection G4UExtrudedSolid::GetZSection(G4int i) const
{
return ZSection(GetShape()->GetZSection(i));
}
inline std::vector<G4UExtrudedSolid::ZSection> G4UExtrudedSolid::GetZSections() const
{
std::vector<UExtrudedSolid::ZSection> sv = GetShape()->GetZSections();
std::vector<G4UExtrudedSolid::ZSection> vec;
for (unsigned int i=0; i<sv.size(); ++i)
{
vec.push_back(ZSection(sv[i]));
}
return vec;
}
#endif // G4GEOM_USE_USOLIDS
#endif
@@ -45,7 +45,7 @@
#include "G4USolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UGenericPolycone.hh"
#include "G4PolyconeSide.hh"
@@ -65,12 +65,14 @@ class G4UGenericPolycone : public G4USolid
inline UGenericPolycone* GetShape() const;
inline G4double GetStartPhi() const;
inline G4double GetEndPhi() const;
inline G4bool IsOpen() const;
inline G4int GetNumRZCorner() const;
inline G4PolyconeSideRZ GetCorner(G4int index) const;
G4double GetStartPhi() const;
G4double GetEndPhi() const;
G4bool IsOpen() const;
G4int GetNumRZCorner() const;
G4PolyconeSideRZ GetCorner(G4int index) const;
inline G4GeometryType GetEntityType() const;
public: // without description
G4UGenericPolycone(__void__&);
@@ -93,28 +95,9 @@ inline UGenericPolycone* G4UGenericPolycone::GetShape() const
return (UGenericPolycone*) fShape;
}
inline G4double G4UGenericPolycone::GetStartPhi() const
inline G4GeometryType G4UGenericPolycone::GetEntityType() const
{
return GetShape()->GetStartPhi();
}
inline G4double G4UGenericPolycone::GetEndPhi() const
{
return GetShape()->GetEndPhi();
}
inline G4bool G4UGenericPolycone::IsOpen() const
{
return GetShape()->IsOpen();
}
inline G4int G4UGenericPolycone::GetNumRZCorner() const
{
return GetShape()->GetNumRZCorner();
}
inline G4PolyconeSideRZ G4UGenericPolycone::GetCorner(G4int index) const
{
UPolyconeSideRZ pside = GetShape()->GetCorner(index);
G4PolyconeSideRZ psiderz = { pside.r, pside.z };
return psiderz;
return "G4GenericPolycone";
}
#endif // G4GEOM_USE_USOLIDS
@@ -45,12 +45,12 @@
#include "G4USolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UGenericTrap.hh"
#include "G4TwoVector.hh"
class G4Polyhedron;
#include "G4Polyhedron.hh"
class G4UGenericTrap : public G4USolid
{
@@ -63,15 +63,17 @@ class G4UGenericTrap : public G4USolid
inline UGenericTrap* GetShape() const;
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);
inline void SetZHalfLength(G4double);
G4double GetZHalfLength() const;
G4int GetNofVertices() const;
G4TwoVector GetVertex(G4int index) const;
const std::vector<G4TwoVector>& GetVertices() const;
G4double GetTwistAngle(G4int index) const;
G4bool IsTwisted() const;
G4int GetVisSubdivisions() const;
void SetVisSubdivisions(G4int subdiv);
void SetZHalfLength(G4double);
inline G4GeometryType GetEntityType() const;
public: // without description
@@ -96,50 +98,9 @@ inline UGenericTrap* G4UGenericTrap::GetShape() const
return (UGenericTrap*) fShape;
}
inline G4double G4UGenericTrap::GetZHalfLength() const
inline G4GeometryType G4UGenericTrap::GetEntityType() const
{
return GetShape()->GetZHalfLength();
}
inline G4int G4UGenericTrap::GetNofVertices() const
{
return GetShape()->GetNofVertices();
}
inline G4TwoVector G4UGenericTrap::GetVertex(G4int index) const
{
UVector2 v = GetShape()->GetVertex(index);
return G4TwoVector(v.x, v.y);
}
inline const std::vector<G4TwoVector>& G4UGenericTrap::GetVertices() const
{
std::vector<UVector2> v = GetShape()->GetVertices();
static std::vector<G4TwoVector> vertices; vertices.clear();
for (size_t n=0; n<v.size(); ++n)
{
vertices.push_back(G4TwoVector(v[n].x,v[n].y));
}
return vertices;
}
inline G4double G4UGenericTrap::GetTwistAngle(G4int index) const
{
return GetShape()->GetTwistAngle(index);
}
inline G4bool G4UGenericTrap::IsTwisted() const
{
return GetShape()->IsTwisted();
}
inline G4int G4UGenericTrap::GetVisSubdivisions() const
{
return GetShape()->GetVisSubdivisions();
}
inline void G4UGenericTrap::SetVisSubdivisions(G4int subdiv)
{
GetShape()->SetVisSubdivisions(subdiv);
}
inline void G4UGenericTrap::SetZHalfLength(G4double halfZ)
{
GetShape()->SetZHalfLength(halfZ);
return "G4GenericTrap";
}
#endif // G4GEOM_USE_USOLIDS
@@ -45,40 +45,43 @@
#include "G4USolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UParaboloid.hh"
#include "G4Polyhedron.hh"
class G4UParaboloid : public G4USolid {
class G4UParaboloid : public G4USolid
{
public: // with description
public: // with description
G4UParaboloid(const G4String& name, G4double dz, G4double rlo, G4double rhi);
G4UParaboloid(const G4String& name, G4double dz,
G4double rlo,
G4double rhi);
~G4UParaboloid();
~G4UParaboloid();
G4VSolid* Clone() const;
G4VSolid* Clone() const;
inline UParaboloid* GetShape() const;
inline UParaboloid* GetShape() const;
G4double GetZHalfLength() const;
G4double GetRadiusMinusZ() const;
G4double GetRadiusPlusZ() const;
inline G4double GetZHalfLength() const;
inline G4double GetRadiusMinusZ() const;
inline G4double GetRadiusPlusZ() const;
inline G4GeometryType GetEntityType() const;
// inline G4bool Reset();
public: // without description
public: // without description
G4UParaboloid(__void__&);
G4UParaboloid(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4UParaboloid( const G4UParaboloid &source );
G4UParaboloid &operator=( const G4UParaboloid &source );
G4UParaboloid( const G4UParaboloid &source );
G4UParaboloid &operator=( const G4UParaboloid &source );
// Copy constructor and assignment operator.
// G4Polyhedron* CreatePolyhedron() const;
G4Polyhedron* CreatePolyhedron() const;
};
// --------------------------------------------------------------------
@@ -90,48 +93,10 @@ inline UParaboloid* G4UParaboloid::GetShape() const
return (UParaboloid*) fShape;
}
inline G4double G4UParaboloid::GetZHalfLength() const {
return GetShape()->GetDz();
inline G4GeometryType G4UParaboloid::GetEntityType() const
{
return "G4Paraboloid";
}
inline G4double G4UParaboloid::GetRadiusMinusZ() const {
return GetShape()->GetRlo();
}
inline G4double G4UParaboloid::GetRadiusPlusZ() const {
return GetShape()->GetRhi();
}
// inline G4ParaboloidHistorical* G4UParaboloid::GetOriginalParameters() const
// {
// UParaboloidHistorical* pars = GetShape()->GetOriginalParameters();
// G4ParaboloidHistorical* pdata = new G4ParaboloidHistorical(pars->fNumZPlanes);
// pdata->Start_angle = pars->fStartAngle;
// pdata->Opening_angle = pars->fOpeningAngle;
// for (G4int i=0; i<pars->fNumZPlanes; ++i)
// {
// pdata->Z_values[i] = pars->fZValues[i];
// pdata->Rmin[i] = pars->Rmin[i];
// pdata->Rmax[i] = pars->Rmax[i];
// }
// return pdata;
// }
// inline void G4UParaboloid::SetOriginalParameters(G4ParaboloidHistorical* pars)
// {
// UParaboloidHistorical* pdata = GetShape()->GetOriginalParameters();
// pdata->fStartAngle = pars->Start_angle;
// pdata->fOpeningAngle = pars->Opening_angle;
// pdata->fNumZPlanes = pars->Num_z_planes;
// for (G4int i=0; i<pdata->fNumZPlanes; ++i)
// {
// pdata->fZValues[i] = pars->Z_values[i];
// pdata->Rmin[i] = pars->Rmin[i];
// pdata->Rmax[i] = pars->Rmax[i];
// }
// fRebuildPolyhedron = true;
// }
// inline G4bool G4UParaboloid::Reset()
// {
// GetShape()->Reset();
// return 0;
// }
#endif // G4GEOM_USE_USOLIDS
@@ -45,7 +45,7 @@
#include "G4USolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UPolycone.hh"
#include "G4PolyconeSide.hh"
@@ -82,15 +82,17 @@ class G4UPolycone : public G4USolid
inline UPolycone* GetShape() const;
inline G4double GetStartPhi() const;
inline G4double GetEndPhi() const;
inline G4bool IsOpen() const;
inline G4int GetNumRZCorner() const;
inline G4PolyconeSideRZ GetCorner(G4int index) const;
inline G4PolyconeHistorical* GetOriginalParameters() const;
inline void SetOriginalParameters(G4PolyconeHistorical* pars);
G4double GetStartPhi() const;
G4double GetEndPhi() const;
G4bool IsOpen() const;
G4int GetNumRZCorner() const;
G4PolyconeSideRZ GetCorner(G4int index) const;
G4PolyconeHistorical* GetOriginalParameters() const;
void SetOriginalParameters(G4PolyconeHistorical* pars);
inline G4bool Reset();
G4bool Reset();
inline G4GeometryType GetEntityType() const;
public: // without description
@@ -115,61 +117,9 @@ inline UPolycone* G4UPolycone::GetShape() const
return (UPolycone*) fShape;
}
inline G4double G4UPolycone::GetStartPhi() const
inline G4GeometryType G4UPolycone::GetEntityType() const
{
return GetShape()->GetStartPhi();
}
inline G4double G4UPolycone::GetEndPhi() const
{
return GetShape()->GetEndPhi();
}
inline G4bool G4UPolycone::IsOpen() const
{
return GetShape()->IsOpen();
}
inline G4int G4UPolycone::GetNumRZCorner() const
{
return GetShape()->GetNumRZCorner();
}
inline G4PolyconeSideRZ G4UPolycone::GetCorner(G4int index) const
{
UPolyconeSideRZ pside = GetShape()->GetCorner(index);
G4PolyconeSideRZ psiderz = { pside.r, pside.z };
return psiderz;
}
inline G4PolyconeHistorical* G4UPolycone::GetOriginalParameters() const
{
UPolyconeHistorical* pars = GetShape()->GetOriginalParameters();
G4PolyconeHistorical* pdata = new G4PolyconeHistorical(pars->fNumZPlanes);
pdata->Start_angle = pars->fStartAngle;
pdata->Opening_angle = pars->fOpeningAngle;
for (G4int i=0; i<pars->fNumZPlanes; ++i)
{
pdata->Z_values[i] = pars->fZValues[i];
pdata->Rmin[i] = pars->Rmin[i];
pdata->Rmax[i] = pars->Rmax[i];
}
return pdata;
}
inline void G4UPolycone::SetOriginalParameters(G4PolyconeHistorical* pars)
{
UPolyconeHistorical* pdata = GetShape()->GetOriginalParameters();
pdata->fStartAngle = pars->Start_angle;
pdata->fOpeningAngle = pars->Opening_angle;
pdata->fNumZPlanes = pars->Num_z_planes;
for (G4int i=0; i<pdata->fNumZPlanes; ++i)
{
pdata->fZValues[i] = pars->Z_values[i];
pdata->Rmin[i] = pars->Rmin[i];
pdata->Rmax[i] = pars->Rmax[i];
}
fRebuildPolyhedron = true;
}
inline G4bool G4UPolycone::Reset()
{
GetShape()->Reset();
return 0;
return "G4Polycone";
}
#endif // G4GEOM_USE_USOLIDS
@@ -45,7 +45,7 @@
#include "G4USolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UPolyhedra.hh"
#include "G4PolyhedraSide.hh"
@@ -86,17 +86,19 @@ class G4UPolyhedra : public G4USolid
inline UPolyhedra* GetShape() const;
inline G4int GetNumSide() const;
inline G4double GetStartPhi() const;
inline G4double GetEndPhi() const;
inline G4bool IsOpen() const;
inline G4bool IsGeneric() const;
inline G4int GetNumRZCorner() const;
inline G4PolyhedraSideRZ GetCorner( const G4int index ) const;
inline G4PolyhedraHistorical* GetOriginalParameters() const;
inline void SetOriginalParameters(G4PolyhedraHistorical* pars);
G4int GetNumSide() const;
G4double GetStartPhi() const;
G4double GetEndPhi() const;
G4bool IsOpen() const;
G4bool IsGeneric() const;
G4int GetNumRZCorner() const;
G4PolyhedraSideRZ GetCorner( const G4int index ) const;
G4PolyhedraHistorical* GetOriginalParameters() const;
void SetOriginalParameters(G4PolyhedraHistorical* pars);
inline G4bool Reset();
G4bool Reset();
inline G4GeometryType GetEntityType() const;
public: // without description
@@ -120,70 +122,9 @@ inline UPolyhedra* G4UPolyhedra::GetShape() const
return (UPolyhedra*) fShape;
}
inline G4int G4UPolyhedra::GetNumSide() const
inline G4GeometryType G4UPolyhedra::GetEntityType() const
{
return GetShape()->GetNumSide();
}
inline G4double G4UPolyhedra::GetStartPhi() const
{
return GetShape()->GetStartPhi();
}
inline G4double G4UPolyhedra::GetEndPhi() const
{
return GetShape()->GetEndPhi();
}
inline G4bool G4UPolyhedra::IsOpen() const
{
return GetShape()->IsOpen();
}
inline G4bool G4UPolyhedra::IsGeneric() const
{
return GetShape()->IsGeneric();
}
inline G4int G4UPolyhedra::GetNumRZCorner() const
{
return GetShape()->GetNumRZCorner();
}
inline G4PolyhedraSideRZ G4UPolyhedra::GetCorner(G4int index) const
{
UPolyhedraSideRZ pside = GetShape()->GetCorner(index);
G4PolyhedraSideRZ psiderz = { pside.r, pside.z };
return psiderz;
}
inline G4PolyhedraHistorical* G4UPolyhedra::GetOriginalParameters() const
{
UPolyhedraHistorical* pars = GetShape()->GetOriginalParameters();
G4PolyhedraHistorical* pdata = new G4PolyhedraHistorical(pars->fNumZPlanes);
pdata->Start_angle = pars->fStartAngle;
pdata->Opening_angle = pars->fOpeningAngle;
pdata->numSide = pars->fNumSide;
for (G4int i=0; i<pars->fNumZPlanes; ++i)
{
pdata->Z_values[i] = pars->fZValues[i];
pdata->Rmin[i] = pars->Rmin[i];
pdata->Rmax[i] = pars->Rmax[i];
}
return pdata;
}
inline void G4UPolyhedra::SetOriginalParameters(G4PolyhedraHistorical* pars)
{
UPolyhedraHistorical* pdata = GetShape()->GetOriginalParameters();
pdata->fStartAngle = pars->Start_angle;
pdata->fOpeningAngle = pars->Opening_angle;
pdata->fNumSide = pars->numSide;
pdata->fNumZPlanes = pars->Num_z_planes;
for (G4int i=0; i<pdata->fNumZPlanes; ++i)
{
pdata->fZValues[i] = pars->Z_values[i];
pdata->Rmin[i] = pars->Rmin[i];
pdata->Rmax[i] = pars->Rmax[i];
}
fRebuildPolyhedron = true;
}
inline G4bool G4UPolyhedra::Reset()
{
return GetShape()->Reset();
return "G4Polyhedra";
}
#endif // G4GEOM_USE_USOLIDS
@@ -48,10 +48,12 @@
#include "G4USolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "UTet.hh"
#include "G4Polyhedron.hh"
class G4UTet : public G4USolid
{
@@ -68,6 +70,8 @@ class G4UTet : public G4USolid
inline UTet* GetShape() const;
inline G4GeometryType GetEntityType() const;
public: // without description
G4UTet(__void__&);
@@ -79,7 +83,9 @@ class G4UTet : public G4USolid
G4UTet& operator=(const G4UTet& rhs);
// Copy constructor and assignment operator.
inline std::vector<G4ThreeVector> GetVertices() const;
G4Polyhedron* CreatePolyhedron() const;
std::vector<G4ThreeVector> GetVertices() const;
// Return the four vertices of the shape.
};
@@ -92,16 +98,9 @@ inline UTet* G4UTet::GetShape() const
return (UTet*) fShape;
}
inline std::vector<G4ThreeVector> G4UTet::GetVertices() const
inline G4GeometryType G4UTet::GetEntityType() const
{
std::vector<UVector3> vec = GetShape()->GetVertices();
std::vector<G4ThreeVector> vertices;
for (unsigned int i=0; i<vec.size(); ++i)
{
G4ThreeVector v(vec[i].x(), vec[i].y(), vec[i].z());
vertices.push_back(v);
}
return vertices;
return "G4Tet";
}
#endif // G4GEOM_USE_USOLIDS
@@ -24,7 +24,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VFacet.hh 66356 2012-12-18 09:02:32Z gcosmo $
// $Id: G4VFacet.hh 95801 2016-02-25 10:59:41Z gcosmo $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
@@ -81,7 +81,7 @@ class G4VFacet
virtual G4bool Intersect (const G4ThreeVector&, const G4ThreeVector &,
const G4bool , G4double &, G4double &,
G4ThreeVector &) = 0;
virtual G4double GetArea() = 0;
virtual G4double GetArea() const = 0;
virtual G4ThreeVector GetPointOnFace() const = 0;
void ApplyTranslation (const G4ThreeVector v);
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ExtrudedSolid.cc 92024 2015-08-13 14:16:00Z gcosmo $
// $Id: G4ExtrudedSolid.cc 95956 2016-03-03 10:59:53Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -33,6 +33,11 @@
// G4ExtrudedSolid.cc
//
// Author: Ivana Hrivnacova, IPN Orsay
//
// CHANGE HISTORY
// --------------
// 02 March 2016, E Tcherniaev, added CheckPolygon() to remove
// collinear and coincident points from polygon
// --------------------------------------------------------------------
#include "G4ExtrudedSolid.hh"
@@ -44,6 +49,7 @@
#include <cmath>
#include <iomanip>
#include "G4GeometryTolerance.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "G4VFacet.hh"
@@ -53,8 +59,8 @@
//_____________________________________________________________________________
G4ExtrudedSolid::G4ExtrudedSolid( const G4String& pName,
std::vector<G4TwoVector> polygon,
std::vector<ZSection> zsections)
const std::vector<G4TwoVector>& polygon,
const std::vector<ZSection>& zsections)
: G4TessellatedSolid(pName),
fNv(polygon.size()),
fNz(zsections.size()),
@@ -69,15 +75,15 @@ G4ExtrudedSolid::G4ExtrudedSolid( const G4String& pName,
// First check input parameters
if ( fNv < 3 )
if (fNv < 3)
{
std::ostringstream message;
message << "Number of polygon vertices < 3 - " << pName;
message << "Number of vertices in polygon < 3 - " << pName;
G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0002",
FatalErrorInArgument, message);
}
if ( fNz < 2 )
if (fNz < 2)
{
std::ostringstream message;
message << "Number of z-sides < 2 - " << pName;
@@ -95,7 +101,7 @@ G4ExtrudedSolid::G4ExtrudedSolid( const G4String& pName,
G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0002",
FatalErrorInArgument, message);
}
if ( std::fabs( zsections[i+1].fZ - zsections[i].fZ ) < kCarTolerance * 0.5 )
if ( std::fabs( zsections[i+1].fZ - zsections[i].fZ ) < kCarToleranceHalf )
{
std::ostringstream message;
message << "Z-sections with the same z position are not supported - "
@@ -105,35 +111,53 @@ G4ExtrudedSolid::G4ExtrudedSolid( const G4String& pName,
}
}
// Copy polygon
//
fPolygon = polygon;
// Remove collinear and coincident vertices, if any
//
G4String removedVertices;
CheckPolygon(removedVertices);
if (fNv != G4int(polygon.size()))
{
std::ostringstream message;
message << "The following vertices have been removed from the polygon in "
<< pName << G4endl
<< "as collinear or coincident with other vertices: "
<< removedVertices;
G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids1001",
JustWarning, message);
}
if (fNv < 3)
{
std::ostringstream message;
message << "Number of vertices in polygon after removal < 3 - " << pName;
G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0002",
FatalErrorInArgument, message);
}
// 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());
for (G4int i=fNv-1, k=0; k<fNv; i=k++)
{
area += fPolygon[i].x()*fPolygon[k].y() - fPolygon[k].x()*fPolygon[i].y();
}
// Copy polygon
//
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 {
if (area > 0.)
{
// Polygon vertices are defined anti-clockwise, we revert them
//G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids1001",
// G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids1001",
// JustWarning,
// "Polygon vertices defined anti-clockwise, reverting polygon");
for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[fNv-i-1]); }
// "Polygon vertices defined anti-clockwise, reverting polygon");
std::reverse(fPolygon.begin(),fPolygon.end());
}
// Copy z-sections
//
for ( G4int i=0; i<fNz; ++i ) { fZSections.push_back(zsections[i]); }
fZSections = zsections;
G4bool result = MakeFacets();
if (!result)
@@ -144,7 +168,6 @@ G4ExtrudedSolid::G4ExtrudedSolid( const G4String& pName,
FatalException, message);
}
fIsConvex = IsConvex();
ComputeProjectionParameters();
}
@@ -152,10 +175,10 @@ G4ExtrudedSolid::G4ExtrudedSolid( const G4String& pName,
//_____________________________________________________________________________
G4ExtrudedSolid::G4ExtrudedSolid( const G4String& pName,
std::vector<G4TwoVector> polygon,
const std::vector<G4TwoVector>& polygon,
G4double dz,
G4TwoVector off1, G4double scale1,
G4TwoVector off2, G4double scale2 )
const G4TwoVector& off1, G4double scale1,
const G4TwoVector& off2, G4double scale2 )
: G4TessellatedSolid(pName),
fNv(polygon.size()),
fNz(2),
@@ -170,40 +193,56 @@ G4ExtrudedSolid::G4ExtrudedSolid( const G4String& pName,
// First check input parameters
//
if ( fNv < 3 )
if (fNv < 3)
{
std::ostringstream message;
message << "Number of polygon vertices < 3 - " << pName;
message << "Number of vertices in polygon < 3 - " << pName;
G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0002",
FatalErrorInArgument, message);
}
// 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
//
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]); }
fPolygon = polygon;
// Remove collinear and coincident vertices, if any
//
G4String removedVertices;
CheckPolygon(removedVertices);
if (fNv != G4int(polygon.size()))
{
std::ostringstream message;
message << "The following vertices have been removed from the polygon in "
<< pName << G4endl
<< "as collinear or coincident with other vertices: "
<< removedVertices;
G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids1001",
JustWarning, message);
}
else
if (fNv < 3)
{
std::ostringstream message;
message << "Number of vertices in polygon after removal < 3 - " << pName;
G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids0002",
FatalErrorInArgument, message);
}
// Check if polygon vertices are defined clockwise
// (the area is positive if polygon vertices are defined anti-clockwise)
//
G4double area = 0.;
for (G4int i=fNv-1, k=0; k<fNv; i=k++)
{
area += fPolygon[i].x()*fPolygon[k].y() - fPolygon[k].x()*fPolygon[i].y();
}
if (area > 0.)
{
// Polygon vertices are defined anti-clockwise, we revert them
//G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids1001",
// G4Exception("G4ExtrudedSolid::G4ExtrudedSolid()", "GeomSolids1001",
// JustWarning,
// "Polygon vertices defined anti-clockwise, reverting polygon");
for ( G4int i=0; i<fNv; ++i ) { fPolygon.push_back(polygon[fNv-i-1]); }
// "Polygon vertices defined anti-clockwise, reverting polygon");
std::reverse(fPolygon.begin(),fPolygon.end());
}
// Copy z-sections
@@ -279,6 +318,93 @@ G4ExtrudedSolid::~G4ExtrudedSolid()
//_____________________________________________________________________________
void G4ExtrudedSolid::CheckPolygon(G4String & removedVertices)
{
// Remove collinear and coincident vertices from 2D polygon
G4double delta = kCarTolerance; // dimension tolerance
G4double removeIt = kInfinity; // special value to mark vertices for removal
// Main loop: check every three consecutive points, if the points
// are collinear then mark middle point for removal
//
G4int icur, iprev=0, inext=0;
for (G4int i=0; i<fNv; ++i)
{
icur = i;
// Find index of previous point
for (G4int k=1; k<fNv+1; ++k)
{
iprev = icur - k;
if (iprev < 0) iprev += fNv;
if (fPolygon[iprev].x() != removeIt) break;
}
// Find index of next point
for (G4int k=1; k<fNv+1; ++k)
{
inext = icur + k;
if (inext >= fNv) inext -= fNv;
if (fPolygon[inext].x() != removeIt) break;
}
if (iprev == inext) break; // degenerate polygon, stop
// Calculate parameters of the triangle (iprev->icur->inext).
// If the triangle is too small or too narrow then
// mark current point for removal
G4TwoVector e1 = fPolygon[iprev] - fPolygon[icur];
G4TwoVector e2 = fPolygon[inext] - fPolygon[icur];
G4double leng1 = e1.mag();
G4double leng2 = e2.mag();
G4double leng3 = (e2-e1).mag();
G4double lmax = std::max(std::max(leng1,leng2),leng3);
G4double area = std::fabs(e1.x()*e2.y()-e1.y()*e2.x());
// Check length of edges, then check height of the triangle
if (leng1 < delta || leng2 < delta || leng3 < delta)
{
fPolygon[icur].setX(removeIt);
}
else if (area/lmax < delta)
{
fPolygon[icur].setX(removeIt);
}
}
// Remove marked points
//
std::ostringstream message;
icur = 0;
for (G4int i=0; i<fNv; ++i)
{
if (fPolygon[i].x() != removeIt)
{
fPolygon[icur] = fPolygon[i];
icur++;
}
else
{
if (icur != i) message << ",";
message << i;
}
}
// Resize fPolygon, if required
//
if (icur != fNv)
{
fPolygon.resize(icur);
removedVertices = message.str();
fNv = icur;
}
}
//_____________________________________________________________________________
void G4ExtrudedSolid::ComputeProjectionParameters()
{
// Compute parameters for point projections p(z)
@@ -357,28 +483,29 @@ G4TwoVector G4ExtrudedSolid::ProjectPoint(const G4ThreeVector& point) const
//_____________________________________________________________________________
G4bool G4ExtrudedSolid::IsSameLine(G4TwoVector p,
G4TwoVector l1, G4TwoVector l2) const
G4bool G4ExtrudedSolid::IsSameLine(const G4TwoVector& p,
const G4TwoVector& l1,
const G4TwoVector& l2) const
{
// Return true if p is on the line through l1, l2
if ( l1.x() == l2.x() )
{
return std::fabs(p.x() - l1.x()) < kCarTolerance * 0.5;
return std::fabs(p.x() - l1.x()) < kCarToleranceHalf;
}
G4double slope= ((l2.y() - l1.y())/(l2.x() - l1.x()));
G4double slope= ((l2.y() - l1.y())/(l2.x() - l1.x()));
G4double predy= l1.y() + slope *(p.x() - l1.x());
G4double dy= p.y() - predy;
// Calculate perpendicular distance
//
// G4double perpD= std::fabs(dy) / std::sqrt( 1 + slope * slope );
// G4bool simpleComp= (perpD<0.5*kCarTolerance);
// G4bool simpleComp= (perpD<kCarToleranceHalf);
// Check perpendicular distance vs tolerance 'directly'
//
const G4double tol= 0.5 * kCarTolerance ;
G4bool squareComp= (dy*dy < (1+slope*slope) * tol * tol);
G4bool squareComp = (dy*dy < (1+slope*slope)
* kCarToleranceHalf * kCarToleranceHalf);
// return simpleComp;
return squareComp;
@@ -386,16 +513,17 @@ G4bool G4ExtrudedSolid::IsSameLine(G4TwoVector p,
//_____________________________________________________________________________
G4bool G4ExtrudedSolid::IsSameLineSegment(G4TwoVector p,
G4TwoVector l1, G4TwoVector l2) const
G4bool G4ExtrudedSolid::IsSameLineSegment(const G4TwoVector& p,
const G4TwoVector& l1,
const G4TwoVector& l2) const
{
// Return true if p is on the line through l1, l2 and lies between
// l1 and l2
if ( p.x() < std::min(l1.x(), l2.x()) - kCarTolerance * 0.5 ||
p.x() > std::max(l1.x(), l2.x()) + kCarTolerance * 0.5 ||
p.y() < std::min(l1.y(), l2.y()) - kCarTolerance * 0.5 ||
p.y() > std::max(l1.y(), l2.y()) + kCarTolerance * 0.5 )
if ( p.x() < std::min(l1.x(), l2.x()) - kCarToleranceHalf ||
p.x() > std::max(l1.x(), l2.x()) + kCarToleranceHalf ||
p.y() < std::min(l1.y(), l2.y()) - kCarToleranceHalf ||
p.y() > std::max(l1.y(), l2.y()) + kCarToleranceHalf )
{
return false;
}
@@ -405,21 +533,25 @@ G4bool G4ExtrudedSolid::IsSameLineSegment(G4TwoVector p,
//_____________________________________________________________________________
G4bool G4ExtrudedSolid::IsSameSide(G4TwoVector p1, G4TwoVector p2,
G4TwoVector l1, G4TwoVector l2) const
G4bool G4ExtrudedSolid::IsSameSide(const G4TwoVector& p1,
const G4TwoVector& p2,
const G4TwoVector& l1,
const G4TwoVector& l2) const
{
// Return true if p1 and p2 are on the same side of the line through l1, l2
return ( (p1.x() - l1.x()) * (l2.y() - l1.y())
- (l2.x() - l1.x()) * (p1.y() - l1.y()) )
- (l2.x() - l1.x()) * (p1.y() - l1.y()) )
* ( (p2.x() - l1.x()) * (l2.y() - l1.y())
- (l2.x() - l1.x()) * (p2.y() - l1.y()) ) > 0;
}
//_____________________________________________________________________________
G4bool G4ExtrudedSolid::IsPointInside(G4TwoVector a, G4TwoVector b,
G4TwoVector c, G4TwoVector p) const
G4bool G4ExtrudedSolid::IsPointInside(const G4TwoVector& a,
const G4TwoVector& b,
const G4TwoVector& c,
const G4TwoVector& p) const
{
// Return true if p is inside of triangle abc or on its edges,
// else returns false
@@ -447,7 +579,9 @@ G4bool G4ExtrudedSolid::IsPointInside(G4TwoVector a, G4TwoVector b,
//_____________________________________________________________________________
G4double
G4ExtrudedSolid::GetAngle(G4TwoVector po, G4TwoVector pa, G4TwoVector pb) const
G4ExtrudedSolid::GetAngle(const G4TwoVector& po,
const G4TwoVector& pa,
const G4TwoVector& pb) const
{
// Return the angle of the vertex in po
@@ -537,6 +671,9 @@ G4bool G4ExtrudedSolid::AddGeneralPolygonFacets()
typedef std::pair < G4TwoVector, G4int > Vertex;
static const G4double kAngTolerance =
G4GeometryTolerance::GetInstance()->GetAngularTolerance();
// Fill one more vector
//
std::vector< Vertex > verticesToBeDone;
@@ -566,7 +703,7 @@ G4bool G4ExtrudedSolid::AddGeneralPolygonFacets()
//G4cout << "angle " << angle << G4endl;
G4int counter = 0;
while ( angle >= pi ) // Loop checking, 13.08.2015, G.Cosmo
while ( angle >= (pi-kAngTolerance) ) // Loop checking, 13.08.2015, G.Cosmo
{
// G4cout << "Skipping concave vertex " << c2->second << G4endl;
@@ -773,12 +910,12 @@ EInside G4ExtrudedSolid::Inside (const G4ThreeVector &p) const
// Check first if outside extent
//
if ( p.x() < GetMinXExtent() - kCarTolerance * 0.5 ||
p.x() > GetMaxXExtent() + kCarTolerance * 0.5 ||
p.y() < GetMinYExtent() - kCarTolerance * 0.5 ||
p.y() > GetMaxYExtent() + kCarTolerance * 0.5 ||
p.z() < GetMinZExtent() - kCarTolerance * 0.5 ||
p.z() > GetMaxZExtent() + kCarTolerance * 0.5 )
if ( p.x() < GetMinXExtent() - kCarToleranceHalf ||
p.x() > GetMaxXExtent() + kCarToleranceHalf ||
p.y() < GetMinYExtent() - kCarToleranceHalf ||
p.y() > GetMaxYExtent() + kCarToleranceHalf ||
p.z() < GetMinZExtent() - kCarToleranceHalf ||
p.z() > GetMaxZExtent() + kCarToleranceHalf )
{
// G4cout << "G4ExtrudedSolid::Outside extent: " << p << G4endl;
return kOutside;
@@ -817,8 +954,8 @@ EInside G4ExtrudedSolid::Inside (const G4ThreeVector &p) const
{
// Check if on surface of z sides
//
if ( std::fabs( p.z() - fZSections[0].fZ ) < kCarTolerance * 0.5 ||
std::fabs( p.z() - fZSections[fNz-1].fZ ) < kCarTolerance * 0.5 )
if ( std::fabs( p.z() - fZSections[0].fZ ) < kCarToleranceHalf ||
std::fabs( p.z() - fZSections[fNz-1].fZ ) < kCarToleranceHalf )
{
// G4cout << "G4ExtrudedSolid::Inside return Surface (on z side)"
// << G4endl;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GenericTrap.cc 83851 2014-09-19 10:12:12Z gcosmo $
// $Id: G4GenericTrap.cc 95592 2016-02-16 10:48:01Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -36,9 +36,12 @@
// Tatiana Nikitina, CERN; Ivana Hrivnacova, IPN Orsay
// Adapted from Root Arb8 implementation by Andrei Gheata, CERN
//
// History :
// 04 August 2011 T.Nikitina Add SetReferences() and InvertFacets()
// to CreatePolyhedron() for Visualisation of Boolean
// History:
// 04.08.2011 T.Nikitina - Added SetReferences() and InvertFacets()
// to CreatePolyhedron() for Visualisation of Boolean
//
// 03.02.2016 E.Tcherniaev - Revised GetSurfaceArea() and GetCubicVolume(),
// rewritten GetFaceSurfaceArea(), added GetFaceCubicVolume()
// --------------------------------------------------------------------
#include "G4GenericTrap.hh"
@@ -505,8 +508,10 @@ G4ThreeVector G4GenericTrap::SurfaceNormal( const G4ThreeVector& p ) const
//
if ( noSurfaces == 0 )
{
#ifdef G4SPECSDEBUG
G4Exception("G4GenericTrap::SurfaceNormal(p)", "GeomSolids1002",
JustWarning, "Point p is not on surface !?" );
#endif
sumnorm=apprnorm;
// Add Approximative Surface Normal Calculation?
}
@@ -549,7 +554,9 @@ G4ThreeVector G4GenericTrap::NormalToPlane( const G4ThreeVector& p,
if (std::fabs(distz)<halfCarTolerance)
{
p1=G4ThreeVector(fVertices[i].x(),fVertices[i].y(),-fDz);distz=-1;}
p1=G4ThreeVector(fVertices[i].x(),fVertices[i].y(),-fDz);
distz=-1;
}
else
{
p1=G4ThreeVector(fVertices[i+4].x(),fVertices[i+4].y(),fDz);
@@ -1218,11 +1225,8 @@ G4bool G4GenericTrap::CalculateExtent(const EAxis pAxis,
// Computes bounding vectors for a shape
//
G4double Dx,Dy;
G4ThreeVector minVec = GetMinimumBBox();
G4ThreeVector maxVec = GetMaximumBBox();
Dx = 0.5*(maxVec.x()- minVec.x());
Dy = 0.5*(maxVec.y()- minVec.y());
if (!pTransform.IsRotated())
{
@@ -1235,8 +1239,8 @@ G4bool G4GenericTrap::CalculateExtent(const EAxis pAxis,
G4double zoffset,zMin,zMax;
xoffset=pTransform.NetTranslation().x();
xMin=xoffset-Dx;
xMax=xoffset+Dx;
xMin=xoffset+minVec.x();
xMax=xoffset+maxVec.x();
if (pVoxelLimit.IsXLimited())
{
if ( (xMin>pVoxelLimit.GetMaxXExtent()+kCarTolerance)
@@ -1258,8 +1262,8 @@ G4bool G4GenericTrap::CalculateExtent(const EAxis pAxis,
}
yoffset=pTransform.NetTranslation().y();
yMin=yoffset-Dy;
yMax=yoffset+Dy;
yMin=yoffset+minVec.y();
yMax=yoffset+maxVec.y();
if (pVoxelLimit.IsYLimited())
{
if ( (yMin>pVoxelLimit.GetMaxYExtent()+kCarTolerance)
@@ -1281,8 +1285,8 @@ G4bool G4GenericTrap::CalculateExtent(const EAxis pAxis,
}
zoffset=pTransform.NetTranslation().z();
zMin=zoffset-fDz;
zMax=zoffset+fDz;
zMin=zoffset+minVec.z();
zMax=zoffset+maxVec.z();
if (pVoxelLimit.IsZLimited())
{
if ( (zMin>pVoxelLimit.GetMaxZExtent()+kCarTolerance)
@@ -1548,58 +1552,62 @@ G4ThreeVector G4GenericTrap::GetPointOnSurface() const
// --------------------------------------------------------------------
G4double G4GenericTrap::GetCubicVolume()
G4double G4GenericTrap::GetSurfaceArea()
{
if(fCubicVolume != 0.) {;}
else { fCubicVolume = G4VSolid::GetCubicVolume(); }
return fCubicVolume;
if (fSurfaceArea == 0.0) {
if(fIsTwisted) {
fSurfaceArea = G4VSolid::GetSurfaceArea();
} else {
// Set vertices
G4ThreeVector vertix0(fVertices[0].x(),fVertices[0].y(),-fDz);
G4ThreeVector vertix1(fVertices[1].x(),fVertices[1].y(),-fDz);
G4ThreeVector vertix2(fVertices[2].x(),fVertices[2].y(),-fDz);
G4ThreeVector vertix3(fVertices[3].x(),fVertices[3].y(),-fDz);
G4ThreeVector vertix4(fVertices[4].x(),fVertices[4].y(), fDz);
G4ThreeVector vertix5(fVertices[5].x(),fVertices[5].y(), fDz);
G4ThreeVector vertix6(fVertices[6].x(),fVertices[6].y(), fDz);
G4ThreeVector vertix7(fVertices[7].x(),fVertices[7].y(), fDz);
// Find Surface Area
fSurfaceArea = GetFaceSurfaceArea(vertix0,vertix1,vertix2,vertix3) // -fDz plane
+ GetFaceSurfaceArea(vertix1,vertix0,vertix4,vertix5) // Lat plane
+ GetFaceSurfaceArea(vertix2,vertix1,vertix5,vertix6) // Lat plane
+ GetFaceSurfaceArea(vertix3,vertix2,vertix6,vertix7) // Lat plane
+ GetFaceSurfaceArea(vertix0,vertix3,vertix7,vertix4) // Lat plane
+ GetFaceSurfaceArea(vertix7,vertix6,vertix5,vertix4); // +fDz plane
}
}
return fSurfaceArea;
}
// --------------------------------------------------------------------
G4double G4GenericTrap::GetSurfaceArea()
G4double G4GenericTrap::GetCubicVolume()
{
if(fSurfaceArea != 0.) {;}
else
{
std::vector<G4ThreeVector> vertices;
for (G4int i=0; i<4;i++)
{
vertices.push_back(G4ThreeVector(fVertices[i].x(),fVertices[i].y(),-fDz));
}
for (G4int i=4; i<8;i++)
{
vertices.push_back(G4ThreeVector(fVertices[i].x(),fVertices[i].y(),fDz));
}
if (fCubicVolume == 0.0) {
if(fIsTwisted) {
fCubicVolume = G4VSolid::GetCubicVolume();
} else {
// Set vertices
G4ThreeVector vertix0(fVertices[0].x(),fVertices[0].y(),-fDz);
G4ThreeVector vertix1(fVertices[1].x(),fVertices[1].y(),-fDz);
G4ThreeVector vertix2(fVertices[2].x(),fVertices[2].y(),-fDz);
G4ThreeVector vertix3(fVertices[3].x(),fVertices[3].y(),-fDz);
G4ThreeVector vertix4(fVertices[4].x(),fVertices[4].y(), fDz);
G4ThreeVector vertix5(fVertices[5].x(),fVertices[5].y(), fDz);
G4ThreeVector vertix6(fVertices[6].x(),fVertices[6].y(), fDz);
G4ThreeVector vertix7(fVertices[7].x(),fVertices[7].y(), fDz);
// Surface Area of Planes(only estimation for twisted)
//
G4double fSurface0=GetFaceSurfaceArea(vertices[0],vertices[1],
vertices[2],vertices[3]);//-fDz plane
G4double fSurface1=GetFaceSurfaceArea(vertices[0],vertices[1],
vertices[5],vertices[4]);// Lat plane
G4double fSurface2=GetFaceSurfaceArea(vertices[3],vertices[0],
vertices[4],vertices[7]);// Lat plane
G4double fSurface3=GetFaceSurfaceArea(vertices[2],vertices[3],
vertices[7],vertices[6]);// Lat plane
G4double fSurface4=GetFaceSurfaceArea(vertices[2],vertices[1],
vertices[5],vertices[6]);// Lat plane
G4double fSurface5=GetFaceSurfaceArea(vertices[4],vertices[5],
vertices[6],vertices[7]);// fDz plane
// Total Surface Area
//
if(!fIsTwisted)
{
fSurfaceArea = fSurface0+fSurface1+fSurface2
+ fSurface3+fSurface4+fSurface5;
}
else
{
fSurfaceArea = G4VSolid::GetSurfaceArea();
// Find Cubic Volume
fCubicVolume = GetFaceCubicVolume(vertix0,vertix1,vertix2,vertix3) // -fDz plane
+ GetFaceCubicVolume(vertix1,vertix0,vertix4,vertix5) // Lat plane
+ GetFaceCubicVolume(vertix2,vertix1,vertix5,vertix6) // Lat plane
+ GetFaceCubicVolume(vertix3,vertix2,vertix6,vertix7) // Lat plane
+ GetFaceCubicVolume(vertix0,vertix3,vertix7,vertix4) // Lat plane
+ GetFaceCubicVolume(vertix7,vertix6,vertix5,vertix4); // +fDz plane
}
}
return fSurfaceArea;
return fCubicVolume;
}
// --------------------------------------------------------------------
@@ -1609,23 +1617,20 @@ G4double G4GenericTrap::GetFaceSurfaceArea(const G4ThreeVector& p0,
const G4ThreeVector& p2,
const G4ThreeVector& p3) const
{
// Auxiliary method for Get Surface Area of Face
G4double aOne, aTwo;
G4ThreeVector t, u, v, w, Area, normal;
// Returns area of the facet
return (((p2-p0).cross(p3-p1)).mag()) / 2.;
}
t = p2 - p1;
u = p0 - p1;
v = p2 - p3;
w = p0 - p3;
Area = w.cross(v);
aOne = 0.5*Area.mag();
Area = t.cross(u);
aTwo = 0.5*Area.mag();
return aOne + aTwo;
// --------------------------------------------------------------------
G4double G4GenericTrap::GetFaceCubicVolume(const G4ThreeVector& p0,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3) const
{
// Returns contribution of the facet to the volume of the solid.
// Orientation of the facet is important, normal should point to outside.
return (((p2-p0).cross(p3-p1)).dot(p0)) / 6.;
}
// --------------------------------------------------------------------
@@ -2150,13 +2155,11 @@ G4VisExtent G4GenericTrap::GetExtent() const
}
#endif
G4double Dx,Dy;
G4ThreeVector minVec = GetMinimumBBox();
G4ThreeVector maxVec = GetMaximumBBox();
Dx = 0.5*(maxVec.x()- minVec.x());
Dy = 0.5*(maxVec.y()- minVec.y());
return G4VisExtent (-Dx, Dx, -Dy, Dy, -fDz, fDz);
return G4VisExtent (minVec.x(), maxVec.x(),
minVec.y(), maxVec.y(),
minVec.z(), maxVec.z());
}
// --------------------------------------------------------------------
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4IntersectingCone.cc 72937 2013-08-14 13:20:38Z gcosmo $
// $Id: G4IntersectingCone.cc 95997 2016-03-07 13:16:25Z gcosmo $
//
//
// --------------------------------------------------------------------
@@ -215,6 +215,8 @@ G4int G4IntersectingCone::LineHitsCone1( const G4ThreeVector &p,
const G4ThreeVector &v,
G4double *s1, G4double *s2 )
{
static const G4double EPS = DBL_EPSILON; // Precision constant,
// originally it was 1E-6
G4double x0 = p.x(), y0 = p.y(), z0 = p.z();
G4double tx = v.x(), ty = v.y(), tz = v.z();
@@ -224,9 +226,9 @@ G4int G4IntersectingCone::LineHitsCone1( const G4ThreeVector &p,
G4double radical = b*b - 4*a*c;
if (radical < -1E-6*std::fabs(b)) { return 0; } // No solution
if (radical < -EPS*std::fabs(b)) { return 0; } // No solution
if (radical < 1E-6*std::fabs(b))
if (radical < EPS*std::fabs(b))
{
//
// The radical is roughly zero: check for special, very rare, cases
@@ -234,7 +236,7 @@ G4int G4IntersectingCone::LineHitsCone1( const G4ThreeVector &p,
if (std::fabs(a) > 1/kInfinity)
{
if(B==0.) { return 0; }
if ( std::fabs(x0*ty - y0*tx) < std::fabs(1E-6/B) )
if ( std::fabs(x0*ty - y0*tx) < std::fabs(EPS/B) )
{
*s1 = -0.5*b/a;
return 1;
@@ -305,10 +307,11 @@ G4int G4IntersectingCone::LineHitsCone2( const G4ThreeVector &p,
const G4ThreeVector &v,
G4double *s1, G4double *s2 )
{
static const G4double EPS = DBL_EPSILON; // Precision constant,
// originally it was 1E-6
G4double x0 = p.x(), y0 = p.y(), z0 = p.z();
G4double tx = v.x(), ty = v.y(), tz = v.z();
// Special case which might not be so rare: B = 0 (precisely)
//
if (B==0)
@@ -327,16 +330,16 @@ G4int G4IntersectingCone::LineHitsCone2( const G4ThreeVector &p,
G4double radical = b*b - 4*a*c;
if (radical < -1E-6*std::fabs(b)) { return 0; } // No solution
if (radical < -EPS*std::fabs(b)) { return 0; } // No solution
if (radical < 1E-6*std::fabs(b))
if (radical < EPS*std::fabs(b))
{
//
// The radical is roughly zero: check for special, very rare, cases
//
if (std::fabs(a) > 1/kInfinity)
{
if ( std::fabs(x0*ty - y0*tx) < std::fabs(1E-6/B) )
if ( std::fabs(x0*ty - y0*tx) < std::fabs(EPS/B) )
{
*s1 = -0.5*b/a;
return 1;
@@ -25,19 +25,25 @@
// ********************************************************************
//
//
// $Id: G4QuadrangularFacet.cc 66819 2013-01-12 16:20:10Z gcosmo $
// $Id: G4QuadrangularFacet.cc 95945 2016-03-03 09:54:38Z gcosmo $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
// CHANGE HISTORY
// --------------
//
// 31 October 2004, P R Truscott, QinetiQ Ltd, UK - Created.
// 12 October 2012, M Gayer, CERN
// 31 October 2004 P R Truscott, QinetiQ Ltd, UK - Created.
//
// 12 October 2012 M Gayer, CERN
// New implementation reducing memory requirements by 50%,
// and considerable CPU speedup together with the new
// implementation of G4TessellatedSolid.
//
// 29 February 2016 E Tcherniaev, CERN
// Added exhaustive tests to catch various problems with a
// quadrangular facet: collinear vertices, non planar surface,
// degenerate, concave or self intersecting quadrilateral.
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#include "G4QuadrangularFacet.hh"
@@ -57,8 +63,12 @@ G4QuadrangularFacet::G4QuadrangularFacet (const G4ThreeVector &vt0,
const G4ThreeVector &vt3,
G4FacetVertexType vertexType)
{
G4ThreeVector e1, e2, e3;
G4double delta = 1.0 * kCarTolerance; // dimension tolerance
G4double epsilon = 0.01 * kCarTolerance; // planarity tolerance
fRadius = 0.0;
G4ThreeVector e1, e2, e3;
SetVertex(0, vt0);
if (vertexType == ABSOLUTE)
{
@@ -80,59 +90,128 @@ G4QuadrangularFacet::G4QuadrangularFacet (const G4ThreeVector &vt0,
e2 = vt2;
e3 = vt3;
}
G4double length1 = e1.mag();
G4double length2 = (GetVertex(2)-GetVertex(1)).mag();
G4double length3 = (GetVertex(3)-GetVertex(2)).mag();
G4double length4 = e3.mag();
G4ThreeVector normal1 = e1.cross(e2).unit();
G4ThreeVector normal2 = e2.cross(e3).unit();
// Check length of sides and diagonals
//
G4double leng1 = e1.mag();
G4double leng2 = (e2-e1).mag();
G4double leng3 = (e3-e2).mag();
G4double leng4 = e3.mag();
bool isDefined = (length1 > kCarTolerance && length2 > kCarTolerance &&
length3 > kCarTolerance && length4 > kCarTolerance &&
normal1.dot(normal2) >= 0.9999999999);
G4double diag1 = e2.mag();
G4double diag2 = (e3-e1).mag();
if (isDefined)
{
fFacet1 = G4TriangularFacet (GetVertex(0),GetVertex(1),
GetVertex(2),ABSOLUTE);
fFacet2 = G4TriangularFacet (GetVertex(0),GetVertex(2),
GetVertex(3),ABSOLUTE);
G4TriangularFacet facet3 (GetVertex(0),GetVertex(1),GetVertex(3),ABSOLUTE);
G4TriangularFacet facet4 (GetVertex(1),GetVertex(2),GetVertex(3),ABSOLUTE);
G4ThreeVector normal12 = fFacet1.GetSurfaceNormal()
+ fFacet2.GetSurfaceNormal();
G4ThreeVector normal34 = facet3.GetSurfaceNormal()
+ facet4.GetSurfaceNormal();
G4ThreeVector normal = 0.25 * (normal12 + normal34);
fFacet1.SetSurfaceNormal (normal);
fFacet2.SetSurfaceNormal (normal);
G4ThreeVector vtmp = 0.5 * (e1 + e2);
fCircumcentre = GetVertex(0) + vtmp;
G4double radiusSqr = vtmp.mag2();
fRadius = std::sqrt(radiusSqr);
}
else
if (leng1 <= delta || leng2 <= delta || leng3 <= delta || leng4 <= delta ||
diag1 <= delta || diag2 <= delta)
{
ostringstream message;
message << "Sides/diagonals of facet are too small." << G4endl
<< "P0 = " << GetVertex(0) << G4endl
<< "P1 = " << GetVertex(1) << G4endl
<< "P2 = " << GetVertex(2) << G4endl
<< "P3 = " << GetVertex(3) << G4endl
<< "Side1 length (P0->P1) = " << leng1 << G4endl
<< "Side2 length (P1->P2) = " << leng2 << G4endl
<< "Side3 length (P2->P3) = " << leng3 << G4endl
<< "Side4 length (P3->P0) = " << leng4 << G4endl
<< "Diagonal1 length (P0->P2) = " << diag1 << G4endl
<< "Diagonal2 length (P1->P3) = " << diag2;
G4Exception("G4QuadrangularFacet::G4QuadrangularFacet()",
"GeomSolids0002", JustWarning,
"Length of sides of facet are too small or sides not planar.");
G4cout << G4endl;
G4cout << "P0 = " << GetVertex(0) << G4endl;
G4cout << "P1 = " << GetVertex(1) << G4endl;
G4cout << "P2 = " << GetVertex(2) << G4endl;
G4cout << "P3 = " << GetVertex(3) << G4endl;
G4cout << "Side lengths = P0->P1" << length1 << G4endl;
G4cout << "Side lengths = P1->P2" << length2 << G4endl;
G4cout << "Side lengths = P2->P3" << length3 << G4endl;
G4cout << "Side lengths = P3->P0" << length4 << G4endl;
G4cout << G4endl;
fRadius = 0.0;
"GeomSolids1001", JustWarning, message);
return;
}
// Check that vertices are not collinear
//
G4double s1 = (e1.cross(e2)).mag()*0.5;
G4double s2 = ((e2-e1).cross(e3-e2)).mag()*0.5;
G4double s3 = (e2.cross(e3)).mag()*0.5;
G4double s4 = (e1.cross(e3)).mag()*0.5;
G4double h1 = 2.*s1 / std::max(std::max(leng1,leng2),diag1);
G4double h2 = 2.*s2 / std::max(std::max(leng2,leng3),diag2);
G4double h3 = 2.*s3 / std::max(std::max(leng3,leng4),diag1);
G4double h4 = 2.*s4 / std::max(std::max(leng4,leng1),diag2);
if (h1 <= delta || h2 <= delta || h3 <= delta || h4 <= delta )
{
ostringstream message;
message << "Facet has three or more collinear vertices." << G4endl
<< "P0 = " << GetVertex(0) << G4endl
<< "P1 = " << GetVertex(1) << G4endl
<< "P2 = " << GetVertex(2) << G4endl
<< "P3 = " << GetVertex(3) << G4endl
<< "Height in P0-P1-P2 = " << h1 << G4endl
<< "Height in P1-P2-P3 = " << h2 << G4endl
<< "Height in P2-P3-P4 = " << h3 << G4endl
<< "Height in P4-P0-P1 = " << h4;
G4Exception("G4QuadrangularFacet::G4QuadrangularFacet()",
"GeomSolids1001", JustWarning, message);
return;
}
// Check that vertices are coplanar by computing minimal
// height of tetrahedron comprising of vertices
//
G4double smax = std::max( std::max(s1,s2), std::max(s3,s4) );
G4double hmin = 0.5 * std::fabs( e1.dot(e2.cross(e3)) ) / smax;
if (hmin >= epsilon)
{
ostringstream message;
message << "Facet is not planar." << G4endl
<< "Disrepancy = " << hmin << G4endl
<< "P0 = " << GetVertex(0) << G4endl
<< "P1 = " << GetVertex(1) << G4endl
<< "P2 = " << GetVertex(2) << G4endl
<< "P3 = " << GetVertex(3);
G4Exception("G4QuadrangularFacet::G4QuadrangularFacet()",
"GeomSolids1001", JustWarning, message);
return;
}
// Check that facet is convex by computing crosspoint
// of diagonals
//
G4ThreeVector normal = e2.cross(e3-e1);
G4double s = kInfinity, t = kInfinity, magnitude2 = normal.mag2();
if (magnitude2 > delta*delta) // check: magnitude2 != 0.
{
s = normal.dot(e1.cross(e3-e1)) / magnitude2;
t = normal.dot(e1.cross(e2)) / magnitude2;
}
if (s <= 0. || s >= 1. || t <= 0. || t >= 1.)
{
ostringstream message;
message << "Facet is not convex." << G4endl
<< "Parameters of crosspoint of diagonals: "
<< s << " and " << t << G4endl
<< "should both be within (0,1) range" << G4endl
<< "P0 = " << GetVertex(0) << G4endl
<< "P1 = " << GetVertex(1) << G4endl
<< "P2 = " << GetVertex(2) << G4endl
<< "P3 = " << GetVertex(3);
G4Exception("G4QuadrangularFacet::G4QuadrangularFacet()",
"GeomSolids1001", JustWarning, message);
return;
}
// Define facet
//
fFacet1 = G4TriangularFacet(GetVertex(0),GetVertex(1),GetVertex(2),ABSOLUTE);
fFacet2 = G4TriangularFacet(GetVertex(0),GetVertex(2),GetVertex(3),ABSOLUTE);
normal = normal.unit();
fFacet1.SetSurfaceNormal(normal);
fFacet2.SetSurfaceNormal(normal);
G4ThreeVector vtmp = 0.5 * (e1 + e2);
fCircumcentre = GetVertex(0) + vtmp;
G4double radiusSqr = vtmp.mag2();
fRadius = std::sqrt(radiusSqr);
// 29.02.2016 Remark by E.Tcherniaev: computation
// of fCircumcenter and fRadius is wrong, however
// it did not create any problem till now.
// Bizarre! Need to investigate!
}
///////////////////////////////////////////////////////////////////////////////
@@ -250,20 +329,21 @@ G4bool G4QuadrangularFacet::Intersect (const G4ThreeVector &p,
///////////////////////////////////////////////////////////////////////////////
//
// Auxiliary method to get a random point on surface
// Auxiliary method to get a uniform random point on the facet
//
G4ThreeVector G4QuadrangularFacet::GetPointOnFace() const
{
G4ThreeVector pr = (G4RandFlat::shoot(0.,1.) < 0.5)
? fFacet1.GetPointOnFace() : fFacet2.GetPointOnFace();
return pr;
G4double s1 = fFacet1.GetArea();
G4double s2 = fFacet2.GetArea();
return ((s1+s2)*G4UniformRand() < s1) ?
fFacet1.GetPointOnFace() : fFacet2.GetPointOnFace();
}
///////////////////////////////////////////////////////////////////////////////
//
// Auxiliary method for returning the surface area
//
G4double G4QuadrangularFacet::GetArea()
G4double G4QuadrangularFacet::GetArea() const
{
G4double area = fFacet1.GetArea() + fFacet2.GetArea();
return area;
@@ -24,7 +24,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TessellatedSolid.cc 94457 2015-11-18 14:35:46Z gcosmo $
// $Id: G4TessellatedSolid.cc 95311 2016-02-04 13:54:13Z gcosmo $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
@@ -1968,7 +1968,7 @@ G4double G4TessellatedSolid::GetCubicVolume ()
G4VFacet &facet = *fFacets[i];
G4double area = facet.GetArea();
G4ThreeVector unit_normal = facet.GetSurfaceNormal();
fCubicVolume += area * (facet.GetVertex(0) * unit_normal);
fCubicVolume += area * (facet.GetVertex(0).dot(unit_normal));
}
fCubicVolume /= 3.;
return fCubicVolume;
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TriangularFacet.cc 87920 2015-01-21 13:11:38Z gcosmo $
// $Id: G4TriangularFacet.cc 95945 2016-03-03 09:54:38Z gcosmo $
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
//
@@ -56,6 +56,10 @@
// and considerable CPU speedup together with the new
// implementation of G4TessellatedSolid.
//
// 23 February 2016 E Tcherniaev, CERN
// Improved test to detect degenerate (too small or
// too narrow) triangles.
//
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#include "G4TriangularFacet.hh"
@@ -96,69 +100,65 @@ G4TriangularFacet::G4TriangularFacet (const G4ThreeVector &vt0,
fE2 = vt2;
}
G4ThreeVector E1xE2 = fE1.cross(fE2);
fArea = 0.5 * E1xE2.mag();
for (G4int i = 0; i < 3; ++i) fIndices[i] = -1;
G4double eMag1 = fE1.mag();
G4double eMag2 = fE2.mag();
G4double eMag3 = (fE2-fE1).mag();
fIsDefined = true;
G4double delta = kCarTolerance; // Set tolerance for checking
if (eMag1 <= kCarTolerance || eMag2 <= kCarTolerance
|| eMag3 <= kCarTolerance)
// Check length of edges
//
G4double leng1 = fE1.mag();
G4double leng2 = (fE2-fE1).mag();
G4double leng3 = fE2.mag();
if (leng1 <= delta || leng2 <= delta || leng3 <= delta)
{
fIsDefined = false;
}
// Check min height of triangle
//
if (fIsDefined)
{
if (2.*fArea/std::max(std::max(leng1,leng2),leng3) <= delta)
{
fIsDefined = false;
}
}
// Define facet
//
if (!fIsDefined)
{
ostringstream message;
message << "Length of sides of facet are too small." << G4endl
<< "fVertices[0] = " << GetVertex(0) << G4endl
<< "fVertices[1] = " << GetVertex(1) << G4endl
<< "fVertices[2] = " << GetVertex(2) << G4endl
<< "Side lengths = fVertices[0]->fVertices[1]" << eMag1 << G4endl
<< "Side lengths = fVertices[0]->fVertices[2]" << eMag2 << G4endl
<< "Side lengths = fVertices[1]->fVertices[2]" << eMag3;
message << "Facet is too small or too narrow." << G4endl
<< "Triangle area = " << fArea << G4endl
<< "P0 = " << GetVertex(0) << G4endl
<< "P1 = " << GetVertex(1) << G4endl
<< "P2 = " << GetVertex(2) << G4endl
<< "Side1 length (P0->P1) = " << leng1 << G4endl
<< "Side2 length (P1->P2) = " << leng2 << G4endl
<< "Side3 length (P2->P0) = " << leng3;
G4Exception("G4TriangularFacet::G4TriangularFacet()",
"GeomSolids1001", JustWarning, message);
fIsDefined = false;
"GeomSolids1001", JustWarning, message);
fSurfaceNormal.set(0,0,0);
fA = fB = fC = 0.0;
fDet = 0.0;
fCircumcentre = vt0 + 0.5*fE1 + 0.5*fE2;
fArea = fRadius = 0.0;
}
else
{
fIsDefined = true;
fSurfaceNormal = fE1.cross(fE2).unit();
fSurfaceNormal = E1xE2.unit();
fA = fE1.mag2();
fB = fE1.dot(fE2);
fC = fE2.mag2();
fDet = fabs(fA*fC - fB*fB);
fDet = std::fabs(fA*fC - fB*fB);
// sMin = -0.5*kCarTolerance/sqrt(fA);
// sMax = 1.0 - sMin;
// tMin = -0.5*kCarTolerance/sqrt(fC);
// G4ThreeVector vtmp = 0.25 * (fE1 + fE2);
fArea = 0.5 * (fE1.cross(fE2)).mag();
G4double lambda0, lambda1;
if(std::fabs(fArea) < kCarTolerance*kCarTolerance)
{
ostringstream message;
message << "Area of Facet is too small, possible flat triangle!" << G4endl
<< " fVertices[0] = " << GetVertex(0) << G4endl
<< " fVertices[1] = " << GetVertex(1) << G4endl
<< " fVertices[2] = " << GetVertex(2) << G4endl
<< "Area = " << fArea;
G4Exception("G4TriangularFacet::G4TriangularFacet()",
"GeomSolids1001", JustWarning, message);
lambda0 = 0.5;
lambda1 = 0.5;
}
else
{
lambda0 = (fA-fB) * fC / (8.0*fArea*fArea);
lambda1 = (fC-fB) * fA / (8.0*fArea*fArea);
}
G4ThreeVector p0 = GetVertex(0);
fCircumcentre = p0 + lambda0*fE1 + lambda1*fE2;
G4double radiusSqr = (fCircumcentre-p0).mag2();
fRadius = sqrt(radiusSqr);
fCircumcentre =
vt0 + (E1xE2.cross(fE1)*fC + fE2.cross(E1xE2)*fA) / (2.*E1xE2.mag2());
fRadius = (fCircumcentre - vt0).mag();
}
}
@@ -752,16 +752,14 @@ G4bool G4TriangularFacet::Intersect (const G4ThreeVector &p,
//
// GetPointOnFace
//
// Auxiliary method for get fA random point on surface
// Auxiliary method, returns a uniform random point on the facet
//
G4ThreeVector G4TriangularFacet::GetPointOnFace() const
{
G4double alpha = G4RandFlat::shoot(0., 1.);
G4double beta = G4RandFlat::shoot(0., 1.);
G4double lambda1 = alpha*beta;
G4double lambda0 = alpha-lambda1;
return GetVertex(0) + lambda0*fE1 + lambda1*fE2;
G4double u = G4UniformRand();
G4double v = G4UniformRand();
if (u+v > 1.) { u = 1. - u; v = 1. - v; }
return GetVertex(0) + u*fE1 + v*fE2;
}
////////////////////////////////////////////////////////////////////////
@@ -770,7 +768,7 @@ G4ThreeVector G4TriangularFacet::GetPointOnFace() const
//
// Auxiliary method for returning the surface fArea
//
G4double G4TriangularFacet::GetArea()
G4double G4TriangularFacet::GetArea() const
{
return fArea;
}
@@ -33,9 +33,9 @@
#include "G4ExtrudedSolid.hh"
#include "G4UExtrudedSolid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4Polyhedron.hh"
#include "G4PolyhedronArbitrary.hh"
////////////////////////////////////////////////////////////////////////
//
@@ -124,4 +124,90 @@ G4UExtrudedSolid::operator=(const G4UExtrudedSolid &source)
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Accessors
G4int G4UExtrudedSolid::GetNofVertices() const
{
return GetShape()->GetNofVertices();
}
G4TwoVector G4UExtrudedSolid::GetVertex(G4int i) const
{
UVector2 v = GetShape()->GetVertex(i);
return G4TwoVector(v.x, v.y);
}
std::vector<G4TwoVector> G4UExtrudedSolid::GetPolygon() const
{
std::vector<UVector2> pol = GetShape()->GetPolygon();
std::vector<G4TwoVector> v;
for (unsigned int i=0; i<pol.size(); ++i)
{
v.push_back(G4TwoVector(pol[i].x, pol[i].y));
}
return v;
}
G4int G4UExtrudedSolid::GetNofZSections() const
{
return GetShape()->GetNofZSections();
}
G4UExtrudedSolid::ZSection G4UExtrudedSolid::GetZSection(G4int i) const
{
return ZSection(GetShape()->GetZSection(i));
}
std::vector<G4UExtrudedSolid::ZSection> G4UExtrudedSolid::GetZSections() const
{
std::vector<UExtrudedSolid::ZSection> sv = GetShape()->GetZSections();
std::vector<G4UExtrudedSolid::ZSection> vec;
for (unsigned int i=0; i<sv.size(); ++i)
{
vec.push_back(ZSection(sv[i]));
}
return vec;
}
///////////////////////////////////////////////////////////////////////////////
//
// CreatePolyhedron()
//
G4Polyhedron* G4UExtrudedSolid::CreatePolyhedron () const
{
G4int nFacets = GetShape()->GetNumberOfFacets();
G4int nVertices = 0;
for (G4int l = 0; l<nFacets; ++l) // compute total number of vertices first
{
VUFacet* facet = GetShape()->GetFacet(l);
G4int n = facet->GetNumberOfVertices();
nVertices += n;
}
G4PolyhedronArbitrary *polyhedron =
new G4PolyhedronArbitrary (nVertices,nFacets);
for (G4int i = 0; i<nFacets; ++i)
{
VUFacet* facet = GetShape()->GetFacet(i);
G4int v[4];
G4int n = facet->GetNumberOfVertices();
for (G4int m = 0; m<n; ++m)
{
UVector3 vtx = facet->GetVertex(m);
polyhedron->AddVertex(G4ThreeVector(vtx.x(), vtx.y(), vtx.z()));
}
if (n > 4) n = 4;
else if (n == 3) v[3] = 0;
for (G4int j=0; j<n; ++j)
{
G4int k = facet->GetVertexIndex(j);
v[j] = k+1;
}
polyhedron->AddFacet(v[0],v[1],v[2],v[3]);
}
polyhedron->SetReferences();
return (G4Polyhedron*) polyhedron;
}
#endif // G4GEOM_USE_USOLIDS
@@ -33,7 +33,7 @@
#include "G4GenericPolycone.hh"
#include "G4UGenericPolycone.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4Polyhedron.hh"
@@ -98,6 +98,30 @@ G4UGenericPolycone::operator=(const G4UGenericPolycone &source)
return *this;
}
G4double G4UGenericPolycone::GetStartPhi() const
{
return GetShape()->GetStartPhi();
}
G4double G4UGenericPolycone::GetEndPhi() const
{
return GetShape()->GetEndPhi();
}
G4bool G4UGenericPolycone::IsOpen() const
{
return GetShape()->IsOpen();
}
G4int G4UGenericPolycone::GetNumRZCorner() const
{
return GetShape()->GetNumRZCorner();
}
G4PolyconeSideRZ G4UGenericPolycone::GetCorner(G4int index) const
{
UPolyconeSideRZ pside = GetShape()->GetCorner(index);
G4PolyconeSideRZ psiderz = { pside.r, pside.z };
return psiderz;
}
G4Polyhedron* G4UGenericPolycone::CreatePolyhedron() const
{
@@ -33,11 +33,14 @@
#include "G4GenericTrap.hh"
#include "G4UGenericTrap.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4Polyhedron.hh"
#include "G4PolyhedronArbitrary.hh"
#include "G4AutoLock.hh"
namespace { G4Mutex UGenericTrapMutex = G4MUTEX_INITIALIZER; }
////////////////////////////////////////////////////////////////////////
//
// Constructor (generic parameters)
@@ -101,6 +104,57 @@ G4UGenericTrap::operator=(const G4UGenericTrap &source)
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Accessors & modifiers
//
G4double G4UGenericTrap::GetZHalfLength() const
{
return GetShape()->GetZHalfLength();
}
G4int G4UGenericTrap::GetNofVertices() const
{
return GetShape()->GetNofVertices();
}
G4TwoVector G4UGenericTrap::GetVertex(G4int index) const
{
UVector2 v = GetShape()->GetVertex(index);
return G4TwoVector(v.x, v.y);
}
const std::vector<G4TwoVector>& G4UGenericTrap::GetVertices() const
{
G4AutoLock l(&UGenericTrapMutex);
std::vector<UVector2> v = GetShape()->GetVertices();
static std::vector<G4TwoVector> vertices; vertices.clear();
for (size_t n=0; n<v.size(); ++n)
{
vertices.push_back(G4TwoVector(v[n].x,v[n].y));
}
return vertices;
}
G4double G4UGenericTrap::GetTwistAngle(G4int index) const
{
return GetShape()->GetTwistAngle(index);
}
G4bool G4UGenericTrap::IsTwisted() const
{
return GetShape()->IsTwisted();
}
G4int G4UGenericTrap::GetVisSubdivisions() const
{
return GetShape()->GetVisSubdivisions();
}
void G4UGenericTrap::SetVisSubdivisions(G4int subdiv)
{
GetShape()->SetVisSubdivisions(subdiv);
}
void G4UGenericTrap::SetZHalfLength(G4double halfZ)
{
GetShape()->SetZHalfLength(halfZ);
}
//////////////////////////////////////////////////////////////////////////
//
// CreatePolyhedron()
@@ -35,9 +35,11 @@
#include "G4Paraboloid.hh"
#include "G4UParaboloid.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4VPVParameterisation.hh"
#include "G4PhysicalConstants.hh"
#include "G4Polyhedron.hh"
////////////////////////////////////////////////////////////////////////
//
@@ -91,6 +93,25 @@ G4UParaboloid& G4UParaboloid::operator = (const G4UParaboloid& rhs)
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Accessors
G4double G4UParaboloid::GetZHalfLength() const
{
return GetShape()->GetDz();
}
G4double G4UParaboloid::GetRadiusMinusZ() const
{
return GetShape()->GetRlo();
}
G4double G4UParaboloid::GetRadiusPlusZ() const
{
return GetShape()->GetRhi();
}
//////////////////////////////////////////////////////////////////////////
//
// Make a clone of the object
@@ -100,4 +121,15 @@ G4VSolid* G4UParaboloid::Clone() const
return new G4UParaboloid(*this);
}
////////////////////////////////////////////////////////////////////////
//
// CreatePolyhedron
//
G4Polyhedron* G4UParaboloid::CreatePolyhedron() const
{
return new G4PolyhedronParaboloid(GetRadiusMinusZ(),
GetRadiusPlusZ(),
GetZHalfLength(), 0., twopi);
}
#endif // G4GEOM_USE_USOLIDS
@@ -32,7 +32,7 @@
#include "G4Polycone.hh"
#include "G4UPolycone.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4VPVParameterisation.hh"
@@ -112,6 +112,67 @@ G4UPolycone &G4UPolycone::operator=( const G4UPolycone &source )
}
////////////////////////////////////////////////////////////////////////
//
// Accessors & modifiers
//
G4double G4UPolycone::GetStartPhi() const
{
return GetShape()->GetStartPhi();
}
G4double G4UPolycone::GetEndPhi() const
{
return GetShape()->GetEndPhi();
}
G4bool G4UPolycone::IsOpen() const
{
return GetShape()->IsOpen();
}
G4int G4UPolycone::GetNumRZCorner() const
{
return GetShape()->GetNumRZCorner();
}
G4PolyconeSideRZ G4UPolycone::GetCorner(G4int index) const
{
UPolyconeSideRZ pside = GetShape()->GetCorner(index);
G4PolyconeSideRZ psiderz = { pside.r, pside.z };
return psiderz;
}
G4PolyconeHistorical* G4UPolycone::GetOriginalParameters() const
{
UPolyconeHistorical* pars = GetShape()->GetOriginalParameters();
G4PolyconeHistorical* pdata = new G4PolyconeHistorical(pars->fNumZPlanes);
pdata->Start_angle = pars->fStartAngle;
pdata->Opening_angle = pars->fOpeningAngle;
for (G4int i=0; i<pars->fNumZPlanes; ++i)
{
pdata->Z_values[i] = pars->fZValues[i];
pdata->Rmin[i] = pars->Rmin[i];
pdata->Rmax[i] = pars->Rmax[i];
}
return pdata;
}
void G4UPolycone::SetOriginalParameters(G4PolyconeHistorical* pars)
{
UPolyconeHistorical* pdata = GetShape()->GetOriginalParameters();
pdata->fStartAngle = pars->Start_angle;
pdata->fOpeningAngle = pars->Opening_angle;
pdata->fNumZPlanes = pars->Num_z_planes;
for (G4int i=0; i<pdata->fNumZPlanes; ++i)
{
pdata->fZValues[i] = pars->Z_values[i];
pdata->Rmin[i] = pars->Rmin[i];
pdata->Rmax[i] = pars->Rmax[i];
}
fRebuildPolyhedron = true;
}
G4bool G4UPolycone::Reset()
{
GetShape()->Reset();
return 0;
}
////////////////////////////////////////////////////////////////////////
//
// Dispatch to parameterisation for replication mechanism dimension
@@ -32,7 +32,7 @@
#include "G4Polyhedra.hh"
#include "G4UPolyhedra.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
#include "G4VPVParameterisation.hh"
@@ -119,6 +119,77 @@ G4UPolyhedra& G4UPolyhedra::operator=( const G4UPolyhedra &source )
}
////////////////////////////////////////////////////////////////////////
//
// Accessors & modifiers
//
G4int G4UPolyhedra::GetNumSide() const
{
return GetShape()->GetNumSide();
}
G4double G4UPolyhedra::GetStartPhi() const
{
return GetShape()->GetStartPhi();
}
G4double G4UPolyhedra::GetEndPhi() const
{
return GetShape()->GetEndPhi();
}
G4bool G4UPolyhedra::IsOpen() const
{
return GetShape()->IsOpen();
}
G4bool G4UPolyhedra::IsGeneric() const
{
return GetShape()->IsGeneric();
}
G4int G4UPolyhedra::GetNumRZCorner() const
{
return GetShape()->GetNumRZCorner();
}
G4PolyhedraSideRZ G4UPolyhedra::GetCorner(G4int index) const
{
UPolyhedraSideRZ pside = GetShape()->GetCorner(index);
G4PolyhedraSideRZ psiderz = { pside.r, pside.z };
return psiderz;
}
G4PolyhedraHistorical* G4UPolyhedra::GetOriginalParameters() const
{
UPolyhedraHistorical* pars = GetShape()->GetOriginalParameters();
G4PolyhedraHistorical* pdata = new G4PolyhedraHistorical(pars->fNumZPlanes);
pdata->Start_angle = pars->fStartAngle;
pdata->Opening_angle = pars->fOpeningAngle;
pdata->numSide = pars->fNumSide;
for (G4int i=0; i<pars->fNumZPlanes; ++i)
{
pdata->Z_values[i] = pars->fZValues[i];
pdata->Rmin[i] = pars->Rmin[i];
pdata->Rmax[i] = pars->Rmax[i];
}
return pdata;
}
void G4UPolyhedra::SetOriginalParameters(G4PolyhedraHistorical* pars)
{
UPolyhedraHistorical* pdata = GetShape()->GetOriginalParameters();
pdata->fStartAngle = pars->Start_angle;
pdata->fOpeningAngle = pars->Opening_angle;
pdata->fNumSide = pars->numSide;
pdata->fNumZPlanes = pars->Num_z_planes;
for (G4int i=0; i<pdata->fNumZPlanes; ++i)
{
pdata->fZValues[i] = pars->Z_values[i];
pdata->Rmin[i] = pars->Rmin[i];
pdata->Rmax[i] = pars->Rmax[i];
}
fRebuildPolyhedron = true;
}
G4bool G4UPolyhedra::Reset()
{
return GetShape()->Reset();
}
////////////////////////////////////////////////////////////////////////
//
// Dispatch to parameterisation for replication mechanism dimension
+40 -1
View File
@@ -36,7 +36,7 @@
#include "G4Tet.hh"
#include "G4UTet.hh"
#if defined(G4GEOM_USE_USOLIDS)
#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
////////////////////////////////////////////////////////////////////////
//
@@ -106,4 +106,43 @@ G4UTet& G4UTet::operator = (const G4UTet& rhs)
return *this;
}
///////////////////////////////////////////////////////////////////////////////
//
// Accessors
//
std::vector<G4ThreeVector> G4UTet::GetVertices() const
{
std::vector<UVector3> vec = GetShape()->GetVertices();
std::vector<G4ThreeVector> vertices;
for (unsigned int i=0; i<vec.size(); ++i)
{
G4ThreeVector v(vec[i].x(), vec[i].y(), vec[i].z());
vertices.push_back(v);
}
return vertices;
}
////////////////////////////////////////////////////////////////////////
//
// CreatePolyhedron
//
G4Polyhedron* G4UTet::CreatePolyhedron() const
{
G4int index = 0;
G4double array[12];
GetShape()->GetParametersList(index, array);
G4Polyhedron *ph=new G4Polyhedron;
G4double xyz[4][3];
const G4int faces[4][4]={{1,3,2,0},{1,4,3,0},{1,2,4,0},{2,3,4,0}};
xyz[0][0]=array[0]; xyz[0][1]=array[1]; xyz[0][2]=array[2]; // fAnchor
xyz[1][0]=array[3]; xyz[1][1]=array[4]; xyz[1][2]=array[5]; // fP2
xyz[2][0]=array[6]; xyz[2][1]=array[7]; xyz[2][2]=array[8]; // fP3
xyz[3][0]=array[9]; xyz[3][1]=array[10]; xyz[3][2]=array[11]; // fP4
ph->createPolyhedron(4,4,xyz,faces);
return ph;
}
#endif // G4GEOM_USE_USOLIDS