112 if (
this == &rhs) {
return *
this; }
133 pMin.
set(std::max(minA.
x(),minB.
x()),
134 std::max(minA.
y(),minB.
y()),
135 std::max(minA.
z(),minB.
z()));
137 pMax.
set(std::min(maxA.
x(),maxB.
x()),
138 std::min(maxA.
y(),maxB.
y()),
139 std::min(maxA.
z(),maxB.
z()));
143 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
145 std::ostringstream message;
146 message <<
"Bad bounding box (min >= max) for solid: "
148 <<
"\npMin = " << pMin
149 <<
"\npMax = " << pMax;
150 G4Exception(
"G4IntersectionSolid::BoundingLimits()",
"GeomMgt0001",
177 pMin = std::max( minA, minB );
178 pMax = std::min( maxA, maxB );
196 if(positionA ==
kOutside)
return positionA;
199 if(positionA ==
kInside)
return positionB;
201 if(positionB ==
kOutside)
return positionB;
220 G4cout <<
"WARNING - Invalid call in "
221 <<
"G4IntersectionSolid::SurfaceNormal(p)" <<
G4endl
222 <<
" Point p is outside !" <<
G4endl;
224 G4cerr <<
"WARNING - Invalid call in "
225 <<
"G4IntersectionSolid::SurfaceNormal(p)" <<
G4endl
226 <<
" Point p is outside !" <<
G4endl;
252 G4cout <<
"WARNING - Invalid call in "
253 <<
"G4IntersectionSolid::SurfaceNormal(p)" <<
G4endl
254 <<
" Point p is out of surface !" <<
G4endl;
256 G4cerr <<
"WARNING - Invalid call in "
257 <<
"G4IntersectionSolid::SurfaceNormal(p)" <<
G4endl
258 <<
" Point p is out of surface !" <<
G4endl;
278 G4cout <<
"WARNING - Invalid call in "
279 <<
"G4IntersectionSolid::DistanceToIn(p,v)" <<
G4endl
280 <<
" Point p is inside !" <<
G4endl;
283 G4cerr <<
"WARNING - Invalid call in "
284 <<
"G4IntersectionSolid::DistanceToIn(p,v)" <<
G4endl
285 <<
" Point p is inside !" <<
G4endl;
298 G4bool doA =
true, doB =
true;
300 static const std::size_t max_trials=10000;
301 for (std::size_t trial=0; trial<max_trials; ++trial)
313 if( dA1 == kInfinity )
return kInfinity;
331 if(dB1 == kInfinity)
return kInfinity;
344 if( dB1 < dA2 )
return dB1;
354 if( dA1 < dB2 )
return dA1;
365 G4Exception(
"G4IntersectionSolid::DistanceToIn(p,v)",
367 "Reached maximum number of iterations! Returning zero.");
383 G4cout <<
"WARNING - Invalid call in "
384 <<
"G4IntersectionSolid::DistanceToIn(p)" <<
G4endl
385 <<
" Point p is inside !" <<
G4endl;
387 G4cerr <<
"WARNING - Invalid call in "
388 <<
"G4IntersectionSolid::DistanceToIn(p)" <<
G4endl
389 <<
" Point p is inside !" <<
G4endl;
427 G4bool validNormA, validNormB;
441 G4cout <<
"WARNING - Invalid call in "
442 <<
"G4IntersectionSolid::DistanceToOut(p,v)" <<
G4endl
443 <<
" Point p is outside !" <<
G4endl;
446 G4cerr <<
"WARNING - Invalid call in "
447 <<
"G4IntersectionSolid::DistanceToOut(p,v)" <<
G4endl
448 <<
" Point p is outside !" <<
G4endl;
456 G4double dist = std::min(distA,distB) ;
462 *validNorm = validNormA;
467 *validNorm = validNormB;
485 G4cout <<
"WARNING - Invalid call in "
486 <<
"G4IntersectionSolid::DistanceToOut(p)" <<
G4endl
487 <<
" Point p is outside !" <<
G4endl;
489 G4cerr <<
"WARNING - Invalid call in "
490 <<
"G4IntersectionSolid::DistanceToOut(p)" <<
G4endl
491 <<
" Point p is outside !" <<
G4endl;
518 return {
"G4IntersectionSolid"};
554 if (processor.
execute(*result))
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
G4BooleanSolid & operator=(const G4BooleanSolid &rhs)
G4Polyhedron * GetPolyhedron() const override
const G4VSolid * GetConstituentSolid(G4int no) const override
static G4VBooleanProcessor * fExternalBoolProcessor
G4Polyhedron * StackPolyhedron(HepPolyhedronProcessor &, const G4VSolid *) const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override
G4GeometryType GetEntityType() const override
G4Polyhedron * CreatePolyhedron() const override
~G4IntersectionSolid() override
G4IntersectionSolid & operator=(const G4IntersectionSolid &rhs)
G4IntersectionSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const override
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
void DescribeYourselfTo(G4VGraphicsScene &scene) const override
EInside Inside(const G4ThreeVector &p) const override
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const override
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
G4VSolid * Clone() const override
virtual G4PolyhedronArbitrary * Intersection(G4Polyhedron *, G4Polyhedron *)
virtual void AddSolid(const G4Box &)=0
virtual G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const =0
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const =0
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
virtual void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
bool execute(HepPolyhedron &)