Geant4  10.03
G4PolyhedraSide.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4PolyhedraSide.hh 99392 2016-09-20 13:33:55Z gcosmo $
28 //
29 //
30 // --------------------------------------------------------------------
31 // GEANT 4 class header file
32 //
33 //
34 // G4PolyhedraSide
35 //
36 // Class description:
37 //
38 // Class implementing a face that represents one segmented side
39 // of a polyhedra:
40 //
41 // G4PolyhedraSide( const G4PolyhedraSideRZ *prevRZ,
42 // const G4PolyhedraSideRZ *tail,
43 // const G4PolyhedraSideRZ *head,
44 // const G4PolyhedraSideRZ *nextRZ,
45 // G4int numSide,
46 // G4double phiStart, G4double phiTotal,
47 // G4bool phiIsOpen, G4bool isAllBehind=false )
48 //
49 // Values for r1,z1 and r2,z2 should be specified in clockwise
50 // order in (r,z).
51 
52 // Author:
53 // David C. Williams (davidw@scipp.ucsc.edu)
54 // --------------------------------------------------------------------
55 
56 #ifndef G4PolyhedraSide_hh
57 #define G4PolyhedraSide_hh
58 
59 #include "G4VCSGface.hh"
60 
61 class G4IntersectingCone;
62 
64 {
65  G4double r, z; // start of vector
66 };
67 
68 // ----------------------------------------------------------------------------
69 // MT-specific utility code
70 
71 #include "G4GeomSplitter.hh"
72 
73 // The class G4PhSideData is introduced to encapsulate the
74 // fields of the class G4PolyhedraSide that may not be read-only.
75 //
77 {
78  public:
79  void initialize()
80  {
81  fPhi.first = G4ThreeVector(0,0,0);
82  fPhi.second= 0.0;
83  }
84 
85  std::pair<G4ThreeVector, G4double> fPhi; // Cached value for phi
86 
87 };
88 
89 // The type G4PhSideManager is introduced to encapsulate the methods used
90 // by both the master thread and worker threads to allocate memory space
91 // for the fields encapsulated by the class G4PhSideData.
92 //
94 
95 //
96 // ----------------------------------------------------------------------------
97 
99 {
100 
101  public: // with description
102 
103  G4PolyhedraSide( const G4PolyhedraSideRZ *prevRZ,
104  const G4PolyhedraSideRZ *tail,
105  const G4PolyhedraSideRZ *head,
106  const G4PolyhedraSideRZ *nextRZ,
107  G4int numSide,
108  G4double phiStart, G4double phiTotal,
109  G4bool phiIsOpen, G4bool isAllBehind=false );
110  virtual ~G4PolyhedraSide();
111 
112  G4PolyhedraSide( const G4PolyhedraSide &source );
113  G4PolyhedraSide& operator=( const G4PolyhedraSide &source );
114 
115  G4bool Intersect( const G4ThreeVector &p, const G4ThreeVector &v,
116  G4bool outgoing, G4double surfTolerance,
117  G4double &distance, G4double &distFromSurface,
119 
120  G4double Distance( const G4ThreeVector &p, G4bool outgoing );
121 
122  EInside Inside( const G4ThreeVector &p, G4double tolerance,
123  G4double *bestDistance );
124 
125  G4ThreeVector Normal( const G4ThreeVector &p, G4double *bestDistance );
126 
127  G4double Extent( const G4ThreeVector axis );
128 
129  void CalculateExtent( const EAxis axis,
130  const G4VoxelLimits &voxelLimit,
131  const G4AffineTransform &tranform,
132  G4SolidExtentList &extentList );
133 
134  G4VCSGface *Clone() { return new G4PolyhedraSide( *this ); }
135 
136  public: // without description
137 
138  // Methods used for GetPointOnSurface()
139 
141  G4ThreeVector p2,
142  G4ThreeVector p3,
143  G4ThreeVector *p4 );
146  G4double *Area );
149 
150  public: // without description
151 
152  G4PolyhedraSide(__void__&);
153  // Fake default constructor for usage restricted to direct object
154  // persistency for clients requiring preallocation of memory for
155  // persistifiable objects.
156 
157  inline G4int GetInstanceID() const { return instanceID; }
158  // Returns the instance ID.
159 
160  static const G4PhSideManager& GetSubInstanceManager();
161  // Returns the private data instance manager.
162 
163  //
164  // A couple internal data structures
165  //
166  struct sG4PolyhedraSideVec; // Secret recipe for allowing
167  friend struct sG4PolyhedraSideVec; // protected nested structures
168 
169  typedef struct sG4PolyhedraSideEdge
170  {
171  G4ThreeVector normal; // Unit normal to this edge
172  G4ThreeVector corner[2]; // The two corners of this phi edge
173  G4ThreeVector cornNorm[2]; // The normals of these corners
175 
176  typedef struct sG4PolyhedraSideVec
177  {
178  G4ThreeVector normal, // Normal (point out of the shape)
179  center, // Point in center of side
180  surfPhi, // Unit vector on surface pointing along phi
181  surfRZ; // Unit vector on surface pointing along R/Z
182  G4PolyhedraSideEdge *edges[2]; // The phi boundary edges to this side
183  // [0]=low phi [1]=high phi
184  G4ThreeVector edgeNorm[2]; // RZ edge normals [i] at {r[i],z[i]}
186 
187  protected:
188 
190  const G4PolyhedraSideVec& vec,
191  G4double normSign,
192  G4double surfTolerance,
193  G4double &distance,
194  G4double &distFromSurface );
195 
197  const G4ThreeVector &v,
198  G4int *i1, G4int *i2 );
199 
201 
202  G4int PhiSegment( G4double phi );
203 
204  G4double GetPhi( const G4ThreeVector& p );
205 
207  const G4PolyhedraSideVec &vec,
208  G4double *normDist );
209 
211  const G4PolyhedraSideVec &vec,
212  G4double *normDist );
213 
214  void CopyStuff( const G4PolyhedraSide &source );
215 
216  protected:
217 
218  G4int numSide; // Number sides
219  G4double r[2], z[2]; // r, z parameters, in specified order
220  G4double startPhi, // Start phi (0 to 2pi), if phiIsOpen
221  deltaPhi, // Delta phi (0 to 2pi), if phiIsOpen
222  endPhi; // End phi (>startPhi), if phiIsOpen
223  G4bool phiIsOpen; // True if there is a phi slice
224  G4bool allBehind; // True if the entire solid is "behind" this face
225 
226  G4IntersectingCone *cone; // Our intersecting cone
227 
228  G4PolyhedraSideVec *vecs; // Vector set for each facet of our face
229  G4PolyhedraSideEdge *edges; // The edges belong to vecs
230  G4double lenRZ, // RZ length of each side
231  lenPhi[2]; // Phi dimensions of each side
232  G4double edgeNorm; // Normal in RZ/Phi space to each side
233 
234  private:
235 
236  G4double kCarTolerance; // Geometrical surface thickness
237  G4double fSurfaceArea; // Surface Area
238 
240  // This field is used as instance ID.
242  // This field helps to use the class G4PhSideManager introduced above.
243 };
244 
245 #endif
G4ThreeVector GetPointOnPlane(G4ThreeVector p0, G4ThreeVector p1, G4ThreeVector p2, G4ThreeVector p3, G4double *Area)
G4double GetPhi(const G4ThreeVector &p)
G4double lenPhi[2]
G4double Extent(const G4ThreeVector axis)
G4PolyhedraSide(const G4PolyhedraSideRZ *prevRZ, const G4PolyhedraSideRZ *tail, const G4PolyhedraSideRZ *head, const G4PolyhedraSideRZ *nextRZ, G4int numSide, G4double phiStart, G4double phiTotal, G4bool phiIsOpen, G4bool isAllBehind=false)
CLHEP::Hep3Vector G4ThreeVector
EInside Inside(const G4ThreeVector &p, G4double tolerance, G4double *bestDistance)
virtual ~G4PolyhedraSide()
G4int ClosestPhiSegment(G4double phi)
std::pair< G4ThreeVector, G4double > fPhi
G4double DistanceToOneSide(const G4ThreeVector &p, const G4PolyhedraSideVec &vec, G4double *normDist)
G4VCSGface * Clone()
static const G4PhSideManager & GetSubInstanceManager()
G4ThreeVector Normal(const G4ThreeVector &p, G4double *bestDistance)
G4int LineHitsSegments(const G4ThreeVector &p, const G4ThreeVector &v, G4int *i1, G4int *i2)
struct G4PolyhedraSide::sG4PolyhedraSideEdge G4PolyhedraSideEdge
G4PolyhedraSideVec * vecs
int G4int
Definition: G4Types.hh:78
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:77
G4double DistanceAway(const G4ThreeVector &p, const G4PolyhedraSideVec &vec, G4double *normDist)
G4double Distance(const G4ThreeVector &p, G4bool outgoing)
G4double SurfaceTriangle(G4ThreeVector p1, G4ThreeVector p2, G4ThreeVector p3, G4ThreeVector *p4)
G4bool IntersectSidePlane(const G4ThreeVector &p, const G4ThreeVector &v, const G4PolyhedraSideVec &vec, G4double normSign, G4double surfTolerance, G4double &distance, G4double &distFromSurface)
struct G4PolyhedraSide::sG4PolyhedraSideVec G4PolyhedraSideVec
bool G4bool
Definition: G4Types.hh:79
G4GeomSplitter< G4PhSideData > G4PhSideManager
G4int PhiSegment(G4double phi)
static G4GEOM_DLL G4PhSideManager subInstanceManager
G4bool Intersect(const G4ThreeVector &p, const G4ThreeVector &v, G4bool outgoing, G4double surfTolerance, G4double &distance, G4double &distFromSurface, G4ThreeVector &normal, G4bool &allBehind)
G4ThreeVector GetPointOnFace()
EInside
Definition: geomdefs.hh:58
EAxis
Definition: geomdefs.hh:54
G4double SurfaceArea()
void CopyStuff(const G4PolyhedraSide &source)
G4IntersectingCone * cone
G4PolyhedraSideEdge * edges
G4int GetInstanceID() const
double G4double
Definition: G4Types.hh:76
void CalculateExtent(const EAxis axis, const G4VoxelLimits &voxelLimit, const G4AffineTransform &tranform, G4SolidExtentList &extentList)
G4PolyhedraSide & operator=(const G4PolyhedraSide &source)
#define G4GEOM_DLL
Definition: geomwdefs.hh:48