Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4VPhysicalVolume.cc
Go to the documentation of this file.
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: G4VPhysicalVolume.cc 100428 2016-10-21 12:59:37Z gcosmo $
28 //
29 //
30 // class G4VPhysicalVolume Implementation
31 //
32 // --------------------------------------------------------------------
33 
34 #include "G4VPhysicalVolume.hh"
35 
36 #include "G4PhysicalVolumeStore.hh"
37 #include "G4LogicalVolume.hh"
38 
39 // This new field helps to use the class G4PVManager
40 //
42 
43 // These macros change the references to fields that are now encapsulated
44 // in the class G4PVData.
45 //
46 #define G4MT_rot ((subInstanceManager.offset[instanceID]).frot)
47 #define G4MT_trans ((subInstanceManager.offset[instanceID]).ftrans)
48 #define G4MT_pvdata (subInstanceManager.offset[instanceID])
49 
50 // Constructor: init parameters and register in Store
51 //
53  const G4ThreeVector &tlate,
54  const G4String& pName,
55  G4LogicalVolume* pLogical,
57  : flogical(pLogical),
58  fname(pName), flmother(0)
59 {
61 
62  this->SetRotation( pRot ); // G4MT_rot = pRot;
63  this->SetTranslation( tlate ); // G4MT_trans = tlate;
64 
65  // Initialize 'Shadow' data structure - for use by object persistency
66  pvdata = new G4PVData();
67  pvdata->frot = pRot;
68  pvdata->ftrans = G4ThreeVector(tlate);
69 
71 }
72 
73 // Fake default constructor - sets only member data and allocates memory
74 // for usage restricted to object persistency.
75 //
77  : flogical(0), fname(""), flmother(0), pvdata(0)
78 {
79  // Register to store
80  //
82 
84 }
85 
86 // Destructor - remove from Store
87 //
89 {
90  delete pvdata;
92 }
93 
94 // This method is similar to the constructor. It is used by each worker
95 // thread to achieve the same effect as that of the master thread exept
96 // to register the new created instance. This method is invoked explicitly.
97 // It does not create a new G4VPhysicalVolume instance.
98 // It only assign the value for the fields encapsulated by the class G4PVData.
99 //
102  G4RotationMatrix *pRot,
103  const G4ThreeVector &tlate)
104 {
106 
107  this->SetRotation( pRot ); // G4MT_rot = pRot;
108  this->SetTranslation( tlate ); // G4MT_trans = tlate;
109  // G4PhysicalVolumeStore::Register(this);
110 }
111 
112 // This method is similar to the destructor. It is used by each worker
113 // thread to achieve the partial effect as that of the master thread.
114 // For G4VPhysicalVolume instances, nothing more to do here.
115 //
117 {
118 }
119 
120 // Returns the private data instance manager.
121 //
123 {
124  return subInstanceManager;
125 }
126 
128 {
129  return 1;
130 }
131 
133 {
134  return G4MT_trans;
135 }
136 
138 {
139  G4MT_trans=vec;
140 }
141 
143 {
144  return G4MT_rot;
145 }
146 
148 {
149  return G4MT_rot;
150 }
151 
153 {
154  G4MT_rot=pRot;
155 }
156 
158 {
159  static G4RotationMatrix aRotM;
160  static G4RotationMatrix IdentityRM;
161 
162  G4RotationMatrix* retval = &IdentityRM;
163 
164  // Insure against frot being a null pointer
165  if(this->GetRotation())
166  {
167  aRotM = GetRotation()->inverse();
168  retval= &aRotM;
169  }
170  return retval;
171 }
172 
174 {
175  G4RotationMatrix aRotM; // Initialised to identity
176 
177  // Insure against G4MT_rot being a null pointer
178  if(G4MT_rot)
179  {
180  aRotM= G4MT_rot->inverse();
181  }
182  return aRotM;
183 }
184 
186 {
187  return G4MT_trans;
188 }
189 
191 {
192  return G4MT_rot;
193 }
194 
196 {
197  return -G4MT_trans;
198 }
199 
200 // Only implemented for placed and parameterised volumes.
201 // Not required for replicas.
202 //
204 {
205  return false;
206 }
virtual ~G4VPhysicalVolume()
G4ThreeVector GetFrameTranslation() const
G4VPhysicalVolume(G4RotationMatrix *pRot, const G4ThreeVector &tlate, const G4String &pName, G4LogicalVolume *pLogical, G4VPhysicalVolume *pMother)
CLHEP::Hep3Vector G4ThreeVector
G4ThreeVector ftrans
static void Register(G4VPhysicalVolume *pSolid)
const G4RotationMatrix * GetRotation() const
G4int CreateSubInstance()
int G4int
Definition: G4Types.hh:78
static G4GEOM_DLL G4PVManager subInstanceManager
static void DeRegister(G4VPhysicalVolume *pSolid)
HepRotation inverse() const
void SetRotation(G4RotationMatrix *)
void InitialiseWorker(G4VPhysicalVolume *pMasterObject, G4RotationMatrix *pRot, const G4ThreeVector &tlate)
void TerminateWorker(G4VPhysicalVolume *pMasterObject)
static const G4PVManager & GetSubInstanceManager()
bool G4bool
Definition: G4Types.hh:79
void SlaveCopySubInstanceArray()
G4RotationMatrix GetObjectRotationValue() const
void SetTranslation(const G4ThreeVector &v)
#define G4MT_trans
#define G4MT_rot
const G4ThreeVector & GetTranslation() const
const G4RotationMatrix * GetFrameRotation() const
virtual G4int GetMultiplicity() const
G4RotationMatrix * GetObjectRotation() const
G4ThreeVector GetObjectTranslation() const
double G4double
Definition: G4Types.hh:76
virtual G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true, G4int errMax=1)
G4RotationMatrix * frot