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.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

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