Geant4 Cross Reference |
>> 1 // This code implementation is the intellectual property of >> 2 // the GEANT4 collaboration. 1 // 3 // 2 // ******************************************* << 4 // By copying, distributing or modifying the Program (or any work 3 // * License and Disclaimer << 5 // based on the Program) you indicate your acceptance of this statement, 4 // * << 6 // and all its terms. 5 // * The Geant4 software is copyright of th << 6 // * the Geant4 Collaboration. It is provided << 7 // * conditions of the Geant4 Software License << 8 // * LICENSE and available at http://cern.ch/ << 9 // * include a list of copyright holders. << 10 // * << 11 // * Neither the authors of this software syst << 12 // * institutes,nor the agencies providing fin << 13 // * work make any representation or warran << 14 // * regarding this software system or assum << 15 // * use. Please see the license in the file << 16 // * for the full disclaimer and the limitatio << 17 // * << 18 // * This code implementation is the result << 19 // * technical work of the GEANT4 collaboratio << 20 // * By using, copying, modifying or distri << 21 // * any work based on the software) you ag << 22 // * use in resulting scientific publicati << 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* << 25 // 7 // 26 // G4SolidExtentList implementation; a list of << 8 // $Id: G4SolidExtentList.cc,v 1.1 2000/04/07 11:03:23 gcosmo Exp $ >> 9 // GEANT4 tag $Name: geant4-03-01 $ >> 10 // >> 11 // >> 12 // -------------------------------------------------------------------- >> 13 // GEANT 4 class source file >> 14 // >> 15 // >> 16 // G4SolidExtentList.cc >> 17 // >> 18 // Implementation of a list of (voxel) extents along one axis 27 // 19 // 28 // Author: David C. Williams (davidw@scipp.ucs << 29 // ------------------------------------------- 20 // -------------------------------------------------------------------- 30 21 31 #include "G4SolidExtentList.hh" 22 #include "G4SolidExtentList.hh" 32 #include "G4VoxelLimits.hh" 23 #include "G4VoxelLimits.hh" 33 #include "G4GeometryTolerance.hh" << 34 24 >> 25 // 35 // Constructor (default) 26 // Constructor (default) 36 // 27 // 37 G4SolidExtentList::G4SolidExtentList() 28 G4SolidExtentList::G4SolidExtentList() 38 { 29 { 39 axis = kZAxis; << 30 axis = kZAxis; 40 minLimit = -INT_MAX/2; << 31 limited = false; 41 maxLimit = INT_MAX/2; << 32 minLimit = -DBL_MAX; >> 33 maxLimit = +DBL_MAX; 42 } 34 } 43 35 >> 36 >> 37 // 44 // Constructor (limited case) 38 // Constructor (limited case) 45 // 39 // 46 G4SolidExtentList::G4SolidExtentList( const EA << 40 G4SolidExtentList::G4SolidExtentList( const EAxis targetAxis, const G4VoxelLimits &voxelLimits ) 47 const G4 << 48 { 41 { 49 axis = targetAxis; << 42 axis = targetAxis; 50 << 43 51 limited = voxelLimits.IsLimited( axis ); << 44 limited = voxelLimits.IsLimited( axis ); 52 if (limited) << 45 if (limited) { 53 { << 46 minLimit = voxelLimits.GetMinExtent( axis ); 54 minLimit = voxelLimits.GetMinExtent( axis << 47 maxLimit = voxelLimits.GetMaxExtent( axis ); 55 maxLimit = voxelLimits.GetMaxExtent( axis << 48 } 56 } << 49 else { 57 else << 50 minLimit = -DBL_MAX; 58 { << 51 maxLimit = +DBL_MAX; 59 minLimit = -INT_MAX/2; << 52 } 60 maxLimit = INT_MAX/2; << 61 } << 62 } 53 } 63 54 >> 55 >> 56 // 64 // Destructor 57 // Destructor 65 // 58 // 66 G4SolidExtentList::~G4SolidExtentList() = defa << 59 G4SolidExtentList::~G4SolidExtentList() {;} >> 60 >> 61 67 62 >> 63 // 68 // AddSurface 64 // AddSurface 69 // 65 // 70 // 66 // 71 void G4SolidExtentList::AddSurface( const G4Cl << 67 void G4SolidExtentList::AddSurface( const G4ClippablePolygon &surface ) 72 { 68 { 73 // << 69 // 74 // Keep track of four surfaces << 70 // Keep track of four surfaces 75 // << 71 // 76 G4double smin=.0, smax=0.; << 72 G4double min, max; 77 << 73 78 surface.GetExtent( axis, smin, smax ); << 74 surface.GetExtent( axis, min, max ); 79 << 75 80 if (smin > maxLimit) << 76 if (min > maxLimit) { 81 { << 77 // 82 // << 78 // Nearest surface beyond maximum limit 83 // Nearest surface beyond maximum limit << 79 // 84 // << 80 if (surface.InFrontOf(minAbove,axis)) minAbove = surface; 85 if (surface.InFrontOf(minAbove,axis)) minA << 81 } 86 } << 82 else if (max < minLimit) { 87 else if (smax < minLimit) << 83 // 88 { << 84 // Nearest surface below minimum limit 89 // << 85 // 90 // Nearest surface below minimum limit << 86 if (surface.BehindOf(maxBelow,axis)) maxBelow = surface; 91 // << 87 } 92 if (surface.BehindOf(maxBelow,axis)) maxBe << 88 else { 93 } << 89 // 94 else << 90 // Max and min surfaces inside 95 { << 91 // 96 // << 92 if (surface.BehindOf(maxSurface,axis)) maxSurface = surface; 97 // Max and min surfaces inside << 93 if (surface.InFrontOf(minSurface,axis)) minSurface = surface; 98 // << 94 } 99 if (surface.BehindOf(maxSurface,axis)) max << 100 if (surface.InFrontOf(minSurface,axis)) mi << 101 } << 102 } 95 } 103 96 >> 97 >> 98 >> 99 // 104 // GetExtent 100 // GetExtent 105 // 101 // 106 // Return extent after processing all surfaces 102 // Return extent after processing all surfaces 107 // 103 // 108 G4bool G4SolidExtentList::GetExtent( G4double& << 104 G4bool G4SolidExtentList::GetExtent( G4double &min, G4double &max ) const 109 { 105 { 110 G4double kCarTolerance = G4GeometryTolerance << 106 // 111 ->GetSurfaceToleran << 107 // Did we have any surfaces within the limits? 112 // << 108 // 113 // Did we have any surfaces within the limit << 109 if (minSurface.Empty()) { 114 // << 110 // 115 if (minSurface.Empty()) << 111 // Nothing! Do we have anything above? 116 { << 112 // 117 // << 113 if (minAbove.Empty()) return false; 118 // Nothing! Do we have anything above? << 114 119 // << 115 // 120 if (minAbove.Empty()) return false; << 116 // Yup. Is it facing inwards? 121 << 117 // 122 // << 118 if (minAbove.GetNormal().operator()(axis) < 0) return false; 123 // Yup. Is it facing inwards? << 119 124 // << 120 // 125 if (minAbove.GetNormal().operator()(axis) << 121 // No. We must be entirely within the solid 126 << 122 // 127 // << 123 max = maxLimit + kCarTolerance; 128 // No. We must be entirely within the soli << 124 min = minLimit - kCarTolerance; 129 // << 125 return true; 130 emax = maxLimit + kCarTolerance; << 126 } 131 emin = minLimit - kCarTolerance; << 127 132 return true; << 128 // 133 } << 129 // Check max surface 134 << 130 // 135 // << 131 if (maxSurface.GetNormal().operator()(axis) < 0) { 136 // Check max surface << 132 // 137 // << 133 // Inward facing: max limit must be embedded within solid 138 if (maxSurface.GetNormal().operator()(axis) << 134 // 139 { << 135 max = maxLimit + kCarTolerance; 140 // << 136 } 141 // Inward facing: max limit must be embedd << 137 else { 142 // << 138 G4double sMin, sMax; 143 emax = maxLimit + kCarTolerance; << 139 maxSurface.GetExtent( axis, sMin, sMax ); 144 } << 140 max = ( (sMax > maxLimit) ? maxLimit : sMax ) + kCarTolerance; 145 else << 141 } 146 { << 142 147 G4double sMin=0., sMax=0.; << 143 // 148 maxSurface.GetExtent( axis, sMin, sMax ); << 144 // Check min surface 149 emax = ( (sMax > maxLimit) ? maxLimit : sM << 145 // 150 } << 146 if (minSurface.GetNormal().operator()(axis) > 0) { 151 << 147 // 152 // << 148 // Inward facing: max limit must be embedded within solid 153 // Check min surface << 149 // 154 // << 150 min = minLimit - kCarTolerance; 155 if (minSurface.GetNormal().operator()(axis) << 151 } 156 { << 152 else { 157 // << 153 G4double sMin, sMax; 158 // Inward facing: max limit must be embedd << 154 minSurface.GetExtent( axis, sMin, sMax ); 159 // << 155 min = ( (sMin < minLimit) ? minLimit : sMin ) - kCarTolerance; 160 emin = minLimit - kCarTolerance; << 156 } 161 } << 157 162 else << 158 return true; 163 { << 164 G4double sMin=0., sMax=0.; << 165 minSurface.GetExtent( axis, sMin, sMax ); << 166 emin = ( (sMin < minLimit) ? minLimit : sM << 167 } << 168 << 169 return true; << 170 } 159 } 171 160 >> 161 >> 162 >> 163 172 164