From: ageay Date: Wed, 24 Aug 2011 14:37:22 +0000 (+0000) Subject: Addition of getTypesOfFieldAvailable method. X-Git-Tag: V6_main_FINAL~978 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=66df0f1076d8e98e27efff22f9b2b34becdbc0b6;p=tools%2Fmedcoupling.git Addition of getTypesOfFieldAvailable method. --- diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index e0f5c38bf..e397c5525 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -307,6 +307,11 @@ TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const return _type; } +void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set& types) const throw(INTERP_KERNEL::Exception) +{ + types.insert(_type); +} + void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType) { _type=newType; @@ -598,6 +603,14 @@ void MEDFileFieldPerMeshPerType::getDimension(int& dim) const dim=std::max(dim,curDim); } +void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set& types) const throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) + { + (*it)->fillTypesOfFieldAvailable(types); + } +} + int MEDFileFieldPerMeshPerType::getIteration() const { return _father->getIteration(); @@ -853,6 +866,12 @@ void MEDFileFieldPerMesh::getDimension(int& dim) const (*it)->getDimension(dim); } +void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set& types) const throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++) + (*it)->fillTypesOfFieldAvailable(types); +} + double MEDFileFieldPerMesh::getTime() const { return _father->getTime(); @@ -1700,6 +1719,24 @@ void MEDFileField1TSWithoutDAS::fillIteration(std::pair& p) const p.second=_order; } +void MEDFileField1TSWithoutDAS::fillTypesOfFieldAvailable(std::vector& types) const throw(INTERP_KERNEL::Exception) +{ + std::set types2; + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) + { + (*it)->fillTypesOfFieldAvailable(types2); + } + std::back_insert_iterator< std::vector > bi(types); + std::copy(types2.begin(),types2.end(),bi); +} + +std::vector MEDFileField1TSWithoutDAS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception) +{ + std::vector ret; + fillTypesOfFieldAvailable(ret); + return ret; +} + void MEDFileField1TSWithoutDAS::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception) { med_int numdt,numit; @@ -2331,6 +2368,15 @@ std::vector< std::pair > MEDFileFieldMultiTSWithoutDAS::getIterations() return ret; } +std::vector< std::vector > MEDFileFieldMultiTSWithoutDAS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception) +{ + int lgth=_time_steps.size(); + std::vector< std::vector > ret(lgth); + for(int i=0;ifillTypesOfFieldAvailable(ret[i]); + return ret; +} + const MEDFileField1TSWithoutDAS& MEDFileFieldMultiTSWithoutDAS::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception) { for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++) diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index 91115902d..39b919d7d 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -93,6 +93,7 @@ namespace ParaMEDMEM std::string getName() const; std::string getMeshName() const; TypeOfField getType() const; + void fillTypesOfFieldAvailable(std::set& types) const throw(INTERP_KERNEL::Exception); void setType(TypeOfField newType); INTERP_KERNEL::NormalizedCellType getGeoType() const; int getNumberOfComponents() const; @@ -132,6 +133,7 @@ namespace ParaMEDMEM void finishLoading(med_idt fid, TypeOfField type) throw(INTERP_KERNEL::Exception); void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); void getDimension(int& dim) const; + void fillTypesOfFieldAvailable(std::set& types) const throw(INTERP_KERNEL::Exception); int getIteration() const; int getOrder() const; double getTime() const; @@ -169,6 +171,7 @@ namespace ParaMEDMEM void assignNodeFieldProfile(const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); void finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception); void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); + void fillTypesOfFieldAvailable(std::set& types) const throw(INTERP_KERNEL::Exception); void getDimension(int& dim) const; double getTime() const; int getIteration() const; @@ -292,6 +295,7 @@ namespace ParaMEDMEM bool isDealingTS(int iteration, int order) const; std::pair getDtIt() const; void fillIteration(std::pair& p) const; + void fillTypesOfFieldAvailable(std::vector& types) const throw(INTERP_KERNEL::Exception); const std::vector& getInfo() const { return _infos; } // static MEDFileField1TSWithoutDAS *New(const char *fieldName, int csit, int iteration, int order, const std::vector& infos); @@ -305,6 +309,7 @@ namespace ParaMEDMEM void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); public: + std::vector getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFieldFieldGlobsReal *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception); @@ -358,6 +363,7 @@ namespace ParaMEDMEM static MEDFileFieldMultiTSWithoutDAS *New(med_idt fid, const char *fieldName, int id, const std::vector& infos, int nbOfStep) throw(INTERP_KERNEL::Exception); int getNumberOfTS() const; std::vector< std::pair > getIterations() const; + std::vector< std::vector > getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception); void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); std::string getName() const; std::vector< std::pair > getTimeSteps(std::vector& ret1) const throw(INTERP_KERNEL::Exception); diff --git a/src/MEDLoader/Swig/MEDLoader.i b/src/MEDLoader/Swig/MEDLoader.i index 59dd73948..842ef52b3 100644 --- a/src/MEDLoader/Swig/MEDLoader.i +++ b/src/MEDLoader/Swig/MEDLoader.i @@ -567,6 +567,15 @@ namespace ParaMEDMEM 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 > ret=self->getTypesOfFieldAvailable(); + PyObject *ret2=PyList_New(ret.size()); + for(int i=0;i& rett=ret[i]; + PyObject *ret3=PyList_New(rett.size()); + for(int j=0;j