63 const std::vector<G4PhysicalVolumesSearchScene::Findings>& pvFindings,
64 G4int nDataPointsPerMaxHalfExtent,
66 G4int arrow3DLineSegmentsPerCircle)
67: fExtentForField(extentForField)
68, fPVFindings(pvFindings)
69, fNDataPointsPerMaxHalfExtent(nDataPointsPerMaxHalfExtent)
70, fRepresentation(representation)
71, fArrow3DLineSegmentsPerCircle(arrow3DLineSegmentsPerCircle)
72, fTypeOfField(typeOfField)
75 fType =
"G4"+typeOfField+
"FieldModel";
78 std::ostringstream oss;
82 oss <<
" whole scene";
94 <<
',' << findings.fpFoundPV->GetName()
95 <<
':' << findings.fFoundPVCopyNo;
100 oss <<
" light arrow";
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;
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.) {
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;
177 std::vector<G4Point3D> Field(nSamples);
178 std::vector<G4Point3D> xyz(nSamples);
182 for (
G4int i = 0; i < nXSamples; i++) {
183 G4double x = xSceneCentre + (i - nDataPointsPerXHalfScene) * interval;
185 for (
G4int j = 0; j < nYSamples; j++) {
186 G4double y = ySceneCentre + (j - nDataPointsPerYHalfScene) * interval;
188 for (
G4int k = 0; k < nZSamples; k++) {
189 G4double z = zSceneCentre + (k - nDataPointsPerZHalfScene) * interval;
192 const G4int ijk = i * nYSamples * nZSamples + j * nZSamples + k;
202 G4int copyNo = findings.fFoundPVCopyNo;
207 solid = param->ComputeSolid(copyNo,pvParam);
211 const auto&
transform = findings.fFoundObjectTransformation;
213 auto translation =
transform.getTranslation();
220 if (!isInPV)
continue;
227 const G4Field* field = globalField;
236 if (pRegionFieldMgr) {
256 if (mag > FieldMagnitudeMax) FieldMagnitudeMax = mag;
261 if (FieldMagnitudeMax <= 0.) {
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;
274 red = 2. * (0.5 - f);
276 blue = 2. * (f - 0.5);
277 green = 2. * (1.0 - f);
282 G4bool drawAsLine =
false;
284 case Representation::fullArrow:
289 case Representation::lightArrow:
297 G4double arrowLength = arrowLengthMax * f;
299 if (f < 0.01) arrowLength = arrowLengthMax * 0.01;
300 const G4Point3D head = xyz[i] + arrowLength*Field[i]/Fmag;
307 FArrowLite.push_back(xyz[i]);
308 FArrowLite.push_back(head);
314 head.
x(), head.
y(), head.
z(),
315 arrowLength/5, arrowColour,
static const G4double pos
static const G4double alpha
G4GLOB_DLL std::ostream G4cout
Hep3Vector & transform(const HepRotation &)
void DescribeYourselfTo(G4VGraphicsScene &) override
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
virtual void DescribeYourselfTo(G4VGraphicsScene &sceneHandler)
G4int fArrow3DLineSegmentsPerCircle
G4VFieldModel(const G4String &typeOfField, const G4String &symbol="", const G4VisExtent &extentForField=G4VisExtent(), const std::vector< G4PhysicalVolumesSearchScene::Findings > &pvFindings=std::vector< G4PhysicalVolumesSearchScene::Findings >(), G4int nDataPointsPerHalfScene=10, Representation representation=Representation::fullArrow, G4int arrow3DLineSegmentsPerCircle=6)
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())=0
virtual void AddPrimitive(const G4Polyline &)=0
virtual const G4VisExtent & GetExtent() const
virtual void EndPrimitives()=0
G4String fGlobalDescription
G4LogicalVolume * GetLogicalVolume() const
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
void SetLineWidth(G4double)
static const G4VisExtent & GetNullExtent()
void SetVisAttributes(const G4VisAttributes *)
T max(const T t1, const T t2)
brief Return the largest of the two arguments