From 199dd4ca9c21e9174cc275175e75cf07b4cc5cdc Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Tue, 1 Dec 2015 12:00:51 +0100 Subject: [PATCH] step 3 --- src/MEDLoader/MEDFileEquivalence.cxx | 149 +++++++++++++++++++++++- src/MEDLoader/MEDFileEquivalence.hxx | 34 +++++- src/MEDLoader/MEDFileMesh.cxx | 10 +- src/MEDLoader/MEDFileMesh.hxx | 8 +- src/MEDLoader/Swig/MEDLoaderCommon.i | 164 ++++++++++++++++++++++++++- 5 files changed, 344 insertions(+), 21 deletions(-) diff --git a/src/MEDLoader/MEDFileEquivalence.cxx b/src/MEDLoader/MEDFileEquivalence.cxx index 0c7601a8a..ae556d85b 100644 --- a/src/MEDLoader/MEDFileEquivalence.cxx +++ b/src/MEDLoader/MEDFileEquivalence.cxx @@ -27,6 +27,7 @@ extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO]; extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO]; +extern med_geometry_type typmai3[34]; extern med_geometry_type typmainoeud[1]; using namespace ParaMEDMEM; @@ -40,6 +41,24 @@ MEDFileEquivalencePair *MEDFileEquivalencePair::Load(MEDFileEquivalences *father return ret.retn(); } +void MEDFileEquivalencePair::write(med_idt fid) const +{ + std::string meshName(getFather()->getMeshName()); + INTERP_KERNEL::AutoPtr meshName2(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); + INTERP_KERNEL::AutoPtr name(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); + INTERP_KERNEL::AutoPtr desc(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE)); + MEDLoaderBase::safeStrCpy(meshName.c_str(),MED_NAME_SIZE,meshName2,getFather()->getMesh()->getTooLongStrPolicy()); + MEDLoaderBase::safeStrCpy(_name.c_str(),MED_NAME_SIZE,name,getFather()->getMesh()->getTooLongStrPolicy()); + MEDLoaderBase::safeStrCpy(_description.c_str(),MED_COMMENT_SIZE,desc,getFather()->getMesh()->getTooLongStrPolicy()); + MEDFILESAFECALLERWR0(MEDequivalenceCr,(fid,meshName2,name,desc)); + const MEDFileEquivalenceCell *cell(_cell); + if(cell) + cell->write(fid); + const MEDFileEquivalenceNode *node(_node); + if(node) + node->write(fid); +} + const MEDFileMesh *MEDFileEquivalencePair::getMesh() const { return getFather()->getMesh(); @@ -88,6 +107,24 @@ void MEDFileEquivalencePair::setArray(int meshDimRelToMaxExt, DataArrayInt *da) } } +/*! + * The returned pointer is a borrowed pointer. + */ +MEDFileEquivalenceCell *MEDFileEquivalencePair::initCell() +{ + _cell=new MEDFileEquivalenceCell(this); + return _cell; +} + +/*! + * The returned pointer is a borrowed pointer. + */ +MEDFileEquivalenceNode *MEDFileEquivalencePair::initNode() +{ + _node=new MEDFileEquivalenceNode(this,0); + return _node; +} + std::size_t MEDFileEquivalencePair::getHeapMemorySizeWithoutChildren() const { return 0; @@ -193,11 +230,11 @@ std::vector MEDFileEquivalences::getEquivalenceNames() const return ret; } -void MEDFileEquivalences::appendEmptyEquivalenceWithName(const std::string& name) +MEDFileEquivalencePair *MEDFileEquivalences::appendEmptyEquivalenceWithName(const std::string& name) { MEDCouplingAutoRefCountObjectPtr elt(MEDFileEquivalencePair::New(this,name)); _equ.push_back(elt); - + return elt; } void MEDFileEquivalences::killEquivalenceWithName(const std::string& name) @@ -230,6 +267,21 @@ void MEDFileEquivalences::killEquivalenceAt(int i) _equ.erase(it); } +void MEDFileEquivalences::clear() +{ + _equ.clear(); +} + +void MEDFileEquivalences::write(med_idt fid) const +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_equ.begin();it!=_equ.end();it++) + { + const MEDFileEquivalencePair *elt(*it); + if(elt) + elt->write(fid); + } +} + int MEDFileEquivalences::PresenceOfEquivalences(med_idt fid, const std::string& meshName) { med_int nequ(MEDnEquivalence(fid,meshName.c_str())); @@ -255,7 +307,7 @@ MEDFileEquivalences *MEDFileEquivalences::Load(med_idt fid, int nbOfEq, MEDFileM return ret.retn(); } -void MEDFileEquivalences::CheckDataArray(DataArrayInt *data) +void MEDFileEquivalences::CheckDataArray(const DataArrayInt *data) { if(!data) return; @@ -292,11 +344,36 @@ std::vector MEDFileEquivalenceData::getDirectChildrenWi return ret; } +void MEDFileEquivalenceData::writeLL(med_idt fid, med_entity_type medtype, med_geometry_type medgt) const +{ + + const DataArrayInt *da(getArray()); + if(!da) + return ; + MEDFileEquivalences::CheckDataArray(da); + const MEDFileMesh *mesh(getFather()->getMesh()); + int dt,it; + mesh->getTime(dt,it); + std::string meshName(mesh->getName()); + std::string equName(getFather()->getName()); + INTERP_KERNEL::AutoPtr meshName2(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); + INTERP_KERNEL::AutoPtr name(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); + MEDLoaderBase::safeStrCpy(meshName.c_str(),MED_NAME_SIZE,meshName2,getFather()->getMesh()->getTooLongStrPolicy()); + MEDLoaderBase::safeStrCpy(equName.c_str(),MED_NAME_SIZE,name,getFather()->getMesh()->getTooLongStrPolicy()); + MEDCouplingAutoRefCountObjectPtr da2(da->deepCpy()); da2->rearrange(1); da2->applyLin(1,1); da2->rearrange(2); + MEDFILESAFECALLERWR0(MEDequivalenceCorrespondenceWr,(fid,meshName2,name,dt,it,medtype,medgt,da2->getNumberOfTuples(),da2->begin())); +} + std::size_t MEDFileEquivalenceCellType::getHeapMemorySizeWithoutChildren() const { return sizeof(MEDFileEquivalenceCellType); } +void MEDFileEquivalenceCellType::write(med_idt fid) const +{ + writeLL(fid,MED_CELL,typmai3[_type]); +} + std::vector MEDFileEquivalenceCell::getDirectChildrenWithNull() const { std::size_t sz(_types.size()); @@ -321,6 +398,16 @@ MEDFileEquivalenceCell *MEDFileEquivalenceCell::Load(med_idt fid, MEDFileEquival return 0; } +void MEDFileEquivalenceCell::write(med_idt fid) const +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_types.begin();it!=_types.end();it++) + { + const MEDFileEquivalenceCellType *ct(*it); + if(ct) + ct->write(fid); + } +} + DataArrayInt *MEDFileEquivalenceCell::getArray(INTERP_KERNEL::NormalizedCellType type) { for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_types.begin();it!=_types.end();it++) @@ -335,16 +422,63 @@ DataArrayInt *MEDFileEquivalenceCell::getArray(INTERP_KERNEL::NormalizedCellType void MEDFileEquivalenceCell::setArray(int meshDimRelToMax, DataArrayInt *da) { + if(!da) + return ; MEDFileEquivalences::CheckDataArray(da); MEDFileMesh *mm(getMesh()); + int totalNbOfCells(mm->getNumberOfCellsAtLevel(meshDimRelToMax)); + // + MEDCouplingAutoRefCountObjectPtr tmp(da->deepCpy()); tmp->rearrange(1); + int maxv,minv; + tmp->getMinMaxValues(minv,maxv); + if((minv<0 || minv>=totalNbOfCells) || (maxv<0 || maxv>=totalNbOfCells)) + { + std::ostringstream oss; oss << "MEDFileEquivalenceCell::setArray : Input 2 component DataArray has incorrect values ! all values must be in [0," << totalNbOfCells << ") !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + // std::vector gts(mm->getGeoTypesAtLevel(meshDimRelToMax)); + int startId(0),endId; + std::vector compS(1,0); for(std::vector::const_iterator it=gts.begin();it!=gts.end();it++) { - mm->getNumberOfCellsWithType(*it); - //TODO + endId=startId+mm->getNumberOfCellsWithType(*it); + MEDCouplingAutoRefCountObjectPtr da0(da->keepSelectedComponents(compS)); + MEDCouplingAutoRefCountObjectPtr ids(da0->getIdsInRange(startId,endId)); + MEDCouplingAutoRefCountObjectPtr da1(da->selectByTupleIdSafe(ids->begin(),ids->end())); + da1->applyLin(1,-startId); + setArrayForType(*it,da1); + startId=endId; } } +void MEDFileEquivalenceCell::setArrayForType(INTERP_KERNEL::NormalizedCellType type, DataArrayInt *da) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_types.begin();it!=_types.end();it++) + { + MEDFileEquivalenceCellType *elt(*it); + if(elt && elt->getType()==type) + { + elt->setArray(da); + return ; + } + } + MEDCouplingAutoRefCountObjectPtr newElt(new MEDFileEquivalenceCellType(getFather(),type,da)); + _types.push_back(newElt); +} + +std::vector MEDFileEquivalenceCell::getTypes() const +{ + std::vector ret; + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_types.begin();it!=_types.end();it++) + { + const MEDFileEquivalenceCellType *elt(*it); + if(elt) + ret.push_back(elt->getType()); + } + return ret; +} + void MEDFileEquivalenceCell::load(med_idt fid) { std::string meshName(getFather()->getFather()->getMeshName()),name(getName()); @@ -371,3 +505,8 @@ std::size_t MEDFileEquivalenceNode::getHeapMemorySizeWithoutChildren() const { return sizeof(MEDFileEquivalenceNode); } + +void MEDFileEquivalenceNode::write(med_idt fid) const +{ + writeLL(fid,MED_NODE,MED_NONE); +} diff --git a/src/MEDLoader/MEDFileEquivalence.hxx b/src/MEDLoader/MEDFileEquivalence.hxx index 9e8694247..be352bec5 100644 --- a/src/MEDLoader/MEDFileEquivalence.hxx +++ b/src/MEDLoader/MEDFileEquivalence.hxx @@ -40,6 +40,7 @@ namespace ParaMEDMEM { public: static MEDFileEquivalencePair *Load(MEDFileEquivalences *father, med_idt fid, const std::string& name, const std::string &desc); + void write(med_idt fid) const; const MEDFileEquivalences *getFather() const { return _father; } MEDFileEquivalences *getFather() { return _father; } const MEDFileMesh *getMesh() const; @@ -52,6 +53,8 @@ namespace ParaMEDMEM MEDLOADER_EXPORT void setName(const std::string& name) { _name=name; } MEDLOADER_EXPORT std::string getDescription() const { return _description; } MEDLOADER_EXPORT void setDescription(const std::string& descr) { _description=descr; } + MEDLOADER_EXPORT MEDFileEquivalenceCell *initCell(); + MEDLOADER_EXPORT MEDFileEquivalenceNode *initNode(); MEDLOADER_EXPORT MEDFileEquivalenceCell *getCell() { return _cell; } MEDLOADER_EXPORT MEDFileEquivalenceNode *getNode() { return _node; } MEDLOADER_EXPORT void setArray(int meshDimRelToMaxExt, DataArrayInt *da); @@ -82,13 +85,15 @@ namespace ParaMEDMEM MEDLOADER_EXPORT MEDFileEquivalencePair *getEquivalenceWithName(const std::string& name); MEDLOADER_EXPORT int size() const; MEDLOADER_EXPORT std::vector getEquivalenceNames() const; - MEDLOADER_EXPORT void appendEmptyEquivalenceWithName(const std::string& name); + MEDLOADER_EXPORT MEDFileEquivalencePair *appendEmptyEquivalenceWithName(const std::string& name); MEDLOADER_EXPORT void killEquivalenceWithName(const std::string& name); MEDLOADER_EXPORT void killEquivalenceAt(int i); + MEDLOADER_EXPORT void clear(); public: + void write(med_idt fid) const; static int PresenceOfEquivalences(med_idt fid, const std::string& meshName); static MEDFileEquivalences *Load(med_idt fid, int nbOfEq, MEDFileMesh *owner); - static void CheckDataArray(DataArrayInt *data); + static void CheckDataArray(const DataArrayInt *data); private: MEDFileEquivalences(MEDFileMesh *owner):_owner(owner) { } private: @@ -104,6 +109,8 @@ namespace ParaMEDMEM MEDFileEquivalencePair *getFather() { return _father; } const MEDFileMesh *getMesh() const { return getFather()->getMesh(); } MEDFileMesh *getMesh() { return getFather()->getMesh(); } + protected: + ~MEDFileEquivalenceBase() { } private: MEDFileEquivalencePair *_father; }; @@ -112,10 +119,14 @@ namespace ParaMEDMEM { public: MEDFileEquivalenceData(MEDFileEquivalencePair *owner, DataArrayInt *data); - void setArray(DataArrayInt *data); - const DataArrayInt *getArray() const { return _data; } - DataArrayInt *getArray() { return _data; } + MEDLOADER_EXPORT void setArray(DataArrayInt *data); + MEDLOADER_EXPORT const DataArrayInt *getArray() const { return _data; } + MEDLOADER_EXPORT DataArrayInt *getArray() { return _data; } MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + protected: + void writeLL(med_idt fid, med_entity_type medtype, med_geometry_type medgt) const; + protected: + ~MEDFileEquivalenceData() { } protected: MEDCouplingAutoRefCountObjectPtr _data; }; @@ -126,6 +137,10 @@ namespace ParaMEDMEM MEDFileEquivalenceCellType(MEDFileEquivalencePair *owner, INTERP_KERNEL::NormalizedCellType type, DataArrayInt *data):MEDFileEquivalenceData(owner,data),_type(type) { } MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; INTERP_KERNEL::NormalizedCellType getType() const { return _type; } + public: + void write(med_idt fid) const; + private: + ~MEDFileEquivalenceCellType() { } private: INTERP_KERNEL::NormalizedCellType _type; }; @@ -136,12 +151,18 @@ namespace ParaMEDMEM MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; static MEDFileEquivalenceCell *Load(med_idt fid, MEDFileEquivalencePair *owner); + void write(med_idt fid) const; public: + MEDLOADER_EXPORT void clear() { _types.clear(); } MEDLOADER_EXPORT std::size_t size() const { return _types.size(); } MEDLOADER_EXPORT DataArrayInt *getArray(INTERP_KERNEL::NormalizedCellType type); MEDLOADER_EXPORT void setArray(int meshDimRelToMax, DataArrayInt *da); + MEDLOADER_EXPORT void setArrayForType(INTERP_KERNEL::NormalizedCellType type, DataArrayInt *da); + MEDLOADER_EXPORT std::vector getTypes() const; public: MEDFileEquivalenceCell(MEDFileEquivalencePair *owner):MEDFileEquivalenceBase(owner) { } + private: + ~MEDFileEquivalenceCell() { } private: void load(med_idt fid); std::string getName() const { return getFather()->getName(); } @@ -154,6 +175,9 @@ namespace ParaMEDMEM public: MEDFileEquivalenceNode(MEDFileEquivalencePair *owner, DataArrayInt *data):MEDFileEquivalenceData(owner,data) { } MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; + void write(med_idt fid) const; + private: + ~MEDFileEquivalenceNode() { } }; } diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 3e3bb25dc..619b3e4bd 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -183,6 +183,10 @@ void MEDFileMesh::write(med_idt fid) const if(_name.empty()) throw INTERP_KERNEL::Exception("MEDFileMesh : name is empty. MED file ask for a NON EMPTY name !"); writeLL(fid); + writeJoints(fid); + const MEDFileEquivalences *eqs(_equiv); + if(eqs) + eqs->write(fid); } /*! @@ -2591,8 +2595,6 @@ void MEDFileUMesh::writeLL(med_idt fid) const if((const MEDFileUMeshSplitL1 *)(*it)!=0) (*it)->write(fid,meshName,mdim); MEDFileUMeshL2::WriteFamiliesAndGrps(fid,meshName,_families,_groups,_too_long_str); - - writeJoints(fid); } /*! @@ -6133,8 +6135,6 @@ void MEDFileCMesh::writeLL(med_idt fid) const // std::string meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE)); MEDFileStructuredMesh::writeStructuredLL(fid,meshName); - - writeJoints(fid); } void MEDFileCMesh::synchronizeTinyInfoOnLeaves() const @@ -6342,8 +6342,6 @@ void MEDFileCurveLinearMesh::writeLL(med_idt fid) const // std::string meshName(MEDLoaderBase::buildStringFromFortran(maa,MED_NAME_SIZE)); MEDFileStructuredMesh::writeStructuredLL(fid,meshName); - - writeJoints(fid); } void MEDFileCurveLinearMesh::loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs) diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index 666032f76..496088da6 100644 --- a/src/MEDLoader/MEDFileMesh.hxx +++ b/src/MEDLoader/MEDFileMesh.hxx @@ -63,7 +63,7 @@ namespace ParaMEDMEM MEDLOADER_EXPORT int getIteration() const { return _iteration; } MEDLOADER_EXPORT void setTimeValue(double time) { _time=time; } MEDLOADER_EXPORT void setTime(int dt, int it, double time) { _time=time; _iteration=dt; _order=it; } - MEDLOADER_EXPORT double getTime(int& dt, int& it) { dt=_iteration; it=_order; return _time; } + MEDLOADER_EXPORT double getTime(int& dt, int& it) const { dt=_iteration; it=_order; return _time; } MEDLOADER_EXPORT double getTimeValue() const { return _time; } MEDLOADER_EXPORT void setTimeUnit(const std::string& unit) { _dt_unit=unit; } MEDLOADER_EXPORT std::string getTimeUnit() const { return _dt_unit; } @@ -175,6 +175,9 @@ namespace ParaMEDMEM MEDLOADER_EXPORT int getNumberOfJoints() const; MEDLOADER_EXPORT MEDFileJoints *getJoints() const; MEDLOADER_EXPORT void setJoints( MEDFileJoints* joints ); + MEDFileEquivalences *getEquivalences() { return _equiv; } + const MEDFileEquivalences *getEquivalences() const { return _equiv; } + void initializeEquivalences() { _equiv=MEDFileEquivalences::New(this); } protected: MEDFileMesh(); //! protected because no way in MED file API to specify this name @@ -198,9 +201,6 @@ namespace ParaMEDMEM void writeJoints(med_idt fid) const; void loadJointsFromFile(med_idt fid, MEDFileJoints *toUseInstedOfReading=0); void loadEquivalences(med_idt fid); - MEDFileEquivalences *getEquivalences() { return _equiv; } - const MEDFileEquivalences *getEquivalences() const { return _equiv; } - void initializeEquivalences() { _equiv=MEDFileEquivalences::New(this); } protected: int _order; int _iteration; diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 89e8ea236..0c838c550 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -36,6 +36,7 @@ #include "MEDFileField.hxx" #include "MEDFileParameter.hxx" #include "MEDFileData.hxx" +#include "MEDFileEquivalence.hxx" #include "MEDFileMeshReadSelector.hxx" #include "MEDFileFieldOverView.hxx" #include "MEDLoaderTypemaps.i" @@ -99,6 +100,7 @@ using namespace ParaMEDMEM; %newobject ParaMEDMEM::MEDFileMesh::getNodeFamiliesArr; %newobject ParaMEDMEM::MEDFileMesh::getAllFamiliesIdsReferenced; %newobject ParaMEDMEM::MEDFileMesh::computeAllFamilyIdsInUse; +%newobject ParaMEDMEM::MEDFileMesh::getEquivalences; %newobject ParaMEDMEM::MEDFileData::getJoints; %newobject ParaMEDMEM::MEDFileStructuredMesh::getImplicitFaceMesh; %newobject ParaMEDMEM::MEDFileUMesh::New; @@ -211,6 +213,15 @@ using namespace ParaMEDMEM; %newobject ParaMEDMEM::MEDFileJoints::getJointAtPos; %newobject ParaMEDMEM::MEDFileJoints::getJointWithName; %newobject ParaMEDMEM::MEDFileJoints::__getitem__; +%newobject ParaMEDMEM::MEDFileEquivalences::getEquivalence; +%newobject ParaMEDMEM::MEDFileEquivalences::getEquivalenceWithName; +%newobject ParaMEDMEM::MEDFileEquivalences::appendEmptyEquivalenceWithName; +%newobject ParaMEDMEM::MEDFileEquivalencePair::initCell; +%newobject ParaMEDMEM::MEDFileEquivalencePair::initNode; +%newobject ParaMEDMEM::MEDFileEquivalencePair::getCell; +%newobject ParaMEDMEM::MEDFileEquivalencePair::getNode; +%newobject ParaMEDMEM::MEDFileEquivalenceData::getArray; +%newobject ParaMEDMEM::MEDFileEquivalenceCell::getArray; %newobject ParaMEDMEM::SauvWriter::New; %newobject ParaMEDMEM::SauvReader::New; @@ -244,6 +255,12 @@ using namespace ParaMEDMEM; %feature("unref") MEDFileJointOneStep "$this->decrRef();" %feature("unref") MEDFileJoint "$this->decrRef();" %feature("unref") MEDFileJoints "$this->decrRef();" +%feature("unref") MEDFileEquivalences "$this->decrRef();" +%feature("unref") MEDFileEquivalencePair "$this->decrRef();" +%feature("unref") MEDFileEquivalenceBase "$this->decrRef();" +%feature("unref") MEDFileEquivalenceData "$this->decrRef();" +%feature("unref") MEDFileEquivalenceCell "$this->decrRef();" +%feature("unref") MEDFileEquivalenceNode "$this->decrRef();" %feature("unref") MEDFileData "$this->decrRef();" %feature("unref") SauvReader "$this->decrRef();" %feature("unref") SauvWriter "$this->decrRef();" @@ -501,6 +518,7 @@ namespace ParaMEDMEM } } }; + class MEDFileJointCorrespondence : public RefCountObject, public MEDFileWritable { public: @@ -584,6 +602,7 @@ namespace ParaMEDMEM } } }; + class MEDFileJoint : public RefCountObject, public MEDFileWritable { public: @@ -703,6 +722,141 @@ namespace ParaMEDMEM } } }; + + class MEDFileEquivalenceBase : public RefCountObject + { + private: + MEDFileEquivalenceBase(); + }; + + class MEDFileEquivalenceData : public MEDFileEquivalenceBase + { + private: + MEDFileEquivalenceData(); + public: + void setArray(DataArrayInt *data); + %extend + { + DataArrayInt *getArray() + { + DataArrayInt *ret(self->getArray()); + if(ret) ret->incrRef(); + return ret; + } + } + }; + + class MEDFileEquivalenceNode : public MEDFileEquivalenceData + { + private: + MEDFileEquivalenceNode(); + }; + + class MEDFileEquivalenceCell : public MEDFileEquivalenceBase + { + private: + MEDFileEquivalenceCell(); + public: + void clear(); + std::size_t size() const; + void setArray(int meshDimRelToMax, DataArrayInt *da) throw(INTERP_KERNEL::Exception); + void setArrayForType(INTERP_KERNEL::NormalizedCellType type, DataArrayInt *da) throw(INTERP_KERNEL::Exception); + %extend + { + DataArrayInt *getArray(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception) + { + DataArrayInt *ret(self->getArray(type)); + if(ret) ret->incrRef(); + return ret; + } + + PyObject *getTypes() const throw(INTERP_KERNEL::Exception) + { + std::vector result(self->getTypes()); + 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; + } + } + }; + + class MEDFileEquivalencePair : public RefCountObject + { + private: + MEDFileEquivalencePair(); + public: + std::string getName() const; + void setName(const std::string& name); + std::string getDescription() const; + void setDescription(const std::string& descr); + void setArray(int meshDimRelToMaxExt, DataArrayInt *da);; + %extend + { + MEDFileEquivalenceCell *initCell() + { + MEDFileEquivalenceCell *ret(self->initCell()); + if(ret) ret->incrRef(); + return ret; + } + + MEDFileEquivalenceNode *initNode() + { + MEDFileEquivalenceNode *ret(self->initNode()); + if(ret) ret->incrRef(); + return ret; + } + + MEDFileEquivalenceCell *getCell() + { + MEDFileEquivalenceCell *ret(self->getCell()); + if(ret) ret->incrRef(); + return ret; + } + + MEDFileEquivalenceNode *getNode() + { + MEDFileEquivalenceNode *ret(self->getNode()); + if(ret) ret->incrRef(); + return ret; + } + } + }; + + class MEDFileEquivalences : public RefCountObject + { + private: + MEDFileEquivalences(); + public: + int size() const; + std::vector getEquivalenceNames() const throw(INTERP_KERNEL::Exception); + void killEquivalenceWithName(const std::string& name) throw(INTERP_KERNEL::Exception); + void killEquivalenceAt(int i) throw(INTERP_KERNEL::Exception); + void clear(); + %extend + { + MEDFileEquivalencePair *getEquivalence(int i) throw(INTERP_KERNEL::Exception) + { + MEDFileEquivalencePair *ret(self->getEquivalence(i)); + if(ret) ret->incrRef(); + return ret; + } + MEDFileEquivalencePair *getEquivalenceWithName(const std::string& name) throw(INTERP_KERNEL::Exception) + { + MEDFileEquivalencePair *ret(self->getEquivalenceWithName(name)); + if(ret) ret->incrRef(); + return ret; + } + + MEDFileEquivalencePair *appendEmptyEquivalenceWithName(const std::string& name) throw(INTERP_KERNEL::Exception) + { + MEDFileEquivalencePair *ret(self->appendEmptyEquivalenceWithName(name)); + if(ret) ret->incrRef(); + return ret; + } + } + }; class MEDFileMesh : public RefCountObject, public MEDFileWritable { @@ -820,7 +974,8 @@ namespace ParaMEDMEM virtual DataArrayInt *getNodeFamiliesArr(const std::vector& fams, bool renum=false) const throw(INTERP_KERNEL::Exception); int getNumberOfJoints(); MEDFileJoints *getJoints(); - void setJoints( MEDFileJoints* joints ); + void setJoints( MEDFileJoints* joints ); + void initializeEquivalences(); %extend { std::string __str__() const throw(INTERP_KERNEL::Exception) @@ -990,6 +1145,13 @@ namespace ParaMEDMEM PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(ret3),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); return ret; } + + MEDFileEquivalences *getEquivalences() throw(INTERP_KERNEL::Exception) + { + MEDFileEquivalences *ret(self->getEquivalences()); + if(ret) ret->incrRef(); + return ret; + } } }; -- 2.39.2