2// ********************************************************************
3// * License and Disclaimer *
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. *
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. *
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// ********************************************************************
26// class G4ReplicaNavigation Inline implementation
28// --------------------------------------------------------------------
30// ********************************************************************
32// ********************************************************************
36G4ReplicaNavigation::VoxelLocate( const G4SmartVoxelHeader* pHead,
37 const G4ThreeVector& localPoint,
38 const G4int blocked ) const
40 EAxis targetHeaderAxis;
42 G4double targetHeaderMin, targetHeaderMax;
43 G4double targetHeaderNodeWidth, targetNodePos;
44 G4int targetHeaderNoSlices, targetNodeNo;
46 targetHeaderAxis = pHead->GetAxis();
47 targetHeaderNoSlices = G4int(pHead->GetNoSlices());
48 targetHeaderMin = pHead->GetMinExtent();
49 targetHeaderMax = pHead->GetMaxExtent();
50 targetHeaderNodeWidth = ( targetHeaderMax-targetHeaderMin )
51 / targetHeaderNoSlices;
53 switch (targetHeaderAxis)
56 coord = localPoint.x();
59 coord = localPoint.y();
62 coord = localPoint.z();
65 coord = localPoint.perp();
68 coord = localPoint.phi();
69 if ( (coord<0) && (coord<targetHeaderMin) ) coord += CLHEP::twopi;
75 targetNodePos = (coord-targetHeaderMin)/targetHeaderNodeWidth;
76 targetNodeNo = (G4int) targetNodePos;
78 if ( targetNodeNo==blocked )
80 targetNodeNo = (targetNodePos-targetNodeNo<0.5)
81 ? targetNodeNo-1 : targetNodeNo+1;
83 // Do not need to check range: If on outer edge of zeroth
84 // voxel & it is blocked => should have exited mother
85 // (or similar) P.Kent
86 // assert(targetNodeNo>=0&&targetNodeNo<targetHeaderNoSlices);
88 if( (targetNodeNo<0) || (targetNodeNo>=targetHeaderNoSlices) )
91#ifdef G4DEBUG_NAVIGATION
92 std::ostringstream message;
93 message << "Voxel location failed:" << G4endl
94 << " (targetNodeNo>=0&&targetNodeNo<targetHeaderNoSlices) "
96 << " - targetNodeNo= " << targetNodeNo << G4endl
97 << " - Number of Slices = " << targetHeaderNoSlices;
98 G4Exception("G4ReplicaNavigation::VoxelLocate()",
99 "GeomNav1002", JustWarning, message);
101 // In the case of rotational symmetry and an extent over the
102 // whole 360 degrees, the above is not true and you can go from
103 // the last voxel to the zeroth and vice versa
104 // H.Boie, April 30, 2001
105 if ( (targetHeaderAxis==kPhi)
106 && (targetHeaderMin==0) && (targetHeaderMax==CLHEP::twopi) )
108 if ( targetNodeNo<0 )
109 targetNodeNo = targetHeaderNoSlices-1;
110 else if ( targetNodeNo>=targetHeaderNoSlices )
117 else if ( targetNodeNo>=targetHeaderNoSlices )
118 targetNodeNo = targetHeaderNoSlices-1;
124 // Rounding protection
126 if ( targetNodeNo<0 )
130 else if ( targetNodeNo>=targetHeaderNoSlices )
132 targetNodeNo = targetHeaderNoSlices-1;
138// ********************************************************************
140// ********************************************************************
144G4ReplicaNavigation::LevelLocate( G4NavigationHistory& history,
145 const G4VPhysicalVolume* blockedVol,
146 const G4int blockedNum,
147 const G4ThreeVector&, // globalPoint
148 const G4ThreeVector*, // globalDirection
149 const G4bool, // pLocatedOnEdge
150 G4ThreeVector& localPoint )
152 G4VPhysicalVolume *motherPhysical, *pPhysical;
153 G4LogicalVolume *motherLogical;
154 G4SmartVoxelHeader *motherVoxelHeader;
157 motherPhysical = history.GetTopVolume();
158 motherLogical = motherPhysical->GetLogicalVolume();
159 motherVoxelHeader = motherLogical->GetVoxelHeader();
160 pPhysical = motherLogical->GetDaughter(0);
162 if ( blockedVol==pPhysical )
164 nodeNo = VoxelLocate(motherVoxelHeader, localPoint, blockedNum);
168 nodeNo = VoxelLocate(motherVoxelHeader, localPoint);
171 ComputeTransformation(nodeNo, pPhysical, localPoint);
172 history.NewLevel(pPhysical, kReplica, nodeNo);
173 pPhysical->SetCopyNo(nodeNo);
178// ********************************************************************
179// SetPhiTransformation
180// ********************************************************************
184G4ReplicaNavigation::SetPhiTransformation( const G4double ang,
185 G4VPhysicalVolume* pVol ) const
189 if ( pVol != nullptr )
191 *pVol->GetRotation() = rm;
195// ********************************************************************
197// ********************************************************************
200G4int G4ReplicaNavigation::GetVerboseLevel() const
205// ********************************************************************
207// ********************************************************************
210void G4ReplicaNavigation::SetVerboseLevel(G4int level)
215// ********************************************************************
217// ********************************************************************
220void G4ReplicaNavigation::CheckMode(G4bool mode)