| 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: G4VoxelNavigation.icc,v 1.4 2006/06/29 18:36:30 gunter Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-03 $
|
|---|
| 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | // class G4VoxelNavigation Inline implementation
|
|---|
| 32 | //
|
|---|
| 33 | // --------------------------------------------------------------------
|
|---|
| 34 |
|
|---|
| 35 | // ********************************************************************
|
|---|
| 36 | // VoxelLocate
|
|---|
| 37 | // ********************************************************************
|
|---|
| 38 | //
|
|---|
| 39 | inline
|
|---|
| 40 | G4SmartVoxelNode*
|
|---|
| 41 | G4VoxelNavigation::VoxelLocate( G4SmartVoxelHeader* pHead,
|
|---|
| 42 | const G4ThreeVector& localPoint )
|
|---|
| 43 | {
|
|---|
| 44 | G4SmartVoxelHeader *targetVoxelHeader=pHead;
|
|---|
| 45 | G4SmartVoxelNode *targetVoxelNode=0;
|
|---|
| 46 | G4SmartVoxelProxy *sampleProxy;
|
|---|
| 47 | EAxis targetHeaderAxis;
|
|---|
| 48 | G4double targetHeaderMin, targetHeaderNodeWidth;
|
|---|
| 49 | G4int targetHeaderNoSlices, targetNodeNo;
|
|---|
| 50 |
|
|---|
| 51 | fVoxelDepth = 0;
|
|---|
| 52 |
|
|---|
| 53 | while ( !targetVoxelNode )
|
|---|
| 54 | {
|
|---|
| 55 | targetHeaderAxis = targetVoxelHeader->GetAxis();
|
|---|
| 56 | targetHeaderNoSlices = targetVoxelHeader->GetNoSlices();
|
|---|
| 57 | targetHeaderMin = targetVoxelHeader->GetMinExtent();
|
|---|
| 58 | targetHeaderNodeWidth = (targetVoxelHeader->GetMaxExtent()-targetHeaderMin)
|
|---|
| 59 | / targetHeaderNoSlices;
|
|---|
| 60 | targetNodeNo = G4int( (localPoint(targetHeaderAxis)-targetHeaderMin)
|
|---|
| 61 | / targetHeaderNodeWidth);
|
|---|
| 62 | // Rounding protection
|
|---|
| 63 | //
|
|---|
| 64 | if ( targetNodeNo<0 )
|
|---|
| 65 | {
|
|---|
| 66 | targetNodeNo = 0;
|
|---|
| 67 | }
|
|---|
| 68 | else if ( targetNodeNo>=targetHeaderNoSlices )
|
|---|
| 69 | {
|
|---|
| 70 | targetNodeNo = targetHeaderNoSlices-1;
|
|---|
| 71 | }
|
|---|
| 72 | // Stack info for stepping
|
|---|
| 73 | //
|
|---|
| 74 | fVoxelAxisStack[fVoxelDepth] = targetHeaderAxis;
|
|---|
| 75 | fVoxelNoSlicesStack[fVoxelDepth] = targetHeaderNoSlices;
|
|---|
| 76 | fVoxelSliceWidthStack[fVoxelDepth] = targetHeaderNodeWidth;
|
|---|
| 77 | fVoxelNodeNoStack[fVoxelDepth] = targetNodeNo;
|
|---|
| 78 | fVoxelHeaderStack[fVoxelDepth] = targetVoxelHeader;
|
|---|
| 79 | sampleProxy = targetVoxelHeader->GetSlice(targetNodeNo);
|
|---|
| 80 |
|
|---|
| 81 | if ( sampleProxy->IsNode() )
|
|---|
| 82 | {
|
|---|
| 83 | targetVoxelNode = sampleProxy->GetNode();
|
|---|
| 84 | }
|
|---|
| 85 | else
|
|---|
| 86 | {
|
|---|
| 87 | targetVoxelHeader = sampleProxy->GetHeader();
|
|---|
| 88 | fVoxelDepth++;
|
|---|
| 89 | }
|
|---|
| 90 | }
|
|---|
| 91 | fVoxelNode = targetVoxelNode;
|
|---|
| 92 | return targetVoxelNode;
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | // ********************************************************************
|
|---|
| 96 | // LevelLocate
|
|---|
| 97 | // ********************************************************************
|
|---|
| 98 | //
|
|---|
| 99 | inline
|
|---|
| 100 | G4bool
|
|---|
| 101 | G4VoxelNavigation::LevelLocate( G4NavigationHistory& history,
|
|---|
| 102 | const G4VPhysicalVolume* blockedVol,
|
|---|
| 103 | const G4int,
|
|---|
| 104 | const G4ThreeVector& globalPoint,
|
|---|
| 105 | const G4ThreeVector* globalDirection,
|
|---|
| 106 | const G4bool pLocatedOnEdge,
|
|---|
| 107 | G4ThreeVector& localPoint )
|
|---|
| 108 | {
|
|---|
| 109 | G4SmartVoxelHeader *targetVoxelHeader;
|
|---|
| 110 | G4SmartVoxelNode *targetVoxelNode;
|
|---|
| 111 | G4VPhysicalVolume *targetPhysical, *samplePhysical;
|
|---|
| 112 | G4LogicalVolume *targetLogical;
|
|---|
| 113 | G4VSolid *sampleSolid;
|
|---|
| 114 | G4ThreeVector samplePoint;
|
|---|
| 115 | G4int targetNoDaughters;
|
|---|
| 116 |
|
|---|
| 117 | targetPhysical = history.GetTopVolume();
|
|---|
| 118 | targetLogical = targetPhysical->GetLogicalVolume();
|
|---|
| 119 | targetVoxelHeader = targetLogical->GetVoxelHeader();
|
|---|
| 120 |
|
|---|
| 121 | // Find the voxel containing the point
|
|---|
| 122 | //
|
|---|
| 123 | targetVoxelNode = VoxelLocate(targetVoxelHeader,localPoint);
|
|---|
| 124 |
|
|---|
| 125 | targetNoDaughters=targetVoxelNode->GetNoContained();
|
|---|
| 126 | if ( targetNoDaughters==0 ) return false;
|
|---|
| 127 |
|
|---|
| 128 | //
|
|---|
| 129 | // Search daughters in volume
|
|---|
| 130 | //
|
|---|
| 131 |
|
|---|
| 132 | for ( register int sampleNo=targetNoDaughters-1; sampleNo>=0; sampleNo-- )
|
|---|
| 133 | {
|
|---|
| 134 | samplePhysical = targetLogical->
|
|---|
| 135 | GetDaughter(targetVoxelNode->GetVolume(sampleNo));
|
|---|
| 136 | if ( samplePhysical!=blockedVol )
|
|---|
| 137 | {
|
|---|
| 138 | // Setup history
|
|---|
| 139 | //
|
|---|
| 140 | history.NewLevel(samplePhysical, kNormal, samplePhysical->GetCopyNo());
|
|---|
| 141 | sampleSolid = samplePhysical->GetLogicalVolume()->GetSolid();
|
|---|
| 142 | samplePoint = history.GetTopTransform().TransformPoint(globalPoint);
|
|---|
| 143 |
|
|---|
| 144 | if( G4AuxiliaryNavServices::CheckPointOnSurface(sampleSolid,
|
|---|
| 145 | samplePoint,
|
|---|
| 146 | globalDirection,
|
|---|
| 147 | history.GetTopTransform(),
|
|---|
| 148 | pLocatedOnEdge) )
|
|---|
| 149 | {
|
|---|
| 150 | // Enter this daughter
|
|---|
| 151 | //
|
|---|
| 152 | localPoint = samplePoint;
|
|---|
| 153 | return true;
|
|---|
| 154 | }
|
|---|
| 155 | else
|
|---|
| 156 | {
|
|---|
| 157 | history.BackLevel();
|
|---|
| 158 | }
|
|---|
| 159 | }
|
|---|
| 160 | }
|
|---|
| 161 | return false;
|
|---|
| 162 | }
|
|---|
| 163 |
|
|---|
| 164 | // ********************************************************************
|
|---|
| 165 | // GetVerboseLevel
|
|---|
| 166 | // ********************************************************************
|
|---|
| 167 | //
|
|---|
| 168 | inline
|
|---|
| 169 | G4int G4VoxelNavigation::GetVerboseLevel() const
|
|---|
| 170 | {
|
|---|
| 171 | return fVerbose;
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | // ********************************************************************
|
|---|
| 175 | // SetVerboseLevel
|
|---|
| 176 | // ********************************************************************
|
|---|
| 177 | //
|
|---|
| 178 | inline
|
|---|
| 179 | void G4VoxelNavigation::SetVerboseLevel(G4int level)
|
|---|
| 180 | {
|
|---|
| 181 | fVerbose = level;
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | // ********************************************************************
|
|---|
| 185 | // CheckMode
|
|---|
| 186 | // ********************************************************************
|
|---|
| 187 | //
|
|---|
| 188 | inline
|
|---|
| 189 | void G4VoxelNavigation::CheckMode(G4bool mode)
|
|---|
| 190 | {
|
|---|
| 191 | fCheck = mode;
|
|---|
| 192 | }
|
|---|