%ignore ParaMEDMEM::DataArrayDoubleIterator::nextt;
%ignore ParaMEDMEM::DataArrayDoubleTuple::next;
%ignore ParaMEDMEM::DataArrayDoubleTuple::repr;
+%ignore ParaMEDMEM::DataArrayDouble::writeVTK;
+%ignore ParaMEDMEM::DataArrayInt::writeVTK;
+%ignore ParaMEDMEM::DataArrayDouble::SetArrayIn;
+%ignore ParaMEDMEM::DataArrayInt::SetArrayIn;
%nodefaultctor;
INTERP_KERNEL::AutoPtr<double> pos=convertPyToNewDblArr2(p,&sz);
std::vector<int> elts;
self->getCellsContainingPoint(pos,eps,elts);
- return convertIntArrToPyList2(elts);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc((int)elts.size(),1);
+ std::copy(elts.begin(),elts.end(),ret->getPointer());
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
}
void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception)
{
std::vector<int> nodes;
self->findBoundaryNodes(nodes);
- return convertIntArrToPyList2(nodes);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc((int)nodes.size(),1);
+ std::copy(nodes.begin(),nodes.end(),ret->getPointer());
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
}
void renumberNodes(PyObject *li, int newNbOfNodes) throw(INTERP_KERNEL::Exception)
{
self->findNodesOnLine(p,v,eps,nodes);
delete [] v;
delete [] p;
- return convertIntArrToPyList2(nodes);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc((int)nodes.size(),1);
+ std::copy(nodes.begin(),nodes.end(),ret->getPointer());
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
}
PyObject *findNodesOnPlane(PyObject *pt, PyObject *vec, double eps) const throw(INTERP_KERNEL::Exception)
{
self->findNodesOnPlane(p,v,eps,nodes);
delete [] v;
delete [] p;
- return convertIntArrToPyList2(nodes);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc((int)nodes.size(),1);
+ std::copy(nodes.begin(),nodes.end(),ret->getPointer());
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
}
PyObject *getNodeIdsNearPoint(PyObject *pt, double eps) const throw(INTERP_KERNEL::Exception)
{
if(size<self->getSpaceDimension())
throw INTERP_KERNEL::Exception("getNodeIdsNearPoint : to tiny array ! must be at least of size SpaceDim !");
std::vector<int> tmp=self->getNodeIdsNearPoint(pos,eps);
- return convertIntArrToPyList2(tmp);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc((int)tmp.size(),1);
+ std::copy(tmp.begin(),tmp.end(),ret->getPointer());
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
}
PyObject *getNodeIdsNearPoints(PyObject *pt, int nbOfNodes, double eps) const throw(INTERP_KERNEL::Exception)
double *tmp=convertPyToNewDblArr2(bbox,&size);
self->getCellsInBoundingBox(tmp,eps,elems);
delete [] tmp;
- return convertIntArrToPyList2(elems);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc((int)elems.size(),1);
+ std::copy(elems.begin(),elems.end(),ret->getPointer());
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
}
static void Rotate2DAlg(PyObject *center, double angle, int nbNodes, PyObject *coords) throw(INTERP_KERNEL::Exception)
{
std::vector<int> cells;
self->checkButterflyCells(cells);
- return convertIntArrToPyList2(cells);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc((int)cells.size(),1);
+ std::copy(cells.begin(),cells.end(),ret->getPointer());
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
}
PyObject *splitByType() const throw(INTERP_KERNEL::Exception)
throw e;
}
delete [] v;
- return convertIntArrToPyList2(cells);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc((int)cells.size(),1);
+ std::copy(cells.begin(),cells.end(),ret->getPointer());
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
}
void orientCorrectly2DCells(PyObject *vec, bool polyOnly) throw(INTERP_KERNEL::Exception)
{
std::vector<int> cells;
self->arePolyhedronsNotCorrectlyOriented(cells);
- return convertIntArrToPyList2(cells);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc((int)cells.size(),1);
+ std::copy(cells.begin(),cells.end(),ret->getPointer());
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
}
PyObject *findAndCorrectBadOriented3DExtrudedCells() throw(INTERP_KERNEL::Exception)
{
std::vector<int> cells;
self->findAndCorrectBadOriented3DExtrudedCells(cells);
- return convertIntArrToPyList2(cells);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc((int)cells.size(),1);
+ std::copy(cells.begin(),cells.end(),ret->getPointer());
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
}
PyObject *getFastAveragePlaneOfThis() const throw(INTERP_KERNEL::Exception)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getCellIdsCrossingPlane : in parameter 2 expecting vector of type list of float of size 3 !");
return self->getCellIdsCrossingPlane(orig,vect,eps);
}
+
+ void convertToPolyTypes(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ int sw;
+ int pos1;
+ std::vector<int> pos2;
+ DataArrayInt *pos3=0;
+ convertObjToPossibleCpp1(li,sw,pos1,pos2,pos3);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->convertToPolyTypes(&pos1,&pos1+1);
+ return;
+ }
+ case 2:
+ {
+ if(pos2.empty())
+ return;
+ self->convertToPolyTypes(&pos2[0],&pos2[0]+pos2.size());
+ return ;
+ }
+ case 3:
+ {
+ self->convertToPolyTypes(pos3->begin(),pos3->end());
+ return ;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertToPolyTypes : unexpected input array type recognized !");
+ }
+ }
}
- void convertToPolyTypes(const std::vector<int>& cellIdsToConvert) throw(INTERP_KERNEL::Exception);
void convertAllToPoly();
void convertExtrudedPolyhedra() throw(INTERP_KERNEL::Exception);
void unPolyze() throw(INTERP_KERNEL::Exception);
return self->repr();
}
+ int __len__() const throw(INTERP_KERNEL::Exception)
+ {
+ if(self->isAllocated())
+ {
+ if(self->getNumberOfComponents()==1)
+ return self->getNumberOfTuples();
+ throw INTERP_KERNEL::Exception("DataArrayInt::__len__ : len is not defined here because number of components is not equal to 1 !");
+ }
+ else
+ {
+ throw INTERP_KERNEL::Exception("DataArrayInt::__len__ : Instance is NOT allocated !");
+ }
+ }
+
DataArrayIntIterator *__iter__()
{
return self->iterator();
{
std::vector<int> tmp;
self->getCellIdsHavingGaussLocalization(locId,tmp);
- return convertIntArrToPyList2(tmp);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc((int)tmp.size(),1);
+ std::copy(tmp.begin(),tmp.end(),ret->getPointer());
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
}
}
};
self.assertEqual(targetMesh.getNumberOfNodes(),9)
self.assertEqual(targetMesh.getMeshDimension(),0)
pass
-
+
def testMeshM1D(self):
meshM1D=MEDCouplingUMesh.New();
self.assertRaises(InterpKernelException,meshM1D.getMeshDimension);
self.assertEqual(8,mesh.getNumberOfCells());
self.assertEqual(114,mesh.getNodalConnectivity().getNumberOfTuples());
pass
-
+
def testDescConn2D(self):
mesh=MEDCouplingDataForTest.build2DTargetMesh_1();
desc=DataArrayInt.New();
self.assertEqual(expected5,list(mesh2.getNodalConnectivityIndex().getValues()));
self.assertEqual(expected7,list(mesh2.getNodalConnectivity().getValues()));
pass
-
+
def testFindBoundaryNodes(self):
mesh=MEDCouplingDataForTest.build3DTargetMesh_1();
boundaryNodes=mesh.findBoundaryNodes();
expected1=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26];
- self.assertEqual(expected1,list(boundaryNodes));
+ self.assertEqual(expected1,boundaryNodes.getValues());
pass
-
+
def testBoundaryMesh(self):
mesh=MEDCouplingDataForTest.build3DTargetMesh_1();
mesh2=mesh.buildBoundaryMesh(False);
self.assertEqual(24,mesh2.getNumberOfCells());
self.assertEqual(26,mesh2.getNumberOfNodes());
pass
-
+
def testBuildPartOfMySelf(self):
mesh=MEDCouplingDataForTest.build2DTargetMesh_1();
mesh.setName("Toto");
conn.setIJ(16,0,tmp)
cells=sourceMesh.checkButterflyCells();
self.assertEqual(1,len(cells));
- self.assertEqual(3,cells[0]);
+ self.assertEqual([3],cells.getValues());
tmp=conn.getIJ(15,0)
conn.setIJ(15,0,conn.getIJ(16,0))
conn.setIJ(16,0,tmp)
conn.setIJ(16,0,tmp)
cells=sourceMesh.checkButterflyCells();
self.assertEqual(1,len(cells));
- self.assertEqual(3,cells[0]);
+ self.assertEqual([3],cells.getValues());
tmp=conn.getIJ(15,0)
conn.setIJ(15,0,conn.getIJ(16,0))
conn.setIJ(16,0,tmp)
t1=targetMesh.getCellsContainingPoint(pos2,1e-12)
self.assertEqual(2,len(t1));
expectedValues3=[0,1]
- self.assertEqual(list(t1),expectedValues3);
+ self.assertEqual(list(t1.getValues()),expectedValues3);
pos3=[0.2,0.2]
t1=None
t1=targetMesh.getCellsContainingPoint(pos3,1e-12);
self.assertEqual(5,len(t1));
expectedValues4=[0,1,2,3,4]
- self.assertEqual(list(t1),expectedValues4);
+ self.assertEqual(list(t1.getValues()),expectedValues4);
self.assertEqual(0,targetMesh.getCellContainingPoint(pos3,1e-12));
#3D
targetMesh=MEDCouplingDataForTest.build3DTargetMesh_1();
t1=targetMesh.getCellsContainingPoint(pos5,1e-12);
self.assertEqual(8,len(t1));
expectedValues5=[0,1,2,3,4,5,6,7]
- self.assertEqual(list(t1),expectedValues5);
+ self.assertEqual(list(t1.getValues()),expectedValues5);
pos6=[0., 50., 0.]
t1=None
t1=targetMesh.getCellsContainingPoint(pos6,1e-12);
self.assertEqual(2,len(t1));
expectedValues6=[0,2]
- self.assertEqual(list(t1),expectedValues6);
+ self.assertEqual(list(t1.getValues()),expectedValues6);
#3D outside
pos7=[-1.0,-1.0,0.]
self.assertEqual(-1,targetMesh.getCellContainingPoint(pos7,1e-12));
val=da.getValues();
self.assertEqual(expected,list(val));
#
- ddd=DataArrayInt.New()
- ddd.setValues(n,len(n),1)
- m3dSurf=mesh.buildFacePartOfMySelfNode(ddd,True);
+ m3dSurf=mesh.buildFacePartOfMySelfNode(n,True);
self.assertTrue(isinstance(m3dSurf,MEDCouplingUMesh))
me=MEDCouplingExtrudedMesh.New(mesh,m3dSurf,0);
da=me.getMesh3DIds();
f.setGaussLocalizationOnCells(ids4,_refCoo2,_gsCoo2,_wg2);
self.assertEqual(3,f.getNbOfGaussLocalization());
tmpIds=f.getCellIdsHavingGaussLocalization(0);
- self.assertEqual(ids2,list(tmpIds));
+ self.assertEqual(ids2,list(tmpIds.getValues()));
self.assertRaises(InterpKernelException,f.checkCoherency);#<- it's always not ok because undelying array not with the good size.
array2=f.getArray().substr(0,10);
f.setArray(array2);
m.getNodalConnectivity().setValues(conn,len(conn),1)
res1=m.are2DCellsNotCorrectlyOriented(vec,False);
self.assertEqual(1,len(res1));
- self.assertEqual(2,res1[0]);
+ self.assertEqual(2,res1.getValues()[0]);
m.orientCorrectly2DCells(vec,False);
res1=m.are2DCellsNotCorrectlyOriented(vec,False);
self.assertTrue(len(res1)==0);
self.assertEqual(16,m.getCellContainingPoint(pos1,1e-12));
#
elems=m2.getCellsInBoundingBox([3.5,6.,12.2,25.,0.,1.5],1e-7)
- self.assertEqual([1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17],elems)
+ self.assertEqual([1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17],elems.getValues())
#
pt=[2.4,12.7,-3.4]
m.scale(pt,3.7);
pass
def testElementaryDAThrowAndSpecialCases(self):
- return
da=DataArrayInt.New();
self.assertRaises(InterpKernelException, da.checkAllocated);
self.assertRaises(InterpKernelException, da.fillWithValue, 1);
self.assertEqual(5,db.GetNumberOfItemGivenBES(0,10,2,"theMessageInThrow"));
self.assertEqual(6,db.GetNumberOfItemGivenBES(0,11,2,"theMessageInThrow"));
- #std::cout<<"\n!!!!!!!!!\n"<<dd.repr()<<"\n!!!!!!!!!\n";
self.assertTrue(not ((da.repr().find("Number of components : 1"))==-1));
self.assertTrue(not ((dd.repr().find("Number of components : 1"))==-1));
self.assertTrue(not ((dbl.repr().find("Number of components : 1"))==-1));
self.assertTrue(not ((dd.reprZip().find("Number of components : 1"))==-1));
self.assertTrue(not ((dbl.reprZip().find("Number of components : 1"))==-1));
- ret=io.StringIO("hello")
- print "\n***",ret.str(),"\n***"
- dbl.writeVTK("file.tmp",ret,2);
- print "\n***",ret.str(),"\n***"
- self.assertTrue(not ((ret.str().find("<DataArray"))==-1));
- self.assertTrue(not ((ret.str().find("Float32"))==-1));
- self.assertTrue(not ((ret.str().find("16 15 14 13 12 11 10"))==-1));
-
self.assertRaises(InterpKernelException, dbl.selectByTupleId2, 0, 1, -1);
self.assertRaises(InterpKernelException, dbl.substr, -1, 1);
self.assertRaises(InterpKernelException, dbl.substr, 8, 1);
dbl3=DataArrayDouble.New();
dbl3.alloc(6,2);
dbl3.fillWithValue(11.);
- #int tupleId;
#bad number of components
- self.assertRaises(InterpKernelException, dbl3.getMaxValue, tupleId);
- self.assertRaises(InterpKernelException, dd.getMaxValue, tupleId);
- self.assertRaises(InterpKernelException, dbl3.getMinValue, tupleId);
- self.assertRaises(InterpKernelException, dd.getMinValue, tupleId);
+ self.assertRaises(InterpKernelException, dbl3.getMaxValue);
+ self.assertRaises(InterpKernelException, dd.getMaxValue);
+ self.assertRaises(InterpKernelException, dbl3.getMinValue);
+ self.assertRaises(InterpKernelException, dd.getMinValue);
self.assertRaises(InterpKernelException, dbl3.getAverageValue);
self.assertRaises(InterpKernelException, dd.getAverageValue);
self.assertRaises(InterpKernelException, dd.accumulate, 100);
db.fillWithValue(6); #bad Ids for dbl3
self.assertRaises(InterpKernelException, dbl3.setPartOfValuesAdv, dbl2, db);
- DataArrayDouble_SetArrayIn(dbl,dbl3); #dbl.dbl3 memLeaks?
dbl3.checkNoNullValues();
- dbl3.setIJ(6,0,0.);
+ dbl3.setIJ(5,0,0.);
self.assertRaises(InterpKernelException, dbl3.checkNoNullValues);
self.assertRaises(InterpKernelException, dbl3.applyInv, 1.); #div by zero
self.assertRaises(InterpKernelException, dbl2.getIdsInRange, 1., 2.);
- #std::vector<const DataArrayDouble *> a(0); #input list must be NON EMPTY
a=[]
self.assertRaises(InterpKernelException, DataArrayDouble_Aggregate, a);
self.assertRaises(InterpKernelException, DataArrayDouble_Meld, a);
- a.push_back(dbl2);
- a.push_back(dbl); #Nb of components mismatch
+ a=[dbl2,dbl]; #Nb of components mismatch
self.assertRaises(InterpKernelException, DataArrayDouble_Aggregate, a);
self.assertRaises(InterpKernelException, DataArrayDouble_Dot, dbl2, dbl);
mesh.setCoords(tmp2);
pts=[0.2,0.2,0.1,0.3,-0.3,0.7]
c=mesh.getNodeIdsNearPoint(pts,1e-7);
- self.assertEqual([4,9,11],c);
+ self.assertEqual([4,9,11],c.getValues());
c,cI=mesh.getNodeIdsNearPoints(pts,3,1e-7);
self.assertEqual([0,3,3,4],cI.getValues());
self.assertEqual([4,9,11,6],c.getValues());
#
v=m.findAndCorrectBadOriented3DExtrudedCells();
self.assertEqual(4,len(v));
- self.assertEqual(v,invalidCells);
+ self.assertEqual(v.getValues(),invalidCells);
self.assertEqual(connExp,m.getNodalConnectivity().getValues());
#
pass
expected1=[0,3,6]
res=mesh.findNodesOnLine(pt,vec,1e-12);
self.assertEqual(3,len(res));
- self.assertEqual(expected1,res);
+ self.assertEqual(expected1,res.getValues());
#
mesh.changeSpaceDimension(3);
mesh.rotate(pt2,vec2,pi/4.);
res=mesh.findNodesOnLine(pt3,vec3,1e-12);
self.assertEqual(3,len(res));
- self.assertEqual(expected1,res);
+ self.assertEqual(expected1,res.getValues());
pass
def testIntersect2DMeshesTmp2(self):
self.assertRaises(InterpKernelException,m1Cpy.are2DCellsNotCorrectlyOriented,vec1,False);
m1Cpy.changeSpaceDimension(3);
res=m1Cpy.are2DCellsNotCorrectlyOriented(vec1,False)
- self.assertEqual([0],res);
+ self.assertEqual([0],res.getValues());
pass
pass