Geant4  10.00.p01
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 66356 2012-12-18 09:02:32Z 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 #include <vector>
66 
67 #include "G4TwoVector.hh"
68 
69 #include "G4TessellatedSolid.hh"
70 
71 class G4VFacet;
72 
74 {
75 
76  public: // without description
77 
78  struct ZSection
79  {
81  : fZ(z), fOffset(offset), fScale(scale) {}
82 
86  };
87 
88  public: // with description
89 
90  G4ExtrudedSolid( const G4String& pName,
91  std::vector<G4TwoVector> polygon,
92  std::vector<ZSection> zsections);
93  // General constructor
94 
95  G4ExtrudedSolid( const G4String& pName,
96  std::vector<G4TwoVector> polygon,
97  G4double halfZ,
98  G4TwoVector off1, G4double scale1,
99  G4TwoVector off2, G4double scale2 );
100  // Special constructor for solid with 2 z-sections
101 
102  virtual ~G4ExtrudedSolid();
103  // Destructor
104 
105  // Accessors
106 
107  inline G4int GetNofVertices() const;
108  inline G4TwoVector GetVertex(G4int index) const;
109  inline std::vector<G4TwoVector> GetPolygon() const;
110 
111  inline G4int GetNofZSections() const;
112  inline ZSection GetZSection(G4int index) const;
113  inline std::vector<ZSection> GetZSections() const;
114 
115  // Solid methods
116 
117  EInside Inside (const G4ThreeVector &p) const;
119  const G4ThreeVector &v,
120  const G4bool calcNorm=false,
121  G4bool *validNorm=0, G4ThreeVector *n=0) const;
122  G4double DistanceToOut (const G4ThreeVector &p) const;
123  G4GeometryType GetEntityType () const;
124  G4VSolid* Clone() const;
125 
126  std::ostream& StreamInfo(std::ostream &os) const;
127 
128  public: // without description
129 
130  G4ExtrudedSolid(__void__&);
131  // Fake default constructor for usage restricted to direct object
132  // persistency for clients requiring preallocation of memory for
133  // persistifiable objects.
134 
135  G4ExtrudedSolid(const G4ExtrudedSolid& rhs);
137  // Copy constructor and assignment operator.
138 
139  private:
140 
142 
143  G4ThreeVector GetVertex(G4int iz, G4int ind) const;
144  G4TwoVector ProjectPoint(const G4ThreeVector& point) const;
145 
147  G4TwoVector l1, G4TwoVector l2) const;
149  G4TwoVector l1, G4TwoVector l2) const;
151  G4TwoVector l1, G4TwoVector l2) const;
153  G4TwoVector p) const;
155 
156  G4VFacet* MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const;
157  G4VFacet* MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const;
158 
160  G4bool MakeFacets();
161  G4bool IsConvex() const;
162 
163 
164  private:
165 
168  std::vector<G4TwoVector> fPolygon;
169  std::vector<ZSection> fZSections;
170  std::vector< std::vector<G4int> > fTriangles;
173 
174  std::vector<G4double> fKScales;
175  std::vector<G4double> fScale0s;
176  std::vector<G4TwoVector> fKOffsets;
177  std::vector<G4TwoVector> fOffset0s;
178 };
179 
180 #include "G4ExtrudedSolid.icc"
181 
182 #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
std::vector< G4double > fKScales
const G4int n
G4int GetNofZSections() const
std::ostream & StreamInfo(std::ostream &os) const
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