Geant4  10.03
G4ExtrudedSolid.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: G4ExtrudedSolid.hh 100819 2016-11-02 15:17:36Z gcosmo $
28 //
29 //
30 // --------------------------------------------------------------------
31 // GEANT 4 class header file
32 //
33 //
34 // G4ExtrudedSolid
35 //
36 // Class description:
37 //
38 // G4ExtrudedSolid is a solid which represents the extrusion of an arbitrary
39 // polygon with fixed outline in the defined Z sections.
40 // The z-sides of the solid are the scaled versions of the same polygon.
41 // The solid is implemented as a specification of G4TessellatedSolid.
42 //
43 // Parameters in the constructor:
44 // const G4String& pName - solid name
45 // std::vector<G4TwoVector> polygon - the vertices of the outlined polygon
46 // defined in clockwise or anti-clockwise order
47 // std::vector<ZSection> - the z-sections defined by
48 // z position, offset and scale
49 // in increasing z-position order
50 //
51 // Parameters in the special constructor (for solid with 2 z-sections:
52 // G4double halfZ - the solid half length in Z
53 // G4TwoVector off1 - offset of the side in -halfZ
54 // G4double scale1 - scale of the side in -halfZ
55 // G4TwoVector off2 - offset of the side in +halfZ
56 // G4double scale2 - scale of the side in -halfZ
57 
58 // Author:
59 // Ivana Hrivnacova, IPN Orsay
60 //
61 // --------------------------------------------------------------------
62 
63 #ifndef G4ExtrudedSolid_HH
64 #define G4ExtrudedSolid_HH
65 
66 #if defined(G4GEOM_USE_USOLIDS)
67 #define G4GEOM_USE_UEXTRUDEDSOLID 1
68 #endif
69 
70 #if defined(G4GEOM_USE_UEXTRUDEDSOLID)
71  #define G4UExtrudedSolid G4ExtrudedSolid
72  #include "G4UExtrudedSolid.hh"
73 #else
74 
75 #include <vector>
76 
77 #include "G4TwoVector.hh"
78 
79 #include "G4TessellatedSolid.hh"
80 
81 class G4VFacet;
82 
84 {
85 
86  public: // without description
87 
88  struct ZSection
89  {
90  ZSection(G4double z, const G4TwoVector& offset, G4double scale)
91  : fZ(z), fOffset(offset), fScale(scale) {}
92 
96  };
97 
98  public: // with description
99 
100  G4ExtrudedSolid( const G4String& pName,
101  const std::vector<G4TwoVector>& polygon,
102  const std::vector<ZSection>& zsections);
103  // General constructor
104 
105  G4ExtrudedSolid( const G4String& pName,
106  const std::vector<G4TwoVector>& polygon,
107  G4double halfZ,
108  const G4TwoVector& off1, G4double scale1,
109  const G4TwoVector& off2, G4double scale2 );
110  // Special constructor for solid with 2 z-sections
111 
112  virtual ~G4ExtrudedSolid();
113  // Destructor
114 
115  // Accessors
116 
117  inline G4int GetNofVertices() const;
118  inline G4TwoVector GetVertex(G4int index) const;
119  inline std::vector<G4TwoVector> GetPolygon() const;
120 
121  inline G4int GetNofZSections() const;
122  inline ZSection GetZSection(G4int index) const;
123  inline std::vector<ZSection> GetZSections() const;
124 
125  // Solid methods
126 
127  EInside Inside (const G4ThreeVector &p) const;
129  const G4ThreeVector &v,
130  const G4bool calcNorm=false,
131  G4bool *validNorm=0, G4ThreeVector *n=0) const;
132  G4double DistanceToOut (const G4ThreeVector &p) const;
133  void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
134  G4bool CalculateExtent(const EAxis pAxis,
135  const G4VoxelLimits& pVoxelLimit,
136  const G4AffineTransform& pTransform,
137  G4double& pMin, G4double& pMax) const;
138  G4GeometryType GetEntityType () const;
139  G4VSolid* Clone() const;
140 
141  std::ostream& StreamInfo(std::ostream &os) const;
142 
143  public: // without description
144 
145  G4ExtrudedSolid(__void__&);
146  // Fake default constructor for usage restricted to direct object
147  // persistency for clients requiring preallocation of memory for
148  // persistifiable objects.
149 
150  G4ExtrudedSolid(const G4ExtrudedSolid& rhs);
152  // Copy constructor and assignment operator.
153 
154  private:
155 
157 
158  G4ThreeVector GetVertex(G4int iz, G4int ind) const;
159  G4TwoVector ProjectPoint(const G4ThreeVector& point) const;
160 
161  G4bool IsSameLine(const G4TwoVector& p,
162  const G4TwoVector& l1,
163  const G4TwoVector& l2) const;
165  const G4TwoVector& l1,
166  const G4TwoVector& l2) const;
167  G4bool IsSameSide(const G4TwoVector& p1,
168  const G4TwoVector& p2,
169  const G4TwoVector& l1,
170  const G4TwoVector& l2) const;
172  const G4TwoVector& b,
173  const G4TwoVector& c,
174  const G4TwoVector& p) const;
175  G4double GetAngle(const G4TwoVector& p0,
176  const G4TwoVector& pa,
177  const G4TwoVector& pb) const;
178 
179  G4VFacet* MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const;
180  G4VFacet* MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const;
181 
183  G4bool MakeFacets();
184 
185  private:
186 
189  std::vector<G4TwoVector> fPolygon;
190  std::vector<ZSection> fZSections;
191  std::vector< std::vector<G4int> > fTriangles;
194 
195  std::vector<G4double> fKScales;
196  std::vector<G4double> fScale0s;
197  std::vector<G4TwoVector> fKOffsets;
198  std::vector<G4TwoVector> fOffset0s;
199 };
200 
201 #include "G4ExtrudedSolid.icc"
202 
203 #endif
204 
205 #endif
std::vector< G4TwoVector > GetPolygon() const
G4GeometryType GetEntityType() const
void Extent(G4ThreeVector &pMin, G4ThreeVector &pMax) const
CLHEP::Hep3Vector G4ThreeVector
G4VSolid * Clone() const
std::vector< G4TwoVector > fOffset0s
std::vector< G4double > fScale0s
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
std::vector< ZSection > fZSections
G4ExtrudedSolid(const G4String &pName, const std::vector< G4TwoVector > &polygon, const std::vector< ZSection > &zsections)
G4bool IsSameSide(const G4TwoVector &p1, const G4TwoVector &p2, const G4TwoVector &l1, const G4TwoVector &l2) const
virtual ~G4ExtrudedSolid()
EInside Inside(const G4ThreeVector &p) const
int G4int
Definition: G4Types.hh:78
G4TwoVector ProjectPoint(const G4ThreeVector &point) const
G4bool AddGeneralPolygonFacets()
G4TwoVector GetVertex(G4int index) const
G4double GetAngle(const G4TwoVector &p0, const G4TwoVector &pa, const G4TwoVector &pb) const
void ComputeProjectionParameters()
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
bool G4bool
Definition: G4Types.hh:79
G4int GetNofVertices() const
ZSection(G4double z, const G4TwoVector &offset, G4double scale)
std::vector< G4double > fKScales
const G4int n
G4int GetNofZSections() const
std::ostream & StreamInfo(std::ostream &os) const
EInside
Definition: geomdefs.hh:58
EAxis
Definition: geomdefs.hh:54
std::vector< G4TwoVector > fKOffsets
ZSection GetZSection(G4int index) const
G4bool IsPointInside(const G4TwoVector &a, const G4TwoVector &b, const G4TwoVector &c, const G4TwoVector &p) const
CLHEP::Hep2Vector G4TwoVector
Definition: G4TwoVector.hh:42
G4bool IsSameLine(const G4TwoVector &p, const G4TwoVector &l1, const G4TwoVector &l2) const
double G4double
Definition: G4Types.hh:76
std::vector< ZSection > GetZSections() const
G4VFacet * MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const
G4GeometryType fGeometryType
G4bool IsSameLineSegment(const G4TwoVector &p, const G4TwoVector &l1, const G4TwoVector &l2) const
G4ExtrudedSolid & operator=(const G4ExtrudedSolid &rhs)
G4VFacet * MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const
std::vector< std::vector< G4int > > fTriangles
std::vector< G4TwoVector > fPolygon