109 {
110
111
114 assert(tMgr);
117
119 const G4Field* globalField = 0;
120 const G4String intro =
"G4VFieldModel::DescribeYourselfTo: ";
121 if (globalFieldMgr) {
124 if (!globalField) {
125 static G4bool warned =
false;
126 if (!warned) {
127 G4cout << intro <<
"Null global field pointer." <<
G4endl;
128 warned = true;
129 }
130 }
131 }
132 } else {
133 static G4bool warned =
false;
134 if (!warned) {
135 G4cout << intro <<
"No global field manager." <<
G4endl;
136 warned = true;
137 }
138 }
139
143 } else {
145 }
152 const G4double xHalfScene = 0.5 * (xMax - xMin);
153 const G4double yHalfScene = 0.5 * (yMax - yMin);
154 const G4double zHalfScene = 0.5 * (zMax - zMin);
155 const G4double xSceneCentre = 0.5 * (xMax + xMin);
156 const G4double ySceneCentre = 0.5 * (yMax + yMin);
157 const G4double zSceneCentre = 0.5 * (zMax + zMin);
160 if (maxHalfScene <= 0.) {
162 return;
163 }
164
165
167 const G4int nDataPointsPerXHalfScene =
G4int(xHalfScene / interval);
168 const G4int nDataPointsPerYHalfScene =
G4int(yHalfScene / interval);
169 const G4int nDataPointsPerZHalfScene =
G4int(zHalfScene / interval);
170 const G4int nXSamples = 2 * nDataPointsPerXHalfScene + 1;
171 const G4int nYSamples = 2 * nDataPointsPerYHalfScene + 1;
172 const G4int nZSamples = 2 * nDataPointsPerZHalfScene + 1;
173 const G4int nSamples = nXSamples * nYSamples * nZSamples;
174 const G4double arrowLengthMax = 0.8 * interval;
175
176
177 std::vector<G4Point3D> Field(nSamples);
178 std::vector<G4Point3D> xyz(nSamples);
180
181
182 for (
G4int i = 0; i < nXSamples; i++) {
183 G4double x = xSceneCentre + (i - nDataPointsPerXHalfScene) * interval;
184
185 for (
G4int j = 0; j < nYSamples; j++) {
186 G4double y = ySceneCentre + (j - nDataPointsPerYHalfScene) * interval;
187
188 for (
G4int k = 0; k < nZSamples; k++) {
189 G4double z = zSceneCentre + (k - nDataPointsPerZHalfScene) * interval;
190
191
192 const G4int ijk = i * nYSamples * nZSamples + j * nZSamples + k;
193 xyz[ijk].set(x,y,z);
194
196
197
202 G4int copyNo = findings.fFoundPVCopyNo;
205 if (pvParam) {
207 solid = param->ComputeSolid(copyNo,pvParam);
209 }
210
211 const auto&
transform = findings.fFoundObjectTransformation;
213 auto translation =
transform.getTranslation();
216 isInPV = true;
217 break;
218 }
219 }
220 if (!isInPV) continue;
221 }
222
223
224
227 const G4Field* field = globalField;
228 if (pPV) {
229
231 if (pLV) {
232
234 if (pRegion) {
236 if (pRegionFieldMgr) {
238
239 }
240 }
241
243 if (pLVFieldMgr) {
245
246 }
247 }
248 }
249
251
252
254
256 if (mag > FieldMagnitudeMax) FieldMagnitudeMax = mag;
257 }
258 }
259 }
260
261 if (FieldMagnitudeMax <= 0.) {
263 return;
264 }
265
266 for (
G4int i = 0; i < nSamples; i++) {
267 const G4double Fmag = Field[i].mag();
268 const G4double f = Fmag / FieldMagnitudeMax;
269 if (f <= 0.) continue;
270
272 if (f < 0.5) {
273 green = 2. * f;
274 red = 2. * (0.5 - f);
275 } else {
276 blue = 2. * (f - 0.5);
277 green = 2. * (1.0 - f);
278 }
280
281
282 G4bool drawAsLine =
false;
284 case Representation::fullArrow:
285 if (f < 0.1) {
286 drawAsLine = true;
287 }
288 break;
289 case Representation::lightArrow:
290 drawAsLine = true;
291 break;
292 default:
293 break;
294 }
295
296
297 G4double arrowLength = arrowLengthMax * f;
298
299 if (f < 0.01) arrowLength = arrowLengthMax * 0.01;
300 const G4Point3D head = xyz[i] + arrowLength*Field[i]/Fmag;
301
302 if (drawAsLine) {
305 va.SetLineWidth(2.);
307 FArrowLite.push_back(xyz[i]);
308 FArrowLite.push_back(head);
312 } else {
314 head.
x(), head.
y(), head.
z(),
315 arrowLength/5, arrowColour,
318 FArrow.DescribeYourselfTo(sceneHandler);
319 }
320 }
321}
static const G4double pos
static const G4double alpha
G4GLOB_DLL std::ostream G4cout
Hep3Vector & transform(const HepRotation &)
const G4Field * GetDetectorField() const
G4bool DoesFieldExist() const
G4VSolid * GetSolid() const
G4Region * GetRegion() const
G4FieldManager * GetFieldManager() const
G4VPVParameterisation * GetParameterisation() const
G4FieldManager * GetFieldManager() const
static G4TransportationManager * GetTransportationManager()
G4Navigator * GetNavigatorForTracking() const
G4FieldManager * GetFieldManager() const
Representation fRepresentation
virtual void GetFieldAtLocation(const G4Field *field, const G4Point3D &position, G4double time, G4Point3D &result) const =0
G4int fNDataPointsPerMaxHalfExtent
G4VisExtent fExtentForField
std::vector< G4PhysicalVolumesSearchScene::Findings > fPVFindings
G4int fArrow3DLineSegmentsPerCircle
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())=0
virtual void AddPrimitive(const G4Polyline &)=0
virtual const G4VisExtent & GetExtent() const
virtual void EndPrimitives()=0
G4LogicalVolume * GetLogicalVolume() const
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
static const G4VisExtent & GetNullExtent()
void SetVisAttributes(const G4VisAttributes *)
T max(const T t1, const T t2)
brief Return the largest of the two arguments