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] [ 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 ]

Diff markup

Differences between /geometry/management/include/G4BoundingEnvelope.hh (Version 11.3.0) and /geometry/management/include/G4BoundingEnvelope.hh (Version 10.4.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
                                                   >>  26 //
                                                   >>  27 // $Id:$
                                                   >>  28 //
                                                   >>  29 //
 26 // class G4BoundingEnvelope                        30 // class G4BoundingEnvelope
 27 //                                                 31 //
 28 // Class description:                              32 // Class description:
 29 //                                                 33 //
 30 // Helper class to facilitate calculation of t     34 // Helper class to facilitate calculation of the extent of a solid
 31 // within the limits defined by a G4VoxelLimit     35 // within the limits defined by a G4VoxelLimits object.
 32 //                                                 36 //
 33 // The function CalculateExtent() of a particu     37 // The function CalculateExtent() of a particular solid can create
 34 // a G4BoundingEnvelope object that bounds the     38 // a G4BoundingEnvelope object that bounds the solid and then call
 35 // CalculateExtent() of the G4BoundingEnvelope     39 // CalculateExtent() of the G4BoundingEnvelope object.
 36 //                                                 40 //
 37 // Calculation of extent uses G4Transform3D, t     41 // Calculation of extent uses G4Transform3D, thus takes into account
 38 // scaling and reflection, if any.                 42 // scaling and reflection, if any.
 39                                                    43 
 40 // 2016.05.25,  E.Tcherniaev - initial version <<  44 // History:
                                                   >>  45 //
                                                   >>  46 // 2016.05.25 E.Tcherniaev - initial version
                                                   >>  47 //
 41 // -------------------------------------------     48 // --------------------------------------------------------------------
 42 #ifndef G4BOUNDINGENVELOPE_HH                      49 #ifndef G4BOUNDINGENVELOPE_HH
 43 #define G4BOUNDINGENVELOPE_HH                      50 #define G4BOUNDINGENVELOPE_HH
 44                                                    51 
 45 #include <vector>                                  52 #include <vector>
 46 #include "geomdefs.hh"                             53 #include "geomdefs.hh"
 47                                                    54 
 48 #include "G4ThreeVector.hh"                        55 #include "G4ThreeVector.hh"
 49 #include "G4VoxelLimits.hh"                        56 #include "G4VoxelLimits.hh"
 50 #include "G4Transform3D.hh"                        57 #include "G4Transform3D.hh"
 51 #include "G4Point3D.hh"                            58 #include "G4Point3D.hh"
 52 #include "G4Plane3D.hh"                            59 #include "G4Plane3D.hh"
 53                                                    60 
 54 using G4ThreeVectorList = std::vector<G4ThreeV <<  61 typedef std::vector<G4ThreeVector>     G4ThreeVectorList;
 55 using G4Polygon3D = std::vector<G4Point3D>;    <<  62 typedef std::vector<G4Point3D>         G4Polygon3D;
 56 using G4Segment3D = std::pair<G4Point3D,G4Poin <<  63 typedef std::pair<G4Point3D,G4Point3D> G4Segment3D;
 57                                                    64 
 58 class G4BoundingEnvelope                           65 class G4BoundingEnvelope
 59 {                                                  66 {
 60   public:                                          67   public:
 61                                                    68 
 62     G4BoundingEnvelope(const G4ThreeVector& pM     69     G4BoundingEnvelope(const G4ThreeVector& pMin,
 63                        const G4ThreeVector& pM     70                        const G4ThreeVector& pMax);
 64       // Constructor from an axis aligned boun     71       // Constructor from an axis aligned bounding box (AABB)
 65                                                    72 
 66     G4BoundingEnvelope(const std::vector<const     73     G4BoundingEnvelope(const std::vector<const G4ThreeVectorList*>& polygons);
 67       // Constructor from a sequence of convex     74       // Constructor from a sequence of convex polygons, the polygons
 68       // should have equal numbers of vertices     75       // should have equal numbers of vertices except first and last
 69       // polygons which may consist of a singl     76       // polygons which may consist of a single vertex
 70                                                    77 
 71     G4BoundingEnvelope(const G4ThreeVector& pM <<  78     G4BoundingEnvelope(const G4ThreeVector& pMin, 
 72                        const G4ThreeVector& pM     79                        const G4ThreeVector& pMax,
 73                        const std::vector<const     80                        const std::vector<const G4ThreeVectorList*>& polygons);
 74       // Constructor from AABB and a sequence      81       // Constructor from AABB and a sequence of polygons
 75                                                    82 
 76     ~G4BoundingEnvelope() = default;           <<  83     ~G4BoundingEnvelope();
 77       // Destructor                                84       // Destructor
 78                                                    85 
 79     G4bool BoundingBoxVsVoxelLimits(const EAxi     86     G4bool BoundingBoxVsVoxelLimits(const EAxis pAxis,
 80                                     const G4Vo     87                                     const G4VoxelLimits& pVoxelLimits,
 81                                     const G4Tr     88                                     const G4Transform3D& pTransform3D,
 82                                     G4double&      89                                     G4double& pMin, G4double& pMax) const;
 83       // Analyse the position of the bounding      90       // Analyse the position of the bounding box relative to the voxel.
 84       // It returns "true" in the case where t     91       // It returns "true" in the case where the value of the extent can be
 85       // figured out directly from the dimensi     92       // figured out directly from the dimensions of the bounding box, or
 86       // it is clear that the bounding box and     93       // it is clear that the bounding box and the voxel do not intersect.
 87       // The reply "false" means that further      94       // The reply "false" means that further calculations are needed.
 88                                                    95 
 89     G4bool CalculateExtent(const EAxis pAxis,      96     G4bool CalculateExtent(const EAxis pAxis,
 90                            const G4VoxelLimits     97                            const G4VoxelLimits& pVoxelLimits,
 91                            const G4Transform3D     98                            const G4Transform3D& pTransform3D,
 92                            G4double& pMin, G4d     99                            G4double& pMin, G4double& pMax) const;
 93       // Calculate extent of the bounding enve    100       // Calculate extent of the bounding envelope
 94                                                   101 
 95   private:                                        102   private:
 96                                                   103 
 97     void CheckBoundingBox();                      104     void CheckBoundingBox();
 98       // Check correctness of the AABB (axis a    105       // Check correctness of the AABB (axis aligned bounding box)
 99                                                   106 
100     void CheckBoundingPolygons();                 107     void CheckBoundingPolygons();
101       // Check correctness of the sequence of     108       // Check correctness of the sequence of convex polygonal bases
102                                                   109 
103     G4double FindScaleFactor(const G4Transform    110     G4double FindScaleFactor(const G4Transform3D& pTransform3D) const;
104       // Find max scale factor of the transfor    111       // Find max scale factor of the transformation
105                                                   112 
106     void TransformVertices(const G4Transform3D    113     void TransformVertices(const G4Transform3D& pTransform3D,
107                                  std::vector<G << 114                                  std::vector<G4Polygon3D*>& pBases) const;
108                                  std::vector<s << 
109       // Create list of transformed polygons      115       // Create list of transformed polygons
110                                                   116 
111     void GetPrismAABB(const G4Polygon3D& pBase    117     void GetPrismAABB(const G4Polygon3D& pBaseA,
112                       const G4Polygon3D& pBase    118                       const G4Polygon3D& pBaseB,
113                             G4Segment3D& pAABB    119                             G4Segment3D& pAABB) const;
114       // Find bounding box of a prism             120       // Find bounding box of a prism
115                                                   121 
116     void CreateListOfEdges(const G4Polygon3D&     122     void CreateListOfEdges(const G4Polygon3D& baseA,
117                            const G4Polygon3D&     123                            const G4Polygon3D& baseB,
118                                  std::vector<G    124                                  std::vector<G4Segment3D>& pEdges) const;
119       // Create list of edges of a prism          125       // Create list of edges of a prism
120                                                << 126   
121     void CreateListOfPlanes(const G4Polygon3D&    127     void CreateListOfPlanes(const G4Polygon3D& baseA,
122                             const G4Polygon3D&    128                             const G4Polygon3D& baseB,
123                                   std::vector<    129                                   std::vector<G4Plane3D>& pPlanes) const;
124       // Create list of planes bounding a pris    130       // Create list of planes bounding a prism
125                                                   131 
126     G4bool ClipEdgesByVoxel(const std::vector<    132     G4bool ClipEdgesByVoxel(const std::vector<G4Segment3D>& pEdges,
127                             const G4VoxelLimit    133                             const G4VoxelLimits& pLimits,
128                                   G4Segment3D&    134                                   G4Segment3D& pExtent) const;
129       // Clip set of edges by G4VoxelLimits       135       // Clip set of edges by G4VoxelLimits
130                                                   136 
131     void ClipVoxelByPlanes(G4int pBits,           137     void ClipVoxelByPlanes(G4int pBits,
132                            const G4VoxelLimits    138                            const G4VoxelLimits& pLimits,
133                            const std::vector<G    139                            const std::vector<G4Plane3D>& pPlanes,
134                            const G4Segment3D&     140                            const G4Segment3D& pAABB,
135                                  G4Segment3D&     141                                  G4Segment3D& pExtent) const;
136       // Clip G4VoxelLimits by set of planes b    142       // Clip G4VoxelLimits by set of planes bounding a prism
137                                                   143 
138   private:                                        144   private:
139                                                   145 
140     G4ThreeVector fMin, fMax;                  << 146     G4ThreeVector fMin, fMax; 
141       // original bounding box                    147       // original bounding box
142                                                   148 
143     const std::vector<const G4ThreeVectorList* << 149     const std::vector<const G4ThreeVectorList*>* fPolygons;
144       // ref to original sequence of polygonal    150       // ref to original sequence of polygonal bases
145 };                                                151 };
146                                                   152 
147 #endif // G4BOUNDINGENVELOPE_HH                   153 #endif // G4BOUNDINGENVELOPE_HH
148                                                   154