127 if (
this == &rhs) {
return *
this; }
135 halfCarTolerance = rhs.halfCarTolerance;
144void G4UnionSolid::Init()
149 fPMin = pmin - pdelta;
150 fPMax = pmax + pdelta;
165 pMin.
set(std::min(minA.
x(),minB.
x()),
166 std::min(minA.
y(),minB.
y()),
167 std::min(minA.
z(),minB.
z()));
169 pMax.
set(std::max(maxA.
x(),maxB.
x()),
170 std::max(maxA.
y(),maxB.
y()),
171 std::max(maxA.
z(),maxB.
z()));
175 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
177 std::ostringstream message;
178 message <<
"Bad bounding box (min >= max) for solid: "
180 <<
"\npMin = " << pMin
181 <<
"\npMax = " << pMax;
182 G4Exception(
"G4UnionSolid::BoundingLimits()",
"GeomMgt0001",
199 G4bool touchesA, touchesB, out ;
200 G4double minA = kInfinity, minB = kInfinity,
201 maxA = -kInfinity, maxB = -kInfinity;
204 pTransform, minA, maxA);
206 pTransform, minB, maxB);
207 if( touchesA || touchesB )
209 pMin = std::min( minA, minB );
210 pMax = std::max( maxA, maxB );
229 if (std::max(p.
z()-fPMax.
z(), fPMin.
z()-p.
z()) > 0) {
return kOutside; }
232 if (positionA ==
kInside) {
return positionA; }
234 if (positionA ==
kOutside) {
return positionB; }
236 if (positionB ==
kInside) {
return positionB; }
237 if (positionB ==
kOutside) {
return positionA; }
271 return (normalA + normalB).
unit();
275 G4String surf[3] = {
"OUTSIDE",
"SURFACE",
"INSIDE" };
276 std::ostringstream message;
277 G4int oldprc = message.precision(16);
278 message <<
"Invalid call of SurfaceNormal(p) for union solid: "
280 <<
"\nPoint p" << p <<
" is " << surf[
Inside(p)] <<
" !!!";
281 message.precision(oldprc);
282 G4Exception(
"G4UnionSolid::SurfaceNormal()",
"GeomMgt0001",
299 G4cout <<
"WARNING - Invalid call in "
300 <<
"G4UnionSolid::DistanceToIn(p,v)" <<
G4endl
301 <<
" Point p is inside !" <<
G4endl;
304 G4cerr <<
"WARNING - Invalid call in "
305 <<
"G4UnionSolid::DistanceToIn(p,v)" <<
G4endl
306 <<
" Point p is inside !" <<
G4endl;
327 G4cout <<
"WARNING - Invalid call in "
328 <<
"G4UnionSolid::DistanceToIn(p)" <<
G4endl
329 <<
" Point p is inside !" <<
G4endl;
331 G4cerr <<
"WARNING - Invalid call in "
332 <<
"G4UnionSolid::DistanceToIn(p)" <<
G4endl
333 <<
" Point p is inside !" <<
G4endl;
339 G4double safety = std::min(distA,distB) ;
340 if(safety < 0.0) safety = 0.0 ;
370 G4cout <<
"WARNING - Invalid call in "
371 <<
"G4UnionSolid::DistanceToOut(p,v)" <<
G4endl
372 <<
" Point p is outside !" <<
G4endl;
375 G4cerr <<
"WARNING - Invalid call in "
376 <<
"G4UnionSolid::DistanceToOut(p,v)" <<
G4endl
377 <<
" Point p is outside !" <<
G4endl;
402 && (disTmp > halfCarTolerance) );
420 && (disTmp > halfCarTolerance) );
442 G4cout <<
"WARNING - Invalid call in "
443 <<
"G4UnionSolid::DistanceToOut(p)" <<
G4endl
444 <<
" Point p is outside !" <<
G4endl;
446 G4cerr <<
"WARNING - Invalid call in "
447 <<
"G4UnionSolid::DistanceToOut(p)" <<
G4endl
448 <<
" Point p is outside !" <<
G4endl;
533 if (processor.
execute(*result)) {
return result; }
534 else {
return nullptr; }
556 bminA.
x() < bmaxB.
x() && bminA.
y() < bmaxB.
y() && bminA.
z() < bmaxB.
z() &&
557 bminB.
x() < bmaxA.
x() && bminB.
y() < bmaxA.
y() && bminB.
z() < bmaxA.
z();
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 * StackPolyhedron(HepPolyhedronProcessor &, const G4VSolid *) const
virtual G4double GetCubicVolume()
G4double GetRadialTolerance() const
static G4GeometryTolerance * GetInstance()
G4UnionSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const
EInside Inside(const G4ThreeVector &p) const
G4UnionSolid & operator=(const G4UnionSolid &rhs)
G4GeometryType GetEntityType() const
G4Polyhedron * CreatePolyhedron() const
virtual G4double GetCubicVolume() final
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
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
virtual G4double GetCubicVolume()
bool execute(HepPolyhedron &)