Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4VoxelNavigation.icc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 // 
0026 // class G4VoxelNavigation Inline implementation
0027 //
0028 // --------------------------------------------------------------------
0029 
0030 // ********************************************************************
0031 // VoxelLocate
0032 // ********************************************************************
0033 //
0034 inline
0035 G4SmartVoxelNode*
0036 G4VoxelNavigation::VoxelLocate( G4SmartVoxelHeader* pHead,
0037                                 const G4ThreeVector& localPoint )
0038 {
0039   G4SmartVoxelHeader* targetVoxelHeader = pHead;
0040   G4SmartVoxelNode* targetVoxelNode = nullptr;
0041   G4SmartVoxelProxy* sampleProxy;
0042   EAxis targetHeaderAxis;
0043   G4double targetHeaderMin, targetHeaderNodeWidth;
0044   G4int targetHeaderNoSlices, targetNodeNo;
0045 
0046   fVoxelDepth = 0;
0047 
0048   while ( targetVoxelNode == nullptr )
0049   {
0050     targetHeaderAxis = targetVoxelHeader->GetAxis();
0051     targetHeaderNoSlices = G4int(targetVoxelHeader->GetNoSlices());
0052     targetHeaderMin = targetVoxelHeader->GetMinExtent();
0053     targetHeaderNodeWidth = (targetVoxelHeader->GetMaxExtent()-targetHeaderMin)
0054                           / targetHeaderNoSlices;
0055     targetNodeNo = G4int( (localPoint(targetHeaderAxis)-targetHeaderMin)
0056                           / targetHeaderNodeWidth);
0057     // Rounding protection
0058     //
0059     if ( targetNodeNo<0 )
0060     {
0061       targetNodeNo = 0;
0062     }
0063     else if ( targetNodeNo>=targetHeaderNoSlices )
0064     {
0065       targetNodeNo = targetHeaderNoSlices-1;
0066     }
0067     // Stack info for stepping
0068     //
0069     fVoxelAxisStack[fVoxelDepth] = targetHeaderAxis;
0070     fVoxelNoSlicesStack[fVoxelDepth] = targetHeaderNoSlices;
0071     fVoxelSliceWidthStack[fVoxelDepth] = targetHeaderNodeWidth;
0072     fVoxelNodeNoStack[fVoxelDepth] = targetNodeNo;
0073     fVoxelHeaderStack[fVoxelDepth] = targetVoxelHeader;
0074     sampleProxy = targetVoxelHeader->GetSlice(targetNodeNo);
0075 
0076     if ( sampleProxy->IsNode() )
0077     {
0078       targetVoxelNode = sampleProxy->GetNode();
0079     }
0080     else
0081     {
0082       targetVoxelHeader = sampleProxy->GetHeader();
0083       ++fVoxelDepth;
0084     }
0085   }
0086   fVoxelNode = targetVoxelNode;
0087   return targetVoxelNode;
0088 }
0089 
0090 // ********************************************************************
0091 // LevelLocate
0092 // ********************************************************************
0093 //
0094 inline
0095 G4bool
0096 G4VoxelNavigation::LevelLocate( G4NavigationHistory& history,
0097                           const G4VPhysicalVolume* blockedVol,
0098                           const G4int,
0099                           const G4ThreeVector& globalPoint,
0100                           const G4ThreeVector* globalDirection,
0101                           const G4bool pLocatedOnEdge, 
0102                                 G4ThreeVector& localPoint )
0103 {
0104   G4SmartVoxelHeader *targetVoxelHeader;
0105   G4SmartVoxelNode *targetVoxelNode;
0106   G4VPhysicalVolume *targetPhysical, *samplePhysical;
0107   G4LogicalVolume *targetLogical;
0108   G4VSolid *sampleSolid;
0109   G4ThreeVector samplePoint;
0110   G4int targetNoDaughters;
0111   
0112   targetPhysical = history.GetTopVolume();
0113   targetLogical = targetPhysical->GetLogicalVolume();
0114   targetVoxelHeader = targetLogical->GetVoxelHeader();
0115 
0116   // Find the voxel containing the point
0117   //
0118   targetVoxelNode = VoxelLocate(targetVoxelHeader,localPoint);
0119 
0120   targetNoDaughters = G4int(targetVoxelNode->GetNoContained());
0121   if ( targetNoDaughters==0 ) { return false; }
0122 
0123   //
0124   // Search daughters in volume
0125   //
0126 
0127   for ( auto sampleNo=targetNoDaughters-1; sampleNo>=0; sampleNo-- )
0128   {
0129     samplePhysical = targetLogical->
0130                      GetDaughter(targetVoxelNode->GetVolume(sampleNo));
0131     if ( samplePhysical!=blockedVol )
0132     {
0133       // Setup history
0134       //
0135       history.NewLevel(samplePhysical, kNormal, samplePhysical->GetCopyNo());
0136       sampleSolid = samplePhysical->GetLogicalVolume()->GetSolid();
0137       samplePoint = history.GetTopTransform().TransformPoint(globalPoint);
0138 
0139       if( G4AuxiliaryNavServices::CheckPointOnSurface(sampleSolid,
0140                                                       samplePoint,
0141                                                       globalDirection, 
0142                                                       history.GetTopTransform(),
0143                                                       pLocatedOnEdge) )
0144       {
0145         // Enter this daughter
0146         //
0147         localPoint = samplePoint;
0148         return true;
0149       }
0150       history.BackLevel();
0151     }
0152   }
0153   return false;
0154 }
0155 
0156 // ********************************************************************
0157 // GetVerboseLevel
0158 // ********************************************************************
0159 //
0160 inline
0161 G4int G4VoxelNavigation::GetVerboseLevel() const
0162 {
0163   return fLogger->GetVerboseLevel();
0164 }
0165 
0166 // ********************************************************************
0167 // EnableBestSafety
0168 // ********************************************************************
0169 //
0170 inline
0171 void  G4VoxelNavigation::EnableBestSafety(G4bool flag)
0172 {
0173   fBestSafety = flag;
0174 }