00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include "G4SolidExtentList.hh"
00041 #include "G4VoxelLimits.hh"
00042 #include "G4GeometryTolerance.hh"
00043
00044
00045
00046
00047
00048 G4SolidExtentList::G4SolidExtentList()
00049 {
00050 axis = kZAxis;
00051 limited = false;
00052 minLimit = -INT_MAX/2;
00053 maxLimit = INT_MAX/2;
00054 }
00055
00056
00057
00058
00059
00060 G4SolidExtentList::G4SolidExtentList( const EAxis targetAxis,
00061 const G4VoxelLimits &voxelLimits )
00062 {
00063 axis = targetAxis;
00064
00065 limited = voxelLimits.IsLimited( axis );
00066 if (limited)
00067 {
00068 minLimit = voxelLimits.GetMinExtent( axis );
00069 maxLimit = voxelLimits.GetMaxExtent( axis );
00070 }
00071 else
00072 {
00073 minLimit = -INT_MAX/2;
00074 maxLimit = INT_MAX/2;
00075 }
00076 }
00077
00078
00079
00080
00081
00082 G4SolidExtentList::~G4SolidExtentList()
00083 {
00084 }
00085
00086
00087
00088
00089
00090
00091 void G4SolidExtentList::AddSurface( const G4ClippablePolygon &surface )
00092 {
00093
00094
00095
00096 G4double min, max;
00097
00098 surface.GetExtent( axis, min, max );
00099
00100 if (min > maxLimit)
00101 {
00102
00103
00104
00105 if (surface.InFrontOf(minAbove,axis)) minAbove = surface;
00106 }
00107 else if (max < minLimit)
00108 {
00109
00110
00111
00112 if (surface.BehindOf(maxBelow,axis)) maxBelow = surface;
00113 }
00114 else
00115 {
00116
00117
00118
00119 if (surface.BehindOf(maxSurface,axis)) maxSurface = surface;
00120 if (surface.InFrontOf(minSurface,axis)) minSurface = surface;
00121 }
00122 }
00123
00124
00125
00126
00127
00128
00129
00130
00131 G4bool G4SolidExtentList::GetExtent( G4double &min, G4double &max ) const
00132 {
00133 G4double kCarTolerance = G4GeometryTolerance::GetInstance()
00134 ->GetSurfaceTolerance();
00135
00136
00137
00138 if (minSurface.Empty())
00139 {
00140
00141
00142
00143 if (minAbove.Empty()) return false;
00144
00145
00146
00147
00148 if (minAbove.GetNormal().operator()(axis) < 0) return false;
00149
00150
00151
00152
00153 max = maxLimit + kCarTolerance;
00154 min = minLimit - kCarTolerance;
00155 return true;
00156 }
00157
00158
00159
00160
00161 if (maxSurface.GetNormal().operator()(axis) < 0)
00162 {
00163
00164
00165
00166 max = maxLimit + kCarTolerance;
00167 }
00168 else
00169 {
00170 G4double sMin, sMax;
00171 maxSurface.GetExtent( axis, sMin, sMax );
00172 max = ( (sMax > maxLimit) ? maxLimit : sMax ) + kCarTolerance;
00173 }
00174
00175
00176
00177
00178 if (minSurface.GetNormal().operator()(axis) > 0)
00179 {
00180
00181
00182
00183 min = minLimit - kCarTolerance;
00184 }
00185 else
00186 {
00187 G4double sMin, sMax;
00188 minSurface.GetExtent( axis, sMin, sMax );
00189 min = ( (sMin < minLimit) ? minLimit : sMin ) - kCarTolerance;
00190 }
00191
00192 return true;
00193 }
00194