X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FSwig%2FMEDLoaderCommon.i;h=ac5c2cbda3cc24f6e316a7b267cd1635069c4b6e;hb=b4634cfcaa239b987c02485ba0b9b5e6a666676f;hp=08396b5bf3fa6574abffbeb0af4de38658a16a02;hpb=79386ac5c73f8365c428b8ef595c4ef004959667;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 08396b5bf..ac5c2cbda 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D +// Copyright (C) 2017 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 @@ -16,9 +16,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author : Anthony Geay (CEA/DEN) - -%module MEDLoader +// Author : Anthony Geay (EDF R&D) #define MEDCOUPLING_EXPORT #define MEDLOADER_EXPORT @@ -37,6 +35,7 @@ #include "MEDFileParameter.hxx" #include "MEDFileData.hxx" #include "MEDFileEquivalence.hxx" +#include "MEDFileEntities.hxx" #include "MEDFileMeshReadSelector.hxx" #include "MEDFileFieldOverView.hxx" #include "MEDLoaderTypemaps.i" @@ -77,9 +76,9 @@ using namespace MEDCoupling; %newobject ReadUMeshFromFamiliesSwig; %newobject ReadUMeshFromGroupsSwig; +%newobject ReadFieldSwig; %newobject MEDCoupling::ReadUMeshFromFile; %newobject MEDCoupling::ReadMeshFromFile; -%newobject MEDCoupling::ReadField; %newobject MEDCoupling::ReadFieldCell; %newobject MEDCoupling::ReadFieldNode; %newobject MEDCoupling::ReadFieldGauss; @@ -98,6 +97,7 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileMesh::getNodeGroupsArr; %newobject MEDCoupling::MEDFileMesh::getNodeFamilyArr; %newobject MEDCoupling::MEDFileMesh::getNodeFamiliesArr; +%newobject MEDCoupling::MEDFileMesh::getGlobalNumFieldAtLevel; %newobject MEDCoupling::MEDFileMesh::getAllFamiliesIdsReferenced; %newobject MEDCoupling::MEDFileMesh::computeAllFamilyIdsInUse; %newobject MEDCoupling::MEDFileMesh::getEquivalences; @@ -120,9 +120,14 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileUMesh::extractFamilyFieldOnGeoType; %newobject MEDCoupling::MEDFileUMesh::extractNumberFieldOnGeoType; %newobject MEDCoupling::MEDFileUMesh::zipCoords; +%newobject MEDCoupling::MEDFileUMesh::deduceNodeSubPartFromCellSubPart; +%newobject MEDCoupling::MEDFileUMesh::extractPart; %newobject MEDCoupling::MEDFileUMesh::buildExtrudedMesh; %newobject MEDCoupling::MEDFileUMesh::linearToQuadratic; %newobject MEDCoupling::MEDFileUMesh::quadraticToLinear; +%newobject MEDCoupling::MEDFileUMesh::symmetry3DPlane; +%newobject MEDCoupling::MEDFileUMesh::Aggregate; +%newobject MEDCoupling::MEDFileUMesh::convertToExtrudedMesh; %newobject MEDCoupling::MEDFileCMesh::New; %newobject MEDCoupling::MEDFileCurveLinearMesh::New; %newobject MEDCoupling::MEDFileMeshMultiTS::New; @@ -135,7 +140,14 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileMeshes::__getitem__; %newobject MEDCoupling::MEDFileMeshes::__iter__; +%newobject MEDCoupling::MEDFileMeshSupports::New; +%newobject MEDCoupling::MEDFileMeshSupports::getSupMeshWithName; + +%newobject MEDCoupling::MEDFileStructureElements::New; + %newobject MEDCoupling::MEDFileFields::New; +%newobject MEDCoupling::MEDFileFields::NewAdv; +%newobject MEDCoupling::MEDFileFields::NewWithDynGT; %newobject MEDCoupling::MEDFileFields::LoadPartOf; %newobject MEDCoupling::MEDFileFields::LoadSpecificEntities; %newobject MEDCoupling::MEDFileFields::deepCopy; @@ -145,9 +157,12 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileFields::partOfThisLyingOnSpecifiedMeshName; %newobject MEDCoupling::MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps; %newobject MEDCoupling::MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps; +%newobject MEDCoupling::MEDFileFields::partOfThisOnStructureElements; %newobject MEDCoupling::MEDFileFields::__iter__; %newobject MEDCoupling::MEDFileFields::extractPart; +%newobject MEDCoupling::MEDFileFields::linearToQuadratic; +%newobject MEDCoupling::MEDFileWritableStandAlone::serialize; %newobject MEDCoupling::MEDFileAnyTypeFieldMultiTS::New; %newobject MEDCoupling::MEDFileAnyTypeFieldMultiTS::deepCopy; %newobject MEDCoupling::MEDFileAnyTypeFieldMultiTS::shallowCpy; @@ -159,22 +174,41 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileAnyTypeFieldMultiTS::buildNewEmpty; %newobject MEDCoupling::MEDFileFieldMultiTS::New; %newobject MEDCoupling::MEDFileFieldMultiTS::LoadSpecificEntities; +%newobject MEDCoupling::MEDFileFieldMultiTS::field; %newobject MEDCoupling::MEDFileFieldMultiTS::getFieldAtLevel; %newobject MEDCoupling::MEDFileFieldMultiTS::getFieldAtTopLevel; %newobject MEDCoupling::MEDFileFieldMultiTS::getFieldOnMeshAtLevel; %newobject MEDCoupling::MEDFileFieldMultiTS::getFieldAtLevelOld; %newobject MEDCoupling::MEDFileFieldMultiTS::getUndergroundDataArray; %newobject MEDCoupling::MEDFileFieldMultiTS::convertToInt; + %newobject MEDCoupling::MEDFileIntFieldMultiTS::New; +%newobject MEDCoupling::MEDFileIntFieldMultiTS::field; %newobject MEDCoupling::MEDFileIntFieldMultiTS::LoadSpecificEntities; %newobject MEDCoupling::MEDFileIntFieldMultiTS::getUndergroundDataArray; %newobject MEDCoupling::MEDFileIntFieldMultiTS::convertToDouble; +%newobject MEDCoupling::MEDFileIntFieldMultiTS::getFieldAtLevel; +%newobject MEDCoupling::MEDFileIntFieldMultiTS::getFieldAtTopLevel; +%newobject MEDCoupling::MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel; +%newobject MEDCoupling::MEDFileIntFieldMultiTS::getFieldAtLevelOld; + +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::New; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::field; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::LoadSpecificEntities; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::getUndergroundDataArray; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::convertToDouble; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::getFieldAtLevel; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::getFieldAtTopLevel; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::getFieldOnMeshAtLevel; +%newobject MEDCoupling::MEDFileFloatFieldMultiTS::getFieldAtLevelOld; %newobject MEDCoupling::MEDFileAnyTypeField1TS::New; +%newobject MEDCoupling::MEDFileAnyTypeField1TS::NewAdv; %newobject MEDCoupling::MEDFileAnyTypeField1TS::shallowCpy; %newobject MEDCoupling::MEDFileAnyTypeField1TS::deepCopy; %newobject MEDCoupling::MEDFileAnyTypeField1TS::extractPart; %newobject MEDCoupling::MEDFileField1TS::New; +%newobject MEDCoupling::MEDFileField1TS::field; %newobject MEDCoupling::MEDFileField1TS::getFieldAtLevel; %newobject MEDCoupling::MEDFileField1TS::getFieldAtTopLevel; %newobject MEDCoupling::MEDFileField1TS::getFieldOnMeshAtLevel; @@ -183,14 +217,31 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileField1TS::convertToInt; %newobject MEDCoupling::MEDFileIntField1TS::New; +%newobject MEDCoupling::MEDFileIntField1TS::field; +%newobject MEDCoupling::MEDFileIntField1TS::getFieldAtLevel; +%newobject MEDCoupling::MEDFileIntField1TS::getFieldAtTopLevel; +%newobject MEDCoupling::MEDFileIntField1TS::getFieldOnMeshAtLevel; +%newobject MEDCoupling::MEDFileIntField1TS::getFieldAtLevelOld; %newobject MEDCoupling::MEDFileIntField1TS::getUndergroundDataArray; %newobject MEDCoupling::MEDFileIntField1TS::convertToDouble; +%newobject MEDCoupling::MEDFileFloatField1TS::New; +%newobject MEDCoupling::MEDFileFloatField1TS::field; +%newobject MEDCoupling::MEDFileFloatField1TS::getFieldAtLevel; +%newobject MEDCoupling::MEDFileFloatField1TS::getFieldAtTopLevel; +%newobject MEDCoupling::MEDFileFloatField1TS::getFieldOnMeshAtLevel; +%newobject MEDCoupling::MEDFileFloatField1TS::getFieldAtLevelOld; +%newobject MEDCoupling::MEDFileFloatField1TS::getUndergroundDataArray; +%newobject MEDCoupling::MEDFileFloatField1TS::convertToDouble; + %newobject MEDCoupling::MEDFileData::New; %newobject MEDCoupling::MEDFileData::deepCopy; %newobject MEDCoupling::MEDFileData::getMeshes; %newobject MEDCoupling::MEDFileData::getFields; %newobject MEDCoupling::MEDFileData::getParams; +%newobject MEDCoupling::MEDFileData::Aggregate; + +%newobject MEDCoupling::MEDFileEntities::BuildFrom; %newobject MEDCoupling::MEDFileParameterDouble1TS::New; %newobject MEDCoupling::MEDFileParameterDouble1TS::deepCopy; @@ -207,12 +258,17 @@ using namespace MEDCoupling; %newobject MEDCoupling::MEDFileJointCorrespondence::New; %newobject MEDCoupling::MEDFileJointCorrespondence::deepCopy; %newobject MEDCoupling::MEDFileJointCorrespondence::shallowCpy; +%newobject MEDCoupling::MEDFileJointCorrespondence::getCorrespondence; %newobject MEDCoupling::MEDFileJointOneStep::New; %newobject MEDCoupling::MEDFileJointOneStep::deepCopy; %newobject MEDCoupling::MEDFileJointOneStep::shallowCpy; +%newobject MEDCoupling::MEDFileJointOneStep::getCorrespondenceAtPos; +%newobject MEDCoupling::MEDFileJointOneStep::__getitem__; %newobject MEDCoupling::MEDFileJoint::New; %newobject MEDCoupling::MEDFileJoint::deepCopy; %newobject MEDCoupling::MEDFileJoint::shallowCpy; +%newobject MEDCoupling::MEDFileJoint::getStepAtPos; +%newobject MEDCoupling::MEDFileJoint::__getitem__; %newobject MEDCoupling::MEDFileJoints::New; %newobject MEDCoupling::MEDFileJoints::deepCopy; %newobject MEDCoupling::MEDFileJoints::getJointAtPos; @@ -248,9 +304,13 @@ using namespace MEDCoupling; %feature("unref") MEDFileAnyTypeField1TS "$this->decrRef();" %feature("unref") MEDFileField1TS "$this->decrRef();" %feature("unref") MEDFileIntField1TS "$this->decrRef();" +%feature("unref") MEDFileFloatField1TS "$this->decrRef();" %feature("unref") MEDFileAnyTypeFieldMultiTS "$this->decrRef();" %feature("unref") MEDFileFieldMultiTS "$this->decrRef();" %feature("unref") MEDFileIntFieldMultiTS "$this->decrRef();" +%feature("unref") MEDFileFloatFieldMultiTS "$this->decrRef();" +%feature("unref") MEDFileMeshSupports "$this->decrRef();" +%feature("unref") MEDFileStructureElements "$this->decrRef();" %feature("unref") MEDFileFields "$this->decrRef();" %feature("unref") MEDFileParameter1TS "$this->decrRef();" %feature("unref") MEDFileParameterDouble1TSWTI "$this->decrRef();" @@ -280,7 +340,8 @@ using namespace MEDCoupling; namespace MEDCoupling { bool HasXDR(); - std::string MEDFileVersionStr(); + std::string MEDFileVersionStr() throw(INTERP_KERNEL::Exception); + std::string MEDFileVersionOfFileStr(const std::string& fileName) throw(INTERP_KERNEL::Exception); void SetEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception); void SetCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception); void SetTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception); @@ -303,7 +364,6 @@ namespace MEDCoupling MEDCoupling::MEDCouplingUMesh *ReadUMeshFromFile(const std::string& fileName, const std::string& meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); MEDCoupling::MEDCouplingUMesh *ReadUMeshFromFile(const std::string& fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); int ReadUMeshDimFromFile(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception); - MEDCoupling::MEDCouplingFieldDouble *ReadField(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); MEDCoupling::MEDCouplingFieldDouble *ReadFieldCell(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); MEDCoupling::MEDCouplingFieldDouble *ReadFieldNode(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); MEDCoupling::MEDCouplingFieldDouble *ReadFieldGauss(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); @@ -311,9 +371,9 @@ namespace MEDCoupling void WriteMesh(const std::string& fileName, const MEDCoupling::MEDCouplingMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception); void WriteUMesh(const std::string& fileName, const MEDCoupling::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception); void WriteUMeshDep(const std::string& fileName, const MEDCoupling::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - void WriteField(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - void WriteFieldDep(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - void WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception); + void WriteField(const std::string& fileName, const MEDCoupling::MEDCouplingField *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); + void WriteFieldDep(const std::string& fileName, const MEDCoupling::MEDCouplingField *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); + void WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, const MEDCoupling::MEDCouplingField *f) throw(INTERP_KERNEL::Exception); } %rename (MEDFileVersion) MEDFileVersionSwig; @@ -330,10 +390,11 @@ namespace MEDCoupling %rename (GetTypesOfField) GetTypesOfFieldSwig; %rename (ReadUMeshFromGroups) ReadUMeshFromGroupsSwig; %rename (ReadUMeshFromFamilies) ReadUMeshFromFamiliesSwig; +%rename (ReadField) ReadFieldSwig; %inline { - PyObject *MEDFileVersionSwig() + PyObject *MEDFileVersionSwig() throw(INTERP_KERNEL::Exception) { int major,minor,release; MEDCoupling::MEDFileVersion(major,minor,release); @@ -344,7 +405,31 @@ namespace MEDCoupling return ret; } - PyObject *GetFieldIterationsSwig(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, const std::string& fieldName) + MEDCoupling::MEDCouplingField *ReadFieldSwig(const std::string& fileName) throw(INTERP_KERNEL::Exception) + { + MCAuto ret(MEDCoupling::ReadField(fileName)); + return ret.retn(); + } + + MEDCoupling::MEDCouplingField *ReadFieldSwig(const std::string& fileName, const std::string& fieldName) throw(INTERP_KERNEL::Exception) + { + MCAuto ret(MEDCoupling::ReadField(fileName,fieldName)); + return ret.retn(); + } + + MEDCoupling::MEDCouplingField *ReadFieldSwig(const std::string& fileName, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception) + { + MCAuto ret(MEDCoupling::ReadField(fileName,fieldName,iteration,order)); + return ret.retn(); + } + + MEDCoupling::MEDCouplingFieldDouble *ReadFieldSwig(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception) + { + MCAuto ret(MEDCoupling::ReadField(type,fileName,meshName,meshDimRelToMax,fieldName,iteration,order)); + return ret.retn(); + } + + PyObject *GetFieldIterationsSwig(MEDCoupling::TypeOfField type, const std::string& fileName, const std::string& meshName, const std::string& fieldName) throw(INTERP_KERNEL::Exception) { std::vector< std::pair > res=MEDCoupling::GetFieldIterations(type,fileName,meshName,fieldName); PyObject *ret=PyList_New(res.size()); @@ -513,7 +598,32 @@ namespace MEDCoupling int getZipConnPolicy() throw(INTERP_KERNEL::Exception); void setZipConnPolicy(int newVal) throw(INTERP_KERNEL::Exception); }; + + class MEDFileWritableStandAlone : public MEDFileWritable + { + public: + void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); + void write30(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); + %extend + { + DataArrayByte *serialize() const throw(INTERP_KERNEL::Exception) + { + MCAuto ret(self->serialize()); + return ret.retn(); + } + PyObject *__getstate__() throw(INTERP_KERNEL::Exception) + { + PyObject *ret(PyList_New(0)); + return ret; + } + + void __setstate__(PyObject *inp) throw(INTERP_KERNEL::Exception) + { + } + } + }; + class MEDFileMeshReadSelector { public: @@ -527,12 +637,14 @@ namespace MEDCoupling bool isNodeNameFieldReading() const; bool isCellNumFieldReading() const; bool isNodeNumFieldReading() const; + bool isGlobalNodeNumFieldReading() const; void setCellFamilyFieldReading(bool b); void setNodeFamilyFieldReading(bool b); void setCellNameFieldReading(bool b); void setNodeNameFieldReading(bool b); void setCellNumFieldReading(bool b); void setNodeNumFieldReading(bool b); + void setGlobalNodeNumFieldReading(bool b); %extend { std::string __str__() const throw(INTERP_KERNEL::Exception) @@ -571,7 +683,6 @@ namespace MEDCoupling void setRemoteGeometryType(INTERP_KERNEL::NormalizedCellType type); INTERP_KERNEL::NormalizedCellType getRemoteGeometryType() const; void setCorrespondence(DataArrayInt *corr) throw(INTERP_KERNEL::Exception); - const DataArrayInt *getCorrespondence() const throw(INTERP_KERNEL::Exception); void write(const std::string& fileName, int mode, const std::string& localMeshName, const std::string& jointName, int order, int iteration) const throw(INTERP_KERNEL::Exception); std::string simpleRepr() const throw(INTERP_KERNEL::Exception); %extend @@ -595,6 +706,14 @@ namespace MEDCoupling { return self->simpleRepr(); } + + DataArrayInt *getCorrespondence() const throw(INTERP_KERNEL::Exception) + { + const DataArrayInt *ret(self->getCorrespondence()); + if(ret) + ret->incrRef(); + return const_cast(ret); + } } }; @@ -612,7 +731,6 @@ namespace MEDCoupling int getIteration() const; void pushCorrespondence(MEDFileJointCorrespondence* correspondence); int getNumberOfCorrespondences() const; - MEDFileJointCorrespondence *getCorrespondenceAtPos(int i) const; void write(const std::string& fileName, int mode, const std::string& localMeshName, const std::string& jointName) const throw(INTERP_KERNEL::Exception); std::string simpleRepr() const throw(INTERP_KERNEL::Exception); %extend @@ -631,15 +749,28 @@ namespace MEDCoupling { return self->simpleRepr(); } + + MEDFileJointCorrespondence *getCorrespondenceAtPos(int i) const throw(INTERP_KERNEL::Exception) + { + MEDFileJointCorrespondence *ret(self->getCorrespondenceAtPos(i)); + if(ret) + ret->incrRef(); + return ret; + } + + MEDFileJointCorrespondence *__getitem__(int i) const throw(INTERP_KERNEL::Exception) + { + return MEDCoupling_MEDFileJointOneStep_getCorrespondenceAtPos(self,i); + } } }; - class MEDFileJoint : public RefCountObject, public MEDFileWritable + class MEDFileJoint : public RefCountObject, public MEDFileWritableStandAlone { public: static MEDFileJoint *New() throw(INTERP_KERNEL::Exception); static MEDFileJoint *New(const std::string& fileName, const std::string& mName, int num) throw(INTERP_KERNEL::Exception); - static MEDFileJoint *New(const std::string& jointName, const std::string& locMeshName, const std::string& remoteMeshName, int remoteMeshNum ) throw(INTERP_KERNEL::Exception); + static MEDFileJoint *New(const std::string& jointName, const std::string& locMeshName, const std::string& remoteMeshName, int remoteMeshNum) throw(INTERP_KERNEL::Exception); MEDFileJoint *deepCopy() const; MEDFileJoint *shallowCpy() const; bool isEqual(const MEDFileJoint *other) const; @@ -656,8 +787,6 @@ namespace MEDCoupling int getDomainNumber() const; void pushStep(MEDFileJointOneStep* step); int getNumberOfSteps() const; - MEDFileJointOneStep *getStepAtPos(int i) const; - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); std::string simpleRepr() const; %extend { @@ -671,21 +800,38 @@ namespace MEDCoupling return MEDFileJoint::New(fileName,mName,num); } + MEDFileJoint(const std::string& jointName, const std::string& locMeshName, const std::string& remoteMeshName, int remoteMeshNum) throw(INTERP_KERNEL::Exception) + { + return MEDFileJoint::New(jointName,locMeshName,remoteMeshName,remoteMeshNum); + } + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } + + MEDFileJointOneStep *getStepAtPos(int i) const throw(INTERP_KERNEL::Exception) + { + MEDFileJointOneStep *ret(self->getStepAtPos(i)); + if(ret) + ret->incrRef(); + return ret; + } + + MEDFileJointOneStep *__getitem__(int i) throw(INTERP_KERNEL::Exception) + { + return MEDCoupling_MEDFileJoint_getStepAtPos(self,i); + } } }; - class MEDFileJoints : public RefCountObject, public MEDFileWritable + class MEDFileJoints : public RefCountObject, public MEDFileWritableStandAlone { public: static MEDFileJoints *New() throw(INTERP_KERNEL::Exception); static MEDFileJoints *New(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception); MEDFileJoints *deepCopy() const; std::string simpleRepr() const; - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); std::string getMeshName() const; int getNumberOfJoints() const; std::vector getJointsNames() const; @@ -713,6 +859,7 @@ namespace MEDCoupling MEDFileJoint *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) { + static const char msg[]="MEDFileJoints::__getitem__ : only integer or string with meshname supported !"; if(PyInt_Check(obj)) { MEDFileJoint *ret=self->getJointAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfJoints())); @@ -720,15 +867,10 @@ namespace MEDCoupling ret->incrRef(); return ret; } - else if(PyString_Check(obj)) - { - MEDFileJoint *ret=self->getJointWithName(PyString_AsString(obj)); - if(ret) - ret->incrRef(); - return ret; - } - else - throw INTERP_KERNEL::Exception("MEDFileJoints::__getitem__ : only integer or string with meshname supported !"); + MEDFileJoint *ret(self->getJointWithName(convertPyObjectToStr(obj,msg))); + if(ret) + ret->incrRef(); + return ret; } int __len__() const throw(INTERP_KERNEL::Exception) @@ -754,7 +896,7 @@ namespace MEDCoupling } }; - class MEDFileEquivalenceBase : public RefCountObject + class MEDFileEquivalenceBase : public RefCountObject, public MEDFileWritableStandAlone { private: MEDFileEquivalenceBase(); @@ -813,7 +955,7 @@ namespace MEDCoupling } }; - class MEDFileEquivalencePair : public RefCountObject + class MEDFileEquivalencePair : public RefCountObject, public MEDFileWritableStandAlone { private: MEDFileEquivalencePair(); @@ -855,7 +997,7 @@ namespace MEDCoupling } }; - class MEDFileEquivalences : public RefCountObject + class MEDFileEquivalences : public RefCountObject, public MEDFileWritableStandAlone { private: MEDFileEquivalences(); @@ -889,11 +1031,12 @@ namespace MEDCoupling } }; - class MEDFileMesh : public RefCountObject, public MEDFileWritable + class MEDFileMesh : public RefCountObject, public MEDFileWritableStandAlone { public: static MEDFileMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); static MEDFileMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); + static MEDFileMesh *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); virtual MEDFileMesh *createNewEmpty() const throw(INTERP_KERNEL::Exception); virtual MEDFileMesh *deepCopy() const throw(INTERP_KERNEL::Exception); virtual MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception); @@ -929,7 +1072,6 @@ namespace MEDCoupling virtual MEDFileMesh *cartesianize() const throw(INTERP_KERNEL::Exception); std::vector getNonEmptyLevels() const throw(INTERP_KERNEL::Exception); std::vector getNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception); - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception); // bool existsGroup(const std::string& groupName) const throw(INTERP_KERNEL::Exception); @@ -1007,6 +1149,7 @@ namespace MEDCoupling virtual void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception); virtual void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr) throw(INTERP_KERNEL::Exception); virtual void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr) throw(INTERP_KERNEL::Exception); + virtual void setGlobalNumFieldAtLevel(int meshDimRelToMaxExt, DataArrayInt *globalNumArr) throw(INTERP_KERNEL::Exception); virtual void addNodeGroup(const DataArrayInt *ids) throw(INTERP_KERNEL::Exception); virtual void addGroup(int meshDimRelToMaxExt, const DataArrayInt *ids) throw(INTERP_KERNEL::Exception); virtual DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector& fams, bool renum=false) const throw(INTERP_KERNEL::Exception); @@ -1022,6 +1165,8 @@ namespace MEDCoupling void setJoints( MEDFileJoints* joints ); void initializeEquivalences(); void killEquivalences(); + bool presenceOfStructureElements() const throw(INTERP_KERNEL::Exception); + void killStructureElements() throw(INTERP_KERNEL::Exception); %extend { std::string __str__() const throw(INTERP_KERNEL::Exception) @@ -1198,6 +1343,12 @@ namespace MEDCoupling if(ret) ret->incrRef(); return ret; } + + virtual DataArrayInt *getGlobalNumFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) + { + MCAuto ret(self->getGlobalNumFieldAtLevel(meshDimRelToMaxExt)); + return ret.retn(); + } } }; @@ -1206,7 +1357,10 @@ namespace MEDCoupling public: static MEDFileUMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); static MEDFileUMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); + static MEDFileUMesh *New(const MEDCouplingMappedExtrudedMesh *mem) throw(INTERP_KERNEL::Exception); + static MEDFileUMesh *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); static MEDFileUMesh *New(); + static const char *GetSpeStr4ExtMesh(); ~MEDFileUMesh(); int getSpaceDimension() const throw(INTERP_KERNEL::Exception); int getRelativeLevOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception); @@ -1227,6 +1381,7 @@ namespace MEDCoupling // void setFamilyNameAttachedOnId(int id, const std::string& newFamName) throw(INTERP_KERNEL::Exception); void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception); + void setCoordsForced(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception); void eraseGroupsAtLevel(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception); void removeMeshAtLevel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception); void setMeshAtLevel(int meshDimRelToMax, MEDCoupling1GTUMesh *m) throw(INTERP_KERNEL::Exception); @@ -1238,6 +1393,7 @@ namespace MEDCoupling MEDFileUMesh *buildExtrudedMesh(const MEDCouplingUMesh *m1D, int policy) const throw(INTERP_KERNEL::Exception); MEDFileUMesh *linearToQuadratic(int conversionType=0, double eps=1e-12) const throw(INTERP_KERNEL::Exception); MEDFileUMesh *quadraticToLinear(double eps=1e-12) const throw(INTERP_KERNEL::Exception); + MEDCouplingMappedExtrudedMesh *convertToExtrudedMesh() 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) @@ -1250,15 +1406,19 @@ namespace MEDCoupling return MEDFileUMesh::New(fileName,mrs); } - MEDFileUMesh() + MEDFileUMesh(const MEDCouplingMappedExtrudedMesh *mem) throw(INTERP_KERNEL::Exception) { - return MEDFileUMesh::New(); + return MEDFileUMesh::New(mem); + } + + MEDFileUMesh(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileUMesh::New(db); } - // serialization - static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception) + MEDFileUMesh() { - return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDFileUMesh"); + return MEDFileUMesh::New(); } 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) @@ -1272,14 +1432,6 @@ namespace MEDCoupling return MEDFileUMesh::LoadPartOf(fileName,mName,typesCpp2,slicPerTyp,dt,it,mrs); } - PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception) - {// put an empty dict in input to say to __new__ to call __init__... - PyObject *ret(PyTuple_New(1)); - PyObject *ret0(PyDict_New()); - PyTuple_SetItem(ret,0,ret0); - return ret; - } - PyObject *__getstate__() throw(INTERP_KERNEL::Exception) { std::vector a0; @@ -1380,6 +1532,48 @@ namespace MEDCoupling self->removeMeshAtLevel(meshDimRelToMax); } + MEDFileUMesh *symmetry3DPlane(PyObject *point, PyObject *normalVector) const throw(INTERP_KERNEL::Exception) + { + const char msg[]="Python wrap of MEDFileUMesh::symmetry3DPlane : "; + double val,val2; + DataArrayDouble *a,*a2; + DataArrayDoubleTuple *aa,*aa2; + std::vector bb,bb2; + int sw; + const double *centerPtr(convertObjToPossibleCpp5_Safe(point,sw,val,a,aa,bb,msg,1,3,true)); + const double *vectorPtr(convertObjToPossibleCpp5_Safe(normalVector,sw,val2,a2,aa2,bb2,msg,1,3,true)); + MCAuto ret(self->symmetry3DPlane(centerPtr,vectorPtr)); + return ret.retn(); + } + + static MEDFileUMesh *Aggregate(PyObject *meshes) throw(INTERP_KERNEL::Exception) + { + std::vector meshesCpp; + convertFromPyObjVectorOfObj(meshes,SWIGTYPE_p_MEDCoupling__MEDFileUMesh,"MEDFileUMesh",meshesCpp); + MCAuto ret(MEDFileUMesh::Aggregate(meshesCpp)); + return ret.retn(); + } + + PyObject *getAllDistributionOfTypes() const throw(INTERP_KERNEL::Exception) + { + std::vector< std::pair > ret(self->getAllDistributionOfTypes()); + return convertVecPairIntToPy(ret); + } + + DataArrayInt *deduceNodeSubPartFromCellSubPart(PyObject *extractDef) const throw(INTERP_KERNEL::Exception) + { + std::map > extractDefCpp; + convertToMapIntDataArrayInt(extractDef,extractDefCpp); + return self->deduceNodeSubPartFromCellSubPart(extractDefCpp); + } + + MEDFileUMesh *extractPart(PyObject *extractDef) const throw(INTERP_KERNEL::Exception) + { + std::map > extractDefCpp; + convertToMapIntDataArrayInt(extractDef,extractDefCpp); + return self->extractPart(extractDefCpp); + } + void setMeshes(PyObject *li, bool renum=false) throw(INTERP_KERNEL::Exception) { std::vector ms; @@ -1471,6 +1665,7 @@ namespace MEDCoupling { public: static MEDFileCMesh *New(); + static MEDFileCMesh *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); static MEDFileCMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); static MEDFileCMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); void setMesh(MEDCouplingCMesh *m) throw(INTERP_KERNEL::Exception); @@ -1491,6 +1686,11 @@ namespace MEDCoupling { return MEDFileCMesh::New(fileName,mName,dt,it,mrs); } + + MEDFileCMesh(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileCMesh::New(db); + } PyObject *getMesh() const throw(INTERP_KERNEL::Exception) { @@ -1506,6 +1706,7 @@ namespace MEDCoupling { public: static MEDFileCurveLinearMesh *New(); + static MEDFileCurveLinearMesh *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); static MEDFileCurveLinearMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); static MEDFileCurveLinearMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); void setMesh(MEDCouplingCurveLinearMesh *m) throw(INTERP_KERNEL::Exception); @@ -1525,6 +1726,11 @@ namespace MEDCoupling { return MEDFileCurveLinearMesh::New(fileName,mName,dt,it,mrs); } + + MEDFileCurveLinearMesh(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileCurveLinearMesh::New(db); + } PyObject *getMesh() const throw(INTERP_KERNEL::Exception) { @@ -1536,7 +1742,7 @@ namespace MEDCoupling } }; - class MEDFileMeshMultiTS : public RefCountObject, public MEDFileWritable + class MEDFileMeshMultiTS : public RefCountObject, public MEDFileWritableStandAlone { public: static MEDFileMeshMultiTS *New(); @@ -1544,7 +1750,6 @@ namespace MEDCoupling static MEDFileMeshMultiTS *New(const std::string& fileName, const std::string& mName) throw(INTERP_KERNEL::Exception); MEDFileMeshMultiTS *deepCopy() const throw(INTERP_KERNEL::Exception); std::string getName() const throw(INTERP_KERNEL::Exception); - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); void setOneTimeStep(MEDFileMesh *mesh1TimeStep) throw(INTERP_KERNEL::Exception); void cartesianizeMe() throw(INTERP_KERNEL::Exception); %extend @@ -1596,13 +1801,12 @@ namespace MEDCoupling } }; - class MEDFileMeshes : public RefCountObject, public MEDFileWritable + class MEDFileMeshes : public RefCountObject, public MEDFileWritableStandAlone { public: static MEDFileMeshes *New(); - static MEDFileMeshes *New(const std::string& fileName) throw(INTERP_KERNEL::Exception); + static MEDFileMeshes *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); MEDFileMeshes *deepCopy() const throw(INTERP_KERNEL::Exception); - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception); std::vector getMeshesNames() const throw(INTERP_KERNEL::Exception); // @@ -1611,6 +1815,8 @@ namespace MEDCoupling void setMeshAtPos(int i, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception); void destroyMeshAtPos(int i) throw(INTERP_KERNEL::Exception); void cartesianizeMe() throw(INTERP_KERNEL::Exception); + bool presenceOfStructureElements() const throw(INTERP_KERNEL::Exception); + void killStructureElements() throw(INTERP_KERNEL::Exception); %extend { MEDFileMeshes() @@ -1623,6 +1829,11 @@ namespace MEDCoupling return MEDFileMeshes::New(fileName); } + MEDFileMeshes(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileMeshes::New(db); + } + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); @@ -1630,22 +1841,18 @@ namespace MEDCoupling MEDFileMesh *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) { - if(PyInt_Check(obj)) + static const char msg[]="MEDFileMeshes::__getitem__ : only integer or string with meshname supported !"; + if(PyInt_Check(obj)) { MEDFileMesh *ret=self->getMeshAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfMeshes())); if(ret) ret->incrRef(); return ret; } - else if(PyString_Check(obj)) - { - MEDFileMesh *ret=self->getMeshWithName(PyString_AsString(obj)); - if(ret) - ret->incrRef(); - return ret; - } - else - throw INTERP_KERNEL::Exception("MEDFileMeshes::__getitem__ : only integer or string with meshname supported !"); + MEDFileMesh *ret(self->getMeshWithName(convertPyObjectToStr(obj,msg))); + if(ret) + ret->incrRef(); + return ret; } MEDFileMeshes *__setitem__(int obj, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception) @@ -1731,6 +1938,8 @@ namespace MEDCoupling void changeLocName(const std::string& oldName, const std::string& newName) throw(INTERP_KERNEL::Exception); int getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception); int getLocalizationId(const std::string& loc) const throw(INTERP_KERNEL::Exception); + int getProfileId(const std::string& pfl) const throw(INTERP_KERNEL::Exception); + void killStructureElementsInGlobs() throw(INTERP_KERNEL::Exception); %extend { PyObject *getProfile(const std::string& pflName) const throw(INTERP_KERNEL::Exception) @@ -1822,13 +2031,35 @@ namespace MEDCoupling } }; - class MEDFileAnyTypeField1TS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable + class MEDFileEntities + { + public: + %extend + { + static MEDFileEntities *BuildFrom(PyObject *entities) throw(INTERP_KERNEL::Exception) + { + std::vector< std::pair > inp; + std::vector< std::pair > inp0(convertTimePairIdsFromPy(entities)); + { + std::size_t sz(inp0.size()); + inp.resize(sz); + for(std::size_t i=0;i((TypeOfField)inp0[i].first,(INTERP_KERNEL::NormalizedCellType)inp0[i].second); + } + return MEDFileEntities::BuildFrom(&inp); + } + } + private: + MEDFileEntities(); + }; + + class MEDFileAnyTypeField1TS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritableStandAlone { public: static MEDFileAnyTypeField1TS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception); - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); + static MEDFileAnyTypeField1TS *NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities) throw(INTERP_KERNEL::Exception); void loadArrays() throw(INTERP_KERNEL::Exception); void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); void unloadArrays() throw(INTERP_KERNEL::Exception); @@ -1989,8 +2220,11 @@ namespace MEDCoupling static MEDFileField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception); static MEDFileField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); static MEDFileField1TS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileField1TS *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); static MEDFileField1TS *New(); MEDCoupling::MEDFileIntField1TS *convertToInt(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + void copyTimeInfoFrom(MEDCouplingFieldDouble *mcf) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *field(const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); @@ -2018,11 +2252,16 @@ namespace MEDCoupling return MEDFileField1TS::New(fileName,fieldName,iteration,order,loadAll); } + MEDFileField1TS(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileField1TS::New(db); + } + MEDFileField1TS() { return MEDFileField1TS::New(); } - + void copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception) { const DataArrayDouble *arr=0; @@ -2038,12 +2277,7 @@ namespace MEDCoupling PyObject *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception) { - DataArrayInt *ret1=0; - DataArrayDouble *ret0=self->getFieldWithProfile(type,meshDimRelToMax,mesh,ret1); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; + return MEDFileField1TS_getFieldWithProfile(self,type,meshDimRelToMax,mesh); } PyObject *getFieldSplitedByType2(const std::string& mname=std::string()) const throw(INTERP_KERNEL::Exception) @@ -2090,29 +2324,7 @@ namespace MEDCoupling PyObject *getUndergroundDataArrayExt() const throw(INTERP_KERNEL::Exception) { - std::vector< std::pair,std::pair > > elt1Cpp; - DataArrayDouble *elt0=self->getUndergroundDataArrayExt(elt1Cpp); - if(elt0) - elt0->incrRef(); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(elt0),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 )); - std::size_t sz=elt1Cpp.size(); - PyObject *elt=PyList_New(sz); - for(std::size_t i=0;i(self); } } }; @@ -2122,12 +2334,20 @@ namespace MEDCoupling public: static MEDFileIntField1TS *New(); static MEDFileIntField1TS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileIntField1TS *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); static MEDFileIntField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); static MEDFileIntField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception); MEDCoupling::MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); // - void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception); - void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); + void setFieldNoProfileSBT(const MEDCouplingFieldInt *field) throw(INTERP_KERNEL::Exception); + void setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); + void copyTimeInfoFrom(MEDCouplingFieldInt *mcf) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldInt *field(const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldInt *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldInt *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldInt *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); %extend { MEDFileIntField1TS() throw(INTERP_KERNEL::Exception) @@ -2150,78 +2370,104 @@ namespace MEDCoupling return MEDFileIntField1TS::New(fileName,fieldName,iteration,order,loadAll); } + MEDFileIntField1TS(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileIntField1TS::New(db); + } + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } - PyObject *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception) + PyObject *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception) { - DataArrayInt *ret1=0; - MEDCouplingFieldDouble *ret0=self->getFieldAtLevel(type,meshDimRelToMax,ret1,renumPol); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return MEDFileField1TS_getFieldWithProfile(self,type,meshDimRelToMax,mesh); + } + + DataArrayInt *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *ret=self->getUndergroundDataArray(); + if(ret) + ret->incrRef(); return ret; } - PyObject *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception) + PyObject *getUndergroundDataArrayExt() const throw(INTERP_KERNEL::Exception) { - DataArrayInt *ret1=0; - MEDCouplingFieldDouble *ret0=self->getFieldAtTopLevel(type,ret1,renumPol); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; + return MEDFileField1TS_getUndergroundDataArrayExt(self); } + } + }; - PyObject *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception) + class MEDFileFloatField1TS : public MEDFileAnyTypeField1TS + { + public: + static MEDFileFloatField1TS *New(); + static MEDFileFloatField1TS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFloatField1TS *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); + static MEDFileFloatField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFloatField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception); + MEDCoupling::MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + // + void setFieldNoProfileSBT(const MEDCouplingFieldFloat *field) throw(INTERP_KERNEL::Exception); + void setFieldProfile(const MEDCouplingFieldFloat *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); + void copyTimeInfoFrom(MEDCouplingFieldFloat *mcf) throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *field(const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + %extend + { + MEDFileFloatField1TS() throw(INTERP_KERNEL::Exception) { - DataArrayInt *ret1=0; - MEDCouplingFieldDouble *ret0=self->getFieldOnMeshAtLevel(type,meshDimRelToMax,mesh,ret1,renumPol); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; + return MEDFileFloatField1TS::New(); } - - PyObject *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception) + + MEDFileFloatField1TS(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception) { - DataArrayInt *ret1=0; - MEDCouplingFieldDouble *ret0=self->getFieldOnMeshAtLevel(type,mesh,ret1,renumPol); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; + return MEDFileFloatField1TS::New(fileName,loadAll); } - - PyObject *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception) + + MEDFileFloatField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception) { - DataArrayInt *ret1=0; - MEDCouplingFieldDouble *ret0=self->getFieldAtLevelOld(type,mname,meshDimRelToMax,ret1,renumPol); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; + return MEDFileFloatField1TS::New(fileName,fieldName,loadAll); + } + + MEDFileFloatField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatField1TS::New(fileName,fieldName,iteration,order,loadAll); + } + + MEDFileFloatField1TS(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatField1TS::New(db); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); } PyObject *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception) { - DataArrayInt *ret1=0; - DataArrayInt *ret0=self->getFieldWithProfile(type,meshDimRelToMax,mesh,ret1); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; + return MEDFileField1TS_getFieldWithProfile(self,type,meshDimRelToMax,mesh); } - DataArrayInt *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception) + DataArrayFloat *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception) { - DataArrayInt *ret=self->getUndergroundDataArray(); + DataArrayFloat *ret=self->getUndergroundDataArray(); if(ret) ret->incrRef(); return ret; } + + PyObject *getUndergroundDataArrayExt() const throw(INTERP_KERNEL::Exception) + { + return MEDFileField1TS_getUndergroundDataArrayExt(self); + } } }; @@ -2244,7 +2490,7 @@ namespace MEDCoupling } }; - class MEDFileAnyTypeFieldMultiTS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable + class MEDFileAnyTypeFieldMultiTS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritableStandAlone { public: static MEDFileAnyTypeFieldMultiTS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); @@ -2264,7 +2510,6 @@ namespace MEDCoupling void eraseEmptyTS() throw(INTERP_KERNEL::Exception); int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception); int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception); - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); void loadArrays() throw(INTERP_KERNEL::Exception); void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); void unloadArrays() throw(INTERP_KERNEL::Exception); @@ -2319,17 +2564,8 @@ namespace MEDCoupling PyObject *getIterations() const throw(INTERP_KERNEL::Exception) { - std::vector< std::pair > res=self->getIterations(); - PyObject *ret=PyList_New(res.size()); - int rk=0; - for(std::vector< std::pair >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++) - { - PyObject *elt=PyTuple_New(2); - PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first)); - PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second)); - PyList_SetItem(ret,rk,elt); - } - return ret; + std::vector< std::pair > res(self->getIterations()); + return convertVecPairIntToPy(res); } PyObject *getTimeSteps() const throw(INTERP_KERNEL::Exception) @@ -2435,8 +2671,7 @@ namespace MEDCoupling if(PySlice_Check(elts)) { Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *oC=reinterpret_cast(elts); - GetIndicesOfSlice(oC,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__delitem__ : error in input slice !"); + GetIndicesOfSlice(elts,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__delitem__ : error in input slice !"); self->eraseTimeStepIds2(strt,stp,step); } else @@ -2454,7 +2689,7 @@ namespace MEDCoupling std::vector pos2; DataArrayInt *pos3=0; DataArrayIntTuple *pos4=0; - convertObjToPossibleCpp1(li,sw,pos1,pos2,pos3,pos4); + convertIntStarLikePyObjToCpp(li,sw,pos1,pos2,pos3,pos4); switch(sw) { case 1: @@ -2501,8 +2736,7 @@ namespace MEDCoupling else if(elt0 && PySlice_Check(elt0)) { Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *oC=reinterpret_cast(elt0); - GetIndicesOfSlice(oC,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__getitem__ : error in input slice !"); + GetIndicesOfSlice(elt0,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__getitem__ : error in input slice !"); return convertMEDFileFieldMultiTS(self->buildSubPartSlice(strt,stp,step),SWIG_POINTER_OWN | 0); } else @@ -2625,22 +2859,26 @@ namespace MEDCoupling } }; + class MEDFileIntFieldMultiTS; + class MEDFileFieldMultiTS : public MEDFileAnyTypeFieldMultiTS { public: static MEDFileFieldMultiTS *New() throw(INTERP_KERNEL::Exception); static MEDFileFieldMultiTS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); static MEDFileFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFieldMultiTS *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); // + MEDCouplingFieldDouble *field(int iteration, int order, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); // void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception); void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); - MEDCoupling::MEDFileIntFieldMultiTS *convertToInt(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + MEDFileIntFieldMultiTS *convertToInt(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); %extend { MEDFileFieldMultiTS() @@ -2657,6 +2895,11 @@ namespace MEDCoupling { return MEDFileFieldMultiTS::New(fileName,fieldName,loadAll); } + + MEDFileFieldMultiTS(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileFieldMultiTS::New(db); + } static MEDFileFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true) { @@ -2781,10 +3024,17 @@ namespace MEDCoupling static MEDFileIntFieldMultiTS *New(); static MEDFileIntFieldMultiTS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); static MEDFileIntFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileIntFieldMultiTS *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); // - void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception); - void appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); + void appendFieldNoProfileSBT(const MEDCouplingFieldInt *field) throw(INTERP_KERNEL::Exception); + void appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); MEDCoupling::MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldInt *field(int iteration, int order, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldInt *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldInt *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldInt *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); %extend { MEDFileIntFieldMultiTS() @@ -2802,16 +3052,15 @@ namespace MEDCoupling return MEDFileIntFieldMultiTS::New(fileName,fieldName,loadAll); } + MEDFileIntFieldMultiTS(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileIntFieldMultiTS::New(db); + } + static MEDFileIntFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true) { std::vector > tmp(convertTimePairIdsFromPy(entities)); - std::size_t sz(tmp.size()); - std::vector< std::pair > entitiesCpp(sz); - for(std::size_t i=0;i > entitiesCpp(convertVecPairIntToVecPairTOFCT(tmp)); return MEDFileIntFieldMultiTS::LoadSpecificEntities(fileName,fieldName,entitiesCpp,loadAll); } @@ -2820,89 +3069,138 @@ namespace MEDCoupling return self->simpleRepr(); } - PyObject *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception) + PyObject *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception) { - DataArrayInt *ret1=0; - MEDCouplingFieldDouble *ret0=self->getFieldAtLevel(type,iteration,order,meshDimRelToMax,ret1,renumPol); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; + DataArrayInt *ret1=0; + DataArrayInt *ret0=self->getFieldWithProfile(type,iteration,order,meshDimRelToMax,mesh,ret1); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; } - PyObject *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception) + DataArrayInt *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception) { - DataArrayInt *ret1=0; - MEDCouplingFieldDouble *ret0=self->getFieldAtTopLevel(type,iteration,order,ret1,renumPol); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + DataArrayInt *ret=self->getUndergroundDataArray(iteration,order); + if(ret) + ret->incrRef(); return ret; } + } + }; - PyObject *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception) + class MEDFileFloatFieldMultiTS : public MEDFileAnyTypeFieldMultiTS + { + public: + static MEDFileFloatFieldMultiTS *New(); + static MEDFileFloatFieldMultiTS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFloatFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFloatFieldMultiTS *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); + // + void appendFieldNoProfileSBT(const MEDCouplingFieldFloat *field) throw(INTERP_KERNEL::Exception); + void appendFieldProfile(const MEDCouplingFieldFloat *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); + MEDCoupling::MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *field(int iteration, int order, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldFloat *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + %extend + { + MEDFileFloatFieldMultiTS() { - DataArrayInt *ret1=0; - MEDCouplingFieldDouble *ret0=self->getFieldOnMeshAtLevel(type,iteration,order,meshDimRelToMax,mesh,ret1,renumPol); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; + return MEDFileFloatFieldMultiTS::New(); } - PyObject *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception) + MEDFileFloatFieldMultiTS(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception) { - DataArrayInt *ret1=0; - MEDCouplingFieldDouble *ret0=self->getFieldOnMeshAtLevel(type,iteration,order,mesh,ret1,renumPol); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; + return MEDFileFloatFieldMultiTS::New(fileName,loadAll); } - PyObject *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception) + MEDFileFloatFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception) { - DataArrayInt *ret1=0; - MEDCouplingFieldDouble *ret0=self->getFieldAtLevelOld(type,iteration,order,mname,meshDimRelToMax,ret1,renumPol); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; + return MEDFileFloatFieldMultiTS::New(fileName,fieldName,loadAll); + } + + MEDFileFloatFieldMultiTS(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileFloatFieldMultiTS::New(db); + } + + static MEDFileFloatFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, PyObject *entities, bool loadAll=true) + { + std::vector > tmp(convertTimePairIdsFromPy(entities)); + std::vector< std::pair > entitiesCpp(convertVecPairIntToVecPairTOFCT(tmp)); + return MEDFileFloatFieldMultiTS::LoadSpecificEntities(fileName,fieldName,entitiesCpp,loadAll); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); } PyObject *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception) { DataArrayInt *ret1=0; - DataArrayInt *ret0=self->getFieldWithProfile(type,iteration,order,meshDimRelToMax,mesh,ret1); + DataArrayFloat *ret0=self->getFieldWithProfile(type,iteration,order,meshDimRelToMax,mesh,ret1); PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayFloat, SWIG_POINTER_OWN | 0 )); PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); return ret; } - DataArrayInt *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception) + DataArrayFloat *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception) { - DataArrayInt *ret=self->getUndergroundDataArray(iteration,order); + DataArrayFloat *ret=self->getUndergroundDataArray(iteration,order); if(ret) ret->incrRef(); return ret; } } }; + + class MEDFileMeshSupports : public RefCountObject, public MEDFileWritableStandAlone + { + public: + static MEDFileMeshSupports *New(const std::string& fileName) throw(INTERP_KERNEL::Exception); + std::vector getSupMeshNames() const throw(INTERP_KERNEL::Exception); + %extend + { + MEDFileUMesh *getSupMeshWithName(const std::string& name) const throw(INTERP_KERNEL::Exception) + { + const MEDFileUMesh *ret(self->getSupMeshWithName(name)); + MEDFileUMesh *ret2(const_cast(ret)); + if(ret2) + ret2->incrRef(); + return ret2; + } + } + }; + + class MEDFileStructureElements : public RefCountObject, public MEDFileWritableStandAlone + { + public: + static MEDFileStructureElements *New(const std::string& fileName, const MEDFileMeshSupports *ms) throw(INTERP_KERNEL::Exception); + private: + MEDFileStructureElements(); + }; - class MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable + class MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritableStandAlone { public: static MEDFileFields *New() throw(INTERP_KERNEL::Exception); static MEDFileFields *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFields *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); + static MEDFileFields *NewAdv(const std::string& fileName, bool loadAll, const MEDFileEntities *entities) throw(INTERP_KERNEL::Exception); static MEDFileFields *LoadPartOf(const std::string& fileName, bool loadAll=true, const MEDFileMeshes *ms=0) throw(INTERP_KERNEL::Exception); + static MEDFileFields *NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll=true) throw(INTERP_KERNEL::Exception); MEDFileFields *deepCopy() const throw(INTERP_KERNEL::Exception); MEDFileFields *shallowCpy() const throw(INTERP_KERNEL::Exception); void loadArrays() throw(INTERP_KERNEL::Exception); void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); void unloadArrays() throw(INTERP_KERNEL::Exception); void unloadArraysWithoutDataLoss() throw(INTERP_KERNEL::Exception); - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); int getNumberOfFields() const; std::vector getFieldsNames() const throw(INTERP_KERNEL::Exception); std::vector getMeshesNames() const throw(INTERP_KERNEL::Exception); @@ -2914,6 +3212,12 @@ namespace MEDCoupling MEDFileAnyTypeFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception); MEDFileAnyTypeFieldMultiTS *getFieldWithName(const std::string& fieldName) const throw(INTERP_KERNEL::Exception); MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const throw(INTERP_KERNEL::Exception); + bool presenceOfStructureElements() const throw(INTERP_KERNEL::Exception); + void aggregate(const MEDFileFields& other) throw(INTERP_KERNEL::Exception); + void killStructureElements() throw(INTERP_KERNEL::Exception); + void keepOnlyStructureElements() throw(INTERP_KERNEL::Exception); + void keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName) throw(INTERP_KERNEL::Exception); + void blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses) throw(INTERP_KERNEL::Exception); void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception); bool removeFieldsWithoutAnyTimeStep() throw(INTERP_KERNEL::Exception); %extend @@ -2927,12 +3231,34 @@ namespace MEDCoupling { return MEDFileFields::New(fileName,loadAll); } + + MEDFileFields(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileFields::New(db); + } + + MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileEntities *entities) throw(INTERP_KERNEL::Exception) + { + return MEDFileFields::NewAdv(fileName,loadAll,entities); + } std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } + + MEDFileFields *partOfThisOnStructureElements() const throw(INTERP_KERNEL::Exception) + { + MCAuto ret(self->partOfThisOnStructureElements()); + return ret.retn(); + } + MEDFileFields *partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const throw(INTERP_KERNEL::Exception) + { + MCAuto ret(self->partOfThisLyingOnSpecifiedMeshSEName(meshName,seName)); + return ret.retn(); + } + static MEDFileFields *LoadSpecificEntities(const std::string& fileName, PyObject *entities, bool loadAll=true) throw(INTERP_KERNEL::Exception) { std::vector > tmp(convertTimePairIdsFromPy(entities)); @@ -2946,6 +3272,13 @@ namespace MEDCoupling return MEDFileFields::LoadSpecificEntities(fileName,entitiesCpp,loadAll); } + PyObject *getMeshSENames() const throw(INTERP_KERNEL::Exception) + { + std::vector< std::pair > ps; + self->getMeshSENames(ps); + return convertVectPairStToPy(ps); + } + PyObject *getCommonIterations() const throw(INTERP_KERNEL::Exception) { bool ret1; @@ -3020,14 +3353,14 @@ namespace MEDCoupling int getPosOfField(PyObject *elt0) const throw(INTERP_KERNEL::Exception) { - if(elt0 && PyInt_Check(elt0)) + static const char msg[]="MEDFileFields::getPosOfField : invalid input params ! expected fields[int], fields[string_of_field_name] !"; + if(!elt0) + throw INTERP_KERNEL::Exception(msg); + if(PyInt_Check(elt0)) {//fmts[3] return PyInt_AS_LONG(elt0); } - else if(elt0 && PyString_Check(elt0)) - return self->getPosFromFieldName(PyString_AsString(elt0)); - else - throw INTERP_KERNEL::Exception("MEDFileFields::getPosOfField : invalid input params ! expected fields[int], fields[string_of_field_name] !"); + return self->getPosFromFieldName(convertPyObjectToStr(elt0,msg)); } std::vector getPosOfFields(PyObject *elts) const throw(INTERP_KERNEL::Exception) @@ -3063,8 +3396,7 @@ namespace MEDCoupling if(elts && PySlice_Check(elts)) { Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *oC=reinterpret_cast(elts); - GetIndicesOfSlice(oC,self->getNumberOfFields(),&strt,&stp,&step,"MEDFileFields.__delitem__ : error in input slice !"); + GetIndicesOfSlice(elts,self->getNumberOfFields(),&strt,&stp,&step,"MEDFileFields.__delitem__ : error in input slice !"); self->destroyFieldsAtPos2(strt,stp,step); } else @@ -3081,6 +3413,12 @@ namespace MEDCoupling convertToMapIntDataArrayInt(extractDef,extractDefCpp); return self->extractPart(extractDefCpp,mm); } + + MEDFileFields *linearToQuadratic(const MEDFileMeshes *oldLin, const MEDFileMeshes *newQuad) const throw(INTERP_KERNEL::Exception) + { + MCAuto ret(self->linearToQuadratic(oldLin,newQuad)); + return ret.retn(); + } } }; @@ -3231,7 +3569,7 @@ namespace MEDCoupling std::vector pos2; DataArrayInt *pos3=0; DataArrayIntTuple *pos4=0; - convertObjToPossibleCpp1(ids,sw,pos1,pos2,pos3,pos4); + convertIntStarLikePyObjToCpp(ids,sw,pos1,pos2,pos3,pos4); switch(sw) { case 1: @@ -3368,13 +3706,13 @@ namespace MEDCoupling } }; - class MEDFileParameters : public RefCountObject, public MEDFileWritable + class MEDFileParameters : public RefCountObject, public MEDFileWritableStandAlone { public: static MEDFileParameters *New(); static MEDFileParameters *New(const std::string& fileName) throw(INTERP_KERNEL::Exception); + static MEDFileParameters *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); MEDFileParameters *deepCopy() const throw(INTERP_KERNEL::Exception); - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); std::vector getParamsNames() const throw(INTERP_KERNEL::Exception); std::string simpleRepr() const throw(INTERP_KERNEL::Exception); void resize(int newSize) throw(INTERP_KERNEL::Exception); @@ -3395,6 +3733,11 @@ namespace MEDCoupling return MEDFileParameters::New(fileName); } + MEDFileParameters(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileParameters::New(db); + } + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); @@ -3402,6 +3745,7 @@ namespace MEDCoupling MEDFileParameterMultiTS *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) { + static const char msg[]="MEDFileParameters::__getitem__ : only integer or string with meshname supported !"; if(PyInt_Check(obj)) { MEDFileParameterMultiTS *ret=self->getParamAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfParams())); @@ -3409,15 +3753,10 @@ namespace MEDCoupling ret->incrRef(); return ret; } - else if(PyString_Check(obj)) - { - MEDFileParameterMultiTS *ret=self->getParamWithName(PyString_AsString(obj)); - if(ret) - ret->incrRef(); - return ret; - } - else - throw INTERP_KERNEL::Exception("MEDFileParameters::__getitem__ : only integer or string with meshname supported !"); + MEDFileParameterMultiTS *ret(self->getParamWithName(convertPyObjectToStr(obj,msg))); + if(ret) + ret->incrRef(); + return ret; } int __len__() const throw(INTERP_KERNEL::Exception) @@ -3455,9 +3794,10 @@ namespace MEDCoupling } }; - class MEDFileData : public RefCountObject, public MEDFileWritable + class MEDFileData : public RefCountObject, public MEDFileWritableStandAlone { public: + static MEDFileData *New(DataArrayByte *db) throw(INTERP_KERNEL::Exception); static MEDFileData *New(const std::string& fileName) throw(INTERP_KERNEL::Exception); static MEDFileData *New(); MEDFileData *deepCopy() const throw(INTERP_KERNEL::Exception); @@ -3470,8 +3810,10 @@ namespace MEDCoupling // bool changeMeshName(const std::string& oldMeshName, const std::string& newMeshName) throw(INTERP_KERNEL::Exception); bool unPolyzeMeshes() throw(INTERP_KERNEL::Exception); + void dealWithStructureElements() throw(INTERP_KERNEL::Exception); + std::string getHeader() const throw(INTERP_KERNEL::Exception); + void setHeader(const std::string& header) throw(INTERP_KERNEL::Exception); // - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); %extend { MEDFileData(const std::string& fileName) throw(INTERP_KERNEL::Exception) @@ -3479,6 +3821,11 @@ namespace MEDCoupling return MEDFileData::New(fileName); } + MEDFileData(DataArrayByte *db) throw(INTERP_KERNEL::Exception) + { + return MEDFileData::New(db); + } + MEDFileData() { return MEDFileData::New(); @@ -3518,6 +3865,14 @@ namespace MEDCoupling std::vector< std::pair > modifTab=convertVecPairStStFromPy(li); return self->changeMeshNames(modifTab); } + + static MEDFileData *Aggregate(PyObject *mfds) throw(INTERP_KERNEL::Exception) + { + std::vector mfdsCpp; + convertFromPyObjVectorOfObj(mfds,SWIGTYPE_p_MEDCoupling__MEDFileData,"MEDFileData",mfdsCpp); + MCAuto ret(MEDFileData::Aggregate(mfdsCpp)); + return ret.retn(); + } } };