Geant4  10.01.p03
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 83851 2014-09-19 10:12:12Z 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 #ifndef G4ExtrudedSolid_HH
63 #define G4ExtrudedSolid_HH
64 
65 #if defined(G4GEOM_USE_USOLIDS)
66 #define G4GEOM_USE_UEXTRUDEDSOLID 1
67 #endif
68 
69 #if defined(G4GEOM_USE_UEXTRUDEDSOLID)
70  #define G4UExtrudedSolid G4ExtrudedSolid
71  #include "G4UExtrudedSolid.hh"
72 #else
73 
74 #include <vector>
75 
76 #include "G4TwoVector.hh"
77 
78 #include "G4TessellatedSolid.hh"
79 
80 class G4VFacet;
81 
83 {
84 
85  public: // without description
86 
87  struct ZSection
88  {
90  : fZ(z), fOffset(offset), fScale(scale) {}
91 
95  };
96 
97  public: // with description
98 
99  G4ExtrudedSolid( const G4String& pName,
100  std::vector<G4TwoVector> polygon,
101  std::vector<ZSection> zsections);
102  // General constructor
103 
104  G4ExtrudedSolid( const G4String& pName,
105  std::vector<G4TwoVector> polygon,
106  G4double halfZ,
107  G4TwoVector off1, G4double scale1,
108  G4TwoVector off2, G4double scale2 );
109  // Special constructor for solid with 2 z-sections
110 
111  virtual ~G4ExtrudedSolid();
112  // Destructor
113 
114  // Accessors
115 
116  inline G4int GetNofVertices() const;
117  inline G4TwoVector GetVertex(G4int index) const;
118  inline std::vector<G4TwoVector> GetPolygon() const;
119 
120  inline G4int GetNofZSections() const;
121  inline ZSection GetZSection(G4int index) const;
122  inline std::vector<ZSection> GetZSections() const;
123 
124  // Solid methods
125 
126  EInside Inside (const G4ThreeVector &p) const;
128  const G4ThreeVector &v,
129  const G4bool calcNorm=false,
130  G4bool *validNorm=0, G4ThreeVector *n=0) const;
131  G4double DistanceToOut (const G4ThreeVector &p) const;
132  G4GeometryType GetEntityType () const;
133  G4VSolid* Clone() const;
134 
135  std::ostream& StreamInfo(std::ostream &os) const;
136 
137  public: // without description
138 
139  G4ExtrudedSolid(__void__&);
140  // Fake default constructor for usage restricted to direct object
141  // persistency for clients requiring preallocation of memory for
142  // persistifiable objects.
143 
144  G4ExtrudedSolid(const G4ExtrudedSolid& rhs);
146  // Copy constructor and assignment operator.
147 
148  private:
149 
151 
152  G4ThreeVector GetVertex(G4int iz, G4int ind) const;
153  G4TwoVector ProjectPoint(const G4ThreeVector& point) const;
154 
156  G4TwoVector l1, G4TwoVector l2) const;
158  G4TwoVector l1, G4TwoVector l2) const;
160  G4TwoVector l1, G4TwoVector l2) const;
162  G4TwoVector p) const;
164 
165  G4VFacet* MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const;
166  G4VFacet* MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const;
167 
169  G4bool MakeFacets();
170  G4bool IsConvex() const;
171 
172 
173  private:
174 
177  std::vector<G4TwoVector> fPolygon;
178  std::vector<ZSection> fZSections;
179  std::vector< std::vector<G4int> > fTriangles;
182 
183  std::vector<G4double> fKScales;
184  std::vector<G4double> fScale0s;
185  std::vector<G4TwoVector> fKOffsets;
186  std::vector<G4TwoVector> fOffset0s;
187 };
188 
189 #include "G4ExtrudedSolid.icc"
190 
191 #endif
192 
193 #endif
std::vector< G4TwoVector > GetPolygon() const
G4bool IsPointInside(G4TwoVector a, G4TwoVector b, G4TwoVector c, G4TwoVector p) const
G4GeometryType GetEntityType() const
G4bool IsConvex() const
CLHEP::Hep3Vector G4ThreeVector
G4VSolid * Clone() const
std::vector< G4TwoVector > fOffset0s
std::vector< G4double > fScale0s
G4ExtrudedSolid(const G4String &pName, std::vector< G4TwoVector > polygon, std::vector< ZSection > zsections)
G4double z
Definition: TRTMaterials.hh:39
std::vector< ZSection > fZSections
ZSection(G4double z, G4TwoVector offset, G4double scale)
G4double a
Definition: TRTMaterials.hh:39
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
G4bool IsSameLine(G4TwoVector p, G4TwoVector l1, G4TwoVector l2) const
G4double GetAngle(G4TwoVector p0, G4TwoVector pa, G4TwoVector pb) const
void ComputeProjectionParameters()
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
bool G4bool
Definition: G4Types.hh:79
G4double iz
Definition: TRTMaterials.hh:39
G4int GetNofVertices() const
const G4double p2
const G4double p1
std::vector< G4double > fKScales
const G4int n
G4int GetNofZSections() const
std::ostream & StreamInfo(std::ostream &os) const
const G4double p0
EInside
Definition: geomdefs.hh:58
G4bool IsSameLineSegment(G4TwoVector p, G4TwoVector l1, G4TwoVector l2) const
std::vector< G4TwoVector > fKOffsets
ZSection GetZSection(G4int index) const
G4bool IsSameSide(G4TwoVector p1, G4TwoVector p2, G4TwoVector l1, G4TwoVector l2) const
CLHEP::Hep2Vector G4TwoVector
Definition: G4TwoVector.hh:42
double G4double
Definition: G4Types.hh:76
std::vector< ZSection > GetZSections() const
G4VFacet * MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const
G4GeometryType fGeometryType
G4ExtrudedSolid & operator=(const G4ExtrudedSolid &rhs)
G4VFacet * MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const
std::vector< std::vector< G4int > > fTriangles
std::vector< G4TwoVector > fPolygon