|
|
|||
File indexing completed on 2026-09-25 09:13:55
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 // G4ReplicaNavigation 0027 // 0028 // Class description: 0029 // 0030 // Utility for navigation in volumes containing a single G4PVParameterised 0031 // volume for which voxels for the replicated volumes have been constructed. 0032 // [Voxels MUST be along one axis only: NOT refined] 0033 0034 // Author: Paul Kent (CERN), August 1996 0035 // -------------------------------------------------------------------- 0036 #ifndef G4REPLICANAVIGATION_HH 0037 #define G4REPLICANAVIGATION_HH 1 0038 0039 #include <CLHEP/Units/SystemOfUnits.h> 0040 0041 #include "G4Types.hh" 0042 #include "G4NavigationHistory.hh" 0043 #include "G4LogicalVolume.hh" 0044 #include "G4VPhysicalVolume.hh" 0045 #include "G4ThreeVector.hh" 0046 #include "G4BlockingList.hh" 0047 0048 // Required for voxel handling 0049 // 0050 #include "G4SmartVoxelHeader.hh" 0051 0052 class G4VSolid; 0053 0054 struct G4ExitNormal 0055 { 0056 /** 0057 * @brief G4ExitNormal, a bucket to hold value of Normal (3-vector), Booleans 0058 * for calculated and leave-behind or 'validConvex', and exiting side.. 0059 */ 0060 0061 /** Identity of 'Side' of Replicas. Used by DistanceToOut methods. */ 0062 enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPX,kMX,kPY,kMY,kPZ,kMZ,kMother}; 0063 0064 G4ThreeVector exitNormal; 0065 G4bool calculated; // Normal 0066 G4bool validConvex; // Solid locally convex 0067 ESide exitSide; 0068 0069 public: 0070 0071 G4ExitNormal(const G4ThreeVector& norm = G4ThreeVector(0.,0.,0.), 0072 G4bool calc = false, 0073 G4bool valid= false, 0074 ESide side = kNull ) 0075 { exitNormal= norm; calculated= calc; validConvex=valid; exitSide=side;} 0076 }; 0077 0078 /** 0079 * @brief G4ReplicaNavigation is a utility class for navigation in volumes 0080 * containing a single G4PVParameterised volume for which voxels for the 0081 * replicated volumes have been constructed. 0082 * @note Voxels MUST be along one axis only: NOT refined. 0083 */ 0084 0085 class G4ReplicaNavigation 0086 { 0087 public: 0088 0089 /** 0090 * Constructor and default Destructor. 0091 */ 0092 G4ReplicaNavigation(); 0093 ~G4ReplicaNavigation() = default; 0094 0095 /** 0096 * Searches positioned volumes in mother at current top level of @p history 0097 * for volume containing @p globalPoint. Do not test against @p blockedVol. 0098 * If a containing volume is found, push it onto navigation history state. 0099 * @param[in,out] history Navigation history. 0100 * @param[in,out] blockedVol Blocked volume to be ignored in queries. 0101 * @param[in,out] blockedNum Copy number for blocked replica volumes. 0102 * @param[in,out] globalPoint Point in global coordinates system. 0103 * @param[in,out] globalDirection Pointer to global direction or null. 0104 * @param[in,out] localPoint Point in local coordinates system. 0105 * @returns Whether a containing volume has been found. 0106 */ 0107 inline G4bool LevelLocate( G4NavigationHistory& history, 0108 const G4VPhysicalVolume* blockedVol, 0109 const G4int blockedNum, 0110 const G4ThreeVector& globalPoint, 0111 const G4ThreeVector* globalDirection, 0112 const G4bool pLocatedOnEdge, 0113 G4ThreeVector& localPoint ); 0114 0115 /** 0116 * Computes the length of a step to the next boundary. 0117 * Do not test against @p pBlockedPhysical. Identify the next candidate 0118 * volume (if a daughter of the current volume), and return it in: 0119 * pBlockedPhysical, blockedReplicaNo. 0120 * @param[in] globalPoint Global point. 0121 * @param[in] globalDirection Global direction vector. 0122 * @param[in] localPoint Local point. 0123 * @param[in] localDirection Local direction vector. 0124 * @param[in] currentProposedStepLength Current proposed step length. 0125 * @param[in,out] newSafety New safety. 0126 * @param[in,out] history Navigation history. 0127 * @param[in,out] validExitNormal Flag to indicate whether exit normal is 0128 * valid or not. 0129 * @param[in,out] exitNormal Exit normal. 0130 * @param[in,out] exiting Flag to indicate whether exiting a volume. 0131 * @param[in,out] entering Flag to indicate whether entering a volume. 0132 * @param[in,out] pBlockedPhysical Blocked physical volume that should be 0133 * ignored in queries. 0134 * @param[in,out] blockedReplicaNo Copy number for blocked replica volumes. 0135 * @returns Length from current point to next boundary surface along 0136 * @p localDirection. 0137 */ 0138 G4double ComputeStep( const G4ThreeVector& globalPoint, 0139 const G4ThreeVector& globalDirection, 0140 const G4ThreeVector& localPoint, 0141 const G4ThreeVector& localDirection, 0142 const G4double currentProposedStepLength, 0143 G4double& newSafety, 0144 G4NavigationHistory& history, 0145 G4bool& validExitNormal, 0146 G4bool& calculatedExitNormal, 0147 G4ThreeVector &exitNormal, 0148 G4bool& exiting, 0149 G4bool& entering, 0150 G4VPhysicalVolume* (*pBlockedPhysical), 0151 G4int &blockedReplicaNo ); 0152 0153 /** 0154 * Calculates the isotropic distance to the nearest boundary from the 0155 * specified point in the local/global coordinate system. 0156 * The localpoint utilised must be within the current volume. 0157 * @param[in] globalPoint Global point. 0158 * @param[in] localPoint Local point. 0159 * @param[in] history Navigation history. 0160 * @param[in] pProposedMaxLength Maximum step length beyond which volumes 0161 * need not be checked. 0162 * @returns Length from current point to closest surface. 0163 */ 0164 G4double ComputeSafety( const G4ThreeVector& globalPoint, 0165 const G4ThreeVector& localPoint, 0166 const G4NavigationHistory& history, 0167 const G4double pProposedMaxLength = DBL_MAX ) const; 0168 0169 /** 0170 * Locates the specified point in the local/global coordinate system. 0171 * The localpoint utilised must be within the current volume. 0172 * @param[in] history Navigation history. 0173 * @param[in] globalPoint Global point. 0174 * @param[in] localPoint Local point. 0175 * @param[in,out] exiting Flag to indicate whether exiting a volume. 0176 * @param[in,out] notKnownInside Flag to indicate whether exiting replica. 0177 * @returns If point is located inside the current replica volume. 0178 */ 0179 EInside BackLocate( G4NavigationHistory &history, 0180 const G4ThreeVector& globalPoint, 0181 G4ThreeVector& localPoint, 0182 const G4bool& exiting, 0183 G4bool& notKnownInside ) const; 0184 0185 /** 0186 * Setups transformation and transform point into local system. 0187 */ 0188 void ComputeTransformation( const G4int replicaNo, 0189 G4VPhysicalVolume* pVol, 0190 G4ThreeVector& point ) const; 0191 0192 /** 0193 * Setups transformation into local system. 0194 */ 0195 void ComputeTransformation( const G4int replicaNo, 0196 G4VPhysicalVolume* pVol ) const; 0197 0198 /** 0199 * Computes if local point point is inside the reference volume or not. 0200 * @param[in] pVol Pointer to the reference volume. 0201 * @param[in] replicaNo Replica number of current volume. 0202 * @param[in] localPoint Point in local coordinates system. 0203 * @returns If point is inside referenced replica volume or not. 0204 */ 0205 EInside Inside( const G4VPhysicalVolume* pVol, 0206 const G4int replicaNo, 0207 const G4ThreeVector& localPoint ) const; 0208 0209 /** 0210 * Estimates the isotropic distance to exit the reference volume from 0211 * the provided local point. 0212 * @param[in] pVol Pointer to the reference volume. 0213 * @param[in] replicaNo Replica number of current volume. 0214 * @param[in] localPoint Point in local coordinates system. 0215 * @returns The isotropic distance to exit. 0216 */ 0217 G4double DistanceToOut( const G4VPhysicalVolume* pVol, 0218 const G4int replicaNo, 0219 const G4ThreeVector& localPoint ) const; 0220 0221 /** 0222 * Calculates the distance to exit the reference volume from the provided 0223 * local point, given its direction. 0224 * @param[in] pVol Pointer to the reference volume. 0225 * @param[in] replicaNo Replica number of current volume. 0226 * @param[in] localPoint Point in local coordinates system. 0227 * @param[in] localDirection The local direction. 0228 * @param[in,out] candidateNormal The candidate exit notmal. 0229 * @returns The distance to exit. 0230 */ 0231 G4double DistanceToOut( const G4VPhysicalVolume* pVol, 0232 const G4int replicaNo, 0233 const G4ThreeVector& localPoint, 0234 const G4ThreeVector& localDirection, 0235 G4ExitNormal& candidateNormal ) const; 0236 0237 /** 0238 * Verbosity control. 0239 * @note If level>0 && G4VERBOSE, printout can occur. 0240 */ 0241 inline G4int GetVerboseLevel() const; 0242 inline void SetVerboseLevel(G4int level); 0243 0244 /** 0245 * Run navigation in "check-mode", therefore using additional 0246 * verifications and more strict correctness conditions. 0247 * @note Is effective only with G4VERBOSE set. 0248 * @param[in] mode Flag to enable/disable check-mode. 0249 */ 0250 inline void CheckMode(G4bool mode); 0251 0252 private: 0253 0254 /** 0255 * Locates voxel node based on given point. 0256 * @param[in] pHead Pointer to header of nodes to look through. 0257 * @param[in] localPoint Local point 0258 * @param[in] blocked Flag to indicate if volume is blocked or not. 0259 * @returns Pointer to the node where the given point is located. 0260 */ 0261 inline G4int VoxelLocate( const G4SmartVoxelHeader* pHead, 0262 const G4ThreeVector& localPoint, 0263 const G4int blocked=-1 ) const; 0264 0265 /** 0266 * Computes distance to exit for phi replica. 0267 */ 0268 G4double DistanceToOutPhi( const G4ThreeVector& localPoint, 0269 const G4ThreeVector& localDirection, 0270 const G4double width, 0271 G4ExitNormal& foundNormal ) const; 0272 0273 /** 0274 * Computes distance to exit for radial replica. 0275 */ 0276 G4double DistanceToOutRad( const G4ThreeVector& localPoint, 0277 const G4ThreeVector& localDirection, 0278 const G4double width, 0279 const G4double offset, 0280 const G4int replicaNo, 0281 G4ExitNormal& foundNormal ) const; 0282 0283 /** 0284 * Sets phi rotation of target volume. 0285 */ 0286 inline void SetPhiTransformation( const G4double ang, 0287 G4VPhysicalVolume* pVol = nullptr ) const; 0288 0289 private: 0290 0291 // Invariants - unaltered during navigation ------------------------------- 0292 // ********** 0293 0294 /** Check mode. */ 0295 G4bool fCheck = false; 0296 0297 /** Verbosity. */ 0298 G4int fVerbose = 0; 0299 0300 /** Local cached constants. */ 0301 G4double kCarTolerance, kRadTolerance, kAngTolerance, 0302 halfkCarTolerance, halfkRadTolerance, halfkAngTolerance, 0303 fMinStep; 0304 }; 0305 0306 #include "G4ReplicaNavigation.icc" 0307 0308 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|