X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FSwig%2FMEDLoaderCommon.i;h=b4132f8ca797f04b315fb2a235cbd9b131525f8f;hb=1ca2b215a1ae474745fabc87dd9c5c98e9af6354;hp=84736406eca3009836b1f36018ad5f4b876a9ddb;hpb=887d0e1efce4f46f68d2596dcd801f02f5c1f99e;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 84736406e..b4132f8ca 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2012 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 // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,9 +27,13 @@ %{ #include "MEDLoader.hxx" +#include "MEDFileJoint.hxx" #include "MEDFileMesh.hxx" #include "MEDFileField.hxx" +#include "MEDFileParameter.hxx" #include "MEDFileData.hxx" +#include "MEDFileMeshReadSelector.hxx" +#include "MEDFileFieldOverView.hxx" #include "MEDLoaderTypemaps.i" #include "SauvReader.hxx" #include "SauvWriter.hxx" @@ -46,15 +50,37 @@ using namespace ParaMEDMEM; $result=convertMEDFileMesh($1,$owner); } +%typemap(out) ParaMEDMEM::MEDFileParameter1TS* +{ + $result=convertMEDFileParameter1TS($1,$owner); +} + +%typemap(out) ParaMEDMEM::MEDFileAnyTypeFieldMultiTS* +{ + $result=convertMEDFileFieldMultiTS($1,$owner); +} + +%typemap(out) ParaMEDMEM::MEDFileAnyTypeField1TS* +{ + $result=convertMEDFileField1TS($1,$owner); +} + +%typemap(out) ParaMEDMEM::MEDMeshMultiLev* +{ + $result=convertMEDMeshMultiLev($1,$owner); +} + %newobject MEDLoader::ReadUMeshFromFamilies; %newobject MEDLoader::ReadUMeshFromGroups; %newobject MEDLoader::ReadUMeshFromFile; +%newobject MEDLoader::ReadMeshFromFile; %newobject MEDLoader::ReadField; %newobject MEDLoader::ReadFieldCell; %newobject MEDLoader::ReadFieldNode; %newobject MEDLoader::ReadFieldGauss; %newobject MEDLoader::ReadFieldGaussNE; %newobject ParaMEDMEM::MEDFileMesh::New; +%newobject ParaMEDMEM::MEDFileMesh::createNewEmpty; %newobject ParaMEDMEM::MEDFileMesh::deepCpy; %newobject ParaMEDMEM::MEDFileMesh::shallowCpy; %newobject ParaMEDMEM::MEDFileMesh::getGenMeshAtLevel; @@ -67,8 +93,13 @@ using namespace ParaMEDMEM; %newobject ParaMEDMEM::MEDFileMesh::getNodeFamilyArr; %newobject ParaMEDMEM::MEDFileMesh::getNodeFamiliesArr; %newobject ParaMEDMEM::MEDFileMesh::getAllFamiliesIdsReferenced; +%newobject ParaMEDMEM::MEDFileMesh::computeAllFamilyIdsInUse; +%newobject ParaMEDMEM::MEDFileData::getJoints; +%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; @@ -78,7 +109,14 @@ using namespace ParaMEDMEM; %newobject ParaMEDMEM::MEDFileUMesh::getLevelM1Mesh; %newobject ParaMEDMEM::MEDFileUMesh::getLevelM2Mesh; %newobject ParaMEDMEM::MEDFileUMesh::getLevelM3Mesh; +%newobject ParaMEDMEM::MEDFileUMesh::getDirectUndergroundSingleGeoTypeMesh; +%newobject ParaMEDMEM::MEDFileUMesh::extractFamilyFieldOnGeoType; +%newobject ParaMEDMEM::MEDFileUMesh::extractNumberFieldOnGeoType; %newobject ParaMEDMEM::MEDFileUMesh::zipCoords; +%newobject ParaMEDMEM::MEDFileUMesh::buildExtrudedMesh; +%newobject ParaMEDMEM::MEDFileUMesh::__getitem__; +%newobject ParaMEDMEM::MEDFileUMesh::linearToQuadratic; +%newobject ParaMEDMEM::MEDFileUMesh::quadraticToLinear; %newobject ParaMEDMEM::MEDFileCMesh::New; %newobject ParaMEDMEM::MEDFileCurveLinearMesh::New; %newobject ParaMEDMEM::MEDFileMeshMultiTS::New; @@ -92,75 +130,162 @@ using namespace ParaMEDMEM; %newobject ParaMEDMEM::MEDFileMeshes::__iter__; %newobject ParaMEDMEM::MEDFileFields::New; +%newobject ParaMEDMEM::MEDFileFields::LoadPartOf; +%newobject ParaMEDMEM::MEDFileFields::LoadSpecificEntities; %newobject ParaMEDMEM::MEDFileFields::deepCpy; +%newobject ParaMEDMEM::MEDFileFields::shallowCpy; %newobject ParaMEDMEM::MEDFileFields::getFieldWithName; %newobject ParaMEDMEM::MEDFileFields::getFieldAtPos; -%newobject ParaMEDMEM::MEDFileFields::__getitem__; +%newobject ParaMEDMEM::MEDFileFields::partOfThisLyingOnSpecifiedMeshName; +%newobject ParaMEDMEM::MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps; +%newobject ParaMEDMEM::MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps; %newobject ParaMEDMEM::MEDFileFields::__iter__; + +%newobject ParaMEDMEM::MEDFileAnyTypeFieldMultiTS::New; +%newobject ParaMEDMEM::MEDFileAnyTypeFieldMultiTS::deepCpy; +%newobject ParaMEDMEM::MEDFileAnyTypeFieldMultiTS::shallowCpy; +%newobject ParaMEDMEM::MEDFileAnyTypeFieldMultiTS::getTimeStepAtPos; +%newobject ParaMEDMEM::MEDFileAnyTypeFieldMultiTS::getTimeStep; +%newobject ParaMEDMEM::MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime; +%newobject ParaMEDMEM::MEDFileAnyTypeFieldMultiTS::__iter__; %newobject ParaMEDMEM::MEDFileFieldMultiTS::New; -%newobject ParaMEDMEM::MEDFileFieldMultiTS::deepCpy; -%newobject ParaMEDMEM::MEDFileFieldMultiTS::getTimeStepAtPos; -%newobject ParaMEDMEM::MEDFileFieldMultiTS::getTimeStep; -%newobject ParaMEDMEM::MEDFileFieldMultiTS::getTimeStepGivenTime; -%newobject ParaMEDMEM::MEDFileFieldMultiTS::__getitem__; -%newobject ParaMEDMEM::MEDFileFieldMultiTS::__iter__; +%newobject ParaMEDMEM::MEDFileFieldMultiTS::LoadSpecificEntities; %newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtLevel; %newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtTopLevel; %newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldOnMeshAtLevel; %newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtLevelOld; %newobject ParaMEDMEM::MEDFileFieldMultiTS::getUndergroundDataArray; +%newobject ParaMEDMEM::MEDFileFieldMultiTS::convertToInt; +%newobject ParaMEDMEM::MEDFileIntFieldMultiTS::New; +%newobject ParaMEDMEM::MEDFileIntFieldMultiTS::LoadSpecificEntities; +%newobject ParaMEDMEM::MEDFileIntFieldMultiTS::getUndergroundDataArray; +%newobject ParaMEDMEM::MEDFileIntFieldMultiTS::convertToDouble; + +%newobject ParaMEDMEM::MEDFileAnyTypeField1TS::New; +%newobject ParaMEDMEM::MEDFileAnyTypeField1TS::shallowCpy; +%newobject ParaMEDMEM::MEDFileAnyTypeField1TS::deepCpy; %newobject ParaMEDMEM::MEDFileField1TS::New; -%newobject ParaMEDMEM::MEDFileField1TS::deepCpy; %newobject ParaMEDMEM::MEDFileField1TS::getFieldAtLevel; %newobject ParaMEDMEM::MEDFileField1TS::getFieldAtTopLevel; %newobject ParaMEDMEM::MEDFileField1TS::getFieldOnMeshAtLevel; %newobject ParaMEDMEM::MEDFileField1TS::getFieldAtLevelOld; %newobject ParaMEDMEM::MEDFileField1TS::getUndergroundDataArray; +%newobject ParaMEDMEM::MEDFileField1TS::convertToInt; +%newobject ParaMEDMEM::MEDFileIntField1TS::New; +%newobject ParaMEDMEM::MEDFileIntField1TS::getUndergroundDataArray; +%newobject ParaMEDMEM::MEDFileIntField1TS::convertToDouble; %newobject ParaMEDMEM::MEDFileData::New; %newobject ParaMEDMEM::MEDFileData::deepCpy; %newobject ParaMEDMEM::MEDFileData::getMeshes; %newobject ParaMEDMEM::MEDFileData::getFields; +%newobject ParaMEDMEM::MEDFileData::getParams; + +%newobject ParaMEDMEM::MEDFileParameterDouble1TS::New; +%newobject ParaMEDMEM::MEDFileParameterDouble1TS::deepCpy; +%newobject ParaMEDMEM::MEDFileParameterMultiTS::New; +%newobject ParaMEDMEM::MEDFileParameterMultiTS::deepCpy; +%newobject ParaMEDMEM::MEDFileParameterMultiTS::getTimeStepAtPos; +%newobject ParaMEDMEM::MEDFileParameterMultiTS::__getitem__; +%newobject ParaMEDMEM::MEDFileParameters::New; +%newobject ParaMEDMEM::MEDFileParameters::deepCpy; +%newobject ParaMEDMEM::MEDFileParameters::getParamAtPos; +%newobject ParaMEDMEM::MEDFileParameters::getParamWithName; +%newobject ParaMEDMEM::MEDFileParameters::__getitem__; + +%newobject ParaMEDMEM::MEDFileJointCorrespondence::New; +%newobject ParaMEDMEM::MEDFileJointCorrespondence::deepCpy; +%newobject ParaMEDMEM::MEDFileJointCorrespondence::shallowCpy; +%newobject ParaMEDMEM::MEDFileJointOneStep::New; +%newobject ParaMEDMEM::MEDFileJointOneStep::deepCpy; +%newobject ParaMEDMEM::MEDFileJointOneStep::shallowCpy; +%newobject ParaMEDMEM::MEDFileJoint::New; +%newobject ParaMEDMEM::MEDFileJoint::deepCpy; +%newobject ParaMEDMEM::MEDFileJoint::shallowCpy; +%newobject ParaMEDMEM::MEDFileJoints::New; +%newobject ParaMEDMEM::MEDFileJoints::deepCpy; +%newobject ParaMEDMEM::MEDFileJoints::getJointAtPos; +%newobject ParaMEDMEM::MEDFileJoints::getJointWithName; +%newobject ParaMEDMEM::MEDFileJoints::__getitem__; %newobject ParaMEDMEM::SauvWriter::New; %newobject ParaMEDMEM::SauvReader::New; %newobject ParaMEDMEM::SauvReader::loadInMEDFileDS; +%newobject ParaMEDMEM::MEDFileMeshStruct::New; +%newobject ParaMEDMEM::MEDMeshMultiLev::prepare; +%newobject ParaMEDMEM::MEDMeshMultiLev::buildDataArray; +%newobject ParaMEDMEM::MEDFileFastCellSupportComparator::New; +%newobject ParaMEDMEM::MEDFileFastCellSupportComparator::buildFromScratchDataSetSupport; + %feature("unref") MEDFileMesh "$this->decrRef();" %feature("unref") MEDFileUMesh "$this->decrRef();" %feature("unref") MEDFileCMesh "$this->decrRef();" %feature("unref") MEDFileMeshMultiTS "$this->decrRef();" %feature("unref") MEDFileMeshes "$this->decrRef();" %feature("unref") MEDFileFieldLoc "$this->decrRef();" +%feature("unref") MEDFileAnyTypeField1TS "$this->decrRef();" %feature("unref") MEDFileField1TS "$this->decrRef();" +%feature("unref") MEDFileIntField1TS "$this->decrRef();" +%feature("unref") MEDFileAnyTypeFieldMultiTS "$this->decrRef();" %feature("unref") MEDFileFieldMultiTS "$this->decrRef();" +%feature("unref") MEDFileIntFieldMultiTS "$this->decrRef();" %feature("unref") MEDFileFields "$this->decrRef();" +%feature("unref") MEDFileParameter1TS "$this->decrRef();" +%feature("unref") MEDFileParameterDouble1TSWTI "$this->decrRef();" +%feature("unref") MEDFileParameterDouble1TS "$this->decrRef();" +%feature("unref") MEDFileParameterMultiTS "$this->decrRef();" +%feature("unref") MEDFileParameters "$this->decrRef();" +%feature("unref") MEDFileJointCorrespondence "$this->decrRef();" +%feature("unref") MEDFileJointOneStep "$this->decrRef();" +%feature("unref") MEDFileJoint "$this->decrRef();" +%feature("unref") MEDFileJoints "$this->decrRef();" %feature("unref") MEDFileData "$this->decrRef();" %feature("unref") SauvReader "$this->decrRef();" %feature("unref") SauvWriter "$this->decrRef();" +%feature("unref") MEDFileFastCellSupportComparator "$this->decrRef();" +%feature("unref") MEDMeshMultiLev "$this->decrRef();" +%feature("unref") MEDUMeshMultiLev "$this->decrRef();" +%feature("unref") MEDCMeshMultiLev "$this->decrRef();" +%feature("unref") MEDCurveLinearMeshMultiLev "$this->decrRef();" +%feature("unref") MEDFileMeshStruct "$this->decrRef();" class MEDLoader { public: - static void setEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception); - static void setCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception); - static void setTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception); - static void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception); - static std::vector GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception); - static std::vector GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception); - static std::vector GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetMeshFamiliesNamesOnGroup(const char *fileName, const char *meshName, const char *grpName) throw(INTERP_KERNEL::Exception); - static std::vector GetMeshGroupsNamesOnFamily(const char *fileName, const char *meshName, const char *famName) throw(INTERP_KERNEL::Exception); - static std::vector GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetAllFieldNames(const char *fileName) throw(INTERP_KERNEL::Exception); - static std::vector GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetCellFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static std::vector GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static double GetTimeAttachedOnFieldIteration(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); + static bool HasXDR(); + static std::string MEDFileVersionStr(); + static void SetEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception); + static void SetCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception); + static void SetTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception); + static void CheckFileForRead(const std::string& fileName) throw(INTERP_KERNEL::Exception); + static std::vector GetMeshNames(const std::string& fileName) throw(INTERP_KERNEL::Exception); + static std::vector GetMeshNamesOnField(const std::string& fileName, const std::string& fieldName) throw(INTERP_KERNEL::Exception); + static std::vector GetMeshGroupsNames(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception); + static std::vector GetMeshFamiliesNames(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception); + static std::vector GetMeshFamiliesNamesOnGroup(const std::string& fileName, const std::string& meshName, const std::string& grpName) throw(INTERP_KERNEL::Exception); + static std::vector GetMeshGroupsNamesOnFamily(const std::string& fileName, const std::string& meshName, const std::string& famName) throw(INTERP_KERNEL::Exception); + static std::vector GetAllFieldNamesOnMesh(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception); + static std::vector GetAllFieldNames(const std::string& fileName) throw(INTERP_KERNEL::Exception); + static std::vector GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception); + static std::vector GetCellFieldNamesOnMesh(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception); + static std::vector GetNodeFieldNamesOnMesh(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception); + static double GetTimeAttachedOnFieldIteration(const std::string& fileName, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); + static void AssignStaticWritePropertiesTo(ParaMEDMEM::MEDFileWritable& obj) throw(INTERP_KERNEL::Exception); %extend { - static PyObject *GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception) + static PyObject *MEDFileVersion() + { + int major,minor,release; + MEDLoader::MEDFileVersion(major,minor,release); + PyObject *ret(PyTuple_New(3)); + PyTuple_SetItem(ret,0,SWIG_From_int(major)); + PyTuple_SetItem(ret,1,SWIG_From_int(minor)); + PyTuple_SetItem(ret,2,SWIG_From_int(release)); + return ret; + } + + static PyObject *GetFieldIterations(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName, const std::string& fieldName) throw(INTERP_KERNEL::Exception) { std::vector< std::pair > res=MEDLoader::GetFieldIterations(type,fileName,meshName,fieldName); PyObject *ret=PyList_New(res.size()); @@ -175,9 +300,9 @@ public: return ret; } - static PyObject *GetAllFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception) + static PyObject *GetAllFieldIterations(const std::string& fileName, const std::string& fieldName) throw(INTERP_KERNEL::Exception) { - std::vector< std::pair< std::pair, double> > res=MEDLoader::GetAllFieldIterations(fileName,meshName,fieldName); + std::vector< std::pair< std::pair, double> > res=MEDLoader::GetAllFieldIterations(fileName,fieldName); PyObject *ret=PyList_New(res.size()); int rk=0; for(std::vector< std::pair< std::pair, double> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++) @@ -191,7 +316,7 @@ public: return ret; } - static PyObject *GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception) + static PyObject *GetCellFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName) throw(INTERP_KERNEL::Exception) { std::vector< std::pair > res=MEDLoader::GetCellFieldIterations(fileName,meshName,fieldName); PyObject *ret=PyList_New(res.size()); @@ -205,7 +330,7 @@ public: } return ret; } - static PyObject *GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception) + static PyObject *GetNodeFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName) throw(INTERP_KERNEL::Exception) { std::vector< std::pair > res=MEDLoader::GetNodeFieldIterations(fileName,meshName,fieldName); PyObject *ret=PyList_New(res.size()); @@ -219,7 +344,7 @@ public: } return ret; } - static PyObject *GetComponentsNamesOfField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception) + static PyObject *GetComponentsNamesOfField(const std::string& fileName, const std::string& fieldName) throw(INTERP_KERNEL::Exception) { std::vector< std::pair > res=MEDLoader::GetComponentsNamesOfField(fileName,fieldName); PyObject *ret=PyList_New(res.size()); @@ -233,7 +358,7 @@ public: } return ret; } - static PyObject *GetUMeshGlobalInfo(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception) + static PyObject *GetUMeshGlobalInfo(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception) { int meshDim,spaceDim,numberOfNodes; std::vector< std::vector< std::pair > > res=MEDLoader::GetUMeshGlobalInfo(fileName,meshName,meshDim,spaceDim,numberOfNodes); @@ -260,32 +385,32 @@ public: PyTuple_SetItem(ret,3,SWIG_From_int(numberOfNodes)); return ret; } - static PyObject *ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, - const char *fieldName, PyObject *liIts) throw(INTERP_KERNEL::Exception) + static PyObject *ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, + const std::string& fieldName, PyObject *liIts) throw(INTERP_KERNEL::Exception) { std::vector > its=convertTimePairIdsFromPy(liIts); std::vector res=MEDLoader::ReadFieldsOnSameMesh(type,fileName,meshName,meshDimRelToMax,fieldName,its); return convertFieldDoubleVecToPy(res); } - static void WriteUMeshesPartition(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception) + static void WriteUMeshesPartition(const std::string& fileName, const std::string& meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception) { std::vector v; convertFromPyObjVectorOfObj(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,"MEDCouplingUMesh",v); MEDLoader::WriteUMeshesPartition(fileName,meshName,v,writeFromScratch); } - static void WriteUMeshesPartitionDep(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception) + static void WriteUMeshesPartitionDep(const std::string& fileName, const std::string& meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception) { std::vector v; convertFromPyObjVectorOfObj(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,"MEDCouplingUMesh",v); MEDLoader::WriteUMeshesPartitionDep(fileName,meshName,v,writeFromScratch); } - static void WriteUMeshes(const char *fileName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception) + static void WriteUMeshes(const std::string& fileName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception) { std::vector v; convertFromPyObjVectorOfObj(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,"MEDCouplingUMesh",v); MEDLoader::WriteUMeshes(fileName,v,writeFromScratch); } - static PyObject *GetTypesOfField(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception) + static PyObject *GetTypesOfField(const std::string& fileName, const std::string& meshName, const std::string& fieldName) throw(INTERP_KERNEL::Exception) { std::vector< ParaMEDMEM::TypeOfField > v=MEDLoader::GetTypesOfField(fileName,meshName,fieldName); int size=v.size(); @@ -294,32 +419,35 @@ public: PyList_SetItem(ret,i,PyInt_FromLong((int)v[i])); return ret; } - static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, PyObject *li) throw(INTERP_KERNEL::Exception) + static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, PyObject *li) throw(INTERP_KERNEL::Exception) { std::vector grps; converPyListToVecString(li,grps); return MEDLoader::ReadUMeshFromGroups(fileName,meshName,meshDimRelToMax,grps); } - static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, PyObject *li) throw(INTERP_KERNEL::Exception) + static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, PyObject *li) throw(INTERP_KERNEL::Exception) { std::vector fams; converPyListToVecString(li,fams); return MEDLoader::ReadUMeshFromFamilies(fileName,meshName,meshDimRelToMax,fams); } } - static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); - static int ReadUMeshDimFromFile(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadField(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - static void WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - static void WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception); + static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const std::string& fileName, const std::string& meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); + static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const std::string& fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); + static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const std::string& fileName, const std::string& meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); + static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const std::string& fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); + static int ReadUMeshDimFromFile(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception); + static ParaMEDMEM::MEDCouplingFieldDouble *ReadField(ParaMEDMEM::TypeOfField type, const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); + static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); + static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); + static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); + static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); + static void WriteMesh(const std::string& fileName, const ParaMEDMEM::MEDCouplingMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception); + static void WriteUMesh(const std::string& fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception); + static void WriteUMeshDep(const std::string& fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception); + static void WriteField(const std::string& fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); + static void WriteFieldDep(const std::string& fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); + static void WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception); }; namespace ParaMEDMEM @@ -334,20 +462,260 @@ namespace ParaMEDMEM void setZipConnPolicy(int newVal) throw(INTERP_KERNEL::Exception); }; + class MEDFileMeshReadSelector + { + public: + MEDFileMeshReadSelector(); + MEDFileMeshReadSelector(unsigned int code); + unsigned int getCode() const; + void setCode(unsigned int newCode); + bool isCellFamilyFieldReading() const; + bool isNodeFamilyFieldReading() const; + bool isCellNameFieldReading() const; + bool isNodeNameFieldReading() const; + bool isCellNumFieldReading() const; + bool isNodeNumFieldReading() 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); + %extend + { + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + std::ostringstream oss; + self->reprAll(oss); + return oss.str(); + } + + std::string __repr__() const throw(INTERP_KERNEL::Exception) + { + std::ostringstream oss; oss << "MEDFileMeshReadSelector C++ instance at " << self << " (with code=" << self->getCode() << ")."; + return oss.str(); + } + } + }; + class MEDFileJointCorrespondence : public RefCountObject, public MEDFileWritable + { + public: + static MEDFileJointCorrespondence *New() throw(INTERP_KERNEL::Exception); + static MEDFileJointCorrespondence *New(DataArrayInt* correspondence) // nodes + throw(INTERP_KERNEL::Exception); + static MEDFileJointCorrespondence *New(DataArrayInt* correspondence, // cells + INTERP_KERNEL::NormalizedCellType loc_geo_type, + INTERP_KERNEL::NormalizedCellType rem_geo_type) + throw(INTERP_KERNEL::Exception); + std::vector getDirectChildrenWithNull() const; + MEDFileJointCorrespondence *deepCpy() const; + MEDFileJointCorrespondence *shallowCpy() const; + void setIsNodal(bool isNodal); + bool getIsNodal() const; + bool isEqual(const MEDFileJointCorrespondence *other) const; + void setLocalGeometryType(INTERP_KERNEL::NormalizedCellType type); + INTERP_KERNEL::NormalizedCellType getLocalGeometryType() const; + 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 + { + MEDFileJointCorrespondence() + { + return MEDFileJointCorrespondence::New(); + } + MEDFileJointCorrespondence(DataArrayInt* correspondence) throw(INTERP_KERNEL::Exception) + { + return MEDFileJointCorrespondence::New(correspondence); + } + MEDFileJointCorrespondence(DataArrayInt* correspondence, // cells + INTERP_KERNEL::NormalizedCellType loc_geo_type, + INTERP_KERNEL::NormalizedCellType rem_geo_type) throw(INTERP_KERNEL::Exception) + { + return MEDFileJointCorrespondence::New(correspondence, loc_geo_type, rem_geo_type); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); + } + } + }; + + class MEDFileJointOneStep : public RefCountObject, public MEDFileWritable + { + public: + static MEDFileJointOneStep *New(int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception); + static MEDFileJointOneStep *New(const std::string& fileName, const std::string& mName, const std::string& jointName, int number=1) throw(INTERP_KERNEL::Exception); + MEDFileJointOneStep *deepCpy() const; + MEDFileJointOneStep *shallowCpy() const; + bool isEqual(const MEDFileJointOneStep *other) const; + void setOrder(int order); + int getOrder() const; + void setIteration(int it); + 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 + { + MEDFileJointOneStep() + { + return MEDFileJointOneStep::New(); + } + + MEDFileJointOneStep(const std::string& fileName, const std::string& mName, const std::string& jointName, int number) throw(INTERP_KERNEL::Exception) + { + return MEDFileJointOneStep::New(fileName,mName,jointName,number); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); + } + } + }; + class MEDFileJoint : public RefCountObject, public MEDFileWritable + { + 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); + MEDFileJoint *deepCpy() const; + MEDFileJoint *shallowCpy() const; + bool isEqual(const MEDFileJoint *other) const; + void setLocalMeshName(const std::string& name); + std::string getLocalMeshName() const; + void setRemoteMeshName(const std::string& name); + std::string getRemoteMeshName() const; + void setDescription(const std::string& name); + std::string getDescription() const; + void setJointName(const std::string& name); + std::string getJointName() const; + bool changeJointNames(const std::vector< std::pair >& modifTab) throw(INTERP_KERNEL::Exception); + void setDomainNumber(const int& number); + 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 + { + MEDFileJoint() + { + return MEDFileJoint::New(); + } + + MEDFileJoint(const std::string& fileName, const std::string& mName, int num) throw(INTERP_KERNEL::Exception) + { + return MEDFileJoint::New(fileName,mName,num); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); + } + } + }; + + class MEDFileJoints : public RefCountObject, public MEDFileWritable + { + public: + static MEDFileJoints *New() throw(INTERP_KERNEL::Exception); + static MEDFileJoints *New(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception); + MEDFileJoints *deepCpy() 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; + bool changeJointNames(const std::vector< std::pair >& modifTab) throw(INTERP_KERNEL::Exception); + void resize(int newSize) throw(INTERP_KERNEL::Exception); + void pushJoint(MEDFileJoint *joint); + void setJointAtPos(int i, MEDFileJoint *joint) throw(INTERP_KERNEL::Exception); + void destroyJointAtPos(int i) throw(INTERP_KERNEL::Exception); + %extend + { + MEDFileJoints() + { + return MEDFileJoints::New(); + } + + MEDFileJoints(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception) + { + return MEDFileJoints::New(fileName,meshName); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); + } + + MEDFileJoint *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + if(PyInt_Check(obj)) + { + MEDFileJoint *ret=self->getJointAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfJoints())); + if(ret) + 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 !"); + } + + int __len__() const throw(INTERP_KERNEL::Exception) + { + return self->getNumberOfJoints(); + } + + MEDFileJoint *getJointAtPos(int i) const throw(INTERP_KERNEL::Exception) + { + MEDFileJoint *ret=self->getJointAtPos(i); + if(ret) + ret->incrRef(); + return ret; + } + + MEDFileJoint *getJointWithName(const std::string& paramName) const throw(INTERP_KERNEL::Exception) + { + MEDFileJoint *ret=self->getJointWithName(paramName); + if(ret) + ret->incrRef(); + return ret; + } + } + }; + class MEDFileMesh : public RefCountObject, public MEDFileWritable { public: - static MEDFileMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception); - static MEDFileMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1); + 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); + virtual MEDFileMesh *createNewEmpty() const throw(INTERP_KERNEL::Exception); virtual MEDFileMesh *deepCpy() const throw(INTERP_KERNEL::Exception); virtual MEDFileMesh *shallowCpy() const throw(INTERP_KERNEL::Exception); - virtual void clearNonDiscrAttributes() const; - void setName(const char *name); - const char *getName(); - void setUnivName(const char *name); - const char *getUnivName() const; - void setDescription(const char *name); - const char *getDescription() const; + virtual void clearNonDiscrAttributes() const throw(INTERP_KERNEL::Exception); + void setName(const std::string& name); + std::string getName(); + std::string getUnivName() const; + bool getUnivNameWrStatus() const; + void setUnivNameWrStatus(bool newStatus); + void setDescription(const std::string& name); + std::string getDescription() const; void setOrder(int order); int getOrder() const; void setIteration(int it); @@ -355,52 +723,73 @@ namespace ParaMEDMEM void setTimeValue(double time); void setTime(int dt, int it, double time); double getTimeValue() const; - void setTimeUnit(const char *unit); - const char *getTimeUnit() const; + void setTimeUnit(const std::string& unit); + std::string getTimeUnit() const; 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); + virtual int getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception); + virtual bool hasImplicitPart() const throw(INTERP_KERNEL::Exception); + virtual int buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception); + virtual void releaseImplicitPartIfAny() const throw(INTERP_KERNEL::Exception); + virtual std::vector getFamArrNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception); + virtual std::vector getNumArrNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception); + virtual std::vector getNameArrNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception); + virtual std::vector getDistributionOfTypes(int meshDimRelToMax) 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 char *groupName) const; - bool existsFamily(int famId) const; - bool existsFamily(const char *familyName) const; - void setFamilyId(const char *familyName, int id); - void setFamilyIdUnique(const char *familyName, int id) throw(INTERP_KERNEL::Exception); - void addFamily(const char *familyName, int id) throw(INTERP_KERNEL::Exception); - void addFamilyOnGrp(const char *grpName, const char *famName) throw(INTERP_KERNEL::Exception); - virtual void createGroupOnAll(int meshDimRelToMaxExt, const char *groupName) throw(INTERP_KERNEL::Exception); + bool existsGroup(const std::string& groupName) const throw(INTERP_KERNEL::Exception); + bool existsFamily(int famId) const throw(INTERP_KERNEL::Exception); + bool existsFamily(const std::string& familyName) const throw(INTERP_KERNEL::Exception); + void setFamilyId(const std::string& familyName, int id) throw(INTERP_KERNEL::Exception); + void setFamilyIdUnique(const std::string& familyName, int id) throw(INTERP_KERNEL::Exception); + void addFamily(const std::string& familyName, int id) throw(INTERP_KERNEL::Exception); + void addFamilyOnGrp(const std::string& grpName, const std::string& famName) throw(INTERP_KERNEL::Exception); + virtual void createGroupOnAll(int meshDimRelToMaxExt, const std::string& groupName) throw(INTERP_KERNEL::Exception); virtual bool keepFamIdsOnlyOnLevs(const std::vector& famIds, const std::vector& levs) throw(INTERP_KERNEL::Exception); - void copyFamGrpMapsFrom(const MEDFileMesh& other); - const std::map& getFamilyInfo() const; - const std::map >& getGroupInfo() const; - std::vector getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception); + void copyFamGrpMapsFrom(const MEDFileMesh& other) throw(INTERP_KERNEL::Exception); + void clearGrpMap() throw(INTERP_KERNEL::Exception); + void clearFamMap() throw(INTERP_KERNEL::Exception); + void clearFamGrpMaps() throw(INTERP_KERNEL::Exception); + const std::map& getFamilyInfo() const throw(INTERP_KERNEL::Exception); + const std::map >& getGroupInfo() const throw(INTERP_KERNEL::Exception); + std::vector getFamiliesOnGroup(const std::string& name) const throw(INTERP_KERNEL::Exception); std::vector getFamiliesOnGroups(const std::vector& grps) const throw(INTERP_KERNEL::Exception); - std::vector getFamiliesIdsOnGroup(const char *name) const throw(INTERP_KERNEL::Exception); - void setFamiliesOnGroup(const char *name, const std::vector& fams) throw(INTERP_KERNEL::Exception); - void setFamiliesIdsOnGroup(const char *name, const std::vector& famIds) throw(INTERP_KERNEL::Exception); - std::vector getGroupsOnFamily(const char *name) const throw(INTERP_KERNEL::Exception); - void setGroupsOnFamily(const char *famName, const std::vector& grps) throw(INTERP_KERNEL::Exception); - std::vector getGroupsNames() const; - std::vector getFamiliesNames() const; + std::vector getFamiliesIdsOnGroup(const std::string& name) const throw(INTERP_KERNEL::Exception); + void setFamiliesOnGroup(const std::string& name, const std::vector& fams) throw(INTERP_KERNEL::Exception); + void setFamiliesIdsOnGroup(const std::string& name, const std::vector& famIds) throw(INTERP_KERNEL::Exception); + std::vector getGroupsOnFamily(const std::string& name) const throw(INTERP_KERNEL::Exception); + void setGroupsOnFamily(const std::string& famName, const std::vector& grps) throw(INTERP_KERNEL::Exception); + std::vector getGroupsNames() const throw(INTERP_KERNEL::Exception); + std::vector getFamiliesNames() const throw(INTERP_KERNEL::Exception); void assignFamilyNameWithGroupName() throw(INTERP_KERNEL::Exception); - void removeGroup(const char *name) throw(INTERP_KERNEL::Exception); - void removeFamily(const char *name) throw(INTERP_KERNEL::Exception); - void changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception); - void changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception); + std::vector removeEmptyGroups() throw(INTERP_KERNEL::Exception); + void removeGroup(const std::string& name) throw(INTERP_KERNEL::Exception); + void removeFamily(const std::string& name) throw(INTERP_KERNEL::Exception); + std::vector removeOrphanGroups() throw(INTERP_KERNEL::Exception); + std::vector removeOrphanFamilies() throw(INTERP_KERNEL::Exception); + void removeFamiliesReferedByNoGroups() throw(INTERP_KERNEL::Exception); + void rearrangeFamilies() throw(INTERP_KERNEL::Exception); + void checkOrphanFamilyZero() const throw(INTERP_KERNEL::Exception); + void changeGroupName(const std::string& oldName, const std::string& newName) throw(INTERP_KERNEL::Exception); + void changeFamilyName(const std::string& oldName, const std::string& newName) throw(INTERP_KERNEL::Exception); void changeFamilyId(int oldId, int newId) throw(INTERP_KERNEL::Exception); - void changeAllGroupsContainingFamily(const char *familyNameToChange, const std::vector& newFamiliesNames) throw(INTERP_KERNEL::Exception); + void changeAllGroupsContainingFamily(const std::string& familyNameToChange, const std::vector& newFamiliesNames) throw(INTERP_KERNEL::Exception); void setFamilyInfo(const std::map& info); void setGroupInfo(const std::map >&info); - int getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception); + int getFamilyId(const std::string& name) const throw(INTERP_KERNEL::Exception); + int getMaxAbsFamilyId() const throw(INTERP_KERNEL::Exception); int getMaxFamilyId() const throw(INTERP_KERNEL::Exception); int getMinFamilyId() const throw(INTERP_KERNEL::Exception); + int getTheMaxAbsFamilyId() const throw(INTERP_KERNEL::Exception); int getTheMaxFamilyId() const throw(INTERP_KERNEL::Exception); int getTheMinFamilyId() const throw(INTERP_KERNEL::Exception); + virtual int getMaxAbsFamilyIdInArrays() const throw(INTERP_KERNEL::Exception); virtual int getMaxFamilyIdInArrays() const throw(INTERP_KERNEL::Exception); virtual int getMinFamilyIdInArrays() const throw(INTERP_KERNEL::Exception); DataArrayInt *getAllFamiliesIdsReferenced() const throw(INTERP_KERNEL::Exception); + DataArrayInt *computeAllFamilyIdsInUse() const throw(INTERP_KERNEL::Exception); std::vector getFamiliesIds(const std::vector& famNames) const throw(INTERP_KERNEL::Exception); std::string getFamilyNameGivenId(int id) const throw(INTERP_KERNEL::Exception); bool ensureDifferentFamIdsPerLevel() throw(INTERP_KERNEL::Exception); @@ -413,26 +802,22 @@ namespace ParaMEDMEM virtual MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const throw(INTERP_KERNEL::Exception); 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 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); virtual DataArrayInt *getGroupsArr(int meshDimRelToMaxExt, const std::vector& grps, bool renum=false) const throw(INTERP_KERNEL::Exception); - virtual DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception); - virtual DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception); - virtual DataArrayInt *getNodeGroupArr(const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception); + virtual DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const throw(INTERP_KERNEL::Exception); + virtual DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const std::string& fam, bool renum=false) const throw(INTERP_KERNEL::Exception); + virtual DataArrayInt *getNodeGroupArr(const std::string& grp, bool renum=false) const throw(INTERP_KERNEL::Exception); virtual DataArrayInt *getNodeGroupsArr(const std::vector& grps, bool renum=false) const throw(INTERP_KERNEL::Exception); - virtual DataArrayInt *getNodeFamilyArr(const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception); + virtual DataArrayInt *getNodeFamilyArr(const std::string& fam, bool renum=false) const throw(INTERP_KERNEL::Exception); virtual DataArrayInt *getNodeFamiliesArr(const std::vector& fams, bool renum=false) const throw(INTERP_KERNEL::Exception); + int getNumberOfJoints(); + MEDFileJoints *getJoints(); + void setJoints( MEDFileJoints* joints ); %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 throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); @@ -460,6 +845,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) { @@ -485,6 +877,26 @@ namespace ParaMEDMEM return res; } + PyObject *getAllGeoTypes() const throw(INTERP_KERNEL::Exception) + { + std::vector result(self->getAllGeoTypes()); + std::vector::const_iterator iL=result.begin(); + PyObject *res=PyList_New(result.size()); + for(int i=0;iL!=result.end(); i++, iL++) + PyList_SetItem(res,i,PyInt_FromLong(*iL)); + return res; + } + + PyObject *getGeoTypesAtLevel(int meshDimRelToMax) const throw(INTERP_KERNEL::Exception) + { + std::vector result(self->getGeoTypesAtLevel(meshDimRelToMax)); + std::vector::const_iterator iL=result.begin(); + PyObject *res=PyList_New(result.size()); + for(int i=0;iL!=result.end(); i++, iL++) + PyList_SetItem(res,i,PyInt_FromLong(*iL)); + return res; + } + PyObject *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) { const DataArrayInt *tmp=self->getFamilyFieldAtLevel(meshDimRelToMaxExt); @@ -493,6 +905,14 @@ namespace ParaMEDMEM return SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); } + PyObject *getOrCreateAndGetFamilyFieldAtLevel(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception) + { + const DataArrayInt *tmp=self->getOrCreateAndGetFamilyFieldAtLevel(meshDimRelToMaxExt); + if(tmp) + tmp->incrRef(); + return SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); + } + PyObject *getNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) { const DataArrayInt *tmp=self->getNumberFieldAtLevel(meshDimRelToMaxExt); @@ -501,6 +921,22 @@ namespace ParaMEDMEM 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) + { + const DataArrayAsciiChar *tmp=self->getNameFieldAtLevel(meshDimRelToMaxExt); + if(tmp) + tmp->incrRef(); + return SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayAsciiChar, SWIG_POINTER_OWN | 0 ); + } + PyObject *findOrCreateAndGiveFamilyWithId(int id, bool& created) throw(INTERP_KERNEL::Exception) { bool ret1; @@ -550,81 +986,213 @@ namespace ParaMEDMEM class MEDFileUMesh : public MEDFileMesh { public: - static MEDFileUMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception); - static MEDFileUMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception); + 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(); ~MEDFileUMesh(); int getSpaceDimension() const throw(INTERP_KERNEL::Exception); + int getRelativeLevOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception); // - std::vector getGrpNonEmptyLevels(const char *grp) const throw(INTERP_KERNEL::Exception); - std::vector getGrpNonEmptyLevelsExt(const char *grp) const throw(INTERP_KERNEL::Exception); - std::vector getFamNonEmptyLevels(const char *fam) const throw(INTERP_KERNEL::Exception); - std::vector getFamNonEmptyLevelsExt(const char *fam) 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); + std::vector getFamNonEmptyLevels(const std::string& fam) const throw(INTERP_KERNEL::Exception); + std::vector getFamNonEmptyLevelsExt(const std::string& fam) const throw(INTERP_KERNEL::Exception); std::vector getGrpsNonEmptyLevels(const std::vector& grps) const throw(INTERP_KERNEL::Exception); std::vector getGrpsNonEmptyLevelsExt(const std::vector& grps) const throw(INTERP_KERNEL::Exception); std::vector getFamsNonEmptyLevels(const std::vector& fams) const throw(INTERP_KERNEL::Exception); 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 char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception); - DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception); + MEDCouplingUMesh *getGroup(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 char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception); - DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception); + MEDCouplingUMesh *getFamily(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 char *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 char *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); MEDCouplingUMesh *getLevelM2Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *getLevelM3Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception); + void forceComputationOfParts() 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); - void addNodeGroup(const DataArrayInt *ids) throw(INTERP_KERNEL::Exception); - void addGroup(int meshDimRelToMaxExt, const DataArrayInt *ids) throw(INTERP_KERNEL::Exception); void removeMeshAtLevel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception); + void setMeshAtLevel(int meshDimRelToMax, MEDCoupling1GTUMesh *m) throw(INTERP_KERNEL::Exception); void setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld=false) throw(INTERP_KERNEL::Exception); - void setMeshAtLevelGen(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception); - void setGroupsFromScratch(int meshDimRelToMax, const std::vector& ms) throw(INTERP_KERNEL::Exception); - void setGroupsOnSetMesh(int meshDimRelToMax, const std::vector& ms, bool renum) throw(INTERP_KERNEL::Exception); void optimizeFamilies() throw(INTERP_KERNEL::Exception); 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); + 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); %extend { - MEDFileUMesh(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception) + MEDFileUMesh(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) { - return MEDFileUMesh::New(fileName,mName,dt,it); + return MEDFileUMesh::New(fileName,mName,dt,it,mrs); } - MEDFileUMesh(const char *fileName) throw(INTERP_KERNEL::Exception) + MEDFileUMesh(const std::string& fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) { - return MEDFileUMesh::New(fileName); + return MEDFileUMesh::New(fileName,mrs); } MEDFileUMesh() { 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"); + } + + 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 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 __setitem__(int meshDimRelToMax, MEDCouplingPointSet *mesh) throw(INTERP_KERNEL::Exception) + { + if(!mesh) + throw INTERP_KERNEL::Exception("MEDFileUMesh::__setitem__ : Input mesh is NULL !"); + MEDCouplingUMesh *m0(dynamic_cast(mesh)); + if(m0) + { + self->setMeshAtLevel(meshDimRelToMax,m0,false); + return ; + } + MEDCoupling1GTUMesh *m1(dynamic_cast(mesh)); + if(m1) + { + self->setMeshAtLevel(meshDimRelToMax,m1); + return ; + } + throw INTERP_KERNEL::Exception("MEDFileUMesh::__setitem__ : Not recognized input mesh !"); + } + + void __delitem__(int meshDimRelToMax) throw(INTERP_KERNEL::Exception) + { + self->removeMeshAtLevel(meshDimRelToMax); + } + + void setMeshes(PyObject *li, bool renum=false) throw(INTERP_KERNEL::Exception) + { + std::vector ms; + convertFromPyObjVectorOfObj(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,"MEDCouplingUMesh",ms); + self->setMeshes(ms,renum); + } + + void setGroupsFromScratch(int meshDimRelToMax, PyObject *li, bool renum=false) throw(INTERP_KERNEL::Exception) + { + std::vector ms; + convertFromPyObjVectorOfObj(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,"MEDCouplingUMesh",ms); + self->setGroupsFromScratch(meshDimRelToMax,ms,renum); } - void setGroupsAtLevel(int meshDimRelToMaxExt, PyObject *li, bool renum=false) throw(INTERP_KERNEL::Exception) + void setGroupsOnSetMesh(int meshDimRelToMax, 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); + std::vector ms; + convertFromPyObjVectorOfObj(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,"MEDCouplingUMesh",ms); + self->setGroupsOnSetMesh(meshDimRelToMax,ms,renum); } DataArrayDouble *getCoords() const throw(INTERP_KERNEL::Exception) @@ -635,7 +1203,15 @@ namespace ParaMEDMEM return ret; } - PyObject *duplicateNodesOnM1Group(const char *grpNameM1) throw(INTERP_KERNEL::Exception) + 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; self->duplicateNodesOnM1Group(grpNameM1,ret0,ret1,ret2); @@ -645,20 +1221,54 @@ namespace ParaMEDMEM PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); return ret; } + + MEDCoupling1GTUMesh *getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception) + { + MEDCoupling1GTUMesh *ret(self->getDirectUndergroundSingleGeoTypeMesh(gt)); + if(ret) + ret->incrRef(); + return ret; + } + + PyObject *getDirectUndergroundSingleGeoTypeMeshes(int meshDimRelToMax) const throw(INTERP_KERNEL::Exception) + { + std::vector tmp(self->getDirectUndergroundSingleGeoTypeMeshes(meshDimRelToMax)); + std::size_t sz(tmp.size()); + PyObject *ret=PyList_New(sz); + for(std::size_t i=0;iincrRef(); + PyList_SetItem(ret,i,convertMesh(tmp[i], SWIG_POINTER_OWN | 0 )); + } + return ret; + } } }; class MEDFileStructuredMesh : public MEDFileMesh { + public: + %extend + { + MEDCoupling1SGTUMesh *getImplicitFaceMesh() const throw(INTERP_KERNEL::Exception) + { + MEDCoupling1SGTUMesh *ret(self->getImplicitFaceMesh()); + if(ret) + ret->incrRef(); + return ret; + } + } }; class MEDFileCMesh : public MEDFileStructuredMesh { public: static MEDFileCMesh *New(); - static MEDFileCMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception); - static MEDFileCMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) 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); + int getSpaceDimension() const throw(INTERP_KERNEL::Exception); %extend { MEDFileCMesh() @@ -666,14 +1276,14 @@ namespace ParaMEDMEM return MEDFileCMesh::New(); } - MEDFileCMesh(const char *fileName) throw(INTERP_KERNEL::Exception) + MEDFileCMesh(const std::string& fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) { - return MEDFileCMesh::New(fileName); + return MEDFileCMesh::New(fileName,mrs); } - MEDFileCMesh(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception) + MEDFileCMesh(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) { - return MEDFileCMesh::New(fileName,mName,dt,it); + return MEDFileCMesh::New(fileName,mName,dt,it,mrs); } PyObject *getMesh() const throw(INTERP_KERNEL::Exception) @@ -690,8 +1300,8 @@ namespace ParaMEDMEM { public: static MEDFileCurveLinearMesh *New(); - static MEDFileCurveLinearMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception); - static MEDFileCurveLinearMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) 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); %extend { @@ -700,14 +1310,14 @@ namespace ParaMEDMEM return MEDFileCurveLinearMesh::New(); } - MEDFileCurveLinearMesh(const char *fileName) throw(INTERP_KERNEL::Exception) + MEDFileCurveLinearMesh(const std::string& fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) { - return MEDFileCurveLinearMesh::New(fileName); + return MEDFileCurveLinearMesh::New(fileName,mrs); } - MEDFileCurveLinearMesh(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception) + MEDFileCurveLinearMesh(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) { - return MEDFileCurveLinearMesh::New(fileName,mName,dt,it); + return MEDFileCurveLinearMesh::New(fileName,mName,dt,it,mrs); } PyObject *getMesh() const throw(INTERP_KERNEL::Exception) @@ -724,11 +1334,11 @@ namespace ParaMEDMEM { public: static MEDFileMeshMultiTS *New(); - static MEDFileMeshMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception); - static MEDFileMeshMultiTS *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception); + static MEDFileMeshMultiTS *New(const std::string& fileName) throw(INTERP_KERNEL::Exception); + static MEDFileMeshMultiTS *New(const std::string& fileName, const std::string& mName) throw(INTERP_KERNEL::Exception); MEDFileMeshMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception); - const char *getName() const throw(INTERP_KERNEL::Exception); - void write(const char *fileName, int mode) 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); %extend { @@ -737,12 +1347,12 @@ namespace ParaMEDMEM return MEDFileMeshMultiTS::New(); } - MEDFileMeshMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception) + MEDFileMeshMultiTS(const std::string& fileName) throw(INTERP_KERNEL::Exception) { return MEDFileMeshMultiTS::New(fileName); } - MEDFileMeshMultiTS(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception) + MEDFileMeshMultiTS(const std::string& fileName, const std::string& mName) throw(INTERP_KERNEL::Exception) { return MEDFileMeshMultiTS::New(fileName,mName); } @@ -783,9 +1393,9 @@ namespace ParaMEDMEM { public: static MEDFileMeshes *New(); - static MEDFileMeshes *New(const char *fileName) throw(INTERP_KERNEL::Exception); + static MEDFileMeshes *New(const std::string& fileName) throw(INTERP_KERNEL::Exception); MEDFileMeshes *deepCpy() const throw(INTERP_KERNEL::Exception); - void write(const char *fileName, int mode) 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); // @@ -800,12 +1410,12 @@ namespace ParaMEDMEM return MEDFileMeshes::New(); } - MEDFileMeshes(const char *fileName) throw(INTERP_KERNEL::Exception) + MEDFileMeshes(const std::string& fileName) throw(INTERP_KERNEL::Exception) { return MEDFileMeshes::New(fileName); } - std::string __str__() const + std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } @@ -814,7 +1424,7 @@ namespace ParaMEDMEM { if(PyInt_Check(obj)) { - MEDFileMesh *ret=self->getMeshAtPos((int)PyInt_AS_LONG(obj)); + MEDFileMesh *ret=self->getMeshAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfMeshes())); if(ret) ret->incrRef(); return ret; @@ -840,6 +1450,11 @@ namespace ParaMEDMEM { return self->iterator(); } + + int __len__() const throw(INTERP_KERNEL::Exception) + { + return self->getNumberOfMeshes(); + } MEDFileMesh *getMeshAtPos(int i) const throw(INTERP_KERNEL::Exception) { @@ -848,7 +1463,7 @@ namespace ParaMEDMEM ret->incrRef(); return ret; } - MEDFileMesh *getMeshWithName(const char *mname) const throw(INTERP_KERNEL::Exception) + MEDFileMesh *getMeshWithName(const std::string& mname) const throw(INTERP_KERNEL::Exception) { MEDFileMesh *ret=self->getMeshWithName(mname); if(ret) @@ -861,14 +1476,14 @@ namespace ParaMEDMEM class MEDFileFieldLoc : public RefCountObject { public: - const std::string& getName() const; + std::string getName() const; int getDimension() const; int getNumberOfGaussPoints() const; int getNumberOfPointsInCells() const; const std::vector& getRefCoords() const; const std::vector& getGaussCoords() const; const std::vector& getGaussWeights() const; - bool isEqual(const MEDFileFieldLoc& other, double eps) const; + bool isEqual(const MEDFileFieldLoc& other, double eps) const throw(INTERP_KERNEL::Exception); %extend { std::string __str__() const throw(INTERP_KERNEL::Exception) @@ -881,12 +1496,19 @@ namespace ParaMEDMEM class MEDFileFieldGlobsReal { public: + void resetContent(); void shallowCpyGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception); void deepCpyGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception); + void shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception); + void deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception); + void appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception); + void checkGlobsCoherency() const throw(INTERP_KERNEL::Exception); + void checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception); + void checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception); std::vector getPfls() const throw(INTERP_KERNEL::Exception); std::vector getLocs() const throw(INTERP_KERNEL::Exception); - bool existsPfl(const char *pflName) const throw(INTERP_KERNEL::Exception); - bool existsLoc(const char *locName) const throw(INTERP_KERNEL::Exception); + bool existsPfl(const std::string& pflName) const throw(INTERP_KERNEL::Exception); + bool existsLoc(const std::string& locName) const throw(INTERP_KERNEL::Exception); std::string createNewNameOfPfl() const throw(INTERP_KERNEL::Exception); std::string createNewNameOfLoc() const throw(INTERP_KERNEL::Exception); std::vector< std::vector > whichAreEqualProfiles() const throw(INTERP_KERNEL::Exception); @@ -897,13 +1519,13 @@ namespace ParaMEDMEM virtual std::vector getLocsReallyUsedMulti() const throw(INTERP_KERNEL::Exception); 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); - void changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception); + void changePflName(const std::string& oldName, const std::string& newName) throw(INTERP_KERNEL::Exception); + 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 char *loc) const throw(INTERP_KERNEL::Exception); + int getLocalizationId(const std::string& loc) const throw(INTERP_KERNEL::Exception); %extend { - PyObject *getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception) + PyObject *getProfile(const std::string& pflName) const throw(INTERP_KERNEL::Exception) { const DataArrayInt *ret=self->getProfile(pflName); if(ret) @@ -922,14 +1544,16 @@ namespace ParaMEDMEM PyObject *getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception) { const MEDFileFieldLoc *loc=&self->getLocalizationFromId(locId); - loc->incrRef(); + if(loc) + loc->incrRef(); return SWIG_NewPointerObj(SWIG_as_voidptr(loc),SWIGTYPE_p_ParaMEDMEM__MEDFileFieldLoc, SWIG_POINTER_OWN | 0 ); } - PyObject *getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception) + PyObject *getLocalization(const std::string& locName) const throw(INTERP_KERNEL::Exception) { const MEDFileFieldLoc *loc=&self->getLocalization(locName); - loc->incrRef(); + if(loc) + loc->incrRef(); return SWIG_NewPointerObj(SWIG_as_voidptr(loc),SWIGTYPE_p_ParaMEDMEM__MEDFileFieldLoc, SWIG_POINTER_OWN | 0 ); } @@ -980,124 +1604,112 @@ namespace ParaMEDMEM std::vector< std::pair, std::string > > v=convertVecPairVecStFromPy(li); self->changeLocsNamesInStruct(v); } + + std::string simpleReprGlobs() const throw(INTERP_KERNEL::Exception) + { + std::ostringstream oss; + self->simpleReprGlobs(oss); + return oss.str(); + } } }; - class MEDFileField1TS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable + class MEDFileAnyTypeField1TS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable { public: - static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static MEDFileField1TS *New(); - void write(const char *fileName, int mode) 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); - MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); - // - void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception); - void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); - void setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception); - void setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception); - void copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception); - MEDFileField1TS *deepCpy() const throw(INTERP_KERNEL::Exception); - // + 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); + void loadArrays() throw(INTERP_KERNEL::Exception); + void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); + void unloadArrays() throw(INTERP_KERNEL::Exception); + void unloadArraysWithoutDataLoss() throw(INTERP_KERNEL::Exception); int getDimension() const throw(INTERP_KERNEL::Exception); int getIteration() const throw(INTERP_KERNEL::Exception); int getOrder() const throw(INTERP_KERNEL::Exception); std::string getName() throw(INTERP_KERNEL::Exception); - void setName(const char *name) throw(INTERP_KERNEL::Exception); + void setName(const std::string& name) throw(INTERP_KERNEL::Exception); std::string getMeshName() throw(INTERP_KERNEL::Exception); - void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception); + void setMeshName(const std::string& newMeshName) throw(INTERP_KERNEL::Exception); + int getMeshIteration() const throw(INTERP_KERNEL::Exception); + int getMeshOrder() const throw(INTERP_KERNEL::Exception); int getNumberOfComponents() const throw(INTERP_KERNEL::Exception); 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); + std::string getDtUnit() const throw(INTERP_KERNEL::Exception); + void setDtUnit(const std::string& dtUnit) 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 throw(INTERP_KERNEL::Exception) - { - return self->simpleRepr(); - } + { + PyObject *getTime() throw(INTERP_KERNEL::Exception) + { + int tmp1,tmp2; + double tmp0=self->getTime(tmp1,tmp2); + PyObject *res = PyList_New(3); + PyList_SetItem(res,0,SWIG_From_int(tmp1)); + PyList_SetItem(res,1,SWIG_From_int(tmp2)); + PyList_SetItem(res,2,SWIG_From_double(tmp0)); + return res; + } - 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_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; - } + PyObject *getDtIt() const throw(INTERP_KERNEL::Exception) + { + std::pair res=self->getDtIt(); + PyObject *elt=PyTuple_New(2); + PyTuple_SetItem(elt,0,SWIG_From_int(res.first)); + PyTuple_SetItem(elt,1,SWIG_From_int(res.second)); + return elt; + } - void setProfileNameOnLeaf(INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception) - { - self->setProfileNameOnLeaf(0,typ,locId,newPflName,forceRenameOnGlob); - } - - void setLocNameOnLeaf(INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception) - { - self->setLocNameOnLeaf(0,typ,locId,newLocName,forceRenameOnGlob); - } + void setProfileNameOnLeaf(INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception) + { + self->setProfileNameOnLeaf(0,typ,locId,newPflName,forceRenameOnGlob); + } + + void setLocNameOnLeaf(INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception) + { + self->setLocNameOnLeaf(0,typ,locId,newLocName,forceRenameOnGlob); + } - PyObject *getTime() throw(INTERP_KERNEL::Exception) - { - int tmp1,tmp2; - double tmp0=self->getTime(tmp1,tmp2); - PyObject *res = PyList_New(3); - PyList_SetItem(res,0,SWIG_From_int(tmp1)); - PyList_SetItem(res,1,SWIG_From_int(tmp2)); - PyList_SetItem(res,2,SWIG_From_double(tmp0)); - return res; - } - - PyObject *getDtIt() const throw(INTERP_KERNEL::Exception) - { - std::pair res=self->getDtIt(); - PyObject *elt=PyTuple_New(2); - PyTuple_SetItem(elt,0,SWIG_From_int(res.first)); - PyTuple_SetItem(elt,1,SWIG_From_int(res.second)); - return elt; - } - - PyObject *getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception) - { - std::vector ret=self->getTypesOfFieldAvailable(); - PyObject *ret2=PyList_New(ret.size()); - for(int i=0;i<(int)ret.size();i++) - PyList_SetItem(ret2,i,SWIG_From_int(ret[i])); - return ret2; - } - - PyObject *getNonEmptyLevels(const char *mname=0) const throw(INTERP_KERNEL::Exception) - { - std::vector ret1; - int ret0=self->getNonEmptyLevels(mname,ret1); - PyObject *elt=PyTuple_New(2); - PyTuple_SetItem(elt,0,SWIG_From_int(ret0)); - PyTuple_SetItem(elt,1,convertIntArrToPyList2(ret1)); - return elt; - } - - PyObject *getFieldSplitedByType(const char *mname=0) const throw(INTERP_KERNEL::Exception) - { - std::vector types; - std::vector< std::vector > typesF; - std::vector< std::vector > pfls; - std::vector< std::vector > locs; - std::vector< std::vector< std::pair > > ret=self->getFieldSplitedByType(mname,types,typesF,pfls,locs); - int sz=ret.size(); - PyObject *ret2=PyList_New(sz); + bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector< std::pair > modifTab=convertVecPairStStFromPy(li); + return self->changeMeshNames(modifTab); + } + + PyObject *getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception) + { + std::vector ret=self->getTypesOfFieldAvailable(); + PyObject *ret2=PyList_New(ret.size()); + for(int i=0;i<(int)ret.size();i++) + PyList_SetItem(ret2,i,SWIG_From_int(ret[i])); + return ret2; + } + + PyObject *getNonEmptyLevels(const std::string& mname=std::string()) const throw(INTERP_KERNEL::Exception) + { + std::vector ret1; + int ret0=self->getNonEmptyLevels(mname,ret1); + PyObject *elt=PyTuple_New(2); + PyTuple_SetItem(elt,0,SWIG_From_int(ret0)); + PyTuple_SetItem(elt,1,convertIntArrToPyList2(ret1)); + return elt; + } + + PyObject *getFieldSplitedByType(const std::string& mname=std::string()) const throw(INTERP_KERNEL::Exception) + { + std::vector types; + std::vector< std::vector > typesF; + std::vector< std::vector > pfls; + std::vector< std::vector > locs; + std::vector< std::vector< std::pair > > ret=self->getFieldSplitedByType(mname,types,typesF,pfls,locs); + int sz=ret.size(); + PyObject *ret2=PyList_New(sz); for(int i=0;i >& dadsI=ret[i]; @@ -1122,9 +1734,104 @@ namespace ParaMEDMEM PyList_SetItem(ret2,i,elt); } return ret2; + } + + PyObject *splitComponents() const throw(INTERP_KERNEL::Exception) + { + std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret=self->splitComponents(); + std::size_t sz=ret.size(); + PyObject *retPy=PyList_New(sz); + for(std::size_t i=0;i > ret=self->splitDiscretizations(); + std::size_t sz=ret.size(); + PyObject *retPy=PyList_New(sz); + for(std::size_t i=0;i > ret=self->splitMultiDiscrPerGeoTypes(); + std::size_t sz=ret.size(); + PyObject *retPy=PyList_New(sz); + for(std::size_t i=0;igetArray(); + self->copyTinyInfoFrom(field,arr); + } + + 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; + 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_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + PyObject *getFieldSplitedByType2(const std::string& mname=std::string()) const throw(INTERP_KERNEL::Exception) { std::vector types; std::vector< std::vector > typesF; @@ -1192,25 +1899,127 @@ namespace ParaMEDMEM PyTuple_SetItem(ret,1,elt); return ret; } - - bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception) - { - std::vector< std::pair > modifTab=convertVecPairStStFromPy(li); - return self->changeMeshNames(modifTab); - } } }; - class MEDFileFieldMultiTSIterator + class MEDFileIntField1TS : public MEDFileAnyTypeField1TS + { + public: + static MEDFileIntField1TS *New(); + static MEDFileIntField1TS *New(const std::string& fileName, bool loadAll=true) 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); + ParaMEDMEM::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); + %extend + { + MEDFileIntField1TS() throw(INTERP_KERNEL::Exception) + { + return MEDFileIntField1TS::New(); + } + + MEDFileIntField1TS(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileIntField1TS::New(fileName,loadAll); + } + + MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileIntField1TS::New(fileName,fieldName,loadAll); + } + + MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileIntField1TS::New(fileName,fieldName,iteration,order,loadAll); + } + + 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) + { + 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_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + PyObject *getFieldAtTopLevel(TypeOfField type, int renumPol=0) 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_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + PyObject *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const 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_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + PyObject *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const 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_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + PyObject *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const 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_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + 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_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + DataArrayInt *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *ret=self->getUndergroundDataArray(); + if(ret) + ret->incrRef(); + return ret; + } + } + }; + + class MEDFileAnyTypeFieldMultiTSIterator { public: %extend { PyObject *next() throw(INTERP_KERNEL::Exception) { - MEDFileField1TS *ret=self->nextt(); + MEDFileAnyTypeField1TS *ret=self->nextt(); if(ret) - return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDFileField1TS,SWIG_POINTER_OWN | 0); + return convertMEDFileField1TS(ret, SWIG_POINTER_OWN | 0 ); else { PyErr_SetString(PyExc_StopIteration,"No more data."); @@ -1220,206 +2029,441 @@ namespace ParaMEDMEM } }; - class MEDFileFieldMultiTS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable + class MEDFileAnyTypeFieldMultiTS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable { public: - static MEDFileFieldMultiTS *New() throw(INTERP_KERNEL::Exception); - static MEDFileFieldMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception); - static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception); - MEDFileFieldMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception); - // - MEDFileField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception); - MEDFileField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception); - MEDFileField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception); - // - void write(const char *fileName, int mode) 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 char *mname, int iteration, int order, 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); - // + static MEDFileAnyTypeFieldMultiTS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileAnyTypeFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception); + virtual MEDFileAnyTypeFieldMultiTS *shallowCpy() const throw(INTERP_KERNEL::Exception); + std::string getName() const throw(INTERP_KERNEL::Exception); + void setName(const std::string& name) throw(INTERP_KERNEL::Exception); + std::string getDtUnit() const throw(INTERP_KERNEL::Exception); + void setDtUnit(const std::string& dtUnit) throw(INTERP_KERNEL::Exception); + std::string getMeshName() const throw(INTERP_KERNEL::Exception); + void setMeshName(const std::string& newMeshName) throw(INTERP_KERNEL::Exception); + const std::vector& 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); int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception); int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception); - std::string getName() const throw(INTERP_KERNEL::Exception); - void setName(const char *name) throw(INTERP_KERNEL::Exception); - std::string getMeshName() const throw(INTERP_KERNEL::Exception); - void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception); - const std::vector& getInfo() 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); + void unloadArraysWithoutDataLoss() throw(INTERP_KERNEL::Exception); + // + virtual MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception); + void pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception); + void synchronizeNameScope() throw(INTERP_KERNEL::Exception); %extend - { - MEDFileFieldMultiTS() - { - return MEDFileFieldMultiTS::New(); - } + { + int __len__() const throw(INTERP_KERNEL::Exception) + { + return self->getNumberOfTS(); + } - MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception) - { - return MEDFileFieldMultiTS::New(fileName); - } + int getTimeId(PyObject *elt0) const throw(INTERP_KERNEL::Exception) + { + if(elt0 && PyInt_Check(elt0)) + {//fmts[3] + int pos=PyInt_AS_LONG(elt0); + return pos; + } + else if(elt0 && PyTuple_Check(elt0)) + { + if(PyTuple_Size(elt0)==2) + { + PyObject *o0=PyTuple_GetItem(elt0,0); + PyObject *o1=PyTuple_GetItem(elt0,1); + if(PyInt_Check(o0) && PyInt_Check(o1)) + {//fmts(1,-1) + int iter=PyInt_AS_LONG(o0); + int order=PyInt_AS_LONG(o1); + return self->getPosOfTimeStep(iter,order); + } + else + throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size 2 but two integers are expected in this tuple to request a time steps !"); + } + else + throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size != 2 ! two integers are expected in this tuple to request a time steps !"); + } + else if(elt0 && PyFloat_Check(elt0)) + { + double val=PyFloat_AS_DOUBLE(elt0); + return self->getPosGivenTime(val); + } + else + throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::__getitem__ : invalid input params ! expected fmts[int], fmts[int,int] or fmts[double] to request time step !"); + } + + 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; + } + + PyObject *getTimeSteps() const throw(INTERP_KERNEL::Exception) + { + std::vector ret1; + std::vector< std::pair > ret=self->getTimeSteps(ret1); + std::size_t sz=ret.size(); + PyObject *ret2=PyList_New(sz); + for(std::size_t i=0;i > ret=self->getTypesOfFieldAvailable(); + PyObject *ret2=PyList_New(ret.size()); + for(int i=0;i<(int)ret.size();i++) + { + const std::vector& rett=ret[i]; + PyObject *ret3=PyList_New(rett.size()); + for(int j=0;j<(int)rett.size();j++) + PyList_SetItem(ret3,j,SWIG_From_int(rett[j])); + PyList_SetItem(ret2,i,ret3); + } + return ret2; + } + + PyObject *getNonEmptyLevels(int iteration, int order, const std::string& mname=std::string()) const throw(INTERP_KERNEL::Exception) + { + std::vector ret1; + int ret0=self->getNonEmptyLevels(iteration,order,mname,ret1); + PyObject *elt=PyTuple_New(2); + PyTuple_SetItem(elt,0,SWIG_From_int(ret0)); + PyTuple_SetItem(elt,1,convertIntArrToPyList2(ret1)); + return elt; + } + + PyObject *getFieldSplitedByType(int iteration, int order, const std::string& mname=std::string()) const throw(INTERP_KERNEL::Exception) + { + std::vector types; + std::vector< std::vector > typesF; + std::vector< std::vector > pfls; + std::vector< std::vector > locs; + std::vector< std::vector< std::pair > > ret=self->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs); + int sz=ret.size(); + PyObject *ret2=PyList_New(sz); + for(int i=0;i >& dadsI=ret[i]; + const std::vector& typesFI=typesF[i]; + const std::vector& pflsI=pfls[i]; + const std::vector& locsI=locs[i]; + PyObject *elt=PyTuple_New(2); + PyTuple_SetItem(elt,0,SWIG_From_int(types[i])); + int sz2=ret[i].size(); + PyObject *elt2=PyList_New(sz2); + for(int j=0;jsimpleRepr(); - } + std::vector getTimeIds(PyObject *elts) const throw(INTERP_KERNEL::Exception) + { + if(PyList_Check(elts)) + { + int sz=PyList_Size(elts); + std::vector ret(sz); + for(int i=0;i ret(1); + ret[0]=ParaMEDMEM_MEDFileAnyTypeFieldMultiTS_getTimeId(self,elts); + return ret; + } + } + + void __delitem__(PyObject *elts) throw(INTERP_KERNEL::Exception) + { + 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 !"); + self->eraseTimeStepIds2(strt,stp,step); + } + else + { + std::vector idsToRemove=ParaMEDMEM_MEDFileAnyTypeFieldMultiTS_getTimeIds(self,elts); + if(!idsToRemove.empty()) + self->eraseTimeStepIds(&idsToRemove[0],&idsToRemove[0]+idsToRemove.size()); + } + } + + void eraseTimeStepIds(PyObject *li) throw(INTERP_KERNEL::Exception) + { + int sw; + int pos1; + std::vector pos2; + DataArrayInt *pos3=0; + DataArrayIntTuple *pos4=0; + convertObjToPossibleCpp1(li,sw,pos1,pos2,pos3,pos4); + switch(sw) + { + case 1: + { + self->eraseTimeStepIds(&pos1,&pos1+1); + return; + } + case 2: + { + if(pos2.empty()) + return; + self->eraseTimeStepIds(&pos2[0],&pos2[0]+pos2.size()); + return ; + } + case 3: + { + self->eraseTimeStepIds(pos3->begin(),pos3->end()); + return ; + } + default: + throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds : unexpected input array type recognized !"); + } + } - int __len__() const throw(INTERP_KERNEL::Exception) - { - return self->getNumberOfTS(); - } + MEDFileAnyTypeFieldMultiTSIterator *__iter__() throw(INTERP_KERNEL::Exception) + { + return self->iterator(); + } - MEDFileField1TS *__getitem__(PyObject *elt0) const throw(INTERP_KERNEL::Exception) - { - if(elt0 && PyInt_Check(elt0)) - {//fmts[3] - int pos=PyInt_AS_LONG(elt0); - return self->getTimeStepAtPos(pos); - } - else if(elt0 && PyTuple_Check(elt0)) - { - if(PyTuple_Size(elt0)==2) - { - PyObject *o0=PyTuple_GetItem(elt0,0); - PyObject *o1=PyTuple_GetItem(elt0,1); - if(PyInt_Check(o0) && PyInt_Check(o1)) - {//fmts(1,-1) - int iter=PyInt_AS_LONG(o0); - int order=PyInt_AS_LONG(o1); - return self->getTimeStep(iter,order); - } - else - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size 2 but two integers are expected in this tuple to request a time steps !"); - } - else - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size != 2 ! two integers are expected in this tuple to request a time steps !"); - } - else if(elt0 && PyFloat_Check(elt0)) - { - double val=PyFloat_AS_DOUBLE(elt0); - return self->getTimeStepGivenTime(val); - } - else - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input params ! expected fmts[int], fmts[int,int] or fmts[double] to request time step !"); - } + PyObject *__getitem__(PyObject *elt0) const throw(INTERP_KERNEL::Exception) + { + if(elt0 && PyList_Check(elt0)) + { + int sz=PyList_Size(elt0); + MEDCouplingAutoRefCountObjectPtr da=DataArrayInt::New(); da->alloc(sz,1); + int *pt=da->getPointer(); + for(int i=0;ibuildSubPart(da->begin(),da->end()),SWIG_POINTER_OWN | 0); + } + 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 !"); + return convertMEDFileFieldMultiTS(self->buildSubPartSlice(strt,stp,step),SWIG_POINTER_OWN | 0); + } + else + return convertMEDFileField1TS(self->getTimeStepAtPos(MEDFileAnyTypeFieldMultiTSgetitemSingleTS__(self,elt0)),SWIG_POINTER_OWN | 0); + } + + bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector< std::pair > modifTab=convertVecPairStStFromPy(li); + return self->changeMeshNames(modifTab); + } + + PyObject *splitComponents() const throw(INTERP_KERNEL::Exception) + { + std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret=self->splitComponents(); + std::size_t sz=ret.size(); + PyObject *retPy=PyList_New(sz); + for(std::size_t i=0;i > ret=self->splitDiscretizations(); + std::size_t sz=ret.size(); + PyObject *retPy=PyList_New(sz); + for(std::size_t i=0;i > ret=self->splitMultiDiscrPerGeoTypes(); + std::size_t sz=ret.size(); + PyObject *retPy=PyList_New(sz); + for(std::size_t i=0;ipushBackTimeSteps(reinterpret_cast(argp)); + } + else + { + std::vector tmp; + convertFromPyObjVectorOfObj(li,SWIGTYPE_p_ParaMEDMEM__MEDFileAnyTypeField1TS,"MEDFileAnyTypeField1TS",tmp); + self->pushBackTimeSteps(tmp); + } + } + + static PyObject *MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(PyObject *li) throw(INTERP_KERNEL::Exception) + { + std::vector vectFMTS; + convertFromPyObjVectorOfObj(li,SWIGTYPE_p_ParaMEDMEM__MEDFileAnyTypeFieldMultiTS,"MEDFileAnyTypeFieldMultiTS",vectFMTS); + std::vector< std::vector > ret=MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(vectFMTS); + std::size_t sz=ret.size(); + PyObject *retPy=PyList_New(sz); + for(std::size_t i=0;iincrRef(); + PyList_SetItem(ret1Py,j,convertMEDFileFieldMultiTS(elt,SWIG_POINTER_OWN | 0 )); + } + PyList_SetItem(retPy,i,ret1Py); + } + return retPy; + } + + static PyObject *MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(PyObject *li, const MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception) + { + std::vector vectFMTS; + convertFromPyObjVectorOfObj(li,SWIGTYPE_p_ParaMEDMEM__MEDFileAnyTypeFieldMultiTS,"MEDFileAnyTypeFieldMultiTS",vectFMTS); + std::vector< MEDCouplingAutoRefCountObjectPtr > ret2; + std::vector< std::vector > ret=MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(vectFMTS,mesh,ret2); + if(ret2.size()!=ret.size()) + { + std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport (PyWrap) : internal error ! Size of 2 vectors must match ! (" << ret.size() << "!=" << ret2.size() << ") !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + std::size_t sz=ret.size(); + PyObject *retPy=PyList_New(sz); + for(std::size_t i=0;iincrRef(); + PyList_SetItem(ret1Py,j,convertMEDFileFieldMultiTS(elt,SWIG_POINTER_OWN | 0 )); + } + PyTuple_SetItem(ret0Py,0,ret1Py); + PyTuple_SetItem(ret0Py,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret2[i].retn()),SWIGTYPE_p_ParaMEDMEM__MEDFileFastCellSupportComparator, SWIG_POINTER_OWN | 0 )); + PyList_SetItem(retPy,i,ret0Py); + } + return retPy; + } + } + }; - MEDFileFieldMultiTSIterator *__iter__() throw(INTERP_KERNEL::Exception) + 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); + // + 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); + // + 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); + ParaMEDMEM::MEDFileIntFieldMultiTS *convertToInt(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + %extend + { + MEDFileFieldMultiTS() { - return self->iterator(); + return MEDFileFieldMultiTS::New(); } - PyObject *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception) - { - DataArrayInt *ret1=0; - DataArrayDouble *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_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; - } - - PyObject *getIterations() const + MEDFileFieldMultiTS(const std::string& fileName, bool loadAll=true) 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; + return MEDFileFieldMultiTS::New(fileName,loadAll); } - PyObject *getTimeSteps() const throw(INTERP_KERNEL::Exception) - { - std::vector ret1; - std::vector< std::pair > ret=self->getTimeSteps(ret1); - std::size_t sz=ret.size(); - PyObject *ret2=PyList_New(sz); - for(std::size_t i=0;i > ret=self->getTypesOfFieldAvailable(); - PyObject *ret2=PyList_New(ret.size()); - for(int i=0;i<(int)ret.size();i++) + std::vector > tmp(convertTimePairIdsFromPy(entities)); + std::size_t sz(tmp.size()); + std::vector< std::pair > entitiesCpp(sz); + for(std::size_t i=0;i& rett=ret[i]; - PyObject *ret3=PyList_New(rett.size()); - for(int j=0;j<(int)rett.size();j++) - PyList_SetItem(ret3,j,SWIG_From_int(rett[j])); - PyList_SetItem(ret2,i,ret3); + entitiesCpp[i].first=(TypeOfField)tmp[i].first; + entitiesCpp[i].second=(INTERP_KERNEL::NormalizedCellType)tmp[i].second; } - return ret2; + return MEDFileFieldMultiTS::LoadSpecificEntities(fileName,fieldName,entitiesCpp,loadAll); } - - PyObject *getNonEmptyLevels(int iteration, int order, const char *mname=0) const throw(INTERP_KERNEL::Exception) + + std::string __str__() const throw(INTERP_KERNEL::Exception) { - std::vector ret1; - int ret0=self->getNonEmptyLevels(iteration,order,mname,ret1); - PyObject *elt=PyTuple_New(2); - PyTuple_SetItem(elt,0,SWIG_From_int(ret0)); - PyTuple_SetItem(elt,1,convertIntArrToPyList2(ret1)); - return elt; + return self->simpleRepr(); } - PyObject *getFieldSplitedByType(int iteration, int order, const char *mname=0) const throw(INTERP_KERNEL::Exception) + PyObject *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception) { - std::vector types; - std::vector< std::vector > typesF; - std::vector< std::vector > pfls; - std::vector< std::vector > locs; - std::vector< std::vector< std::pair > > ret=self->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs); - int sz=ret.size(); - PyObject *ret2=PyList_New(sz); - for(int i=0;i >& dadsI=ret[i]; - const std::vector& typesFI=typesF[i]; - const std::vector& pflsI=pfls[i]; - const std::vector& locsI=locs[i]; - PyObject *elt=PyTuple_New(2); - PyTuple_SetItem(elt,0,SWIG_From_int(types[i])); - int sz2=ret[i].size(); - PyObject *elt2=PyList_New(sz2); - for(int j=0;jgetFieldWithProfile(type,iteration,order,meshDimRelToMax,mesh,ret1); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; } - PyObject *getFieldSplitedByType2(int iteration, int order, const char *mname=0) const throw(INTERP_KERNEL::Exception) + PyObject *getFieldSplitedByType2(int iteration, int order, const std::string& mname=std::string()) const throw(INTERP_KERNEL::Exception) { std::vector types; std::vector< std::vector > typesF; @@ -1459,6 +2503,7 @@ namespace ParaMEDMEM ret->incrRef(); return ret; } + PyObject *getUndergroundDataArrayExt(int iteration, int order) const throw(INTERP_KERNEL::Exception) { std::vector< std::pair,std::pair > > elt1Cpp; @@ -1485,106 +2530,6 @@ namespace ParaMEDMEM PyTuple_SetItem(ret,1,elt); return ret; } - - int getTimeId(PyObject *elt0) const throw(INTERP_KERNEL::Exception) - { - if(elt0 && PyInt_Check(elt0)) - {//fmts[3] - int pos=PyInt_AS_LONG(elt0); - return pos; - } - else if(elt0 && PyTuple_Check(elt0)) - { - if(PyTuple_Size(elt0)==2) - { - PyObject *o0=PyTuple_GetItem(elt0,0); - PyObject *o1=PyTuple_GetItem(elt0,1); - if(PyInt_Check(o0) && PyInt_Check(o1)) - {//fmts(1,-1) - int iter=PyInt_AS_LONG(o0); - int order=PyInt_AS_LONG(o1); - return self->getPosOfTimeStep(iter,order); - } - else - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size 2 but two integers are expected in this tuple to request a time steps !"); - } - else - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size != 2 ! two integers are expected in this tuple to request a time steps !"); - } - else if(elt0 && PyFloat_Check(elt0)) - { - double val=PyFloat_AS_DOUBLE(elt0); - return self->getPosGivenTime(val); - } - else - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input params ! expected fmts[int], fmts[int,int] or fmts[double] to request time step !"); - } - - std::vector getTimeIds(PyObject *elts) const throw(INTERP_KERNEL::Exception) - { - if(PyList_Check(elts)) - { - int sz=PyList_Size(elts); - std::vector ret(sz); - for(int i=0;i ret(1); - ret[0]=ParaMEDMEM_MEDFileFieldMultiTS_getTimeId(self,elts); - return ret; - } - } - - void __delitem__(PyObject *elts) throw(INTERP_KERNEL::Exception) - { - std::vector idsToRemove=ParaMEDMEM_MEDFileFieldMultiTS_getTimeIds(self,elts); - if(!idsToRemove.empty()) - self->eraseTimeStepIds(&idsToRemove[0],&idsToRemove[0]+idsToRemove.size()); - } - - void eraseTimeStepIds(PyObject *li) throw(INTERP_KERNEL::Exception) - { - int sw; - int pos1; - std::vector pos2; - DataArrayInt *pos3=0; - DataArrayIntTuple *pos4=0; - convertObjToPossibleCpp1(li,sw,pos1,pos2,pos3,pos4); - switch(sw) - { - case 1: - { - self->eraseTimeStepIds(&pos1,&pos1+1); - return; - } - case 2: - { - if(pos2.empty()) - return; - self->eraseTimeStepIds(&pos2[0],&pos2[0]+pos2.size()); - return ; - } - case 3: - { - self->eraseTimeStepIds(pos3->begin(),pos3->end()); - return ; - } - default: - throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::eraseTimeStepIds : unexpected input array type recognized !"); - } - } - - bool changeMeshNames(PyObject *li) throw(INTERP_KERNEL::Exception) - { - std::vector< std::pair > modifTab=convertVecPairStStFromPy(li); - return self->changeMeshNames(modifTab); - } } }; @@ -1595,9 +2540,9 @@ namespace ParaMEDMEM { PyObject *next() throw(INTERP_KERNEL::Exception) { - MEDFileFieldMultiTS *ret=self->nextt(); + MEDFileAnyTypeFieldMultiTS *ret=self->nextt(); if(ret) - return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDFileFieldMultiTS,SWIG_POINTER_OWN | 0); + return convertMEDFileFieldMultiTS(ret, SWIG_POINTER_OWN | 0 ); else { PyErr_SetString(PyExc_StopIteration,"No more data."); @@ -1607,23 +2552,147 @@ namespace ParaMEDMEM } }; + class MEDFileIntFieldMultiTS : public MEDFileAnyTypeFieldMultiTS + { + public: + 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); + // + 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); + ParaMEDMEM::MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + %extend + { + MEDFileIntFieldMultiTS() + { + return MEDFileIntFieldMultiTS::New(); + } + + MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileIntFieldMultiTS::New(fileName,loadAll); + } + + MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception) + { + return MEDFileIntFieldMultiTS::New(fileName,fieldName,loadAll); + } + + 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;isimpleRepr(); + } + + PyObject *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) 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_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + PyObject *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) 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_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + PyObject *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception) + { + 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_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + PyObject *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const 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_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + PyObject *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol=0) const 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_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + 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); + PyObject *ret=PyTuple_New(2); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + + DataArrayInt *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *ret=self->getUndergroundDataArray(iteration,order); + if(ret) + ret->incrRef(); + return ret; + } + } + }; + class MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable { public: static MEDFileFields *New() throw(INTERP_KERNEL::Exception); - static MEDFileFields *New(const char *fileName) 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); - void write(const char *fileName, int mode) 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); // void resize(int newSize) throw(INTERP_KERNEL::Exception); - void pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception); - void setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception); - MEDFileFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception); - MEDFileFieldMultiTS *getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception); + void pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception); + void setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception); + int getPosFromFieldName(const std::string& fieldName) const throw(INTERP_KERNEL::Exception); + 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); void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception); + bool removeFieldsWithoutAnyTimeStep() throw(INTERP_KERNEL::Exception); %extend { MEDFileFields() @@ -1631,28 +2700,77 @@ namespace ParaMEDMEM return MEDFileFields::New(); } - MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception) + MEDFileFields(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception) { - return MEDFileFields::New(fileName); + return MEDFileFields::New(fileName,loadAll); } std::string __str__() const throw(INTERP_KERNEL::Exception) { return self->simpleRepr(); } - - MEDFileFieldMultiTS *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) + + static MEDFileFields *LoadSpecificEntities(const std::string& fileName, PyObject *entities, bool loadAll=true) throw(INTERP_KERNEL::Exception) { - if(PyInt_Check(obj)) + std::vector > tmp(convertTimePairIdsFromPy(entities)); + std::size_t sz(tmp.size()); + std::vector< std::pair > entitiesCpp(sz); + for(std::size_t i=0;igetFieldAtPos((int)PyInt_AS_LONG(obj)); + entitiesCpp[i].first=(TypeOfField)tmp[i].first; + entitiesCpp[i].second=(INTERP_KERNEL::NormalizedCellType)tmp[i].second; } - else if(PyString_Check(obj)) + return MEDFileFields::LoadSpecificEntities(fileName,entitiesCpp,loadAll); + } + + PyObject *getCommonIterations() const throw(INTERP_KERNEL::Exception) + { + bool ret1; + std::vector< std::pair > ret0=self->getCommonIterations(ret1); + PyObject *ret=PyTuple_New(2); + PyObject *ret_0=PyList_New(ret0.size()); + int rk=0; + for(std::vector< std::pair >::const_iterator iter=ret0.begin();iter!=ret0.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_0,rk,elt); + } + PyTuple_SetItem(ret,0,ret_0); + PyObject *ret_1=ret1?Py_True:Py_False; Py_XINCREF(ret_1); + PyTuple_SetItem(ret,1,ret_1); + return ret; + } + + MEDFileFields *partOfThisLyingOnSpecifiedTimeSteps(PyObject *timeSteps) const throw(INTERP_KERNEL::Exception) + { + std::vector< std::pair > ts=convertTimePairIdsFromPy(timeSteps); + return self->partOfThisLyingOnSpecifiedTimeSteps(ts); + } + + MEDFileFields *partOfThisNotLyingOnSpecifiedTimeSteps(PyObject *timeSteps) const throw(INTERP_KERNEL::Exception) + { + std::vector< std::pair > ts=convertTimePairIdsFromPy(timeSteps); + return self->partOfThisNotLyingOnSpecifiedTimeSteps(ts); + } + + PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + if(obj && PyList_Check(obj)) { - return self->getFieldWithName(PyString_AsString(obj)); + int sz=PyList_Size(obj); + MEDCouplingAutoRefCountObjectPtr da=DataArrayInt::New(); da->alloc(sz,1); + int *pt=da->getPointer(); + for(int i=0;ibuildSubPart(da->begin(),da->end())),SWIGTYPE_p_ParaMEDMEM__MEDFileFields, SWIG_POINTER_OWN | 0 ); } else - throw INTERP_KERNEL::Exception("MEDFileFields::__getitem__ : only integer or string with fieldname supported !"); + return convertMEDFileFieldMultiTS(self->getFieldAtPos(MEDFileFieldsgetitemSingleTS__(self,obj)), SWIG_POINTER_OWN | 0 ); } MEDFileFields *__setitem__(int obj, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception) @@ -1661,6 +2779,11 @@ namespace ParaMEDMEM return self; } + int __len__() const throw(INTERP_KERNEL::Exception) + { + return self->getNumberOfFields(); + } + MEDFileFieldsIterator *__iter__() throw(INTERP_KERNEL::Exception) { return self->iterator(); @@ -1671,27 +2794,457 @@ namespace ParaMEDMEM std::vector< std::pair > modifTab=convertVecPairStStFromPy(li); return self->changeMeshNames(modifTab); } - } - }; - class MEDFileData : public RefCountObject, public MEDFileWritable - { - public: - static MEDFileData *New(const char *fileName) throw(INTERP_KERNEL::Exception); - static MEDFileData *New(); + int getPosOfField(PyObject *elt0) const throw(INTERP_KERNEL::Exception) + { + if(elt0 && 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] !"); + } + + std::vector getPosOfFields(PyObject *elts) const throw(INTERP_KERNEL::Exception) + { + if(PyList_Check(elts)) + { + int sz=PyList_Size(elts); + std::vector ret(sz); + for(int i=0;i ret(1); + ret[0]=ParaMEDMEM_MEDFileFields_getPosOfField(self,elts); + return ret; + } + } + + void pushFields(PyObject *fields) throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + convertFromPyObjVectorOfObj(fields,SWIGTYPE_p_ParaMEDMEM__MEDFileAnyTypeFieldMultiTS,"MEDFileAnyTypeFieldMultiTS",tmp); + self->pushFields(tmp); + } + + void __delitem__(PyObject *elts) throw(INTERP_KERNEL::Exception) + { + 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 !"); + self->destroyFieldsAtPos2(strt,stp,step); + } + else + { + std::vector idsToRemove=ParaMEDMEM_MEDFileFields_getPosOfFields(self,elts); + if(!idsToRemove.empty()) + self->destroyFieldsAtPos(&idsToRemove[0],&idsToRemove[0]+idsToRemove.size()); + } + } + } + }; + + class MEDFileParameter1TS : public RefCountObject + { + public: + void setIteration(int it); + int getIteration() const; + void setOrder(int order); + int getOrder() const; + void setTimeValue(double time); + void setTime(int dt, int it, double time); + double getTime(int& dt, int& it); + double getTimeValue() const; + }; + + class MEDFileParameterDouble1TSWTI : public MEDFileParameter1TS + { + public: + void setValue(double val) throw(INTERP_KERNEL::Exception); + double getValue() const throw(INTERP_KERNEL::Exception); + std::string simpleRepr() const throw(INTERP_KERNEL::Exception); + %extend + { + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); + } + } + }; + + class MEDFileParameterTinyInfo : public MEDFileWritable + { + public: + void setDescription(const std::string& name); + std::string getDescription() const; + void setTimeUnit(const std::string& unit); + std::string getTimeUnit() const; + }; + + class MEDFileParameterDouble1TS : public MEDFileParameterDouble1TSWTI, public MEDFileParameterTinyInfo + { + public: + static MEDFileParameterDouble1TS *New(); + static MEDFileParameterDouble1TS *New(const std::string& fileName) throw(INTERP_KERNEL::Exception); + static MEDFileParameterDouble1TS *New(const std::string& fileName, const std::string& paramName) throw(INTERP_KERNEL::Exception); + static MEDFileParameterDouble1TS *New(const std::string& fileName, const std::string& paramName, int dt, int it) throw(INTERP_KERNEL::Exception); + virtual MEDFileParameter1TS *deepCpy() const throw(INTERP_KERNEL::Exception); + virtual std::string simpleRepr() const throw(INTERP_KERNEL::Exception); + void setName(const std::string& name) 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); + %extend + { + MEDFileParameterDouble1TS() + { + return MEDFileParameterDouble1TS::New(); + } + + MEDFileParameterDouble1TS(const std::string& fileName) throw(INTERP_KERNEL::Exception) + { + return MEDFileParameterDouble1TS::New(fileName); + } + + MEDFileParameterDouble1TS(const std::string& fileName, const std::string& paramName) throw(INTERP_KERNEL::Exception) + { + return MEDFileParameterDouble1TS::New(fileName,paramName); + } + + MEDFileParameterDouble1TS(const std::string& fileName, const std::string& paramName, int dt, int it) throw(INTERP_KERNEL::Exception) + { + return MEDFileParameterDouble1TS::New(fileName,paramName,dt,it); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); + } + + PyObject *isEqual(const MEDFileParameter1TS *other, double eps) const throw(INTERP_KERNEL::Exception) + { + std::string what; + bool ret0=self->isEqual(other,eps,what); + PyObject *res=PyList_New(2); + PyObject *ret0Py=ret0?Py_True:Py_False; + Py_XINCREF(ret0Py); + PyList_SetItem(res,0,ret0Py); + PyList_SetItem(res,1,PyString_FromString(what.c_str())); + return res; + } + } + }; + + class MEDFileParameterMultiTS : public RefCountObject, public MEDFileParameterTinyInfo + { + public: + static MEDFileParameterMultiTS *New(); + static MEDFileParameterMultiTS *New(const std::string& fileName) throw(INTERP_KERNEL::Exception); + static MEDFileParameterMultiTS *New(const std::string& fileName, const std::string& paramName) throw(INTERP_KERNEL::Exception); + std::string getName() const; + void setName(const std::string& name); + MEDFileParameterMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception); + void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); + std::string simpleRepr() const throw(INTERP_KERNEL::Exception); + void appendValue(int dt, int it, double time, double val) throw(INTERP_KERNEL::Exception); + double getDoubleValue(int iteration, int order) const 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); + int getNumberOfTS() const throw(INTERP_KERNEL::Exception); + %extend + { + MEDFileParameterMultiTS() + { + return MEDFileParameterMultiTS::New(); + } + + MEDFileParameterMultiTS(const std::string& fileName) + { + return MEDFileParameterMultiTS::New(fileName); + } + + MEDFileParameterMultiTS(const std::string& fileName, const std::string& paramName) + { + return MEDFileParameterMultiTS::New(fileName,paramName); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); + } + + PyObject *isEqual(const MEDFileParameterMultiTS *other, double eps) const throw(INTERP_KERNEL::Exception) + { + std::string what; + bool ret0=self->isEqual(other,eps,what); + PyObject *res=PyList_New(2); + PyObject *ret0Py=ret0?Py_True:Py_False; + Py_XINCREF(ret0Py); + PyList_SetItem(res,0,ret0Py); + PyList_SetItem(res,1,PyString_FromString(what.c_str())); + return res; + } + + void eraseTimeStepIds(PyObject *ids) throw(INTERP_KERNEL::Exception) + { + int sw; + int pos1; + std::vector pos2; + DataArrayInt *pos3=0; + DataArrayIntTuple *pos4=0; + convertObjToPossibleCpp1(ids,sw,pos1,pos2,pos3,pos4); + switch(sw) + { + case 1: + { + self->eraseTimeStepIds(&pos1,&pos1+1); + return; + } + case 2: + { + if(pos2.empty()) + return; + self->eraseTimeStepIds(&pos2[0],&pos2[0]+pos2.size()); + return ; + } + case 3: + { + self->eraseTimeStepIds(pos3->begin(),pos3->end()); + return ; + } + default: + throw INTERP_KERNEL::Exception("MEDFileParameterMultiTS::eraseTimeStepIds : unexpected input array type recognized !"); + } + } + + int getTimeStepId(PyObject *elt0) const throw(INTERP_KERNEL::Exception) + { + if(elt0 && PyInt_Check(elt0)) + {//fmts[3] + int pos=InterpreteNegativeInt(PyInt_AS_LONG(elt0),self->getNumberOfTS()); + return pos; + } + else if(elt0 && PyTuple_Check(elt0)) + { + if(PyTuple_Size(elt0)==2) + { + PyObject *o0=PyTuple_GetItem(elt0,0); + PyObject *o1=PyTuple_GetItem(elt0,1); + if(PyInt_Check(o0) && PyInt_Check(o1)) + {//fmts(1,-1) + int iter=PyInt_AS_LONG(o0); + int order=PyInt_AS_LONG(o1); + return self->getPosOfTimeStep(iter,order); + } + else + throw INTERP_KERNEL::Exception("MEDFileParameterMultiTS::getTimeStepId : invalid input param ! input is a tuple of size 2 but two integers are expected in this tuple to request a time steps !"); + } + else + throw INTERP_KERNEL::Exception("MEDFileParameterMultiTS::getTimeStepId : invalid input param ! input is a tuple of size != 2 ! two integers are expected in this tuple to request a time steps !"); + } + else if(elt0 && PyFloat_Check(elt0)) + { + double val=PyFloat_AS_DOUBLE(elt0); + return self->getPosGivenTime(val); + } + else + throw INTERP_KERNEL::Exception("MEDFileParameterMultiTS::getTimeStepId : invalid input params ! expected fmts[int], fmts[int,int] or fmts[double] to request time step !"); + } + + MEDFileParameter1TS *__getitem__(PyObject *elt0) const throw(INTERP_KERNEL::Exception) + { + MEDFileParameter1TS *ret=self->getTimeStepAtPos(ParaMEDMEM_MEDFileParameterMultiTS_getTimeStepId(self,elt0)); + if(ret) + ret->incrRef(); + return ret; + } + + std::vector getTimeStepIds(PyObject *elts) const throw(INTERP_KERNEL::Exception) + { + if(PyList_Check(elts)) + { + int sz=PyList_Size(elts); + std::vector ret(sz); + for(int i=0;i ret(1); + ret[0]=ParaMEDMEM_MEDFileParameterMultiTS_getTimeStepId(self,elts); + return ret; + } + } + + void __delitem__(PyObject *elts) throw(INTERP_KERNEL::Exception) + { + std::vector idsToRemove=ParaMEDMEM_MEDFileParameterMultiTS_getTimeStepIds(self,elts); + if(!idsToRemove.empty()) + self->eraseTimeStepIds(&idsToRemove[0],&idsToRemove[0]+idsToRemove.size()); + } + + MEDFileParameter1TS *getTimeStepAtPos(int posId) const throw(INTERP_KERNEL::Exception) + { + MEDFileParameter1TS *ret=self->getTimeStepAtPos(posId); + if(ret) + ret->incrRef(); + return ret; + } + + 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; + } + + PyObject *getTimeSteps() const throw(INTERP_KERNEL::Exception) + { + std::vector res2; + std::vector< std::pair > res=self->getTimeSteps(res2); + 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(3); + PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first)); + PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second)); + PyTuple_SetItem(elt,2,SWIG_From_double(res2[rk])); + PyList_SetItem(ret,rk,elt); + } + return ret; + } + } + }; + + class MEDFileParameters : public RefCountObject, public MEDFileWritable + { + public: + static MEDFileParameters *New(); + static MEDFileParameters *New(const std::string& fileName) throw(INTERP_KERNEL::Exception); + MEDFileParameters *deepCpy() 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); + void pushParam(MEDFileParameterMultiTS *param) throw(INTERP_KERNEL::Exception); + void setParamAtPos(int i, MEDFileParameterMultiTS *param) throw(INTERP_KERNEL::Exception); + void destroyParamAtPos(int i) throw(INTERP_KERNEL::Exception); + int getPosFromParamName(const std::string& paramName) const throw(INTERP_KERNEL::Exception); + int getNumberOfParams() const throw(INTERP_KERNEL::Exception); + %extend + { + MEDFileParameters() + { + return MEDFileParameters::New(); + } + + MEDFileParameters(const std::string& fileName) + { + return MEDFileParameters::New(fileName); + } + + std::string __str__() const throw(INTERP_KERNEL::Exception) + { + return self->simpleRepr(); + } + + MEDFileParameterMultiTS *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) + { + if(PyInt_Check(obj)) + { + MEDFileParameterMultiTS *ret=self->getParamAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfParams())); + if(ret) + 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 !"); + } + + int __len__() const throw(INTERP_KERNEL::Exception) + { + return self->getNumberOfParams(); + } + + MEDFileParameterMultiTS *getParamAtPos(int i) const throw(INTERP_KERNEL::Exception) + { + MEDFileParameterMultiTS *ret=self->getParamAtPos(i); + if(ret) + ret->incrRef(); + return ret; + } + + MEDFileParameterMultiTS *getParamWithName(const std::string& paramName) const throw(INTERP_KERNEL::Exception) + { + MEDFileParameterMultiTS *ret=self->getParamWithName(paramName); + if(ret) + ret->incrRef(); + return ret; + } + + PyObject *isEqual(const MEDFileParameters *other, double eps) const throw(INTERP_KERNEL::Exception) + { + std::string what; + bool ret0=self->isEqual(other,eps,what); + PyObject *res=PyList_New(2); + PyObject *ret0Py=ret0?Py_True:Py_False; + Py_XINCREF(ret0Py); + PyList_SetItem(res,0,ret0Py); + PyList_SetItem(res,1,PyString_FromString(what.c_str())); + return res; + } + } + }; + + class MEDFileData : public RefCountObject, public MEDFileWritable + { + public: + static MEDFileData *New(const std::string& fileName) throw(INTERP_KERNEL::Exception); + static MEDFileData *New(); MEDFileData *deepCpy() const throw(INTERP_KERNEL::Exception); void setFields(MEDFileFields *fields) throw(INTERP_KERNEL::Exception); void setMeshes(MEDFileMeshes *meshes) throw(INTERP_KERNEL::Exception); + void setParams(MEDFileParameters *params) throw(INTERP_KERNEL::Exception); int getNumberOfFields() const throw(INTERP_KERNEL::Exception); int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception); + int getNumberOfParams() const throw(INTERP_KERNEL::Exception); // - bool changeMeshName(const char *oldMeshName, const char *newMeshName) throw(INTERP_KERNEL::Exception); + bool changeMeshName(const std::string& oldMeshName, const std::string& newMeshName) throw(INTERP_KERNEL::Exception); bool unPolyzeMeshes() throw(INTERP_KERNEL::Exception); // - void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); + void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); %extend { - MEDFileData(const char *fileName) throw(INTERP_KERNEL::Exception) + MEDFileData(const std::string& fileName) throw(INTERP_KERNEL::Exception) { return MEDFileData::New(fileName); } @@ -1714,6 +3267,14 @@ namespace ParaMEDMEM return ret; } + MEDFileParameters *getParams() const throw(INTERP_KERNEL::Exception) + { + MEDFileParameters *ret=self->getParams(); + if(ret) + ret->incrRef(); + return ret; + } + MEDFileFields *getFields() const throw(INTERP_KERNEL::Exception) { MEDFileFields *ret=self->getFields(); @@ -1733,8 +3294,15 @@ namespace ParaMEDMEM class SauvReader : public RefCountObject { public: - static SauvReader* New(const char *fileName) throw(INTERP_KERNEL::Exception); + static SauvReader* New(const std::string& fileName) throw(INTERP_KERNEL::Exception); MEDFileData * loadInMEDFileDS() throw(INTERP_KERNEL::Exception); + %extend + { + SauvReader(const std::string& fileName) throw(INTERP_KERNEL::Exception) + { + return SauvReader::New(fileName); + } + } }; class SauvWriter : public RefCountObject @@ -1742,7 +3310,216 @@ namespace ParaMEDMEM public: static SauvWriter * New(); void setMEDFileDS(const MEDFileData* medData, unsigned meshIndex = 0) throw(INTERP_KERNEL::Exception); - void write(const char* fileName) throw(INTERP_KERNEL::Exception); + void write(const std::string& fileName) throw(INTERP_KERNEL::Exception); + void setCpyGrpIfOnASingleFamilyStatus(bool status) throw(INTERP_KERNEL::Exception); + bool getCpyGrpIfOnASingleFamilyStatus() const throw(INTERP_KERNEL::Exception); + %extend + { + SauvWriter() throw(INTERP_KERNEL::Exception) + { + return SauvWriter::New(); + } + } }; + + /////////////// + + class MEDFileMeshStruct; + class MEDFileField1TSStructItem + { + public: + static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception); + }; + + class MEDFileMeshStruct : public RefCountObject + { + public: + static MEDFileMeshStruct *New(const MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception); + protected: + ~MEDFileMeshStruct(); + }; + + class MEDMeshMultiLev : public RefCountObject + { + public: + virtual MEDMeshMultiLev *prepare() const throw(INTERP_KERNEL::Exception); + DataArray *buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const throw(INTERP_KERNEL::Exception); + protected: + ~MEDMeshMultiLev(); + public: + %extend + { + PyObject *retrieveFamilyIdsOnCells() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *famIds(0); + bool isWithoutCopy(false); + self->retrieveFamilyIdsOnCells(famIds,isWithoutCopy); + PyObject *ret=PyTuple_New(2); + PyObject *ret1Py=isWithoutCopy?Py_True:Py_False; + Py_XINCREF(ret1Py); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(famIds),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,ret1Py); + return ret; + } + + PyObject *retrieveNumberIdsOnCells() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *numIds(0); + bool isWithoutCopy(false); + self->retrieveNumberIdsOnCells(numIds,isWithoutCopy); + PyObject *ret=PyTuple_New(2); + PyObject *ret1Py=isWithoutCopy?Py_True:Py_False; + Py_XINCREF(ret1Py); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(numIds),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,ret1Py); + return ret; + } + + PyObject *retrieveFamilyIdsOnNodes() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *famIds(0); + bool isWithoutCopy(false); + self->retrieveFamilyIdsOnNodes(famIds,isWithoutCopy); + PyObject *ret=PyTuple_New(2); + PyObject *ret1Py=isWithoutCopy?Py_True:Py_False; + Py_XINCREF(ret1Py); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(famIds),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,ret1Py); + return ret; + } + + PyObject *retrieveNumberIdsOnNodes() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *numIds(0); + bool isWithoutCopy(false); + self->retrieveNumberIdsOnNodes(numIds,isWithoutCopy); + PyObject *ret=PyTuple_New(2); + PyObject *ret1Py=isWithoutCopy?Py_True:Py_False; + Py_XINCREF(ret1Py); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(numIds),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,ret1Py); + return ret; + } + + PyObject *getGeoTypes() const throw(INTERP_KERNEL::Exception) + { + std::vector< INTERP_KERNEL::NormalizedCellType > result(self->getGeoTypes()); + std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator iL(result.begin()); + PyObject *res(PyList_New(result.size())); + for(int i=0;iL!=result.end(); i++, iL++) + PyList_SetItem(res,i,PyInt_FromLong(*iL)); + return res; + } + } + }; + + class MEDUMeshMultiLev : public MEDMeshMultiLev + { + protected: + ~MEDUMeshMultiLev(); + public: + %extend + { + PyObject *buildVTUArrays() const throw(INTERP_KERNEL::Exception) + { + DataArrayDouble *coords(0); DataArrayByte *types(0); DataArrayInt *cellLocations(0),*cells(0),*faceLocations(0),*faces(0); + bool ncc(self->buildVTUArrays(coords,types,cellLocations,cells,faceLocations,faces)); + PyObject *ret0Py=ncc?Py_True:Py_False; + Py_XINCREF(ret0Py); + PyObject *ret=PyTuple_New(7); + PyTuple_SetItem(ret,0,ret0Py); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(coords),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(types),SWIGTYPE_p_ParaMEDMEM__DataArrayByte, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(cellLocations),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(cells),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,5,SWIG_NewPointerObj(SWIG_as_voidptr(faceLocations),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,6,SWIG_NewPointerObj(SWIG_as_voidptr(faces),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return ret; + } + } + }; + + class MEDStructuredMeshMultiLev : public MEDMeshMultiLev + { + protected: + ~MEDStructuredMeshMultiLev(); + }; + + class MEDCMeshMultiLev : public MEDStructuredMeshMultiLev + { + protected: + ~MEDCMeshMultiLev(); + public: + %extend + { + PyObject *buildVTUArrays() const throw(INTERP_KERNEL::Exception) + { + bool isInternal; + std::vector< DataArrayDouble * > objs(self->buildVTUArrays(isInternal)); + std::size_t sz(objs.size()); + PyObject *ret(PyTuple_New(2)); + PyObject *ret0=PyList_New(sz); + for(std::size_t i=0;i ret1; + bool ret2; + self->buildVTUArrays(ret0,ret1,ret2); + std::size_t sz(ret1.size()); + PyObject *ret=PyTuple_New(3); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); + PyObject *ret1Py=PyList_New(sz); + for(std::size_t i=0;i result(self->getGeoTypesAt(timeStepId,m)); + std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator iL(result.begin()); + PyObject *res(PyList_New(result.size())); + for(int i=0;iL!=result.end(); i++, iL++) + PyList_SetItem(res,i,PyInt_FromLong(*iL)); + return res; + } + } + }; }