Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4SubtractionSolid Class Reference

#include <G4SubtractionSolid.hh>

Inheritance diagram for G4SubtractionSolid:
G4BooleanSolid G4VSolid

Public Member Functions

 G4SubtractionSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
 
 G4SubtractionSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB, G4RotationMatrix *rotMatrix, const G4ThreeVector &transVector)
 
 G4SubtractionSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB, const G4Transform3D &transform)
 
virtual ~G4SubtractionSolid ()
 
G4GeometryType GetEntityType () const
 
G4VSolidClone () const
 
 G4SubtractionSolid (__void__ &)
 
 G4SubtractionSolid (const G4SubtractionSolid &rhs)
 
G4SubtractionSolidoperator= (const G4SubtractionSolid &rhs)
 
G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
 
EInside Inside (const G4ThreeVector &p) const
 
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const
 
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const
 
G4double DistanceToIn (const G4ThreeVector &p) const
 
G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
 
G4double DistanceToOut (const G4ThreeVector &p) const
 
void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
void DescribeYourselfTo (G4VGraphicsScene &scene) const
 
G4PolyhedronCreatePolyhedron () const
 
- Public Member Functions inherited from G4BooleanSolid
 G4BooleanSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
 
 G4BooleanSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB, G4RotationMatrix *rotMatrix, const G4ThreeVector &transVector)
 
 G4BooleanSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB, const G4Transform3D &transform)
 
virtual ~G4BooleanSolid ()
 
virtual const G4VSolidGetConstituentSolid (G4int no) const
 
virtual G4VSolidGetConstituentSolid (G4int no)
 
G4double GetCubicVolume ()
 
G4double GetSurfaceArea ()
 
virtual G4PolyhedronGetPolyhedron () const
 
std::ostream & StreamInfo (std::ostream &os) const
 
G4int GetCubVolStatistics () const
 
G4double GetCubVolEpsilon () const
 
void SetCubVolStatistics (G4int st)
 
void SetCubVolEpsilon (G4double ep)
 
G4int GetAreaStatistics () const
 
G4double GetAreaAccuracy () const
 
void SetAreaStatistics (G4int st)
 
void SetAreaAccuracy (G4double ep)
 
G4ThreeVector GetPointOnSurface () const
 
 G4BooleanSolid (__void__ &)
 
 G4BooleanSolid (const G4BooleanSolid &rhs)
 
G4BooleanSolidoperator= (const G4BooleanSolid &rhs)
 
- Public Member Functions inherited from G4VSolid
 G4VSolid (const G4String &name)
 
virtual ~G4VSolid ()
 
G4bool operator== (const G4VSolid &s) const
 
G4String GetName () const
 
void SetName (const G4String &name)
 
G4double GetTolerance () const
 
void DumpInfo () const
 
virtual G4VisExtent GetExtent () const
 
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
 
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 
 G4VSolid (__void__ &)
 
 G4VSolid (const G4VSolid &rhs)
 
G4VSolidoperator= (const G4VSolid &rhs)
 

Additional Inherited Members

- Protected Member Functions inherited from G4BooleanSolid
G4PolyhedronStackPolyhedron (HepPolyhedronProcessor &, const G4VSolid *) const
 
G4double GetAreaRatio () const
 
- Protected Member Functions inherited from G4VSolid
void CalculateClippedPolygonExtent (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipCrossSection (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipBetweenSections (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipPolygon (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis) const
 
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
 
G4double EstimateSurfaceArea (G4int nStat, G4double ell) const
 
- Protected Attributes inherited from G4BooleanSolid
G4VSolidfPtrSolidA
 
G4VSolidfPtrSolidB
 
G4double fAreaRatio
 
- Protected Attributes inherited from G4VSolid
G4double kCarTolerance
 

Detailed Description

Definition at line 53 of file G4SubtractionSolid.hh.

Constructor & Destructor Documentation

G4SubtractionSolid::G4SubtractionSolid ( const G4String pName,
G4VSolid pSolidA,
G4VSolid pSolidB 
)

Definition at line 60 of file G4SubtractionSolid.cc.

Referenced by Clone().

63  : G4BooleanSolid(pName,pSolidA,pSolidB)
64 {
65 }
G4BooleanSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
G4SubtractionSolid::G4SubtractionSolid ( const G4String pName,
G4VSolid pSolidA,
G4VSolid pSolidB,
G4RotationMatrix rotMatrix,
const G4ThreeVector transVector 
)

Definition at line 71 of file G4SubtractionSolid.cc.

76  : G4BooleanSolid(pName,pSolidA,pSolidB,rotMatrix,transVector)
77 {
78 }
G4BooleanSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
G4SubtractionSolid::G4SubtractionSolid ( const G4String pName,
G4VSolid pSolidA,
G4VSolid pSolidB,
const G4Transform3D transform 
)

Definition at line 84 of file G4SubtractionSolid.cc.

88  : G4BooleanSolid(pName,pSolidA,pSolidB,transform)
89 {
90 }
G4BooleanSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
G4SubtractionSolid::~G4SubtractionSolid ( )
virtual

Definition at line 106 of file G4SubtractionSolid.cc.

107 {
108 }
G4SubtractionSolid::G4SubtractionSolid ( __void__ &  a)

Definition at line 97 of file G4SubtractionSolid.cc.

98  : G4BooleanSolid(a)
99 {
100 }
G4BooleanSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
G4SubtractionSolid::G4SubtractionSolid ( const G4SubtractionSolid rhs)

Definition at line 114 of file G4SubtractionSolid.cc.

115  : G4BooleanSolid (rhs)
116 {
117 }
G4BooleanSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)

Member Function Documentation

G4bool G4SubtractionSolid::CalculateExtent ( const EAxis  pAxis,
const G4VoxelLimits pVoxelLimit,
const G4AffineTransform pTransform,
G4double pMin,
G4double pMax 
) const
virtual

Implements G4VSolid.

Definition at line 142 of file G4SubtractionSolid.cc.

References G4VSolid::CalculateExtent(), and G4BooleanSolid::fPtrSolidA.

147 {
148  // Since we cannot be sure how much the second solid subtracts
149  // from the first, we must use the first solid's extent!
150 
151  return fPtrSolidA->CalculateExtent( pAxis, pVoxelLimit,
152  pTransform, pMin, pMax );
153 }
virtual G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const =0
G4VSolid * fPtrSolidA
G4VSolid * G4SubtractionSolid::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 522 of file G4SubtractionSolid.cc.

References G4SubtractionSolid().

523 {
524  return new G4SubtractionSolid(*this);
525 }
G4SubtractionSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
void G4SubtractionSolid::ComputeDimensions ( G4VPVParameterisation p,
const G4int  n,
const G4VPhysicalVolume pRep 
)
virtual

Reimplemented from G4VSolid.

Definition at line 532 of file G4SubtractionSolid.cc.

535 {
536 }
G4Polyhedron * G4SubtractionSolid::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 553 of file G4SubtractionSolid.cc.

References HepPolyhedronProcessor::execute(), processor, and G4BooleanSolid::StackPolyhedron().

554 {
556  // Stack components and components of components recursively
557  // See G4BooleanSolid::StackPolyhedron
558  G4Polyhedron* top = StackPolyhedron(processor, this);
559  G4Polyhedron* result = new G4Polyhedron(*top);
560  if (processor.execute(*result)) { return result; }
561  else { return 0; }
562 }
#define processor
Definition: xmlparse.cc:600
G4Polyhedron * StackPolyhedron(HepPolyhedronProcessor &, const G4VSolid *) const
bool execute(HepPolyhedron &)
void G4SubtractionSolid::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 543 of file G4SubtractionSolid.cc.

References G4VGraphicsScene::AddSolid().

544 {
545  scene.AddSolid (*this);
546 }
virtual void AddSolid(const G4Box &)=0
G4double G4SubtractionSolid::DistanceToIn ( const G4ThreeVector p,
const G4ThreeVector v 
) const
virtual

Implements G4VSolid.

Definition at line 258 of file G4SubtractionSolid.cc.

References G4VSolid::DistanceToIn(), G4VSolid::DistanceToOut(), G4VSolid::DumpInfo(), G4BooleanSolid::fPtrSolidA, G4BooleanSolid::fPtrSolidB, G4cerr, G4cout, G4endl, G4Exception(), G4VSolid::GetEntityType(), G4VSolid::GetName(), Inside(), G4VSolid::Inside(), JustWarning, kInside, and kOutside.

260 {
261  G4double dist = 0.0,disTmp = 0.0 ;
262 
263 #ifdef G4BOOLDEBUG
264  if( Inside(p) == kInside )
265  {
266  G4cout << "WARNING - Invalid call in "
267  << "G4SubtractionSolid::DistanceToIn(p,v)" << G4endl
268  << " Point p is inside !" << G4endl;
269  G4cout << " p = " << p << G4endl;
270  G4cout << " v = " << v << G4endl;
271  G4cerr << "WARNING - Invalid call in "
272  << "G4SubtractionSolid::DistanceToIn(p,v)" << G4endl
273  << " Point p is inside !" << G4endl;
274  G4cerr << " p = " << p << G4endl;
275  G4cerr << " v = " << v << G4endl;
276  }
277 #endif
278 
279  // if( // ( fPtrSolidA->Inside(p) != kOutside) && // case1:p in both A&B
280  if ( fPtrSolidB->Inside(p) != kOutside ) // start: out of B
281  {
282  dist = fPtrSolidB->DistanceToOut(p,v) ; // ,calcNorm,validNorm,n) ;
283 
284  if( fPtrSolidA->Inside(p+dist*v) != kInside )
285  {
286  G4int count1=0;
287  do
288  {
289  disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
290 
291  if(disTmp == kInfinity)
292  {
293  return kInfinity ;
294  }
295  dist += disTmp ;
296 
297  if( Inside(p+dist*v) == kOutside )
298  {
299  disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
300  dist += disTmp ;
301  count1++;
302  if( count1 > 1000 ) // Infinite loop detected
303  {
304  G4String nameB = fPtrSolidB->GetName();
305  if(fPtrSolidB->GetEntityType()=="G4DisplacedSolid")
306  {
307  nameB = (dynamic_cast<G4DisplacedSolid*>(fPtrSolidB))
308  ->GetConstituentMovedSolid()->GetName();
309  }
310  std::ostringstream message;
311  message << "Illegal condition caused by solids: "
312  << fPtrSolidA->GetName() << " and " << nameB << G4endl;
313  message.precision(16);
314  message << "Looping detected in point " << p+dist*v
315  << ", from original point " << p
316  << " and direction " << v << G4endl
317  << "Computed candidate distance: " << dist << "*mm. ";
318  message.precision(6);
319  DumpInfo();
320  G4Exception("G4SubtractionSolid::DistanceToIn(p,v)",
321  "GeomSolids1001", JustWarning, message,
322  "Returning candidate distance.");
323  return dist;
324  }
325  }
326  }
327  while( Inside(p+dist*v) == kOutside ) ;
328  }
329  }
330  else // p outside A, start in A
331  {
332  dist = fPtrSolidA->DistanceToIn(p,v) ;
333 
334  if( dist == kInfinity ) // past A, hence past A\B
335  {
336  return kInfinity ;
337  }
338  else
339  {
340  G4int count2=0;
341  while( Inside(p+dist*v) == kOutside ) // pushing loop
342  {
343  disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
344  dist += disTmp ;
345 
346  if( Inside(p+dist*v) == kOutside )
347  {
348  disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
349 
350  if(disTmp == kInfinity) // past A, hence past A\B
351  {
352  return kInfinity ;
353  }
354  dist += disTmp ;
355  count2++;
356  if( count2 > 1000 ) // Infinite loop detected
357  {
358  G4String nameB = fPtrSolidB->GetName();
359  if(fPtrSolidB->GetEntityType()=="G4DisplacedSolid")
360  {
361  nameB = (dynamic_cast<G4DisplacedSolid*>(fPtrSolidB))
362  ->GetConstituentMovedSolid()->GetName();
363  }
364  std::ostringstream message;
365  message << "Illegal condition caused by solids: "
366  << fPtrSolidA->GetName() << " and " << nameB << G4endl;
367  message.precision(16);
368  message << "Looping detected in point " << p+dist*v
369  << ", from original point " << p
370  << " and direction " << v << G4endl
371  << "Computed candidate distance: " << dist << "*mm. ";
372  message.precision(6);
373  DumpInfo();
374  G4Exception("G4SubtractionSolid::DistanceToIn(p,v)",
375  "GeomSolids1001", JustWarning, message,
376  "Returning candidate distance.");
377  return dist;
378  }
379  }
380  }
381  }
382  }
383 
384  return dist ;
385 }
G4String GetName() const
G4VSolid * fPtrSolidB
virtual G4GeometryType GetEntityType() const =0
int G4int
Definition: G4Types.hh:78
void DumpInfo() const
G4GLOB_DLL std::ostream G4cout
virtual EInside Inside(const G4ThreeVector &p) const =0
EInside Inside(const G4ThreeVector &p) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4VSolid * fPtrSolidA
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
G4GLOB_DLL std::ostream G4cerr
G4double G4SubtractionSolid::DistanceToIn ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 394 of file G4SubtractionSolid.cc.

References G4VSolid::DistanceToIn(), G4VSolid::DistanceToOut(), G4BooleanSolid::fPtrSolidA, G4BooleanSolid::fPtrSolidB, G4cerr, G4cout, G4endl, Inside(), G4VSolid::Inside(), kInside, and kOutside.

395 {
396  G4double dist=0.0;
397 
398 #ifdef G4BOOLDEBUG
399  if( Inside(p) == kInside )
400  {
401  G4cout << "WARNING - Invalid call in "
402  << "G4SubtractionSolid::DistanceToIn(p)" << G4endl
403  << " Point p is inside !" << G4endl;
404  G4cout << " p = " << p << G4endl;
405  G4cerr << "WARNING - Invalid call in "
406  << "G4SubtractionSolid::DistanceToIn(p)" << G4endl
407  << " Point p is inside !" << G4endl;
408  G4cerr << " p = " << p << G4endl;
409  }
410 #endif
411 
412  if( ( fPtrSolidA->Inside(p) != kOutside) && // case 1
413  ( fPtrSolidB->Inside(p) != kOutside) )
414  {
415  dist= fPtrSolidB->DistanceToOut(p) ;
416  }
417  else
418  {
419  dist= fPtrSolidA->DistanceToIn(p) ;
420  }
421 
422  return dist;
423 }
G4VSolid * fPtrSolidB
G4GLOB_DLL std::ostream G4cout
virtual EInside Inside(const G4ThreeVector &p) const =0
EInside Inside(const G4ThreeVector &p) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
G4VSolid * fPtrSolidA
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
G4GLOB_DLL std::ostream G4cerr
G4double G4SubtractionSolid::DistanceToOut ( const G4ThreeVector p,
const G4ThreeVector v,
const G4bool  calcNorm = false,
G4bool validNorm = 0,
G4ThreeVector n = 0 
) const
virtual

Implements G4VSolid.

Definition at line 430 of file G4SubtractionSolid.cc.

References G4VSolid::DistanceToIn(), G4VSolid::DistanceToOut(), G4BooleanSolid::fPtrSolidA, G4BooleanSolid::fPtrSolidB, G4cerr, G4cout, G4endl, Inside(), kOutside, python.hepunit::mm, G4VSolid::SurfaceNormal(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

435 {
436 #ifdef G4BOOLDEBUG
437  if( Inside(p) == kOutside )
438  {
439  G4cout << "Position:" << G4endl << G4endl;
440  G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl;
441  G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl;
442  G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl;
443  G4cout << "Direction:" << G4endl << G4endl;
444  G4cout << "v.x() = " << v.x() << G4endl;
445  G4cout << "v.y() = " << v.y() << G4endl;
446  G4cout << "v.z() = " << v.z() << G4endl << G4endl;
447  G4cout << "WARNING - Invalid call in "
448  << "G4SubtractionSolid::DistanceToOut(p,v)" << G4endl
449  << " Point p is outside !" << G4endl;
450  G4cout << " p = " << p << G4endl;
451  G4cout << " v = " << v << G4endl;
452  G4cerr << "WARNING - Invalid call in "
453  << "G4SubtractionSolid::DistanceToOut(p,v)" << G4endl
454  << " Point p is outside !" << G4endl;
455  G4cerr << " p = " << p << G4endl;
456  G4cerr << " v = " << v << G4endl;
457  }
458 #endif
459 
460  G4double distout;
461  G4double distA = fPtrSolidA->DistanceToOut(p,v,calcNorm,validNorm,n) ;
462  G4double distB = fPtrSolidB->DistanceToIn(p,v) ;
463  if(distB < distA)
464  {
465  if(calcNorm)
466  {
467  *n = -(fPtrSolidB->SurfaceNormal(p+distB*v)) ;
468  *validNorm = false ;
469  }
470  distout= distB ;
471  }
472  else
473  {
474  distout= distA ;
475  }
476  return distout;
477 }
G4VSolid * fPtrSolidB
double x() const
double z() const
G4GLOB_DLL std::ostream G4cout
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
EInside Inside(const G4ThreeVector &p) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
double y() const
G4VSolid * fPtrSolidA
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
G4GLOB_DLL std::ostream G4cerr
G4double G4SubtractionSolid::DistanceToOut ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 484 of file G4SubtractionSolid.cc.

References G4VSolid::DistanceToIn(), G4VSolid::DistanceToOut(), G4BooleanSolid::fPtrSolidA, G4BooleanSolid::fPtrSolidB, G4cerr, G4cout, G4endl, Inside(), kOutside, and G4INCL::Math::min().

485 {
486  G4double dist=0.0;
487 
488  if( Inside(p) == kOutside )
489  {
490 #ifdef G4BOOLDEBUG
491  G4cout << "WARNING - Invalid call in "
492  << "G4SubtractionSolid::DistanceToOut(p)" << G4endl
493  << " Point p is outside" << G4endl;
494  G4cout << " p = " << p << G4endl;
495  G4cerr << "WARNING - Invalid call in "
496  << "G4SubtractionSolid::DistanceToOut(p)" << G4endl
497  << " Point p is outside" << G4endl;
498  G4cerr << " p = " << p << G4endl;
499 #endif
500  }
501  else
502  {
504  fPtrSolidB->DistanceToIn(p) ) ;
505  }
506  return dist;
507 }
G4VSolid * fPtrSolidB
G4GLOB_DLL std::ostream G4cout
EInside Inside(const G4ThreeVector &p) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4VSolid * fPtrSolidA
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
G4GLOB_DLL std::ostream G4cerr
G4GeometryType G4SubtractionSolid::GetEntityType ( ) const
virtual

Reimplemented from G4BooleanSolid.

Definition at line 513 of file G4SubtractionSolid.cc.

514 {
515  return G4String("G4SubtractionSolid");
516 }
EInside G4SubtractionSolid::Inside ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 159 of file G4SubtractionSolid.cc.

References G4BooleanSolid::fPtrSolidA, G4BooleanSolid::fPtrSolidB, G4GeometryTolerance::GetInstance(), G4GeometryTolerance::GetRadialTolerance(), G4VSolid::Inside(), kInside, kOutside, kSurface, and G4VSolid::SurfaceNormal().

Referenced by DistanceToIn(), DistanceToOut(), and SurfaceNormal().

160 {
161  EInside positionA = fPtrSolidA->Inside(p);
162  if (positionA == kOutside) return kOutside;
163 
164  EInside positionB = fPtrSolidB->Inside(p);
165 
166  if(positionA == kInside && positionB == kOutside)
167  {
168  return kInside ;
169  }
170  else
171  {
172  if(( positionA == kInside && positionB == kSurface) ||
173  ( positionB == kOutside && positionA == kSurface) ||
174  ( positionA == kSurface && positionB == kSurface &&
175  ( fPtrSolidA->SurfaceNormal(p) -
176  fPtrSolidB->SurfaceNormal(p) ).mag2() >
178  {
179  return kSurface;
180  }
181  else
182  {
183  return kOutside;
184  }
185  }
186 }
G4VSolid * fPtrSolidB
virtual EInside Inside(const G4ThreeVector &p) const =0
G4double GetRadialTolerance() const
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
EInside
Definition: geomdefs.hh:58
G4VSolid * fPtrSolidA
static G4GeometryTolerance * GetInstance()
G4SubtractionSolid & G4SubtractionSolid::operator= ( const G4SubtractionSolid rhs)

Definition at line 124 of file G4SubtractionSolid.cc.

References G4BooleanSolid::operator=().

125 {
126  // Check assignment to self
127  //
128  if (this == &rhs) { return *this; }
129 
130  // Copy base class data
131  //
133 
134  return *this;
135 }
G4BooleanSolid & operator=(const G4BooleanSolid &rhs)
G4ThreeVector G4SubtractionSolid::SurfaceNormal ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 193 of file G4SubtractionSolid.cc.

References G4VSolid::DistanceToIn(), G4VSolid::DistanceToOut(), G4BooleanSolid::fPtrSolidA, G4BooleanSolid::fPtrSolidB, G4cerr, G4cout, G4endl, Inside(), G4VSolid::Inside(), kInside, kOutside, kSurface, and G4VSolid::SurfaceNormal().

194 {
195  G4ThreeVector normal;
196  EInside insideThis= Inside(p);
197  if( insideThis == kOutside )
198  {
199 #ifdef G4BOOLDEBUG
200  G4cout << "WARNING - Invalid call [1] in "
201  << "G4SubtractionSolid::SurfaceNormal(p)" << G4endl
202  << " Point p is outside !" << G4endl;
203  G4cout << " p = " << p << G4endl;
204  G4cerr << "WARNING - Invalid call [1] in "
205  << "G4SubtractionSolid::SurfaceNormal(p)" << G4endl
206  << " Point p is outside !" << G4endl;
207  G4cerr << " p = " << p << G4endl;
208 #endif
209  }
210  else
211  {
212  EInside InsideA = fPtrSolidA->Inside(p);
213  EInside InsideB = fPtrSolidB->Inside(p);
214 
215  if( InsideA == kSurface &&
216  InsideB != kInside )
217  {
218  normal = fPtrSolidA->SurfaceNormal(p) ;
219  }
220  else if( InsideA == kInside &&
221  InsideB != kOutside )
222  {
223  normal = -fPtrSolidB->SurfaceNormal(p) ;
224  }
225  else
226  {
228  {
229  normal = fPtrSolidA->SurfaceNormal(p) ;
230  }
231  else
232  {
233  normal = -fPtrSolidB->SurfaceNormal(p) ;
234  }
235 #ifdef G4BOOLDEBUG
236  if(insideThis == kInside)
237  {
238  G4cout << "WARNING - Invalid call [2] in "
239  << "G4SubtractionSolid::SurfaceNormal(p)" << G4endl
240  << " Point p is inside !" << G4endl;
241  G4cout << " p = " << p << G4endl;
242  G4cerr << "WARNING - Invalid call [2] in "
243  << "G4SubtractionSolid::SurfaceNormal(p)" << G4endl
244  << " Point p is inside !" << G4endl;
245  G4cerr << " p = " << p << G4endl;
246  }
247 #endif
248  }
249  }
250  return normal;
251 }
G4VSolid * fPtrSolidB
G4GLOB_DLL std::ostream G4cout
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
EInside Inside(const G4ThreeVector &p) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
EInside
Definition: geomdefs.hh:58
G4VSolid * fPtrSolidA
#define G4endl
Definition: G4ios.hh:61
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
G4GLOB_DLL std::ostream G4cerr

The documentation for this class was generated from the following files: