source: trunk/source/geometry/solids/specific/include/G4ExtrudedSolid.hh@ 1316

Last change on this file since 1316 was 1315, checked in by garnier, 15 years ago

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File size: 6.7 KB
RevLine 
[831]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//
[1315]27// $Id: G4ExtrudedSolid.hh,v 1.8 2010/04/15 10:23:34 ivana Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
[831]29//
30//
31// --------------------------------------------------------------------
32// GEANT 4 class header file
33//
34//
35// G4ExtrudedSolid
36//
37// Class description:
38//
39// G4ExtrudedSolid is a solid which represents the extrusion of an arbitrary
40// polygon with fixed outline in the defined Z sections.
41// The z-sides of the solid are the scaled versions of the same polygon.
42// The solid is implemented as a specification of G4TessellatedSolid.
43//
44// Parameters in the constructor:
45// const G4String& pName - solid name
46// std::vector<G4TwoVector> polygon - the vertices of the outlined polygon
[1315]47// defined in clockwise or anti-clockwise order
[831]48// std::vector<ZSection> - the z-sections defined by
49// z position, offset and scale
50// in increasing z-position order
51//
52// Parameters in the special constructor (for solid with 2 z-sections:
53// G4double hz - the solid half length in Z
54// G4TwoVector off1 - offset of the side in -hz
55// G4double scale1 - scale of the side in -hz
56// G4TwoVector off2 - offset of the side in +hz
57// G4double scale2 - scale of the side in -hz
58
59// Author:
60// Ivana Hrivnacova, IPN Orsay
61// --------------------------------------------------------------------
62
63#ifndef G4ExtrudedSolid_HH
64#define G4ExtrudedSolid_HH
65
66#include <vector>
67
68#include "G4TwoVector.hh"
69
70#include "G4TessellatedSolid.hh"
71
72class G4ExtrudedSolid : public G4TessellatedSolid
73{
74
75 public: // without description
76
77 struct ZSection
78 {
79 ZSection(G4double z, G4TwoVector offset, G4double scale)
80 : fZ(z), fOffset(offset), fScale(scale) {}
81
82 G4double fZ;
83 G4TwoVector fOffset;
84 G4double fScale;
85 };
86
87 public: // with description
88
89 G4ExtrudedSolid( const G4String& pName,
90 std::vector<G4TwoVector> polygon,
91 std::vector<ZSection> zsections);
92 // General constructor
93
94 G4ExtrudedSolid( const G4String& pName,
95 std::vector<G4TwoVector> polygon,
96 G4double hz,
97 G4TwoVector off1, G4double scale1,
98 G4TwoVector off2, G4double scale2 );
99 // Special constructor for solid with 2 z-sections
100
101 virtual ~G4ExtrudedSolid();
102 // Destructor
103
104 // Accessors
105
106 inline G4int GetNofVertices() const;
107 inline G4TwoVector GetVertex(G4int index) const;
108 inline std::vector<G4TwoVector> GetPolygon() const;
109
110 inline G4int GetNofZSections() const;
111 inline ZSection GetZSection(G4int index) const;
112 inline std::vector<ZSection> GetZSections() const;
113
114 // Solid methods
115
116 EInside Inside (const G4ThreeVector &p) const;
117 G4double DistanceToOut(const G4ThreeVector &p,
118 const G4ThreeVector &v,
119 const G4bool calcNorm=false,
120 G4bool *validNorm=0, G4ThreeVector *n=0) const;
121 G4double DistanceToOut (const G4ThreeVector &p) const;
122 G4GeometryType GetEntityType () const;
123
124 std::ostream& StreamInfo(std::ostream &os) const;
125
126 public: // without description
127
128 G4ExtrudedSolid(__void__&);
129 // Fake default constructor for usage restricted to direct object
130 // persistency for clients requiring preallocation of memory for
131 // persistifiable objects.
132
133 private:
134
135 void ComputeProjectionParameters();
136
137 G4ThreeVector GetVertex(G4int iz, G4int ind) const;
138 G4TwoVector ProjectPoint(const G4ThreeVector& point) const;
139
140 G4bool IsSameLine(G4TwoVector p,
141 G4TwoVector l1, G4TwoVector l2) const;
142 G4bool IsSameLineSegment(G4TwoVector p,
143 G4TwoVector l1, G4TwoVector l2) const;
144 G4bool IsSameSide(G4TwoVector p1, G4TwoVector p2,
145 G4TwoVector l1, G4TwoVector l2) const;
146 G4bool IsPointInside(G4TwoVector a, G4TwoVector b, G4TwoVector c,
147 G4TwoVector p) const;
148 G4double GetAngle(G4TwoVector p0, G4TwoVector pa, G4TwoVector pb) const;
149
150 G4VFacet* MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const;
151 G4VFacet* MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const;
152
153 G4bool AddGeneralPolygonFacets();
154 G4bool MakeFacets();
155 G4bool IsConvex() const;
156
157
158 private:
159
160 G4int fNv;
161 G4int fNz;
162 std::vector<G4TwoVector> fPolygon;
163 std::vector<ZSection> fZSections;
164 std::vector< std::vector<G4int> > fTriangles;
165 G4bool fIsConvex;
166 G4GeometryType fGeometryType;
167
168 std::vector<G4double> fKScales;
169 std::vector<G4double> fScale0s;
170 std::vector<G4TwoVector> fKOffsets;
171 std::vector<G4TwoVector> fOffset0s;
172};
173
174#include "G4ExtrudedSolid.icc"
175
176#endif
Note: See TracBrowser for help on using the repository browser.