Geant4 11.1.1
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 ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool operator!= (const G4UImessenger &messenger) const
 
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 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
 

Detailed Description

Definition at line 479 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneAddVolume()

G4VisCommandSceneAddVolume::G4VisCommandSceneAddVolume ( )

Definition at line 3031 of file G4VisCommandsSceneAdd.cc.

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

◆ ~G4VisCommandSceneAddVolume()

G4VisCommandSceneAddVolume::~G4VisCommandSceneAddVolume ( )
virtual

Definition at line 3108 of file G4VisCommandsSceneAdd.cc.

3108 {
3109 delete fpCommand;
3110}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneAddVolume::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 3112 of file G4VisCommandsSceneAdd.cc.

3112 {
3113 return "world 0 -1";
3114}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 3116 of file G4VisCommandsSceneAdd.cc.

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