63 const std::vector<G4PhysicalVolumesSearchScene::Findings>& pvFindings,
64 G4int nDataPointsPerMaxHalfScene,
66 G4int arrow3DLineSegmentsPerCircle)
67 : fExtentForField(extentForField)
68 , fPVFindings(pvFindings)
69 , fNDataPointsPerMaxHalfScene(nDataPointsPerMaxHalfScene)
70 , fRepresentation(representation)
71 , fArrow3DLineSegmentsPerCircle(arrow3DLineSegmentsPerCircle)
72 , fTypeOfField(typeOfField)
73 , fArrowPrefix(symbol)
75 fType =
"G4"+typeOfField+
"FieldModel";
78 std::ostringstream oss;
79 oss <<
':' << fNDataPointsPerMaxHalfScene
80 <<
':' << fArrow3DLineSegmentsPerCircle;
82 oss <<
" whole scene";
85 <<
':' << fExtentForField.GetXmin()
86 <<
':' << fExtentForField.GetXmax()
87 <<
':' << fExtentForField.GetYmin()
88 <<
':' << fExtentForField.GetYmax()
89 <<
':' << fExtentForField.GetZmin()
90 <<
':' << fExtentForField.GetZmax();
92 for (
const auto& findings: fPVFindings) {
94 <<
',' << findings.fpFoundPV->GetName()
95 <<
':' << findings.fFoundPVCopyNo;
97 if (fRepresentation == Representation::fullArrow) {
99 }
else if (fRepresentation == Representation::lightArrow) {
100 oss <<
" light arrow";
103 fGlobalDescription = fType + oss.str();
119 const G4Field* globalField = 0;
120 const G4String intro =
"G4VFieldModel::DescribeYourselfTo: ";
121 if (globalFieldMgr) {
125 static G4bool warned =
false;
127 G4cout << intro <<
"Null global field pointer." <<
G4endl;
133 static G4bool warned =
false;
135 G4cout << intro <<
"No global field manager." <<
G4endl;
147 const G4double xHalfScene = 0.5 * (xMax - xMin);
148 const G4double yHalfScene = 0.5 * (yMax - yMin);
149 const G4double zHalfScene = 0.5 * (zMax - zMin);
150 const G4double xSceneCentre = 0.5 * (xMax + xMin);
151 const G4double ySceneCentre = 0.5 * (yMax + yMin);
152 const G4double zSceneCentre = 0.5 * (zMax + zMin);
155 if (maxHalfScene <= 0.) {
162 const G4int nDataPointsPerXHalfScene =
G4int(xHalfScene / interval);
163 const G4int nDataPointsPerYHalfScene =
G4int(yHalfScene / interval);
164 const G4int nDataPointsPerZHalfScene =
G4int(zHalfScene / interval);
165 const G4int nXSamples = 2 * nDataPointsPerXHalfScene + 1;
166 const G4int nYSamples = 2 * nDataPointsPerYHalfScene + 1;
167 const G4int nZSamples = 2 * nDataPointsPerZHalfScene + 1;
168 const G4int nSamples = nXSamples * nYSamples * nZSamples;
169 const G4double arrowLengthMax = 0.8 * interval;
172 std::vector<G4Point3D> Field(nSamples);
173 std::vector<G4Point3D> xyz(nSamples);
177 for (
G4int i = 0; i < nXSamples; i++) {
178 G4double x = xSceneCentre + (i - nDataPointsPerXHalfScene) * interval;
180 for (
G4int j = 0; j < nYSamples; j++) {
181 G4double y = ySceneCentre + (j - nDataPointsPerYHalfScene) * interval;
183 for (
G4int k = 0;
k < nZSamples;
k++) {
184 G4double z = zSceneCentre + (
k - nDataPointsPerZHalfScene) * interval;
187 const G4int ijk = i * nYSamples * nZSamples + j * nZSamples +
k;
195 if (x < ext.GetXmin() || x > ext.GetXmax() ||
196 y < ext.GetYmin() || y > ext.GetYmax() ||
197 z < ext.GetZmin() || z > ext.GetZmax())
206 G4int copyNo = findings.fFoundPVCopyNo;
211 solid = param->ComputeSolid(copyNo,pvParam);
215 const auto&
transform = findings.fFoundObjectTransformation;
217 auto translation =
transform.getTranslation();
224 if (!isInPV)
continue;
231 const G4Field* field = globalField;
240 if (pRegionFieldMgr) {
260 if (mag > FieldMagnitudeMax) FieldMagnitudeMax = mag;
265 if (FieldMagnitudeMax <= 0.) {
270 for (
G4int i = 0; i < nSamples; i++) {
271 const G4double Fmag = Field[i].mag();
272 const G4double f = Fmag / FieldMagnitudeMax;
273 if (f <= 0.)
continue;
278 red = 2. * (0.5 -
f);
280 blue = 2. * (f - 0.5);
281 green = 2. * (1.0 -
f);
286 G4bool drawAsLine =
false;
288 case Representation::fullArrow:
293 case Representation::lightArrow:
301 G4double arrowLength = arrowLengthMax *
f;
303 if (f < 0.01) arrowLength = arrowLengthMax * 0.01;
304 const G4Point3D head = xyz[i] + arrowLength*Field[i]/Fmag;
311 FArrowLite.push_back(xyz[i]);
312 FArrowLite.push_back(head);
318 head.
x(), head.
y(), head.
z(),
319 arrowLength/5, arrowColour,