int getCellContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception)
{
- int sz;
- INTERP_KERNEL::AutoPtr<double> pos=convertPyToNewDblArr2(p,&sz);
+ double val;
+ DataArrayDouble *a;
+ DataArrayDoubleTuple *aa;
+ std::vector<double> bb;
+ int sw;
+ int spaceDim=self->getSpaceDimension();
+ const char msg[]="Python wrap of MEDCouplingUMesh::getCellContainingPoint : ";
+ const double *pos=convertObjToPossibleCpp5_Safe(p,sw,val,a,aa,bb,msg,1,spaceDim,true);
return self->getCellContainingPoint(pos,eps);
}
PyObject *getCellsContainingPoints(PyObject *p, int nbOfPoints, double eps) const throw(INTERP_KERNEL::Exception)
{
- int sz;
- INTERP_KERNEL::AutoPtr<double> pos=convertPyToNewDblArr2(p,&sz);
+ double val;
+ DataArrayDouble *a;
+ DataArrayDoubleTuple *aa;
+ std::vector<double> bb;
+ int sw;
+ int spaceDim=self->getSpaceDimension();
+ const char msg[]="Python wrap of MEDCouplingUMesh::getCellContainingPoint : ";
+ const double *pos=convertObjToPossibleCpp5_Safe(p,sw,val,a,aa,bb,msg,nbOfPoints,spaceDim,true);
std::vector<int> elts,eltsIndex;
self->getCellsContainingPoints(pos,nbOfPoints,eps,elts,eltsIndex);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
void translate(PyObject *vector) throw(INTERP_KERNEL::Exception)
{
- int sz;
- INTERP_KERNEL::AutoPtr<double> v=convertPyToNewDblArr2(vector,&sz);
- if(sz!=self->getSpaceDimension())
- {
- std::ostringstream oss; oss << "Python wrap of MEDCouplingPointSet::translate : the space dimension is " << self->getSpaceDimension() << " and the input array size is " << sz;
- oss << " ! The size of the input list or tuple must be equal to " << self->getSpaceDimension() << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- self->translate(v);
+ double val;
+ DataArrayDouble *a;
+ DataArrayDoubleTuple *aa;
+ std::vector<double> bb;
+ int sw;
+ int spaceDim=self->getSpaceDimension();
+ const char msg[]="Python wrap of MEDCouplingPointSet::translate : ";
+ const double *vectorPtr=convertObjToPossibleCpp5_Safe(vector,sw,val,a,aa,bb,msg,1,spaceDim,true);
+ self->translate(vectorPtr);
+ }
+
+ void rotate(PyObject *center, double alpha) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Python wrap of MEDCouplingPointSet::rotate : ";
+ double val;
+ DataArrayDouble *a;
+ DataArrayDoubleTuple *aa;
+ std::vector<double> bb;
+ int sw;
+ int spaceDim=self->getSpaceDimension();
+ const double *centerPtr=convertObjToPossibleCpp5_Safe(center,sw,val,a,aa,bb,msg,1,spaceDim,true);
+ self->rotate(centerPtr,0,alpha);
}
void rotate(PyObject *center, PyObject *vector, double alpha) throw(INTERP_KERNEL::Exception)
{
- int sz;
- INTERP_KERNEL::AutoPtr<double> c=convertPyToNewDblArr2(center,&sz);
- if(!c)
- return ;
- INTERP_KERNEL::AutoPtr<double> v=convertPyToNewDblArr2(vector,&sz);
- if(!v)
- { return ; }
- self->rotate(c,v,alpha);
+ const char msg[]="Python wrap of MEDCouplingPointSet::rotate : ";
+ double val;
+ DataArrayDouble *a;
+ DataArrayDoubleTuple *aa;
+ std::vector<double> bb;
+ int sw;
+ int spaceDim=self->getSpaceDimension();
+ const double *centerPtr=convertObjToPossibleCpp5_Safe(center,sw,val,a,aa,bb,msg,1,spaceDim,true);
+ const double *vectorPtr=convertObjToPossibleCpp5_Safe(vector,sw,val,a,aa,bb,msg,1,spaceDim,false);
+ self->rotate(centerPtr,vectorPtr,alpha);
}
PyObject *getAllGeoTypes() const throw(INTERP_KERNEL::Exception)
int sz;
INTERP_KERNEL::AutoPtr<double> orig=convertPyToNewDblArr2(origin,&sz);
if(!orig || sz!=3)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSlice3D : in parameter 1 expecting origin of type list of float of size 3 !");
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSlice3DSurf : in parameter 1 expecting origin of type list of float of size 3 !");
INTERP_KERNEL::AutoPtr<double> vect=convertPyToNewDblArr2(vec,&sz);
if(!vec || sz!=3)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSlice3D : in parameter 2 expecting vector of type list of float of size 3 !");
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSlice3DSurf : in parameter 2 expecting vector of type list of float of size 3 !");
DataArrayInt *cellIds=0;
MEDCouplingUMesh *ret0=self->buildSlice3DSurf(orig,vect,eps,cellIds);
PyObject *ret=PyTuple_New(2);
#2D with no help of bounding box.
center=[0.2,0.2]
MEDCouplingPointSet.Rotate2DAlg(center,0.78539816339744830962,6,pos);
- targetMesh.rotate(center,[],0.78539816339744830962);
+ targetMesh.rotate(center,0.78539816339744830962);
t1=None
t2=None
t1,t2=targetMesh.getCellsContainingPoints(pos,6,1e-12);
f.changeSpaceDimension(2);
#
center=[0.,0.]
- f.rotate(center,[],pi/3);
+ f.rotate(center,None,pi/3);
g=c.buildExtrudedMesh(f,0);
g.checkCoherency();
expected1=[ 0.4330127018922193, 0.4330127018922193, 0.649519052838329, 1.2990381056766578, 1.299038105676658, 1.948557158514987, 2.1650635094610955, 2.1650635094610964, 3.2475952641916446, 3.031088913245533, 3.0310889132455352, 4.546633369868303 ]
}
throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
}
+
+/*!
+ * if value int -> cpp val sw=1
+ * if value double -> cpp val sw=1
+ * if value DataArrayDouble -> cpp DataArrayDouble sw=2
+ * if value DataArrayDoubleTuple -> cpp DataArrayDoubleTuple sw=3
+ * if value list[int,double] -> cpp std::vector<double> sw=4
+ * if value tuple[int,double] -> cpp std::vector<double> sw=4
+ */
+static const double *convertObjToPossibleCpp5_Safe(PyObject *value, int& sw, double& val, ParaMEDMEM::DataArrayDouble *&d, ParaMEDMEM::DataArrayDoubleTuple *&e, std::vector<double>& f,
+ const char *msg, int nbTuplesExpected, int nbCompExpected, bool throwIfNullPt) throw(INTERP_KERNEL::Exception)
+{
+ sw=-1;
+ if(PyFloat_Check(value))
+ {
+ val=PyFloat_AS_DOUBLE(value);
+ sw=1;
+ if(nbTuplesExpected*nbCompExpected!=1)
+ {
+ std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyFloat) !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return &val;
+ }
+ if(PyInt_Check(value))
+ {
+ val=(double)PyInt_AS_LONG(value);
+ sw=1;
+ if(nbTuplesExpected*nbCompExpected!=1)
+ {
+ std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyInt) !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return &val;
+ }
+ if(PyTuple_Check(value))
+ {
+ int size=PyTuple_Size(value);
+ f.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(value,i);
+ if(PyFloat_Check(o))
+ f[i]=PyFloat_AS_DOUBLE(o);
+ else if(PyInt_Check(o))
+ f[i]=(double)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=4;
+ if(nbTuplesExpected*nbCompExpected!=(int)f.size())
+ {
+ std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension " << f.size() << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return &f[0];
+ }
+ if(PyList_Check(value))
+ {
+ int size=PyList_Size(value);
+ f.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyList_GetItem(value,i);
+ if(PyFloat_Check(o))
+ f[i]=PyFloat_AS_DOUBLE(o);
+ else if(PyInt_Check(o))
+ f[i]=(double)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=4;
+ if(nbTuplesExpected*nbCompExpected!=(int)f.size())
+ {
+ std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension " << f.size() << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return &f[0];
+ }
+ void *argp;
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+ if(SWIG_IsOK(status))
+ {
+ d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
+ sw=2;
+ if(d)
+ {
+ if(d->getNumberOfTuples()==nbTuplesExpected)
+ {
+ if(d->getNumberOfComponents()==nbCompExpected)
+ {
+ return d->getConstPointer();
+ }
+ else
+ {
+ std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input has " << d->getNumberOfComponents() << " components !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ else
+ {
+ std::ostringstream oss; oss << msg << " input DataArrayDouble should have a number of tuples equal to " << nbTuplesExpected << " and there are " << d->getNumberOfTuples() << " tuples !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ else
+ {
+ if(throwIfNullPt)
+ {
+ std::ostringstream oss; oss << msg << " null pointer not accepted!";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ else
+ return 0;
+ }
+ }
+ status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0);
+ if(SWIG_IsOK(status))
+ {
+ e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp);
+ sw=3;
+ if(e->getNumberOfCompo()==nbCompExpected)
+ {
+ if(nbTuplesExpected==1)
+ return e->getConstPointer();
+ else
+ {
+ std::ostringstream oss; oss << msg << "nb of tuples expected to be " << nbTuplesExpected << " , and input DataArrayDoubleTuple has always one tuple by contruction !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ else
+ {
+ std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");
+}