78{
81
82
83
84
87
88 if ( (sCode & eCode) != 0 )
89 {
90
91
92 remainsAfterClip = false;
93 }
94 else if ( sCode == 0 && eCode == 0 )
95 {
96
97
98 remainsAfterClip = true ;
99 }
100 else
101 {
102
103
104
106
110
114
115 while ( sCode != eCode )
116 {
117
118
119
120
121 if ( sCode != 0 )
122 {
123 if ( (sCode & 0x01) != 0 )
124 {
125 z1 += (fxAxisMin-x1)*(z2-z1)/(x2-x1);
126 y1 += (fxAxisMin-x1)*(y2-y1)/(x2-x1);
127 x1 = fxAxisMin;
128 }
129 else if ( (sCode & 0x02) != 0 )
130 {
131 z1 += (fxAxisMax-x1)*(z2-z1)/(x2-x1);
132 y1 += (fxAxisMax-x1)*(y2-y1)/(x2-x1);
133 x1 = fxAxisMax ;
134 }
135 else if ( (sCode & 0x04) != 0 )
136 {
137 x1 += (fyAxisMin-y1)*(x2-x1)/(y2-y1);
138 z1 += (fyAxisMin-y1)*(z2-z1)/(y2-y1);
139 y1 = fyAxisMin;
140 }
141 else if ( (sCode & 0x08) != 0 )
142 {
143 x1 += (fyAxisMax-y1)*(x2-x1)/(y2-y1);
144 z1 += (fyAxisMax-y1)*(z2-z1)/(y2-y1);
145 y1 = fyAxisMax;
146 }
147 else if ( (sCode & 0x10) != 0 )
148 {
149 x1 += (fzAxisMin-z1)*(x2-x1)/(z2-z1);
150 y1 += (fzAxisMin-z1)*(y2-y1)/(z2-z1);
151 z1 = fzAxisMin;
152 }
153 else if ( (sCode & 0x20) != 0 )
154 {
155 x1 += (fzAxisMax-z1)*(x2-x1)/(z2-z1);
156 y1 += (fzAxisMax-z1)*(y2-y1)/(z2-z1);
157 z1 = fzAxisMax;
158 }
159 }
160 if ( eCode != 0 )
161 {
162 if ( (eCode & 0x01) != 0 )
163 {
164 z2 += (fxAxisMin-x2)*(z1-z2)/(x1-x2);
165 y2 += (fxAxisMin-x2)*(y1-y2)/(x1-x2);
166 x2 = fxAxisMin;
167 }
168 else if ( (eCode & 0x02) != 0 )
169 {
170 z2 += (fxAxisMax-x2)*(z1-z2)/(x1-x2);
171 y2 += (fxAxisMax-x2)*(y1-y2)/(x1-x2);
172 x2 = fxAxisMax;
173 }
174 else if ( (eCode & 0x04) != 0 )
175 {
176 x2 += (fyAxisMin-y2)*(x1-x2)/(y1-y2);
177 z2 += (fyAxisMin-y2)*(z1-z2)/(y1-y2);
178 y2 = fyAxisMin;
179 }
180 else if ((eCode&0x08) != 0)
181 {
182 x2 += (fyAxisMax-y2)*(x1-x2)/(y1-y2);
183 z2 += (fyAxisMax-y2)*(z1-z2)/(y1-y2);
184 y2 = fyAxisMax;
185 }
186 else if ( (eCode & 0x10) != 0 )
187 {
188 x2 += (fzAxisMin-z2)*(x1-x2)/(z1-z2);
189 y2 += (fzAxisMin-z2)*(y1-y2)/(z1-z2);
190 z2 = fzAxisMin;
191 }
192 else if ( (eCode & 0x20) != 0 )
193 {
194 x2 += (fzAxisMax-z2)*(x1-x2)/(z1-z2);
195 y2 += (fzAxisMax-z2)*(y1-y2)/(z1-z2);
196 z2 = fzAxisMax;
197 }
198 }
203 }
204 remainsAfterClip = sCode == 0 && eCode == 0;
205 }
206 return remainsAfterClip;
207}
CLHEP::Hep3Vector G4ThreeVector
G4int OutCode(const G4ThreeVector &pVec) const