Geant4 11.4.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 ()=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, const 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 (const 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 496 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneAddVolume()

G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume ( )

Definition at line 3101 of file G4VisCommandsSceneAdd.cc.

3101 {
3102 G4bool omitable;
3103 fpCommand = new G4UIcommand ("/vis/scene/add/volume", this);
3104 fpCommand -> SetGuidance
3105 ("Adds a physical volume to current scene, with optional clipping volume.");
3106 fpCommand -> SetGuidance
3107 ("If physical-volume-name is \"world\" (the default), the top of the"
3108 "\nmain geometry tree (material world) is added. If \"worlds\", the"
3109 "\ntops of all worlds - material world and parallel worlds, if any - are"
3110 "\nadded. Otherwise a search of all worlds is made.");
3111 fpCommand -> SetGuidance
3112 ("In the last case the names of all volumes in all worlds are matched"
3113 "\nagainst physical-volume-name. If this is of the form \"/regexp/\","
3114 "\nwhere regexp is a regular expression (see C++ regex), the match uses"
3115 "\nthe usual rules of regular expression matching. Otherwise an exact"
3116 "\nmatch is required."
3117 "\nFor example, \"/Shap/\" adds \"Shape1\" and \"Shape2\".");
3118 fpCommand -> SetGuidance
3119 ("It may help to see a textual representation of the geometry hierarchy of"
3120 "\nthe worlds. Try \"/vis/drawTree [worlds]\".");
3121 fpCommand -> SetGuidance
3122 ("If clip-volume-type is specified, the subsequent parameters are used to"
3123 "\nto define a clipping volume. For example,"
3124 "\n\"/vis/scene/add/volume ! ! ! -box km 0 1 0 1 0 1\" will draw the world"
3125 "\nwith the positive octant cut away. (If the Boolean Processor issues"
3126 "\nwarnings try replacing 0 by 0.000000001 or something.)");
3127 fpCommand -> SetGuidance
3128 ("If clip-volume-type is prepended with '-', the clip-volume is subtracted"
3129 "\n(cutaway). (This is the default if there is no prepended character.)"
3130 "\nIf '*' is prepended, the intersection of the physical-volume and the"
3131 "\nclip-volume is made. (You can make a section through the detector with"
3132 "\na thin box, for example).");
3133 fpCommand -> SetGuidance
3134 ("For \"box\", the parameters are xmin,xmax,ymin,ymax,zmin,zmax."
3135 "\nOnly \"box\" is programmed at present.");
3136 G4UIparameter* parameter;
3137 parameter = new G4UIparameter ("physical-volume-name", 's', omitable = true);
3138 parameter -> SetDefaultValue ("world");
3139 fpCommand -> SetParameter (parameter);
3140 parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
3141 parameter -> SetGuidance ("If negative, matches any copy no.");
3142 parameter -> SetDefaultValue (-1);
3143 fpCommand -> SetParameter (parameter);
3144 parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
3145 parameter -> SetGuidance
3146 ("Depth of descent of geometry hierarchy. Default = unlimited depth.");
3147 parameter -> SetDefaultValue (G4PhysicalVolumeModel::UNLIMITED);
3148 fpCommand -> SetParameter (parameter);
3149 parameter = new G4UIparameter ("clip-volume-type", 's', omitable = true);
3150 parameter -> SetParameterCandidates("none box -box *box");
3151 parameter -> SetDefaultValue ("none");
3152 parameter -> SetGuidance("[-|*]type. See general guidance.");
3153 fpCommand -> SetParameter (parameter);
3154 parameter = new G4UIparameter ("parameter-unit", 's', omitable = true);
3155 parameter -> SetDefaultValue ("m");
3156 fpCommand -> SetParameter (parameter);
3157 parameter = new G4UIparameter ("parameter-1", 'd', omitable = true);
3158 parameter -> SetDefaultValue (0.);
3159 fpCommand -> SetParameter (parameter);
3160 parameter = new G4UIparameter ("parameter-2", 'd', omitable = true);
3161 parameter -> SetDefaultValue (0.);
3162 fpCommand -> SetParameter (parameter);
3163 parameter = new G4UIparameter ("parameter-3", 'd', omitable = true);
3164 parameter -> SetDefaultValue (0.);
3165 fpCommand -> SetParameter (parameter);
3166 parameter = new G4UIparameter ("parameter-4", 'd', omitable = true);
3167 parameter -> SetDefaultValue (0.);
3168 fpCommand -> SetParameter (parameter);
3169 parameter = new G4UIparameter ("parameter-5", 'd', omitable = true);
3170 parameter -> SetDefaultValue (0.);
3171 fpCommand -> SetParameter (parameter);
3172 parameter = new G4UIparameter ("parameter-6", 'd', omitable = true);
3173 parameter -> SetDefaultValue (0.);
3174 fpCommand -> SetParameter (parameter);
3175}
bool G4bool
Definition G4Types.hh:86

◆ ~G4VisCommandSceneAddVolume()

G4VisCommandSceneAddVolume::~G4VisCommandSceneAddVolume ( )
virtual

Definition at line 3177 of file G4VisCommandsSceneAdd.cc.

3177 {
3178 delete fpCommand;
3179}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneAddVolume::GetCurrentValue ( G4UIcommand * command)
virtual

Reimplemented from G4UImessenger.

Definition at line 3181 of file G4VisCommandsSceneAdd.cc.

3181 {
3182 return "world 0 -1";
3183}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 3185 of file G4VisCommandsSceneAdd.cc.

3186 {
3187
3188 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
3189 G4bool warn = verbosity >= G4VisManager::warnings;
3190
3191 G4Scene* pScene = fpVisManager->GetCurrentScene();
3192 if (!pScene) {
3193 if (verbosity >= G4VisManager::errors) {
3194 G4warn << "ERROR: No current scene. Please create one." << G4endl;
3195 }
3196 return;
3197 }
3198
3199 G4String name, clipVolumeType, parameterUnit;
3200 G4int copyNo, requestedDepthOfDescent;
3201 G4double param1, param2, param3, param4, param5, param6;
3202 std::istringstream is (newValue);
3203 is >> name >> copyNo >> requestedDepthOfDescent
3204 >> clipVolumeType >> parameterUnit
3205 >> param1 >> param2 >> param3 >> param4 >> param5 >> param6;
3207 G4PhysicalVolumeModel::subtraction; // Default subtraction mode.
3208 if (clipVolumeType[size_t(0)] == '-') {
3209 clipVolumeType = clipVolumeType.substr(1); // Remove first character.
3210 } else if (clipVolumeType[size_t(0)] == '*') {
3212 clipVolumeType = clipVolumeType.substr(1);
3213 }
3214 G4double unit = G4UIcommand::ValueOf(parameterUnit);
3215 param1 *= unit; param2 *= unit; param3 *= unit;
3216 param4 *= unit; param5 *= unit; param6 *= unit;
3217
3218 G4VSolid* clippingSolid = nullptr;
3219 if (clipVolumeType == "box") {
3220 const G4double dX = (param2 - param1) / 2.;
3221 const G4double dY = (param4 - param3) / 2.;
3222 const G4double dZ = (param6 - param5) / 2.;
3223 const G4double x0 = (param2 + param1) / 2.;
3224 const G4double y0 = (param4 + param3) / 2.;
3225 const G4double z0 = (param6 + param5) / 2.;
3226 clippingSolid = new G4DisplacedSolid
3227 ("_displaced_clipping_box",
3228 new G4Box("_clipping_box",dX,dY,dZ),
3229 G4Translate3D(x0,y0,z0));
3230 }
3231
3232 G4TransportationManager* transportationManager =
3234
3235 size_t nWorlds = transportationManager->GetNoWorlds();
3236 if (nWorlds > 1) { // Parallel worlds in operation...
3237 if (verbosity >= G4VisManager::warnings) {
3238 static G4bool warned = false;
3239 if (!warned && name != "worlds") {
3240 G4warn <<
3241 "WARNING: Parallel worlds in operation. To visualise, specify"
3242 "\n \"worlds\" or the parallel world volume or sub-volume name"
3243 "\n and control visibility with /vis/geometry."
3244 << G4endl;
3245 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
3246 transportationManager->GetWorldsIterator();
3247 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
3248 G4warn << " World " << i << ": " << (*iterWorld)->GetName()
3249 << G4endl;
3250 warned = true;
3251 }
3252 }
3253 }
3254 }
3255
3256 // Get the world (the initial value of the iterator points to the mass world).
3257 G4VPhysicalVolume* world = *(transportationManager->GetWorldsIterator());
3258
3259 if (!world) {
3260 if (verbosity >= G4VisManager::errors) {
3261 G4warn <<
3262 "ERROR: G4VisCommandSceneAddVolume::SetNewValue:"
3263 "\n No world. Maybe the geometry has not yet been defined."
3264 "\n Try \"/run/initialize\""
3265 << G4endl;
3266 }
3267 return;
3268 }
3269
3270 std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
3271
3272 // When it comes to determining the extent of a physical volume we normally
3273 // assume the user wishes to ignore "invisible" volumes. For example, most
3274 // users make the world volume invisible. So we ask the physical volume
3275 // model to traverse the geometry hierarchy, starting at the named physical
3276 // volume, until it finds non-invisible ones, whose extents are accumulated
3277 // to determine the overall extent. (Once a non-invisible volume is found,
3278 // the search is curtailed - daughters are always contained within the mother
3279 // so they have no subsequent influence on the extent of the mother - but the
3280 // search continues at the same level until all highest level non-invisible
3281 // volumes are found an their extents accumulated.) So the default is
3282 G4bool useFullExtent = false;
3283 // However, the above procedure can be time consuming in some situations, such
3284 // as a nested parameterisation whose ultimate volumes are the first non-
3285 // visible ones, which are typical of a medical "phantom". So we assume here
3286 // below that if a user specifies a name other than "world" or "worlds" he/she
3287 // wished the extent to be determined by the volume, whether it is visible
3288 // or not. So we set useFullExtent true at that point below.
3289
3290 if (name == "world") {
3291
3292 findingsVector.push_back
3293 (G4PhysicalVolumesSearchScene::Findings(world,world));
3294
3295 } else if (name == "worlds") {
3296
3297 if (nWorlds <= 1) {
3298 if (verbosity >= G4VisManager::warnings) {
3299 G4warn <<
3300 "WARNING: G4VisCommandSceneAddVolume::SetNewValue:"
3301 "\n Parallel worlds requested but none exist."
3302 "\n Just adding material world."
3303 << G4endl;
3304 }
3305 }
3306 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
3307 transportationManager->GetWorldsIterator();
3308 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
3309 findingsVector.push_back
3310 (G4PhysicalVolumesSearchScene::Findings
3311 (*iterWorld,*iterWorld));
3312 }
3313
3314 } else { // Search all worlds...
3315
3316 // Use the model's full extent. This assumes the user wants these
3317 // volumes in the findings vector (there could be more than one) to
3318 // determine the scene's extent. Otherwise G4PhysicalVolumeModel would
3319 // re-calculate each volume's extent based on visibility, etc., which
3320 // could be time consuming.
3321 useFullExtent = true;
3322
3323 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
3324 transportationManager->GetWorldsIterator();
3325 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
3326 G4ModelingParameters mp; // Default - no culling.
3327 G4PhysicalVolumeModel searchModel
3328 (*iterWorld,
3329 requestedDepthOfDescent,
3330 G4Transform3D(),
3331 &mp,
3332 useFullExtent);
3333 G4PhysicalVolumesSearchScene searchScene(&searchModel, name, copyNo);
3334 searchModel.DescribeYourselfTo (searchScene); // Initiate search.
3335 for (const auto& findings: searchScene.GetFindings()) {
3336 findingsVector.push_back(findings);
3337 }
3338 }
3339 }
3340
3341 for (const auto& findings: findingsVector) {
3342 // Set copy number from search findings for replicas and parameterisations.
3343 findings.fpFoundPV->SetCopyNo(findings.fFoundPVCopyNo);
3344 G4PhysicalVolumeModel* foundPVModel = new G4PhysicalVolumeModel
3345 (findings.fpFoundPV,
3346 requestedDepthOfDescent,
3347 findings.fFoundObjectTransformation,
3348 0, // No modelling parameters (these are set later by the scene handler).
3349 useFullExtent,
3350 findings.fFoundBasePVPath);
3351 if (clippingSolid) {
3352 foundPVModel->SetClippingSolid(clippingSolid);
3353 foundPVModel->SetClippingMode(clippingMode);
3354 }
3355 if (!foundPVModel->Validate(warn)) return;
3356 // ...so add it to the scene.
3357 G4bool successful = pScene->AddRunDurationModel(foundPVModel,warn);
3358 if (successful) {
3359 if (verbosity >= G4VisManager::confirmations) {
3360 G4cout << "\"" << findings.fpFoundPV->GetName()
3361 << "\", copy no. " << findings.fFoundPVCopyNo
3362 << ",\n found in searched volume \""
3363 << findings.fpSearchPV->GetName()
3364 << "\" at depth " << findings.fFoundDepth
3365 << ",\n base path: \"" << findings.fFoundBasePVPath
3366 << "\",\n with a requested depth of further descent of ";
3367 if (requestedDepthOfDescent < 0) {
3368 G4cout << "<0 (unlimited)";
3369 }
3370 else {
3371 G4cout << requestedDepthOfDescent;
3372 }
3373 G4cout << ",\n has been added to scene \"" << pScene->GetName() << "\"."
3374 << G4endl;
3375 }
3376 } else {
3378 }
3379 }
3380
3381 if (findingsVector.empty()) {
3382 if (verbosity >= G4VisManager::errors) {
3383 G4warn << "ERROR: Volume \"" << name << "\"";
3384 if (copyNo >= 0) {
3385 G4warn << ", copy no. " << copyNo << ",";
3386 }
3387 G4warn << " not found." << G4endl;
3388 }
3390 return;
3391 }
3392
3394}
#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
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
const char * name(G4int ptype)

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