X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FSwig%2FMEDLoaderCommon.i;h=f9143b5a8d3efb8d93f9ffb5b45b6f32cd145578;hb=45282ab496c290658fb5b0083b948edf4526012d;hp=52621541bc451373fe033e69cb00926b04bc9377;hpb=84ddd4290c34f47a07b36552679129a7a347444f;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 52621541b..f9143b5a8 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -95,7 +95,9 @@ using namespace ParaMEDMEM; %newobject ParaMEDMEM::MEDFileMesh::computeAllFamilyIdsInUse; %newobject ParaMEDMEM::MEDFileStructuredMesh::getImplicitFaceMesh; %newobject ParaMEDMEM::MEDFileUMesh::New; +%newobject ParaMEDMEM::MEDFileUMesh::LoadPartOf; %newobject ParaMEDMEM::MEDFileUMesh::getCoords; +%newobject ParaMEDMEM::MEDFileUMesh::getPartDefAtLevel; %newobject ParaMEDMEM::MEDFileUMesh::getGroup; %newobject ParaMEDMEM::MEDFileUMesh::getGroups; %newobject ParaMEDMEM::MEDFileUMesh::getFamily; @@ -109,6 +111,8 @@ using namespace ParaMEDMEM; %newobject ParaMEDMEM::MEDFileUMesh::extractFamilyFieldOnGeoType; %newobject ParaMEDMEM::MEDFileUMesh::extractNumberFieldOnGeoType; %newobject ParaMEDMEM::MEDFileUMesh::zipCoords; +%newobject ParaMEDMEM::MEDFileUMesh::buildExtrudedMesh; +%newobject ParaMEDMEM::MEDFileUMesh::__getitem__; %newobject ParaMEDMEM::MEDFileCMesh::New; %newobject ParaMEDMEM::MEDFileCurveLinearMesh::New; %newobject ParaMEDMEM::MEDFileMeshMultiTS::New; @@ -122,6 +126,7 @@ using namespace ParaMEDMEM; %newobject ParaMEDMEM::MEDFileMeshes::__iter__; %newobject ParaMEDMEM::MEDFileFields::New; +%newobject ParaMEDMEM::MEDFileFields::LoadPartOf; %newobject ParaMEDMEM::MEDFileFields::deepCpy; %newobject ParaMEDMEM::MEDFileFields::shallowCpy; %newobject ParaMEDMEM::MEDFileFields::getFieldWithName; @@ -603,6 +608,13 @@ namespace ParaMEDMEM PyList_SetItem(res,1,PyString_FromString(what.c_str())); return res; } + + void setGroupsAtLevel(int meshDimRelToMaxExt, PyObject *li, bool renum=false) throw(INTERP_KERNEL::Exception) + { + std::vector grps; + convertFromPyObjVectorOfObj(li,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,"DataArrayInt",grps); + self->setGroupsAtLevel(meshDimRelToMaxExt,grps,renum); + } PyObject *areFamsEqual(const MEDFileMesh *other) const throw(INTERP_KERNEL::Exception) { @@ -663,6 +675,14 @@ namespace ParaMEDMEM tmp->incrRef(); return SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); } + + PyObject *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) + { + const DataArrayInt *tmp=self->getRevNumberFieldAtLevel(meshDimRelToMaxExt); + if(tmp) + tmp->incrRef(); + return SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); + } PyObject *getNameFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) { @@ -726,6 +746,7 @@ namespace ParaMEDMEM static MEDFileUMesh *New(); ~MEDFileUMesh(); int getSpaceDimension() const throw(INTERP_KERNEL::Exception); + int getRelativeLevOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception); // std::vector getGrpNonEmptyLevels(const std::string& grp) const throw(INTERP_KERNEL::Exception); std::vector getGrpNonEmptyLevelsExt(const std::string& grp) const throw(INTERP_KERNEL::Exception); @@ -737,17 +758,10 @@ namespace ParaMEDMEM std::vector getFamsNonEmptyLevelsExt(const std::vector& fams) const throw(INTERP_KERNEL::Exception); std::vector getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const throw(INTERP_KERNEL::Exception); - DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector& grps, bool renum=false) const throw(INTERP_KERNEL::Exception); - DataArrayInt *getGroupsArr(int meshDimRelToMaxExt, const std::vector& grps, bool renum=false) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *getFamily(int meshDimRelToMaxExt, const std::string& fam, bool renum=false) const throw(INTERP_KERNEL::Exception); - DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const std::string& fam, bool renum=false) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *getFamilies(int meshDimRelToMaxExt, const std::vector& fams, bool renum=false) const throw(INTERP_KERNEL::Exception); - DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector& fams, bool renum=false) const throw(INTERP_KERNEL::Exception); - DataArrayInt *getNodeGroupArr(const std::string& grp, bool renum=false) const throw(INTERP_KERNEL::Exception); DataArrayInt *getNodeGroupsArr(const std::vector& grps, bool renum=false) const throw(INTERP_KERNEL::Exception); - DataArrayInt *getNodeFamilyArr(const std::string& fam, bool renum=false) const throw(INTERP_KERNEL::Exception); - DataArrayInt *getNodeFamiliesArr(const std::vector& fams, bool renum=false) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *getMeshAtLevel(int meshDimRelToMaxExt, bool renum=false) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *getLevel0Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *getLevelM1Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception); @@ -755,6 +769,7 @@ namespace ParaMEDMEM MEDCouplingUMesh *getLevelM3Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception); void forceComputationOfParts() const throw(INTERP_KERNEL::Exception); // + int getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception); void setFamilyNameAttachedOnId(int id, const std::string& newFamName) throw(INTERP_KERNEL::Exception); void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception); void eraseGroupsAtLevel(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception); @@ -767,6 +782,7 @@ namespace ParaMEDMEM DataArrayInt *zipCoords() throw(INTERP_KERNEL::Exception); DataArrayInt *extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception); DataArrayInt *extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception); + MEDFileUMesh *buildExtrudedMesh(const MEDCouplingUMesh *m1D, int policy) const throw(INTERP_KERNEL::Exception); %extend { MEDFileUMesh(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) @@ -783,20 +799,111 @@ namespace ParaMEDMEM { return MEDFileUMesh::New(); } - - PyObject *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) + + // serialization + static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) { - const DataArrayInt *tmp=self->getRevNumberFieldAtLevel(meshDimRelToMaxExt); - if(tmp) - tmp->incrRef(); - return SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); + return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDFileUMesh"); } - - void setGroupsAtLevel(int meshDimRelToMaxExt, PyObject *li, bool renum=false) throw(INTERP_KERNEL::Exception) + + static MEDFileUMesh *LoadPartOf(const std::string& fileName, const std::string& mName, PyObject *types, const std::vector& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) { - std::vector grps; - convertFromPyObjVectorOfObj(li,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,"DataArrayInt",grps); - self->setGroupsAtLevel(meshDimRelToMaxExt,grps,renum); + std::vector typesCpp1; + convertPyToNewIntArr3(types,typesCpp1); + std::size_t sz(typesCpp1.size()); + std::vector typesCpp2(sz); + for(std::size_t ii=0;ii a0; + std::vector a1; + std::vector a2; + std::vector< MEDCouplingAutoRefCountObjectPtr > a3; + MEDCouplingAutoRefCountObjectPtr a4; + self->serialize(a0,a1,a2,a3,a4); + PyObject *ret(PyTuple_New(5)); + PyTuple_SetItem(ret,0,convertDblArrToPyList2(a0)); + PyTuple_SetItem(ret,1,convertIntArrToPyList2(a1)); + int sz(a2.size()); + PyObject *ret2(PyList_New(sz)); + for(int i=0;iincrRef(); + PyList_SetItem(ret3,i,SWIG_NewPointerObj(SWIG_as_voidptr(elt),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + } + PyTuple_SetItem(ret,3,ret3); + DataArrayDouble *ret4(a4); + if(ret4) + ret4->incrRef(); + PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(ret4),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); + return ret; + } + + void __setstate__(PyObject *inp) throw(INTERP_KERNEL::Exception) + { + static const char MSG[]="MEDFileUMesh.__setstate__ : expected input is a tuple of size 4 !"; + if(!PyTuple_Check(inp)) + throw INTERP_KERNEL::Exception(MSG); + int sz(PyTuple_Size(inp)); + if(sz!=5) + throw INTERP_KERNEL::Exception(MSG); + std::vector a0; + std::vector a1; + std::vector a2; + std::vector< MEDCouplingAutoRefCountObjectPtr > a3; + MEDCouplingAutoRefCountObjectPtr a4; + // + PyObject *a0py(PyTuple_GetItem(inp,0)),*a1py(PyTuple_GetItem(inp,1)),*a2py(PyTuple_GetItem(inp,2)); + int tmp(-1); + fillArrayWithPyListDbl3(a0py,tmp,a0); + convertPyToNewIntArr3(a1py,a1); + fillStringVector(a2py,a2); + // + PyObject *b0py(PyTuple_GetItem(inp,3)),*b1py(PyTuple_GetItem(inp,4)); + void *argp(0); + int status(SWIG_ConvertPtr(b1py,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0)); + if(!SWIG_IsOK(status)) + throw INTERP_KERNEL::Exception(MSG); + a4=reinterpret_cast(argp); + if((DataArrayDouble *)a4) + a4->incrRef(); + { + std::vector< DataArrayInt * > a3Tmp; + convertFromPyObjVectorOfObj(b0py,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,"DataArrayInt",a3Tmp); + std::size_t sz(a3Tmp.size()); + a3.resize(sz); + for(std::size_t i=0;iincrRef(); + } + self->unserialize(a0,a1,a2,a3,a4); + } + } + + MEDCouplingUMesh *__getitem__(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) + { + return self->getMeshAtLevel(meshDimRelToMaxExt,false); } void setMeshes(PyObject *li, bool renum=false) throw(INTERP_KERNEL::Exception) @@ -828,6 +935,14 @@ namespace ParaMEDMEM return ret; } + PartDefinition *getPartDefAtLevel(int meshDimRelToMaxExt, INTERP_KERNEL::NormalizedCellType gt=INTERP_KERNEL::NORM_ERROR) const throw(INTERP_KERNEL::Exception) + { + const PartDefinition *ret(self->getPartDefAtLevel(meshDimRelToMaxExt,gt)); + if(ret) + ret->incrRef(); + return const_cast(ret); + } + PyObject *duplicateNodesOnM1Group(const std::string& grpNameM1) throw(INTERP_KERNEL::Exception) { DataArrayInt *ret0=0,*ret1=0,*ret2=0; @@ -1255,6 +1370,7 @@ namespace ParaMEDMEM bool isDealingTS(int iteration, int order) const throw(INTERP_KERNEL::Exception); void setInfo(const std::vector& infos) throw(INTERP_KERNEL::Exception); const std::vector& getInfo() const throw(INTERP_KERNEL::Exception); + bool presenceOfMultiDiscPerGeoType() const throw(INTERP_KERNEL::Exception); void setTime(int iteration, int order, double val) throw(INTERP_KERNEL::Exception); virtual MEDFileAnyTypeField1TS *shallowCpy() const throw(INTERP_KERNEL::Exception); MEDFileAnyTypeField1TS *deepCpy() const throw(INTERP_KERNEL::Exception); @@ -1371,6 +1487,16 @@ namespace ParaMEDMEM PyList_SetItem(retPy,i,convertMEDFileField1TS(ret[i].retn(), SWIG_POINTER_OWN | 0 )); return retPy; } + + PyObject *splitMultiDiscrPerGeoTypes() const throw(INTERP_KERNEL::Exception) + { + std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret=self->splitMultiDiscrPerGeoTypes(); + std::size_t sz=ret.size(); + PyObject *retPy=PyList_New(sz); + for(std::size_t i=0;i& getInfo() const throw(INTERP_KERNEL::Exception); + bool presenceOfMultiDiscPerGeoType() const throw(INTERP_KERNEL::Exception); int getNumberOfComponents() const throw(INTERP_KERNEL::Exception); int getNumberOfTS() const throw(INTERP_KERNEL::Exception); void eraseEmptyTS() throw(INTERP_KERNEL::Exception); @@ -1924,6 +2051,16 @@ namespace ParaMEDMEM return retPy; } + PyObject *splitMultiDiscrPerGeoTypes() const throw(INTERP_KERNEL::Exception) + { + std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret=self->splitMultiDiscrPerGeoTypes(); + std::size_t sz=ret.size(); + PyObject *retPy=PyList_New(sz); + for(std::size_t i=0;i tmp; @@ -2232,6 +2369,7 @@ namespace ParaMEDMEM public: static MEDFileFields *New() throw(INTERP_KERNEL::Exception); static MEDFileFields *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFields *LoadPartOf(const std::string& fileName, bool loadAll=true, const MEDFileMeshes *ms=0) throw(INTERP_KERNEL::Exception); MEDFileFields *deepCpy() const throw(INTERP_KERNEL::Exception); MEDFileFields *shallowCpy() const throw(INTERP_KERNEL::Exception); void loadArrays() throw(INTERP_KERNEL::Exception); @@ -3001,17 +3139,17 @@ namespace ParaMEDMEM { PyObject *buildVTUArrays() const throw(INTERP_KERNEL::Exception) { - bool isInternal; + bool isInternal; std::vector< DataArrayDouble * > objs(self->buildVTUArrays(isInternal)); std::size_t sz(objs.size()); - PyObject *ret(PyTuple_New(2)); + PyObject *ret(PyTuple_New(2)); PyObject *ret0=PyList_New(sz); for(std::size_t i=0;i ret1; - bool ret2; + bool ret2; self->buildVTUArrays(ret0,ret1,ret2); std::size_t sz(ret1.size()); PyObject *ret=PyTuple_New(3); @@ -3037,9 +3175,9 @@ namespace ParaMEDMEM for(std::size_t i=0;i