Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VisCommandSceneAddVolume Class Reference

#include <G4VisCommandsSceneAdd.hh>

+ Inheritance diagram for G4VisCommandSceneAddVolume:

Public Member Functions

 G4VisCommandSceneAddVolume ()
 
virtual ~G4VisCommandSceneAddVolume ()
 
G4String GetCurrentValue (G4UIcommand *command)
 
void SetNewValue (G4UIcommand *command, G4String newValue)
 
- Public Member Functions inherited from G4VVisCommandScene
 G4VVisCommandScene ()
 
virtual ~G4VVisCommandScene ()
 
- Public Member Functions inherited from G4VVisCommand
 G4VVisCommand ()
 
virtual ~G4VVisCommand ()
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
static void SetVisManager (G4VisManager *)
 
- Protected Member Functions inherited from G4VVisCommandScene
G4String CurrentSceneName ()
 
- Protected Member Functions inherited from G4VVisCommand
void UpdateVisManagerScene (const G4String &sceneName="")
 
- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Static Protected Member Functions inherited from G4VVisCommand
static G4String ConvertToString (G4double x, G4double y, const char *unitName)
 
static void ConvertToDoublePair (const G4String &paramString, G4double &xval, G4double &yval)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 
- Static Protected Attributes inherited from G4VVisCommand
static G4VisManagerfpVisManager = 0
 
static G4Colour fCurrentColour = G4Colour::White()
 
static G4Colour fCurrentTextColour = G4Colour::Blue()
 
static G4Text::Layout fCurrentTextLayout = G4Text::left
 
static G4double fCurrentLineWidth = 1.
 
static G4ModelingParameters::PVNameCopyNoPath fCurrentTouchablePath
 

Detailed Description

Definition at line 382 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneAddVolume()

G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume ( )

Definition at line 2566 of file G4VisCommandsSceneAdd.cc.

2566 {
2567 G4bool omitable;
2568 fpCommand = new G4UIcommand ("/vis/scene/add/volume", this);
2569 fpCommand -> SetGuidance
2570 ("Adds a physical volume to current scene, with optional clipping volume.");
2571 fpCommand -> SetGuidance
2572 ("If physical-volume-name is \"world\" (the default), the top of the"
2573 "\nmain geometry tree (material world) is added. If \"worlds\", the"
2574 "\ntop of all worlds - material world and parallel worlds, if any - are"
2575 "\nadded. Otherwise a search of all worlds is made, taking the first"
2576 "\nmatching occurence only. To see a representation of the geometry"
2577 "\nhierarchy of the worlds, try \"/vis/drawTree [worlds]\" or one of the"
2578 "\ndriver/browser combinations that have the required functionality, e.g., HepRep.");
2579 fpCommand -> SetGuidance
2580 ("If clip-volume-type is specified, the subsequent parameters are used to"
2581 "\nto define a clipping volume. For example,"
2582 "\n\"vis/scene/add/volume ! ! ! -box km 0 1 0 1 0 1\" will draw the world"
2583 "\nwith the positive octant cut away.");
2584 fpCommand -> SetGuidance
2585 ("If clip-volume-type is prepended with '-', the clip-volume is subtracted"
2586 "\n(cutaway). (This is the default if there is no prepended character.)"
2587 "\nIf '*' is prepended, the intersection of the physical-volume and the"
2588 "\nclip-volume is made. (You can make a section/DCUT with a thin box, for"
2589 "\nexample).");
2590 fpCommand -> SetGuidance
2591 ("For \"box\", the parameters are xmin,xmax,ymin,ymax,zmin,zmax."
2592 "\nOnly \"box\" is programmed at present.");
2593 G4UIparameter* parameter;
2594 parameter = new G4UIparameter ("physical-volume-name", 's', omitable = true);
2595 parameter -> SetDefaultValue ("world");
2596 fpCommand -> SetParameter (parameter);
2597 parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
2598 parameter -> SetGuidance
2599 ("If negative, matches any copy no. First name match is taken.");
2600 parameter -> SetDefaultValue (-1);
2601 fpCommand -> SetParameter (parameter);
2602 parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
2603 parameter -> SetGuidance
2604 ("Depth of descent of geometry hierarchy. Default = unlimited depth.");
2605 parameter -> SetDefaultValue (G4Scene::UNLIMITED);
2606 fpCommand -> SetParameter (parameter);
2607 parameter = new G4UIparameter ("clip-volume-type", 's', omitable = true);
2608 parameter -> SetParameterCandidates("none box -box *box");
2609 parameter -> SetDefaultValue ("none");
2610 parameter -> SetGuidance("[-|*]type. See general guidance.");
2611 fpCommand -> SetParameter (parameter);
2612 parameter = new G4UIparameter ("parameter-unit", 's', omitable = true);
2613 parameter -> SetDefaultValue ("m");
2614 fpCommand -> SetParameter (parameter);
2615 parameter = new G4UIparameter ("parameter-1", 'd', omitable = true);
2616 parameter -> SetDefaultValue (0.);
2617 fpCommand -> SetParameter (parameter);
2618 parameter = new G4UIparameter ("parameter-2", 'd', omitable = true);
2619 parameter -> SetDefaultValue (0.);
2620 fpCommand -> SetParameter (parameter);
2621 parameter = new G4UIparameter ("parameter-3", 'd', omitable = true);
2622 parameter -> SetDefaultValue (0.);
2623 fpCommand -> SetParameter (parameter);
2624 parameter = new G4UIparameter ("parameter-4", 'd', omitable = true);
2625 parameter -> SetDefaultValue (0.);
2626 fpCommand -> SetParameter (parameter);
2627 parameter = new G4UIparameter ("parameter-5", 'd', omitable = true);
2628 parameter -> SetDefaultValue (0.);
2629 fpCommand -> SetParameter (parameter);
2630 parameter = new G4UIparameter ("parameter-6", 'd', omitable = true);
2631 parameter -> SetDefaultValue (0.);
2632 fpCommand -> SetParameter (parameter);
2633}
bool G4bool
Definition: G4Types.hh:67
@ UNLIMITED
Definition: G4Scene.hh:55

◆ ~G4VisCommandSceneAddVolume()

G4VisCommandSceneAddVolume::~G4VisCommandSceneAddVolume ( )
virtual

Definition at line 2635 of file G4VisCommandsSceneAdd.cc.

2635 {
2636 delete fpCommand;
2637}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneAddVolume::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 2639 of file G4VisCommandsSceneAdd.cc.

2639 {
2640 return "world 0 -1";
2641}

◆ SetNewValue()

void G4VisCommandSceneAddVolume::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 2643 of file G4VisCommandsSceneAdd.cc.

2644 {
2645
2647 G4bool warn = verbosity >= G4VisManager::warnings;
2648
2650 if (!pScene) {
2651 if (verbosity >= G4VisManager::errors) {
2652 G4cout << "ERROR: No current scene. Please create one." << G4endl;
2653 }
2654 return;
2655 }
2656
2657 G4String name, clipVolumeType, parameterUnit;
2658 G4int copyNo, requestedDepthOfDescent;
2659 G4double param1, param2, param3, param4, param5, param6;
2660 std::istringstream is (newValue);
2661 is >> name >> copyNo >> requestedDepthOfDescent
2662 >> clipVolumeType >> parameterUnit
2663 >> param1 >> param2 >> param3 >> param4 >> param5 >> param6;
2665 G4PhysicalVolumeModel::subtraction; // Default subtraction mode.
2666 if (clipVolumeType[size_t(0)] == '-') {
2667 clipVolumeType = clipVolumeType.substr(1); // Remove first character.
2668 } else if (clipVolumeType[size_t(0)] == '*') {
2670 clipVolumeType = clipVolumeType.substr(1);
2671 }
2672 G4double unit = G4UIcommand::ValueOf(parameterUnit);
2673 param1 *= unit; param2 *= unit; param3 *= unit;
2674 param4 *= unit; param5 *= unit; param6 *= unit;
2675
2676 G4TransportationManager* transportationManager =
2678
2679 size_t nWorlds = transportationManager->GetNoWorlds();
2680 if (nWorlds > 1) { // Parallel worlds in operation...
2681 if (verbosity >= G4VisManager::warnings) {
2682 static G4bool warned = false;
2683 if (!warned && name != "worlds") {
2684 G4cout <<
2685 "WARNING: Parallel worlds in operation. To visualise, specify"
2686 "\n \"worlds\" or the parallel world volume or sub-volume name"
2687 "\n and control visibility with /vis/geometry."
2688 << G4endl;
2689 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2690 transportationManager->GetWorldsIterator();
2691 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2692 G4cout << " World " << i << ": " << (*iterWorld)->GetName()
2693 << G4endl;
2694 warned = true;
2695 }
2696 }
2697 }
2698 }
2699
2700 G4VPhysicalVolume* world = *(transportationManager->GetWorldsIterator());
2701
2702 if (!world) {
2703 if (verbosity >= G4VisManager::errors) {
2704 G4cout <<
2705 "ERROR: G4VisCommandSceneAddVolume::SetNewValue:"
2706 "\n No world. Maybe the geometry has not yet been defined."
2707 "\n Try \"/run/initialize\""
2708 << G4endl;
2709 }
2710 return;
2711 }
2712
2713 const std::vector<G4Scene::Model>& rdModelList = pScene -> GetRunDurationModelList();
2714 std::vector<G4Scene::Model>::const_iterator it;
2715 for (it = rdModelList.begin(); it != rdModelList.end(); ++it) {
2716 if (it->fpModel->GetGlobalDescription().find("G4PhysicalVolumeModel")
2717 != std::string::npos) {
2718 if (((G4PhysicalVolumeModel*)(it->fpModel))->GetTopPhysicalVolume () == world) break;
2719 }
2720 }
2721 if (it != rdModelList.end()) {
2722 if (verbosity >= G4VisManager::warnings) {
2723 G4cout << "WARNING: There is already a volume, \""
2724 << it -> fpModel -> GetGlobalDescription()
2725 << "\",\n in the run-duration model list of scene \""
2726 << pScene -> GetName()
2727 << "\".\n To get a clean scene:"
2728 << "\n /vis/drawVolume " << name
2729 << "\n or"
2730 << "\n /vis/scene/create"
2731 << "\n /vis/scene/add/volume " << name
2732 << "\n /vis/sceneHandler/attach"
2733 << "\n (and also, if necessary, /vis/viewer/flush)"
2734 << G4endl;
2735 }
2736 return;
2737 }
2738
2739 std::vector<G4PhysicalVolumeModel*> models;
2740 std::vector<G4VPhysicalVolume*> foundVolumes;
2741 G4VPhysicalVolume* foundWorld = 0;
2743 typedef std::vector<PVNodeID> PVPath;
2744 PVPath foundFullPVPath;
2745 std::vector<G4int> foundDepths;
2746 std::vector<G4Transform3D> transformations;
2747
2748 if (name == "world") {
2749
2750 models.push_back
2751 (new G4PhysicalVolumeModel (world, requestedDepthOfDescent));
2752 foundVolumes.push_back(world);
2753 foundDepths.push_back(0);
2754 transformations.push_back(G4Transform3D());
2755
2756 } else if (name == "worlds") {
2757
2758 if (nWorlds == 0) {
2759 if (verbosity >= G4VisManager::warnings) {
2760 G4cout <<
2761 "WARNING: G4VisCommandSceneAddVolume::SetNewValue:"
2762 "\n Parallel worlds requested but none exist."
2763 "\n Just adding material world."
2764 << G4endl;
2765 }
2766 }
2767 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2768 transportationManager->GetWorldsIterator();
2769 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2770 models.push_back
2771 (new G4PhysicalVolumeModel (*iterWorld, requestedDepthOfDescent));
2772 foundVolumes.push_back(*iterWorld);
2773 foundDepths.push_back(0);
2774 transformations.push_back(G4Transform3D());
2775 }
2776
2777 } else { // Search all worlds...
2778
2779 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2780 transportationManager->GetWorldsIterator();
2781 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2782 G4PhysicalVolumeModel searchModel (*iterWorld); // Unlimited depth.
2783 G4ModelingParameters mp; // Default - no culling.
2784 searchModel.SetModelingParameters (&mp);
2785 G4PhysicalVolumeSearchScene searchScene (&searchModel, name, copyNo);
2786 searchModel.DescribeYourselfTo (searchScene); // Initiate search.
2787 G4VPhysicalVolume* foundVolume = searchScene.GetFoundVolume ();
2788 if (foundVolume) {
2789 foundWorld = *iterWorld;
2790 foundVolumes.push_back(foundVolume);
2791 foundFullPVPath = searchScene.GetFoundFullPVPath();
2792 foundDepths.push_back(searchScene.GetFoundDepth());
2793 transformations.push_back(searchScene.GetFoundTransformation());
2794 break;
2795 }
2796 }
2797
2798 if (foundVolumes.size()) {
2799 for (size_t i = 0; i < foundVolumes.size(); ++i) {
2801 (foundVolumes[i], requestedDepthOfDescent, transformations[i]);
2802 foundFullPVPath.pop_back(); // "Base" is "Found - 1".
2803 foundPVModel->SetBaseFullPVPath(foundFullPVPath);
2804 models.push_back(foundPVModel);
2805 }
2806 } else {
2807 if (verbosity >= G4VisManager::errors) {
2808 G4cout << "ERROR: Volume \"" << name << "\"";
2809 if (copyNo >= 0) {
2810 G4cout << ", copy no. " << copyNo << ",";
2811 }
2812 G4cout << " not found." << G4endl;
2813 }
2814 return;
2815 }
2816 }
2817
2818 if (clipVolumeType == "box") {
2819 const G4double dX = (param2 - param1) / 2.;
2820 const G4double dY = (param4 - param3) / 2.;
2821 const G4double dZ = (param6 - param5) / 2.;
2822 const G4double x0 = (param2 + param1) / 2.;
2823 const G4double y0 = (param4 + param3) / 2.;
2824 const G4double z0 = (param6 + param5) / 2.;
2825 G4VSolid* clippingSolid =
2827 ("_displaced_clipping_box",
2828 new G4Box("_clipping_box",dX,dY,dZ),
2829 G4Translate3D(x0,y0,z0));
2830 for (size_t i = 0; i < foundVolumes.size(); ++i) {
2831 models[i]->SetClippingSolid(clippingSolid);
2832 models[i]->SetClippingMode(clippingMode);
2833 }
2834 } // If any other shape consider NumberOfRotationSides!!!!!!!!!!!
2835
2836 const G4String& currentSceneName = pScene -> GetName ();
2837 G4bool failure = true;
2838 for (size_t i = 0; i < foundVolumes.size(); ++i) {
2839 G4bool successful = pScene -> AddRunDurationModel (models[i], warn);
2840 if (successful) {
2841 failure = false;
2842 if (verbosity >= G4VisManager::confirmations) {
2843 G4cout << "First occurrence of \""
2844 << foundVolumes[i] -> GetName ()
2845 << "\"";
2846 if (copyNo >= 0) {
2847 G4cout << ", copy no. " << copyNo << ",";
2848 }
2849 G4cout << "\n found ";
2850 if (foundWorld)
2851 G4cout << "in world \"" << foundWorld->GetName() << "\" ";
2852 G4cout << "at depth " << foundDepths[i]
2853 << ",\n with a requested depth of further descent of ";
2854 if (requestedDepthOfDescent < 0) {
2855 G4cout << "<0 (unlimited)";
2856 }
2857 else {
2858 G4cout << requestedDepthOfDescent;
2859 }
2860 G4cout << ",\n has been added to scene \"" << currentSceneName << "\"."
2861 << G4endl;
2862 }
2863 }
2864 }
2865
2866 if (failure) {
2867 G4VisCommandsSceneAddUnsuccessful(verbosity);
2868 return;
2869 }
2870
2871 UpdateVisManagerScene (currentSceneName);
2872}
HepGeom::Translate3D G4Translate3D
HepGeom::Transform3D G4Transform3D
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
Definition: G4Box.hh:55
void SetBaseFullPVPath(const std::vector< G4PhysicalVolumeNodeID > &baseFullPVPath)
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
size_t GetNoWorlds() const
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:288
const G4String & GetName() const
static G4VisManager * fpVisManager
void UpdateVisManagerScene(const G4String &sceneName="")
G4Scene * GetCurrentScene() const
static Verbosity GetVerbosity()
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID
std::vector< PVNodeID > PVPath

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