X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FSwig%2FMEDLoaderCommon.i;h=5c3c7c81150c9ed0e928a1dadbad6074b10befb3;hb=ba63422f07d64dc36cbdeed4060a00db1069d9db;hp=a5ee0a00679045af4da1ca645e89708c148566a8;hpb=e197fcb8cc603df9c360df1798e4fce8ca12366e;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index a5ee0a006..5c3c7c811 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D +// Copyright (C) 2007-2014 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 @@ -93,6 +93,7 @@ using namespace ParaMEDMEM; %newobject ParaMEDMEM::MEDFileMesh::getNodeFamiliesArr; %newobject ParaMEDMEM::MEDFileMesh::getAllFamiliesIdsReferenced; %newobject ParaMEDMEM::MEDFileMesh::computeAllFamilyIdsInUse; +%newobject ParaMEDMEM::MEDFileStructuredMesh::getImplicitFaceMesh; %newobject ParaMEDMEM::MEDFileUMesh::New; %newobject ParaMEDMEM::MEDFileUMesh::getCoords; %newobject ParaMEDMEM::MEDFileUMesh::getGroup; @@ -492,6 +493,9 @@ namespace ParaMEDMEM void setTimeUnit(const std::string& unit); std::string getTimeUnit() const; virtual int getNumberOfNodes() 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); @@ -624,6 +628,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); @@ -759,16 +783,6 @@ namespace ParaMEDMEM { return MEDFileUMesh::New(); } - - 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 *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) { @@ -851,6 +865,17 @@ namespace ParaMEDMEM 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 @@ -1016,7 +1041,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; @@ -1216,6 +1241,7 @@ namespace ParaMEDMEM 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); @@ -1632,6 +1658,7 @@ namespace ParaMEDMEM 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); @@ -1798,12 +1825,8 @@ namespace ParaMEDMEM { Py_ssize_t strt=2,stp=2,step=2; PySliceObject *oC=reinterpret_cast(elts); - if(PySlice_GetIndices(oC,self->getNumberOfTS(),&strt,&stp,&step)==0) - { - self->eraseTimeStepIds2(strt,stp,step); - } - else - throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS.__delitem__ : error in input slice !"); + GetIndicesOfSlice(oC,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__delitem__ : error in input slice !"); + self->eraseTimeStepIds2(strt,stp,step); } else { @@ -1868,10 +1891,8 @@ namespace ParaMEDMEM { Py_ssize_t strt=2,stp=2,step=2; PySliceObject *oC=reinterpret_cast(elt0); - if(PySlice_GetIndices(oC,self->getNumberOfTS(),&strt,&stp,&step)==0) - return convertMEDFileFieldMultiTS(self->buildSubPartSlice(strt,stp,step),SWIG_POINTER_OWN | 0); - else - throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS.__getitem__ : error in input slice !"); + 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); @@ -2216,6 +2237,7 @@ namespace ParaMEDMEM 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); @@ -2229,6 +2251,7 @@ namespace ParaMEDMEM 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() @@ -2364,10 +2387,8 @@ namespace ParaMEDMEM { Py_ssize_t strt=2,stp=2,step=2; PySliceObject *oC=reinterpret_cast(elts); - if(PySlice_GetIndices(oC,self->getNumberOfFields(),&strt,&stp,&step)==0) - self->destroyFieldsAtPos2(strt,stp,step); - else - throw INTERP_KERNEL::Exception("MEDFileFields.__delitem__ : error in input slice !"); + GetIndicesOfSlice(oC,self->getNumberOfFields(),&strt,&stp,&step,"MEDFileFields.__delitem__ : error in input slice !"); + self->destroyFieldsAtPos2(strt,stp,step); } else { @@ -2484,6 +2505,7 @@ namespace ParaMEDMEM 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() @@ -2554,7 +2576,7 @@ namespace ParaMEDMEM { if(elt0 && PyInt_Check(elt0)) {//fmts[3] - int pos=PyInt_AS_LONG(elt0); + int pos=InterpreteNegativeInt(PyInt_AS_LONG(elt0),self->getNumberOfTS()); return pos; } else if(elt0 && PyTuple_Check(elt0)) @@ -2698,7 +2720,7 @@ namespace ParaMEDMEM { if(PyInt_Check(obj)) { - MEDFileParameterMultiTS *ret=self->getParamAtPos((int)PyInt_AS_LONG(obj)); + MEDFileParameterMultiTS *ret=self->getParamAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfParams())); if(ret) ret->incrRef(); return ret; @@ -2819,7 +2841,7 @@ namespace ParaMEDMEM { public: static SauvReader* New(const std::string& fileName) throw(INTERP_KERNEL::Exception); - MEDFileData * loadInMEDFileDS() throw(INTERP_KERNEL::Exception); + MEDFileData * loadInMEDFileDS(bool fix2DOri=false) throw(INTERP_KERNEL::Exception); %extend { SauvReader(const std::string& fileName) throw(INTERP_KERNEL::Exception) @@ -2925,6 +2947,16 @@ namespace ParaMEDMEM 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; + } } }; @@ -2969,17 +3001,17 @@ namespace ParaMEDMEM { PyObject *buildVTUArrays() const throw(INTERP_KERNEL::Exception) { - bool isInternal; + bool isInternal; std::vector< DataArrayDouble * > objs(self->buildVTUArrays(isInternal)); std::size_t sz(objs.size()); - PyObject *ret(PyTuple_New(2)); + PyObject *ret(PyTuple_New(2)); PyObject *ret0=PyList_New(sz); for(std::size_t i=0;i ret1; - bool ret2; + bool ret2; self->buildVTUArrays(ret0,ret1,ret2); std::size_t sz(ret1.size()); PyObject *ret=PyTuple_New(3); @@ -3005,9 +3037,9 @@ namespace ParaMEDMEM 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; + } + } }; }