G4VoxelNavigation.icc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // 
00030 // class G4VoxelNavigation Inline implementation
00031 //
00032 // --------------------------------------------------------------------
00033 
00034 // ********************************************************************
00035 // VoxelLocate
00036 // ********************************************************************
00037 //
00038 inline
00039 G4SmartVoxelNode*
00040 G4VoxelNavigation::VoxelLocate( G4SmartVoxelHeader* pHead,
00041                                 const G4ThreeVector& localPoint )
00042 {
00043   G4SmartVoxelHeader *targetVoxelHeader=pHead;
00044   G4SmartVoxelNode *targetVoxelNode=0;
00045   G4SmartVoxelProxy *sampleProxy;
00046   EAxis targetHeaderAxis;
00047   G4double targetHeaderMin, targetHeaderNodeWidth;
00048   G4int targetHeaderNoSlices, targetNodeNo;
00049 
00050   fVoxelDepth = 0;
00051 
00052   while ( !targetVoxelNode )
00053   {
00054     targetHeaderAxis = targetVoxelHeader->GetAxis();
00055     targetHeaderNoSlices = targetVoxelHeader->GetNoSlices();
00056     targetHeaderMin = targetVoxelHeader->GetMinExtent();
00057     targetHeaderNodeWidth = (targetVoxelHeader->GetMaxExtent()-targetHeaderMin)
00058                           / targetHeaderNoSlices;
00059     targetNodeNo = G4int( (localPoint(targetHeaderAxis)-targetHeaderMin)
00060                           / targetHeaderNodeWidth);
00061     // Rounding protection
00062     //
00063     if ( targetNodeNo<0 )
00064     {
00065       targetNodeNo = 0;
00066     }
00067     else if ( targetNodeNo>=targetHeaderNoSlices )
00068     {
00069       targetNodeNo = targetHeaderNoSlices-1;
00070     }
00071     // Stack info for stepping
00072     //
00073     fVoxelAxisStack[fVoxelDepth] = targetHeaderAxis;
00074     fVoxelNoSlicesStack[fVoxelDepth] = targetHeaderNoSlices;
00075     fVoxelSliceWidthStack[fVoxelDepth] = targetHeaderNodeWidth;
00076     fVoxelNodeNoStack[fVoxelDepth] = targetNodeNo;
00077     fVoxelHeaderStack[fVoxelDepth] = targetVoxelHeader;
00078     sampleProxy = targetVoxelHeader->GetSlice(targetNodeNo);
00079 
00080     if ( sampleProxy->IsNode() )
00081     {
00082       targetVoxelNode = sampleProxy->GetNode();
00083     }
00084     else
00085     {
00086       targetVoxelHeader = sampleProxy->GetHeader();
00087       fVoxelDepth++;
00088     }
00089   }
00090   fVoxelNode = targetVoxelNode;
00091   return targetVoxelNode;
00092 }
00093 
00094 // ********************************************************************
00095 // LevelLocate
00096 // ********************************************************************
00097 //
00098 inline
00099 G4bool
00100 G4VoxelNavigation::LevelLocate( G4NavigationHistory& history,
00101                           const G4VPhysicalVolume* blockedVol,
00102                           const G4int,
00103                           const G4ThreeVector& globalPoint,
00104                           const G4ThreeVector* globalDirection,
00105                           const G4bool pLocatedOnEdge, 
00106                                 G4ThreeVector& localPoint )
00107 {
00108   G4SmartVoxelHeader *targetVoxelHeader;
00109   G4SmartVoxelNode *targetVoxelNode;
00110   G4VPhysicalVolume *targetPhysical, *samplePhysical;
00111   G4LogicalVolume *targetLogical;
00112   G4VSolid *sampleSolid;
00113   G4ThreeVector samplePoint;
00114   G4int targetNoDaughters;
00115   
00116   targetPhysical = history.GetTopVolume();
00117   targetLogical = targetPhysical->GetLogicalVolume();
00118   targetVoxelHeader = targetLogical->GetVoxelHeader();
00119 
00120   // Find the voxel containing the point
00121   //
00122   targetVoxelNode = VoxelLocate(targetVoxelHeader,localPoint);
00123 
00124   targetNoDaughters=targetVoxelNode->GetNoContained();
00125   if ( targetNoDaughters==0 ) return false;
00126 
00127   //
00128   // Search daughters in volume
00129   //
00130 
00131   for ( register int sampleNo=targetNoDaughters-1; sampleNo>=0; sampleNo-- )
00132   {
00133     samplePhysical = targetLogical->
00134                      GetDaughter(targetVoxelNode->GetVolume(sampleNo));
00135     if ( samplePhysical!=blockedVol )
00136     {
00137       // Setup history
00138       //
00139       history.NewLevel(samplePhysical, kNormal, samplePhysical->GetCopyNo());
00140       sampleSolid = samplePhysical->GetLogicalVolume()->GetSolid();
00141       samplePoint = history.GetTopTransform().TransformPoint(globalPoint);
00142 
00143       if( G4AuxiliaryNavServices::CheckPointOnSurface(sampleSolid,
00144                                                       samplePoint,
00145                                                       globalDirection, 
00146                                                       history.GetTopTransform(),
00147                                                       pLocatedOnEdge) )
00148       {
00149         // Enter this daughter
00150         //
00151         localPoint = samplePoint;
00152         return true;
00153       }
00154       else
00155       {
00156         history.BackLevel();
00157       }
00158     }
00159   }
00160   return false;
00161 }
00162 
00163 // ********************************************************************
00164 // GetVerboseLevel
00165 // ********************************************************************
00166 //
00167 inline
00168 G4int G4VoxelNavigation::GetVerboseLevel() const
00169 {
00170   return fLogger->GetVerboseLevel();
00171 }
00172 
00173 // ********************************************************************
00174 // CheckMode
00175 // ********************************************************************
00176 //
00177 inline
00178 void  G4VoxelNavigation::CheckMode(G4bool mode)
00179 {
00180   fCheck = mode;
00181 }
00182 
00183 // ********************************************************************
00184 // EnableBestSafety
00185 // ********************************************************************
00186 //
00187 inline
00188 void  G4VoxelNavigation::EnableBestSafety(G4bool flag)
00189 {
00190   fBestSafety = flag;
00191 }

Generated on Mon May 27 17:50:18 2013 for Geant4 by  doxygen 1.4.7