Salome HOME
Copyright update 2022
[modules/paravis.git] / src / Plugins / MEDWriter / plugin / MEDWriterIO / VTKToMEDMem.h
1 // Copyright (C) 2017-2022  CEA/DEN, EDF R&D
2 //
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, or (at your option) any later version.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (EDF R&D)
20
21 #ifndef __VTKTOMEDMEM_HXX__
22 #define __VTKTOMEDMEM_HXX__
23
24 #include "vtkSystemIncludes.h" //needed for exports
25
26 #include "MEDCouplingRefCountObject.hxx"
27 #include "MEDCouplingMemArray.hxx"
28 #include "MEDCouplingFieldDouble.hxx"
29 #include "MEDCouplingFieldFloat.hxx"
30 #include "MEDCouplingFieldInt.hxx"
31 #include "MEDCouplingFieldInt64.hxx"
32 #include "MEDFileData.hxx"
33 #include "MEDFileField.hxx"
34 #include "MEDFileMesh.hxx"
35 #include "MEDLoaderTraits.hxx"
36
37 #include <exception>
38 #include <string>
39
40 ///////////////////
41
42 class vtkDataSet;
43
44 class VTK_EXPORT MZCException : public std::exception
45 {
46 public:
47   MZCException(const std::string& s):_reason(s) { }
48   virtual const char *what() const noexcept { return _reason.c_str(); }
49   virtual ~MZCException() noexcept { }
50 private:
51   std::string _reason;
52 };
53
54 namespace VTKToMEDMem
55 {
56   class VTK_EXPORT Grp
57   {
58   public:
59     Grp(const std::string& name):_name(name) { }
60     void setFamilies(const std::vector<std::string>& fams) { _fams=fams; }
61     std::string getName() const { return _name; }
62     std::vector<std::string> getFamilies() const { return _fams; }
63   private:
64     std::string _name;
65     std::vector<std::string> _fams;
66   };
67
68   class VTK_EXPORT Fam
69   {
70   public:
71     Fam(const std::string& name);
72     std::string getName() const { return _name; }
73     int getID() const { return _id; }
74   private:
75     std::string _name;
76     int _id;
77   };
78 }
79
80 class vtkDataObject;
81
82 void VTK_EXPORT WriteMEDFileFromVTKDataSet(MEDCoupling::MEDFileData *mfd, vtkDataSet *ds, const std::vector<int>& context, double timeStep, int tsId);
83
84 void VTK_EXPORT WriteMEDFileFromVTKGDS(MEDCoupling::MEDFileData *mfd, vtkDataObject *input, double timeStep, int tsId);
85   
86 void VTK_EXPORT PutFamGrpInfoIfAny(MEDCoupling::MEDFileData *mfd, const std::string& meshName, const std::vector<VTKToMEDMem::Grp>& groups, const std::vector<VTKToMEDMem::Fam>& fams);
87
88 #endif
89