source: trunk/source/geometry/volumes/include/G4AssemblyVolume.hh@ 1175

Last change on this file since 1175 was 1058, checked in by garnier, 17 years ago

file release beta

File size: 8.7 KB
Line 
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: G4AssemblyVolume.hh,v 1.7 2006/06/29 18:56:51 gunter Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
29//
30//
31// Class G4AssemblyVolume
32//
33// Class description:
34//
35// G4AssemblyVolume is a helper class to make the build process of geometry
36// easier. It allows to combine several volumes together in an arbitrary way
37// in 3D space and then work with the result as with a single logical volume
38// for placement.
39// The resulting objects are independent copies of each of the assembled
40// logical volumes. The placements are not, however, bound one to each other
41// when placement is done. They are seen as independent physical volumes in
42// space.
43
44// Author: Radovan Chytracek, John Apostolakis, Gabriele Cosmo
45// Date: November 2000
46//
47// History:
48// March 2006, I.Hrivnacova - Extended to support assembly of assemblies
49// of volumes and reflections
50// ----------------------------------------------------------------------
51#ifndef G4_ASSEMBLYVOLUME_H
52#define G4_ASSEMBLYVOLUME_H
53
54#include <vector>
55
56#include "G4Transform3D.hh"
57#include "G4AssemblyTriplet.hh"
58
59class G4VPhysicalVolume;
60
61class G4AssemblyVolume
62{
63 public: // with description
64
65 G4AssemblyVolume();
66 G4AssemblyVolume( G4LogicalVolume* volume,
67 G4ThreeVector& translation,
68 G4RotationMatrix* rotation);
69 ~G4AssemblyVolume();
70 //
71 // Constructors & destructor.
72 // At destruction all the generated physical volumes and associated
73 // rotation matrices of the imprints will be destroyed.
74 //
75 // The rotation matrix passed as argument can be 0 (identity) or an address
76 // even of an object on the upper stack frame. During assembly imprint, a
77 // new matrix is created anyway and it is kept track of it so it can be
78 // automatically deleted later at the end of the application.
79 // This policy is adopted since user has no control on the way the
80 // rotations are combined.
81
82 void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
83 G4ThreeVector& translation,
84 G4RotationMatrix* rotation);
85 //
86 // Place the given volume 'pPlacedVolume' inside the assembly.
87 //
88 // The adopted approach:
89 //
90 // - Place it w.r.t. the assembly coordinate system.
91 // This step is applied to each of the participating volumes.
92 //
93 // The other possible approaches:
94 //
95 // - Place w.r.t. the firstly added volume.
96 // When placed the first, the virtual coordinate system becomes
97 // the coordinate system of the first one.
98 // Every next volume being added into the assembly will be placed
99 // w.r.t to the first one.
100 //
101 // - Place w.r.t the last placed volume.
102 // When placed the first, the virtual coordinate system becomes
103 // the coordinate system of the first one.
104 // Every next volume being added into the assembly will be placed
105 // w.r.t to the previous one.
106 //
107 // The rotation matrix passed as argument can be 0 (identity) or an address
108 // even of an object on the upper stack frame. During assembly imprint, a
109 // new matrix is created anyway and it is kept track of it so it can be
110 // automatically deleted later at the end of the application.
111 // This policy is adopted since user has no control on the way the
112 // rotations are combined.
113
114 void AddPlacedVolume( G4LogicalVolume* pPlacedVolume,
115 G4Transform3D& transformation);
116 //
117 // The same as previous, but takes complete 3D transformation in space
118 // as its argument.
119
120 void AddPlacedAssembly( G4AssemblyVolume* pAssembly,
121 G4Transform3D& transformation);
122 //
123 // The same as previous AddPlacedVolume(), but takes an assembly volume
124 // as its argument.
125
126 void AddPlacedAssembly( G4AssemblyVolume* pAssembly,
127 G4ThreeVector& translation,
128 G4RotationMatrix* rotation);
129 //
130 // The same as above AddPlacedVolume(), but takes an assembly volume
131 // as its argument with translation and rotation.
132
133 void MakeImprint( G4LogicalVolume* pMotherLV,
134 G4ThreeVector& translationInMother,
135 G4RotationMatrix* pRotationInMother,
136 G4int copyNumBase = 0,
137 G4bool surfCheck = false );
138 //
139 // Creates instance of an assembly volume inside the given mother volume.
140
141 void MakeImprint( G4LogicalVolume* pMotherLV,
142 G4Transform3D& transformation,
143 G4int copyNumBase = 0,
144 G4bool surfCheck = false );
145 //
146 // The same as previous Imprint() method, but takes complete 3D
147 // transformation in space as its argument.
148
149 inline std::vector<G4VPhysicalVolume*>::iterator GetVolumesIterator();
150 inline unsigned int TotalImprintedVolumes() const;
151 //
152 // Methods to access the physical volumes imprinted with the assembly.
153
154 unsigned int GetImprintsCount() const;
155 //
156 // Return the number of made imprints.
157
158 unsigned int GetInstanceCount() const;
159 //
160 // Return the number of existing instance of G4AssemblyVolume class.
161
162 unsigned int GetAssemblyID() const;
163 //
164 // Return instance number of this concrete object.
165
166 protected:
167
168 void SetInstanceCount( unsigned int value );
169 void SetAssemblyID( unsigned int value );
170
171 void InstanceCountPlus();
172 void InstanceCountMinus();
173
174 void SetImprintsCount( unsigned int value );
175 void ImprintsCountPlus();
176 void ImprintsCountMinus();
177 //
178 // Internal counting mechanism, used to compute unique the names of
179 // physical volumes created by MakeImprint() methods.
180
181 private:
182
183 void MakeImprint( G4AssemblyVolume* pAssembly,
184 G4LogicalVolume* pMotherLV,
185 G4Transform3D& transformation,
186 G4int copyNumBase = 0,
187 G4bool surfCheck = false );
188 //
189 // Function for placement of the given assembly in the given mother
190 // (called recursively if the assembly contains an assembly).
191
192 private:
193
194 std::vector<G4AssemblyTriplet> fTriplets;
195 //
196 // Participating volumes represented as a vector of
197 // <logical volume, translation, rotation>.
198
199 std::vector<G4VPhysicalVolume*> fPVStore;
200 //
201 // We need to keep list of physical volumes created by MakeImprint() method
202 // in order to be able to cleanup the objects when not needed anymore.
203 // This requires the user to keep assembly objects in memory during the
204 // whole job or during the life-time of G4Navigator, logical volume store
205 // and physical volume store keep pointers to physical volumes generated by
206 // the assembly volume.
207 // When an assembly object is about to die it will destroy all its
208 // generated physical volumes and rotation matrices as well !
209
210 unsigned int fImprintsCounter;
211 //
212 // Number of imprints of the given assembly volume.
213
214 static unsigned int fsInstanceCounter;
215 //
216 // Class instance counter.
217
218 unsigned int fAssemblyID;
219 //
220 // Assembly object ID derived from instance counter at construction time.
221
222};
223
224#include "G4AssemblyVolume.icc"
225
226#endif // G4_ASSEMBLYVOLUME_H
Note: See TracBrowser for help on using the repository browser.