Geant4_10
G4PolyPhiFace.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: G4PolyPhiFace.hh 66356 2012-12-18 09:02:32Z gcosmo $
28 //
29 //
30 // --------------------------------------------------------------------
31 // GEANT 4 class header file
32 //
33 //
34 // G4PolyPhiFace
35 //
36 // Class description:
37 //
38 // Definition of a face that bounds a polycone or polyhedra when
39 // it has a phi opening:
40 //
41 // G4PolyPhiFace( const G4ReduciblePolygon *rz,
42 // G4double phi,
43 // G4double deltaPhi,
44 // G4double phiOther )
45 //
46 // Specifically: a face that lies on a plane that passes through
47 // the z axis. It has boundaries that are straight lines of arbitrary
48 // length and direction, but with corners aways on the same side of
49 // the z axis.
50 
51 // Author:
52 // David C. Williams (davidw@scipp.ucsc.edu)
53 // --------------------------------------------------------------------
54 
55 #ifndef G4PolyPhiFace_hh
56 #define G4PolyPhiFace_hh
57 
58 #include "G4VCSGface.hh"
59 #include "G4TwoVector.hh"
60 
61 class G4ReduciblePolygon;
62 
64 {
65  G4double x, y, r, z; // position
67  zNorm; // r/z normal
68  G4ThreeVector norm3D; // 3D normal
69 
70  // Needed for Triangulation Algorithm
71  //
74 };
75 
77 {
78  G4PolyPhiFaceEdge(): v0(0), v1(0), tr(.0), tz(0.), length(0.) {}
79  G4PolyPhiFaceVertex *v0, *v1; // Corners
80  G4double tr, tz, // Unit vector along edge
81  length; // Length of edge
82  G4ThreeVector norm3D; // 3D edge normal vector
83 };
84 
85 class G4PolyPhiFace : public G4VCSGface
86 {
87 
88  public: // with description
89 
91  G4double phi, G4double deltaPhi, G4double phiOther );
92  // Constructor.
93  // Points r,z should be supplied in clockwise order in r,z.
94  // For example:
95  // [1]---------[2] ^ R
96  // | | |
97  // | | +--> z
98  // [0]---------[3]
99 
100  virtual ~G4PolyPhiFace();
101  // Destructor. Removes edges and corners.
102 
103  G4PolyPhiFace( const G4PolyPhiFace &source );
104  G4PolyPhiFace& operator=( const G4PolyPhiFace &source );
105  // Copy constructor and assgnment operator.
106 
107  G4bool Intersect( const G4ThreeVector &p, const G4ThreeVector &v,
108  G4bool outgoing, G4double surfTolerance,
109  G4double &distance, G4double &distFromSurface,
111 
112  G4double Distance( const G4ThreeVector &p, G4bool outgoing );
113 
114  EInside Inside( const G4ThreeVector &p, G4double tolerance,
115  G4double *bestDistance );
116 
117  G4ThreeVector Normal( const G4ThreeVector &p, G4double *bestDistance );
118 
119  G4double Extent( const G4ThreeVector axis );
120 
121  void CalculateExtent( const EAxis axis,
122  const G4VoxelLimits &voxelLimit,
123  const G4AffineTransform &tranform,
124  G4SolidExtentList &extentList );
125 
126  inline G4VCSGface *Clone();
127  // Allocates on the heap a clone of this face.
128 
131  G4ThreeVector p3, G4ThreeVector* p4);
133  // Auxiliary methods for determination of points on surface.
134 
135  public: // without description
136 
137  G4PolyPhiFace(__void__&);
138  // Fake default constructor for usage restricted to direct object
139  // persistency for clients requiring preallocation of memory for
140  // persistifiable objects.
141 
142  void Diagnose( G4VSolid *solid );
143  // Throw an exception if something is found inconsistent with
144  // the solid. For debugging purposes only
145 
146  protected:
147 
149  const G4ThreeVector &p, const G4ThreeVector &v );
150  // Decide if the point in r,z is inside the edges of our face,
151  // **but** do so consistently with other faces.
152 
154  G4bool InsideEdges( G4double r, G4double z, G4double *distRZ2,
155  G4PolyPhiFaceVertex **base3Dnorm=0,
156  G4ThreeVector **head3Dnorm=0 );
157  // Decide if the point in r,z is inside the edges of our face.
158 
159  inline G4double ExactZOrder( G4double z,
160  G4double qx, G4double qy, G4double qz,
161  const G4ThreeVector &v,
162  G4double normSign,
163  const G4PolyPhiFaceVertex *vert ) const;
164  // Decide precisely whether a trajectory passes to the left, right,
165  // or exactly passes through the z position of a vertex point in face.
166 
167  void CopyStuff( const G4PolyPhiFace &source );
168 
169  protected:
170 
171  // Functions used for Triangulation in Case of generic Polygone.
172  // The triangulation is used for GetPointOnFace()
173 
175  // Calculation of 2*Area of Triangle with Sign
176 
180  // Boolean functions for sign of Surface
181 
184  // Boolean function for finding proper intersection of two
185  // line segments (a,b) and (c,d).
186 
188  // Boolean function for determining if point c is between a and b
189  // where the three points (a,b,c) are on the same line.
190 
192  G4TwoVector c, G4TwoVector d );
193  // Boolean function for finding proper intersection or not
194  // of two line segments (a,b) and (c,d).
195 
197  // Boolean Diagonalie help to determine if diagonal s
198  // of segment (a,b) is convex or reflex.
199 
201  // Boolean function for determining if b is inside the cone (a0,a,a1)
202  // where a is the center of the cone.
203 
205  // Boolean function for determining if Diagonal is possible
206  // inside Polycone or PolyHedra.
207 
208  void EarInit();
209  // Initialisation for Triangulisation by ear tips.
210  // For details see "Computational Geometry in C" by Joseph O'Rourke.
211 
212  void Triangulate();
213  // Triangularisation by ear tips for Polycone or Polyhedra.
214  // For details see "Computational Geometry in C" by Joseph O'Rourke.
215  // NOTE: a copy of the shape is made and this copy is reordered in
216  // order to have a list of triangles. This list is used by the
217  // method GetPointOnFace().
218 
219  protected:
220 
221  G4int numEdges; // Number of edges
222  G4PolyPhiFaceEdge *edges; // The edges of the face
223  G4PolyPhiFaceVertex *corners; // And the corners
224  G4ThreeVector normal; // Normal unit vector
225  G4ThreeVector radial; // Unit vector along radial direction
226  G4ThreeVector surface; // Point on surface
227  G4ThreeVector surface_point; // Auxiliary point on surface used for
228  // method GetPointOnFace()
229  G4double rMin, rMax, // Extent in r
230  zMin, zMax; // Extent in z
231  G4bool allBehind; // True if the polycone/polyhedra
232  // is behind the place of this face
233  G4double kCarTolerance;// Surface thickness
234  G4double fSurfaceArea; // Surface Area of PolyPhiFace
235  G4PolyPhiFaceVertex *triangles; // Auxiliary pointer to 'corners' used for
236  // triangulation. Copy structure, changing
237  // the structure of 'corners' (ear removal)
238 };
239 
240 #include "G4PolyPhiFace.icc"
241 
242 #endif
G4double ExactZOrder(G4double z, G4double qx, G4double qy, G4double qz, const G4ThreeVector &v, G4double normSign, const G4PolyPhiFaceVertex *vert) const
G4bool InsideEdgesExact(G4double r, G4double z, G4double normSign, const G4ThreeVector &p, const G4ThreeVector &v)
tuple a
Definition: test.py:11
G4ThreeVector surface_point
Float_t d
Definition: plot.C:237
G4PolyPhiFaceVertex * v1
const char * p
Definition: xmltok.h:285
G4PolyPhiFaceVertex * v0
G4ThreeVector norm3D
G4double SurfaceArea()
G4bool Between(G4TwoVector a, G4TwoVector b, G4TwoVector c)
G4double kCarTolerance
void Diagnose(G4VSolid *solid)
G4bool InsideEdges(G4double r, G4double z)
G4bool LeftOn(G4TwoVector a, G4TwoVector b, G4TwoVector c)
int G4int
Definition: G4Types.hh:78
G4bool Intersect(const G4ThreeVector &p, const G4ThreeVector &v, G4bool outgoing, G4double surfTolerance, G4double &distance, G4double &distFromSurface, G4ThreeVector &normal, G4bool &allBehind)
tuple b
Definition: test.py:12
G4double SurfaceTriangle(G4ThreeVector p1, G4ThreeVector p2, G4ThreeVector p3, G4ThreeVector *p4)
EInside Inside(const G4ThreeVector &p, G4double tolerance, G4double *bestDistance)
bool G4bool
Definition: G4Types.hh:79
G4PolyPhiFaceVertex * next
G4PolyPhiFaceVertex * prev
virtual ~G4PolyPhiFace()
void CalculateExtent(const EAxis axis, const G4VoxelLimits &voxelLimit, const G4AffineTransform &tranform, G4SolidExtentList &extentList)
G4double Distance(const G4ThreeVector &p, G4bool outgoing)
G4PolyPhiFaceVertex * corners
G4double fSurfaceArea
tuple v
Definition: test.py:18
G4bool Collinear(G4TwoVector a, G4TwoVector b, G4TwoVector c)
G4bool Diagonalie(G4PolyPhiFaceVertex *a, G4PolyPhiFaceVertex *b)
G4PolyPhiFace & operator=(const G4PolyPhiFace &source)
G4ThreeVector Normal(const G4ThreeVector &p, G4double *bestDistance)
G4ThreeVector GetPointOnFace()
G4double Extent(const G4ThreeVector axis)
jump r
Definition: plot.C:36
G4bool InCone(G4PolyPhiFaceVertex *a, G4PolyPhiFaceVertex *b)
G4PolyPhiFaceVertex * triangles
G4VCSGface * Clone()
G4bool IntersectProp(G4TwoVector a, G4TwoVector b, G4TwoVector c, G4TwoVector d)
EInside
Definition: geomdefs.hh:58
G4double Area2(G4TwoVector a, G4TwoVector b, G4TwoVector c)
EAxis
Definition: geomdefs.hh:54
G4bool Diagonal(G4PolyPhiFaceVertex *a, G4PolyPhiFaceVertex *b)
G4PolyPhiFace(const G4ReduciblePolygon *rz, G4double phi, G4double deltaPhi, G4double phiOther)
tuple z
Definition: test.py:28
double G4double
Definition: G4Types.hh:76
tuple c
Definition: test.py:13
G4ThreeVector norm3D
G4ThreeVector normal
G4ThreeVector surface
void CopyStuff(const G4PolyPhiFace &source)
G4ThreeVector radial
G4bool Left(G4TwoVector a, G4TwoVector b, G4TwoVector c)
G4PolyPhiFaceEdge * edges