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

#include <UGenericPolycone.hh>

Inheritance diagram for UGenericPolycone:
UVCSGfaceted VUSolid

Public Member Functions

 UGenericPolycone (const std::string &name, double phiStart, double phiTotal, int numZPlanes, const double zPlane[], const double rInner[], const double rOuter[])
 
 UGenericPolycone (const std::string &name, double phiStart, double phiTotal, int numRZ, const double r[], const double z[])
 
virtual ~UGenericPolycone ()
 
VUSolid::EnumInside Inside (const UVector3 &p) const
 
double DistanceToIn (const UVector3 &p, const UVector3 &v, double aPstep=UUtils::kInfinity) const
 
UVector3 GetPointOnSurface () const
 
UGeometryType GetEntityType () const
 
VUSolidClone () const
 
std::ostream & StreamInfo (std::ostream &os) const
 
bool Reset ()
 
double GetStartPhi () const
 
double GetEndPhi () const
 
bool IsOpen () const
 
int GetNumRZCorner () const
 
UPolyconeSideRZ GetCorner (int index) const
 
 UGenericPolycone (const UGenericPolycone &source)
 
UGenericPolyconeoperator= (const UGenericPolycone &source)
 
- Public Member Functions inherited from UVCSGfaceted
 UVCSGfaceted (const std::string &name)
 
virtual ~UVCSGfaceted ()
 
 UVCSGfaceted (const UVCSGfaceted &source)
 
UVCSGfacetedoperator= (const UVCSGfaceted &source)
 
VUSolid::EnumInside InsideNoVoxels (const UVector3 &p) const
 
virtual bool Normal (const UVector3 &p, UVector3 &n) const
 
double DistanceToInNoVoxels (const UVector3 &p, const UVector3 &v) const
 
virtual double SafetyFromOutside (const UVector3 &aPoint, bool aAccurate=false) const
 
double DistanceTo (const UVector3 &p, const bool outgoing) const
 
double DistanceToOutNoVoxels (const UVector3 &p, const UVector3 &v, UVector3 &n, bool &aConvex) const
 
virtual double DistanceToOut (const UVector3 &p, const UVector3 &v, UVector3 &n, bool &aConvex, double aPstep=UUtils::kInfinity) const
 
virtual double SafetyFromInside (const UVector3 &aPoint, bool aAccurate=false) const
 
virtual double SafetyFromInsideNoVoxels (const UVector3 &aPoint, bool aAccurate=false) const
 
int GetCubVolStatistics () const
 
double GetCubVolEpsilon () const
 
void SetCubVolStatistics (int st)
 
void SetCubVolEpsilon (double ep)
 
int GetAreaStatistics () const
 
double GetAreaAccuracy () const
 
void SetAreaStatistics (int st)
 
void SetAreaAccuracy (double ep)
 
virtual double Capacity ()
 
virtual double SurfaceArea ()
 
- Public Member Functions inherited from VUSolid
 VUSolid ()
 
 VUSolid (const std::string &name)
 
virtual ~VUSolid ()
 
double GetCarTolerance () const
 
double GetRadTolerance () const
 
double GetAngTolerance () const
 
void SetCarTolerance (double eps)
 
void SetRadTolerance (double eps)
 
void SetAngTolerance (double eps)
 
virtual void ExtentAxis (EAxisType aAxis, double &aMin, double &aMax) const
 
const std::string & GetName () const
 
void SetName (const std::string &aName)
 
virtual void SamplePointsInside (int, UVector3 *) const
 
virtual void SamplePointsOnSurface (int, UVector3 *) const
 
virtual void SamplePointsOnEdge (int, UVector3 *) const
 
double EstimateCubicVolume (int nStat, double epsilon) const
 
double EstimateSurfaceArea (int nStat, double ell) const
 

Protected Member Functions

void Create (double phiStart, double phiTotal, UReduciblePolygon *rz)
 
void CopyStuff (const UGenericPolycone &source)
 
void GetParametersList (int, double *) const
 
void ComputeBBox (UBBox *, bool)
 
void Extent (UVector3 &aMin, UVector3 &aMax) const
 
- Protected Member Functions inherited from UVCSGfaceted
double SafetyFromInsideSection (int index, const UVector3 &p, UBits &bits) const
 
int GetSection (double z) const
 
UVector3 GetPointOnSurfaceGeneric () const
 
void CopyStuff (const UVCSGfaceted &source)
 
void DeleteStuff ()
 
void FindCandidates (double z, std::vector< int > &candidates, bool sides=false)
 
void InitVoxels (UReduciblePolygon &z, double radius)
 

Protected Attributes

double startPhi
 
double endPhi
 
bool phiIsOpen
 
int numCorner
 
UPolyconeSideRZcorners
 
UEnclosingCylinderenclosingCylinder
 
- Protected Attributes inherited from UVCSGfaceted
int numFace
 
UVCSGface ** faces
 
double fCubicVolume
 
double fSurfaceArea
 
std::vector< double > fZs
 
std::vector< std::vector< int > > fCandidates
 
int fMaxSection
 
UBox fBox
 
double fBoxShift
 
bool fNoVoxels
 

Additional Inherited Members

- Public Types inherited from VUSolid
enum  EnumInside { eInside =0, eSurface =1, eOutside =2 }
 
enum  EAxisType { eXaxis =0, eYaxis =1, eZaxis =2 }
 
- Static Public Member Functions inherited from VUSolid
static double Tolerance ()
 
- Static Protected Attributes inherited from VUSolid
static double fgTolerance = 1.0E-9
 
static double frTolerance = 1.0E-9
 
static double faTolerance = 1.0E-9
 

Detailed Description

Definition at line 39 of file UGenericPolycone.hh.

Constructor & Destructor Documentation

UGenericPolycone::UGenericPolycone ( const std::string &  name,
double  phiStart,
double  phiTotal,
int  numZPlanes,
const double  zPlane[],
const double  rInner[],
const double  rOuter[] 
)

Referenced by Clone().

UGenericPolycone::UGenericPolycone ( const std::string &  name,
double  phiStart,
double  phiTotal,
int  numRZ,
const double  r[],
const double  z[] 
)

Definition at line 37 of file UGenericPolycone.cc.

References Create().

44 {
45  UReduciblePolygon* rz = new UReduciblePolygon(r, z, numRZ);
46 
47  Create(phiStart, phiTotal, rz);
48 
49  delete rz;
50 }
G4double z
Definition: TRTMaterials.hh:39
void Create(double phiStart, double phiTotal, UReduciblePolygon *rz)
const XML_Char * name
UVCSGfaceted(const std::string &name)
Definition: UVCSGfaceted.cc:31
UGenericPolycone::~UGenericPolycone ( )
virtual

Definition at line 247 of file UGenericPolycone.cc.

References corners, and enclosingCylinder.

248 {
249  delete [] corners;
250  delete enclosingCylinder;
251 }
UPolyconeSideRZ * corners
UEnclosingCylinder * enclosingCylinder
UGenericPolycone::UGenericPolycone ( const UGenericPolycone source)

Definition at line 257 of file UGenericPolycone.cc.

References CopyStuff().

258  : UVCSGfaceted(source)
259 {
260  CopyStuff(source);
261 }
void CopyStuff(const UGenericPolycone &source)
UVCSGfaceted(const std::string &name)
Definition: UVCSGfaceted.cc:31

Member Function Documentation

VUSolid * UGenericPolycone::Clone ( ) const
virtual

Implements VUSolid.

Definition at line 384 of file UGenericPolycone.cc.

References UGenericPolycone().

385 {
386  return new UGenericPolycone(*this);
387 }
UGenericPolycone(const std::string &name, double phiStart, double phiTotal, int numZPlanes, const double zPlane[], const double rInner[], const double rOuter[])
void UGenericPolycone::ComputeBBox ( UBBox ,
bool   
)
inlineprotectedvirtual

Implements VUSolid.

Definition at line 121 of file UGenericPolycone.hh.

122  {
123  // Computes bounding box.
124  std::cout << "ComputeBBox - Not implemented" << std::endl;
125  }
void UGenericPolycone::CopyStuff ( const UGenericPolycone source)
protected

Definition at line 286 of file UGenericPolycone.cc.

References corners, enclosingCylinder, endPhi, numCorner, phiIsOpen, and startPhi.

Referenced by operator=(), and UGenericPolycone().

287 {
288  //
289  // Simple stuff
290  //
291  startPhi = source.startPhi;
292  endPhi = source.endPhi;
293  phiIsOpen = source.phiIsOpen;
294  numCorner = source.numCorner;
295 
296  //
297  // The corner array
298  //
300 
301  UPolyconeSideRZ* corn = corners,
302  *sourceCorn = source.corners;
303  do
304  {
305  *corn = *sourceCorn;
306  }
307  while (++sourceCorn, ++corn < corners + numCorner);
308 
309  //
310  // Enclosing cylinder
311  //
313 }
UPolyconeSideRZ * corners
UEnclosingCylinder * enclosingCylinder
void UGenericPolycone::Create ( double  phiStart,
double  phiTotal,
UReduciblePolygon rz 
)
protected

Definition at line 59 of file UGenericPolycone.cc.

References UReduciblePolygon::Amax(), UReduciblePolygon::Amin(), UReduciblePolygon::Area(), UReduciblePolygonIterator::Begin(), UReduciblePolygon::BisectedBy(), UReduciblePolygon::Bmax(), UReduciblePolygon::Bmin(), corners, UReduciblePolygon::CrossesItself(), enclosingCylinder, endPhi, UUtils::Exception(), UVCSGfaceted::faces, FatalErrorInArguments, UVCSGfaceted::fMaxSection, UVCSGfaceted::fNoVoxels, UReduciblePolygonIterator::GetA(), UReduciblePolygonIterator::GetB(), VUSolid::GetName(), UVCSGfaceted::InitVoxels(), UReduciblePolygonIterator::Next(), numCorner, UVCSGfaceted::numFace, UReduciblePolygon::NumVertices(), phiIsOpen, UPolyconeSideRZ::r, UEnclosingCylinder::radius, UReduciblePolygon::RemoveDuplicateVertices(), UReduciblePolygon::RemoveRedundantVertices(), UReduciblePolygon::ReverseOrder(), startPhi, VUSolid::Tolerance(), and UPolyconeSideRZ::z.

Referenced by UGenericPolycone().

62 {
63  //
64  // Perform checks of rz values
65  //
66  if (rz->Amin() < 0.0)
67  {
68  std::ostringstream message;
69  message << "Illegal input parameters - " << GetName() << std::endl
70  << " All R values must be >= 0 !";
71  UUtils::Exception("UGenericPolycone::Create()", "GeomSolids0002",
72  FatalErrorInArguments, 1, message.str().c_str());
73  }
74 
75  double rzArea = rz->Area();
76  if (rzArea < -VUSolid::Tolerance())
77  rz->ReverseOrder();
78 
79  else if (rzArea < -VUSolid::Tolerance())
80  {
81  std::ostringstream message;
82  message << "Illegal input parameters - " << GetName() << std::endl
83  << " R/Z Cross section is zero or near zero: " << rzArea;
84  UUtils::Exception("UGenericPolycone::Create()", "GeomSolids0002",
85  FatalErrorInArguments, 1, message.str().c_str());
86  }
87 
90  {
91  std::ostringstream message;
92  message << "Illegal input parameters - " << GetName() << std::endl
93  << " Too few unique R/Z values !";
94  UUtils::Exception("UGenericPolycone::Create()", "GeomSolids0002",
95  FatalErrorInArguments, 1, message.str().c_str());
96  }
97 
98  if (rz->CrossesItself(1 / UUtils::kInfinity))
99  {
100  std::ostringstream message;
101  message << "Illegal input parameters - " << GetName() << std::endl
102  << " R/Z segments Cross !";
103  UUtils::Exception("UGenericPolycone::Create()", "GeomSolids0002",
104  FatalErrorInArguments, 1, message.str().c_str());
105  }
106 
107  numCorner = rz->NumVertices();
108 
109  //
110  // Phi opening? Account for some possible roundoff, and interpret
111  // nonsense value as representing no phi opening
112  //
113  if (phiTotal <= 0 || phiTotal > 2 * UUtils::kPi - 1E-10)
114  {
115  phiIsOpen = false;
116  startPhi = 0;
117  endPhi = 2 * UUtils::kPi;
118  }
119  else
120  {
121  phiIsOpen = true;
122 
123  //
124  // Convert phi into our convention
125  //
126  startPhi = phiStart;
127  while (startPhi < 0) startPhi += 2 * UUtils::kPi;
128 
129  endPhi = phiStart + phiTotal;
130  while (endPhi < startPhi) endPhi += 2 * UUtils::kPi;
131  }
132 
133  //
134  // Allocate corner array.
135  //
137 
138  //
139  // Copy corners
140  //
141  UReduciblePolygonIterator iterRZ(rz);
142 
143  UPolyconeSideRZ* next = corners;
144  iterRZ.Begin();
145  do
146  {
147  next->r = iterRZ.GetA();
148  next->z = iterRZ.GetB();
149  }
150  while (++next, iterRZ.Next());
151 
152  //
153  // Allocate face pointer array
154  //
156  faces = new UVCSGface*[numFace];
157 
158  //
159  // Construct conical faces
160  //
161  // But! Don't construct a face if both points are at zero radius!
162  //
163  UPolyconeSideRZ* corner = corners,
164  *prev = corners + numCorner - 1,
165  *nextNext;
166  UVCSGface** face = faces;
167  do
168  {
169  next = corner + 1;
170  if (next >= corners + numCorner) next = corners;
171  nextNext = next + 1;
172  if (nextNext >= corners + numCorner) nextNext = corners;
173 
174  if (corner->r < 1 / UUtils::kInfinity && next->r < 1 / UUtils::kInfinity) continue;
175 
176  //
177  // We must decide here if we can dare declare one of our faces
178  // as having a "valid" normal (i.e. allBehind = true). This
179  // is never possible if the face faces "inward" in r.
180  //
181  bool allBehind;
182  if (corner->z > next->z)
183  {
184  allBehind = false;
185  }
186  else
187  {
188  //
189  // Otherwise, it is only true if the line passing
190  // through the two points of the segment do not
191  // split the r/z Cross section
192  //
193  allBehind = !rz->BisectedBy(corner->r, corner->z,
194  next->r, next->z, VUSolid::Tolerance());
195  }
196 
197  *face++ = new UPolyconeSide(prev, corner, next, nextNext,
198  startPhi, endPhi - startPhi, phiIsOpen, allBehind);
199  }
200  while (prev = corner, corner = next, corner > corners);
201 
202  if (phiIsOpen)
203  {
204  //
205  // Construct phi open edges
206  //
207  *face++ = new UPolyPhiFace(rz, startPhi, 0, endPhi);
208  *face++ = new UPolyPhiFace(rz, endPhi, 0, startPhi);
209  }
210 
211  //
212  // We might have dropped a face or two: recalculate numFace
213  //
214  numFace = face - faces;
215 
216  //
217  // Make enclosingCylinder
218  //
220  new UEnclosingCylinder(rz->Amax(), rz->Bmax(), rz->Bmin(), phiIsOpen, phiStart, phiTotal);
221 
223 
224  fNoVoxels = fMaxSection < 2;
225 
226 }
double Amin() const
UPolyconeSideRZ * corners
bool RemoveRedundantVertices(double tolerance)
const std::string & GetName() const
Definition: VUSolid.hh:103
bool RemoveDuplicateVertices(double tolerance)
bool BisectedBy(double a1, double b1, double a2, double b2, double tolerance)
static double Tolerance()
Definition: VUSolid.hh:127
UEnclosingCylinder * enclosingCylinder
void InitVoxels(UReduciblePolygon &z, double radius)
int NumVertices() const
double Bmin() const
bool CrossesItself(double tolerance)
double Amax() const
double Bmax() const
UVCSGface ** faces
void Exception(const char *originOfException, const char *exceptionCode, ExceptionSeverity severity, int level, const char *description)
Definition: UUtils.cc:177
double UGenericPolycone::DistanceToIn ( const UVector3 p,
const UVector3 v,
double  aPstep = UUtils::kInfinity 
) const
virtual

Reimplemented from UVCSGfaceted.

Definition at line 358 of file UGenericPolycone.cc.

References UVCSGfaceted::DistanceToIn(), enclosingCylinder, and UEnclosingCylinder::ShouldMiss().

360 {
361  //
362  // Quick test
363  //
364  if (enclosingCylinder->ShouldMiss(p, v))
365  return UUtils::kInfinity;
366 
367  //
368  // Long answer
369  //
370  return UVCSGfaceted::DistanceToIn(p, v, aPstep);
371 }
UEnclosingCylinder * enclosingCylinder
bool ShouldMiss(const UVector3 &p, const UVector3 &v) const
virtual double DistanceToIn(const UVector3 &p, const UVector3 &v, double aPstep=UUtils::kInfinity) const
void UGenericPolycone::Extent ( UVector3 aMin,
UVector3 aMax 
) const
protectedvirtual

Implements VUSolid.

Definition at line 427 of file UGenericPolycone.cc.

References enclosingCylinder, and UEnclosingCylinder::Extent().

428 {
429  enclosingCylinder->Extent(aMin, aMax);
430 }
UEnclosingCylinder * enclosingCylinder
void Extent(UVector3 &aMin, UVector3 &aMax) const
UPolyconeSideRZ UGenericPolycone::GetCorner ( int  index) const
inline
double UGenericPolycone::GetEndPhi ( ) const
inline
UGeometryType UGenericPolycone::GetEntityType ( ) const
virtual

Reimplemented from UVCSGfaceted.

Definition at line 376 of file UGenericPolycone.cc.

377 {
378  return std::string("GenericPolycone");
379 }
int UGenericPolycone::GetNumRZCorner ( ) const
inline
void UGenericPolycone::GetParametersList ( int  ,
double *   
) const
inlineprotectedvirtual

Implements VUSolid.

Definition at line 119 of file UGenericPolycone.hh.

119 {}
UVector3 UGenericPolycone::GetPointOnSurface ( ) const
virtual

Implements VUSolid.

Definition at line 421 of file UGenericPolycone.cc.

References UVCSGfaceted::GetPointOnSurfaceGeneric().

422 {
423  return GetPointOnSurfaceGeneric();
424 
425 }
UVector3 GetPointOnSurfaceGeneric() const
double UGenericPolycone::GetStartPhi ( ) const
inline
VUSolid::EnumInside UGenericPolycone::Inside ( const UVector3 p) const
virtual

Reimplemented from UVCSGfaceted.

Definition at line 338 of file UGenericPolycone.cc.

References enclosingCylinder, VUSolid::eOutside, UVCSGfaceted::Inside(), and UEnclosingCylinder::MustBeOutside().

339 {
340  //
341  // Quick test
342  //
343  if (enclosingCylinder->MustBeOutside(p)) return eOutside;
344 
345  //
346  // Long answer
347  //
348  return UVCSGfaceted::Inside(p);
349 }
bool MustBeOutside(const UVector3 &p) const
UEnclosingCylinder * enclosingCylinder
virtual VUSolid::EnumInside Inside(const UVector3 &p) const
bool UGenericPolycone::IsOpen ( ) const
inline
UGenericPolycone & UGenericPolycone::operator= ( const UGenericPolycone source)

Definition at line 267 of file UGenericPolycone.cc.

References CopyStuff(), corners, enclosingCylinder, and UVCSGfaceted::operator=().

268 {
269  if (this == &source) return *this;
270 
271  UVCSGfaceted::operator=(source);
272 
273  delete [] corners;
274 
275  delete enclosingCylinder;
276 
277  CopyStuff(source);
278 
279  return *this;
280 }
UPolyconeSideRZ * corners
UEnclosingCylinder * enclosingCylinder
UVCSGfaceted & operator=(const UVCSGfaceted &source)
Definition: UVCSGfaceted.cc:63
void CopyStuff(const UGenericPolycone &source)
bool UGenericPolycone::Reset ( )

Definition at line 319 of file UGenericPolycone.cc.

References VUSolid::GetName().

320 {
321 
322  std::ostringstream message;
323  message << "Solid " << GetName() << " built using generic construct."
324  << std::endl << "Not applicable to the generic construct !";
325  // UException("UGenericPolycone::Reset(,,)", "GeomSolids1001",
326  // JustWarning, message, "Parameters NOT resetted.");
327  return 1;
328 
329 }
const std::string & GetName() const
Definition: VUSolid.hh:103
std::ostream & UGenericPolycone::StreamInfo ( std::ostream &  os) const
virtual

Reimplemented from UVCSGfaceted.

Definition at line 392 of file UGenericPolycone.cc.

References corners, endPhi, VUSolid::GetName(), numCorner, UPolyconeSideRZ::r, startPhi, and UPolyconeSideRZ::z.

393 {
394  int oldprc = os.precision(16);
395  os << "-----------------------------------------------------------\n"
396  << " *** Dump for solid - " << GetName() << " ***\n"
397  << " ===================================================\n"
398  << " Solid type: UGenericPolycone\n"
399  << " Parameters: \n"
400  << " starting phi angle : " << startPhi / (UUtils::kPi / 180.0) << " degrees \n"
401  << " ending phi angle : " << endPhi / (UUtils::kPi / 180.0) << " degrees \n";
402  int i = 0;
403 
404  os << " number of RZ points: " << numCorner << "\n"
405  << " RZ values (corners): \n";
406  for (i = 0; i < numCorner; i++)
407  {
408  os << " "
409  << corners[i].r << ", " << corners[i].z << "\n";
410  }
411 
412  os << "-----------------------------------------------------------\n";
413  os.precision(oldprc);
414 
415  return os;
416 }
UPolyconeSideRZ * corners
const std::string & GetName() const
Definition: VUSolid.hh:103

Field Documentation

UPolyconeSideRZ* UGenericPolycone::corners
protected

Definition at line 137 of file UGenericPolycone.hh.

Referenced by CopyStuff(), Create(), operator=(), StreamInfo(), and ~UGenericPolycone().

UEnclosingCylinder* UGenericPolycone::enclosingCylinder
protected
double UGenericPolycone::endPhi
protected

Definition at line 134 of file UGenericPolycone.hh.

Referenced by CopyStuff(), Create(), and StreamInfo().

int UGenericPolycone::numCorner
protected

Definition at line 136 of file UGenericPolycone.hh.

Referenced by CopyStuff(), Create(), and StreamInfo().

bool UGenericPolycone::phiIsOpen
protected

Definition at line 135 of file UGenericPolycone.hh.

Referenced by CopyStuff(), and Create().

double UGenericPolycone::startPhi
protected

Definition at line 133 of file UGenericPolycone.hh.

Referenced by CopyStuff(), Create(), and StreamInfo().


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