Geant4-11
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
G4PhysicalVolumeModel Class Reference

#include <G4PhysicalVolumeModel.hh>

Inheritance diagram for G4PhysicalVolumeModel:
G4VModel G4LogicalVolumeModel

Data Structures

class  G4PhysicalVolumeModelTouchable
 
class  G4PhysicalVolumeNodeID
 
struct  TouchableProperties
 

Public Types

enum  { UNLIMITED = -1 }
 
enum  ClippingMode { subtraction , intersection }
 

Public Member Functions

void Abort () const
 
void CalculateExtent ()
 
std::vector< G4AttValue > * CreateCurrentAttValues () const
 
void CurtailDescent () const
 
void DescribeYourselfTo (G4VGraphicsScene &)
 
 G4PhysicalVolumeModel (G4VPhysicalVolume *=0, G4int requestedDepth=UNLIMITED, const G4Transform3D &modelTransformation=G4Transform3D(), const G4ModelingParameters *=0, G4bool useFullExtent=false, const std::vector< G4PhysicalVolumeNodeID > &baseFullPVPath=std::vector< G4PhysicalVolumeNodeID >())
 
const std::map< G4String, G4AttDef > * GetAttDefs () const
 
const std::vector< G4PhysicalVolumeNodeID > & GetBaseFullPVPath () const
 
const G4VSolidGetClippingSolid () const
 
G4int GetCurrentDepth () const
 
G4String GetCurrentDescription () const
 
G4LogicalVolumeGetCurrentLV () const
 
G4MaterialGetCurrentMaterial () const
 
G4VPhysicalVolumeGetCurrentPV () const
 
G4int GetCurrentPVCopyNo () const
 
G4String GetCurrentTag () const
 
const G4Transform3DGetCurrentTransform () const
 
const std::vector< G4PhysicalVolumeNodeID > & GetDrawnPVPath () const
 
const G4VisExtentGetExtent () const
 
const std::vector< G4PhysicalVolumeNodeID > & GetFullPVPath () const
 
const G4StringGetGlobalDescription () const
 
const G4StringGetGlobalTag () const
 
const G4ModelingParametersGetModelingParameters () const
 
G4int GetRequestedDepth () const
 
G4VPhysicalVolumeGetTopPhysicalVolume () const
 
const G4Transform3DGetTransformation () const
 
const G4StringGetType () const
 
void SetClippingMode (ClippingMode mode)
 
void SetClippingSolid (G4VSolid *pClippingSolid)
 
void SetExtent (const G4VisExtent &)
 
void SetGlobalDescription (const G4String &)
 
void SetGlobalTag (const G4String &)
 
void SetModelingParameters (const G4ModelingParameters *)
 
void SetRequestedDepth (G4int requestedDepth)
 
void SetType (const G4String &)
 
G4bool Validate (G4bool warn)
 
virtual ~G4PhysicalVolumeModel ()
 

Static Public Member Functions

static G4ModelingParameters::PVNameCopyNoPath GetPVNameCopyNoPath (const std::vector< G4PhysicalVolumeNodeID > &)
 

Protected Member Functions

void DescribeAndDescend (G4VPhysicalVolume *, G4int requestedDepth, G4LogicalVolume *, G4VSolid *, G4Material *, const G4Transform3D &, G4VGraphicsScene &)
 
virtual void DescribeSolid (const G4Transform3D &theAT, G4VSolid *pSol, const G4VisAttributes *pVisAttribs, G4VGraphicsScene &sceneHandler)
 
void VisitGeometryAndGetVisReps (G4VPhysicalVolume *, G4int requestedDepth, const G4Transform3D &, G4VGraphicsScene &)
 

Protected Attributes

G4bool fAbort
 
std::vector< G4PhysicalVolumeNodeIDfBaseFullPVPath
 
ClippingMode fClippingMode
 
G4int fCurrentDepth
 
G4int fCurrentPVCopyNo
 
G4Transform3D fCurrentTransform
 
G4bool fCurtailDescent
 
std::vector< G4PhysicalVolumeNodeIDfDrawnPVPath
 
G4VisExtent fExtent
 
std::vector< G4PhysicalVolumeNodeIDfFullPVPath
 
G4String fGlobalDescription
 
G4String fGlobalTag
 
G4VSolidfpClippingSolid
 
G4LogicalVolumefpCurrentLV
 
G4MaterialfpCurrentMaterial
 
G4VPhysicalVolumefpCurrentPV
 
const G4ModelingParametersfpMP
 
G4VPhysicalVolumefpTopPV
 
G4int fRequestedDepth
 
G4int fTopPVCopyNo
 
G4String fTopPVName
 
G4Transform3D fTransform
 
G4String fType
 
G4bool fUseFullExtent
 

Private Member Functions

 G4PhysicalVolumeModel (const G4PhysicalVolumeModel &)
 
G4PhysicalVolumeModeloperator= (const G4PhysicalVolumeModel &)
 

Detailed Description

Definition at line 82 of file G4PhysicalVolumeModel.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
UNLIMITED 

Definition at line 86 of file G4PhysicalVolumeModel.hh.

◆ ClippingMode

Enumerator
subtraction 
intersection 

Definition at line 88 of file G4PhysicalVolumeModel.hh.

Constructor & Destructor Documentation

◆ G4PhysicalVolumeModel() [1/2]

G4PhysicalVolumeModel::G4PhysicalVolumeModel ( G4VPhysicalVolume pVPV = 0,
G4int  requestedDepth = UNLIMITED,
const G4Transform3D modelTransformation = G4Transform3D(),
const G4ModelingParameters pMP = 0,
G4bool  useFullExtent = false,
const std::vector< G4PhysicalVolumeNodeID > &  baseFullPVPath = std::vector<G4PhysicalVolumeNodeID>() 
)

Definition at line 63 of file G4PhysicalVolumeModel.cc.

70: G4VModel (pMP)
71, fpTopPV (pVPV)
72, fTopPVCopyNo (pVPV? pVPV->GetCopyNo(): 0)
73, fRequestedDepth (requestedDepth)
74, fUseFullExtent (useFullExtent)
75, fTransform (modelTransform)
76, fCurrentDepth (0)
81, fCurrentTransform (modelTransform)
82, fBaseFullPVPath (baseFullPVPath)
83, fAbort (false)
84, fCurtailDescent (false)
87{
88 fType = "G4PhysicalVolumeModel";
89
90 if (!fpTopPV) {
91
92 // In some circumstances creating an "empty" G4PhysicalVolumeModel is
93 // allowed, so I have supressed the G4Exception below. If it proves to
94 // be a problem we might have to re-instate it, but it is unlikley to
95 // be used except by visualisation experts. See, for example, /vis/list,
96 // where it is used simply to get a list of G4AttDefs.
97 // G4Exception
98 // ("G4PhysicalVolumeModel::G4PhysicalVolumeModel",
99 // "modeling0010", FatalException, "Null G4PhysicalVolumeModel pointer.");
100
101 fTopPVName = "NULL";
102 fGlobalTag = "Empty";
103 fGlobalDescription = "G4PhysicalVolumeModel " + fGlobalTag;
104
105 } else {
106
107 fTopPVName = fpTopPV -> GetName ();
108 std::ostringstream oss;
109 oss << fpTopPV->GetName() << ':' << fpTopPV->GetCopyNo()
110 << " BasePath:" << fBaseFullPVPath;
111 fGlobalTag = oss.str();
112 fGlobalDescription = "G4PhysicalVolumeModel " + fGlobalTag;
114 }
115}
G4Material * GetMaterial() const
G4VPhysicalVolume * fpTopPV
std::vector< G4PhysicalVolumeNodeID > fBaseFullPVPath
G4VPhysicalVolume * fpCurrentPV
G4String fGlobalDescription
Definition: G4VModel.hh:100
G4String fType
Definition: G4VModel.hh:98
G4VModel(const G4ModelingParameters *=0)
Definition: G4VModel.cc:37
G4String fGlobalTag
Definition: G4VModel.hh:99
G4LogicalVolume * GetLogicalVolume() const
virtual G4int GetCopyNo() const =0
const G4String & GetName() const

References CalculateExtent(), fBaseFullPVPath, G4VModel::fGlobalDescription, G4VModel::fGlobalTag, fpTopPV, fTopPVName, G4VModel::fType, G4VPhysicalVolume::GetCopyNo(), and G4VPhysicalVolume::GetName().

◆ ~G4PhysicalVolumeModel()

G4PhysicalVolumeModel::~G4PhysicalVolumeModel ( )
virtual

Definition at line 117 of file G4PhysicalVolumeModel.cc.

118{
119 delete fpClippingSolid;
120}

References fpClippingSolid.

◆ G4PhysicalVolumeModel() [2/2]

G4PhysicalVolumeModel::G4PhysicalVolumeModel ( const G4PhysicalVolumeModel )
private

Member Function Documentation

◆ Abort()

void G4PhysicalVolumeModel::Abort ( ) const
inline

Definition at line 251 of file G4PhysicalVolumeModel.hh.

251{fAbort = true;}

References fAbort.

Referenced by G4TouchablePropertiesScene::ProcessVolume().

◆ CalculateExtent()

void G4PhysicalVolumeModel::CalculateExtent ( )

Definition at line 134 of file G4PhysicalVolumeModel.cc.

135{
136 // To handle paramaterisations, set copy number and compute dimensions
137 // to get extent right
138 G4VPVParameterisation* pP = fpTopPV -> GetParameterisation ();
139 if (pP) {
140 fpTopPV -> SetCopyNo (fTopPVCopyNo);
141 G4VSolid* solid = pP -> ComputeSolid (fTopPVCopyNo, fpTopPV);
142 solid -> ComputeDimensions (pP, fTopPVCopyNo, fpTopPV);
143 }
144 if (fUseFullExtent) {
145 fExtent = fpTopPV -> GetLogicalVolume () -> GetSolid () -> GetExtent ();
146 } else {
147 // Calculate extent of *drawn* volumes, i.e., ignoring culled, e.g.,
148 // invisible volumes, by traversing the whole geometry hierarchy below
149 // this physical volume.
150 G4BoundingExtentScene beScene(this);
151 const G4int tempRequestedDepth = fRequestedDepth;
152 const G4Transform3D tempTransform = fTransform;
153 const G4ModelingParameters* tempMP = fpMP;
154 fRequestedDepth = -1; // Always search to all depths to define extent.
155 fTransform = G4Transform3D(); // Extent is in local cooridinates
157 (0, // No default vis attributes needed.
158 G4ModelingParameters::wf, // wireframe (not relevant for this).
159 true, // Global culling.
160 true, // Cull invisible volumes.
161 false, // Density culling.
162 0., // Density (not relevant if density culling false).
163 true, // Cull daughters of opaque mothers.
164 24); // No of sides (not relevant for this operation).
165 fpMP = &mParams;
166 DescribeYourselfTo (beScene);
167 fExtent = beScene.GetBoundingExtent();
168 fpMP = tempMP;
169 fTransform = tempTransform;
170 fRequestedDepth = tempRequestedDepth;
171 }
173 if (radius < 0.) { // Nothing in the scene - revert to top extent
174 fExtent = fpTopPV -> GetLogicalVolume () -> GetSolid () -> GetExtent ();
175 }
177}
HepGeom::Transform3D G4Transform3D
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
void DescribeYourselfTo(G4VGraphicsScene &)
G4VisExtent fExtent
Definition: G4VModel.hh:101
const G4VisExtent & GetExtent() const
const G4ModelingParameters * fpMP
Definition: G4VModel.hh:102
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:75
G4VisExtent & Transform(const G4Transform3D &)
Definition: G4VisExtent.cc:102

References DescribeYourselfTo(), G4VModel::fExtent, G4VModel::fpMP, fpTopPV, fRequestedDepth, fTopPVCopyNo, fTransform, fUseFullExtent, G4BoundingExtentScene::GetBoundingExtent(), G4VModel::GetExtent(), G4VisExtent::GetExtentRadius(), G4VisExtent::Transform(), and G4ModelingParameters::wf.

Referenced by G4PhysicalVolumeModel(), and G4VVisCommandGeometrySet::Set().

◆ CreateCurrentAttValues()

std::vector< G4AttValue > * G4PhysicalVolumeModel::CreateCurrentAttValues ( ) const

Definition at line 984 of file G4PhysicalVolumeModel.cc.

985{
986 std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
987
988 if (!fpCurrentLV) {
990 ("G4PhysicalVolumeModel::CreateCurrentAttValues",
991 "modeling0004",
993 "Current logical volume not defined.");
994 return values;
995 }
996
997 std::ostringstream oss; oss << fFullPVPath;
998 values->push_back(G4AttValue("PVPath", oss.str(),""));
999 oss.str(""); oss << fBaseFullPVPath;
1000 values->push_back(G4AttValue("BasePVPath", oss.str(),""));
1001 values->push_back(G4AttValue("LVol", fpCurrentLV->GetName(),""));
1002 G4VSolid* pSol = fpCurrentLV->GetSolid();
1003 values->push_back(G4AttValue("Solid", pSol->GetName(),""));
1004 values->push_back(G4AttValue("EType", pSol->GetEntityType(),""));
1005 oss.str(""); oss << '\n' << *pSol;
1006 values->push_back(G4AttValue("DmpSol", oss.str(),""));
1007 const G4RotationMatrix localRotation = fpCurrentPV->GetObjectRotationValue();
1008 const G4ThreeVector& localTranslation = fpCurrentPV->GetTranslation();
1009 oss.str(""); oss << '\n' << G4Transform3D(localRotation,localTranslation);
1010 values->push_back(G4AttValue("LocalTrans", oss.str(),""));
1011 oss.str(""); oss << '\n' << fCurrentTransform;
1012 values->push_back(G4AttValue("GlobalTrans", oss.str(),""));
1013 G4String matName = fpCurrentMaterial? fpCurrentMaterial->GetName(): G4String("No material");
1014 values->push_back(G4AttValue("Material", matName,""));
1016 values->push_back(G4AttValue("Density", G4BestUnit(matDensity,"Volumic Mass"),""));
1018 oss.str(""); oss << matState;
1019 values->push_back(G4AttValue("State", oss.str(),""));
1021 values->push_back(G4AttValue("Radlen", G4BestUnit(matRadlen,"Length"),""));
1022 G4Region* region = fpCurrentLV->GetRegion();
1023 G4String regionName = region? region->GetName(): G4String("No region");
1024 values->push_back(G4AttValue("Region", regionName,""));
1025 oss.str(""); oss << fpCurrentLV->IsRootRegion();
1026 values->push_back(G4AttValue("RootRegion", oss.str(),""));
1027 return values;
1028}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
G4State
Definition: G4Material.hh:111
@ kStateUndefined
Definition: G4Material.hh:111
#define G4BestUnit(a, b)
G4VSolid * GetSolid() const
G4bool IsRootRegion() const
G4Region * GetRegion() const
const G4String & GetName() const
G4double GetDensity() const
Definition: G4Material.hh:176
G4State GetState() const
Definition: G4Material.hh:177
G4double GetRadlen() const
Definition: G4Material.hh:216
const G4String & GetName() const
Definition: G4Material.hh:173
std::vector< G4PhysicalVolumeNodeID > fFullPVPath
const G4String & GetName() const
const G4ThreeVector GetTranslation() const
G4RotationMatrix GetObjectRotationValue() const
G4String GetName() const
virtual G4GeometryType GetEntityType() const =0

References fBaseFullPVPath, fCurrentTransform, fFullPVPath, fpCurrentLV, fpCurrentMaterial, fpCurrentPV, G4BestUnit, G4Exception(), G4Material::GetDensity(), G4VSolid::GetEntityType(), G4LogicalVolume::GetName(), G4Region::GetName(), G4VSolid::GetName(), G4Material::GetName(), G4VPhysicalVolume::GetObjectRotationValue(), G4Material::GetRadlen(), G4LogicalVolume::GetRegion(), G4LogicalVolume::GetSolid(), G4Material::GetState(), G4VPhysicalVolume::GetTranslation(), G4LogicalVolume::IsRootRegion(), JustWarning, and kStateUndefined.

Referenced by G4VSceneHandler::LoadAtts(), G4ASCIITreeSceneHandler::RequestPrimitives(), and G4VisCommandsTouchable::SetNewValue().

◆ CurtailDescent()

void G4PhysicalVolumeModel::CurtailDescent ( ) const
inline

◆ DescribeAndDescend()

void G4PhysicalVolumeModel::DescribeAndDescend ( G4VPhysicalVolume pVPV,
G4int  requestedDepth,
G4LogicalVolume pLV,
G4VSolid pSol,
G4Material pMaterial,
const G4Transform3D theAT,
G4VGraphicsScene sceneHandler 
)
protected

Definition at line 381 of file G4PhysicalVolumeModel.cc.

389{
390 // Maintain useful data members...
391 fpCurrentPV = pVPV;
392 fCurrentPVCopyNo = pVPV->GetCopyNo();
393 fpCurrentLV = pLV;
394 fpCurrentMaterial = pMaterial;
395
396 // Create a nodeID for use below - note the "drawn" flag is true
397 G4int copyNo = fpCurrentPV->GetCopyNo();
398 auto nodeID = G4PhysicalVolumeNodeID
400
401 // Update full path of physical volumes...
402 fFullPVPath.push_back(nodeID);
403
404 const G4RotationMatrix objectRotation = pVPV -> GetObjectRotationValue ();
405 const G4ThreeVector& translation = pVPV -> GetTranslation ();
406 G4Transform3D theLT (G4Transform3D (objectRotation, translation));
407
408 // Compute the accumulated transformation...
409 // Note that top volume's transformation relative to the world
410 // coordinate system is specified in theAT == startingTransformation
411 // = fTransform (see DescribeYourselfTo), so first time through the
412 // volume's own transformation, which is only relative to its
413 // mother, i.e., not relative to the world coordinate system, should
414 // not be accumulated.
415 G4Transform3D theNewAT (theAT);
416 if (fCurrentDepth != 0) theNewAT = theAT * theLT;
417 fCurrentTransform = theNewAT;
418
419 const G4VisAttributes* pVisAttribs = pLV->GetVisAttributes();
420 // If the volume does not have any vis attributes, create it.
421 G4VisAttributes* tempVisAtts = nullptr;
422 if (!pVisAttribs) {
424 tempVisAtts = new G4VisAttributes(*fpMP->GetDefaultVisAttributes());
425 } else {
426 tempVisAtts = new G4VisAttributes;
427 }
428 // The user may request /vis/viewer/set/colourByDensity.
429 if (fpMP->GetCBDAlgorithmNumber() == 1) {
430 // Algorithm 1: 3 parameters: Simple rainbow mapping.
431 if (fpMP->GetCBDParameters().size() != 3) {
432 G4Exception("G4PhysicalVolumeModelTouchable::DescribeAndDescend",
433 "modeling0014",
435 "Algorithm-parameter mismatch for Colour By Density");
436 } else {
437 const G4double d = pMaterial? pMaterial->GetDensity(): 0.;
438 const G4double d0 = fpMP->GetCBDParameters()[0]; // Invisible d < d0.
439 const G4double d1 = fpMP->GetCBDParameters()[1]; // Rainbow d0->d1->d2.
440 const G4double d2 = fpMP->GetCBDParameters()[2]; // Blue d > d2.
441 if (d < d0) { // Density < d0 is invisible.
442 tempVisAtts->SetVisibility(false);
443 } else { // Intermediate densities are on a spectrum.
444 G4double red, green, blue;
445 if (d < d1) {
446 red = (d1-d)/(d1-d0); green = (d-d0)/(d1-d0); blue = 0.;
447 } else if (d < d2) {
448 red = 0.; green = (d2-d)/(d2-d1); blue = (d-d1)/(d2-d1);
449 } else { // Density >= d2 is blue.
450 red = 0.; green = 0.; blue = 1.;
451 }
452 tempVisAtts->SetColour(G4Colour(red,green,blue));
453 }
454 }
455 } else if (fpMP->GetCBDAlgorithmNumber() == 2) {
456 // Algorithm 2
457 // ...etc.
458 }
459 pVisAttribs = tempVisAtts;
460 }
461 // From here, can assume pVisAttribs is a valid pointer. This is necessary
462 // because PreAddSolid needs a vis attributes object.
463
464 // Check if vis attributes are to be modified by a /vis/touchable/set/ command.
465 const auto& vams = fpMP->GetVisAttributesModifiers();
466 if (vams.size()) {
467 // OK, we have some VAMs (Vis Attributes Modifiers).
468 for (const auto& vam: vams) {
469 const auto& vamPath = vam.GetPVNameCopyNoPath();
470 if (vamPath.size() == fFullPVPath.size()) {
471 // OK, we have a size match.
472 // Check the volume name/copy number path.
473 auto iVAMNameCopyNo = vamPath.begin();
474 auto iPVNodeId = fFullPVPath.begin();
475 for (; iVAMNameCopyNo != vamPath.end(); ++iVAMNameCopyNo, ++iPVNodeId) {
476 if (!(
477 iVAMNameCopyNo->GetName() ==
478 iPVNodeId->GetPhysicalVolume()->GetName() &&
479 iVAMNameCopyNo->GetCopyNo() ==
480 iPVNodeId->GetPhysicalVolume()->GetCopyNo()
481 )) {
482 // This path element does NOT match.
483 break;
484 }
485 }
486 if (iVAMNameCopyNo == vamPath.end()) {
487 // OK, the paths match (the above loop terminated normally).
488 // Create a vis atts object for the modified vis atts.
489 // It is static so that we may return a reliable pointer to it.
490 static G4VisAttributes modifiedVisAtts;
491 // Initialise it with the current vis atts and reset the pointer.
492 modifiedVisAtts = *pVisAttribs;
493 pVisAttribs = &modifiedVisAtts;
494 const G4VisAttributes& transVisAtts = vam.GetVisAttributes();
495 switch (vam.GetVisAttributesSignifier()) {
497 modifiedVisAtts.SetVisibility(transVisAtts.IsVisible());
498 break;
500 modifiedVisAtts.SetDaughtersInvisible
501 (transVisAtts.IsDaughtersInvisible());
502 break;
504 modifiedVisAtts.SetColour(transVisAtts.GetColour());
505 break;
507 modifiedVisAtts.SetLineStyle(transVisAtts.GetLineStyle());
508 break;
510 modifiedVisAtts.SetLineWidth(transVisAtts.GetLineWidth());
511 break;
513 if (transVisAtts.IsForceDrawingStyle()) {
514 if (transVisAtts.GetForcedDrawingStyle() ==
516 modifiedVisAtts.SetForceWireframe(true);
517 }
518 }
519 break;
521 if (transVisAtts.IsForceDrawingStyle()) {
522 if (transVisAtts.GetForcedDrawingStyle() ==
524 modifiedVisAtts.SetForceSolid(true);
525 }
526 }
527 break;
529 if (transVisAtts.IsForceDrawingStyle()) {
530 if (transVisAtts.GetForcedDrawingStyle() ==
532 modifiedVisAtts.SetForceCloud(true);
533 }
534 }
535 break;
537 modifiedVisAtts.SetForceNumberOfCloudPoints
538 (transVisAtts.GetForcedNumberOfCloudPoints());
539 break;
541 if (transVisAtts.IsForceAuxEdgeVisible()) {
542 modifiedVisAtts.SetForceAuxEdgeVisible
543 (transVisAtts.IsForcedAuxEdgeVisible());
544 }
545 break;
547 modifiedVisAtts.SetForceLineSegmentsPerCircle
548 (transVisAtts.GetForcedLineSegmentsPerCircle());
549 break;
550 }
551 }
552 }
553 }
554 }
555
556 // Check for special mesh rendering
558 if (fpMP->GetSpecialMeshVolumes().empty()) {
559 // No volumes specified - all are potentially possible
560 goto create_mesh;
561 } else {
562 for (const auto& pvNameCopyNo: fpMP->GetSpecialMeshVolumes()) {
563 if (pVPV->GetName() == pvNameCopyNo.GetName()) {
564 // We have a name match
565 if (pvNameCopyNo.GetCopyNo() < 0) {
566 // Any copy number is OK
567 goto create_mesh;
568 } else {
569 if (pVPV->GetCopyNo() == pvNameCopyNo.GetCopyNo()) {
570 // We have a name and copy number match
571 goto create_mesh;
572 }
573 }
574 }
575 }
576 // We have fallen out of this loop without finding a match
577 goto continue_processing;
578 }
579 create_mesh:
580 // Create - or at least attempt to create - a mesh. If it cannot be created
581 // out of this pVPV the type will be "invalid".
582 G4Mesh mesh(pVPV,theNewAT);
583 if (mesh.GetMeshType() != G4Mesh::invalid) {
584 fFullPVPath.push_back(nodeID);
585 fDrawnPVPath.push_back(nodeID);
586 sceneHandler.AddCompound(mesh);
587 fFullPVPath.pop_back();
588 fDrawnPVPath.pop_back();
589 delete tempVisAtts; // Needs cleaning up (Coverity warning!!)
590 return;
591 } // else continue processing
592 }
593continue_processing:
594
595 // Make decision to draw...
596 G4bool thisToBeDrawn = true;
597
598 // There are various reasons why this volume
599 // might not be drawn...
600 G4bool culling = fpMP->IsCulling();
601 G4bool cullingInvisible = fpMP->IsCullingInvisible();
602 G4bool markedVisible
603 = pVisAttribs->IsVisible() && pVisAttribs->GetColour().GetAlpha() > 0;
604 G4bool cullingLowDensity = fpMP->IsDensityCulling();
605 G4double density = pMaterial? pMaterial->GetDensity(): 0;
606 G4double densityCut = fpMP -> GetVisibleDensity ();
607
608 // 1) Global culling is on....
609 if (culling) {
610 // 2) Culling of invisible volumes is on...
611 if (cullingInvisible) {
612 // 3) ...and the volume is marked not visible...
613 if (!markedVisible) thisToBeDrawn = false;
614 }
615 // 4) Or culling of low density volumes is on...
616 if (cullingLowDensity) {
617 // 5) ...and density is less than cut value...
618 if (density < densityCut) thisToBeDrawn = false;
619 }
620 }
621 // 6) The user has asked for all further traversing to be aborted...
622 if (fAbort) thisToBeDrawn = false;
623
624 // Set "drawn" flag (it was true by default) - thisToBeDrawn may be false
625 nodeID.SetDrawn(thisToBeDrawn);
626
627 if (thisToBeDrawn) {
628
629 // Update path of drawn physical volumes...
630 fDrawnPVPath.push_back(nodeID);
631
632 if (fpMP->IsExplode() && fDrawnPVPath.size() == 1) {
633 // For top-level drawn volumes, explode along radius...
635 G4Transform3D centred = centering.inverse() * theNewAT;
636 G4Scale3D oldScale;
637 G4Rotate3D oldRotation;
638 G4Translate3D oldTranslation;
639 centred.getDecomposition(oldScale, oldRotation, oldTranslation);
640 G4double explodeFactor = fpMP->GetExplodeFactor();
641 G4Translate3D newTranslation =
642 G4Translate3D(explodeFactor * oldTranslation.dx(),
643 explodeFactor * oldTranslation.dy(),
644 explodeFactor * oldTranslation.dz());
645 theNewAT = centering * newTranslation * oldRotation * oldScale;
646 }
647
648 volumeCount++;
649 DescribeSolid (theNewAT, pSol, pVisAttribs, sceneHandler);
650
651 }
652
653 // Make decision to draw daughters, if any. There are various
654 // reasons why daughters might not be drawn...
655
656 // First, reasons that do not depend on culling policy...
657 G4int nDaughters = pLV->GetNoDaughters();
658 G4bool daughtersToBeDrawn = true;
659 // 1) There are no daughters...
660 if (!nDaughters) daughtersToBeDrawn = false;
661 // 2) We are at the limit if requested depth...
662 else if (requestedDepth == 0) daughtersToBeDrawn = false;
663 // 3) The user has asked for all further traversing to be aborted...
664 else if (fAbort) daughtersToBeDrawn = false;
665 // 4) The user has asked that the descent be curtailed...
666 else if (fCurtailDescent) daughtersToBeDrawn = false;
667
668 // Now, reasons that depend on culling policy...
669 else {
670 G4bool daughtersInvisible = pVisAttribs->IsDaughtersInvisible();
671 // Culling of covered daughters request. This is computed in
672 // G4VSceneHandler::CreateModelingParameters() depending on view
673 // parameters...
674 G4bool cullingCovered = fpMP->IsCullingCovered();
675 G4bool surfaceDrawing =
678 if (pVisAttribs->IsForceDrawingStyle()) {
679 switch (pVisAttribs->GetForcedDrawingStyle()) {
680 default:
681 case G4VisAttributes::wireframe: surfaceDrawing = false; break;
682 case G4VisAttributes::solid: surfaceDrawing = true; break;
683 }
684 }
685 G4bool opaque = pVisAttribs->GetColour().GetAlpha() >= 1.;
686 // 5) Global culling is on....
687 if (culling) {
688 // 6) ..and culling of invisible volumes is on...
689 if (cullingInvisible) {
690 // 7) ...and the mother requests daughters invisible
691 if (daughtersInvisible) daughtersToBeDrawn = false;
692 }
693 // 8) Or culling of covered daughters is requested...
694 if (cullingCovered) {
695 // 9) ...and surface drawing is operating...
696 if (surfaceDrawing) {
697 // 10) ...but only if mother is visible...
698 if (thisToBeDrawn) {
699 // 11) ...and opaque...
700 if (opaque) daughtersToBeDrawn = false;
701 }
702 }
703 }
704 }
705 }
706
707 if (daughtersToBeDrawn) {
708 for (G4int iDaughter = 0; iDaughter < nDaughters; iDaughter++) {
709 // Store daughter pVPV in local variable ready for recursion...
710 G4VPhysicalVolume* pDaughterVPV = pLV -> GetDaughter (iDaughter);
711 // Descend the geometry structure recursively...
714 (pDaughterVPV, requestedDepth - 1, theNewAT, sceneHandler);
716 }
717 }
718
719 // Clean up
720 delete tempVisAtts;
721
722 // Reset for normal descending of next volume at this level...
723 fCurtailDescent = false;
724
725 // Pop item from paths physical volumes...
726 fFullPVPath.pop_back();
727 if (thisToBeDrawn) {
728 fDrawnPVPath.pop_back();
729 }
730}
static const G4double d1
static const G4double d2
@ FatalErrorInArgument
HepGeom::Translate3D G4Translate3D
bool G4bool
Definition: G4Types.hh:86
G4double GetAlpha() const
Definition: G4Colour.hh:155
const G4VisAttributes * GetVisAttributes() const
size_t GetNoDaughters() const
Definition: G4Mesh.hh:47
@ invalid
Definition: G4Mesh.hh:51
const G4VisAttributes * GetDefaultVisAttributes() const
const std::vector< VisAttributesModifier > & GetVisAttributesModifiers() const
const G4Point3D & GetExplodeCentre() const
G4bool IsCullingInvisible() const
const std::vector< PVNameCopyNo > & GetSpecialMeshVolumes() const
G4bool IsExplode() const
G4bool IsCulling() const
const std::vector< G4double > & GetCBDParameters() const
G4bool IsDensityCulling() const
G4bool IsSpecialMeshRendering() const
DrawingStyle GetDrawingStyle() const
G4double GetExplodeFactor() const
G4bool IsCullingCovered() const
G4int GetCBDAlgorithmNumber() const
void VisitGeometryAndGetVisReps(G4VPhysicalVolume *, G4int requestedDepth, const G4Transform3D &, G4VGraphicsScene &)
std::vector< G4PhysicalVolumeNodeID > fDrawnPVPath
virtual void DescribeSolid(const G4Transform3D &theAT, G4VSolid *pSol, const G4VisAttributes *pVisAttribs, G4VGraphicsScene &sceneHandler)
virtual void AddCompound(const G4VTrajectory &)=0
G4int GetForcedNumberOfCloudPoints() const
G4double GetLineWidth() const
G4bool IsDaughtersInvisible() const
void SetColour(const G4Colour &)
void SetVisibility(G4bool=true)
void SetForceAuxEdgeVisible(G4bool=true)
void SetForceCloud(G4bool=true)
G4int GetForcedLineSegmentsPerCircle() const
void SetForceWireframe(G4bool=true)
void SetLineWidth(G4double)
LineStyle GetLineStyle() const
const G4Colour & GetColour() const
G4bool IsVisible() const
G4bool IsForceAuxEdgeVisible() const
G4bool IsForcedAuxEdgeVisible() const
ForcedDrawingStyle GetForcedDrawingStyle() const
void SetForceSolid(G4bool=true)
void SetLineStyle(LineStyle)
void SetForceLineSegmentsPerCircle(G4int nSegments)
void SetDaughtersInvisible(G4bool=true)
void SetForceNumberOfCloudPoints(G4int nPoints)
G4bool IsForceDrawingStyle() const
double dy() const
Definition: Transform3D.h:287
double dz() const
Definition: Transform3D.h:290
double dx() const
Definition: Transform3D.h:284
void getDecomposition(Scale3D &scale, Rotate3D &rotation, Translate3D &translation) const
Definition: Transform3D.cc:173
Transform3D inverse() const
Definition: Transform3D.cc:141

References G4VGraphicsScene::AddCompound(), G4VisAttributes::cloud, d1, d2, DescribeSolid(), HepGeom::Transform3D::dx(), HepGeom::Transform3D::dy(), HepGeom::Transform3D::dz(), fAbort, FatalErrorInArgument, fCurrentDepth, fCurrentPVCopyNo, fCurrentTransform, fCurtailDescent, fDrawnPVPath, fFullPVPath, fpCurrentLV, fpCurrentMaterial, fpCurrentPV, G4VModel::fpMP, G4Exception(), G4Colour::GetAlpha(), G4ModelingParameters::GetCBDAlgorithmNumber(), G4ModelingParameters::GetCBDParameters(), G4VisAttributes::GetColour(), G4VPhysicalVolume::GetCopyNo(), HepGeom::Transform3D::getDecomposition(), G4ModelingParameters::GetDefaultVisAttributes(), G4Material::GetDensity(), G4ModelingParameters::GetDrawingStyle(), G4ModelingParameters::GetExplodeCentre(), G4ModelingParameters::GetExplodeFactor(), G4VisAttributes::GetForcedDrawingStyle(), G4VisAttributes::GetForcedLineSegmentsPerCircle(), G4VisAttributes::GetForcedNumberOfCloudPoints(), G4VisAttributes::GetLineStyle(), G4VisAttributes::GetLineWidth(), G4Mesh::GetMeshType(), G4VPhysicalVolume::GetName(), G4LogicalVolume::GetNoDaughters(), G4ModelingParameters::GetSpecialMeshVolumes(), G4LogicalVolume::GetVisAttributes(), G4ModelingParameters::GetVisAttributesModifiers(), G4ModelingParameters::hlhsr, G4ModelingParameters::hsr, G4Mesh::invalid, HepGeom::Transform3D::inverse(), G4ModelingParameters::IsCulling(), G4ModelingParameters::IsCullingCovered(), G4ModelingParameters::IsCullingInvisible(), G4VisAttributes::IsDaughtersInvisible(), G4ModelingParameters::IsDensityCulling(), G4ModelingParameters::IsExplode(), G4VisAttributes::IsForceAuxEdgeVisible(), G4VisAttributes::IsForcedAuxEdgeVisible(), G4VisAttributes::IsForceDrawingStyle(), G4ModelingParameters::IsSpecialMeshRendering(), G4VisAttributes::IsVisible(), G4VisAttributes::SetColour(), G4VisAttributes::SetDaughtersInvisible(), G4VisAttributes::SetForceAuxEdgeVisible(), G4VisAttributes::SetForceCloud(), G4VisAttributes::SetForceLineSegmentsPerCircle(), G4VisAttributes::SetForceNumberOfCloudPoints(), G4VisAttributes::SetForceSolid(), G4VisAttributes::SetForceWireframe(), G4VisAttributes::SetLineStyle(), G4VisAttributes::SetLineWidth(), G4VisAttributes::SetVisibility(), G4VisAttributes::solid, G4ModelingParameters::VASColour, G4ModelingParameters::VASDaughtersInvisible, G4ModelingParameters::VASForceAuxEdgeVisible, G4ModelingParameters::VASForceCloud, G4ModelingParameters::VASForceLineSegmentsPerCircle, G4ModelingParameters::VASForceNumberOfCloudPoints, G4ModelingParameters::VASForceSolid, G4ModelingParameters::VASForceWireframe, G4ModelingParameters::VASLineStyle, G4ModelingParameters::VASLineWidth, G4ModelingParameters::VASVisibility, VisitGeometryAndGetVisReps(), anonymous_namespace{G4PhysicalVolumeModel.cc}::volumeCount, and G4VisAttributes::wireframe.

Referenced by VisitGeometryAndGetVisReps().

◆ DescribeSolid()

void G4PhysicalVolumeModel::DescribeSolid ( const G4Transform3D theAT,
G4VSolid pSol,
const G4VisAttributes pVisAttribs,
G4VGraphicsScene sceneHandler 
)
protectedvirtual

Reimplemented in G4LogicalVolumeModel.

Definition at line 732 of file G4PhysicalVolumeModel.cc.

737{
738 G4DisplacedSolid* pSectionSolid = fpMP->GetSectionSolid();
739 G4DisplacedSolid* pCutawaySolid = fpMP->GetCutawaySolid();
740
741 if (!fpClippingSolid && !pSectionSolid && !pCutawaySolid) {
742
743 sceneHandler.PreAddSolid (theAT, *pVisAttribs);
744 pSol -> DescribeYourselfTo (sceneHandler); // Standard treatment.
745 sceneHandler.PostAddSolid ();
746
747 } else {
748
749 // Clipping, etc., performed by Boolean operations.
750
751 // First, get polyhedron for current solid...
752 if (pVisAttribs->IsForceLineSegmentsPerCircle())
754 (pVisAttribs->GetForcedLineSegmentsPerCircle());
755 else
757 const G4Polyhedron* pOriginalPolyhedron = pSol->GetPolyhedron();
759
760 if (!pOriginalPolyhedron) {
761
762 if (fpMP->IsWarning())
763 G4cout <<
764 "WARNING: G4PhysicalVolumeModel::DescribeSolid: solid\n \""
765 << pSol->GetName() <<
766 "\" has no polyhedron. Cannot by clipped."
767 << G4endl;
768 pSol -> DescribeYourselfTo (sceneHandler); // Standard treatment.
769
770 } else {
771
772 G4VSolid* pResultantSolid = 0;
773
774 if (fpClippingSolid) {
775 switch (fClippingMode) {
776 default:
777 case subtraction:
778 pResultantSolid = new G4SubtractionSolid
779 ("subtracted_clipped_solid", pSol, fpClippingSolid, theAT.inverse());
780 break;
781 case intersection:
782 pResultantSolid = new G4IntersectionSolid
783 ("intersected_clipped_solid", pSol, fpClippingSolid, theAT.inverse());
784 break;
785 }
786 }
787
788 if (pSectionSolid) {
789 pResultantSolid = new G4IntersectionSolid
790 ("sectioned_solid", pSol, pSectionSolid, theAT.inverse());
791 }
792
793 if (pCutawaySolid) {
794 // Follow above...
795 pResultantSolid = new G4SubtractionSolid
796 ("cutaway_solid", pSol, pCutawaySolid, theAT.inverse());
797 }
798
799 G4Polyhedron* pResultantPolyhedron = pResultantSolid->GetPolyhedron();
800 if (!pResultantPolyhedron) {
801 if (fpMP->IsWarning())
802 G4cout <<
803 "WARNING: G4PhysicalVolumeModel::DescribeSolid: resultant polyhedron for"
804 "\n solid \"" << pSol->GetName() <<
805 "\" not defined due to error during Boolean processing."
806 << G4endl;
807 } else {
808 // It seems that if the sectioning solid does not intersect the
809 // original solid the Boolean Processor returns the original
810 // polyhedron, or a copy thereof. We do not want it.
811 // Check the number of facets, etc. If same, ignore.
812 // What we need from the Boolean Processor is a null pointer or a
813 // null polyhedron. It seems to return the original or a copy of it.
814 if (pResultantPolyhedron->GetNoFacets() == pOriginalPolyhedron->GetNoFacets())
815 // This works in most cases but I still get a box in test202 with
816 // /vis/viewer/set/sectionPlane on 0 0 0 m 0.1 0.1 1
817 {
818 pResultantPolyhedron = nullptr;
819 }
820 }
821
822 if (pResultantPolyhedron) {
823 // Finally, draw polyhedron...
824 sceneHandler.BeginPrimitives(theAT);
825 pResultantPolyhedron->SetVisAttributes(pVisAttribs);
826 sceneHandler.AddPrimitive(*pResultantPolyhedron);
827 sceneHandler.EndPrimitives();
828 }
829
830 delete pResultantSolid;
831 }
832 }
833}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4bool IsWarning() const
G4int GetNoOfSides() const
G4DisplacedSolid * GetSectionSolid() const
G4DisplacedSolid * GetCutawaySolid() const
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())=0
virtual void PostAddSolid()=0
virtual void AddPrimitive(const G4Polyline &)=0
virtual void EndPrimitives()=0
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)=0
virtual G4Polyhedron * GetPolyhedron() const
Definition: G4VSolid.cc:705
G4bool IsForceLineSegmentsPerCircle() const
void SetVisAttributes(const G4VisAttributes *)
Definition: G4Visible.cc:96
static void SetNumberOfRotationSteps(G4int n)
G4int GetNoFacets() const
static void ResetNumberOfRotationSteps()

References G4VGraphicsScene::AddPrimitive(), G4VGraphicsScene::BeginPrimitives(), DescribeYourselfTo(), G4VGraphicsScene::EndPrimitives(), fClippingMode, fpClippingSolid, G4VModel::fpMP, G4cout, G4endl, G4ModelingParameters::GetCutawaySolid(), G4VisAttributes::GetForcedLineSegmentsPerCircle(), G4VSolid::GetName(), HepPolyhedron::GetNoFacets(), G4ModelingParameters::GetNoOfSides(), G4VSolid::GetPolyhedron(), G4ModelingParameters::GetSectionSolid(), intersection, HepGeom::Transform3D::inverse(), G4VisAttributes::IsForceLineSegmentsPerCircle(), G4ModelingParameters::IsWarning(), G4VGraphicsScene::PostAddSolid(), G4VGraphicsScene::PreAddSolid(), HepPolyhedron::ResetNumberOfRotationSteps(), HepPolyhedron::SetNumberOfRotationSteps(), G4Visible::SetVisAttributes(), and subtraction.

Referenced by DescribeAndDescend().

◆ DescribeYourselfTo()

void G4PhysicalVolumeModel::DescribeYourselfTo ( G4VGraphicsScene sceneHandler)
virtual

Implements G4VModel.

Definition at line 179 of file G4PhysicalVolumeModel.cc.

181{
182 if (!fpTopPV) G4Exception
183 ("G4PhysicalVolumeModel::DescribeYourselfTo",
184 "modeling0012", FatalException, "No model.");
185
186 if (!fpMP) G4Exception
187 ("G4PhysicalVolumeModel::DescribeYourselfTo",
188 "modeling0003", FatalException, "No modeling parameters.");
189
190 G4Transform3D startingTransformation = fTransform;
191
192 volumeCount = 0;
193
195 (fpTopPV,
197 startingTransformation,
198 sceneHandler);
199
200// G4cout
201// << "G4PhysicalVolumeModel::DescribeYourselfTo: volume count: "
202// << volumeCount
203// << G4endl;
204
205 // Reset or clear data...
206 fCurrentDepth = 0;
212 fDrawnPVPath.clear();
213 fAbort = false;
214 fCurtailDescent = false;
215}
@ FatalException

References fAbort, FatalException, fBaseFullPVPath, fCurrentDepth, fCurrentPVCopyNo, fCurtailDescent, fDrawnPVPath, fFullPVPath, fpCurrentLV, fpCurrentMaterial, fpCurrentPV, G4VModel::fpMP, fpTopPV, fRequestedDepth, fTransform, G4Exception(), G4VPhysicalVolume::GetCopyNo(), G4VPhysicalVolume::GetLogicalVolume(), G4LogicalVolume::GetMaterial(), VisitGeometryAndGetVisReps(), and anonymous_namespace{G4PhysicalVolumeModel.cc}::volumeCount.

Referenced by G4OpenGLSceneHandler::AddCompound(), G4Qt3DSceneHandler::AddCompound(), G4VtkSceneHandler::AddCompound(), CalculateExtent(), DescribeSolid(), G4LogicalVolumeModel::DescribeYourselfTo(), G4ASCIITreeSceneHandler::EndModeling(), G4TouchableUtils::FindTouchableProperties(), G4VisCommandSceneAddLocalAxes::SetNewValue(), G4VisCommandSceneAddVolume::SetNewValue(), G4VisCommandSetTouchable::SetNewValue(), G4VisCommandSetVolumeForField::SetNewValue(), G4VisCommandsTouchable::SetNewValue(), and G4VisCommandViewerCentreOn::SetNewValue().

◆ GetAttDefs()

const std::map< G4String, G4AttDef > * G4PhysicalVolumeModel::GetAttDefs ( ) const

Definition at line 907 of file G4PhysicalVolumeModel.cc.

908{
909 G4bool isNew;
910 std::map<G4String,G4AttDef>* store
911 = G4AttDefStore::GetInstance("G4PhysicalVolumeModel", isNew);
912 if (isNew) {
913 (*store)["PVPath"] =
914 G4AttDef("PVPath","Physical Volume Path","Physics","","G4String");
915 (*store)["BasePVPath"] =
916 G4AttDef("BasePVPath","Base Physical Volume Path","Physics","","G4String");
917 (*store)["LVol"] =
918 G4AttDef("LVol","Logical Volume","Physics","","G4String");
919 (*store)["Solid"] =
920 G4AttDef("Solid","Solid Name","Physics","","G4String");
921 (*store)["EType"] =
922 G4AttDef("EType","Entity Type","Physics","","G4String");
923 (*store)["DmpSol"] =
924 G4AttDef("DmpSol","Dump of Solid properties","Physics","","G4String");
925 (*store)["LocalTrans"] =
926 G4AttDef("LocalTrans","Local transformation of volume","Physics","","G4String");
927 (*store)["GlobalTrans"] =
928 G4AttDef("GlobalTrans","Global transformation of volume","Physics","","G4String");
929 (*store)["Material"] =
930 G4AttDef("Material","Material Name","Physics","","G4String");
931 (*store)["Density"] =
932 G4AttDef("Density","Material Density","Physics","G4BestUnit","G4double");
933 (*store)["State"] =
934 G4AttDef("State","Material State (enum undefined,solid,liquid,gas)","Physics","","G4String");
935 (*store)["Radlen"] =
936 G4AttDef("Radlen","Material Radiation Length","Physics","G4BestUnit","G4double");
937 (*store)["Region"] =
938 G4AttDef("Region","Cuts Region","Physics","","G4String");
939 (*store)["RootRegion"] =
940 G4AttDef("RootRegion","Root Region (0/1 = false/true)","Physics","","G4bool");
941 }
942 return store;
943}
std::map< G4String, G4AttDef > * GetInstance(const G4String &storeKey, G4bool &isNew)

References G4AttDefStore::GetInstance().

Referenced by G4VSceneHandler::LoadAtts(), G4ASCIITreeSceneHandler::RequestPrimitives(), G4VisCommandList::SetNewValue(), and G4VisCommandsTouchable::SetNewValue().

◆ GetBaseFullPVPath()

const std::vector< G4PhysicalVolumeNodeID > & G4PhysicalVolumeModel::GetBaseFullPVPath ( ) const
inline

Definition at line 198 of file G4PhysicalVolumeModel.hh.

199 {return fBaseFullPVPath;}

References fBaseFullPVPath.

◆ GetClippingSolid()

const G4VSolid * G4PhysicalVolumeModel::GetClippingSolid ( ) const
inline

Definition at line 174 of file G4PhysicalVolumeModel.hh.

175 {return fpClippingSolid;}

References fpClippingSolid.

◆ GetCurrentDepth()

G4int G4PhysicalVolumeModel::GetCurrentDepth ( ) const
inline

◆ GetCurrentDescription()

G4String G4PhysicalVolumeModel::GetCurrentDescription ( ) const
virtual

Reimplemented from G4VModel.

Definition at line 229 of file G4PhysicalVolumeModel.cc.

230{
231 return "G4PhysicalVolumeModel " + GetCurrentTag ();
232}

References GetCurrentTag().

◆ GetCurrentLV()

G4LogicalVolume * G4PhysicalVolumeModel::GetCurrentLV ( ) const
inline

◆ GetCurrentMaterial()

G4Material * G4PhysicalVolumeModel::GetCurrentMaterial ( ) const
inline

◆ GetCurrentPV()

G4VPhysicalVolume * G4PhysicalVolumeModel::GetCurrentPV ( ) const
inline

◆ GetCurrentPVCopyNo()

G4int G4PhysicalVolumeModel::GetCurrentPVCopyNo ( ) const
inline

◆ GetCurrentTag()

G4String G4PhysicalVolumeModel::GetCurrentTag ( ) const
virtual

Reimplemented from G4VModel.

Definition at line 217 of file G4PhysicalVolumeModel.cc.

218{
219 if (fpCurrentPV) {
220 std::ostringstream o;
221 o << fpCurrentPV -> GetCopyNo ();
222 return fpCurrentPV -> GetName () + ":" + o.str();
223 }
224 else {
225 return "WARNING: NO CURRENT VOLUME - global tag is " + fGlobalTag;
226 }
227}

References G4VModel::fGlobalTag, and fpCurrentPV.

Referenced by GetCurrentDescription().

◆ GetCurrentTransform()

const G4Transform3D & G4PhysicalVolumeModel::GetCurrentTransform ( ) const
inline

◆ GetDrawnPVPath()

const std::vector< G4PhysicalVolumeNodeID > & G4PhysicalVolumeModel::GetDrawnPVPath ( ) const
inline

◆ GetExtent()

const G4VisExtent & G4VModel::GetExtent ( ) const
inherited

◆ GetFullPVPath()

const std::vector< G4PhysicalVolumeNodeID > & G4PhysicalVolumeModel::GetFullPVPath ( ) const
inline

◆ GetGlobalDescription()

const G4String & G4VModel::GetGlobalDescription ( ) const
inherited

◆ GetGlobalTag()

const G4String & G4VModel::GetGlobalTag ( ) const
inherited

◆ GetModelingParameters()

const G4ModelingParameters * G4VModel::GetModelingParameters ( ) const
inherited

◆ GetPVNameCopyNoPath()

G4ModelingParameters::PVNameCopyNoPath G4PhysicalVolumeModel::GetPVNameCopyNoPath ( const std::vector< G4PhysicalVolumeNodeID > &  path)
static

Definition at line 122 of file G4PhysicalVolumeModel.cc.

124{
126 for (const auto& node: path) {
127 PVNameCopyNoPath.push_back
129 (node.GetPhysicalVolume()->GetName(),node.GetCopyNo()));
130 }
131 return PVNameCopyNoPath;
132}
std::vector< PVNameCopyNo > PVNameCopyNoPath

Referenced by G4VViewer::TouchableSetColour(), and G4VViewer::TouchableSetVisibility().

◆ GetRequestedDepth()

G4int G4PhysicalVolumeModel::GetRequestedDepth ( ) const
inline

Definition at line 172 of file G4PhysicalVolumeModel.hh.

172{return fRequestedDepth;}

References fRequestedDepth.

Referenced by G4ASCIITreeSceneHandler::EndModeling().

◆ GetTopPhysicalVolume()

G4VPhysicalVolume * G4PhysicalVolumeModel::GetTopPhysicalVolume ( ) const
inline

◆ GetTransformation()

const G4Transform3D & G4PhysicalVolumeModel::GetTransformation ( ) const
inline

Definition at line 180 of file G4PhysicalVolumeModel.hh.

180{return fTransform;}

References fTransform.

Referenced by G4OpenGLQtViewer::parseAndInsertInSceneTree().

◆ GetType()

const G4String & G4VModel::GetType ( ) const
inherited

◆ operator=()

G4PhysicalVolumeModel & G4PhysicalVolumeModel::operator= ( const G4PhysicalVolumeModel )
private

◆ SetClippingMode()

void G4PhysicalVolumeModel::SetClippingMode ( ClippingMode  mode)
inline

Definition at line 244 of file G4PhysicalVolumeModel.hh.

244 {
245 fClippingMode = mode;
246 }

References fClippingMode.

Referenced by G4VisCommandSceneAddVolume::SetNewValue().

◆ SetClippingSolid()

void G4PhysicalVolumeModel::SetClippingSolid ( G4VSolid pClippingSolid)
inline

Definition at line 240 of file G4PhysicalVolumeModel.hh.

240 {
241 fpClippingSolid = pClippingSolid;
242 }

References fpClippingSolid.

Referenced by G4VisCommandSceneAddVolume::SetNewValue().

◆ SetExtent()

void G4VModel::SetExtent ( const G4VisExtent )
inherited

◆ SetGlobalDescription()

void G4VModel::SetGlobalDescription ( const G4String )
inherited

◆ SetGlobalTag()

void G4VModel::SetGlobalTag ( const G4String )
inherited

◆ SetModelingParameters()

void G4VModel::SetModelingParameters ( const G4ModelingParameters )
inherited

◆ SetRequestedDepth()

void G4PhysicalVolumeModel::SetRequestedDepth ( G4int  requestedDepth)
inline

Definition at line 236 of file G4PhysicalVolumeModel.hh.

236 {
237 fRequestedDepth = requestedDepth;
238 }

References fRequestedDepth.

◆ SetType()

void G4VModel::SetType ( const G4String )
inherited

◆ Validate()

G4bool G4PhysicalVolumeModel::Validate ( G4bool  warn)
virtual

Reimplemented from G4VModel.

Definition at line 835 of file G4PhysicalVolumeModel.cc.

836{
837// Not easy to see how to validate this sort of model. Previously there was
838// a check that a volume of the same name (fTopPVName) existed somewhere in
839// the geometry tree but under some circumstances this consumed lots of CPU
840// time. Instead, let us simply check that the volume (fpTopPV) exists in the
841// physical volume store.
842
843 const auto& pvStore = G4PhysicalVolumeStore::GetInstance();
844 auto iterator = find(pvStore->begin(),pvStore->end(),fpTopPV);
845 if (iterator == pvStore->end()) {
846 if (warn) {
848 ed << "Attempt to validate a volume that is no longer in the physical volume store.";
849 G4Exception("G4PhysicalVolumeModel::Validate", "modeling0015", JustWarning, ed);
850 }
851 return false;
852 } else {
853 return true;
854 }
855
856 // Previous algorithm
857// G4TransportationManager* transportationManager =
858// G4TransportationManager::GetTransportationManager ();
859// size_t nWorlds = transportationManager->GetNoWorlds();
860// G4bool found = false;
861// std::vector<G4VPhysicalVolume*>::iterator iterWorld =
862// transportationManager->GetWorldsIterator();
863// for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
864// G4VPhysicalVolume* world = (*iterWorld);
865// if (!world) break; // This can happen if geometry has been cleared/destroyed.
866// // The idea now is to seek a PV with the same name and copy no
867// // in the hope it's the same one!!
868// G4PhysicalVolumeModel searchModel (world);
869// G4int verbosity = 0; // Suppress messages from G4PhysicalVolumeSearchScene.
870// G4PhysicalVolumeSearchScene searchScene
871// (&searchModel, fTopPVName, fTopPVCopyNo, verbosity);
872// G4ModelingParameters mp; // Default modeling parameters for this search.
873// mp.SetDefaultVisAttributes(fpMP? fpMP->GetDefaultVisAttributes(): 0);
874// searchModel.SetModelingParameters (&mp);
875// searchModel.DescribeYourselfTo (searchScene);
876// G4VPhysicalVolume* foundVolume = searchScene.GetFoundVolume ();
877// if (foundVolume) {
878// if (foundVolume != fpTopPV && warn) {
879// G4cout <<
880// "G4PhysicalVolumeModel::Validate(): A volume of the same name and"
881// "\n copy number (\""
882// << fTopPVName << "\", copy " << fTopPVCopyNo
883// << ") still exists and is being used."
884// "\n But it is not the same volume you originally specified"
885// "\n in /vis/scene/add/."
886// << G4endl;
887// }
888// fpTopPV = foundVolume;
889// CalculateExtent ();
890// found = true;
891// }
892// }
893// if (found) return true;
894// else {
895// if (warn) {
896// G4cout <<
897// "G4PhysicalVolumeModel::Validate(): No volume of name and"
898// "\n copy number (\""
899// << fTopPVName << "\", copy " << fTopPVCopyNo
900// << ") exists."
901// << G4endl;
902// }
903// return false;
904// }
905}
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
static G4PhysicalVolumeStore * GetInstance()

References fpTopPV, G4Exception(), G4PhysicalVolumeStore::GetInstance(), and JustWarning.

Referenced by G4VisCommandSceneAddVolume::SetNewValue().

◆ VisitGeometryAndGetVisReps()

void G4PhysicalVolumeModel::VisitGeometryAndGetVisReps ( G4VPhysicalVolume pVPV,
G4int  requestedDepth,
const G4Transform3D theAT,
G4VGraphicsScene sceneHandler 
)
protected

Definition at line 234 of file G4PhysicalVolumeModel.cc.

239{
240 // Visits geometry structure to a given depth (requestedDepth), starting
241 // at given physical volume with given starting transformation and
242 // describes volumes to the scene handler.
243 // requestedDepth < 0 (default) implies full visit.
244 // theAT is the Accumulated Transformation.
245
246 // Find corresponding logical volume and (later) solid, storing in
247 // local variables to preserve re-entrancy.
248 G4LogicalVolume* pLV = pVPV -> GetLogicalVolume ();
249 G4VSolid* pSol = nullptr;
250 G4Material* pMaterial = nullptr;
251
252 if (!(pVPV -> IsReplicated ())) {
253 // Non-replicated physical volume.
254 pSol = pLV -> GetSolid ();
255 pMaterial = pLV -> GetMaterial ();
256 DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
257 theAT, sceneHandler);
258 }
259 else {
260 // Replicated or parametrised physical volume.
261 EAxis axis;
262 G4int nReplicas;
263 G4double width;
264 G4double offset;
265 G4bool consuming;
266 pVPV -> GetReplicationData (axis, nReplicas, width, offset, consuming);
267 G4int nBegin = 0;
268 G4int nEnd = nReplicas;
269 if (fCurrentDepth == 0) { // i.e., top volume
270 nBegin = fTopPVCopyNo; // Describe only one volume, namely the one
271 nEnd = nBegin + 1; // specified by the given copy number.
272 }
273 G4VPVParameterisation* pP = pVPV -> GetParameterisation ();
274 if (pP) { // Parametrised volume.
275 for (int n = nBegin; n < nEnd; n++) {
276 pSol = pP -> ComputeSolid (n, pVPV);
277 pP -> ComputeTransformation (n, pVPV);
278 pSol -> ComputeDimensions (pP, n, pVPV);
279 pVPV -> SetCopyNo (n);
281 // Create a touchable of current parent for ComputeMaterial.
282 // fFullPVPath has not been updated yet so at this point it
283 // corresponds to the parent.
284 G4PhysicalVolumeModelTouchable parentTouchable(fFullPVPath);
285 pMaterial = pP -> ComputeMaterial (n, pVPV, &parentTouchable);
286 DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
287 theAT, sceneHandler);
288 }
289 }
290 else { // Plain replicated volume. From geometry_guide.txt...
291 // The replica's positions are claculated by means of a linear formula.
292 // Replication may occur along:
293 //
294 // o Cartesian axes (kXAxis,kYAxis,kZAxis)
295 //
296 // The replications, of specified width have coordinates of
297 // form (-width*(nReplicas-1)*0.5+n*width,0,0) where n=0.. nReplicas-1
298 // for the case of kXAxis, and are unrotated.
299 //
300 // o Radial axis (cylindrical polar) (kRho)
301 //
302 // The replications are cons/tubs sections, centred on the origin
303 // and are unrotated.
304 // They have radii of width*n+offset to width*(n+1)+offset
305 // where n=0..nReplicas-1
306 //
307 // o Phi axis (cylindrical polar) (kPhi)
308 // The replications are `phi sections' or wedges, and of cons/tubs form
309 // They have phi of offset+n*width to offset+(n+1)*width where
310 // n=0..nReplicas-1
311 //
312 pSol = pLV -> GetSolid ();
313 pMaterial = pLV -> GetMaterial ();
314 G4ThreeVector originalTranslation = pVPV -> GetTranslation ();
315 G4RotationMatrix* pOriginalRotation = pVPV -> GetRotation ();
316 G4double originalRMin = 0., originalRMax = 0.;
317 if (axis == kRho && pSol->GetEntityType() == "G4Tubs") {
318 originalRMin = ((G4Tubs*)pSol)->GetInnerRadius();
319 originalRMax = ((G4Tubs*)pSol)->GetOuterRadius();
320 }
321 G4bool visualisable = true;
322 for (int n = nBegin; n < nEnd; n++) {
323 G4ThreeVector translation; // Identity.
324 G4RotationMatrix rotation; // Identity - life enough for visualizing.
325 G4RotationMatrix* pRotation = 0;
326 switch (axis) {
327 default:
328 case kXAxis:
329 translation = G4ThreeVector (-width*(nReplicas-1)*0.5+n*width,0,0);
330 break;
331 case kYAxis:
332 translation = G4ThreeVector (0,-width*(nReplicas-1)*0.5+n*width,0);
333 break;
334 case kZAxis:
335 translation = G4ThreeVector (0,0,-width*(nReplicas-1)*0.5+n*width);
336 break;
337 case kRho:
338 if (pSol->GetEntityType() == "G4Tubs") {
339 ((G4Tubs*)pSol)->SetInnerRadius(width*n+offset);
340 ((G4Tubs*)pSol)->SetOuterRadius(width*(n+1)+offset);
341 } else {
342 if (fpMP->IsWarning())
343 G4cout <<
344 "G4PhysicalVolumeModel::VisitGeometryAndGetVisReps: WARNING:"
345 "\n built-in replicated volumes replicated in radius for "
346 << pSol->GetEntityType() <<
347 "-type\n solids (your solid \""
348 << pSol->GetName() <<
349 "\") are not visualisable."
350 << G4endl;
351 visualisable = false;
352 }
353 break;
354 case kPhi:
355 rotation.rotateZ (-(offset+(n+0.5)*width));
356 // Minus Sign because for the physical volume we need the
357 // coordinate system rotation.
358 pRotation = &rotation;
359 break;
360 }
361 pVPV -> SetTranslation (translation);
362 pVPV -> SetRotation (pRotation);
363 pVPV -> SetCopyNo (n);
365 if (visualisable) {
366 DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
367 theAT, sceneHandler);
368 }
369 }
370 // Restore originals...
371 pVPV -> SetTranslation (originalTranslation);
372 pVPV -> SetRotation (pOriginalRotation);
373 if (axis == kRho && pSol->GetEntityType() == "G4Tubs") {
374 ((G4Tubs*)pSol)->SetInnerRadius(originalRMin);
375 ((G4Tubs*)pSol)->SetOuterRadius(originalRMax);
376 }
377 }
378 }
379}
CLHEP::Hep3Vector G4ThreeVector
HepRotation & rotateZ(double delta)
Definition: Rotation.cc:87
void DescribeAndDescend(G4VPhysicalVolume *, G4int requestedDepth, G4LogicalVolume *, G4VSolid *, G4Material *, const G4Transform3D &, G4VGraphicsScene &)
Definition: G4Tubs.hh:75
EAxis
Definition: geomdefs.hh:54
@ kPhi
Definition: geomdefs.hh:60
@ kYAxis
Definition: geomdefs.hh:56
@ kXAxis
Definition: geomdefs.hh:55
@ kZAxis
Definition: geomdefs.hh:57
@ kRho
Definition: geomdefs.hh:58

References DescribeAndDescend(), fCurrentDepth, fCurrentPVCopyNo, fFullPVPath, G4VModel::fpMP, fTopPVCopyNo, G4cout, G4endl, G4VSolid::GetEntityType(), G4VSolid::GetName(), pyG4VTouchable::GetRotation, G4ModelingParameters::IsWarning(), kPhi, kRho, kXAxis, kYAxis, kZAxis, CLHEP::detail::n, and CLHEP::HepRotation::rotateZ().

Referenced by DescribeAndDescend(), and DescribeYourselfTo().

Field Documentation

◆ fAbort

G4bool G4PhysicalVolumeModel::fAbort
mutableprotected

Definition at line 298 of file G4PhysicalVolumeModel.hh.

Referenced by Abort(), DescribeAndDescend(), and DescribeYourselfTo().

◆ fBaseFullPVPath

std::vector<G4PhysicalVolumeNodeID> G4PhysicalVolumeModel::fBaseFullPVPath
protected

◆ fClippingMode

ClippingMode G4PhysicalVolumeModel::fClippingMode
protected

Definition at line 301 of file G4PhysicalVolumeModel.hh.

Referenced by DescribeSolid(), and SetClippingMode().

◆ fCurrentDepth

G4int G4PhysicalVolumeModel::fCurrentDepth
protected

◆ fCurrentPVCopyNo

G4int G4PhysicalVolumeModel::fCurrentPVCopyNo
protected

◆ fCurrentTransform

G4Transform3D G4PhysicalVolumeModel::fCurrentTransform
protected

◆ fCurtailDescent

G4bool G4PhysicalVolumeModel::fCurtailDescent
mutableprotected

◆ fDrawnPVPath

std::vector<G4PhysicalVolumeNodeID> G4PhysicalVolumeModel::fDrawnPVPath
protected

◆ fExtent

G4VisExtent G4VModel::fExtent
protectedinherited

◆ fFullPVPath

std::vector<G4PhysicalVolumeNodeID> G4PhysicalVolumeModel::fFullPVPath
protected

◆ fGlobalDescription

G4String G4VModel::fGlobalDescription
protectedinherited

◆ fGlobalTag

G4String G4VModel::fGlobalTag
protectedinherited

◆ fpClippingSolid

G4VSolid* G4PhysicalVolumeModel::fpClippingSolid
protected

◆ fpCurrentLV

G4LogicalVolume* G4PhysicalVolumeModel::fpCurrentLV
protected

◆ fpCurrentMaterial

G4Material* G4PhysicalVolumeModel::fpCurrentMaterial
protected

◆ fpCurrentPV

G4VPhysicalVolume* G4PhysicalVolumeModel::fpCurrentPV
protected

◆ fpMP

const G4ModelingParameters* G4VModel::fpMP
protectedinherited

◆ fpTopPV

G4VPhysicalVolume* G4PhysicalVolumeModel::fpTopPV
protected

◆ fRequestedDepth

G4int G4PhysicalVolumeModel::fRequestedDepth
protected

◆ fTopPVCopyNo

G4int G4PhysicalVolumeModel::fTopPVCopyNo
protected

Definition at line 284 of file G4PhysicalVolumeModel.hh.

Referenced by CalculateExtent(), and VisitGeometryAndGetVisReps().

◆ fTopPVName

G4String G4PhysicalVolumeModel::fTopPVName
protected

Definition at line 283 of file G4PhysicalVolumeModel.hh.

Referenced by G4PhysicalVolumeModel().

◆ fTransform

G4Transform3D G4PhysicalVolumeModel::fTransform
protected

◆ fType

G4String G4VModel::fType
protectedinherited

◆ fUseFullExtent

G4bool G4PhysicalVolumeModel::fUseFullExtent
protected

Definition at line 287 of file G4PhysicalVolumeModel.hh.

Referenced by CalculateExtent().


The documentation for this class was generated from the following files: