source: trunk/source/geometry/volumes/include/G4ReflectionFactory.hh@ 1193

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

file release beta

File size: 10.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: G4ReflectionFactory.hh,v 1.4 2008/11/13 09:33:20 gcosmo Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
29//
30//
31// class G4ReflectionFactory
32//
33// Class description:
34//
35// Class providing functions for volumes placements with a general
36// transfomation that can contain reflection.
37// Reflection is then applied to a solid: a new G4ReflectedSolid
38// instance is created and is placed with a transformation containing
39// pure rotation and translation only.
40// The pair of constituent and reflected logical volumes is
41// considered as a generalized logical volume that is addressed
42// by user specifying the constituent logical volume.
43//
44// Decomposition of a general transformation that can include reflection
45// in a "reflection-free" transformation:
46//
47// x(inM') = TG*x(inM) TG - general transformation
48// = T*(R*x(inM)) T - "reflection-free" transformation
49// = T* x(inReflM)
50//
51// Daughters transformation:
52// When a volume V containing daughter D with transformation TD
53// is placed in mother M with a general tranformation TGV,
54// the TGV is decomposed. New reflected volume ReflV containing
55// a new daughter ReflD with reflected transformation ReflTD is created:
56//
57// x(inV) = TD * x(inD);
58// x(inM) = TGV * x(inV)
59// = TV * R * x(inV)
60// = TV * R * TD * x(inD)
61// = TV * R*TD*R-1 * R*x(inD)
62// = TV * ReflTD * x(inReflD)
63
64// Author: Ivana Hrivnacova, 16.10.2001 (Ivana.Hrivnacova@cern.ch)
65// --------------------------------------------------------------------
66#ifndef G4_REFLECTION_FACTORY_HH
67#define G4_REFLECTION_FACTORY_HH
68
69#include "G4Types.hh"
70#include "G4Transform3D.hh"
71#include "geomdefs.hh"
72
73#include <map>
74
75class G4VPhysicalVolume;
76class G4LogicalVolume;
77class G4VSolid;
78class G4VPVDivisionFactory;
79
80typedef std::pair<G4VPhysicalVolume*,
81 G4VPhysicalVolume*> G4PhysicalVolumesPair;
82typedef std::map<G4LogicalVolume*, G4LogicalVolume*,
83 std::less<G4LogicalVolume*> > G4ReflectedVolumesMap;
84
85class G4ReflectionFactory
86{
87 typedef G4ReflectedVolumesMap::const_iterator LogicalVolumesMapIterator;
88
89 public: // with description
90
91 virtual ~G4ReflectionFactory();
92 // Virtual destructor.
93
94 static G4ReflectionFactory* Instance();
95 // Gets pointer to the instance of the singleton.
96
97 G4PhysicalVolumesPair Place(const G4Transform3D& transform3D,
98 const G4String& name,
99 G4LogicalVolume* LV,
100 G4LogicalVolume* motherLV,
101 G4bool isMany,
102 G4int copyNo,
103 G4bool surfCheck=false);
104 // Evaluates the passed transformation; if it contains reflection
105 // it performs its decomposition, creates new reflected solid and
106 // logical volume (or retrieves them from a map if the reflected
107 // objects were already created), transforms the daughters (if present)
108 // and place it in the given mother.
109 // The result is a pair of physical volumes;
110 // the second physical volume is a placement in a reflected mother
111 // or 0 if mother LV was not reflected.
112
113 G4PhysicalVolumesPair Replicate(const G4String& name,
114 G4LogicalVolume* LV,
115 G4LogicalVolume* motherLV,
116 EAxis axis,
117 G4int nofReplicas,
118 G4double width,
119 G4double offset=0);
120 // Creates replica in the given mother.
121 // The result is a pair of physical volumes;
122 // the second physical volume is a replica in a reflected mother
123 // or 0 if mother LV was not reflected.
124
125 G4PhysicalVolumesPair Divide(const G4String& name,
126 G4LogicalVolume* LV,
127 G4LogicalVolume* motherLV,
128 EAxis axis,
129 G4int nofDivisions,
130 G4double width,
131 G4double offset);
132 G4PhysicalVolumesPair Divide(const G4String& name,
133 G4LogicalVolume* LV,
134 G4LogicalVolume* motherLV,
135 EAxis axis,
136 G4int nofDivisions,
137 G4double offset);
138 G4PhysicalVolumesPair Divide(const G4String& name,
139 G4LogicalVolume* LV,
140 G4LogicalVolume* motherLV,
141 EAxis axis,
142 G4double width,
143 G4double offset);
144 // Creates division in the given mother.
145 // The result is a pair of physical volumes;
146 // the second physical volume is a division in a reflected mother
147 // or 0 if mother LV was not reflected.
148
149 void SetVerboseLevel(G4int verboseLevel);
150 G4int GetVerboseLevel() const;
151 // Sets/gets verbosity level.
152
153 void SetVolumesNameExtension(const G4String& nameExtension);
154 const G4String& GetVolumesNameExtension() const;
155 // Returns the name extension for the reflected solids
156 // and logical volumes.
157
158 void SetScalePrecision(G4double scaleValue);
159 G4double GetScalePrecision() const;
160 // Sets/gets precision factor for the scale consistency check
161 // The default value is set to 10*kCarTolerance.
162
163 G4LogicalVolume* GetConstituentLV(G4LogicalVolume* reflLV) const;
164 // Returns the consituent volume of the given reflected volume,
165 // 0 if the given reflected volume was not found.
166
167 G4LogicalVolume* GetReflectedLV(G4LogicalVolume* lv) const;
168 // Returns the reflected volume of the given consituent volume,
169 // 0 if the given volume was not reflected.
170
171 G4bool IsConstituent(G4LogicalVolume* lv) const;
172 // Returns true if the given volume has been already reflected
173 // (is in the map of constituent volumes).
174
175 G4bool IsReflected(G4LogicalVolume* lv) const;
176 // Returns true if the given volume is a reflected volume
177 // (is in the map reflected volumes).
178
179 const G4ReflectedVolumesMap& GetReflectedVolumesMap() const;
180 // Returns a handle to the internal map of volumes which have
181 // been reflected, after that placement or replication is performed.
182
183 protected:
184
185 G4ReflectionFactory();
186 // Protected singleton constructor.
187
188 G4ReflectionFactory(const G4ReflectionFactory&);
189 G4ReflectionFactory& operator=(const G4ReflectionFactory&);
190 // Disabled copy constructor and assignment operator.
191
192 private:
193
194 G4LogicalVolume* ReflectLV(G4LogicalVolume* LV, G4bool surfCheck=false);
195 // Gets/creates the reflected solid and logical volume
196 // and copies + transforms LV daughters.
197
198 G4LogicalVolume* CreateReflectedLV(G4LogicalVolume* LV);
199 // Creates the reflected solid and logical volume
200 // and add the logical volumes pair in the maps.
201
202 void ReflectDaughters(G4LogicalVolume* LV,
203 G4LogicalVolume* refLV, G4bool surfCheck=false);
204 // Reflects daughters recursively.
205
206 void ReflectPVPlacement(G4VPhysicalVolume* PV,
207 G4LogicalVolume* refLV, G4bool surfCheck=false);
208 // Copies and transforms daughter of PVPlacement type of
209 // a constituent volume into a reflected volume.
210
211 void ReflectPVReplica(G4VPhysicalVolume* PV, G4LogicalVolume* refLV);
212 // Copies and transforms daughter of PVReplica type of
213 // a constituent volume into a reflected volume.
214
215 void ReflectPVDivision(G4VPhysicalVolume* PV, G4LogicalVolume* refLV);
216 // Copies and transforms daughter of PVDivision type of
217 // a constituent volume into a reflected volume.
218
219 void ReflectPVParameterised(G4VPhysicalVolume* PV,
220 G4LogicalVolume* refLV, G4bool surfCheck=false);
221 // Not implemented yet.
222 // Should copy and transform daughter of PVReplica type of
223 // a constituent volume into a reflected volume.
224
225 G4bool IsReflection(const G4Scale3D& scale) const;
226 // Returns true if the scale is negative, false otherwise.
227
228 void CheckScale(const G4Scale3D& scale) const;
229 // Checks if scale correspond to fScale, if not gives exception.
230
231 G4VPVDivisionFactory* GetPVDivisionFactory() const;
232 // Checks if the division factory is instanciated,
233 // if not gives exception.
234
235 void PrintConstituentLVMap();
236 // Temporary - for debugging purpose.
237
238 private:
239
240 static G4ReflectionFactory* fInstance;
241 static const G4String fDefaultNameExtension;
242 static const G4Scale3D fScale;
243 G4double fScalePrecision;
244
245 G4int fVerboseLevel;
246 G4String fNameExtension;
247 G4ReflectedVolumesMap fConstituentLVMap;
248 G4ReflectedVolumesMap fReflectedLVMap;
249};
250
251#endif
Note: See TracBrowser for help on using the repository browser.