1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // File : SauvWriter.hxx
20 // Created : Wed Aug 24 11:18:49 2011
21 // Author : Edward AGAPOV (eap)
23 #ifndef __SAUVWRITER_HXX__
24 #define __SAUVWRITER_HXX__
26 #include "MEDLoaderDefines.hxx"
27 #include "MEDCouplingRefCountObject.hxx"
28 #include "NormalizedUnstructuredMesh.hxx"
29 #include "SauvUtilities.hxx"
30 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
40 class MEDFileFieldMultiTS;
44 * \brief Class to write a MEDFileData into a SAUVE format file
46 class MEDLOADER_EXPORT SauvWriter : public ParaMEDMEM::RefCountObject
49 static SauvWriter * New();
50 void setMEDFileDS(const MEDFileData* medData, unsigned meshIndex = 0);
51 void write(const char* fileName);
54 std::size_t getHeapMemorySize() const { return 0; }
56 * \brief Class representing a GIBI sub-mesh (described in the pile 1 of the SAUVE file).
57 * It stands for a named med sub-mesh (family, etc) and contains either cell IDs or other sub-meshes.
61 std::vector<int> _cellIDsByType[ INTERP_KERNEL::NORM_MAXTYPE+1 ];
62 std::vector<SubMesh*> _subs;
68 static int cellIDsByTypeSize() { return INTERP_KERNEL::NORM_MAXTYPE+1; }
70 SubMesh* addSubMesh(const std::string& name, int dimRelExt);
72 void fillSubMeshes(int& nbSauvObjects, std::map<std::string,int>& nameNbMap);
73 void fillFamilySubMeshes();
74 void fillGroupSubMeshes();
75 void fillProfileSubMeshes();
76 int evaluateNbProfileSubMeshes() const;
77 void makeCompNames(const std::string& fieldName,
78 const std::vector<std::string>& compInfo,
79 std::map<std::string, std::string>& compMedToGibi );
80 void makeProfileIDs( SubMesh* sm,
81 INTERP_KERNEL::NormalizedCellType type,
82 const DataArrayInt* profile );
84 void writeSubMeshes();
85 void writeCompoundSubMesh(int iSub);
87 void writeLongNames();
88 void writeNodalFields(std::map<std::string,int>& fldNamePrefixMap);
89 void writeElemFields(std::map<std::string,int>& fldNamePrefixMap);
90 void writeFieldNames(const bool isNodal, std::map<std::string,int>& fldNamePrefixMap);
91 void writeElemTimeStamp(int iF, int iter, int order);
92 void writeLastRecord();
93 void writeNames( const std::map<std::string,int>& nameNbMap );
97 MEDCouplingAutoRefCountObjectPtr< MEDFileMesh > _fileMesh;
98 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTS > > _nodeFields;
99 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTS > > _cellFields;
101 std::vector<SubMesh> _subs;
102 std::map< int, SubMesh* > _famIDs2Sub;
103 std::map< std::string, SubMesh* > _profile2Sub;
106 LN_MAIL=0, LN_CHAM, LN_COMP, LN_NB
108 std::vector<SauvUtilities::nameGIBItoMED> _longNames[ LN_NB ];
110 std::fstream* _sauvFile;