Geant4  10.02.p03
G4VisCommandSceneAddVolume Class Reference

#include <G4VisCommandsSceneAdd.hh>

Inheritance diagram for G4VisCommandSceneAddVolume:
Collaboration 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, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Private Member Functions

 G4VisCommandSceneAddVolume (const G4VisCommandSceneAddVolume &)
 
G4VisCommandSceneAddVolumeoperator= (const G4VisCommandSceneAddVolume &)
 

Private Attributes

G4UIcommandfpCommand
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
static void SetVisManager (G4VisManager *)
 
static const G4ColourGetCurrentColour ()
 
static G4double GetCurrentLineWidth ()
 
static const G4ColourGetCurrentTextColour ()
 
static G4Text::Layout GetCurrentTextLayout ()
 
static G4double GetCurrentTextSize ()
 
- 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, G4bool commandsToBeBroadcasted=true)
 
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
 
G4bool commandsShouldBeInMaster
 
- Static Protected Attributes inherited from G4VVisCommand
static G4VisManagerfpVisManager = 0
 
static G4Colour fCurrentColour = G4Colour::White()
 
static G4double fCurrentLineWidth = 1.
 
static G4Colour fCurrentTextColour = G4Colour::Blue()
 
static G4Text::Layout fCurrentTextLayout = G4Text::left
 
static G4double fCurrentTextSize = 12.
 
static G4ModelingParameters::PVNameCopyNoPath fCurrentTouchablePath
 

Detailed Description

Definition at line 413 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneAddVolume() [1/2]

G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume ( )

Definition at line 2700 of file G4VisCommandsSceneAdd.cc.

2700  {
2701  G4bool omitable;
2702  fpCommand = new G4UIcommand ("/vis/scene/add/volume", this);
2703  fpCommand -> SetGuidance
2704  ("Adds a physical volume to current scene, with optional clipping volume.");
2705  fpCommand -> SetGuidance
2706  ("If physical-volume-name is \"world\" (the default), the top of the"
2707  "\nmain geometry tree (material world) is added. If \"worlds\", the"
2708  "\ntop of all worlds - material world and parallel worlds, if any - are"
2709  "\nadded. Otherwise a search of all worlds is made, taking the first"
2710  "\nmatching occurence only. To see a representation of the geometry"
2711  "\nhierarchy of the worlds, try \"/vis/drawTree [worlds]\" or one of the"
2712  "\ndriver/browser combinations that have the required functionality, e.g., HepRep.");
2713  fpCommand -> SetGuidance
2714  ("If clip-volume-type is specified, the subsequent parameters are used to"
2715  "\nto define a clipping volume. For example,"
2716  "\n\"/vis/scene/add/volume ! ! ! -box km 0 1 0 1 0 1\" will draw the world"
2717  "\nwith the positive octant cut away. (If the Boolean Processor issues"
2718  "\nwarnings try replacing 0 by 0.000000001 or something.)");
2719  fpCommand -> SetGuidance
2720  ("If clip-volume-type is prepended with '-', the clip-volume is subtracted"
2721  "\n(cutaway). (This is the default if there is no prepended character.)"
2722  "\nIf '*' is prepended, the intersection of the physical-volume and the"
2723  "\nclip-volume is made. (You can make a section/DCUT with a thin box, for"
2724  "\nexample).");
2725  fpCommand -> SetGuidance
2726  ("For \"box\", the parameters are xmin,xmax,ymin,ymax,zmin,zmax."
2727  "\nOnly \"box\" is programmed at present.");
2728  G4UIparameter* parameter;
2729  parameter = new G4UIparameter ("physical-volume-name", 's', omitable = true);
2730  parameter -> SetDefaultValue ("world");
2731  fpCommand -> SetParameter (parameter);
2732  parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
2733  parameter -> SetGuidance
2734  ("If negative, matches any copy no. First name match is taken.");
2735  parameter -> SetDefaultValue (-1);
2736  fpCommand -> SetParameter (parameter);
2737  parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
2738  parameter -> SetGuidance
2739  ("Depth of descent of geometry hierarchy. Default = unlimited depth.");
2740  parameter -> SetDefaultValue (G4Scene::UNLIMITED);
2741  fpCommand -> SetParameter (parameter);
2742  parameter = new G4UIparameter ("clip-volume-type", 's', omitable = true);
2743  parameter -> SetParameterCandidates("none box -box *box");
2744  parameter -> SetDefaultValue ("none");
2745  parameter -> SetGuidance("[-|*]type. See general guidance.");
2746  fpCommand -> SetParameter (parameter);
2747  parameter = new G4UIparameter ("parameter-unit", 's', omitable = true);
2748  parameter -> SetDefaultValue ("m");
2749  fpCommand -> SetParameter (parameter);
2750  parameter = new G4UIparameter ("parameter-1", 'd', omitable = true);
2751  parameter -> SetDefaultValue (0.);
2752  fpCommand -> SetParameter (parameter);
2753  parameter = new G4UIparameter ("parameter-2", 'd', omitable = true);
2754  parameter -> SetDefaultValue (0.);
2755  fpCommand -> SetParameter (parameter);
2756  parameter = new G4UIparameter ("parameter-3", 'd', omitable = true);
2757  parameter -> SetDefaultValue (0.);
2758  fpCommand -> SetParameter (parameter);
2759  parameter = new G4UIparameter ("parameter-4", 'd', omitable = true);
2760  parameter -> SetDefaultValue (0.);
2761  fpCommand -> SetParameter (parameter);
2762  parameter = new G4UIparameter ("parameter-5", 'd', omitable = true);
2763  parameter -> SetDefaultValue (0.);
2764  fpCommand -> SetParameter (parameter);
2765  parameter = new G4UIparameter ("parameter-6", 'd', omitable = true);
2766  parameter -> SetDefaultValue (0.);
2767  fpCommand -> SetParameter (parameter);
2768 }
bool G4bool
Definition: G4Types.hh:79

◆ ~G4VisCommandSceneAddVolume()

G4VisCommandSceneAddVolume::~G4VisCommandSceneAddVolume ( )
virtual

Definition at line 2770 of file G4VisCommandsSceneAdd.cc.

2770  {
2771  delete fpCommand;
2772 }

◆ G4VisCommandSceneAddVolume() [2/2]

G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume ( const G4VisCommandSceneAddVolume )
private

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneAddVolume::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 2774 of file G4VisCommandsSceneAdd.cc.

2774  {
2775  return "world 0 -1";
2776 }

◆ operator=()

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

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 2778 of file G4VisCommandsSceneAdd.cc.

2779  {
2780 
2782  G4bool warn = verbosity >= G4VisManager::warnings;
2783 
2784  G4Scene* pScene = fpVisManager->GetCurrentScene();
2785  if (!pScene) {
2786  if (verbosity >= G4VisManager::errors) {
2787  G4cerr << "ERROR: No current scene. Please create one." << G4endl;
2788  }
2789  return;
2790  }
2791 
2792  G4String name, clipVolumeType, parameterUnit;
2793  G4int copyNo, requestedDepthOfDescent;
2794  G4double param1, param2, param3, param4, param5, param6;
2795  std::istringstream is (newValue);
2796  is >> name >> copyNo >> requestedDepthOfDescent
2797  >> clipVolumeType >> parameterUnit
2798  >> param1 >> param2 >> param3 >> param4 >> param5 >> param6;
2800  G4PhysicalVolumeModel::subtraction; // Default subtraction mode.
2801  if (clipVolumeType[size_t(0)] == '-') {
2802  clipVolumeType = clipVolumeType.substr(1); // Remove first character.
2803  } else if (clipVolumeType[size_t(0)] == '*') {
2804  clippingMode = G4PhysicalVolumeModel::intersection;
2805  clipVolumeType = clipVolumeType.substr(1);
2806  }
2807  G4double unit = G4UIcommand::ValueOf(parameterUnit);
2808  param1 *= unit; param2 *= unit; param3 *= unit;
2809  param4 *= unit; param5 *= unit; param6 *= unit;
2810 
2811  G4TransportationManager* transportationManager =
2813 
2814  size_t nWorlds = transportationManager->GetNoWorlds();
2815  if (nWorlds > 1) { // Parallel worlds in operation...
2816  if (verbosity >= G4VisManager::warnings) {
2817  static G4bool warned = false;
2818  if (!warned && name != "worlds") {
2819  G4cout <<
2820  "WARNING: Parallel worlds in operation. To visualise, specify"
2821  "\n \"worlds\" or the parallel world volume or sub-volume name"
2822  "\n and control visibility with /vis/geometry."
2823  << G4endl;
2824  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2825  transportationManager->GetWorldsIterator();
2826  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2827  G4cout << " World " << i << ": " << (*iterWorld)->GetName()
2828  << G4endl;
2829  warned = true;
2830  }
2831  }
2832  }
2833  }
2834 
2835  G4VPhysicalVolume* world = *(transportationManager->GetWorldsIterator());
2836 
2837  if (!world) {
2838  if (verbosity >= G4VisManager::errors) {
2839  G4cerr <<
2840  "ERROR: G4VisCommandSceneAddVolume::SetNewValue:"
2841  "\n No world. Maybe the geometry has not yet been defined."
2842  "\n Try \"/run/initialize\""
2843  << G4endl;
2844  }
2845  return;
2846  }
2847 
2848  const std::vector<G4Scene::Model>& rdModelList = pScene -> GetRunDurationModelList();
2849  std::vector<G4Scene::Model>::const_iterator it;
2850  for (it = rdModelList.begin(); it != rdModelList.end(); ++it) {
2851  if (it->fpModel->GetGlobalDescription().find("G4PhysicalVolumeModel")
2852  != std::string::npos) {
2853  if (((G4PhysicalVolumeModel*)(it->fpModel))->GetTopPhysicalVolume () == world) break;
2854  }
2855  }
2856  if (it != rdModelList.end()) {
2857  if (verbosity >= G4VisManager::warnings) {
2858  G4cout << "WARNING: There is already a volume, \""
2859  << it -> fpModel -> GetGlobalDescription()
2860  << "\",\n in the run-duration model list of scene \""
2861  << pScene -> GetName()
2862  << "\".\n To get a clean scene:"
2863  << "\n /vis/drawVolume " << name
2864  << "\n or"
2865  << "\n /vis/scene/create"
2866  << "\n /vis/scene/add/volume " << name
2867  << "\n /vis/sceneHandler/attach"
2868  << "\n (and also, if necessary, /vis/viewer/flush)"
2869  << G4endl;
2870  }
2871  return;
2872  }
2873 
2874  std::vector<G4PhysicalVolumeModel*> models;
2875  std::vector<G4VPhysicalVolume*> foundVolumes;
2876  G4VPhysicalVolume* foundWorld = 0;
2878  typedef std::vector<PVNodeID> PVPath;
2879  PVPath foundFullPVPath;
2880  std::vector<G4int> foundDepths;
2881  std::vector<G4Transform3D> transformations;
2882 
2883  if (name == "world") {
2884 
2885  models.push_back
2886  (new G4PhysicalVolumeModel (world, requestedDepthOfDescent));
2887  foundVolumes.push_back(world);
2888  foundDepths.push_back(0);
2889  transformations.push_back(G4Transform3D());
2890 
2891  } else if (name == "worlds") {
2892 
2893  if (nWorlds == 0) {
2894  if (verbosity >= G4VisManager::warnings) {
2895  G4cout <<
2896  "WARNING: G4VisCommandSceneAddVolume::SetNewValue:"
2897  "\n Parallel worlds requested but none exist."
2898  "\n Just adding material world."
2899  << G4endl;
2900  }
2901  }
2902  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2903  transportationManager->GetWorldsIterator();
2904  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2905  models.push_back
2906  (new G4PhysicalVolumeModel (*iterWorld, requestedDepthOfDescent));
2907  foundVolumes.push_back(*iterWorld);
2908  foundDepths.push_back(0);
2909  transformations.push_back(G4Transform3D());
2910  }
2911 
2912  } else { // Search all worlds...
2913 
2914  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2915  transportationManager->GetWorldsIterator();
2916  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2917  G4PhysicalVolumeModel searchModel (*iterWorld); // Unlimited depth.
2918  G4ModelingParameters mp; // Default - no culling.
2919  searchModel.SetModelingParameters (&mp);
2920  G4PhysicalVolumeSearchScene searchScene (&searchModel, name, copyNo);
2921  searchModel.DescribeYourselfTo (searchScene); // Initiate search.
2922  G4VPhysicalVolume* foundVolume = searchScene.GetFoundVolume ();
2923  if (foundVolume) {
2924  foundWorld = *iterWorld;
2925  foundVolumes.push_back(foundVolume);
2926  foundFullPVPath = searchScene.GetFoundFullPVPath();
2927  foundDepths.push_back(searchScene.GetFoundDepth());
2928  transformations.push_back(searchScene.GetFoundTransformation());
2929  break;
2930  }
2931  }
2932 
2933  if (foundVolumes.size()) {
2934  for (size_t i = 0; i < foundVolumes.size(); ++i) {
2935  G4PhysicalVolumeModel* foundPVModel = new G4PhysicalVolumeModel
2936  (foundVolumes[i], requestedDepthOfDescent, transformations[i]);
2937  foundFullPVPath.pop_back(); // "Base" is "Found - 1".
2938  foundPVModel->SetBaseFullPVPath(foundFullPVPath);
2939  models.push_back(foundPVModel);
2940  }
2941  } else {
2942  if (verbosity >= G4VisManager::errors) {
2943  G4cerr << "ERROR: Volume \"" << name << "\"";
2944  if (copyNo >= 0) {
2945  G4cerr << ", copy no. " << copyNo << ",";
2946  }
2947  G4cerr << " not found." << G4endl;
2948  }
2949  return;
2950  }
2951  }
2952 
2953  if (clipVolumeType == "box") {
2954  const G4double dX = (param2 - param1) / 2.;
2955  const G4double dY = (param4 - param3) / 2.;
2956  const G4double dZ = (param6 - param5) / 2.;
2957  const G4double x0 = (param2 + param1) / 2.;
2958  const G4double y0 = (param4 + param3) / 2.;
2959  const G4double z0 = (param6 + param5) / 2.;
2960  G4VSolid* clippingSolid =
2961  new G4DisplacedSolid
2962  ("_displaced_clipping_box",
2963  new G4Box("_clipping_box",dX,dY,dZ),
2964  G4Translate3D(x0,y0,z0));
2965  for (size_t i = 0; i < foundVolumes.size(); ++i) {
2966  models[i]->SetClippingSolid(clippingSolid);
2967  models[i]->SetClippingMode(clippingMode);
2968  }
2969  } // If any other shape consider NumberOfRotationSides!!!!!!!!!!!
2970 
2971  const G4String& currentSceneName = pScene -> GetName ();
2972  G4bool failure = true;
2973  for (size_t i = 0; i < foundVolumes.size(); ++i) {
2974  G4bool successful = pScene -> AddRunDurationModel (models[i], warn);
2975  if (successful) {
2976  failure = false;
2977  if (verbosity >= G4VisManager::confirmations) {
2978  G4cout << "First occurrence of \""
2979  << foundVolumes[i] -> GetName ()
2980  << "\"";
2981  if (copyNo >= 0) {
2982  G4cout << ", copy no. " << copyNo << ",";
2983  }
2984  G4cout << "\n found ";
2985  if (foundWorld)
2986  G4cout << "in world \"" << foundWorld->GetName() << "\" ";
2987  G4cout << "at depth " << foundDepths[i]
2988  << ",\n with a requested depth of further descent of ";
2989  if (requestedDepthOfDescent < 0) {
2990  G4cout << "<0 (unlimited)";
2991  }
2992  else {
2993  G4cout << requestedDepthOfDescent;
2994  }
2995  G4cout << ",\n has been added to scene \"" << currentSceneName << "\"."
2996  << G4endl;
2997  }
2998  }
2999  }
3000 
3001  if (failure) {
3003  return;
3004  }
3005 
3006  UpdateVisManagerScene (currentSceneName);
3007 }
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
G4Scene * GetCurrentScene() const
Definition: G4Box.hh:64
void UpdateVisManagerScene(const G4String &sceneName="")
G4String name
Definition: TRTMaterials.hh:40
size_t GetNoWorlds() const
int G4int
Definition: G4Types.hh:78
static void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID
HepGeom::Transform3D G4Transform3D
std::vector< PVNodeID > PVPath
void SetBaseFullPVPath(const std::vector< G4PhysicalVolumeNodeID > &baseFullPVPath)
static G4TransportationManager * GetTransportationManager()
const G4String & GetName() const
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:308
static Verbosity GetVerbosity()
HepGeom::Translate3D G4Translate3D
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4GLOB_DLL std::ostream G4cerr
static G4VisManager * fpVisManager
Here is the call graph for this function:

Member Data Documentation

◆ fpCommand

G4UIcommand* G4VisCommandSceneAddVolume::fpCommand
private

Definition at line 422 of file G4VisCommandsSceneAdd.hh.


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