Geant4  10.02
G4GenericTrap.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: G4GenericTrap.hh 83851 2014-09-19 10:12:12Z gcosmo $
28 //
29 //
30 // --------------------------------------------------------------------
31 // GEANT 4 class header file
32 //
33 //
34 // G4GenericTrap
35 //
36 // Class description:
37 //
38 // G4GenericTrap is a solid which represents an arbitrary trapezoid with
39 // up to 8 vertices standing on two parallel planes perpendicular to Z axis.
40 //
41 // Parameters in the constructor:
42 // - name - solid name
43 // - halfZ - the solid half length in Z
44 // - vertices - the (x,y) coordinates of vertices:
45 // o first four points: vertices[i], i<4
46 // are the vertices sitting on the -halfZ plane;
47 // o last four points: vertices[i], i>=4
48 // are the vertices sitting on the +halfZ plane.
49 //
50 // The order of defining the vertices of the solid is the following:
51 // - point 0 is connected with points 1,3,4
52 // - point 1 is connected with points 0,2,5
53 // - point 2 is connected with points 1,3,6
54 // - point 3 is connected with points 0,2,7
55 // - point 4 is connected with points 0,5,7
56 // - point 5 is connected with points 1,4,6
57 // - point 6 is connected with points 2,5,7
58 // - point 7 is connected with points 3,4,6
59 // Points can be identical in order to create shapes with less than
60 // 8 vertices.
61 
62 // Authors:
63 // Tatiana Nikitina, CERN; Ivana Hrivnacova, IPN Orsay
64 // Adapted from Root Arb8 implementation, author Andrea Gheata, CERN
65 // -------------------------------------------------------------------
66 
67 #ifndef G4GenericTrap_HH
68 #define G4GenericTrap_HH
69 
70 #if defined(G4GEOM_USE_USOLIDS)
71 #define G4GEOM_USE_UGENERICTRAP 1
72 #endif
73 
74 #if defined(G4GEOM_USE_UGENERICTRAP)
75  #define G4UGenericTrap G4GenericTrap
76  #include "G4UGenericTrap.hh"
77 #else
78 
79 #include <vector>
80 
81 #include "G4TwoVector.hh"
82 #include "G4VSolid.hh"
83 #include "globals.hh"
84 
85 class G4VFacet;
86 class G4TessellatedSolid;
87 
88 class G4GenericTrap : public G4VSolid
89 {
90  public: // with description
91 
92  G4GenericTrap( const G4String& name, G4double halfZ,
93  const std::vector<G4TwoVector>& vertices );
94  // Constructor
95 
97  // Destructor
98 
99  // Accessors
100 
101  inline G4double GetZHalfLength() const;
102  inline G4int GetNofVertices() const;
103  inline G4TwoVector GetVertex(G4int index) const;
104  inline const std::vector<G4TwoVector>& GetVertices() const;
105  inline G4double GetTwistAngle(G4int index) const;
106  inline G4bool IsTwisted() const;
107  inline G4int GetVisSubdivisions() const;
108  inline void SetVisSubdivisions(G4int subdiv);
109 
110  // Solid methods
111 
112  EInside Inside(const G4ThreeVector& p) const;
113  G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const;
115  const G4ThreeVector& v) const;
116  G4double DistanceToIn(const G4ThreeVector& p) const;
118  const G4ThreeVector& v,
119  const G4bool calcNorm = false,
120  G4bool *validNorm = 0,
121  G4ThreeVector *n = 0) const;
122  G4double DistanceToOut(const G4ThreeVector& p) const;
123  G4bool CalculateExtent(const EAxis pAxis,
124  const G4VoxelLimits& pVoxelLimit,
125  const G4AffineTransform& pTransform,
126  G4double& pmin, G4double& pmax) const;
127 
129 
130  G4VSolid* Clone() const;
131 
132  std::ostream& StreamInfo(std::ostream& os) const;
133 
135 
138 
139  // Visualisation functions
140 
141  G4Polyhedron* GetPolyhedron () const;
142  void DescribeYourselfTo(G4VGraphicsScene& scene) const;
143  G4VisExtent GetExtent() const;
145 
146  public: // without description
147 
148  G4GenericTrap(__void__&);
149  // Fake default constructor for usage restricted to direct object
150  // persistency for clients requiring preallocation of memory for
151  // persistifiable objects.
152 
153  G4GenericTrap(const G4GenericTrap& rhs);
154  G4GenericTrap& operator=(const G4GenericTrap& rhs);
155  // Copy constructor and assignment operator.
156 
157  private:
158 
159  // Internal methods
160 
161  inline void SetTwistAngle(G4int index, G4double twist);
163  G4bool CheckOrder(const std::vector<G4TwoVector>& vertices) const;
164  G4bool IsSegCrossing(const G4TwoVector& a, const G4TwoVector& b,
165  const G4TwoVector& c, const G4TwoVector& d) const;
166  G4bool IsSegCrossingZ(const G4TwoVector& a, const G4TwoVector& b,
167  const G4TwoVector& c, const G4TwoVector& d) const;
169  G4AffineTransform& pTransform) const;
170  void ReorderVertices(std::vector<G4ThreeVector>& vertices) const;
171  void ComputeBBox();
172  inline G4ThreeVector GetMinimumBBox() const;
173  inline G4ThreeVector GetMaximumBBox() const;
174 
175  G4VFacet* MakeDownFacet(const std::vector<G4ThreeVector>& fromVertices,
176  G4int ind1, G4int ind2, G4int ind3) const;
177  G4VFacet* MakeUpFacet(const std::vector<G4ThreeVector>& fromVertices,
178  G4int ind1, G4int ind2, G4int ind3) const;
179  G4VFacet* MakeSideFacet(const G4ThreeVector& downVertex0,
180  const G4ThreeVector& downVertex1,
181  const G4ThreeVector& upVertex1,
182  const G4ThreeVector& upVertex0) const;
184 
186  const std::vector<G4TwoVector>& poly) const;
188  const G4ThreeVector& v, const G4int ipl) const ;
190  const G4ThreeVector& v, const G4int ipl) const;
192  const G4int ipl) const;
193  G4double SafetyToFace(const G4ThreeVector& p, const G4int iseg) const;
195  const G4ThreeVector& p1,
196  const G4ThreeVector& p2,
197  const G4ThreeVector& p3) const;
198  protected:
199 
202 
203  private:
204 
205  // static data members
206 
207  static const G4int fgkNofVertices;
208  static const G4double fgkTolerance;
209 
211 
212  // data members
213 
215  std::vector<G4TwoVector> fVertices;
222 
224  // Codes for faces (kXY[num]=num of lateral face,kMZ= minus z face etc)
225 
228  // Surface and Volume
229 };
230 
231 #include "G4GenericTrap.icc"
232 
233 #endif
234 
235 #endif
static const G4int fgkNofVertices
G4Polyhedron * GetPolyhedron() const
G4int GetVisSubdivisions() const
void SetTwistAngle(G4int index, G4double twist)
G4bool IsSegCrossingZ(const G4TwoVector &a, const G4TwoVector &b, const G4TwoVector &c, const G4TwoVector &d) const
G4GenericTrap(const G4String &name, G4double halfZ, const std::vector< G4TwoVector > &vertices)
CLHEP::Hep3Vector G4ThreeVector
G4VisExtent GetExtent() const
G4double fTwist[4]
G4TessellatedSolid * CreateTessellatedSolid() const
G4Polyhedron * fpPolyhedron
G4double DistToPlane(const G4ThreeVector &p, const G4ThreeVector &v, const G4int ipl) const
G4VFacet * MakeSideFacet(const G4ThreeVector &downVertex0, const G4ThreeVector &downVertex1, const G4ThreeVector &upVertex1, const G4ThreeVector &upVertex0) const
G4String name
Definition: TRTMaterials.hh:40
G4int fVisSubdivisions
G4VSolid * Clone() const
G4double GetFaceSurfaceArea(const G4ThreeVector &p0, const G4ThreeVector &p1, const G4ThreeVector &p2, const G4ThreeVector &p3) const
G4ThreeVector NormalToPlane(const G4ThreeVector &p, const G4int ipl) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
G4GeometryType GetEntityType() const
G4TwoVector GetVertex(G4int index) const
G4bool IsTwisted() const
G4double a
Definition: TRTMaterials.hh:39
G4double GetZHalfLength() const
G4VFacet * MakeUpFacet(const std::vector< G4ThreeVector > &fromVertices, G4int ind1, G4int ind2, G4int ind3) const
int G4int
Definition: G4Types.hh:78
G4bool ComputeIsTwisted()
G4double SafetyToFace(const G4ThreeVector &p, const G4int iseg) const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4double GetSurfaceArea()
G4ThreeVector GetMaximumBBox() const
G4TessellatedSolid * fTessellatedSolid
G4ThreeVector GetPointOnSurface() const
G4VFacet * MakeDownFacet(const std::vector< G4ThreeVector > &fromVertices, G4int ind1, G4int ind2, G4int ind3) const
G4GenericTrap & operator=(const G4GenericTrap &rhs)
bool G4bool
Definition: G4Types.hh:79
std::ostream & StreamInfo(std::ostream &os) const
G4double GetTwistAngle(G4int index) const
G4double DistToTriangle(const G4ThreeVector &p, const G4ThreeVector &v, const G4int ipl) const
std::vector< G4ThreeVector > G4ThreeVectorList
Definition: G4VSolid.hh:79
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
G4double fSurfaceArea
const G4int n
G4double GetCubicVolume()
std::vector< G4TwoVector > fVertices
EInside Inside(const G4ThreeVector &p) const
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &pTransform) const
G4double fCubicVolume
G4ThreeVector GetMinimumBBox() const
G4Polyhedron * CreatePolyhedron() const
G4int GetNofVertices() const
void ReorderVertices(std::vector< G4ThreeVector > &vertices) const
EInside
Definition: geomdefs.hh:58
EInside InsidePolygone(const G4ThreeVector &p, const std::vector< G4TwoVector > &poly) const
EAxis
Definition: geomdefs.hh:54
CLHEP::Hep2Vector G4TwoVector
Definition: G4TwoVector.hh:42
G4double halfCarTolerance
G4bool IsSegCrossing(const G4TwoVector &a, const G4TwoVector &b, const G4TwoVector &c, const G4TwoVector &d) const
double G4double
Definition: G4Types.hh:76
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4bool CheckOrder(const std::vector< G4TwoVector > &vertices) const
void SetVisSubdivisions(G4int subdiv)
const std::vector< G4TwoVector > & GetVertices() const
G4bool fRebuildPolyhedron
G4ThreeVector fMinBBoxVector
static const G4double fgkTolerance
G4ThreeVector fMaxBBoxVector
void DescribeYourselfTo(G4VGraphicsScene &scene) const