Back to index

salome-med  6.5.0
SauvWriter.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 // File      : SauvWriter.hxx
00020 // Created   : Wed Aug 24 11:18:49 2011
00021 // Author    : Edward AGAPOV (eap)
00022 
00023 #ifndef __SAUVWRITER_HXX__
00024 #define __SAUVWRITER_HXX__
00025 
00026 #include "MEDLoaderDefines.hxx"
00027 #include "MEDCouplingRefCountObject.hxx"
00028 #include "NormalizedUnstructuredMesh.hxx"
00029 #include "SauvUtilities.hxx"
00030 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
00031 
00032 #include <vector>
00033 #include <string>
00034 #include <map>
00035 
00036 namespace ParaMEDMEM
00037 {
00038   class MEDFileData;
00039   class MEDFileMesh;
00040   class MEDFileFieldMultiTS;
00041   class DataArrayInt;
00042 
00046   class MEDLOADER_EXPORT SauvWriter : public ParaMEDMEM::RefCountObject
00047   {
00048   public:
00049     static SauvWriter * New();
00050     void setMEDFileDS(const MEDFileData* medData, unsigned meshIndex = 0);
00051     void write(const char* fileName);
00052 
00053   private:
00054 
00059     struct SubMesh
00060     {
00061       std::vector<int>      _cellIDsByType[ INTERP_KERNEL::NORM_MAXTYPE+1 ];
00062       std::vector<SubMesh*> _subs;
00063       std::string           _name;
00064       int                   _id;
00065       int                   _nbSauvObjects;
00066       int                   _dimRelExt;
00067       int nbTypes() const;
00068       static int cellIDsByTypeSize() { return INTERP_KERNEL::NORM_MAXTYPE+1; }
00069     };
00070     SubMesh* addSubMesh(const std::string& name, int dimRelExt);
00071 
00072     void fillSubMeshes(int& nbSauvObjects, std::map<std::string,int>& nameNbMap);
00073     void fillFamilySubMeshes();
00074     void fillGroupSubMeshes();
00075     void fillProfileSubMeshes();
00076     int evaluateNbProfileSubMeshes() const;
00077     void makeCompNames(const std::string&                  fieldName,
00078                        const std::vector<std::string>&     compInfo,
00079                        std::map<std::string, std::string>& compMedToGibi );
00080     void makeProfileIDs( SubMesh*                          sm,
00081                          INTERP_KERNEL::NormalizedCellType type,
00082                          const DataArrayInt*               profile );
00083     void writeFileHead();
00084     void writeSubMeshes();
00085     void writeCompoundSubMesh(int iSub);
00086     void writeNodes();
00087     void writeLongNames();
00088     void writeNodalFields(std::map<std::string,int>& fldNamePrefixMap);
00089     void writeElemFields(std::map<std::string,int>& fldNamePrefixMap);
00090     void writeFieldNames(const bool isNodal, std::map<std::string,int>& fldNamePrefixMap);
00091     void writeElemTimeStamp(int iF, int iter, int order);
00092     void writeLastRecord();
00093     void writeNames( const std::map<std::string,int>& nameNbMap );
00094 
00095   private:
00096 
00097     MEDCouplingAutoRefCountObjectPtr< MEDFileMesh >                        _fileMesh;
00098     std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTS > > _nodeFields;
00099     std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldMultiTS > > _cellFields;
00100 
00101     std::vector<SubMesh>                      _subs;
00102     std::map< int, SubMesh* >                 _famIDs2Sub;
00103     std::map< std::string, SubMesh* >         _profile2Sub;
00104     enum
00105       {
00106         LN_MAIL=0, LN_CHAM, LN_COMP, LN_NB
00107       };
00108     std::vector<SauvUtilities::nameGIBItoMED> _longNames[ LN_NB ];
00109 
00110     std::fstream*                             _sauvFile;
00111   };
00112 }
00113 
00114 #endif