60 G4String error_msg =
"Redefinition of constant or variable: "+
name;
61 G4Exception(
"G4GDMLEvaluator::DefineConstant()",
"InvalidExpression",
71 G4String error_msg =
"Redefinition of constant or variable: "+
name;
72 G4Exception(
"G4GDMLEvaluator::DefineVariable()",
"InvalidExpression",
81 std::vector<G4double> valueList)
83 const G4int size = valueList.size();
87 G4String error_msg =
"Matrix '"+name+
"' is empty!";
88 G4Exception(
"G4GDMLEvaluator::DefineMatrix()",
"InvalidSize",
102 if (size % coldim != 0)
104 G4String error_msg =
"Matrix '" + name +
"' is not filled correctly!";
105 G4Exception(
"G4GDMLEvaluator::DefineMatrix()",
"InvalidSize",
109 if ((size == coldim) || (coldim == 1))
111 for (
G4int i=0;i<size;i++)
113 std::stringstream MatrixElementNameStream;
114 MatrixElementNameStream << name <<
"_" << i;
120 const G4int rowdim = size/coldim;
122 for (
G4int i=0;i<rowdim;i++)
124 for (
G4int j=0;j<coldim;j++)
126 std::stringstream MatrixElementNameStream;
127 MatrixElementNameStream << name <<
"_" << i <<
"_" << j;
128 DefineConstant(MatrixElementNameStream.str(),valueList[coldim*i+j]);
138 G4String error_msg =
"Variable '" + name +
"' is not defined!";
139 G4Exception(
"G4GDMLEvaluator::SetVariable()",
"InvalidSetup",
149 for (
size_t i=0;i<variableCount;i++)
159 std::string::size_type full = in.size();
160 std::string::size_type
open = in.find(
"[",0);
161 std::string::size_type
close = in.find(
"]",0);
163 if (open==close) {
return in; }
165 if ((open>close) || (open==std::string::npos) || (close==std::string::npos))
167 G4String error_msg =
"Bracket mismatch: " +
in;
168 G4Exception(
"G4GDMLEvaluator::SolveBrackets()",
"InvalidExpression",
173 std::string::size_type begin =
open;
174 std::string::size_type end = 0;
175 std::string::size_type end1 = 0;
177 out.append(in,0,open);
183 end = in.find(
",",begin+1);
184 end1= in.find(
"]",begin+1);
185 if (end>end1) { end = end1; }
186 if (end==std::string::npos) { end =
close;}
188 std::stringstream indexStream;
189 indexStream <<
"_" <<
EvaluateInteger(in.substr(begin+1,end-begin-1))-1;
191 out.append(indexStream.str());
197 if (full==close) {
return out; }
199 open = in.find(
"[",begin);
200 close = in.find(
"]",begin+1);
202 if (open==close) { out.
append(in.substr(end+1,full-end-1));
return out; }
203 out.
append(in.substr(end+1,open-end-1));
207 }
while (close<full);
218 if (!expression.empty())
225 G4String error_msg =
"Error in expression: " + expression;
226 G4Exception(
"G4GDMLEvaluator::Evaluate()",
"InvalidExpression",
247 G4String error_msg =
"Expression '" + expression
248 +
"' is expected to have an integer value!";
249 G4Exception(
"G4GDMLEvaluator::EvaluateInteger()",
"InvalidExpression",
259 G4String error_msg =
"Constant '" + name
260 +
"' is not defined! It is a variable!";
261 G4Exception(
"G4GDMLEvaluator::GetConstant()",
"InvalidSetup",
266 G4String error_msg =
"Constant '" + name +
"' is not defined!";
267 G4Exception(
"G4GDMLEvaluator::GetConstant()",
"InvalidSetup",
277 G4String error_msg =
"Variable '" + name +
"' is not a defined!";
278 G4Exception(
"G4GDMLEvaluator::GetVariable()",
"InvalidSetup",
286 std::ostringstream os;
294 std::ostringstream os;