1018 if (!currentViewer) {
1021 "ERROR: G4VisCommandViewerInterpolate::SetNewValue: no current viewer."
1028 G4int nInterpolationPoints;
1033 std::istringstream iss (newValue);
1036 >> nInterpolationPoints
1037 >> waitTimePerPointString
1040 G4String waitTimePerPointDimString(waitTimePerPointString +
' ' + timeUnit);
1044 if (waitTimePerPointmilliseconds < 0) waitTimePerPointmilliseconds = 0;
1066 std::vector<G4ViewParameters> viewVector;
1068 const G4int safety = 9999;
1069 G4int safetyCount = 0;
1075 G4String shellCommand =
"echo " + pattern;
1076 FILE *filelist = popen(shellCommand.c_str(),
"r");
1080 <<
"ERROR: G4VisCommandViewerInterpolate::SetNewValue:"
1081 <<
"\n Error obtaining pipe."
1088 const size_t BUFLENGTH = 999999;
1089 char buf[BUFLENGTH];
1090 fgets(buf, BUFLENGTH, filelist);
1091 std::istringstream fileliststream(buf);
1092 while (fileliststream >> pathname
1093 && safetyCount++ < safety) {
1094 uiManager->
ApplyCommand(
"/control/execute " + pathname);
1099 #else // WIN32 (popen is not available in Windows)
1101 std::experimental::filesystem::v1::path filePattern(pattern);
1106 std::string regexp_pattern(
"^" + filePattern.filename().string());
1107 std::string result_pattern =
"";
1109 size_t currentPos = 0;
1111 std::string currentReplacement =
"";
1112 size_t pos1 = regexp_pattern.find(
'.', nextPos);
1113 size_t pos2 = regexp_pattern.find(
'*', nextPos);
1114 size_t pos3 = regexp_pattern.find(
'?', nextPos);
1115 while ((pos1 != std::string::npos) || (pos2 != std::string::npos) || (pos3 != std::string::npos)) {
1117 currentReplacement =
"\\.";
1118 if (pos2 < nextPos) {
1120 currentReplacement =
".*";
1122 if (pos3 < nextPos) {
1124 currentReplacement =
"(.{1,1})";
1126 result_pattern += regexp_pattern.substr(currentPos, nextPos - currentPos) + currentReplacement;
1128 currentPos = nextPos;
1129 pos1 = regexp_pattern.find(
'.', currentPos);
1130 pos2 = regexp_pattern.find(
'*', currentPos);
1131 pos3 = regexp_pattern.find(
'?', currentPos);
1133 result_pattern += regexp_pattern.substr(currentPos);
1137 G4String parentPath(filePattern.parent_path().string().length() ? filePattern.parent_path().string() : std::string(
"./"));
1139 std::regex result_pattern_regex (result_pattern, std::regex_constants::basic | std::regex_constants::icase);
1140 for (
auto iter = std::experimental::filesystem::v1::directory_iterator(parentPath);
1141 iter != std::experimental::filesystem::v1::directory_iterator() && safetyCount++ < safety;
1144 const auto& file = iter->path();
1146 G4String filename(file.filename().string());
1147 if (std::regex_match(filename, result_pattern_regex))
1149 uiManager->
ApplyCommand(
"/control/execute " + filename);
1156 if (safetyCount >= safety) {
1159 "/vis/viewer/interpolate:"
1160 "\n the number of way points exceeds the maximum currently allowed: "
1176 if (exportString ==
"export" &&
1179 #ifdef G4VIS_USE_STD11
1180 if (waitTimePerPointmilliseconds > 0)
1181 std::this_thread::sleep_for(std::chrono::milliseconds(waitTimePerPointmilliseconds));
1183 }
while (safetyCount++ < safety);
1193 G4cout <<
"Viewer \"" << currentViewer -> GetName () <<
"\""
1194 <<
" restored." <<
G4endl;
const G4String & GetName() const
void SetVerboseLevel(G4int)
const G4ViewParameters & GetViewParameters() const
void SetViewParameters(const G4ViewParameters &vp)
G4int GetVerboseLevel() const
static G4double ConvertToDimensionedDouble(const char *st)
void SetVerboseLevel(G4int val)
static G4UImanager * GetUIpointer()
G4GLOB_DLL std::ostream G4cout
G4bool contains(const std::string &) const
void SetAutoRefresh(G4bool)
static constexpr double millisecond
static Verbosity GetVerbosity()
G4VViewer * GetCurrentViewer() const
static G4ViewParameters * CatmullRomCubicSplineInterpolation(const std::vector< G4ViewParameters > &views, G4int nInterpolationPoints=50)
G4bool IsAutoRefresh() const
G4int ApplyCommand(const char *aCommand)
G4GLOB_DLL std::ostream G4cerr
static G4VisManager * fpVisManager