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

Last change on this file since 1337 was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 10.8 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.5 2010/04/13 07:19:01 gcosmo Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
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    void Reset(); 
184      // Resets maps of constituent and reflected volumes.
185      // To be used exclusively when volumes are removed from the stores.
186
187  protected: 
188
189    G4ReflectionFactory();
190      // Protected singleton constructor.
191
192    G4ReflectionFactory(const G4ReflectionFactory&);
193    G4ReflectionFactory& operator=(const G4ReflectionFactory&);
194      // Disabled copy constructor and assignment operator.
195 
196  private: 
197
198    G4LogicalVolume*   ReflectLV(G4LogicalVolume* LV, G4bool surfCheck=false);
199      // Gets/creates the reflected solid and logical volume
200      // and copies + transforms LV daughters.
201
202    G4LogicalVolume*   CreateReflectedLV(G4LogicalVolume* LV);
203      // Creates the reflected solid and logical volume
204      // and add the logical volumes pair in the maps.
205
206    void ReflectDaughters(G4LogicalVolume* LV,
207                          G4LogicalVolume* refLV, G4bool surfCheck=false);
208      // Reflects daughters recursively.
209
210    void ReflectPVPlacement(G4VPhysicalVolume* PV,
211                            G4LogicalVolume* refLV, G4bool surfCheck=false);
212      // Copies and transforms daughter of PVPlacement type of
213      // a constituent volume into a reflected volume.
214
215    void ReflectPVReplica(G4VPhysicalVolume* PV, G4LogicalVolume* refLV);
216      // Copies and transforms daughter of PVReplica type of
217      // a constituent volume into a reflected volume.
218
219    void ReflectPVDivision(G4VPhysicalVolume* PV, G4LogicalVolume* refLV);
220      // Copies and transforms daughter of PVDivision type of
221      // a constituent volume into a reflected volume.
222
223    void ReflectPVParameterised(G4VPhysicalVolume* PV,
224                                G4LogicalVolume* refLV, G4bool surfCheck=false);
225      // Not implemented yet.
226      // Should copy and transform daughter of PVReplica type of
227      // a constituent volume into a reflected volume.
228
229    G4bool IsReflection(const G4Scale3D& scale) const;
230      // Returns true if the scale is negative, false otherwise.
231
232    void CheckScale(const G4Scale3D& scale) const;
233      // Checks if scale correspond to fScale, if not gives exception.
234
235    G4VPVDivisionFactory* GetPVDivisionFactory() const;
236      // Checks if the division factory is instanciated,
237      // if not gives exception.
238
239    void PrintConstituentLVMap(); 
240      // Temporary - for debugging purpose.
241 
242  private:
243
244    static G4ReflectionFactory* fInstance;
245    static const G4String       fDefaultNameExtension;
246    static const G4Scale3D      fScale;
247    G4double                    fScalePrecision;
248
249    G4int              fVerboseLevel;
250    G4String           fNameExtension;
251    G4ReflectedVolumesMap  fConstituentLVMap;
252    G4ReflectedVolumesMap  fReflectedLVMap;
253};
254
255#endif
Note: See TracBrowser for help on using the repository browser.