X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FMEDFileMesh.hxx;h=4b54ed0ce177913ba62148c0a80270d4d82d434f;hb=8bae03a55f48814db1d747c9ef8a8ee51d64e6d4;hp=b9dc110c0389c1782cbe4d7cee852b73824856be;hpb=638889f1fe147dffd1e61ba40431f31a7a1a9b20;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index b9dc110c0..4b54ed0ce 100644 --- a/src/MEDLoader/MEDFileMesh.hxx +++ b/src/MEDLoader/MEDFileMesh.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D +// Copyright (C) 2007-2019 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 @@ -23,7 +23,7 @@ #include "MEDLoaderDefines.hxx" #include "MEDFileMeshLL.hxx" -#include "MEDFileUtilities.hxx" +#include "MEDFileUtilities.txx" #include "MEDCouplingPartDefinition.hxx" #include "MEDFileMeshReadSelector.hxx" #include "MEDFileJoint.hxx" @@ -41,7 +41,10 @@ namespace MEDCoupling { public: MEDLOADER_EXPORT static MEDFileMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileMesh *New(DataArrayByte *db) { return BuildFromMemoryChunk(db); } MEDLOADER_EXPORT static MEDFileMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0, MEDFileJoints* joints=0); + MEDLOADER_EXPORT static MEDFileMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0, MEDFileJoints* joints=0); MEDLOADER_EXPORT void writeLL(med_idt fid) const; MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; @@ -88,6 +91,8 @@ namespace MEDCoupling MEDLOADER_EXPORT virtual std::vector getDistributionOfTypes(int meshDimRelToMax) const; MEDLOADER_EXPORT virtual void whichAreNodesFetched(const MEDFileField1TSStructItem& st, const MEDFileFieldGlobsReal *globs, std::vector& nodesFetched) const = 0; MEDLOADER_EXPORT virtual MEDFileMesh *cartesianize() const = 0; + MEDLOADER_EXPORT virtual bool presenceOfStructureElements() const = 0; + MEDLOADER_EXPORT virtual void killStructureElements() { } // MEDLOADER_EXPORT bool areFamsEqual(const MEDFileMesh *other, std::string& what) const; MEDLOADER_EXPORT bool areGrpsEqual(const MEDFileMesh *other, std::string& what) const; @@ -131,12 +136,14 @@ namespace MEDCoupling MEDLOADER_EXPORT static std::string GetMagicFamilyStr(); MEDLOADER_EXPORT void assignFamilyNameWithGroupName(); MEDLOADER_EXPORT std::vector removeEmptyGroups(); + MEDLOADER_EXPORT void removeGroupAtLevel(int meshDimRelToMaxExt, const std::string& name); MEDLOADER_EXPORT void removeGroup(const std::string& name); MEDLOADER_EXPORT void removeFamily(const std::string& name); MEDLOADER_EXPORT std::vector removeOrphanGroups(); MEDLOADER_EXPORT std::vector removeOrphanFamilies(); MEDLOADER_EXPORT void removeFamiliesReferedByNoGroups(); MEDLOADER_EXPORT void rearrangeFamilies(); + MEDLOADER_EXPORT void zipFamilies(); MEDLOADER_EXPORT void checkOrphanFamilyZero() const; MEDLOADER_EXPORT void changeGroupName(const std::string& oldName, const std::string& newName); MEDLOADER_EXPORT void changeFamilyName(const std::string& oldName, const std::string& newName); @@ -167,6 +174,7 @@ namespace MEDCoupling MEDLOADER_EXPORT virtual void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) = 0; MEDLOADER_EXPORT virtual void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr) = 0; MEDLOADER_EXPORT virtual void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr) = 0; + MEDLOADER_EXPORT virtual void setGlobalNumFieldAtLevel(int meshDimRelToMaxExt, DataArrayInt *globalNumArr) = 0; MEDLOADER_EXPORT virtual void addNodeGroup(const DataArrayInt *ids) = 0; MEDLOADER_EXPORT virtual void addGroup(int meshDimRelToMaxExt, const DataArrayInt *ids) = 0; MEDLOADER_EXPORT virtual const DataArrayInt *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const = 0; @@ -175,6 +183,7 @@ namespace MEDCoupling MEDLOADER_EXPORT virtual const DataArrayInt *getNumberFieldAtLevel(int meshDimRelToMaxExt) const = 0; MEDLOADER_EXPORT virtual const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const = 0; MEDLOADER_EXPORT virtual const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const = 0; + MEDLOADER_EXPORT virtual MCAuto getGlobalNumFieldAtLevel(int meshDimRelToMaxExt) const = 0; MEDLOADER_EXPORT virtual DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector& fams, bool renum=false) const = 0; MEDLOADER_EXPORT virtual DataArrayInt *getGroupsArr(int meshDimRelToMaxExt, const std::vector& grps, bool renum=false) const; MEDLOADER_EXPORT virtual DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const; @@ -192,6 +201,8 @@ namespace MEDCoupling const MEDFileEquivalences *getEquivalences() const { return _equiv; } void killEquivalences() { _equiv=(MEDFileEquivalences *)0; } void initializeEquivalences() { _equiv=MEDFileEquivalences::New(this); } + static INTERP_KERNEL::NormalizedCellType ConvertFromMEDFileGeoType(med_geometry_type geoType); + static TypeOfField ConvertFromMEDFileEntity(med_entity_type etype); protected: MEDFileMesh(); //! protected because no way in MED file API to specify this name @@ -218,6 +229,7 @@ namespace MEDCoupling bool areEquivalencesEqual(const MEDFileMesh *other, std::string& what) const; void getEquivalencesRepr(std::ostream& oss) const; void checkCartesian() const; + void checkNoGroupClash(const DataArrayInt *famArr, const std::string& grpName) const; private: virtual void writeMeshLL(med_idt fid) const = 0; protected: @@ -247,7 +259,10 @@ namespace MEDCoupling friend class MEDFileMesh; public: MEDLOADER_EXPORT static MEDFileUMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileUMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); MEDLOADER_EXPORT static MEDFileUMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileUMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileUMesh *New(DataArrayByte *db) { return BuildFromMemoryChunk(db); } MEDLOADER_EXPORT static MEDFileUMesh *New(const MEDCouplingMappedExtrudedMesh *mem); MEDLOADER_EXPORT static MEDFileUMesh *New(); MEDLOADER_EXPORT static MEDFileUMesh *LoadPartOf(const std::string& fileName, const std::string& mName, const std::vector& types, const std::vector& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); @@ -264,6 +279,7 @@ namespace MEDCoupling MEDLOADER_EXPORT void clearNodeAndCellNumbers(); MEDLOADER_EXPORT void clearNonDiscrAttributes() const; MEDLOADER_EXPORT void setName(const std::string& name); + MEDLOADER_EXPORT const std::vector< MCAuto >& getAccessOfUndergroundEltStrs() const { return _elt_str; } // MEDLOADER_EXPORT int getMaxAbsFamilyIdInArrays() const; MEDLOADER_EXPORT int getMaxFamilyIdInArrays() const; @@ -278,6 +294,7 @@ namespace MEDCoupling MEDLOADER_EXPORT const DataArrayInt *getNumberFieldAtLevel(int meshDimRelToMaxExt) const; MEDLOADER_EXPORT const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const; MEDLOADER_EXPORT const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const; + MEDLOADER_EXPORT MCAuto getGlobalNumFieldAtLevel(int meshDimRelToMaxExt) const; MEDLOADER_EXPORT const PartDefinition *getPartDefAtLevel(int meshDimRelToMaxExt, INTERP_KERNEL::NormalizedCellType gt=INTERP_KERNEL::NORM_ERROR) const; MEDLOADER_EXPORT int getNumberOfNodes() const; MEDLOADER_EXPORT int getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const; @@ -288,6 +305,8 @@ namespace MEDCoupling 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 MEDFileMesh *cartesianize() const; + MEDLOADER_EXPORT bool presenceOfStructureElements() const; + MEDLOADER_EXPORT void killStructureElements(); MEDLOADER_EXPORT std::vector getNonEmptyLevels() const; MEDLOADER_EXPORT std::vector getNonEmptyLevelsExt() const; MEDLOADER_EXPORT std::vector getFamArrNonEmptyLevelsExt() const; @@ -322,6 +341,7 @@ namespace MEDCoupling MEDLOADER_EXPORT void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr); MEDLOADER_EXPORT void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr); MEDLOADER_EXPORT void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr); + MEDLOADER_EXPORT void setGlobalNumFieldAtLevel(int meshDimRelToMaxExt, DataArrayInt *globalNumArr); MEDLOADER_EXPORT void addNodeGroup(const DataArrayInt *ids); MEDLOADER_EXPORT void addGroup(int meshDimRelToMaxExt, const DataArrayInt *ids); MEDLOADER_EXPORT void removeMeshAtLevel(int meshDimRelToMax); @@ -370,11 +390,13 @@ namespace MEDCoupling private: std::vector< MCAuto > _ms; MCAuto _coords; - MCAuto _fam_coords; + MCAuto _fam_coords; ///< Node family indices MCAuto _num_coords; + MCAuto _global_num_coords; MCAuto _name_coords; mutable MCAuto _rev_num_coords; MCAuto _part_coords; + std::vector< MCAuto > _elt_str; }; class MEDFileStructuredMesh : public MEDFileMesh @@ -394,11 +416,13 @@ namespace MEDCoupling MEDLOADER_EXPORT void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr); MEDLOADER_EXPORT void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr); MEDLOADER_EXPORT void setNameFieldAtLevel(int meshDimRelToMaxExt, DataArrayAsciiChar *nameArr); + MEDLOADER_EXPORT void setGlobalNumFieldAtLevel(int meshDimRelToMaxExt, DataArrayInt *globalNumArr); MEDLOADER_EXPORT void addNodeGroup(const DataArrayInt *ids); MEDLOADER_EXPORT void addGroup(int meshDimRelToMaxExt, const DataArrayInt *ids); MEDLOADER_EXPORT const DataArrayInt *getNumberFieldAtLevel(int meshDimRelToMaxExt) const; MEDLOADER_EXPORT const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const; MEDLOADER_EXPORT const DataArrayAsciiChar *getNameFieldAtLevel(int meshDimRelToMaxExt) const; + MEDLOADER_EXPORT MCAuto getGlobalNumFieldAtLevel(int meshDimRelToMaxExt) const; MEDLOADER_EXPORT std::vector getNonEmptyLevels() const; MEDLOADER_EXPORT std::vector getNonEmptyLevelsExt() const; MEDLOADER_EXPORT std::vector getFamArrNonEmptyLevelsExt() const; @@ -417,6 +441,7 @@ namespace MEDCoupling 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 bool presenceOfStructureElements() const { return false; } MEDLOADER_EXPORT virtual const MEDCouplingStructuredMesh *getStructuredMesh() const = 0; // tools MEDLOADER_EXPORT bool unPolyze(std::vector& oldCode, std::vector& newCode, DataArrayInt *& o2nRenumCell); @@ -454,7 +479,10 @@ namespace MEDCoupling public: MEDLOADER_EXPORT static MEDFileCMesh *New(); MEDLOADER_EXPORT static MEDFileCMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileCMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileCMesh *New(DataArrayByte *db) { return BuildFromMemoryChunk(db); } MEDLOADER_EXPORT static MEDFileCMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileCMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const; @@ -487,7 +515,10 @@ namespace MEDCoupling public: MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(); MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(DataArrayByte *db) { return BuildFromMemoryChunk(db); } MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); + MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const; @@ -517,7 +548,9 @@ namespace MEDCoupling { public: MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(); + MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(med_idt fid); MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(const std::string& fileName); + MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(med_idt fid, const std::string& mName); MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(const std::string& fileName, const std::string& mName); MEDLOADER_EXPORT MEDFileMeshMultiTS *deepCopy() const; MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; @@ -531,12 +564,14 @@ namespace MEDCoupling MEDLOADER_EXPORT void setOneTimeStep(MEDFileMesh *mesh1TimeStep); MEDLOADER_EXPORT MEDFileJoints *getJoints() const; MEDLOADER_EXPORT void setJoints(MEDFileJoints* joints); + MEDLOADER_EXPORT bool presenceOfStructureElements() const; + MEDLOADER_EXPORT void killStructureElements(); private: ~MEDFileMeshMultiTS() { } - void loadFromFile(const std::string& fileName, const std::string& mName); + void loadFromFile(med_idt fid, const std::string& mName); MEDFileMeshMultiTS(); - MEDFileMeshMultiTS(const std::string& fileName); - MEDFileMeshMultiTS(const std::string& fileName, const std::string& mName); + MEDFileMeshMultiTS(med_idt fid); + MEDFileMeshMultiTS(med_idt fid, const std::string& mName); private: std::vector< MCAuto > _mesh_one_ts; }; @@ -547,6 +582,8 @@ namespace MEDCoupling { public: MEDLOADER_EXPORT static MEDFileMeshes *New(); + MEDLOADER_EXPORT static MEDFileMeshes *New(med_idt fid); + MEDLOADER_EXPORT static MEDFileMeshes *New(DataArrayByte *db) { return BuildFromMemoryChunk(db); } MEDLOADER_EXPORT static MEDFileMeshes *New(const std::string& fileName); MEDLOADER_EXPORT MEDFileMeshes *deepCopy() const; MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; @@ -566,12 +603,14 @@ namespace MEDCoupling MEDLOADER_EXPORT void pushMesh(MEDFileMesh *mesh); MEDLOADER_EXPORT void setMeshAtPos(int i, MEDFileMesh *mesh); MEDLOADER_EXPORT void destroyMeshAtPos(int i); + MEDLOADER_EXPORT bool presenceOfStructureElements() const; + MEDLOADER_EXPORT void killStructureElements(); private: ~MEDFileMeshes() { } void checkConsistencyLight() const; - void loadFromFile(const std::string& fileName); + void loadFromFile(med_idt fid); MEDFileMeshes(); - MEDFileMeshes(const std::string& fileName); + MEDFileMeshes(med_idt fid); private: std::vector< MCAuto > _meshes; };