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