Geant4  10.02.p02
G4NavigationLevelRep.icc
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: G4NavigationLevelRep.icc 87590 2014-12-11 14:30:29Z gcosmo $
28 //
29 // 1 October 1997 J.Apostolakis Initial version.
30 //
31 // ----------------------------------------------------------------------
32 
33 extern G4GEOM_DLL G4ThreadLocal
34 G4Allocator<G4NavigationLevelRep> *aNavigLevelRepAllocator;
35 
36 // Constructors
37 //--------------
38 
39 inline
40 G4NavigationLevelRep::G4NavigationLevelRep( G4VPhysicalVolume* pPhysVol,
41  const G4AffineTransform& afTransform,
42  EVolume volTp,
43  G4int repNo )
44  : sTransform(afTransform),
45  sPhysicalVolumePtr(pPhysVol),
46  sReplicaNo(repNo),
47  sVolumeType(volTp),
48  fCountRef(1)
49 {
50 }
51 
52 inline
53 G4NavigationLevelRep::G4NavigationLevelRep()
54  : sTransform(),
55  sPhysicalVolumePtr(0),
56  sReplicaNo(-1),
57  sVolumeType(kReplica),
58  fCountRef(1)
59 {
60 }
61 
62 inline
63 G4NavigationLevelRep::G4NavigationLevelRep( G4VPhysicalVolume* pPhysVol,
64  const G4AffineTransform& levelAbove,
65  const G4AffineTransform& relativeCurrent,
66  EVolume volTp,
67  G4int repNo )
68  : sPhysicalVolumePtr(pPhysVol),
69  sReplicaNo(repNo),
70  sVolumeType(volTp),
71  fCountRef(1)
72 {
73  sTransform.InverseProduct( levelAbove, relativeCurrent );
74 }
75 
76 inline
77 G4NavigationLevelRep::G4NavigationLevelRep( G4NavigationLevelRep& right )
78  : sTransform(right.sTransform),
79  sPhysicalVolumePtr(right.sPhysicalVolumePtr),
80  sReplicaNo(right.sReplicaNo),
81  sVolumeType(right.sVolumeType),
82  fCountRef(1)
83 {
84 }
85 
86 // Destructor
87 //--------------
88 
89 inline
90 G4NavigationLevelRep::~G4NavigationLevelRep()
91 {
92 #ifdef DEBUG_NAVIG_LEVEL
93  if(fCountRef>0)
94  {
95  G4Exception("G4NavigationLevelRep::~G4NavigationLevelRep()",
96  "GeomVol0003", FatalException,
97  "Deletion of data-level object with positive reference count.");
98  }
99 #endif
100 }
101 
102 // Operators
103 // --------------
104 
105 inline
106 G4NavigationLevelRep&
107 G4NavigationLevelRep::operator=( const G4NavigationLevelRep &right )
108 {
109  if ( &right != this )
110  {
111  sTransform = right.sTransform;
112  sPhysicalVolumePtr = right.sPhysicalVolumePtr;
113  sVolumeType = right.sVolumeType;
114  sReplicaNo = right.sReplicaNo;
115  fCountRef = right.fCountRef;
116  }
117  return *this;
118 }
119 
120 // Accessors
121 // --------------
122 
123 inline
124 G4VPhysicalVolume*
125 G4NavigationLevelRep::GetPhysicalVolume()
126 {
127  return sPhysicalVolumePtr;
128 }
129 
130 inline
131 const G4AffineTransform&
132 G4NavigationLevelRep::GetTransform() const
133 {
134  return sTransform;
135 }
136 
137 inline
138 const G4AffineTransform*
139 G4NavigationLevelRep::GetTransformPtr() const
140 {
141  return &sTransform;
142 }
143 
144 inline
145 EVolume G4NavigationLevelRep::GetVolumeType() const
146 {
147  return sVolumeType;
148 }
149 
150 inline
151 G4int G4NavigationLevelRep::GetReplicaNo() const
152 {
153  return sReplicaNo;
154 }
155 
156 inline
157 void G4NavigationLevelRep::AddAReference()
158 {
159  ++fCountRef;
160 }
161 
162 inline
163 G4bool G4NavigationLevelRep::RemoveAReference()
164 {
165  return( --fCountRef <= 0 );
166 }
167 
168 // There is no provision that this class is subclassed.
169 // If it is subclassed & new data members are added then the
170 // following "new" & "delete" will fail and give errors.
171 //
172 inline
173 void* G4NavigationLevelRep::operator new(size_t)
174 {
175  if (!aNavigLevelRepAllocator)
176  {
177  aNavigLevelRepAllocator = new G4Allocator<G4NavigationLevelRep>;
178  }
179  return (void *) aNavigLevelRepAllocator->MallocSingle();
180 }
181 
182 inline
183 void G4NavigationLevelRep::operator delete(void *aLevelRep)
184 {
185  aNavigLevelRepAllocator->FreeSingle((G4NavigationLevelRep *) aLevelRep);
186 }