Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4BooleanSolid Class Reference

#include <G4BooleanSolid.hh>

Inheritance diagram for G4BooleanSolid:
Collaboration diagram for G4BooleanSolid:

Public Member Functions

 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 G4GeometryType GetEntityType () const
 
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
 
virtual void Extent (G4ThreeVector &pMin, G4ThreeVector &pMax) const
 
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 G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const =0
 
virtual G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const =0
 
virtual G4double DistanceToIn (const G4ThreeVector &p) const =0
 
virtual G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
 
virtual G4double DistanceToOut (const G4ThreeVector &p) const =0
 
virtual void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
virtual G4VSolidClone () const
 
void DumpInfo () const
 
virtual void DescribeYourselfTo (G4VGraphicsScene &scene) const =0
 
virtual G4VisExtent GetExtent () const
 
virtual G4PolyhedronCreatePolyhedron () const
 
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
 
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 
 G4VSolid (__void__ &)
 
 G4VSolid (const G4VSolid &rhs)
 
G4VSolidoperator= (const G4VSolid &rhs)
 
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
 
G4double EstimateSurfaceArea (G4int nStat, G4double ell) const
 

Protected Member Functions

void GetListOfPrimitives (std::vector< std::pair< G4VSolid *, G4Transform3D >> &, const G4Transform3D &) const
 
G4PolyhedronStackPolyhedron (HepPolyhedronProcessor &, const G4VSolid *) 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
 

Protected Attributes

G4VSolidfPtrSolidA
 
G4VSolidfPtrSolidB
 
- Protected Attributes inherited from G4VSolid
G4double kCarTolerance
 

Detailed Description

Definition at line 51 of file G4BooleanSolid.hh.

Constructor & Destructor Documentation

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

Definition at line 61 of file G4BooleanSolid.cc.

63  :
64  G4VSolid(pName), fStatistics(1000000), fCubVolEpsilon(0.001),
65  fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
66  fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
67  createdDisplacedSolid(false)
68 {
69  fPtrSolidA = pSolidA ;
70  fPtrSolidB = pSolidB ;
71 }
G4VSolid * fPtrSolidB
G4VSolid * fPtrSolidA
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:61
G4BooleanSolid::G4BooleanSolid ( const G4String pName,
G4VSolid pSolidA,
G4VSolid pSolidB,
G4RotationMatrix rotMatrix,
const G4ThreeVector transVector 
)

Definition at line 77 of file G4BooleanSolid.cc.

81  :
82  G4VSolid(pName), fStatistics(1000000), fCubVolEpsilon(0.001),
83  fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
84  fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
85  createdDisplacedSolid(true)
86 {
87  fPtrSolidA = pSolidA ;
88  fPtrSolidB = new G4DisplacedSolid("placedB",pSolidB,rotMatrix,transVector) ;
89 }
G4VSolid * fPtrSolidB
G4VSolid * fPtrSolidA
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:61
G4BooleanSolid::G4BooleanSolid ( const G4String pName,
G4VSolid pSolidA,
G4VSolid pSolidB,
const G4Transform3D transform 
)

Definition at line 95 of file G4BooleanSolid.cc.

98  :
99  G4VSolid(pName), fStatistics(1000000), fCubVolEpsilon(0.001),
100  fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
101  fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
102  createdDisplacedSolid(true)
103 {
104  fPtrSolidA = pSolidA ;
105  fPtrSolidB = new G4DisplacedSolid("placedB",pSolidB,transform) ;
106 }
G4VSolid * fPtrSolidB
G4VSolid * fPtrSolidA
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:61
G4BooleanSolid::~G4BooleanSolid ( )
virtual

Definition at line 126 of file G4BooleanSolid.cc.

127 {
128  if(createdDisplacedSolid)
129  {
130  ((G4DisplacedSolid*)fPtrSolidB)->CleanTransformations();
131  }
132  delete fpPolyhedron; fpPolyhedron = 0;
133 }
G4VSolid * fPtrSolidB
G4BooleanSolid::G4BooleanSolid ( __void__ &  a)

Definition at line 113 of file G4BooleanSolid.cc.

114  : G4VSolid(a), fPtrSolidA(0), fPtrSolidB(0),
115  fStatistics(1000000), fCubVolEpsilon(0.001),
116  fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
117  fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
118  createdDisplacedSolid(false)
119 {
120 }
G4VSolid * fPtrSolidB
G4VSolid * fPtrSolidA
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:61
G4BooleanSolid::G4BooleanSolid ( const G4BooleanSolid rhs)

Definition at line 139 of file G4BooleanSolid.cc.

140  : G4VSolid (rhs), fPtrSolidA(rhs.fPtrSolidA), fPtrSolidB(rhs.fPtrSolidB),
141  fStatistics(rhs.fStatistics), fCubVolEpsilon(rhs.fCubVolEpsilon),
142  fAreaAccuracy(rhs.fAreaAccuracy), fCubicVolume(rhs.fCubicVolume),
143  fSurfaceArea(rhs.fSurfaceArea), fRebuildPolyhedron(false), fpPolyhedron(0),
144  createdDisplacedSolid(rhs.createdDisplacedSolid)
145 {
146  fPrimitives.resize(0); fPrimitivesSurfaceArea = 0.;
147 }
G4VSolid * fPtrSolidB
G4VSolid * fPtrSolidA
G4VSolid(const G4String &name)
Definition: G4VSolid.cc:61

Member Function Documentation

G4double G4BooleanSolid::GetAreaAccuracy ( ) const
inline
G4int G4BooleanSolid::GetAreaStatistics ( ) const
inline
const G4VSolid * G4BooleanSolid::GetConstituentSolid ( G4int  no) const
virtual

Reimplemented from G4VSolid.

Definition at line 183 of file G4BooleanSolid.cc.

184 {
185  const G4VSolid* subSolid=0;
186  if( no == 0 )
187  subSolid = fPtrSolidA;
188  else if( no == 1 )
189  subSolid = fPtrSolidB;
190  else
191  {
192  DumpInfo();
193  G4Exception("G4BooleanSolid::GetConstituentSolid()",
194  "GeomSolids0002", FatalException, "Invalid solid index.");
195  }
196 
197  return subSolid;
198 }
G4VSolid * fPtrSolidB
void DumpInfo() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4VSolid * fPtrSolidA

Here is the call graph for this function:

Here is the caller graph for this function:

G4VSolid * G4BooleanSolid::GetConstituentSolid ( G4int  no)
virtual

Reimplemented from G4VSolid.

Definition at line 206 of file G4BooleanSolid.cc.

207 {
208  G4VSolid* subSolid=0;
209  if( no == 0 )
210  subSolid = fPtrSolidA;
211  else if( no == 1 )
212  subSolid = fPtrSolidB;
213  else
214  {
215  DumpInfo();
216  G4Exception("G4BooleanSolid::GetConstituentSolid()",
217  "GeomSolids0002", FatalException, "Invalid solid index.");
218  }
219 
220  return subSolid;
221 }
G4VSolid * fPtrSolidB
void DumpInfo() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4VSolid * fPtrSolidA

Here is the call graph for this function:

G4double G4BooleanSolid::GetCubicVolume ( )
inlinevirtual

Reimplemented from G4VSolid.

G4double G4BooleanSolid::GetCubVolEpsilon ( ) const
inline
G4int G4BooleanSolid::GetCubVolStatistics ( ) const
inline
G4GeometryType G4BooleanSolid::GetEntityType ( ) const
virtual

Implements G4VSolid.

Reimplemented in G4IntersectionSolid, G4SubtractionSolid, and G4UnionSolid.

Definition at line 227 of file G4BooleanSolid.cc.

228 {
229  return G4String("G4BooleanSolid");
230 }

Here is the caller graph for this function:

void G4BooleanSolid::GetListOfPrimitives ( std::vector< std::pair< G4VSolid *, G4Transform3D >> &  primitives,
const G4Transform3D curPlacement 
) const
protected

Definition at line 255 of file G4BooleanSolid.cc.

258 {
259  G4Transform3D transform;
260  G4VSolid* solid;
261  G4String type;
262 
263  // Repeat two times, first time for fPtrSolidA and then for fPtrSolidB
264  //
265  for (G4int i=0; i<2; i++)
266  {
267  transform = curPlacement;
268  solid = (i == 0) ? fPtrSolidA : fPtrSolidB;
269  type = solid->GetEntityType();
270 
271  // While current solid is a trasformed solid just modify transform
272  //
273  while (type == "G4DisplacedSolid" ||
274  type == "G4ReflectedSolid" ||
275  type == "G4ScaledSolid")
276  {
277  if (type == "G4DisplacedSolid")
278  {
279  transform = transform * G4Transform3D(
280  ((G4DisplacedSolid*)solid)->GetObjectRotation(),
281  ((G4DisplacedSolid*)solid)->GetObjectTranslation());
282  solid = ((G4DisplacedSolid*)solid)->GetConstituentMovedSolid();
283  }
284  else if (type == "G4ReflectedSolid")
285  {
286  transform= transform*((G4ReflectedSolid*)solid)->GetDirectTransform3D();
287  solid = ((G4ReflectedSolid*)solid)->GetConstituentMovedSolid();
288  }
289  else if (type == "G4ScaledSolid")
290  {
291  transform = transform * ((G4ScaledSolid*)solid)->GetScaleTransform();
292  solid = ((G4ScaledSolid*)solid)->GetUnscaledSolid();
293  }
294  type = solid->GetEntityType();
295  }
296 
297  // If current solid is a Boolean solid then continue recursion,
298  // otherwise add it to the list of primitives
299  //
300  if (type == "G4UnionSolid" ||
301  type == "G4SubtractionSolid" ||
302  type == "G4IntersectionSolid" ||
303  type == "G4BooleanSolid")
304  {
305  ((G4BooleanSolid *)solid)->GetListOfPrimitives(primitives,transform);
306  }
307  else
308  {
309  primitives.push_back(std::pair<G4VSolid*,G4Transform3D>(solid,transform));
310  }
311  }
312 }
G4VSolid * fPtrSolidB
virtual G4GeometryType GetEntityType() const =0
int G4int
Definition: G4Types.hh:78
HepGeom::Transform3D G4Transform3D
G4VSolid * fPtrSolidA

Here is the call graph for this function:

Here is the caller graph for this function:

G4ThreeVector G4BooleanSolid::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 319 of file G4BooleanSolid.cc.

320 {
321  G4int nprims = fPrimitives.size();
322  std::pair<G4VSolid *, G4Transform3D> prim;
323 
324  // Get list of primitives and find the total area of their surfaces
325  //
326  if (nprims == 0)
327  {
328  GetListOfPrimitives(fPrimitives, G4Transform3D());
329  nprims = fPrimitives.size();
330  fPrimitivesSurfaceArea = 0.;
331  for (G4int i=0; i<nprims; i++)
332  {
333  fPrimitivesSurfaceArea += fPrimitives[i].first->GetSurfaceArea();
334  }
335  }
336 
337  // Select random primitive, get random point on its surface and
338  // check that the point belongs to the surface of the solid
339  //
341  for (G4int k=0; k<1000000; k++) // try 1000000 times
342  {
343  G4double rand = fPrimitivesSurfaceArea * G4UniformRand();
344  G4double area = 0.;
345  for (G4int i=0; i<nprims; i++)
346  {
347  prim = fPrimitives[i];
348  area += prim.first->GetSurfaceArea();
349  if (rand < area) break;
350  }
351  p = prim.first->GetPointOnSurface();
352  p = prim.second * G4Point3D(p);
353  if (Inside(p) == kSurface) return p;
354  }
355  std::ostringstream message;
356  message << "Solid - " << GetName() << "\n"
357  << "All attempts to generate a point on the surface have failed.\n"
358  << "Returning point from the last unsuccessful attempt!";
359  G4Exception("G4BooleanSolid::GetPointOnSurface()",
360  "GeomSolids1001", JustWarning, message);
361  return p;
362 }
G4String GetName() const
const char * p
Definition: xmltok.h:285
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:97
virtual EInside Inside(const G4ThreeVector &p) const =0
void GetListOfPrimitives(std::vector< std::pair< G4VSolid *, G4Transform3D >> &, const G4Transform3D &) const
HepGeom::Transform3D G4Transform3D
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4Polyhedron * G4BooleanSolid::GetPolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 368 of file G4BooleanSolid.cc.

369 {
370  if (!fpPolyhedron ||
371  fRebuildPolyhedron ||
373  fpPolyhedron->GetNumberOfRotationSteps())
374  {
375  G4AutoLock l(&polyhedronMutex);
376  delete fpPolyhedron;
377  fpPolyhedron = CreatePolyhedron();
378  fRebuildPolyhedron = false;
379  l.unlock();
380  }
381  return fpPolyhedron;
382 }
virtual G4Polyhedron * CreatePolyhedron() const
Definition: G4VSolid.cc:660
static G4int GetNumberOfRotationSteps()
G4int GetNumberOfRotationStepsAtTimeOfCreation() const

Here is the call graph for this function:

G4double G4BooleanSolid::GetSurfaceArea ( )
inlinevirtual

Reimplemented from G4VSolid.

G4BooleanSolid & G4BooleanSolid::operator= ( const G4BooleanSolid rhs)

Definition at line 153 of file G4BooleanSolid.cc.

154 {
155  // Check assignment to self
156  //
157  if (this == &rhs) { return *this; }
158 
159  // Copy base class data
160  //
161  G4VSolid::operator=(rhs);
162 
163  // Copy data
164  //
166  fStatistics= rhs.fStatistics; fCubVolEpsilon= rhs.fCubVolEpsilon;
167  fAreaAccuracy= rhs.fAreaAccuracy; fCubicVolume= rhs.fCubicVolume;
168  fSurfaceArea= rhs.fSurfaceArea;
169  createdDisplacedSolid= rhs.createdDisplacedSolid;
170  fRebuildPolyhedron = false;
171  delete fpPolyhedron; fpPolyhedron = 0;
172  fPrimitives.resize(0); fPrimitivesSurfaceArea = 0.;
173 
174  return *this;
175 }
G4VSolid * fPtrSolidB
G4VSolid * fPtrSolidA
G4VSolid & operator=(const G4VSolid &rhs)
Definition: G4VSolid.cc:111

Here is the call graph for this function:

Here is the caller graph for this function:

void G4BooleanSolid::SetAreaAccuracy ( G4double  ep)
inline
void G4BooleanSolid::SetAreaStatistics ( G4int  st)
inline
void G4BooleanSolid::SetCubVolEpsilon ( G4double  ep)
inline
void G4BooleanSolid::SetCubVolStatistics ( G4int  st)
inline
G4Polyhedron * G4BooleanSolid::StackPolyhedron ( HepPolyhedronProcessor processor,
const G4VSolid solid 
) const
protected

Definition at line 389 of file G4BooleanSolid.cc.

391 {
393  const G4String& type = solid->GetEntityType();
394  if (type == "G4UnionSolid")
395  { operation = HepPolyhedronProcessor::UNION; }
396  else if (type == "G4IntersectionSolid")
397  { operation = HepPolyhedronProcessor::INTERSECTION; }
398  else if (type == "G4SubtractionSolid")
399  { operation = HepPolyhedronProcessor::SUBTRACTION; }
400  else
401  {
402  std::ostringstream message;
403  message << "Solid - " << solid->GetName()
404  << " - Unrecognised composite solid" << G4endl
405  << " Returning NULL !";
406  G4Exception("StackPolyhedron()", "GeomSolids1001", JustWarning, message);
407  return 0;
408  }
409 
410  G4Polyhedron* top = 0;
411  const G4VSolid* solidA = solid->GetConstituentSolid(0);
412  const G4VSolid* solidB = solid->GetConstituentSolid(1);
413 
414  if (solidA->GetConstituentSolid(0))
415  {
416  top = StackPolyhedron(processor, solidA);
417  }
418  else
419  {
420  top = solidA->GetPolyhedron();
421  }
422  G4Polyhedron* operand = solidB->GetPolyhedron();
423  processor.push_back (operation, *operand);
424 
425  return top;
426 }
virtual G4Polyhedron * GetPolyhedron() const
Definition: G4VSolid.cc:665
G4String GetName() const
virtual G4GeometryType GetEntityType() const =0
static int operand(pchar begin, pchar end, double &result, pchar &endp, const dic_type &dictionary)
Definition: Evaluator.cc:162
void push_back(Operation, const HepPolyhedron &)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual const G4VSolid * GetConstituentSolid(G4int no) const
Definition: G4VSolid.cc:168
#define G4endl
Definition: G4ios.hh:61
G4Polyhedron * StackPolyhedron(HepPolyhedronProcessor &, const G4VSolid *) const

Here is the call graph for this function:

Here is the caller graph for this function:

std::ostream & G4BooleanSolid::StreamInfo ( std::ostream &  os) const
virtual

Implements G4VSolid.

Definition at line 236 of file G4BooleanSolid.cc.

237 {
238  os << "-----------------------------------------------------------\n"
239  << " *** Dump for Boolean solid - " << GetName() << " ***\n"
240  << " ===================================================\n"
241  << " Solid type: " << GetEntityType() << "\n"
242  << " Parameters of constituent solids: \n"
243  << "===========================================================\n";
244  fPtrSolidA->StreamInfo(os);
245  fPtrSolidB->StreamInfo(os);
246  os << "===========================================================\n";
247 
248  return os;
249 }
G4String GetName() const
G4VSolid * fPtrSolidB
virtual G4GeometryType GetEntityType() const
virtual std::ostream & StreamInfo(std::ostream &os) const =0
G4VSolid * fPtrSolidA

Here is the call graph for this function:

Member Data Documentation

G4VSolid* G4BooleanSolid::fPtrSolidA
protected

Definition at line 121 of file G4BooleanSolid.hh.

G4VSolid* G4BooleanSolid::fPtrSolidB
protected

Definition at line 122 of file G4BooleanSolid.hh.


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