Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4VisCommandSceneAddVolume Class Reference

#include <G4VisCommandsSceneAdd.hh>

Inheritance diagram for G4VisCommandSceneAddVolume:
G4VVisCommandScene G4VVisCommand G4UImessenger

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
 

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, 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
 
- 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 394 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume ( )

Definition at line 2475 of file G4VisCommandsSceneAdd.cc.

References G4Scene::UNLIMITED.

2475  {
2476  G4bool omitable;
2477  fpCommand = new G4UIcommand ("/vis/scene/add/volume", this);
2478  fpCommand -> SetGuidance
2479  ("Adds a physical volume to current scene, with optional clipping volume.");
2480  fpCommand -> SetGuidance
2481  ("If physical-volume-name is \"world\" (the default), the top of the"
2482  "\nmain geometry tree (material world) is added. If \"worlds\", the"
2483  "\ntop of all worlds - material world and parallel worlds, if any - are"
2484  "\nadded. Otherwise a search of all worlds is made, taking the first"
2485  "\nmatching occurence only. To see a representation of the geometry"
2486  "\nhierarchy of the worlds, try \"/vis/drawTree [worlds]\" or one of the"
2487  "\ndriver/browser combinations that have the required functionality, e.g., HepRep.");
2488  fpCommand -> SetGuidance
2489  ("If clip-volume-type is specified, the subsequent parameters are used to"
2490  "\nto define a clipping volume. For example,"
2491  "\n\"vis/scene/add/volume ! ! ! -box km 0 1 0 1 0 1\" will draw the world"
2492  "\nwith the positive octant cut away.");
2493  fpCommand -> SetGuidance
2494  ("If clip-volume-type is prepended with '-', the clip-volume is subtracted"
2495  "\n(cutaway). (This is the default if there is no prepended character.)"
2496  "\nIf '*' is prepended, the intersection of the physical-volume and the"
2497  "\nclip-volume is made. (You can make a section/DCUT with a thin box, for"
2498  "\nexample).");
2499  fpCommand -> SetGuidance
2500  ("For \"box\", the parameters are xmin,xmax,ymin,ymax,zmin,zmax."
2501  "\nOnly \"box\" is programmed at present.");
2502  G4UIparameter* parameter;
2503  parameter = new G4UIparameter ("physical-volume-name", 's', omitable = true);
2504  parameter -> SetDefaultValue ("world");
2505  fpCommand -> SetParameter (parameter);
2506  parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
2507  parameter -> SetGuidance
2508  ("If negative, matches any copy no. First name match is taken.");
2509  parameter -> SetDefaultValue (-1);
2510  fpCommand -> SetParameter (parameter);
2511  parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
2512  parameter -> SetGuidance
2513  ("Depth of descent of geometry hierarchy. Default = unlimited depth.");
2514  parameter -> SetDefaultValue (G4Scene::UNLIMITED);
2515  fpCommand -> SetParameter (parameter);
2516  parameter = new G4UIparameter ("clip-volume-type", 's', omitable = true);
2517  parameter -> SetParameterCandidates("none box -box *box");
2518  parameter -> SetDefaultValue ("none");
2519  parameter -> SetGuidance("[-|*]type. See general guidance.");
2520  fpCommand -> SetParameter (parameter);
2521  parameter = new G4UIparameter ("parameter-unit", 's', omitable = true);
2522  parameter -> SetDefaultValue ("m");
2523  fpCommand -> SetParameter (parameter);
2524  parameter = new G4UIparameter ("parameter-1", 'd', omitable = true);
2525  parameter -> SetDefaultValue (0.);
2526  fpCommand -> SetParameter (parameter);
2527  parameter = new G4UIparameter ("parameter-2", 'd', omitable = true);
2528  parameter -> SetDefaultValue (0.);
2529  fpCommand -> SetParameter (parameter);
2530  parameter = new G4UIparameter ("parameter-3", 'd', omitable = true);
2531  parameter -> SetDefaultValue (0.);
2532  fpCommand -> SetParameter (parameter);
2533  parameter = new G4UIparameter ("parameter-4", 'd', omitable = true);
2534  parameter -> SetDefaultValue (0.);
2535  fpCommand -> SetParameter (parameter);
2536  parameter = new G4UIparameter ("parameter-5", 'd', omitable = true);
2537  parameter -> SetDefaultValue (0.);
2538  fpCommand -> SetParameter (parameter);
2539  parameter = new G4UIparameter ("parameter-6", 'd', omitable = true);
2540  parameter -> SetDefaultValue (0.);
2541  fpCommand -> SetParameter (parameter);
2542 }
bool G4bool
Definition: G4Types.hh:79
G4VisCommandSceneAddVolume::~G4VisCommandSceneAddVolume ( )
virtual

Definition at line 2544 of file G4VisCommandsSceneAdd.cc.

2544  {
2545  delete fpCommand;
2546 }

Member Function Documentation

G4String G4VisCommandSceneAddVolume::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 2548 of file G4VisCommandsSceneAdd.cc.

2548  {
2549  return "world 0 -1";
2550 }
void G4VisCommandSceneAddVolume::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 2552 of file G4VisCommandsSceneAdd.cc.

References G4VisManager::confirmations, G4PhysicalVolumeModel::DescribeYourselfTo(), G4VisManager::errors, G4VVisCommand::fpVisManager, G4cout, G4endl, G4VisManager::GetCurrentScene(), G4PhysicalVolumeSearchScene::GetFoundDepth(), G4PhysicalVolumeSearchScene::GetFoundFullPVPath(), G4PhysicalVolumeSearchScene::GetFoundTransformation(), G4PhysicalVolumeSearchScene::GetFoundVolume(), G4VPhysicalVolume::GetName(), G4TransportationManager::GetNoWorlds(), G4TransportationManager::GetTransportationManager(), G4VisManager::GetVerbosity(), G4TransportationManager::GetWorldsIterator(), G4PhysicalVolumeModel::intersection, G4PhysicalVolumeModel::SetBaseFullPVPath(), G4VModel::SetModelingParameters(), G4PhysicalVolumeModel::subtraction, G4VVisCommand::UpdateVisManagerScene(), G4UIcommand::ValueOf(), G4VisManager::warnings, and G4InuclParticleNames::z0.

2553  {
2554 
2556  G4bool warn = verbosity >= G4VisManager::warnings;
2557 
2558  G4Scene* pScene = fpVisManager->GetCurrentScene();
2559  if (!pScene) {
2560  if (verbosity >= G4VisManager::errors) {
2561  G4cout << "ERROR: No current scene. Please create one." << G4endl;
2562  }
2563  return;
2564  }
2565 
2566  G4String name, clipVolumeType, parameterUnit;
2567  G4int copyNo, requestedDepthOfDescent;
2568  G4double param1, param2, param3, param4, param5, param6;
2569  std::istringstream is (newValue);
2570  is >> name >> copyNo >> requestedDepthOfDescent
2571  >> clipVolumeType >> parameterUnit
2572  >> param1 >> param2 >> param3 >> param4 >> param5 >> param6;
2574  G4PhysicalVolumeModel::subtraction; // Default subtraction mode.
2575  if (clipVolumeType[size_t(0)] == '-') {
2576  clipVolumeType = clipVolumeType.substr(1); // Remove first character.
2577  } else if (clipVolumeType[size_t(0)] == '*') {
2578  clippingMode = G4PhysicalVolumeModel::intersection;
2579  clipVolumeType = clipVolumeType.substr(1);
2580  }
2581  G4double unit = G4UIcommand::ValueOf(parameterUnit);
2582  param1 *= unit; param2 *= unit; param3 *= unit;
2583  param4 *= unit; param5 *= unit; param6 *= unit;
2584 
2585  G4TransportationManager* transportationManager =
2587 
2588  size_t nWorlds = transportationManager->GetNoWorlds();
2589  if (nWorlds > 1) { // Parallel worlds in operation...
2590  if (verbosity >= G4VisManager::warnings) {
2591  static G4bool warned = false;
2592  if (!warned && name != "worlds") {
2593  G4cout <<
2594  "WARNING: Parallel worlds in operation. To visualise, specify"
2595  "\n \"worlds\" or the parallel world volume or sub-volume name"
2596  "\n and control visibility with /vis/geometry."
2597  << G4endl;
2598  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2599  transportationManager->GetWorldsIterator();
2600  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2601  G4cout << " World " << i << ": " << (*iterWorld)->GetName()
2602  << G4endl;
2603  warned = true;
2604  }
2605  }
2606  }
2607  }
2608 
2609  G4VPhysicalVolume* world = *(transportationManager->GetWorldsIterator());
2610 
2611  if (!world) {
2612  if (verbosity >= G4VisManager::errors) {
2613  G4cout <<
2614  "ERROR: G4VisCommandSceneAddVolume::SetNewValue:"
2615  "\n No world. Maybe the geometry has not yet been defined."
2616  "\n Try \"/run/initialize\""
2617  << G4endl;
2618  }
2619  return;
2620  }
2621 
2622  const std::vector<G4Scene::Model>& rdModelList = pScene -> GetRunDurationModelList();
2623  std::vector<G4Scene::Model>::const_iterator it;
2624  for (it = rdModelList.begin(); it != rdModelList.end(); ++it) {
2625  if (it->fpModel->GetGlobalDescription().find("G4PhysicalVolumeModel")
2626  != std::string::npos) {
2627  if (((G4PhysicalVolumeModel*)(it->fpModel))->GetTopPhysicalVolume () == world) break;
2628  }
2629  }
2630  if (it != rdModelList.end()) {
2631  if (verbosity >= G4VisManager::warnings) {
2632  G4cout << "WARNING: There is already a volume, \""
2633  << it -> fpModel -> GetGlobalDescription()
2634  << "\",\n in the run-duration model list of scene \""
2635  << pScene -> GetName()
2636  << "\".\n To get a clean scene:"
2637  << "\n /vis/drawVolume " << name
2638  << "\n or"
2639  << "\n /vis/scene/create"
2640  << "\n /vis/scene/add/volume " << name
2641  << "\n /vis/sceneHandler/attach"
2642  << "\n (and also, if necessary, /vis/viewer/flush)"
2643  << G4endl;
2644  }
2645  return;
2646  }
2647 
2648  std::vector<G4PhysicalVolumeModel*> models;
2649  std::vector<G4VPhysicalVolume*> foundVolumes;
2650  G4VPhysicalVolume* foundWorld = 0;
2652  typedef std::vector<PVNodeID> PVPath;
2653  PVPath foundFullPVPath;
2654  std::vector<G4int> foundDepths;
2655  std::vector<G4Transform3D> transformations;
2656 
2657  if (name == "world") {
2658 
2659  models.push_back
2660  (new G4PhysicalVolumeModel (world, requestedDepthOfDescent));
2661  foundVolumes.push_back(world);
2662  foundDepths.push_back(0);
2663  transformations.push_back(G4Transform3D());
2664 
2665  } else if (name == "worlds") {
2666 
2667  if (nWorlds == 0) {
2668  if (verbosity >= G4VisManager::warnings) {
2669  G4cout <<
2670  "WARNING: G4VisCommandSceneAddVolume::SetNewValue:"
2671  "\n Parallel worlds requested but none exist."
2672  "\n Just adding material world."
2673  << G4endl;
2674  }
2675  }
2676  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2677  transportationManager->GetWorldsIterator();
2678  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2679  models.push_back
2680  (new G4PhysicalVolumeModel (*iterWorld, requestedDepthOfDescent));
2681  foundVolumes.push_back(*iterWorld);
2682  foundDepths.push_back(0);
2683  transformations.push_back(G4Transform3D());
2684  }
2685 
2686  } else { // Search all worlds...
2687 
2688  std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2689  transportationManager->GetWorldsIterator();
2690  for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2691  G4PhysicalVolumeModel searchModel (*iterWorld); // Unlimited depth.
2692  G4ModelingParameters mp; // Default - no culling.
2693  searchModel.SetModelingParameters (&mp);
2694  G4PhysicalVolumeSearchScene searchScene (&searchModel, name, copyNo);
2695  searchModel.DescribeYourselfTo (searchScene); // Initiate search.
2696  G4VPhysicalVolume* foundVolume = searchScene.GetFoundVolume ();
2697  if (foundVolume) {
2698  foundWorld = *iterWorld;
2699  foundVolumes.push_back(foundVolume);
2700  foundFullPVPath = searchScene.GetFoundFullPVPath();
2701  foundDepths.push_back(searchScene.GetFoundDepth());
2702  transformations.push_back(searchScene.GetFoundTransformation());
2703  break;
2704  }
2705  }
2706 
2707  if (foundVolumes.size()) {
2708  for (size_t i = 0; i < foundVolumes.size(); ++i) {
2709  G4PhysicalVolumeModel* foundPVModel = new G4PhysicalVolumeModel
2710  (foundVolumes[i], requestedDepthOfDescent, transformations[i]);
2711  foundFullPVPath.pop_back(); // "Base" is "Found - 1".
2712  foundPVModel->SetBaseFullPVPath(foundFullPVPath);
2713  models.push_back(foundPVModel);
2714  }
2715  } else {
2716  if (verbosity >= G4VisManager::errors) {
2717  G4cout << "ERROR: Volume \"" << name << "\"";
2718  if (copyNo >= 0) {
2719  G4cout << ", copy no. " << copyNo << ",";
2720  }
2721  G4cout << " not found." << G4endl;
2722  }
2723  return;
2724  }
2725  }
2726 
2727  if (clipVolumeType == "box") {
2728  const G4double dX = (param2 - param1) / 2.;
2729  const G4double dY = (param4 - param3) / 2.;
2730  const G4double dZ = (param6 - param5) / 2.;
2731  const G4double x0 = (param2 + param1) / 2.;
2732  const G4double y0 = (param4 + param3) / 2.;
2733  const G4double z0 = (param6 + param5) / 2.;
2734  G4VSolid* clippingSolid =
2735  new G4DisplacedSolid
2736  ("_displaced_clipping_box",
2737  new G4Box("_clipping_box",dX,dY,dZ),
2738  G4Translate3D(x0,y0,z0));
2739  for (size_t i = 0; i < foundVolumes.size(); ++i) {
2740  models[i]->SetClippingSolid(clippingSolid);
2741  models[i]->SetClippingMode(clippingMode);
2742  }
2743  } // If any other shape consider NumberOfRotationSides!!!!!!!!!!!
2744 
2745  const G4String& currentSceneName = pScene -> GetName ();
2746  G4bool failure = true;
2747  for (size_t i = 0; i < foundVolumes.size(); ++i) {
2748  G4bool successful = pScene -> AddRunDurationModel (models[i], warn);
2749  if (successful) {
2750  failure = false;
2751  if (verbosity >= G4VisManager::confirmations) {
2752  G4cout << "First occurrence of \""
2753  << foundVolumes[i] -> GetName ()
2754  << "\"";
2755  if (copyNo >= 0) {
2756  G4cout << ", copy no. " << copyNo << ",";
2757  }
2758  G4cout << "\n found ";
2759  if (foundWorld)
2760  G4cout << "in world \"" << foundWorld->GetName() << "\" ";
2761  G4cout << "at depth " << foundDepths[i]
2762  << ",\n with a requested depth of further descent of ";
2763  if (requestedDepthOfDescent < 0) {
2764  G4cout << "<0 (unlimited)";
2765  }
2766  else {
2767  G4cout << requestedDepthOfDescent;
2768  }
2769  G4cout << ",\n has been added to scene \"" << currentSceneName << "\"."
2770  << G4endl;
2771  }
2772  }
2773  }
2774 
2775  if (failure) {
2776  G4VisCommandsSceneAddUnsuccessful(verbosity);
2777  return;
2778  }
2779 
2780  UpdateVisManagerScene (currentSceneName);
2781 }
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
Definition: G4Box.hh:63
void UpdateVisManagerScene(const G4String &sceneName="")
const XML_Char * name
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
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()
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:294
static Verbosity GetVerbosity()
HepGeom::Translate3D G4Translate3D
size_t GetNoWorlds() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4Scene * GetCurrentScene() const
static G4VisManager * fpVisManager

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