Import Geant4 11.4.0 source tree
This commit is contained in:
@@ -33,9 +33,9 @@
|
||||
// The choice of protected vs private is due to the fact that we want
|
||||
// to propagate functions further down in the inheritance hierarchy.
|
||||
|
||||
// Author:
|
||||
// 17.05.17 G.Cosmo: Adapted for G4VSolid from original G4USolids bridge
|
||||
// class and the USolidsAdapter class in VecGeom.
|
||||
// Author: Gabriele Cosmo (CERN), 17.05.2017
|
||||
// Adapted for G4VSolid from original G4USolids bridge
|
||||
// class and the USolidsAdapter class in VecGeom.
|
||||
// ------------------------------------------------------------------------
|
||||
#ifndef G4UADAPTER_HH
|
||||
#define G4UADAPTER_HH
|
||||
@@ -62,6 +62,12 @@
|
||||
|
||||
class G4VPVParameterisation;
|
||||
|
||||
/**
|
||||
* @brief G4UAdapter is a utility class for adapting VecGeom solids API to
|
||||
* Geant4 solids. The Adapter is supposed to be a G4VSolid
|
||||
* "implemented-in-terms-of" the VecGeom UnplacedVolume_t.
|
||||
*/
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
class G4UAdapter : public G4VSolid, protected UnplacedVolume_t
|
||||
{
|
||||
@@ -69,138 +75,210 @@ class G4UAdapter : public G4VSolid, protected UnplacedVolume_t
|
||||
|
||||
using U3Vector = vecgeom::Vector3D<G4double>;
|
||||
|
||||
/** VecGeom volumes have special delete/new ("AlignedBase")
|
||||
and we need to make these functions public again. */
|
||||
using UnplacedVolume_t::operator delete;
|
||||
using UnplacedVolume_t::operator new;
|
||||
// VecGeom volumes have special delete/new ("AlignedBase")
|
||||
// and we need to make these functions public again
|
||||
|
||||
G4UAdapter(const G4String& name)
|
||||
: G4VSolid(name)
|
||||
{ kHalfTolerance = 0.5*kCarTolerance; }
|
||||
/**
|
||||
* Constructor taking a name.
|
||||
* @param[in] name The name of the volume.
|
||||
*/
|
||||
G4UAdapter(const G4String& name);
|
||||
|
||||
/**
|
||||
* Constructor templated on arguments for UnplacedVolume_t.
|
||||
* @param[in] name The name of the volume.
|
||||
* @param[in] params Templated arguments for UnplacedVolume_t.
|
||||
*/
|
||||
template <typename... T>
|
||||
G4UAdapter(const G4String& name, const T &... params)
|
||||
: G4VSolid(name), UnplacedVolume_t(params...)
|
||||
{ kHalfTolerance = 0.5*kCarTolerance; }
|
||||
G4UAdapter(const G4String& name, const T &... params);
|
||||
|
||||
/**
|
||||
* Virtual destructor.
|
||||
*/
|
||||
virtual ~G4UAdapter();
|
||||
|
||||
G4bool operator==(const G4UAdapter& s) const;
|
||||
// Return true only if addresses are the same.
|
||||
/**
|
||||
* Copy constructor and assignment operator.
|
||||
*/
|
||||
G4UAdapter(const G4UAdapter& rhs);
|
||||
G4UAdapter& operator=(const G4UAdapter& rhs);
|
||||
|
||||
/**
|
||||
* Equality operator. Returns true only if addresses are the same.
|
||||
*/
|
||||
G4bool operator==(const G4UAdapter& s) const;
|
||||
|
||||
/**
|
||||
* Calculates the minimum and maximum extent of the solid, when under the
|
||||
* specified transform, and within the specified limits.
|
||||
* @param[in] pAxis The axis along which compute the extent.
|
||||
* @param[in] pVoxelLimit The limiting space dictated by voxels.
|
||||
* @param[in] pTransform The internal transformation applied to the solid.
|
||||
* @param[out] pMin The minimum extent value.
|
||||
* @param[out] pMax The maximum extent value.
|
||||
* @returns True if the solid is intersected by the extent region.
|
||||
*/
|
||||
virtual G4bool CalculateExtent(const EAxis pAxis,
|
||||
const G4VoxelLimits& pVoxelLimit,
|
||||
const G4AffineTransform& pTransform,
|
||||
G4double& pMin, G4double& pMax) const override;
|
||||
// Calculate the minimum and maximum extent of the solid, when under the
|
||||
// specified transform, and within the specified limits. If the solid
|
||||
// is not intersected by the region, return false, else return true.
|
||||
|
||||
/**
|
||||
* Returns the characterisation of a point at offset 'p' respect
|
||||
* to the shape.
|
||||
* @param[in] p The point at offset p.
|
||||
* @returns kOutside if the point is outside the shapes boundaries
|
||||
* plus Tolerance/2; kSurface if the point is less than
|
||||
* Tolerance/2 from a surface; kInside otherwise.
|
||||
*/
|
||||
virtual EInside Inside(const G4ThreeVector& p) const override;
|
||||
// Returns kOutside if the point at offset p is outside the shapes
|
||||
// boundaries plus Tolerance/2, kSurface if the point is <= Tolerance/2
|
||||
// from a surface, otherwise kInside.
|
||||
|
||||
/**
|
||||
* Returns the outwards pointing unit normal of the shape for the
|
||||
* surface closest to the point at offset 'p'.
|
||||
* @param[in] p The point at offset p.
|
||||
* @returns The outwards pointing unit normal.
|
||||
*/
|
||||
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
|
||||
// Returns the outwards pointing unit normal of the shape for the
|
||||
// surface closest to the point at offset p.
|
||||
|
||||
/**
|
||||
* Returns the distance along the normalised vector 'v' to the shape,
|
||||
* from the point at offset 'p'. If there is no intersection, returns
|
||||
* kInfinity. The first intersection resulting from 'leaving' a
|
||||
* surface/volume is discarded. Hence, it is tolerant of points on
|
||||
* the surface of the shape.
|
||||
* @param[in] p The point at offset p.
|
||||
* @param[in] v The normalised direction vector.
|
||||
* @returns The distance to enter the shape.
|
||||
*/
|
||||
virtual G4double DistanceToIn(const G4ThreeVector& p,
|
||||
const G4ThreeVector& v) const override;
|
||||
// Return the distance along the normalised vector v to the shape,
|
||||
// from the point at offset p. If there is no intersection, return
|
||||
// kInfinity. The first intersection resulting from `leaving' a
|
||||
// surface/volume is discarded. Hence, it is tolerant of points on
|
||||
// the surface of the shape.
|
||||
|
||||
/**
|
||||
* Calculates the distance to the nearest surface of a shape from an
|
||||
* outside point. The distance can be an underestimate.
|
||||
* @param[in] p The point at offset p.
|
||||
* @returns The safety distance to enter the shape.
|
||||
*/
|
||||
virtual G4double DistanceToIn(const G4ThreeVector& p) const override;
|
||||
// Calculate the distance to the nearest surface of a shape from an
|
||||
// outside point. The distance can be an underestimate.
|
||||
|
||||
/**
|
||||
* Returns the distance along the normalised vector 'v' to the shape,
|
||||
* from a point at an offset 'p' inside or on the surface of the shape.
|
||||
* Intersections with surfaces, when the point is less than Tolerance/2
|
||||
* from a surface must be ignored.
|
||||
* @param[in] p The point at offset p.
|
||||
* @param[in] v The normalised direction vector.
|
||||
* @param[in] calcNorm Flag to indicate if to calculate the normal or not.
|
||||
* @param[out] validNorm Flag set to true if the solid lies entirely
|
||||
* behind or on the exiting surface. It is set false if the
|
||||
* solid does not lie entirely behind or on the exiting surface.
|
||||
* 'calcNorm' must be true, otherwise it is unused.
|
||||
* @param[out] n The exiting outwards normal vector (undefined Magnitude).
|
||||
* 'calcNorm' must be true, otherwise it is unused.
|
||||
* @returns The distance to exit the shape.
|
||||
*/
|
||||
virtual G4double DistanceToOut(const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm = false,
|
||||
G4bool* validNorm = 0,
|
||||
G4ThreeVector* n = 0) const override;
|
||||
// Return the distance along the normalised vector v to the shape,
|
||||
// from a point at an offset p inside or on the surface of the shape.
|
||||
// Intersections with surfaces, when the point is < Tolerance/2 from a
|
||||
// surface must be ignored.
|
||||
// If calcNorm==true:
|
||||
// validNorm set true if the solid lies entirely behind or on the
|
||||
// exiting surface.
|
||||
// n set to exiting outwards normal vector (undefined Magnitude).
|
||||
// validNorm set to false if the solid does not lie entirely behind
|
||||
// or on the exiting surface
|
||||
// If calcNorm==false:
|
||||
// validNorm and n are unused.
|
||||
//
|
||||
// Must be called as solid.DistanceToOut(p,v) or by specifying all
|
||||
// the parameters.
|
||||
|
||||
/**
|
||||
* Calculates the distance to the nearest surface of a shape from an
|
||||
* inside point 'p'. The distance can be an underestimate.
|
||||
* @param[in] p The point at offset p.
|
||||
* @returns The safety distance to exit the shape.
|
||||
*/
|
||||
virtual G4double DistanceToOut(const G4ThreeVector& p) const override;
|
||||
// Calculate the distance to the nearest surface of a shape from an
|
||||
// inside point. The distance can be an underestimate.
|
||||
|
||||
/**
|
||||
* Dispatch method for parameterisation replication mechanism and
|
||||
* dimension computation. Throws exception if ComputeDimensions() is
|
||||
* called from an illegal derived class.
|
||||
*/
|
||||
virtual void ComputeDimensions(G4VPVParameterisation* p,
|
||||
const G4int n,
|
||||
const G4VPhysicalVolume* pRep) override;
|
||||
// Throw exception if ComputeDimensions called from an illegal
|
||||
// derived class.
|
||||
|
||||
/**
|
||||
* Returns an estimation of the solid volume in internal units.
|
||||
* This method may be overloaded by derived classes to compute the
|
||||
* exact geometrical quantity for solids where this is possible,
|
||||
* or anyway to cache the computed value.
|
||||
* Note: the computed value is NOT cached.
|
||||
*/
|
||||
virtual G4double GetCubicVolume() override;
|
||||
// Returns an estimation of the solid volume in internal units.
|
||||
// This method may be overloaded by derived classes to compute the
|
||||
// exact geometrical quantity for solids where this is possible,
|
||||
// or anyway to cache the computed value.
|
||||
// Note: the computed value is NOT cached.
|
||||
|
||||
/**
|
||||
* Returns an estimation of the solid surface area in internal units.
|
||||
* This method may be overloaded by derived classes to compute the
|
||||
* exact geometrical quantity for solids where this is possible,
|
||||
* or anyway to cache the computed value.
|
||||
* Note: the computed value is NOT cached.
|
||||
*/
|
||||
virtual G4double GetSurfaceArea() override;
|
||||
// Return an estimation of the solid surface area in internal units.
|
||||
// This method may be overloaded by derived classes to compute the
|
||||
// exact geometrical quantity for solids where this is possible,
|
||||
// or anyway to cache the computed value.
|
||||
// Note: the computed value is NOT cached.
|
||||
|
||||
/**
|
||||
* Returns a random point located on the surface of the solid.
|
||||
*/
|
||||
virtual G4ThreeVector GetPointOnSurface() const override;
|
||||
// Returns a random point located on the surface of the solid.
|
||||
|
||||
/**
|
||||
* Returns the number of constituents used for construction of the solid.
|
||||
* For non-Boolean solids the return value is one.
|
||||
*/
|
||||
virtual G4int GetNumOfConstituents() const override;
|
||||
// Returns the number of constituents used for construction of the solid.
|
||||
// For non-Boolean solids the return value is one.
|
||||
|
||||
/**
|
||||
* Returns true if the solid has only planar faces, false otherwise.
|
||||
*/
|
||||
virtual G4bool IsFaceted() const override;
|
||||
// Returns true if the solid has only planar faces, false otherwise.
|
||||
|
||||
/**
|
||||
* Provides identification of the class of an object
|
||||
* (required for persistency).
|
||||
*/
|
||||
virtual G4GeometryType GetEntityType() const override;
|
||||
// Provide identification of the class of an object.
|
||||
// (required for persistency)
|
||||
|
||||
/**
|
||||
* Returns a pointer of a dynamically allocated copy of the solid.
|
||||
* Returns a null pointer with warning in case the concrete solid does not
|
||||
* implement this method. The caller has responsibility for ownership.
|
||||
*/
|
||||
virtual G4VSolid* Clone() const override;
|
||||
// Returns a pointer of a dynamically allocated copy of the solid.
|
||||
// Returns NULL pointer with warning in case the concrete solid does not
|
||||
// implement this method. The caller has responsibility for ownership.
|
||||
|
||||
/**
|
||||
* Dumps contents of the solid to a stream.
|
||||
*/
|
||||
virtual std::ostream& StreamInfo(std::ostream& os) const override;
|
||||
// Dumps contents of the solid to a stream.
|
||||
|
||||
/**
|
||||
* A "double dispatch" function which identifies the solid
|
||||
* to the graphics scene for visualization.
|
||||
*/
|
||||
virtual void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
|
||||
// A "double dispatch" function which identifies the solid
|
||||
// to the graphics scene for visualization.
|
||||
|
||||
/**
|
||||
* Provides extent (bounding box) as possible hint to the graphics view.
|
||||
*/
|
||||
virtual G4VisExtent GetExtent() const override;
|
||||
// Provide extent (bounding box) as possible hint to the graphics view.
|
||||
|
||||
/**
|
||||
* Creates a Polyhedron used for Visualisation.
|
||||
*/
|
||||
virtual G4Polyhedron* CreatePolyhedron() const override;
|
||||
// Create Polyhedron used for Visualisation
|
||||
|
||||
/**
|
||||
* Smart access function - creates on request and stores for future
|
||||
* access. A null pointer means "not available".
|
||||
*/
|
||||
virtual G4Polyhedron* GetPolyhedron() const override;
|
||||
// Smart access function - creates on request and stores for future
|
||||
// access. A null pointer means "not available".
|
||||
|
||||
G4UAdapter(const G4UAdapter& rhs);
|
||||
G4UAdapter& operator=(const G4UAdapter& rhs);
|
||||
// Copy constructor and assignment operator.
|
||||
|
||||
public: // VecGeom overridden methods
|
||||
// VecGeom overridden methods ---------------------------------------------
|
||||
|
||||
vecgeom::Precision
|
||||
DistanceToOut(U3Vector const& position, U3Vector const& direction,
|
||||
@@ -242,7 +320,8 @@ class G4UAdapter : public G4VSolid, protected UnplacedVolume_t
|
||||
mutable G4bool fRebuildPolyhedron = false;
|
||||
mutable G4Polyhedron* fPolyhedron = nullptr;
|
||||
|
||||
G4double kHalfTolerance; // Cached geometrical tolerance
|
||||
/** Cached geometrical tolerance. */
|
||||
G4double kHalfTolerance;
|
||||
|
||||
using UnplacedVolume_t::DistanceToOut;
|
||||
using UnplacedVolume_t::DistanceToIn;
|
||||
@@ -250,303 +329,7 @@ class G4UAdapter : public G4VSolid, protected UnplacedVolume_t
|
||||
|
||||
// Inline implementations
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4UAdapter<UnplacedVolume_t>::~G4UAdapter()
|
||||
{
|
||||
delete fPolyhedron; fPolyhedron = nullptr;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4bool G4UAdapter<UnplacedVolume_t>::
|
||||
operator==(const G4UAdapter& rhs) const
|
||||
{
|
||||
return (this == &rhs) ? true : false;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4UAdapter<UnplacedVolume_t>::
|
||||
G4UAdapter(const G4UAdapter& rhs)
|
||||
: G4VSolid(rhs), UnplacedVolume_t(rhs)
|
||||
{
|
||||
kHalfTolerance = 0.5*kCarTolerance;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4UAdapter<UnplacedVolume_t>& G4UAdapter<UnplacedVolume_t>::
|
||||
operator=(const G4UAdapter& rhs)
|
||||
{
|
||||
// Check assignment to self
|
||||
//
|
||||
if (this == &rhs)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Copy base class data
|
||||
//
|
||||
G4VSolid::operator=(rhs);
|
||||
UnplacedVolume_t::operator=(rhs);
|
||||
|
||||
// Copy data
|
||||
//
|
||||
fRebuildPolyhedron = false;
|
||||
delete fPolyhedron; fPolyhedron = nullptr;
|
||||
kHalfTolerance = 0.5*kCarTolerance;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
EInside G4UAdapter<UnplacedVolume_t>::
|
||||
Inside(const G4ThreeVector& p) const
|
||||
{
|
||||
U3Vector pt(p.x(), p.y(), p.z());
|
||||
vecgeom::EnumInside in_temp;
|
||||
EInside in = kOutside;
|
||||
|
||||
in_temp = UnplacedVolume_t::Inside(pt);
|
||||
|
||||
if (in_temp == vecgeom::EnumInside::eInside) in = kInside;
|
||||
else if (in_temp == vecgeom::EnumInside::eSurface) in = kSurface;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4ThreeVector G4UAdapter<UnplacedVolume_t>::
|
||||
SurfaceNormal(const G4ThreeVector& pt) const
|
||||
{
|
||||
U3Vector p(pt.x(), pt.y(), pt.z());
|
||||
U3Vector n;
|
||||
UnplacedVolume_t::Normal(p, n);
|
||||
return G4ThreeVector(n.x(), n.y(), n.z());
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4double G4UAdapter<UnplacedVolume_t>::
|
||||
DistanceToIn(const G4ThreeVector& pt, const G4ThreeVector& d) const
|
||||
{
|
||||
U3Vector p(pt.x(), pt.y(), pt.z());
|
||||
U3Vector v(d.x(), d.y(), d.z());
|
||||
G4double dist = UnplacedVolume_t::DistanceToIn(p, v, kInfinity);
|
||||
|
||||
// apply Geant4 distance conventions
|
||||
//
|
||||
if (dist < kHalfTolerance) return 0.0;
|
||||
return (dist > kInfinity) ? kInfinity : dist;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4double G4UAdapter<UnplacedVolume_t>::
|
||||
DistanceToIn(const G4ThreeVector& pt) const
|
||||
{
|
||||
U3Vector p(pt.x(), pt.y(), pt.z());
|
||||
G4double dist = UnplacedVolume_t::SafetyToIn(p);
|
||||
|
||||
// Apply Geant4 convention: convert negative values to zero
|
||||
//
|
||||
if (dist < kHalfTolerance) return 0.0;
|
||||
return (dist > kInfinity) ? kInfinity : dist;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4double G4UAdapter<UnplacedVolume_t>::
|
||||
DistanceToOut(const G4ThreeVector& pt, const G4ThreeVector& d,
|
||||
const G4bool calcNorm, G4bool* validNorm,
|
||||
G4ThreeVector* norm) const
|
||||
{
|
||||
U3Vector p(pt.x(), pt.y(), pt.z());
|
||||
U3Vector v(d.x(), d.y(), d.z());
|
||||
|
||||
G4double dist = UnplacedVolume_t::DistanceToOut(p, v, kInfinity);
|
||||
if(calcNorm)
|
||||
{
|
||||
*validNorm = UnplacedVolume_t::IsConvex();
|
||||
U3Vector n, hitpoint = p + dist * v;
|
||||
UnplacedVolume_t::Normal(hitpoint, n);
|
||||
norm->set(n.x(), n.y(), n.z());
|
||||
}
|
||||
|
||||
// Apply Geant4 distance conventions
|
||||
//
|
||||
if (dist < kHalfTolerance) return 0.0;
|
||||
return (dist > kInfinity) ? kInfinity : dist;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4double G4UAdapter<UnplacedVolume_t>::
|
||||
DistanceToOut(const G4ThreeVector& pt) const
|
||||
{
|
||||
U3Vector p(pt.x(), pt.y(), pt.z());
|
||||
G4double dist = UnplacedVolume_t::SafetyToOut(p);
|
||||
|
||||
// Apply Geant4 convention: convert negative values to zero
|
||||
//
|
||||
if (dist < kHalfTolerance) return 0.0;
|
||||
return (dist > kInfinity) ? kInfinity : dist;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4double G4UAdapter<UnplacedVolume_t>::GetCubicVolume()
|
||||
{
|
||||
return UnplacedVolume_t::Capacity();
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4double G4UAdapter<UnplacedVolume_t>::GetSurfaceArea()
|
||||
{
|
||||
return UnplacedVolume_t::SurfaceArea();
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4ThreeVector G4UAdapter<UnplacedVolume_t>::GetPointOnSurface() const
|
||||
{
|
||||
U3Vector p = UnplacedVolume_t::SamplePointOnSurface();
|
||||
return G4ThreeVector(p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4int G4UAdapter<UnplacedVolume_t>::GetNumOfConstituents() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4bool G4UAdapter<UnplacedVolume_t>::IsFaceted() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Inline visualization adapters
|
||||
|
||||
namespace
|
||||
{
|
||||
G4Mutex pMutex = G4MUTEX_INITIALIZER;
|
||||
}
|
||||
|
||||
// Free function to enable ostream output
|
||||
template <class UnplacedVolume_t>
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const G4UAdapter<UnplacedVolume_t>& uAdapted)
|
||||
{
|
||||
return uAdapted.StreamInfo(os);
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
void G4UAdapter<UnplacedVolume_t>::
|
||||
ComputeDimensions(G4VPVParameterisation*, const G4int,
|
||||
const G4VPhysicalVolume*)
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Illegal call to G4UAdapter::ComputeDimensions()" << G4endl
|
||||
<< "Method not overloaded by derived class !";
|
||||
G4Exception("G4UAdapter::ComputeDimensions()", "GeomSolids0003",
|
||||
FatalException, message);
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
void G4UAdapter<UnplacedVolume_t>::
|
||||
DescribeYourselfTo(G4VGraphicsScene& scene) const
|
||||
{
|
||||
scene.AddSolid(*this);
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4GeometryType G4UAdapter<UnplacedVolume_t>::
|
||||
GetEntityType() const
|
||||
{
|
||||
|
||||
G4String string = "VSolid"; // UnplacedVolume_t::GetEntityType();
|
||||
return "G4" + string;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
std::ostream& G4UAdapter<UnplacedVolume_t>::
|
||||
StreamInfo(std::ostream& os) const
|
||||
{
|
||||
UnplacedVolume_t::Print(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4VSolid* G4UAdapter<UnplacedVolume_t>::Clone() const
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Clone() method not implemented for type: "
|
||||
<< GetEntityType() << "!" << G4endl
|
||||
<< "Returning NULL pointer!";
|
||||
G4Exception("G4UAdapter::Clone()", "GeomSolids1001", JustWarning, message);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4bool G4UAdapter<UnplacedVolume_t>::CalculateExtent(const EAxis pAxis,
|
||||
const G4VoxelLimits& pVoxelLimit,
|
||||
const G4AffineTransform& pTransform,
|
||||
G4double& pMin, G4double& pMax) const
|
||||
{
|
||||
U3Vector vmin, vmax;
|
||||
UnplacedVolume_t::Extent(vmin,vmax);
|
||||
G4ThreeVector bmin(vmin.x(),vmin.y(),vmin.z());
|
||||
G4ThreeVector bmax(vmax.x(),vmax.y(),vmax.z());
|
||||
|
||||
// Check correctness of the bounding box
|
||||
//
|
||||
if (bmin.x() >= bmax.x() || bmin.y() >= bmax.y() || bmin.z() >= bmax.z())
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Bad bounding box (min >= max) for solid: "
|
||||
<< GetName() << " - " << GetEntityType() << " !"
|
||||
<< "\nmin = " << bmin
|
||||
<< "\nmax = " << bmax;
|
||||
G4Exception("G4UAdapter::CalculateExtent()", "GeomMgt0001",
|
||||
JustWarning, message);
|
||||
StreamInfo(G4cout);
|
||||
}
|
||||
|
||||
G4BoundingEnvelope bbox(bmin,bmax);
|
||||
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4Polyhedron* G4UAdapter<UnplacedVolume_t>::CreatePolyhedron() const
|
||||
{
|
||||
// Must be implemented in concrete wrappers...
|
||||
|
||||
std::ostringstream message;
|
||||
message << "Visualization not supported for USolid shape "
|
||||
<< GetEntityType() << "... Sorry!" << G4endl;
|
||||
G4Exception("G4UAdapter::CreatePolyhedron()", "GeomSolids0003",
|
||||
FatalException, message);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4Polyhedron* G4UAdapter<UnplacedVolume_t>::GetPolyhedron() const
|
||||
{
|
||||
if (!fPolyhedron ||
|
||||
fRebuildPolyhedron ||
|
||||
fPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
|
||||
fPolyhedron->GetNumberOfRotationSteps())
|
||||
{
|
||||
G4AutoLock l(&pMutex);
|
||||
delete fPolyhedron;
|
||||
fPolyhedron = CreatePolyhedron();
|
||||
fRebuildPolyhedron = false;
|
||||
l.unlock();
|
||||
}
|
||||
return fPolyhedron;
|
||||
}
|
||||
|
||||
template <class UnplacedVolume_t>
|
||||
G4VisExtent G4UAdapter<UnplacedVolume_t>::GetExtent() const
|
||||
{
|
||||
U3Vector vmin, vmax;
|
||||
UnplacedVolume_t::Extent(vmin,vmax);
|
||||
return G4VisExtent(vmin.x(),vmax.x(),
|
||||
vmin.y(),vmax.y(),
|
||||
vmin.z(),vmax.z());
|
||||
}
|
||||
#include "G4UAdapter.icc"
|
||||
|
||||
#endif // G4GEOM_USE_USOLIDS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user