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

#include <G4GenericPolycone.hh>

Inheritance diagram for G4GenericPolycone:
G4VCSGfaceted G4VSolid

Public Member Functions

 G4GenericPolycone (const G4String &name, G4double phiStart, G4double phiTotal, G4int numRZ, const G4double r[], const G4double z[])
 
virtual ~G4GenericPolycone ()
 
EInside Inside (const G4ThreeVector &p) const
 
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const
 
G4double DistanceToIn (const G4ThreeVector &p) const
 
G4ThreeVector GetPointOnSurface () const
 
G4GeometryType GetEntityType () const
 
G4VSolidClone () const
 
std::ostream & StreamInfo (std::ostream &os) const
 
G4PolyhedronCreatePolyhedron () const
 
G4bool Reset ()
 
G4double GetStartPhi () const
 
G4double GetEndPhi () const
 
G4bool IsOpen () const
 
G4int GetNumRZCorner () const
 
G4PolyconeSideRZ GetCorner (G4int index) const
 
 G4GenericPolycone (__void__ &)
 
 G4GenericPolycone (const G4GenericPolycone &source)
 
const G4GenericPolyconeoperator= (const G4GenericPolycone &source)
 
- Public Member Functions inherited from G4VCSGfaceted
 G4VCSGfaceted (const G4String &name)
 
virtual ~G4VCSGfaceted ()
 
 G4VCSGfaceted (const G4VCSGfaceted &source)
 
const G4VCSGfacetedoperator= (const G4VCSGfaceted &source)
 
virtual G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
 
virtual G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const
 
virtual G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
 
virtual G4double DistanceToOut (const G4ThreeVector &p) const
 
virtual void DescribeYourselfTo (G4VGraphicsScene &scene) const
 
virtual G4VisExtent GetExtent () const
 
virtual G4PolyhedronGetPolyhedron () 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)
 
virtual G4double GetCubicVolume ()
 
virtual G4double GetSurfaceArea ()
 
 G4VCSGfaceted (__void__ &)
 
- 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 ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
void DumpInfo () const
 
virtual const G4VSolidGetConstituentSolid (G4int no) const
 
virtual G4VSolidGetConstituentSolid (G4int no)
 
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
 
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 
 G4VSolid (__void__ &)
 
 G4VSolid (const G4VSolid &rhs)
 
G4VSolidoperator= (const G4VSolid &rhs)
 

Protected Member Functions

void Create (G4double phiStart, G4double phiTotal, G4ReduciblePolygon *rz)
 
void CopyStuff (const G4GenericPolycone &source)
 
- Protected Member Functions inherited from G4VCSGfaceted
virtual G4double DistanceTo (const G4ThreeVector &p, const G4bool outgoing) const
 
G4ThreeVector GetPointOnSurfaceGeneric () const
 
void CopyStuff (const G4VCSGfaceted &source)
 
void DeleteStuff ()
 
- 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

G4double startPhi
 
G4double endPhi
 
G4bool phiIsOpen
 
G4int numCorner
 
G4PolyconeSideRZcorners
 
G4EnclosingCylinderenclosingCylinder
 
- Protected Attributes inherited from G4VCSGfaceted
G4int numFace
 
G4VCSGface ** faces
 
G4double fCubicVolume
 
G4double fSurfaceArea
 
G4PolyhedronfpPolyhedron
 
- Protected Attributes inherited from G4VSolid
G4double kCarTolerance
 

Detailed Description

Definition at line 70 of file G4GenericPolycone.hh.

Constructor & Destructor Documentation

G4GenericPolycone::G4GenericPolycone ( const G4String name,
G4double  phiStart,
G4double  phiTotal,
G4int  numRZ,
const G4double  r[],
const G4double  z[] 
)

Definition at line 59 of file G4GenericPolycone.cc.

References Create().

Referenced by Clone().

65  : G4VCSGfaceted( name )
66 {
67 
68  G4ReduciblePolygon *rz = new G4ReduciblePolygon( r, z, numRZ );
69 
70  Create( phiStart, phiTotal, rz );
71 
72  // Set original_parameters struct for consistency
73  //
74  //SetOriginalParameters(rz);
75 
76  delete rz;
77 }
G4double z
Definition: TRTMaterials.hh:39
G4VCSGfaceted(const G4String &name)
void Create(G4double phiStart, G4double phiTotal, G4ReduciblePolygon *rz)
G4GenericPolycone::~G4GenericPolycone ( )
virtual

Definition at line 262 of file G4GenericPolycone.cc.

References corners, and enclosingCylinder.

263 {
264  delete [] corners;
265  delete enclosingCylinder;
266 }
G4PolyconeSideRZ * corners
G4EnclosingCylinder * enclosingCylinder
G4GenericPolycone::G4GenericPolycone ( __void__ &  a)

Definition at line 252 of file G4GenericPolycone.cc.

253  : G4VCSGfaceted(a), startPhi(0.), endPhi(0.), phiIsOpen(false),
255 {
256 }
G4PolyconeSideRZ * corners
G4VCSGfaceted(const G4String &name)
G4EnclosingCylinder * enclosingCylinder
G4GenericPolycone::G4GenericPolycone ( const G4GenericPolycone source)

Definition at line 272 of file G4GenericPolycone.cc.

References CopyStuff().

273  : G4VCSGfaceted( source )
274 {
275  CopyStuff( source );
276 }
G4VCSGfaceted(const G4String &name)
void CopyStuff(const G4GenericPolycone &source)

Member Function Documentation

G4VSolid * G4GenericPolycone::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 420 of file G4GenericPolycone.cc.

References G4GenericPolycone().

421 {
422  return new G4GenericPolycone(*this);
423 }
G4GenericPolycone(const G4String &name, G4double phiStart, G4double phiTotal, G4int numRZ, const G4double r[], const G4double z[])
void G4GenericPolycone::CopyStuff ( const G4GenericPolycone source)
protected

Definition at line 302 of file G4GenericPolycone.cc.

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

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

303 {
304  //
305  // Simple stuff
306  //
307  startPhi = source.startPhi;
308  endPhi = source.endPhi;
309  phiIsOpen = source.phiIsOpen;
310  numCorner = source.numCorner;
311 
312  //
313  // The corner array
314  //
316 
317  G4PolyconeSideRZ *corn = corners,
318  *sourceCorn = source.corners;
319  do
320  {
321  *corn = *sourceCorn;
322  } while( ++sourceCorn, ++corn < corners+numCorner );
323 
324  //
325  // Enclosing cylinder
326  //
328 }
G4PolyconeSideRZ * corners
G4EnclosingCylinder * enclosingCylinder
void G4GenericPolycone::Create ( G4double  phiStart,
G4double  phiTotal,
G4ReduciblePolygon rz 
)
protected

Definition at line 85 of file G4GenericPolycone.cc.

References G4ReduciblePolygon::Amin(), G4ReduciblePolygon::Area(), G4ReduciblePolygonIterator::Begin(), G4ReduciblePolygon::BisectedBy(), corners, G4ReduciblePolygon::CrossesItself(), enclosingCylinder, endPhi, G4VCSGfaceted::faces, FatalErrorInArgument, G4endl, G4Exception(), G4ReduciblePolygonIterator::GetA(), G4ReduciblePolygonIterator::GetB(), G4VSolid::GetName(), G4VSolid::kCarTolerance, G4ReduciblePolygonIterator::Next(), numCorner, G4VCSGfaceted::numFace, G4ReduciblePolygon::NumVertices(), phiIsOpen, G4PolyconeSideRZ::r, G4ReduciblePolygon::RemoveDuplicateVertices(), G4ReduciblePolygon::RemoveRedundantVertices(), G4ReduciblePolygon::ReverseOrder(), startPhi, python.hepunit::twopi, and G4PolyconeSideRZ::z.

Referenced by G4GenericPolycone().

88 {
89  //
90  // Perform checks of rz values
91  //
92  if (rz->Amin() < 0.0)
93  {
94  std::ostringstream message;
95  message << "Illegal input parameters - " << GetName() << G4endl
96  << " All R values must be >= 0 !";
97  G4Exception("G4GenericPolycone::Create()", "GeomSolids0002",
98  FatalErrorInArgument, message);
99  }
100 
101  G4double rzArea = rz->Area();
102  if (rzArea < -kCarTolerance)
103  rz->ReverseOrder();
104 
105  else if (rzArea < -kCarTolerance)
106  {
107  std::ostringstream message;
108  message << "Illegal input parameters - " << GetName() << G4endl
109  << " R/Z cross section is zero or near zero: " << rzArea;
110  G4Exception("G4GenericPolycone::Create()", "GeomSolids0002",
111  FatalErrorInArgument, message);
112  }
113 
115  || (!rz->RemoveRedundantVertices( kCarTolerance )) )
116  {
117  std::ostringstream message;
118  message << "Illegal input parameters - " << GetName() << G4endl
119  << " Too few unique R/Z values !";
120  G4Exception("G4GenericPolycone::Create()", "GeomSolids0002",
121  FatalErrorInArgument, message);
122  }
123 
124  if (rz->CrossesItself(1/kInfinity))
125  {
126  std::ostringstream message;
127  message << "Illegal input parameters - " << GetName() << G4endl
128  << " R/Z segments cross !";
129  G4Exception("G4GenericPolycone::Create()", "GeomSolids0002",
130  FatalErrorInArgument, message);
131  }
132 
133  numCorner = rz->NumVertices();
134 
135  //
136  // Phi opening? Account for some possible roundoff, and interpret
137  // nonsense value as representing no phi opening
138  //
139  if (phiTotal <= 0 || phiTotal > twopi-1E-10)
140  {
141  phiIsOpen = false;
142  startPhi = 0;
143  endPhi = twopi;
144  }
145  else
146  {
147  phiIsOpen = true;
148 
149  //
150  // Convert phi into our convention
151  //
152  startPhi = phiStart;
153  while( startPhi < 0 ) startPhi += twopi;
154 
155  endPhi = phiStart+phiTotal;
156  while( endPhi < startPhi ) endPhi += twopi;
157  }
158 
159  //
160  // Allocate corner array.
161  //
163 
164  //
165  // Copy corners
166  //
167  G4ReduciblePolygonIterator iterRZ(rz);
168 
169  G4PolyconeSideRZ *next = corners;
170  iterRZ.Begin();
171  do
172  {
173  next->r = iterRZ.GetA();
174  next->z = iterRZ.GetB();
175  } while( ++next, iterRZ.Next() );
176 
177  //
178  // Allocate face pointer array
179  //
181  faces = new G4VCSGface*[numFace];
182 
183  //
184  // Construct conical faces
185  //
186  // But! Don't construct a face if both points are at zero radius!
187  //
188  G4PolyconeSideRZ *corner = corners,
189  *prev = corners + numCorner-1,
190  *nextNext;
191  G4VCSGface **face = faces;
192  do
193  {
194  next = corner+1;
195  if (next >= corners+numCorner) next = corners;
196  nextNext = next+1;
197  if (nextNext >= corners+numCorner) nextNext = corners;
198 
199  if (corner->r < 1/kInfinity && next->r < 1/kInfinity) continue;
200 
201  //
202  // We must decide here if we can dare declare one of our faces
203  // as having a "valid" normal (i.e. allBehind = true). This
204  // is never possible if the face faces "inward" in r.
205  //
206  G4bool allBehind;
207  if (corner->z > next->z)
208  {
209  allBehind = false;
210  }
211  else
212  {
213  //
214  // Otherwise, it is only true if the line passing
215  // through the two points of the segment do not
216  // split the r/z cross section
217  //
218  allBehind = !rz->BisectedBy( corner->r, corner->z,
219  next->r, next->z, kCarTolerance );
220  }
221 
222  *face++ = new G4PolyconeSide( prev, corner, next, nextNext,
223  startPhi, endPhi-startPhi, phiIsOpen, allBehind );
224  } while( prev=corner, corner=next, corner > corners );
225 
226  if (phiIsOpen)
227  {
228  //
229  // Construct phi open edges
230  //
231  *face++ = new G4PolyPhiFace( rz, startPhi, 0, endPhi );
232  *face++ = new G4PolyPhiFace( rz, endPhi, 0, startPhi );
233  }
234 
235  //
236  // We might have dropped a face or two: recalculate numFace
237  //
238  numFace = face-faces;
239 
240  //
241  // Make enclosingCylinder
242  //
244  new G4EnclosingCylinder( rz, phiIsOpen, phiStart, phiTotal );
245 }
G4String GetName() const
G4bool CrossesItself(G4double tolerance)
G4PolyconeSideRZ * corners
G4double Amin() const
G4bool RemoveDuplicateVertices(G4double tolerance)
G4EnclosingCylinder * enclosingCylinder
G4bool RemoveRedundantVertices(G4double tolerance)
G4int NumVertices() const
bool G4bool
Definition: G4Types.hh:79
G4VCSGface ** faces
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4bool BisectedBy(G4double a1, G4double b1, G4double a2, G4double b2, G4double tolerance)
#define G4endl
Definition: G4ios.hh:61
G4double kCarTolerance
Definition: G4VSolid.hh:305
double G4double
Definition: G4Types.hh:76
G4Polyhedron * G4GenericPolycone::CreatePolyhedron ( ) const
virtual

Creates user defined polyhedron. This function allows to the user to define arbitrary polyhedron. The faces of the polyhedron should be either triangles or planar quadrilateral. Nodes of a face are defined by indexes pointing to the elements in the xyz array. Numeration of the elements in the array starts from 1 (like in fortran). The indexes can be positive or negative. Negative sign means that the corresponding edge is invisible. The normal of the face should be directed to exterior of the polyhedron.

Parameters
Nnodesnumber of nodes
Nfacesnumber of faces
xyznodes
faces_vecfaces (quadrilaterals or triangles)
Returns
status of the operation - is non-zero in case of problem

Implements G4VCSGfaceted.

Definition at line 467 of file G4GenericPolycone.cc.

References test::a, test::b, test::c, corners, HepPolyhedron::createPolyhedron(), endPhi, G4Exception(), G4VSolid::GetName(), HepPolyhedron::GetNumberOfRotationSteps(), JustWarning, G4VSolid::kCarTolerance, numCorner, phiIsOpen, G4PolyconeSideRZ::r, startPhi, python.hepunit::twopi, and G4PolyconeSideRZ::z.

Referenced by G4ArrowModel::G4ArrowModel().

468 {
469  // The following code prepares for:
470  // HepPolyhedron::createPolyhedron(int Nnodes, int Nfaces,
471  // const double xyz[][3],
472  // const int faces_vec[][4])
473  // Here is an extract from the header file HepPolyhedron.h:
474  /**
475  * Creates user defined polyhedron.
476  * This function allows to the user to define arbitrary polyhedron.
477  * The faces of the polyhedron should be either triangles or planar
478  * quadrilateral. Nodes of a face are defined by indexes pointing to
479  * the elements in the xyz array. Numeration of the elements in the
480  * array starts from 1 (like in fortran). The indexes can be positive
481  * or negative. Negative sign means that the corresponding edge is
482  * invisible. The normal of the face should be directed to exterior
483  * of the polyhedron.
484  *
485  * @param Nnodes number of nodes
486  * @param Nfaces number of faces
487  * @param xyz nodes
488  * @param faces_vec faces (quadrilaterals or triangles)
489  * @return status of the operation - is non-zero in case of problem
490  */
491  const G4int numSide =
493  * (endPhi - startPhi) / twopi) + 1;
494  G4int nNodes;
495  G4int nFaces;
496  typedef G4double double3[3];
497  double3* xyz;
498  typedef G4int int4[4];
499  int4* faces_vec;
500  if (phiIsOpen)
501  {
502  // Triangulate open ends. Simple ear-chopping algorithm...
503  // I'm not sure how robust this algorithm is (J.Allison).
504  //
505  std::vector<G4bool> chopped(numCorner, false);
506  std::vector<G4int*> triQuads;
507  G4int remaining = numCorner;
508  G4int iStarter = 0;
509  while (remaining >= 3)
510  {
511  // Find unchopped corners...
512  //
513  G4int A = -1, B = -1, C = -1;
514  G4int iStepper = iStarter;
515  do
516  {
517  if (A < 0) { A = iStepper; }
518  else if (B < 0) { B = iStepper; }
519  else if (C < 0) { C = iStepper; }
520  do
521  {
522  if (++iStepper >= numCorner) { iStepper = 0; }
523  }
524  while (chopped[iStepper]);
525  }
526  while (C < 0 && iStepper != iStarter);
527 
528  // Check triangle at B is pointing outward (an "ear").
529  // Sign of z cross product determines...
530  //
531  G4double BAr = corners[A].r - corners[B].r;
532  G4double BAz = corners[A].z - corners[B].z;
533  G4double BCr = corners[C].r - corners[B].r;
534  G4double BCz = corners[C].z - corners[B].z;
535  if (BAr * BCz - BAz * BCr < kCarTolerance)
536  {
537  G4int* tq = new G4int[3];
538  tq[0] = A + 1;
539  tq[1] = B + 1;
540  tq[2] = C + 1;
541  triQuads.push_back(tq);
542  chopped[B] = true;
543  --remaining;
544  }
545  else
546  {
547  do
548  {
549  if (++iStarter >= numCorner) { iStarter = 0; }
550  }
551  while (chopped[iStarter]);
552  }
553  }
554  // Transfer to faces...
555  //
556  nNodes = (numSide + 1) * numCorner;
557  nFaces = numSide * numCorner + 2 * triQuads.size();
558  faces_vec = new int4[nFaces];
559  G4int iface = 0;
560  G4int addition = numCorner * numSide;
561  G4int d = numCorner - 1;
562  for (G4int iEnd = 0; iEnd < 2; ++iEnd)
563  {
564  for (size_t i = 0; i < triQuads.size(); ++i)
565  {
566  // Negative for soft/auxiliary/normally invisible edges...
567  //
568  G4int a, b, c;
569  if (iEnd == 0)
570  {
571  a = triQuads[i][0];
572  b = triQuads[i][1];
573  c = triQuads[i][2];
574  }
575  else
576  {
577  a = triQuads[i][0] + addition;
578  b = triQuads[i][2] + addition;
579  c = triQuads[i][1] + addition;
580  }
581  G4int ab = std::abs(b - a);
582  G4int bc = std::abs(c - b);
583  G4int ca = std::abs(a - c);
584  faces_vec[iface][0] = (ab == 1 || ab == d)? a: -a;
585  faces_vec[iface][1] = (bc == 1 || bc == d)? b: -b;
586  faces_vec[iface][2] = (ca == 1 || ca == d)? c: -c;
587  faces_vec[iface][3] = 0;
588  ++iface;
589  }
590  }
591 
592  // Continue with sides...
593 
594  xyz = new double3[nNodes];
595  const G4double dPhi = (endPhi - startPhi) / numSide;
596  G4double phi = startPhi;
597  G4int ixyz = 0;
598  for (G4int iSide = 0; iSide < numSide; ++iSide)
599  {
600  for (G4int iCorner = 0; iCorner < numCorner; ++iCorner)
601  {
602  xyz[ixyz][0] = corners[iCorner].r * std::cos(phi);
603  xyz[ixyz][1] = corners[iCorner].r * std::sin(phi);
604  xyz[ixyz][2] = corners[iCorner].z;
605  if (iSide == 0) // startPhi
606  {
607  if (iCorner < numCorner - 1)
608  {
609  faces_vec[iface][0] = ixyz + 1;
610  faces_vec[iface][1] = -(ixyz + numCorner + 1);
611  faces_vec[iface][2] = ixyz + numCorner + 2;
612  faces_vec[iface][3] = ixyz + 2;
613  }
614  else
615  {
616  faces_vec[iface][0] = ixyz + 1;
617  faces_vec[iface][1] = -(ixyz + numCorner + 1);
618  faces_vec[iface][2] = ixyz + 2;
619  faces_vec[iface][3] = ixyz - numCorner + 2;
620  }
621  }
622  else if (iSide == numSide - 1) // endPhi
623  {
624  if (iCorner < numCorner - 1)
625  {
626  faces_vec[iface][0] = ixyz + 1;
627  faces_vec[iface][1] = ixyz + numCorner + 1;
628  faces_vec[iface][2] = ixyz + numCorner + 2;
629  faces_vec[iface][3] = -(ixyz + 2);
630  }
631  else
632  {
633  faces_vec[iface][0] = ixyz + 1;
634  faces_vec[iface][1] = ixyz + numCorner + 1;
635  faces_vec[iface][2] = ixyz + 2;
636  faces_vec[iface][3] = -(ixyz - numCorner + 2);
637  }
638  }
639  else
640  {
641  if (iCorner < numCorner - 1)
642  {
643  faces_vec[iface][0] = ixyz + 1;
644  faces_vec[iface][1] = -(ixyz + numCorner + 1);
645  faces_vec[iface][2] = ixyz + numCorner + 2;
646  faces_vec[iface][3] = -(ixyz + 2);
647  }
648  else
649  {
650  faces_vec[iface][0] = ixyz + 1;
651  faces_vec[iface][1] = -(ixyz + numCorner + 1);
652  faces_vec[iface][2] = ixyz + 2;
653  faces_vec[iface][3] = -(ixyz - numCorner + 2);
654  }
655  }
656  ++iface;
657  ++ixyz;
658  }
659  phi += dPhi;
660  }
661 
662  // Last corners...
663 
664  for (G4int iCorner = 0; iCorner < numCorner; ++iCorner)
665  {
666  xyz[ixyz][0] = corners[iCorner].r * std::cos(phi);
667  xyz[ixyz][1] = corners[iCorner].r * std::sin(phi);
668  xyz[ixyz][2] = corners[iCorner].z;
669  ++ixyz;
670  }
671  }
672  else // !phiIsOpen - i.e., a complete 360 degrees.
673  {
674  nNodes = numSide * numCorner;
675  nFaces = numSide * numCorner;;
676  xyz = new double3[nNodes];
677  faces_vec = new int4[nFaces];
678  const G4double dPhi = (endPhi - startPhi) / numSide;
679  G4double phi = startPhi;
680  G4int ixyz = 0, iface = 0;
681  for (G4int iSide = 0; iSide < numSide; ++iSide)
682  {
683  for (G4int iCorner = 0; iCorner < numCorner; ++iCorner)
684  {
685  xyz[ixyz][0] = corners[iCorner].r * std::cos(phi);
686  xyz[ixyz][1] = corners[iCorner].r * std::sin(phi);
687  xyz[ixyz][2] = corners[iCorner].z;
688 
689  if (iSide < numSide - 1)
690  {
691  if (iCorner < numCorner - 1)
692  {
693  faces_vec[iface][0] = ixyz + 1;
694  faces_vec[iface][1] = -(ixyz + numCorner + 1);
695  faces_vec[iface][2] = ixyz + numCorner + 2;
696  faces_vec[iface][3] = -(ixyz + 2);
697  }
698  else
699  {
700  faces_vec[iface][0] = ixyz + 1;
701  faces_vec[iface][1] = -(ixyz + numCorner + 1);
702  faces_vec[iface][2] = ixyz + 2;
703  faces_vec[iface][3] = -(ixyz - numCorner + 2);
704  }
705  }
706  else // Last side joins ends...
707  {
708  if (iCorner < numCorner - 1)
709  {
710  faces_vec[iface][0] = ixyz + 1;
711  faces_vec[iface][1] = -(ixyz + numCorner - nFaces + 1);
712  faces_vec[iface][2] = ixyz + numCorner - nFaces + 2;
713  faces_vec[iface][3] = -(ixyz + 2);
714  }
715  else
716  {
717  faces_vec[iface][0] = ixyz + 1;
718  faces_vec[iface][1] = -(ixyz - nFaces + numCorner + 1);
719  faces_vec[iface][2] = ixyz - nFaces + 2;
720  faces_vec[iface][3] = -(ixyz - numCorner + 2);
721  }
722  }
723  ++ixyz;
724  ++iface;
725  }
726  phi += dPhi;
727  }
728  }
729  G4Polyhedron* polyhedron = new G4Polyhedron;
730  G4int problem = polyhedron->createPolyhedron(nNodes, nFaces, xyz, faces_vec);
731  delete [] faces_vec;
732  delete [] xyz;
733  if (problem)
734  {
735  std::ostringstream message;
736  message << "Problem creating G4Polyhedron for: " << GetName();
737  G4Exception("G4GenericPolycone::CreatePolyhedron()", "GeomSolids1002",
738  JustWarning, message);
739  delete polyhedron;
740  return 0;
741  }
742  else
743  {
744  return polyhedron;
745  }
746 }
G4String GetName() const
G4PolyconeSideRZ * corners
G4int createPolyhedron(G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])
int G4int
Definition: G4Types.hh:78
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4int GetNumberOfRotationSteps()
G4double kCarTolerance
Definition: G4VSolid.hh:305
double G4double
Definition: G4Types.hh:76
G4double G4GenericPolycone::DistanceToIn ( const G4ThreeVector p,
const G4ThreeVector v 
) const
virtual

Reimplemented from G4VCSGfaceted.

Definition at line 373 of file G4GenericPolycone.cc.

References G4VCSGfaceted::DistanceToIn(), enclosingCylinder, and G4EnclosingCylinder::ShouldMiss().

375 {
376  //
377  // Quick test
378  //
379  if (enclosingCylinder->ShouldMiss(p,v))
380  return kInfinity;
381 
382  //
383  // Long answer
384  //
385  return G4VCSGfaceted::DistanceToIn( p, v );
386 }
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4EnclosingCylinder * enclosingCylinder
G4bool ShouldMiss(const G4ThreeVector &p, const G4ThreeVector &v) const
G4double G4GenericPolycone::DistanceToIn ( const G4ThreeVector p) const
virtual

Reimplemented from G4VCSGfaceted.

Definition at line 392 of file G4GenericPolycone.cc.

References G4VCSGfaceted::DistanceToIn().

393 {
394  return G4VCSGfaceted::DistanceToIn(p);
395 }
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4PolyconeSideRZ G4GenericPolycone::GetCorner ( G4int  index) const
inline
G4double G4GenericPolycone::GetEndPhi ( ) const
inline
G4GeometryType G4GenericPolycone::GetEntityType ( ) const
virtual

Reimplemented from G4VCSGfaceted.

Definition at line 411 of file G4GenericPolycone.cc.

412 {
413  return G4String("G4GenericPolycone");
414 }
G4int G4GenericPolycone::GetNumRZCorner ( ) const
inline
G4ThreeVector G4GenericPolycone::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 458 of file G4GenericPolycone.cc.

References G4VCSGfaceted::GetPointOnSurfaceGeneric().

459 {
460  return GetPointOnSurfaceGeneric();
461 
462 }
G4ThreeVector GetPointOnSurfaceGeneric() const
G4double G4GenericPolycone::GetStartPhi ( ) const
inline
EInside G4GenericPolycone::Inside ( const G4ThreeVector p) const
virtual

Reimplemented from G4VCSGfaceted.

Definition at line 353 of file G4GenericPolycone.cc.

References enclosingCylinder, G4VCSGfaceted::Inside(), kOutside, and G4EnclosingCylinder::MustBeOutside().

354 {
355  //
356  // Quick test
357  //
358  if (enclosingCylinder->MustBeOutside(p)) return kOutside;
359 
360  //
361  // Long answer
362  //
363  return G4VCSGfaceted::Inside(p);
364 }
G4bool MustBeOutside(const G4ThreeVector &p) const
G4EnclosingCylinder * enclosingCylinder
virtual EInside Inside(const G4ThreeVector &p) const
G4bool G4GenericPolycone::IsOpen ( ) const
inline
const G4GenericPolycone & G4GenericPolycone::operator= ( const G4GenericPolycone source)

Definition at line 282 of file G4GenericPolycone.cc.

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

283 {
284  if (this == &source) return *this;
285 
286  G4VCSGfaceted::operator=( source );
287 
288  delete [] corners;
289  // if (original_parameters) delete original_parameters;
290 
291  delete enclosingCylinder;
292 
293  CopyStuff( source );
294 
295  return *this;
296 }
G4PolyconeSideRZ * corners
G4EnclosingCylinder * enclosingCylinder
void CopyStuff(const G4GenericPolycone &source)
const G4VCSGfaceted & operator=(const G4VCSGfaceted &source)
G4bool G4GenericPolycone::Reset ( )

Definition at line 334 of file G4GenericPolycone.cc.

References G4endl, G4Exception(), G4VSolid::GetName(), and JustWarning.

335 {
336 
337  std::ostringstream message;
338  message << "Solid " << GetName() << " built using generic construct."
339  << G4endl << "Not applicable to the generic construct !";
340  G4Exception("G4GenericPolycone::Reset()", "GeomSolids1001",
341  JustWarning, message, "Parameters NOT resetted.");
342  return 1;
343 
344 }
G4String GetName() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
std::ostream & G4GenericPolycone::StreamInfo ( std::ostream &  os) const
virtual

Reimplemented from G4VCSGfaceted.

Definition at line 428 of file G4GenericPolycone.cc.

References corners, python.hepunit::degree, endPhi, G4VSolid::GetName(), numCorner, G4PolyconeSideRZ::r, startPhi, and G4PolyconeSideRZ::z.

429 {
430  G4int oldprc = os.precision(16);
431  os << "-----------------------------------------------------------\n"
432  << " *** Dump for solid - " << GetName() << " ***\n"
433  << " ===================================================\n"
434  << " Solid type: G4GenericPolycone\n"
435  << " Parameters: \n"
436  << " starting phi angle : " << startPhi/degree << " degrees \n"
437  << " ending phi angle : " << endPhi/degree << " degrees \n";
438  G4int i=0;
439 
440  os << " number of RZ points: " << numCorner << "\n"
441  << " RZ values (corners): \n";
442  for (i=0; i<numCorner; i++)
443  {
444  os << " "
445  << corners[i].r << ", " << corners[i].z << "\n";
446  }
447  os << "-----------------------------------------------------------\n";
448  os.precision(oldprc);
449 
450  return os;
451 }
G4String GetName() const
G4PolyconeSideRZ * corners
int G4int
Definition: G4Types.hh:78
tuple degree
Definition: hepunit.py:69

Field Documentation

G4PolyconeSideRZ* G4GenericPolycone::corners
protected
G4EnclosingCylinder* G4GenericPolycone::enclosingCylinder
protected
G4double G4GenericPolycone::endPhi
protected

Definition at line 140 of file G4GenericPolycone.hh.

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

G4int G4GenericPolycone::numCorner
protected

Definition at line 142 of file G4GenericPolycone.hh.

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

G4bool G4GenericPolycone::phiIsOpen
protected

Definition at line 141 of file G4GenericPolycone.hh.

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

G4double G4GenericPolycone::startPhi
protected

Definition at line 139 of file G4GenericPolycone.hh.

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


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