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

#include <G4IntersectionSolid.hh>

Inheritance diagram for G4IntersectionSolid:
G4BooleanSolid G4VSolid

Public Member Functions

 G4IntersectionSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
 
 G4IntersectionSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB, G4RotationMatrix *rotMatrix, const G4ThreeVector &transVector)
 
 G4IntersectionSolid (const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB, const G4Transform3D &transform)
 
virtual ~G4IntersectionSolid ()
 
G4GeometryType GetEntityType () const
 
G4VSolidClone () const
 
 G4IntersectionSolid (__void__ &)
 
 G4IntersectionSolid (const G4IntersectionSolid &rhs)
 
G4IntersectionSolidoperator= (const G4IntersectionSolid &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 G4IntersectionSolid.hh.

Constructor & Destructor Documentation

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

Definition at line 61 of file G4IntersectionSolid.cc.

Referenced by Clone().

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

Definition at line 71 of file G4IntersectionSolid.cc.

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

Definition at line 84 of file G4IntersectionSolid.cc.

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

Definition at line 106 of file G4IntersectionSolid.cc.

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

Definition at line 97 of file G4IntersectionSolid.cc.

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

Definition at line 114 of file G4IntersectionSolid.cc.

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

Member Function Documentation

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

Implements G4VSolid.

Definition at line 142 of file G4IntersectionSolid.cc.

References G4VSolid::CalculateExtent(), G4BooleanSolid::fPtrSolidA, G4BooleanSolid::fPtrSolidB, G4INCL::Math::max(), and G4INCL::Math::min().

147 {
148  G4bool retA, retB, out;
149  G4double minA, minB, maxA, maxB;
150 
151  retA = fPtrSolidA
152  ->CalculateExtent( pAxis, pVoxelLimit, pTransform, minA, maxA);
153  retB = fPtrSolidB
154  ->CalculateExtent( pAxis, pVoxelLimit, pTransform, minB, maxB);
155 
156  if( retA && retB )
157  {
158  pMin = std::max( minA, minB );
159  pMax = std::min( maxA, maxB );
160  out = (pMax > pMin); // true;
161 #ifdef G4BOOLDEBUG
162  // G4cout.precision(16);
163  // G4cout<<"pMin = "<<pMin<<"; pMax = "<<pMax<<G4endl;
164 #endif
165  }
166  else out = false;
167 
168  return out; // It exists in this slice only if both exist in it.
169 }
G4VSolid * fPtrSolidB
virtual G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const =0
bool G4bool
Definition: G4Types.hh:79
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4VSolid * fPtrSolidA
double G4double
Definition: G4Types.hh:76
G4VSolid * G4IntersectionSolid::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 518 of file G4IntersectionSolid.cc.

References G4IntersectionSolid().

519 {
520  return new G4IntersectionSolid(*this);
521 }
G4IntersectionSolid(const G4String &pName, G4VSolid *pSolidA, G4VSolid *pSolidB)
void G4IntersectionSolid::ComputeDimensions ( G4VPVParameterisation p,
const G4int  n,
const G4VPhysicalVolume pRep 
)
virtual

Reimplemented from G4VSolid.

Definition at line 499 of file G4IntersectionSolid.cc.

502 {
503 }
G4Polyhedron * G4IntersectionSolid::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 538 of file G4IntersectionSolid.cc.

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

539 {
541  // Stack components and components of components recursively
542  // See G4BooleanSolid::StackPolyhedron
543  G4Polyhedron* top = StackPolyhedron(processor, this);
544  G4Polyhedron* result = new G4Polyhedron(*top);
545  if (processor.execute(*result)) { return result; }
546  else { return 0; }
547 }
#define processor
Definition: xmlparse.cc:600
G4Polyhedron * StackPolyhedron(HepPolyhedronProcessor &, const G4VSolid *) const
bool execute(HepPolyhedron &)
void G4IntersectionSolid::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 528 of file G4IntersectionSolid.cc.

References G4VGraphicsScene::AddSolid().

529 {
530  scene.AddSolid (*this);
531 }
virtual void AddSolid(const G4Box &)=0
G4double G4IntersectionSolid::DistanceToIn ( const G4ThreeVector p,
const G4ThreeVector v 
) const
virtual

Implements G4VSolid.

Definition at line 270 of file G4IntersectionSolid.cc.

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

272 {
273  G4double dist = 0.0;
274  if( Inside(p) == kInside )
275  {
276 #ifdef G4BOOLDEBUG
277  G4cout << "WARNING - Invalid call in "
278  << "G4IntersectionSolid::DistanceToIn(p,v)" << G4endl
279  << " Point p is inside !" << G4endl;
280  G4cout << " p = " << p << G4endl;
281  G4cout << " v = " << v << G4endl;
282  G4cerr << "WARNING - Invalid call in "
283  << "G4IntersectionSolid::DistanceToIn(p,v)" << G4endl
284  << " Point p is inside !" << G4endl;
285  G4cerr << " p = " << p << G4endl;
286  G4cerr << " v = " << v << G4endl;
287 #endif
288  }
289  else // if( Inside(p) == kSurface )
290  {
291  EInside wA = fPtrSolidA->Inside(p);
292  EInside wB = fPtrSolidB->Inside(p);
293 
294  G4ThreeVector pA = p, pB = p;
295  G4double dA = 0., dA1=0., dA2=0.;
296  G4double dB = 0., dB1=0., dB2=0.;
297  G4bool doA = true, doB = true;
298 
299  while(true)
300  {
301  if(doA)
302  {
303  // find next valid range for A
304 
305  dA1 = 0.;
306 
307  if( wA != kInside )
308  {
309  dA1 = fPtrSolidA->DistanceToIn(pA, v);
310 
311  if( dA1 == kInfinity ) return kInfinity;
312 
313  pA += dA1*v;
314  }
315  dA2 = dA1 + fPtrSolidA->DistanceToOut(pA, v);
316  }
317  dA1 += dA;
318  dA2 += dA;
319 
320  if(doB)
321  {
322  // find next valid range for B
323 
324  dB1 = 0.;
325  if(wB != kInside)
326  {
327  dB1 = fPtrSolidB->DistanceToIn(pB, v);
328 
329  if(dB1 == kInfinity) return kInfinity;
330 
331  pB += dB1*v;
332  }
333  dB2 = dB1 + fPtrSolidB->DistanceToOut(pB, v);
334  }
335  dB1 += dB;
336  dB2 += dB;
337 
338  // check if they overlap
339 
340  if( dA1 < dB1 )
341  {
342  if( dB1 < dA2 ) return dB1;
343 
344  dA = dA2;
345  pA = p + dA*v; // continue from here
346  wA = kSurface;
347  doA = true;
348  doB = false;
349  }
350  else
351  {
352  if( dA1 < dB2 ) return dA1;
353 
354  dB = dB2;
355  pB = p + dB*v; // continue from here
356  wB = kSurface;
357  doB = true;
358  doA = false;
359  }
360  }
361  }
362  return dist ;
363 }
G4VSolid * fPtrSolidB
EInside Inside(const G4ThreeVector &p) const
const char * p
Definition: xmltok.h:285
G4GLOB_DLL std::ostream G4cout
virtual EInside Inside(const G4ThreeVector &p) const =0
bool G4bool
Definition: G4Types.hh:79
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
EInside
Definition: geomdefs.hh:58
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 G4IntersectionSolid::DistanceToIn ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 371 of file G4IntersectionSolid.cc.

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

372 {
373 #ifdef G4BOOLDEBUG
374  if( Inside(p) == kInside )
375  {
376  G4cout << "WARNING - Invalid call in "
377  << "G4IntersectionSolid::DistanceToIn(p)" << G4endl
378  << " Point p is inside !" << G4endl;
379  G4cout << " p = " << p << G4endl;
380  G4cerr << "WARNING - Invalid call in "
381  << "G4IntersectionSolid::DistanceToIn(p)" << G4endl
382  << " Point p is inside !" << G4endl;
383  G4cerr << " p = " << p << G4endl;
384  }
385 #endif
386  EInside sideA = fPtrSolidA->Inside(p) ;
387  EInside sideB = fPtrSolidB->Inside(p) ;
388  G4double dist=0.0 ;
389 
390  if( sideA != kInside && sideB != kOutside )
391  {
392  dist = fPtrSolidA->DistanceToIn(p) ;
393  }
394  else
395  {
396  if( sideB != kInside && sideA != kOutside )
397  {
398  dist = fPtrSolidB->DistanceToIn(p) ;
399  }
400  else
401  {
402  dist = std::min(fPtrSolidA->DistanceToIn(p),
403  fPtrSolidB->DistanceToIn(p) ) ;
404  }
405  }
406  return dist ;
407 }
G4VSolid * fPtrSolidB
EInside Inside(const G4ThreeVector &p) const
G4GLOB_DLL std::ostream G4cout
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
EInside
Definition: geomdefs.hh:58
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
G4GLOB_DLL std::ostream G4cerr
G4double G4IntersectionSolid::DistanceToOut ( const G4ThreeVector p,
const G4ThreeVector v,
const G4bool  calcNorm = false,
G4bool validNorm = 0,
G4ThreeVector n = 0 
) const
virtual

Implements G4VSolid.

Definition at line 414 of file G4IntersectionSolid.cc.

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

419 {
420  G4bool validNormA, validNormB;
421  G4ThreeVector nA, nB;
422 
423 #ifdef G4BOOLDEBUG
424  if( Inside(p) == kOutside )
425  {
426  G4cout << "Position:" << G4endl << G4endl;
427  G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl;
428  G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl;
429  G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl;
430  G4cout << "Direction:" << G4endl << G4endl;
431  G4cout << "v.x() = " << v.x() << G4endl;
432  G4cout << "v.y() = " << v.y() << G4endl;
433  G4cout << "v.z() = " << v.z() << G4endl << G4endl;
434  G4cout << "WARNING - Invalid call in "
435  << "G4IntersectionSolid::DistanceToOut(p,v)" << G4endl
436  << " Point p is outside !" << G4endl;
437  G4cout << " p = " << p << G4endl;
438  G4cout << " v = " << v << G4endl;
439  G4cerr << "WARNING - Invalid call in "
440  << "G4IntersectionSolid::DistanceToOut(p,v)" << G4endl
441  << " Point p is outside !" << G4endl;
442  G4cerr << " p = " << p << G4endl;
443  G4cerr << " v = " << v << G4endl;
444  }
445 #endif
446  G4double distA = fPtrSolidA->DistanceToOut(p,v,calcNorm,&validNormA,&nA) ;
447  G4double distB = fPtrSolidB->DistanceToOut(p,v,calcNorm,&validNormB,&nB) ;
448 
449  G4double dist = std::min(distA,distB) ;
450 
451  if( calcNorm )
452  {
453  if ( distA < distB )
454  {
455  *validNorm = validNormA;
456  *n = nA;
457  }
458  else
459  {
460  *validNorm = validNormB;
461  *n = nB;
462  }
463  }
464 
465  return dist ;
466 }
G4VSolid * fPtrSolidB
EInside Inside(const G4ThreeVector &p) const
double x() const
double z() const
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
double y() const
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
G4double G4IntersectionSolid::DistanceToOut ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 473 of file G4IntersectionSolid.cc.

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

474 {
475 #ifdef G4BOOLDEBUG
476  if( Inside(p) == kOutside )
477  {
478  G4cout << "WARNING - Invalid call in "
479  << "G4IntersectionSolid::DistanceToOut(p)" << G4endl
480  << " Point p is outside !" << G4endl;
481  G4cout << " p = " << p << G4endl;
482  G4cerr << "WARNING - Invalid call in "
483  << "G4IntersectionSolid::DistanceToOut(p)" << G4endl
484  << " Point p is outside !" << G4endl;
485  G4cerr << " p = " << p << G4endl;
486  }
487 #endif
488 
489  return std::min(fPtrSolidA->DistanceToOut(p),
490  fPtrSolidB->DistanceToOut(p) ) ;
491 
492 }
G4VSolid * fPtrSolidB
EInside Inside(const G4ThreeVector &p) const
G4GLOB_DLL std::ostream G4cout
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
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
G4GeometryType G4IntersectionSolid::GetEntityType ( ) const
virtual

Reimplemented from G4BooleanSolid.

Definition at line 509 of file G4IntersectionSolid.cc.

510 {
511  return G4String("G4IntersectionSolid");
512 }
EInside G4IntersectionSolid::Inside ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 175 of file G4IntersectionSolid.cc.

References G4BooleanSolid::fPtrSolidA, G4BooleanSolid::fPtrSolidB, G4VSolid::Inside(), kInside, kOutside, and kSurface.

Referenced by DistanceToIn(), and DistanceToOut().

176 {
177  EInside positionA = fPtrSolidA->Inside(p) ;
178 
179  if( positionA == kOutside ) return kOutside ;
180 
181  EInside positionB = fPtrSolidB->Inside(p) ;
182 
183  if(positionA == kInside && positionB == kInside)
184  {
185  return kInside ;
186  }
187  else
188  {
189  if((positionA == kInside && positionB == kSurface) ||
190  (positionB == kInside && positionA == kSurface) ||
191  (positionA == kSurface && positionB == kSurface) )
192  {
193  return kSurface ;
194  }
195  else
196  {
197  return kOutside ;
198  }
199  }
200 }
G4VSolid * fPtrSolidB
virtual EInside Inside(const G4ThreeVector &p) const =0
EInside
Definition: geomdefs.hh:58
G4VSolid * fPtrSolidA
G4IntersectionSolid & G4IntersectionSolid::operator= ( const G4IntersectionSolid rhs)

Definition at line 124 of file G4IntersectionSolid.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 G4IntersectionSolid::SurfaceNormal ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 206 of file G4IntersectionSolid.cc.

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

207 {
208  G4ThreeVector normal;
209  EInside insideA, insideB;
210 
211  insideA= fPtrSolidA->Inside(p);
212  insideB= fPtrSolidB->Inside(p);
213 
214 #ifdef G4BOOLDEBUG
215  if( (insideA == kOutside) || (insideB == kOutside) )
216  {
217  G4cout << "WARNING - Invalid call in "
218  << "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
219  << " Point p is outside !" << G4endl;
220  G4cout << " p = " << p << G4endl;
221  G4cerr << "WARNING - Invalid call in "
222  << "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
223  << " Point p is outside !" << G4endl;
224  G4cerr << " p = " << p << G4endl;
225  }
226 #endif
227 
228  // OLD: if(fPtrSolidA->DistanceToOut(p) <= fPtrSolidB->DistanceToOut(p) )
229 
230  // On the surface of both is difficult ... treat it like on A now!
231  //
232  // if( (insideA == kSurface) && (insideB == kSurface) )
233  // normal= fPtrSolidA->SurfaceNormal(p) ;
234  // else
235  if( insideA == kSurface )
236  {
237  normal= fPtrSolidA->SurfaceNormal(p) ;
238  }
239  else if( insideB == kSurface )
240  {
241  normal= fPtrSolidB->SurfaceNormal(p) ;
242  }
243  // We are on neither surface, so we should generate an exception
244  else
245  {
247  normal= fPtrSolidA->SurfaceNormal(p) ;
248  else
249  normal= fPtrSolidB->SurfaceNormal(p) ;
250 #ifdef G4BOOLDEBUG
251  G4cout << "WARNING - Invalid call in "
252  << "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
253  << " Point p is out of surface !" << G4endl;
254  G4cout << " p = " << p << G4endl;
255  G4cerr << "WARNING - Invalid call in "
256  << "G4IntersectionSolid::SurfaceNormal(p)" << G4endl
257  << " Point p is out of surface !" << G4endl;
258  G4cerr << " p = " << p << G4endl;
259 #endif
260  }
261 
262  return normal;
263 }
G4VSolid * fPtrSolidB
G4GLOB_DLL std::ostream G4cout
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) 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: