Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ExtrudedSolid.hh
이 파일의 문서화 페이지로 가기
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 108078 2017-12-20 08:15:44Z 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  {
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  G4double DistanceToIn(const G4ThreeVector& p, const G4ThreeVector& v) const;
130  G4double DistanceToIn(const G4ThreeVector& p ) const;
132  const G4ThreeVector &v,
133  const G4bool calcNorm=false,
134  G4bool *validNorm=0, G4ThreeVector *n=0) const;
135  G4double DistanceToOut(const G4ThreeVector &p) const;
136 
137  void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
138  G4bool CalculateExtent(const EAxis pAxis,
139  const G4VoxelLimits& pVoxelLimit,
140  const G4AffineTransform& pTransform,
141  G4double& pMin, G4double& pMax) const;
142  G4GeometryType GetEntityType () const;
143  G4VSolid* Clone() const;
144 
145  std::ostream& StreamInfo(std::ostream &os) const;
146 
147  public: // without description
148 
149  G4ExtrudedSolid(__void__&);
150  // Fake default constructor for usage restricted to direct object
151  // persistency for clients requiring preallocation of memory for
152  // persistifiable objects.
153 
154  G4ExtrudedSolid(const G4ExtrudedSolid& rhs);
156  // Copy constructor and assignment operator.
157 
158  private:
159 
161  void ComputeLateralPlanes();
162  inline G4bool PointInPolygon(const G4ThreeVector& p) const;
163  inline G4double DistanceToPolygonSqr(const G4ThreeVector& p) const;
165 
166  G4ThreeVector GetVertex(G4int iz, G4int ind) const;
167  G4TwoVector ProjectPoint(const G4ThreeVector& point) const;
168 
170  const G4TwoVector& l1,
171  const G4TwoVector& l2) const;
173  const G4TwoVector& l1,
174  const G4TwoVector& l2) const;
175  G4bool IsSameSide(const G4TwoVector& p1,
176  const G4TwoVector& p2,
177  const G4TwoVector& l1,
178  const G4TwoVector& l2) const;
180  const G4TwoVector& b,
181  const G4TwoVector& c,
182  const G4TwoVector& p) const;
183  G4double GetAngle(const G4TwoVector& p0,
184  const G4TwoVector& pa,
185  const G4TwoVector& pb) const;
186 
187  G4VFacet* MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const;
188  G4VFacet* MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const;
189 
191  G4bool MakeFacets();
192 
193  private:
194 
197  std::vector<G4TwoVector> fPolygon;
198  std::vector<ZSection> fZSections;
199  std::vector< std::vector<G4int> > fTriangles;
202 
204  struct plane { G4double a,b,c,d; }; // a*x + b*y + c*z + d = 0
205  std::vector<plane> fPlanes;
206  struct line { G4double k,m; }; // x = k*y + m;
207  std::vector<line> fLines;
208  std::vector<G4double> fLengths; // edge lengths
209 
210  std::vector<G4double> fKScales;
211  std::vector<G4double> fScale0s;
212  std::vector<G4TwoVector> fKOffsets;
213  std::vector<G4TwoVector> fOffset0s;
214 };
215 
216 #include "G4ExtrudedSolid.icc"
217 
218 #endif
219 
220 #endif
ZSection GetZSection(G4int index) const
G4TwoVector GetVertex(G4int index) const
std::vector< G4double > fKScales
G4bool IsSameLineSegment(const G4TwoVector &p, const G4TwoVector &l1, const G4TwoVector &l2) const
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
void ComputeProjectionParameters()
G4TwoVector ProjectPoint(const G4ThreeVector &point) const
std::vector< G4TwoVector > GetPolygon() const
G4VFacet * MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const
G4VSolid * Clone() const
const char * p
Definition: xmltok.h:285
G4bool IsPointInside(const G4TwoVector &a, const G4TwoVector &b, const G4TwoVector &c, const G4TwoVector &p) const
std::vector< ZSection > fZSections
Double_t z
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
G4ExtrudedSolid(const G4String &pName, const std::vector< G4TwoVector > &polygon, const std::vector< ZSection > &zsections)
G4double GetAngle(const G4TwoVector &p0, const G4TwoVector &pa, const G4TwoVector &pb) const
std::vector< std::vector< G4int > > fTriangles
std::ostream & StreamInfo(std::ostream &os) const
G4bool IsSameSide(const G4TwoVector &p1, const G4TwoVector &p2, const G4TwoVector &l1, const G4TwoVector &l2) const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
G4GeometryType fGeometryType
std::vector< G4double > fLengths
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4ExtrudedSolid & operator=(const G4ExtrudedSolid &rhs)
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
Double_t scale
std::vector< G4TwoVector > fOffset0s
G4bool AddGeneralPolygonFacets()
std::vector< line > fLines
G4int GetNofZSections() const
std::vector< G4TwoVector > fKOffsets
G4GeometryType GetEntityType() const
int G4int
Definition: G4Types.hh:78
EInside
Definition: geomdefs.hh:58
virtual ~G4ExtrudedSolid()
std::vector< plane > fPlanes
EAxis
Definition: geomdefs.hh:54
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
EInside Inside(const G4ThreeVector &p) const
G4bool PointInPolygon(const G4ThreeVector &p) const
G4bool IsSameLine(const G4TwoVector &p, const G4TwoVector &l1, const G4TwoVector &l2) const
Char_t n[5]
G4double DistanceToPolygonSqr(const G4ThreeVector &p) const
ZSection(G4double z, const G4TwoVector &offset, G4double scale)
std::vector< G4double > fScale0s
G4int GetNofVertices() const
std::vector< G4TwoVector > fPolygon
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
std::vector< ZSection > GetZSections() const
G4VFacet * MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const