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 and of QinetiQ Ltd, * |
---|
20 | // * subject to DEFCON 705 IPR conditions. * |
---|
21 | // * By using, copying, modifying or distributing the software (or * |
---|
22 | // * any work based on the software) you agree to acknowledge its * |
---|
23 | // * use in resulting scientific publications, and indicate your * |
---|
24 | // * acceptance of all terms of the Geant4 Software license. * |
---|
25 | // ******************************************************************** |
---|
26 | // |
---|
27 | // $Id: G4TessellatedSolid.hh,v 1.10 2007/12/10 16:30:13 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-03 $ |
---|
29 | // |
---|
30 | // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
31 | // |
---|
32 | // MODULE: G4TessellatedSolid.hh |
---|
33 | // |
---|
34 | // Date: 15/06/2005 |
---|
35 | // Author: P R Truscott |
---|
36 | // Organisation: QinetiQ Ltd, UK |
---|
37 | // Customer: UK Ministry of Defence : RAO CRP TD Electronic Systems |
---|
38 | // Contract: C/MAT/N03517 |
---|
39 | // |
---|
40 | // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
41 | // |
---|
42 | // CHANGE HISTORY |
---|
43 | // -------------- |
---|
44 | // 22 November 2005, F Lei, |
---|
45 | // - Added GetPolyhedron() |
---|
46 | // |
---|
47 | // 31 October 2004, P R Truscott, QinetiQ Ltd, UK |
---|
48 | // - Created. |
---|
49 | // |
---|
50 | // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
51 | // |
---|
52 | // Class description: |
---|
53 | // |
---|
54 | // G4TessellatedSolid is a special Geant4 solid defined by a number of |
---|
55 | // facets (G4VFacet). It is important that the supplied facets shall form a |
---|
56 | // fully enclose space which is the solid. |
---|
57 | // At the moment only two types of facet can be used for the construction of |
---|
58 | // a G4TessellatedSolid, i.e. the G4TriangularFacet and G4QuadrangularFacet. |
---|
59 | // |
---|
60 | // How to contruct a G4TessellatedSolid: |
---|
61 | // |
---|
62 | // First declare a tessellated solid: |
---|
63 | // |
---|
64 | // G4TessellatedSolid* solidTarget = new G4TessellatedSolid("Solid_name"); |
---|
65 | // |
---|
66 | // Define the facets which form the solid |
---|
67 | // |
---|
68 | // G4double targetSiz = 10*cm ; |
---|
69 | // G4TriangularFacet *facet1 = new |
---|
70 | // G4TriangularFacet (G4ThreeVector(-targetSize,-targetSize, 0.0), |
---|
71 | // G4ThreeVector(+targetSize,-targetSize, 0.0), |
---|
72 | // G4ThreeVector( 0.0, 0.0,+targetSize), |
---|
73 | // ABSOLUTE); |
---|
74 | // G4TriangularFacet *facet2 = new |
---|
75 | // G4TriangularFacet (G4ThreeVector(+targetSize,-targetSize, 0.0), |
---|
76 | // G4ThreeVector(+targetSize,+targetSize, 0.0), |
---|
77 | // G4ThreeVector( 0.0, 0.0,+targetSize), |
---|
78 | // ABSOLUTE); |
---|
79 | // G4TriangularFacet *facet3 = new |
---|
80 | // G4TriangularFacet (G4ThreeVector(+targetSize,+targetSize, 0.0), |
---|
81 | // G4ThreeVector(-targetSize,+targetSize, 0.0), |
---|
82 | // G4ThreeVector( 0.0, 0.0,+targetSize), |
---|
83 | // ABSOLUTE); |
---|
84 | // G4TriangularFacet *facet4 = new |
---|
85 | // G4TriangularFacet (G4ThreeVector(-targetSize,+targetSize, 0.0), |
---|
86 | // G4ThreeVector(-targetSize,-targetSize, 0.0), |
---|
87 | // G4ThreeVector( 0.0, 0.0,+targetSize), |
---|
88 | // ABSOLUTE); |
---|
89 | // G4QuadrangularFacet *facet5 = new |
---|
90 | // G4QuadrangularFacet (G4ThreeVector(-targetSize,-targetSize, 0.0), |
---|
91 | // G4ThreeVector(-targetSize,+targetSize, 0.0), |
---|
92 | // G4ThreeVector(+targetSize,+targetSize, 0.0), |
---|
93 | // G4ThreeVector(+targetSize,-targetSize, 0.0), |
---|
94 | // ABSOLUTE); |
---|
95 | // |
---|
96 | // Then add the facets to the solid: |
---|
97 | // |
---|
98 | // solidTarget->AddFacet((G4VFacet*) facet1); |
---|
99 | // solidTarget->AddFacet((G4VFacet*) facet2); |
---|
100 | // solidTarget->AddFacet((G4VFacet*) facet3); |
---|
101 | // solidTarget->AddFacet((G4VFacet*) facet4); |
---|
102 | // solidTarget->AddFacet((G4VFacet*) facet5); |
---|
103 | // |
---|
104 | // Finally declare the solid is complete: |
---|
105 | // |
---|
106 | // solidTarget->SetSolidClosed(true); |
---|
107 | // |
---|
108 | /////////////////////////////////////////////////////////////////////////////// |
---|
109 | #ifndef G4TessellatedSolid_hh |
---|
110 | #define G4TessellatedSolid_hh 1 |
---|
111 | |
---|
112 | #include "G4VSolid.hh" |
---|
113 | #include "G4VFacet.hh" |
---|
114 | #include "G4VGraphicsScene.hh" |
---|
115 | #include "G4VPVParameterisation.hh" |
---|
116 | #include "G4VPhysicalVolume.hh" |
---|
117 | #include "G4VoxelLimits.hh" |
---|
118 | #include "G4AffineTransform.hh" |
---|
119 | #include "G4VisExtent.hh" |
---|
120 | #include "globals.hh" |
---|
121 | |
---|
122 | #include <iostream> |
---|
123 | #include <vector> |
---|
124 | #include <set> |
---|
125 | #include <map> |
---|
126 | |
---|
127 | class G4TessellatedSolid : public G4VSolid |
---|
128 | { |
---|
129 | public: // with description |
---|
130 | |
---|
131 | G4TessellatedSolid (); |
---|
132 | G4TessellatedSolid (const G4String &name); |
---|
133 | virtual ~G4TessellatedSolid (); |
---|
134 | |
---|
135 | G4TessellatedSolid (const G4TessellatedSolid &s); |
---|
136 | const G4TessellatedSolid &operator= (const G4TessellatedSolid &s); |
---|
137 | const G4TessellatedSolid &operator+= (const G4TessellatedSolid &right); |
---|
138 | |
---|
139 | G4bool AddFacet (G4VFacet *aFacet); |
---|
140 | G4VFacet *GetFacet (size_t i) const; |
---|
141 | size_t GetNumberOfFacets () const; |
---|
142 | |
---|
143 | virtual G4double GetCubicVolume (); |
---|
144 | virtual G4double GetSurfaceArea (); |
---|
145 | |
---|
146 | // |
---|
147 | // virtual void ComputeDimensions (G4VPVParameterisation* p, const G4int n, |
---|
148 | // const G4VPhysicalVolume* pRep) const; |
---|
149 | |
---|
150 | virtual EInside Inside (const G4ThreeVector &p) const; |
---|
151 | void SetRandomVectorSet (); |
---|
152 | virtual G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const; |
---|
153 | virtual G4double DistanceToIn(const G4ThreeVector &p, |
---|
154 | const G4ThreeVector &v) const; |
---|
155 | virtual G4double DistanceToIn(const G4ThreeVector &p) const; |
---|
156 | virtual G4double DistanceToOut(const G4ThreeVector &p, |
---|
157 | const G4ThreeVector &v, |
---|
158 | const G4bool calcNorm=false, |
---|
159 | G4bool *validNorm=0, G4ThreeVector *n=0) const; |
---|
160 | virtual G4double DistanceToOut (const G4ThreeVector &p) const; |
---|
161 | virtual G4GeometryType GetEntityType () const; |
---|
162 | |
---|
163 | void SetSolidClosed (const G4bool t); |
---|
164 | G4bool GetSolidClosed () const; |
---|
165 | |
---|
166 | virtual G4ThreeVector GetPointOnSurface() const; |
---|
167 | |
---|
168 | virtual G4bool CalculateExtent(const EAxis pAxis, |
---|
169 | const G4VoxelLimits& pVoxelLimit, |
---|
170 | const G4AffineTransform& pTransform, |
---|
171 | G4double& pMin, G4double& pMax) const; |
---|
172 | |
---|
173 | virtual std::ostream &StreamInfo(std::ostream &os) const; |
---|
174 | |
---|
175 | // Functions for visualization |
---|
176 | |
---|
177 | virtual void DescribeYourselfTo (G4VGraphicsScene& scene) const; |
---|
178 | virtual G4VisExtent GetExtent () const; |
---|
179 | |
---|
180 | G4double GetMinXExtent () const; |
---|
181 | G4double GetMaxXExtent () const; |
---|
182 | G4double GetMinYExtent () const; |
---|
183 | G4double GetMaxYExtent () const; |
---|
184 | G4double GetMinZExtent () const; |
---|
185 | G4double GetMaxZExtent () const; |
---|
186 | |
---|
187 | virtual G4Polyhedron* CreatePolyhedron () const; |
---|
188 | virtual G4Polyhedron* GetPolyhedron () const; |
---|
189 | virtual G4NURBS* CreateNURBS () const; |
---|
190 | |
---|
191 | public: // without description |
---|
192 | |
---|
193 | G4TessellatedSolid(__void__&); |
---|
194 | // Fake default constructor for usage restricted to direct object |
---|
195 | // persistency for clients requiring preallocation of memory for |
---|
196 | // persistifiable objects. |
---|
197 | |
---|
198 | protected: // with description |
---|
199 | |
---|
200 | void DeleteObjects (); |
---|
201 | void CopyObjects (const G4TessellatedSolid &s); |
---|
202 | G4ThreeVectorList* |
---|
203 | CreateRotatedVertices(const G4AffineTransform& pTransform) const; |
---|
204 | // Create the List of transformed vertices in the format required |
---|
205 | // for G4VSolid:: ClipCrossSection and ClipBetweenSections. |
---|
206 | |
---|
207 | private: |
---|
208 | |
---|
209 | mutable G4Polyhedron* fpPolyhedron; |
---|
210 | |
---|
211 | std::vector<G4VFacet *> facets; |
---|
212 | std::set<G4VFacet *> extremeFacets; // Does all other facets lie |
---|
213 | // on or behind this surface? |
---|
214 | G4GeometryType geometryType; |
---|
215 | G4double cubicVolume; |
---|
216 | G4double surfaceArea; |
---|
217 | G4ThreeVectorList vertexList; |
---|
218 | G4double xMinExtent; |
---|
219 | G4double xMaxExtent; |
---|
220 | G4double yMinExtent; |
---|
221 | G4double yMaxExtent; |
---|
222 | G4double zMinExtent; |
---|
223 | G4double zMaxExtent; |
---|
224 | G4bool solidClosed; |
---|
225 | |
---|
226 | G4double dirTolerance; |
---|
227 | G4ThreeVector randir[20]; |
---|
228 | G4int maxTries; |
---|
229 | }; |
---|
230 | |
---|
231 | #endif |
---|