From: ageay Date: Mon, 2 Jul 2012 08:32:47 +0000 (+0000) Subject: Accept now constructors in Python API. X-Git-Tag: V6_main_FINAL~609 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2e9dec525a7d84768bf364ff3a21408ce0d9ef61;p=tools%2Fmedcoupling.git Accept now constructors in Python API. --- diff --git a/src/MEDCoupling/MEDCouplingField.hxx b/src/MEDCoupling/MEDCouplingField.hxx index 50e1ad397..74093090d 100644 --- a/src/MEDCoupling/MEDCouplingField.hxx +++ b/src/MEDCoupling/MEDCouplingField.hxx @@ -74,7 +74,6 @@ namespace ParaMEDMEM int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception); void getCellIdsHavingGaussLocalization(int locId, std::vector& cellIds) const throw(INTERP_KERNEL::Exception); const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception); - protected: void updateTime() const; protected: MEDCouplingField(TypeOfField type); diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 6a5b70cbb..455e25331 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -6604,6 +6604,7 @@ namespace ParaMEDMEM static MEDCouplingFieldTemplate *New(TypeOfField type); std::string simpleRepr() const; std::string advancedRepr() const; + void updateTime() const; %extend { MEDCouplingFieldTemplate(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception) diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 268d2cde9..ce95ac593 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -337,7 +337,7 @@ namespace ParaMEDMEM double getTimeValue() const; void setTimeUnit(const char *unit); const char *getTimeUnit() const; - virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception) = 0; + virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception); std::vector getNonEmptyLevels() const; std::vector getNonEmptyLevelsExt() const; void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); @@ -382,8 +382,8 @@ namespace ParaMEDMEM void normalizeFamIdsTrio() throw(INTERP_KERNEL::Exception); void normalizeFamIdsMEDFile() throw(INTERP_KERNEL::Exception); virtual int getMeshDimension() const throw(INTERP_KERNEL::Exception); - virtual std::string simpleRepr() const = 0; - virtual std::string advancedRepr() const = 0; + virtual std::string simpleRepr() const; + virtual std::string advancedRepr() const; // virtual MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const throw(INTERP_KERNEL::Exception); virtual void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception); @@ -398,6 +398,16 @@ namespace ParaMEDMEM virtual DataArrayInt *getNodeFamiliesArr(const std::vector& fams, bool renum=false) const throw(INTERP_KERNEL::Exception); %extend { + MEDFileMesh(const char *fileName) throw(INTERP_KERNEL::Exception) + { + return MEDFileMesh::New(fileName); + } + + MEDFileMesh(const char *fileName, const char *mName, int dt=-1, int it=-1) + { + return MEDFileMesh::New(fileName,mName,dt,it); + } + std::string __str__() const { return self->simpleRepr(); @@ -526,6 +536,21 @@ namespace ParaMEDMEM void optimizeFamilies() throw(INTERP_KERNEL::Exception); %extend { + MEDFileUMesh(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception) + { + return MEDFileUMesh::New(fileName,mName,dt,it); + } + + MEDFileUMesh(const char *fileName) throw(INTERP_KERNEL::Exception) + { + return MEDFileUMesh::New(fileName); + } + + MEDFileUMesh() + { + return MEDFileUMesh::New(); + } + PyObject *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) { const DataArrayInt *tmp=self->getRevNumberFieldAtLevel(meshDimRelToMaxExt); @@ -571,6 +596,21 @@ namespace ParaMEDMEM void setMesh(MEDCouplingCMesh *m) throw(INTERP_KERNEL::Exception); %extend { + MEDFileCMesh() + { + return MEDFileCMesh::New(); + } + + MEDFileCMesh(const char *fileName) throw(INTERP_KERNEL::Exception) + { + return MEDFileCMesh::New(fileName); + } + + MEDFileCMesh(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception) + { + return MEDFileCMesh::New(fileName,mName,dt,it); + } + PyObject *getMesh() const { const MEDCouplingCMesh *tmp=self->getMesh(); @@ -592,6 +632,21 @@ namespace ParaMEDMEM void setOneTimeStep(MEDFileMesh *mesh1TimeStep) throw(INTERP_KERNEL::Exception); %extend { + MEDFileMeshMultiTS() + { + return MEDFileMeshMultiTS::New(); + } + + MEDFileMeshMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception) + { + return MEDFileMeshMultiTS::New(fileName); + } + + MEDFileMeshMultiTS(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception) + { + return MEDFileMeshMultiTS::New(fileName,mName); + } + MEDFileMesh *getOneTimeStep() const throw(INTERP_KERNEL::Exception) { MEDFileMesh *ret=self->getOneTimeStep(); @@ -617,6 +672,16 @@ namespace ParaMEDMEM void destroyMeshAtPos(int i) throw(INTERP_KERNEL::Exception); %extend { + MEDFileMeshes() + { + return MEDFileMeshes::New(); + } + + MEDFileMeshes(const char *fileName) throw(INTERP_KERNEL::Exception) + { + return MEDFileMeshes::New(fileName); + } + std::string __str__() const { return self->simpleRepr(); @@ -691,10 +756,10 @@ namespace ParaMEDMEM void shallowCpyGlobs(const MEDFileFieldGlobsReal& other); std::vector getPfls() const; std::vector getLocs() const; - virtual std::vector getPflsReallyUsed() const = 0; - virtual std::vector getLocsReallyUsed() const = 0; - virtual std::vector getPflsReallyUsedMulti() const = 0; - virtual std::vector getLocsReallyUsedMulti() const = 0; + virtual std::vector getPflsReallyUsed() const; + virtual std::vector getLocsReallyUsed() const; + virtual std::vector getPflsReallyUsedMulti() const; + virtual std::vector getLocsReallyUsedMulti() const; void killProfileIds(const std::vector& pflIds) throw(INTERP_KERNEL::Exception); void killLocalizationIds(const std::vector& locIds) throw(INTERP_KERNEL::Exception); void changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception); @@ -961,6 +1026,16 @@ namespace ParaMEDMEM void setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception); %extend { + MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception) + { + return MEDFileField1TS::New(fileName,fieldName,iteration,order); + } + + MEDFileField1TS() + { + return MEDFileField1TS::New(); + } + std::string __str__() const { return self->simpleRepr(); @@ -1181,6 +1256,16 @@ namespace ParaMEDMEM void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); %extend { + MEDFileFieldMultiTS() + { + return MEDFileFieldMultiTS::New(); + } + + MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception) + { + return MEDFileFieldMultiTS::New(fileName,fieldName); + } + std::string __str__() const { return self->simpleRepr(); @@ -1249,6 +1334,16 @@ namespace ParaMEDMEM void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception); %extend { + MEDFileFields() + { + return MEDFileFields::New(); + } + + MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception) + { + return MEDFileFields::New(fileName); + } + std::string __str__() const { return self->simpleRepr(); @@ -1289,6 +1384,16 @@ namespace ParaMEDMEM void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); %extend { + MEDFileData(const char *fileName) throw(INTERP_KERNEL::Exception) + { + return MEDFileData::New(fileName); + } + + MEDFileData() + { + return MEDFileData::New(); + } + std::string __str__() const { return self->simpleRepr(); diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index f0eb1fd1e..a97cd9a17 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -1257,6 +1257,42 @@ class MEDLoaderTest(unittest.TestCase): self.assertTrue(delta.getMaxValue()[0]<1e-12) mm.write(fname,2) pass + + def testBasicConstructors(self): + fname="Pyfile18.med" + m=MEDFileMesh(fname) + m=MEDFileMesh(fname,"ExampleOfMultiDimW",-1,-1) + m=MEDFileMesh(fname) + m=MEDFileUMesh(fname,"ExampleOfMultiDimW",-1,-1) + m=MEDFileUMesh(fname) + m=MEDFileUMesh() + self.testMEDMesh6() + m=MEDFileCMesh("MEDFileMesh5.med") + m=MEDFileCMesh("MEDFileMesh5.med","myFirstCartMesh",-1,-1) + m=MEDFileCMesh() + m=MEDFileMeshMultiTS() + m=MEDFileMeshMultiTS(fname) + m=MEDFileMeshMultiTS(fname,"ExampleOfMultiDimW") + m=MEDFileMeshes() + m=MEDFileMeshes(fname) + m=MEDFileField1TS() + m=MEDFileField1TS(fname,"FieldOnFacesShuffle",2,7) + m=MEDFileFieldMultiTS() + m=MEDFileFieldMultiTS(fname,"FieldOnFacesShuffle") + m=MEDFileFields() + m=MEDFileFields(fname) + m=MEDFileData() + m=MEDFileData(fname) + # + m=DataArrayInt() ; m=DataArrayInt(5,2) ; m=DataArrayInt([6,5,4,3,2,1],3,2) + m=DataArrayDouble() ; m=DataArrayDouble(5,2) ; m=DataArrayDouble([6,5,4,3,2,1],3,2) + m=MEDCouplingUMesh("jjj",2) ; m=MEDCouplingUMesh() + m=MEDCouplingCMesh() + m=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) + m=MEDCouplingFieldTemplate(ON_NODES) + m=MEDCouplingMultiFields([]) + m=MEDCouplingFieldOverTime([]) + pass pass unittest.main()