From: Anthony Geay Date: Mon, 30 Nov 2015 17:12:48 +0000 (+0100) Subject: step2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b90dd3a3aabbf030854266e0cb266f8db0d0c833;p=tools%2Fmedcoupling.git step2 --- diff --git a/src/MEDLoader/MEDFileEquivalence.cxx b/src/MEDLoader/MEDFileEquivalence.cxx index 55a917b84..0c7601a8a 100644 --- a/src/MEDLoader/MEDFileEquivalence.cxx +++ b/src/MEDLoader/MEDFileEquivalence.cxx @@ -336,7 +336,13 @@ DataArrayInt *MEDFileEquivalenceCell::getArray(INTERP_KERNEL::NormalizedCellType void MEDFileEquivalenceCell::setArray(int meshDimRelToMax, DataArrayInt *da) { MEDFileEquivalences::CheckDataArray(da); - //TODO + MEDFileMesh *mm(getMesh()); + std::vector gts(mm->getGeoTypesAtLevel(meshDimRelToMax)); + for(std::vector::const_iterator it=gts.begin();it!=gts.end();it++) + { + mm->getNumberOfCellsWithType(*it); + //TODO + } } void MEDFileEquivalenceCell::load(med_idt fid) diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 1ba3b9cb3..3e3bb25dc 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -3425,6 +3425,13 @@ std::vector MEDFileUMesh::getGeoTypesAtLevel( return sp->getGeoTypes(); } +int MEDFileUMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const +{ + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(ct); + const MEDFileUMeshSplitL1 *sp(getMeshAtLevSafe( ((int)cm.getDimension())-getMeshDimension() )); + return sp->getNumberOfCellsWithType(ct); +} + /*! * This method extracts from whole family field ids the part relative to the input parameter \a gt. * \param [in] gt - the geometric type for which the family field is asked. @@ -5668,6 +5675,14 @@ std::vector MEDFileStructuredMesh::getGeoType } } +int MEDFileStructuredMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const +{ + if(ct!=MEDCouplingStructuredMesh::GetGeoTypeGivenMeshDimension(getMeshDimension())) + return 0; + else + return getNumberOfCellsAtLevel(0); +} + void MEDFileStructuredMesh::whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector& nodesFetched) const { if(st.getNumberOfItems()!=1) diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index 4cb74554f..666032f76 100644 --- a/src/MEDLoader/MEDFileMesh.hxx +++ b/src/MEDLoader/MEDFileMesh.hxx @@ -74,6 +74,7 @@ namespace ParaMEDMEM MEDLOADER_EXPORT virtual int buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const = 0; MEDLOADER_EXPORT virtual void releaseImplicitPartIfAny() const = 0; MEDLOADER_EXPORT virtual std::vector getGeoTypesAtLevel(int meshDimRelToMax) const = 0; + MEDLOADER_EXPORT virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const = 0; MEDLOADER_EXPORT virtual std::vector getNonEmptyLevels() const = 0; MEDLOADER_EXPORT virtual std::vector getNonEmptyLevelsExt() const = 0; MEDLOADER_EXPORT virtual std::vector getFamArrNonEmptyLevelsExt() const = 0; @@ -257,6 +258,7 @@ namespace ParaMEDMEM MEDLOADER_EXPORT int buildImplicitPartIfAny(INTERP_KERNEL::NormalizedCellType gt) const; MEDLOADER_EXPORT void releaseImplicitPartIfAny() const; MEDLOADER_EXPORT std::vector getGeoTypesAtLevel(int meshDimRelToMax) const; + MEDLOADER_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const; MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector& nodesFetched) const; MEDLOADER_EXPORT std::vector getNonEmptyLevels() const; MEDLOADER_EXPORT std::vector getNonEmptyLevelsExt() const; @@ -382,6 +384,7 @@ namespace ParaMEDMEM MEDLOADER_EXPORT void releaseImplicitPartIfAny() const; MEDLOADER_EXPORT MEDCoupling1SGTUMesh *getImplicitFaceMesh() const; MEDLOADER_EXPORT std::vector getGeoTypesAtLevel(int meshDimRelToMax) const; + MEDLOADER_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const; MEDLOADER_EXPORT void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector& nodesFetched) const; MEDLOADER_EXPORT virtual const MEDCouplingStructuredMesh *getStructuredMesh() const = 0; // tools diff --git a/src/MEDLoader/MEDFileMeshLL.cxx b/src/MEDLoader/MEDFileMeshLL.cxx index 8fad6bf6f..6adf25496 100644 --- a/src/MEDLoader/MEDFileMeshLL.cxx +++ b/src/MEDLoader/MEDFileMeshLL.cxx @@ -911,6 +911,11 @@ std::vector MEDFileUMeshSplitL1::getGeoTypes( return _m_by_types.getGeoTypes(); } +int MEDFileUMeshSplitL1::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const +{ + return _m_by_types.getNumberOfCellsWithType(ct); +} + MEDCouplingUMesh *MEDFileUMeshSplitL1::getWholeMesh(bool renum) const { MEDCouplingAutoRefCountObjectPtr tmp; @@ -1268,6 +1273,22 @@ std::vector MEDFileUMeshAggregateCompute::get return _m->getAllGeoTypesSorted(); } +int MEDFileUMeshAggregateCompute::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const +{ + if(_mp_time>=_m_time) + { + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++) + { + const MEDCoupling1GTUMesh *elt(*it); + if(elt && elt->getCellModelEnum()==ct) + return elt->getNumberOfCells(); + } + return 0; + } + else + return _m->getNumberOfCellsWithType(ct); +} + std::vector MEDFileUMeshAggregateCompute::retrievePartsWithoutComputation() const { if(_mp_time<_m_time) diff --git a/src/MEDLoader/MEDFileMeshLL.hxx b/src/MEDLoader/MEDFileMeshLL.hxx index b6872efc7..a65e0c106 100644 --- a/src/MEDLoader/MEDFileMeshLL.hxx +++ b/src/MEDLoader/MEDFileMeshLL.hxx @@ -158,6 +158,7 @@ namespace ParaMEDMEM int getNumberOfCells() const; std::vector getParts() const; std::vector getGeoTypes() const; + int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const; std::vector retrievePartsWithoutComputation() const; MEDCoupling1GTUMesh *retrievePartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const; void getStartStopOfGeoTypeWithoutComputation(INTERP_KERNEL::NormalizedCellType gt, int& start, int& stop) const; @@ -221,6 +222,7 @@ namespace ParaMEDMEM int getNumberOfCells() const; bool isMeshStoredSplitByType() const { return _m_by_types.isStoredSplitByType(); } std::vector getGeoTypes() const; + int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) const; std::vector getDirectUndergroundSingleGeoTypeMeshes() const { return _m_by_types.retrievePartsWithoutComputation(); } MEDCoupling1GTUMesh *getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const { return _m_by_types.retrievePartWithoutComputation(gt); } DataArrayInt *extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const; diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 85d65699b..89e8ea236 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -734,6 +734,7 @@ namespace ParaMEDMEM 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 int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType ct) 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);