Geant4-11
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
G4LogicalVolumeModel Class Reference

#include <G4LogicalVolumeModel.hh>

Inheritance diagram for G4LogicalVolumeModel:
G4PhysicalVolumeModel G4VModel

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 &)
 
 G4LogicalVolumeModel (G4LogicalVolume *, G4int soughtDepth=1, G4bool booleans=true, G4bool voxels=true, G4bool readout=true, G4bool checkOverlaps=true, const G4Transform3D &modelTransformation=G4Transform3D(), const G4ModelingParameters *=0)
 
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)
 
virtual ~G4LogicalVolumeModel ()
 

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 &)
 
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
 
G4bool fBooleans
 
G4bool fCheckOverlaps
 
ClippingMode fClippingMode
 
G4int fCurrentDepth
 
G4int fCurrentPVCopyNo
 
G4Transform3D fCurrentTransform
 
G4bool fCurtailDescent
 
std::vector< G4PhysicalVolumeNodeIDfDrawnPVPath
 
G4VisExtent fExtent
 
std::vector< G4PhysicalVolumeNodeIDfFullPVPath
 
G4String fGlobalDescription
 
G4String fGlobalTag
 
G4bool fOverlapsPrinted
 
G4VSolidfpClippingSolid
 
G4LogicalVolumefpCurrentLV
 
G4MaterialfpCurrentMaterial
 
G4VPhysicalVolumefpCurrentPV
 
G4LogicalVolumefpLV
 
const G4ModelingParametersfpMP
 
G4VPhysicalVolumefpTopPV
 
G4bool fReadout
 
G4int fRequestedDepth
 
G4int fTopPVCopyNo
 
G4String fTopPVName
 
G4Transform3D fTransform
 
G4String fType
 
G4bool fUseFullExtent
 
G4bool fVoxels
 

Detailed Description

Definition at line 50 of file G4LogicalVolumeModel.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited
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

◆ G4LogicalVolumeModel()

G4LogicalVolumeModel::G4LogicalVolumeModel ( G4LogicalVolume pLV,
G4int  soughtDepth = 1,
G4bool  booleans = true,
G4bool  voxels = true,
G4bool  readout = true,
G4bool  checkOverlaps = true,
const G4Transform3D modelTransformation = G4Transform3D(),
const G4ModelingParameters pMP = 0 
)

Definition at line 49 of file G4LogicalVolumeModel.cc.

57 :
58 // Instantiate a G4PhysicalVolumeModel with a G4PVPlacement to
59 // represent this logical volume. It has no rotation and a null
60 // translation so that the logical volume will be seen in its own
61 // reference system. It will be added to the physical volume store
62 // but it will not be part of the normal geometry heirarchy so it
63 // has no mother.
65(new G4PVPlacement (0, // No rotation.
66 G4ThreeVector(), // Null traslation.
67 "PhysVol representation of LogVol " + pLV -> GetName (),
68 pLV,
69 0, // No mother.
70 false, // Not "MANY".
71 0), // Copy number.
72 soughtDepth,
73 modelTransformation,
74 pMP,
75 true), // Use full extent.
76 fpLV (pLV),
77 fBooleans (booleans),
78 fVoxels (voxels),
79 fReadout (readout),
80 fCheckOverlaps(checkOverlaps),
81 fOverlapsPrinted(false)
82{
83 fType = "G4LogicalVolumeModel";
84 fGlobalTag = fpLV -> GetName ();
85 fGlobalDescription = "G4LogicalVolumeModel " + fGlobalTag;
86}
CLHEP::Hep3Vector G4ThreeVector
G4PhysicalVolumeModel(G4VPhysicalVolume *=0, G4int requestedDepth=UNLIMITED, const G4Transform3D &modelTransformation=G4Transform3D(), const G4ModelingParameters *=0, G4bool useFullExtent=false, const std::vector< G4PhysicalVolumeNodeID > &baseFullPVPath=std::vector< G4PhysicalVolumeNodeID >())
G4String fGlobalDescription
Definition: G4VModel.hh:100
G4String fType
Definition: G4VModel.hh:98
G4String fGlobalTag
Definition: G4VModel.hh:99

References G4VModel::fGlobalDescription, G4VModel::fGlobalTag, fpLV, and G4VModel::fType.

◆ ~G4LogicalVolumeModel()

G4LogicalVolumeModel::~G4LogicalVolumeModel ( )
virtual

Definition at line 88 of file G4LogicalVolumeModel.cc.

88{}

Member Function Documentation

◆ Abort()

void G4PhysicalVolumeModel::Abort ( ) const
inlineinherited

◆ CalculateExtent()

void G4PhysicalVolumeModel::CalculateExtent ( )
inherited

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
G4VPhysicalVolume * fpTopPV
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 G4PhysicalVolumeModel::DescribeYourselfTo(), G4VModel::fExtent, G4VModel::fpMP, G4PhysicalVolumeModel::fpTopPV, G4PhysicalVolumeModel::fRequestedDepth, G4PhysicalVolumeModel::fTopPVCopyNo, G4PhysicalVolumeModel::fTransform, G4PhysicalVolumeModel::fUseFullExtent, G4BoundingExtentScene::GetBoundingExtent(), G4VModel::GetExtent(), G4VisExtent::GetExtentRadius(), G4VisExtent::Transform(), and G4ModelingParameters::wf.

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

◆ CreateCurrentAttValues()

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

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
std::vector< G4PhysicalVolumeNodeID > fBaseFullPVPath
G4VPhysicalVolume * fpCurrentPV
const G4String & GetName() const
const G4ThreeVector GetTranslation() const
G4RotationMatrix GetObjectRotationValue() const
G4String GetName() const
virtual G4GeometryType GetEntityType() const =0

References G4PhysicalVolumeModel::fBaseFullPVPath, G4PhysicalVolumeModel::fCurrentTransform, G4PhysicalVolumeModel::fFullPVPath, G4PhysicalVolumeModel::fpCurrentLV, G4PhysicalVolumeModel::fpCurrentMaterial, G4PhysicalVolumeModel::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
inlineinherited

◆ DescribeAndDescend()

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

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
virtual G4int GetCopyNo() const =0
const G4String & GetName() const
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, G4PhysicalVolumeModel::DescribeSolid(), HepGeom::Transform3D::dx(), HepGeom::Transform3D::dy(), HepGeom::Transform3D::dz(), G4PhysicalVolumeModel::fAbort, FatalErrorInArgument, G4PhysicalVolumeModel::fCurrentDepth, G4PhysicalVolumeModel::fCurrentPVCopyNo, G4PhysicalVolumeModel::fCurrentTransform, G4PhysicalVolumeModel::fCurtailDescent, G4PhysicalVolumeModel::fDrawnPVPath, G4PhysicalVolumeModel::fFullPVPath, G4PhysicalVolumeModel::fpCurrentLV, G4PhysicalVolumeModel::fpCurrentMaterial, G4PhysicalVolumeModel::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, G4PhysicalVolumeModel::VisitGeometryAndGetVisReps(), anonymous_namespace{G4PhysicalVolumeModel.cc}::volumeCount, and G4VisAttributes::wireframe.

Referenced by G4PhysicalVolumeModel::VisitGeometryAndGetVisReps().

◆ DescribeSolid()

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

Reimplemented from G4PhysicalVolumeModel.

Definition at line 292 of file G4LogicalVolumeModel.cc.

296 {
297
298 if (fBooleans) {
299 // Look for "constituents". Could be a Boolean solid.
300 G4VSolid* pSol0 = pSol -> GetConstituentSolid (0);
301 if (pSol0) { // Composite solid...
302 G4VSolid* pSol1 = pSol -> GetConstituentSolid (1);
303 if (!pSol1) {
305 ("G4PhysicalVolumeModel::DescribeSolid",
306 "modeling0001", FatalException,
307 "2nd component solid in Boolean is missing.");
308 }
309 // Draw these constituents white and "forced wireframe"...
310 G4VisAttributes constituentAttributes;
311 constituentAttributes.SetForceWireframe(true);
312 DescribeSolid (theAT, pSol0, &constituentAttributes, sceneHandler);
313 DescribeSolid (theAT, pSol1, &constituentAttributes, sceneHandler);
314 }
315 }
316
317 // In any case draw the original/resultant solid...
318 sceneHandler.PreAddSolid (theAT, *pVisAttribs);
319 pSol -> DescribeYourselfTo (sceneHandler);
320 sceneHandler.PostAddSolid ();
321}
@ FatalException
void DescribeYourselfTo(G4VGraphicsScene &)
void DescribeSolid(const G4Transform3D &theAT, G4VSolid *pSol, const G4VisAttributes *pVisAttribs, G4VGraphicsScene &sceneHandler)
virtual void PostAddSolid()=0
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)=0

References DescribeSolid(), DescribeYourselfTo(), FatalException, fBooleans, G4Exception(), G4VGraphicsScene::PostAddSolid(), G4VGraphicsScene::PreAddSolid(), and G4VisAttributes::SetForceWireframe().

Referenced by DescribeSolid().

◆ DescribeYourselfTo()

void G4LogicalVolumeModel::DescribeYourselfTo ( G4VGraphicsScene sceneHandler)
virtual

Implements G4VModel.

Definition at line 132 of file G4LogicalVolumeModel.cc.

133 {
134
135 // Store current modeling parameters and ensure nothing is culled.
136 const G4ModelingParameters* tmpMP = fpMP;
137 G4ModelingParameters nonCulledMP;
138 if (fpMP) nonCulledMP = *fpMP;
139 nonCulledMP.SetCulling (false);
140 fpMP = &nonCulledMP;
142 fpMP = tmpMP;
143
144 if (fVoxels) {
146 // Add Voxels.
147 G4DrawVoxels dv;
149 dv.CreatePlacedPolyhedra (fpTopPV -> GetLogicalVolume ());
150 for (size_t i = 0; i < pPPL -> size (); i++) {
151 const G4Transform3D& transform = (*pPPL)[i].GetTransform ();
152 const G4Polyhedron& polyhedron = (*pPPL)[i].GetPolyhedron ();
153 sceneHandler.BeginPrimitives (transform);
154 sceneHandler.AddPrimitive (polyhedron);
155 sceneHandler.EndPrimitives ();
156 }
157 delete pPPL;
158 }
159 }
160
161 if (fReadout) {
162 // Draw readout geometry...
164 if (sd) {
165 G4VReadOutGeometry* roGeom = sd->GetROgeometry();
166 if (roGeom) {
167 G4VPhysicalVolume* roWorld = roGeom->GetROWorld();
168 G4cout << "Readout geometry \"" << roGeom->GetName()
169 << "\" with top physical volume \""
170 << roWorld->GetName()
171 << "\"" << G4endl;
172 G4PhysicalVolumeModel pvModel(roWorld);
173 pvModel.SetModelingParameters(fpMP);
174 pvModel.DescribeYourselfTo(sceneHandler);
175 }
176 }
177 }
178
179 if (fCheckOverlaps) {
181 G4VSolid* motherSolid = motherLog->GetSolid();
182 G4int nDaughters = motherLog->GetNoDaughters();
183
184 // Models are called repeatedly by the scene handler so be careful...
185 // Print overlaps - but only the first time for a given instantiation of G4LogicalVolume
186 if (!fOverlapsPrinted) {
187 for (G4int iDaughter = 0; iDaughter < nDaughters; ++iDaughter) {
188 G4VPhysicalVolume* daughterPhys = motherLog->GetDaughter(iDaughter);
189 daughterPhys->CheckOverlaps();
190 }
191 fOverlapsPrinted = true;
192 }
193
194 // Draw overlaps
195 solidCopyNoVector.clear();
196 for (G4int iDaughter = 0; iDaughter < nDaughters; ++iDaughter) {
197 G4VPhysicalVolume* daughterPhys = motherLog->GetDaughter(iDaughter);
198 G4PVPlacement* daughterPVPlace = dynamic_cast<G4PVPlacement*>(daughterPhys);
199 G4PVParameterised* daughterPVParam = dynamic_cast<G4PVParameterised*>(daughterPhys);
200 const G4int nPoints = 1000;
201
202 if (daughterPVPlace) {
203
204 // This algorithm is based on G4PVPlacement::CheckOverlaps.
205 G4AffineTransform tDaughter(daughterPhys->GetRotation(),daughterPhys->GetTranslation());
206 G4VSolid* daughterSolid = daughterPhys->GetLogicalVolume()->GetSolid();
207 for (G4int i = 0; i < nPoints; ++i) {
208 G4ThreeVector point = daughterSolid->GetPointOnSurface();
209 // Transform to mother's coordinate system
210 G4ThreeVector motherPoint = tDaughter.TransformPoint(point);
211 // Check overlaps with the mother volume
212 if (motherSolid->Inside(motherPoint)==kOutside) {
213 // Draw mother and daughter and point
214 DrawSolid(sceneHandler,motherSolid,0,G4Transform3D());
215 DrawSolid(sceneHandler,daughterSolid,daughterPhys->GetCopyNo(),tDaughter);
216 DrawPoint(sceneHandler,motherPoint);
217 }
218 // Check other daughters
219 for (G4int iSister = 0; iSister < nDaughters; ++iSister) {
220 if (iSister == iDaughter) continue;
221 G4VPhysicalVolume* sisterPhys = motherLog->GetDaughter(iSister);
222 G4AffineTransform tSister(sisterPhys->GetRotation(),sisterPhys->GetTranslation());
223 // Transform to sister's coordinate system
224 G4ThreeVector sisterPoint = tSister.InverseTransformPoint(motherPoint);
225 G4LogicalVolume* sisterLog = sisterPhys->GetLogicalVolume();
226 G4VSolid* sisterSolid = sisterLog->GetSolid();
227 if (sisterSolid->Inside(sisterPoint)==kInside) {
228 // Draw daughter and sister and point
229 DrawSolid(sceneHandler,daughterSolid,daughterPhys->GetCopyNo(),tDaughter);
230 DrawSolid(sceneHandler,sisterSolid,sisterPhys->GetCopyNo(),tSister);
231 DrawPoint(sceneHandler,motherPoint);
232 }
233 }
234 }
235
236 } else if (daughterPVParam) {
237
238 // This algorithm is based on G4PVParameterised::CheckOverlaps
239 const G4int multiplicity = daughterPVParam->GetMultiplicity();
240 auto* param = daughterPVParam->GetParameterisation();
241 // Cache points for later checking against other parameterisations
242 std::vector<G4ThreeVector> motherPoints;
243 for (G4int iP = 0; iP < multiplicity; iP++) {
244 G4VSolid* daughterSolid = param->ComputeSolid(iP, daughterPhys);
245 daughterSolid->ComputeDimensions(param, iP, daughterPhys);
246 param->ComputeTransformation(iP, daughterPhys);
247 G4AffineTransform tDaughter(daughterPVParam->GetRotation(),daughterPVParam->GetTranslation());
248 for (G4int i = 0; i < nPoints; ++i) {
249 G4ThreeVector point = daughterSolid->GetPointOnSurface();
250 // Transform to mother's coordinate system
251 G4ThreeVector motherPoint = tDaughter.TransformPoint(point);
252 // Check overlaps with the mother volume
253 if (motherSolid->Inside(motherPoint)==kOutside) {
254 // Draw mother and daughter and point
255 DrawSolid(sceneHandler,motherSolid,0,G4Transform3D());
256 DrawSolid(sceneHandler,daughterSolid,iP,tDaughter);
257 DrawPoint(sceneHandler,motherPoint);
258 }
259 motherPoints.push_back(motherPoint);
260 }
261 // Check sister parameterisations
262 for (G4int iPP = iP + 1; iPP < multiplicity; iPP++) {
263 G4VSolid* sisterSolid = param->ComputeSolid(iPP, daughterPhys);
264 sisterSolid->ComputeDimensions(param, iPP, daughterPhys);
265 param->ComputeTransformation(iPP, daughterPhys);
266 G4AffineTransform tSister
267 (daughterPVParam->GetRotation(),daughterPVParam->GetTranslation());
268 for (const auto& motherPoint: motherPoints) {
269 // Transform each point into daughter's frame
270 G4ThreeVector sisterPoint = tSister.InverseTransformPoint(motherPoint);
271 if (sisterSolid->Inside(sisterPoint)==kInside) {
272 // Draw sister
273 DrawSolid(sceneHandler,sisterSolid,iPP,tSister);
274 // Recompute daughter parameterisation before drawing
275 daughterSolid->ComputeDimensions(param, iP, daughterPhys);
276 param->ComputeTransformation(iP, daughterPhys);
277 tDaughter = G4AffineTransform
278 (daughterPVParam->GetRotation(),daughterPVParam->GetTranslation());
279 DrawSolid(sceneHandler,daughterSolid,iP,tDaughter);
280 DrawPoint(sceneHandler,motherPoint);
281 }
282 }
283 }
284 }
285 }
286 }
287 }
288}
std::vector< G4PlacedPolyhedron > G4PlacedPolyhedronList
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4PlacedPolyhedronList * CreatePlacedPolyhedra(const G4LogicalVolume *) const
G4VSensitiveDetector * GetSensitiveDetector() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4SmartVoxelHeader * GetVoxelHeader() const
void SetCulling(G4bool)
G4VPVParameterisation * GetParameterisation() const
virtual G4int GetMultiplicity() const
Definition: G4PVReplica.cc:297
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())=0
virtual void AddPrimitive(const G4Polyline &)=0
virtual void EndPrimitives()=0
const G4RotationMatrix * GetRotation() const
virtual G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true, G4int errMax=1)
G4LogicalVolume * GetLogicalVolume() const
G4VPhysicalVolume * GetROWorld() const
G4String GetName() const
G4VReadOutGeometry * GetROgeometry() const
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4VSolid.cc:137
virtual G4ThreeVector GetPointOnSurface() const
Definition: G4VSolid.cc:152
@ kInside
Definition: geomdefs.hh:70
@ kOutside
Definition: geomdefs.hh:68
G4bool transform(G4String &input, const G4String &type)
void DrawSolid(G4VGraphicsScene &sceneHandler, G4VSolid *sol, G4int copyNo, const G4Transform3D &t)
std::vector< solidCopyNoPair > solidCopyNoVector
void DrawPoint(G4VGraphicsScene &sceneHandler, const G4ThreeVector &point)

References G4VGraphicsScene::AddPrimitive(), G4VGraphicsScene::BeginPrimitives(), G4VPhysicalVolume::CheckOverlaps(), G4VSolid::ComputeDimensions(), G4DrawVoxels::CreatePlacedPolyhedra(), G4PhysicalVolumeModel::DescribeYourselfTo(), anonymous_namespace{G4LogicalVolumeModel.cc}::DrawPoint(), anonymous_namespace{G4LogicalVolumeModel.cc}::DrawSolid(), G4VGraphicsScene::EndPrimitives(), fCheckOverlaps, fOverlapsPrinted, fpLV, G4VModel::fpMP, G4PhysicalVolumeModel::fpTopPV, fReadout, fVoxels, G4cout, G4endl, G4VPhysicalVolume::GetCopyNo(), G4LogicalVolume::GetDaughter(), G4VPhysicalVolume::GetLogicalVolume(), G4PVReplica::GetMultiplicity(), G4VReadOutGeometry::GetName(), G4VPhysicalVolume::GetName(), G4LogicalVolume::GetNoDaughters(), G4PVParameterised::GetParameterisation(), G4VSolid::GetPointOnSurface(), G4VSensitiveDetector::GetROgeometry(), G4VPhysicalVolume::GetRotation(), G4VReadOutGeometry::GetROWorld(), G4LogicalVolume::GetSensitiveDetector(), G4LogicalVolume::GetSolid(), G4VPhysicalVolume::GetTranslation(), G4LogicalVolume::GetVoxelHeader(), G4VSolid::Inside(), G4AffineTransform::InverseTransformPoint(), kInside, kOutside, G4ModelingParameters::SetCulling(), G4VModel::SetModelingParameters(), anonymous_namespace{G4LogicalVolumeModel.cc}::solidCopyNoVector, G4coutFormatters::anonymous_namespace{G4coutFormatters.cc}::transform(), and G4AffineTransform::TransformPoint().

Referenced by DescribeSolid().

◆ GetAttDefs()

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

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
inlineinherited

Definition at line 198 of file G4PhysicalVolumeModel.hh.

199 {return fBaseFullPVPath;}

References G4PhysicalVolumeModel::fBaseFullPVPath.

◆ GetClippingSolid()

const G4VSolid * G4PhysicalVolumeModel::GetClippingSolid ( ) const
inlineinherited

Definition at line 174 of file G4PhysicalVolumeModel.hh.

175 {return fpClippingSolid;}

References G4PhysicalVolumeModel::fpClippingSolid.

◆ GetCurrentDepth()

G4int G4PhysicalVolumeModel::GetCurrentDepth ( ) const
inlineinherited

◆ GetCurrentDescription()

G4String G4PhysicalVolumeModel::GetCurrentDescription ( ) const
virtualinherited

Reimplemented from G4VModel.

Definition at line 229 of file G4PhysicalVolumeModel.cc.

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

References G4PhysicalVolumeModel::GetCurrentTag().

◆ GetCurrentLV()

G4LogicalVolume * G4PhysicalVolumeModel::GetCurrentLV ( ) const
inlineinherited

◆ GetCurrentMaterial()

G4Material * G4PhysicalVolumeModel::GetCurrentMaterial ( ) const
inlineinherited

◆ GetCurrentPV()

G4VPhysicalVolume * G4PhysicalVolumeModel::GetCurrentPV ( ) const
inlineinherited

◆ GetCurrentPVCopyNo()

G4int G4PhysicalVolumeModel::GetCurrentPVCopyNo ( ) const
inlineinherited

◆ GetCurrentTag()

G4String G4PhysicalVolumeModel::GetCurrentTag ( ) const
virtualinherited

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 G4PhysicalVolumeModel::fpCurrentPV.

Referenced by G4PhysicalVolumeModel::GetCurrentDescription().

◆ GetCurrentTransform()

const G4Transform3D & G4PhysicalVolumeModel::GetCurrentTransform ( ) const
inlineinherited

◆ GetDrawnPVPath()

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

◆ GetExtent()

const G4VisExtent & G4VModel::GetExtent ( ) const
inherited

◆ GetFullPVPath()

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

◆ 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)
staticinherited

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
inlineinherited

◆ GetTopPhysicalVolume()

G4VPhysicalVolume * G4PhysicalVolumeModel::GetTopPhysicalVolume ( ) const
inlineinherited

◆ GetTransformation()

const G4Transform3D & G4PhysicalVolumeModel::GetTransformation ( ) const
inlineinherited

◆ GetType()

const G4String & G4VModel::GetType ( ) const
inherited

◆ SetClippingMode()

void G4PhysicalVolumeModel::SetClippingMode ( ClippingMode  mode)
inlineinherited

Definition at line 244 of file G4PhysicalVolumeModel.hh.

244 {
245 fClippingMode = mode;
246 }

References G4PhysicalVolumeModel::fClippingMode.

Referenced by G4VisCommandSceneAddVolume::SetNewValue().

◆ SetClippingSolid()

void G4PhysicalVolumeModel::SetClippingSolid ( G4VSolid pClippingSolid)
inlineinherited

Definition at line 240 of file G4PhysicalVolumeModel.hh.

240 {
241 fpClippingSolid = pClippingSolid;
242 }

References G4PhysicalVolumeModel::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)
inlineinherited

Definition at line 236 of file G4PhysicalVolumeModel.hh.

236 {
237 fRequestedDepth = requestedDepth;
238 }

References G4PhysicalVolumeModel::fRequestedDepth.

◆ SetType()

void G4VModel::SetType ( const G4String )
inherited

◆ Validate()

G4bool G4LogicalVolumeModel::Validate ( G4bool  )
inlinevirtual

Reimplemented from G4VModel.

Definition at line 68 of file G4LogicalVolumeModel.hh.

68{return true;}

◆ VisitGeometryAndGetVisReps()

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

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}
HepRotation & rotateZ(double delta)
Definition: Rotation.cc:87
G4bool IsWarning() const
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 G4PhysicalVolumeModel::DescribeAndDescend(), G4PhysicalVolumeModel::fCurrentDepth, G4PhysicalVolumeModel::fCurrentPVCopyNo, G4PhysicalVolumeModel::fFullPVPath, G4VModel::fpMP, G4PhysicalVolumeModel::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 G4PhysicalVolumeModel::DescribeAndDescend(), and G4PhysicalVolumeModel::DescribeYourselfTo().

Field Documentation

◆ fAbort

G4bool G4PhysicalVolumeModel::fAbort
mutableprotectedinherited

◆ fBaseFullPVPath

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

◆ fBooleans

G4bool G4LogicalVolumeModel::fBooleans
protected

Definition at line 84 of file G4LogicalVolumeModel.hh.

Referenced by DescribeSolid().

◆ fCheckOverlaps

G4bool G4LogicalVolumeModel::fCheckOverlaps
protected

Definition at line 87 of file G4LogicalVolumeModel.hh.

Referenced by DescribeYourselfTo().

◆ fClippingMode

ClippingMode G4PhysicalVolumeModel::fClippingMode
protectedinherited

◆ fCurrentDepth

G4int G4PhysicalVolumeModel::fCurrentDepth
protectedinherited

◆ fCurrentPVCopyNo

G4int G4PhysicalVolumeModel::fCurrentPVCopyNo
protectedinherited

◆ fCurrentTransform

G4Transform3D G4PhysicalVolumeModel::fCurrentTransform
protectedinherited

◆ fCurtailDescent

G4bool G4PhysicalVolumeModel::fCurtailDescent
mutableprotectedinherited

◆ fDrawnPVPath

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

◆ fExtent

G4VisExtent G4VModel::fExtent
protectedinherited

◆ fFullPVPath

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

◆ fGlobalDescription

G4String G4VModel::fGlobalDescription
protectedinherited

◆ fGlobalTag

G4String G4VModel::fGlobalTag
protectedinherited

◆ fOverlapsPrinted

G4bool G4LogicalVolumeModel::fOverlapsPrinted
protected

Definition at line 88 of file G4LogicalVolumeModel.hh.

Referenced by DescribeYourselfTo().

◆ fpClippingSolid

G4VSolid* G4PhysicalVolumeModel::fpClippingSolid
protectedinherited

◆ fpCurrentLV

G4LogicalVolume* G4PhysicalVolumeModel::fpCurrentLV
protectedinherited

◆ fpCurrentMaterial

G4Material* G4PhysicalVolumeModel::fpCurrentMaterial
protectedinherited

◆ fpCurrentPV

G4VPhysicalVolume* G4PhysicalVolumeModel::fpCurrentPV
protectedinherited

◆ fpLV

G4LogicalVolume* G4LogicalVolumeModel::fpLV
protected

Definition at line 83 of file G4LogicalVolumeModel.hh.

Referenced by DescribeYourselfTo(), and G4LogicalVolumeModel().

◆ fpMP

const G4ModelingParameters* G4VModel::fpMP
protectedinherited

◆ fpTopPV

G4VPhysicalVolume* G4PhysicalVolumeModel::fpTopPV
protectedinherited

◆ fReadout

G4bool G4LogicalVolumeModel::fReadout
protected

Definition at line 86 of file G4LogicalVolumeModel.hh.

Referenced by DescribeYourselfTo().

◆ fRequestedDepth

G4int G4PhysicalVolumeModel::fRequestedDepth
protectedinherited

◆ fTopPVCopyNo

G4int G4PhysicalVolumeModel::fTopPVCopyNo
protectedinherited

◆ fTopPVName

G4String G4PhysicalVolumeModel::fTopPVName
protectedinherited

◆ fTransform

G4Transform3D G4PhysicalVolumeModel::fTransform
protectedinherited

◆ fType

G4String G4VModel::fType
protectedinherited

◆ fUseFullExtent

G4bool G4PhysicalVolumeModel::fUseFullExtent
protectedinherited

Definition at line 287 of file G4PhysicalVolumeModel.hh.

Referenced by G4PhysicalVolumeModel::CalculateExtent().

◆ fVoxels

G4bool G4LogicalVolumeModel::fVoxels
protected

Definition at line 85 of file G4LogicalVolumeModel.hh.

Referenced by DescribeYourselfTo().


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