2644 {
2645
2648
2650 if (!pScene) {
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;
2666 if (clipVolumeType[size_t(0)] == '-') {
2667 clipVolumeType = clipVolumeType.substr(1);
2668 } else if (clipVolumeType[size_t(0)] == '*') {
2670 clipVolumeType = clipVolumeType.substr(1);
2671 }
2673 param1 *= unit; param2 *= unit; param3 *= unit;
2674 param4 *= unit; param5 *= unit; param6 *= unit;
2675
2678
2679 size_t nWorlds = transportationManager->
GetNoWorlds();
2680 if (nWorlds > 1) {
2682 static G4bool warned =
false;
2683 if (!warned && name != "worlds") {
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."
2689 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2691 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2692 G4cout <<
" World " << i <<
": " << (*iterWorld)->GetName()
2694 warned = true;
2695 }
2696 }
2697 }
2698 }
2699
2701
2702 if (!world) {
2705 "ERROR: G4VisCommandSceneAddVolume::SetNewValue:"
2706 "\n No world. Maybe the geometry has not yet been defined."
2707 "\n Try \"/run/initialize\""
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) {
2719 }
2720 }
2721 if (it != rdModelList.end()) {
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)"
2735 }
2736 return;
2737 }
2738
2739 std::vector<G4PhysicalVolumeModel*> models;
2740 std::vector<G4VPhysicalVolume*> foundVolumes;
2743 typedef std::vector<PVNodeID>
PVPath;
2745 std::vector<G4int> foundDepths;
2746 std::vector<G4Transform3D> transformations;
2747
2748 if (name == "world") {
2749
2750 models.push_back
2752 foundVolumes.push_back(world);
2753 foundDepths.push_back(0);
2755
2756 } else if (name == "worlds") {
2757
2758 if (nWorlds == 0) {
2761 "WARNING: G4VisCommandSceneAddVolume::SetNewValue:"
2762 "\n Parallel worlds requested but none exist."
2763 "\n Just adding material world."
2765 }
2766 }
2767 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2769 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2770 models.push_back
2772 foundVolumes.push_back(*iterWorld);
2773 foundDepths.push_back(0);
2775 }
2776
2777 } else {
2778
2779 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2781 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2784 searchModel.SetModelingParameters (&mp);
2786 searchModel.DescribeYourselfTo (searchScene);
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();
2804 models.push_back(foundPVModel);
2805 }
2806 } else {
2808 G4cout <<
"ERROR: Volume \"" << name <<
"\"";
2809 if (copyNo >= 0) {
2810 G4cout <<
", copy no. " << copyNo <<
",";
2811 }
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.;
2827 ("_displaced_clipping_box",
2828 new G4Box(
"_clipping_box",dX,dY,dZ),
2830 for (size_t i = 0; i < foundVolumes.size(); ++i) {
2831 models[i]->SetClippingSolid(clippingSolid);
2832 models[i]->SetClippingMode(clippingMode);
2833 }
2834 }
2835
2836 const G4String& currentSceneName = pScene -> GetName ();
2838 for (size_t i = 0; i < foundVolumes.size(); ++i) {
2839 G4bool successful = pScene -> AddRunDurationModel (models[i], warn);
2840 if (successful) {
2841 failure = false;
2843 G4cout <<
"First occurrence of \""
2844 << foundVolumes[i] -> GetName ()
2845 << "\"";
2846 if (copyNo >= 0) {
2847 G4cout <<
", copy no. " << copyNo <<
",";
2848 }
2850 if (foundWorld)
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 <<
"\"."
2862 }
2863 }
2864 }
2865
2866 if (failure) {
2867 G4VisCommandsSceneAddUnsuccessful(verbosity);
2868 return;
2869 }
2870
2872}
G4DLLIMPORT std::ostream G4cout
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)
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