Geant4 11.2.2
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 ()=default
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
static G4VisManagerGetVisManager ()
 
static void SetVisManager (G4VisManager *pVisManager)
 
static const G4ColourGetCurrentTextColour ()
 
- Protected Member Functions inherited from G4VVisCommandScene
G4String CurrentSceneName ()
 
- Protected Member Functions inherited from G4VVisCommand
void SetViewParameters (G4VViewer *viewer, const G4ViewParameters &viewParams)
 
void RefreshIfRequired (G4VViewer *viewer)
 
void InterpolateViews (G4VViewer *currentViewer, std::vector< G4ViewParameters > viewVector, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String exportString="")
 
void InterpolateToNewView (G4VViewer *currentViewer, const G4ViewParameters &oldVP, const G4ViewParameters &newVP, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String exportString="")
 
void Twinkle (G4VViewer *currentViewer, const G4ViewParameters &baseVP, const std::vector< std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > > &paths)
 
const G4StringConvertToColourGuidance ()
 
void ConvertToColour (G4Colour &colour, const G4String &redOrString, G4double green, G4double blue, G4double opacity)
 
G4bool ProvideValueOfUnit (const G4String &where, const G4String &unit, const G4String &category, G4double &value)
 
void CopyCameraParameters (G4ViewParameters &target, const G4ViewParameters &from)
 
void CheckSceneAndNotifyHandlers (G4Scene *=nullptr)
 
G4bool CheckView ()
 
void G4VisCommandsSceneAddUnsuccessful (G4VisManager::Verbosity verbosity)
 
void CopyGuidanceFrom (const G4UIcommand *fromCmd, G4UIcommand *toCmd, G4int startLine=0)
 
void CopyParametersFrom (const G4UIcommand *fromCmd, G4UIcommand *toCmd)
 
void DrawExtent (const G4VisExtent &)
 
- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String LtoS (G4long l)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const 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 G4bool ConvertToDoublePair (const G4String &paramString, G4double &xval, G4double &yval)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 
- Static Protected Attributes inherited from G4VVisCommand
static G4VisManagerfpVisManager = nullptr
 
static G4int fCurrentArrow3DLineSegmentsPerCircle = 6
 
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 G4PhysicalVolumeModel::TouchableProperties fCurrentTouchableProperties
 
static G4VisExtent fCurrentExtentForField
 
static std::vector< G4PhysicalVolumesSearchScene::FindingsfCurrrentPVFindingsForField
 
static G4bool fThereWasAViewer = false
 
static G4ViewParameters fExistingVP
 
static G4SceneTreeItem fExistingSceneTree
 

Detailed Description

Definition at line 479 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneAddVolume()

G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume ( )

Definition at line 3039 of file G4VisCommandsSceneAdd.cc.

3039 {
3040 G4bool omitable;
3041 fpCommand = new G4UIcommand ("/vis/scene/add/volume", this);
3042 fpCommand -> SetGuidance
3043 ("Adds a physical volume to current scene, with optional clipping volume.");
3044 fpCommand -> SetGuidance
3045 ("If physical-volume-name is \"world\" (the default), the top of the"
3046 "\nmain geometry tree (material world) is added. If \"worlds\", the"
3047 "\ntops of all worlds - material world and parallel worlds, if any - are"
3048 "\nadded. Otherwise a search of all worlds is made.");
3049 fpCommand -> SetGuidance
3050 ("In the last case the names of all volumes in all worlds are matched"
3051 "\nagainst physical-volume-name. If this is of the form \"/regexp/\","
3052 "\nwhere regexp is a regular expression (see C++ regex), the match uses"
3053 "\nthe usual rules of regular expression matching. Otherwise an exact"
3054 "\nmatch is required."
3055 "\nFor example, \"/Shap/\" adds \"Shape1\" and \"Shape2\".");
3056 fpCommand -> SetGuidance
3057 ("It may help to see a textual representation of the geometry hierarchy of"
3058 "\nthe worlds. Try \"/vis/drawTree [worlds]\" or one of the driver/browser"
3059 "\ncombinations that have the required functionality, e.g., HepRepFile.");
3060 fpCommand -> SetGuidance
3061 ("If clip-volume-type is specified, the subsequent parameters are used to"
3062 "\nto define a clipping volume. For example,"
3063 "\n\"/vis/scene/add/volume ! ! ! -box km 0 1 0 1 0 1\" will draw the world"
3064 "\nwith the positive octant cut away. (If the Boolean Processor issues"
3065 "\nwarnings try replacing 0 by 0.000000001 or something.)");
3066 fpCommand -> SetGuidance
3067 ("If clip-volume-type is prepended with '-', the clip-volume is subtracted"
3068 "\n(cutaway). (This is the default if there is no prepended character.)"
3069 "\nIf '*' is prepended, the intersection of the physical-volume and the"
3070 "\nclip-volume is made. (You can make a section through the detector with"
3071 "\na thin box, for example).");
3072 fpCommand -> SetGuidance
3073 ("For \"box\", the parameters are xmin,xmax,ymin,ymax,zmin,zmax."
3074 "\nOnly \"box\" is programmed at present.");
3075 G4UIparameter* parameter;
3076 parameter = new G4UIparameter ("physical-volume-name", 's', omitable = true);
3077 parameter -> SetDefaultValue ("world");
3078 fpCommand -> SetParameter (parameter);
3079 parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
3080 parameter -> SetGuidance ("If negative, matches any copy no.");
3081 parameter -> SetDefaultValue (-1);
3082 fpCommand -> SetParameter (parameter);
3083 parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
3084 parameter -> SetGuidance
3085 ("Depth of descent of geometry hierarchy. Default = unlimited depth.");
3086 parameter -> SetDefaultValue (G4PhysicalVolumeModel::UNLIMITED);
3087 fpCommand -> SetParameter (parameter);
3088 parameter = new G4UIparameter ("clip-volume-type", 's', omitable = true);
3089 parameter -> SetParameterCandidates("none box -box *box");
3090 parameter -> SetDefaultValue ("none");
3091 parameter -> SetGuidance("[-|*]type. See general guidance.");
3092 fpCommand -> SetParameter (parameter);
3093 parameter = new G4UIparameter ("parameter-unit", 's', omitable = true);
3094 parameter -> SetDefaultValue ("m");
3095 fpCommand -> SetParameter (parameter);
3096 parameter = new G4UIparameter ("parameter-1", 'd', omitable = true);
3097 parameter -> SetDefaultValue (0.);
3098 fpCommand -> SetParameter (parameter);
3099 parameter = new G4UIparameter ("parameter-2", 'd', omitable = true);
3100 parameter -> SetDefaultValue (0.);
3101 fpCommand -> SetParameter (parameter);
3102 parameter = new G4UIparameter ("parameter-3", 'd', omitable = true);
3103 parameter -> SetDefaultValue (0.);
3104 fpCommand -> SetParameter (parameter);
3105 parameter = new G4UIparameter ("parameter-4", 'd', omitable = true);
3106 parameter -> SetDefaultValue (0.);
3107 fpCommand -> SetParameter (parameter);
3108 parameter = new G4UIparameter ("parameter-5", 'd', omitable = true);
3109 parameter -> SetDefaultValue (0.);
3110 fpCommand -> SetParameter (parameter);
3111 parameter = new G4UIparameter ("parameter-6", 'd', omitable = true);
3112 parameter -> SetDefaultValue (0.);
3113 fpCommand -> SetParameter (parameter);
3114}
bool G4bool
Definition G4Types.hh:86

◆ ~G4VisCommandSceneAddVolume()

G4VisCommandSceneAddVolume::~G4VisCommandSceneAddVolume ( )
virtual

Definition at line 3116 of file G4VisCommandsSceneAdd.cc.

3116 {
3117 delete fpCommand;
3118}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneAddVolume::GetCurrentValue ( G4UIcommand * command)
virtual

Reimplemented from G4UImessenger.

Definition at line 3120 of file G4VisCommandsSceneAdd.cc.

3120 {
3121 return "world 0 -1";
3122}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 3124 of file G4VisCommandsSceneAdd.cc.

3125 {
3126
3128 G4bool warn = verbosity >= G4VisManager::warnings;
3129
3131 if (!pScene) {
3132 if (verbosity >= G4VisManager::errors) {
3133 G4warn << "ERROR: No current scene. Please create one." << G4endl;
3134 }
3135 return;
3136 }
3137
3138 G4String name, clipVolumeType, parameterUnit;
3139 G4int copyNo, requestedDepthOfDescent;
3140 G4double param1, param2, param3, param4, param5, param6;
3141 std::istringstream is (newValue);
3142 is >> name >> copyNo >> requestedDepthOfDescent
3143 >> clipVolumeType >> parameterUnit
3144 >> param1 >> param2 >> param3 >> param4 >> param5 >> param6;
3146 G4PhysicalVolumeModel::subtraction; // Default subtraction mode.
3147 if (clipVolumeType[size_t(0)] == '-') {
3148 clipVolumeType = clipVolumeType.substr(1); // Remove first character.
3149 } else if (clipVolumeType[size_t(0)] == '*') {
3151 clipVolumeType = clipVolumeType.substr(1);
3152 }
3153 G4double unit = G4UIcommand::ValueOf(parameterUnit);
3154 param1 *= unit; param2 *= unit; param3 *= unit;
3155 param4 *= unit; param5 *= unit; param6 *= unit;
3156
3157 G4VSolid* clippingSolid = nullptr;
3158 if (clipVolumeType == "box") {
3159 const G4double dX = (param2 - param1) / 2.;
3160 const G4double dY = (param4 - param3) / 2.;
3161 const G4double dZ = (param6 - param5) / 2.;
3162 const G4double x0 = (param2 + param1) / 2.;
3163 const G4double y0 = (param4 + param3) / 2.;
3164 const G4double z0 = (param6 + param5) / 2.;
3165 clippingSolid = new G4DisplacedSolid
3166 ("_displaced_clipping_box",
3167 new G4Box("_clipping_box",dX,dY,dZ),
3168 G4Translate3D(x0,y0,z0));
3169 }
3170
3171 G4TransportationManager* transportationManager =
3173
3174 size_t nWorlds = transportationManager->GetNoWorlds();
3175 if (nWorlds > 1) { // Parallel worlds in operation...
3176 if (verbosity >= G4VisManager::warnings) {
3177 static G4bool warned = false;
3178 if (!warned && name != "worlds") {
3179 G4warn <<
3180 "WARNING: Parallel worlds in operation. To visualise, specify"
3181 "\n \"worlds\" or the parallel world volume or sub-volume name"
3182 "\n and control visibility with /vis/geometry."
3183 << G4endl;
3184 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
3185 transportationManager->GetWorldsIterator();
3186 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
3187 G4warn << " World " << i << ": " << (*iterWorld)->GetName()
3188 << G4endl;
3189 warned = true;
3190 }
3191 }
3192 }
3193 }
3194
3195 // Get the world (the initial value of the iterator points to the mass world).
3196 G4VPhysicalVolume* world = *(transportationManager->GetWorldsIterator());
3197
3198 if (!world) {
3199 if (verbosity >= G4VisManager::errors) {
3200 G4warn <<
3201 "ERROR: G4VisCommandSceneAddVolume::SetNewValue:"
3202 "\n No world. Maybe the geometry has not yet been defined."
3203 "\n Try \"/run/initialize\""
3204 << G4endl;
3205 }
3206 return;
3207 }
3208
3209 std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
3210
3211 // When it comes to determining the extent of a physical volume we normally
3212 // assume the user wishes to ignore "invisible" volumes. For example, most
3213 // users make the world volume invisible. So we ask the physical volume
3214 // model to traverse the geometry hierarchy, starting at the named physical
3215 // volume, until it finds non-invisible ones, whose extents are accumulated
3216 // to determine the overall extent. (Once a non-invisible volume is found,
3217 // the search is curtailed - daughters are always contained within the mother
3218 // so they have no subsequent influence on the extent of the mother - but the
3219 // search continues at the same level until all highest level non-invisible
3220 // volumes are found an their extents accumulated.) So the default is
3221 G4bool useFullExtent = false;
3222 // However, the above procedure can be time consuming in some situations, such
3223 // as a nested parameterisation whose ultimate volumes are the first non-
3224 // visible ones, which are typical of a medical "phantom". So we assume here
3225 // below that if a user specifies a name other than "world" or "worlds" he/she
3226 // wished the extent to be determined by the volume, whether it is visible
3227 // or not. So we set useFullExtent true at that point below.
3228
3229 if (name == "world") {
3230
3231 findingsVector.push_back
3233
3234 } else if (name == "worlds") {
3235
3236 if (nWorlds <= 1) {
3237 if (verbosity >= G4VisManager::warnings) {
3238 G4warn <<
3239 "WARNING: G4VisCommandSceneAddVolume::SetNewValue:"
3240 "\n Parallel worlds requested but none exist."
3241 "\n Just adding material world."
3242 << G4endl;
3243 }
3244 }
3245 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
3246 transportationManager->GetWorldsIterator();
3247 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
3248 findingsVector.push_back
3250 (*iterWorld,*iterWorld));
3251 }
3252
3253 } else { // Search all worlds...
3254
3255 // Use the model's full extent. This assumes the user wants these
3256 // volumes in the findings vector (there could be more than one) to
3257 // determine the scene's extent. Otherwise G4PhysicalVolumeModel would
3258 // re-calculate each volume's extent based on visibility, etc., which
3259 // could be time consuming.
3260 useFullExtent = true;
3261
3262 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
3263 transportationManager->GetWorldsIterator();
3264 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
3265 G4ModelingParameters mp; // Default - no culling.
3266 G4PhysicalVolumeModel searchModel
3267 (*iterWorld,
3268 requestedDepthOfDescent,
3269 G4Transform3D(),
3270 &mp,
3271 useFullExtent);
3272 G4PhysicalVolumesSearchScene searchScene(&searchModel, name, copyNo);
3273 searchModel.DescribeYourselfTo (searchScene); // Initiate search.
3274 for (const auto& findings: searchScene.GetFindings()) {
3275 findingsVector.push_back(findings);
3276 }
3277 }
3278 }
3279
3280 for (const auto& findings: findingsVector) {
3281 // Set copy number from search findings for replicas and parameterisations.
3282 findings.fpFoundPV->SetCopyNo(findings.fFoundPVCopyNo);
3284 (findings.fpFoundPV,
3285 requestedDepthOfDescent,
3286 findings.fFoundObjectTransformation,
3287 0, // No modelling parameters (these are set later by the scene handler).
3288 useFullExtent,
3289 findings.fFoundBasePVPath);
3290 if (clippingSolid) {
3291 foundPVModel->SetClippingSolid(clippingSolid);
3292 foundPVModel->SetClippingMode(clippingMode);
3293 }
3294 if (!foundPVModel->Validate(warn)) return;
3295 // ...so add it to the scene.
3296 G4bool successful = pScene->AddRunDurationModel(foundPVModel,warn);
3297 if (successful) {
3298 if (verbosity >= G4VisManager::confirmations) {
3299 G4cout << "\"" << findings.fpFoundPV->GetName()
3300 << "\", copy no. " << findings.fFoundPVCopyNo
3301 << ",\n found in searched volume \""
3302 << findings.fpSearchPV->GetName()
3303 << "\" at depth " << findings.fFoundDepth
3304 << ",\n base path: \"" << findings.fFoundBasePVPath
3305 << "\",\n with a requested depth of further descent of ";
3306 if (requestedDepthOfDescent < 0) {
3307 G4cout << "<0 (unlimited)";
3308 }
3309 else {
3310 G4cout << requestedDepthOfDescent;
3311 }
3312 G4cout << ",\n has been added to scene \"" << pScene->GetName() << "\"."
3313 << G4endl;
3314 }
3315 } else {
3317 }
3318 }
3319
3320 if (findingsVector.empty()) {
3321 if (verbosity >= G4VisManager::errors) {
3322 G4warn << "ERROR: Volume \"" << name << "\"";
3323 if (copyNo >= 0) {
3324 G4warn << ", copy no. " << copyNo << ",";
3325 }
3326 G4warn << " not found." << G4endl;
3327 }
3329 return;
3330 }
3331
3333}
#define G4warn
Definition G4Scene.cc:41
HepGeom::Transform3D G4Transform3D
HepGeom::Translate3D G4Translate3D
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
Definition G4Box.hh:56
void SetClippingSolid(G4VSolid *pClippingSolid)
void SetClippingMode(ClippingMode mode)
G4bool AddRunDurationModel(G4VModel *, G4bool warn=false)
Definition G4Scene.cc:160
const G4String & GetName() const
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
std::size_t GetNoWorlds() const
static G4double ValueOf(const char *unitName)
void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
void CheckSceneAndNotifyHandlers(G4Scene *=nullptr)
static G4VisManager * fpVisManager
G4Scene * GetCurrentScene() const
static Verbosity GetVerbosity()
const char * name(G4int ptype)

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