val->setVarname(_fast_pos,_var_name);
}
-void LeafExprVar::prepareExprEvaluation(const std::vector<std::string>& vars) const throw(INTERP_KERNEL::Exception)
+void LeafExprVar::prepareExprEvaluation(const std::vector<std::string>& vars, int nbOfCompo, int targetNbOfCompo) const throw(INTERP_KERNEL::Exception)
{
std::vector<std::string>::const_iterator iter=std::find(vars.begin(),vars.end(),_var_name);
if(iter==vars.end())
std::copy(vars.begin(),vars.end(),std::ostream_iterator<std::string>(oss,", "));
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- return;
+ else
+ {
+ int relPos=-7-_fast_pos;
+ if(relPos>=targetNbOfCompo)
+ {
+ std::ostringstream oss; oss << "LeafExprVar::prepareExprEvaluation : Found recognized unitary vector \"" << _var_name << "\" which implies that component #" << relPos;
+ oss << " exists, but it is not the case component id should be in [0," << targetNbOfCompo << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ else
+ return;
+ }
}
_fast_pos=(int)std::distance(vars.begin(),iter);
+ if(_fast_pos>=nbOfCompo)
+ {
+ std::ostringstream oss; oss << "LeafExprVar::prepareExprEvaluation : Found var \"" << _var_name << "\" on place " << _fast_pos << " whereas only must be in [0," << nbOfCompo << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
}
void LeafExprVar::prepareExprEvaluationVec() const throw(INTERP_KERNEL::Exception)
delete res;
}
-void ExprParser::prepareExprEvaluation(const std::vector<std::string>& vars) const throw(INTERP_KERNEL::Exception)
+void ExprParser::prepareExprEvaluation(const std::vector<std::string>& vars, int nbOfCompo, int targetNbOfCompo) const throw(INTERP_KERNEL::Exception)
{
if(_leaf)
{
LeafExprVar *leafC=dynamic_cast<LeafExprVar *>(_leaf);
if(leafC)
- leafC->prepareExprEvaluation(vars);
+ leafC->prepareExprEvaluation(vars,nbOfCompo,targetNbOfCompo);
}
else
for(std::list<ExprParser>::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++)
- (*iter).prepareExprEvaluation(vars);
+ (*iter).prepareExprEvaluation(vars,nbOfCompo,targetNbOfCompo);
}
void ExprParser::prepareExprEvaluationVec() const throw(INTERP_KERNEL::Exception)
void compileX86_64(std::vector<std::string>& ass) const;
void fillValue(Value *val) const throw(INTERP_KERNEL::Exception);
std::string getVar() const { return _var_name; }
- void prepareExprEvaluation(const std::vector<std::string>& vars) const throw(INTERP_KERNEL::Exception);
+ void prepareExprEvaluation(const std::vector<std::string>& vars, int nbOfCompo, int targetNbOfCompo) const throw(INTERP_KERNEL::Exception);
void prepareExprEvaluationVec() const throw(INTERP_KERNEL::Exception);
void replaceValues(const std::vector<double>& valuesInExpr) throw(INTERP_KERNEL::Exception);
static bool isRecognizedKeyVar(const std::string& var, int& pos);
bool isParsingSuccessfull() const { return _is_parsing_ok; }
double evaluate() const throw(INTERP_KERNEL::Exception);
DecompositionInUnitBase evaluateUnit() const throw(INTERP_KERNEL::Exception);
- void prepareExprEvaluation(const std::vector<std::string>& vars) const throw(INTERP_KERNEL::Exception);
+ void prepareExprEvaluation(const std::vector<std::string>& vars, int nbOfCompo, int targetNbOfCompo) const throw(INTERP_KERNEL::Exception);
void evaluateExpr(int szOfOutParam, const double *inParam, double *outParam) const throw(INTERP_KERNEL::Exception);
void prepareExprEvaluationVec() const throw(INTERP_KERNEL::Exception);
void getSetOfVars(std::set<std::string>& vars) const;
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
std::vector<std::string> varsV(vars.begin(),vars.end());
- expr.prepareExprEvaluation(varsV);
+ expr.prepareExprEvaluation(varsV,oldNbOfComp,nbOfComp);
//
DataArrayDouble *newArr=DataArrayDouble::New();
int nbOfTuples=getNumberOfTuples();
std::copy(vars.begin(),vars.end(),std::ostream_iterator<std::string>(oss," "));
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- expr.prepareExprEvaluation(getVarsOnComponent());
+ expr.prepareExprEvaluation(getVarsOnComponent(),oldNbOfComp,nbOfComp);
//
DataArrayDouble *newArr=DataArrayDouble::New();
int nbOfTuples=getNumberOfTuples();
std::copy(vars.begin(),vars.end(),std::ostream_iterator<std::string>(oss," "));
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- expr.prepareExprEvaluation(varsOrder);
+ expr.prepareExprEvaluation(varsOrder,oldNbOfComp,nbOfComp);
//
DataArrayDouble *newArr=DataArrayDouble::New();
int nbOfTuples=getNumberOfTuples();
e->setCoordsAt(0,d);
MEDCouplingUMesh *f=e->buildUnstructured();
DataArrayDouble *g=f->getCoords()->applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
+ CPPUNIT_ASSERT_THROW(f->getCoords()->applyFunc(2,"3.5*IVec+x/6*3.14159265359*KVec"),INTERP_KERNEL::Exception); // KVec refers to component #2 and there is only 2 components !
DataArrayDouble *h=g->fromPolarToCart();
f->setCoords(h);
MEDCouplingUMesh *i=c->buildExtrudedMesh(f,1);
for(int i=0;i<5;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-12);
da2->decrRef();
+ std::vector<std::string> vs2(4); vs2[0]="x"; vs2[1]="y"; vs2[2]="z"; vs2[3]="a";
+ CPPUNIT_ASSERT_THROW(da->applyFunc3(1,vs2,"x+a"),INTERP_KERNEL::Exception);
f1->setArray(da);
CPPUNIT_ASSERT_EQUAL(3,f1->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
e.setCoordsAt(0,d);
f=e.buildUnstructured();
g=f.getCoords().applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
+ self.assertRaises(InterpKernelException,f.getCoords().applyFunc,2,"3.5*IVec+x/6*3.14159265359*KVec"); # KVec refers to component #2 and there is only 2 components !
h=g.fromPolarToCart();
f.setCoords(h);
i=c.buildExtrudedMesh(f,1);
for i in xrange(5):
self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),12);
pass
+ self.assertRaises(InterpKernelException, da.applyFunc3, 1, ["x","y","z","a"],"x+a")
f1.setArray(da);
self.assertEqual(3,f1.getNumberOfComponents());
self.assertEqual(5,f1.getNumberOfTuples());