Salome HOME
Porting to ParaView 5.8
[modules/paravis.git] / src / Plugins / MEDWriter / plugin / MEDWriterIO / VTKToMEDMem.h
1 // Copyright (C) 2017-2019  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 "MEDFileData.hxx"
32 #include "MEDFileField.hxx"
33 #include "MEDFileMesh.hxx"
34 #include "MEDLoaderTraits.hxx"
35
36 #include <exception>
37 #include <string>
38
39 ///////////////////
40
41 class vtkDataSet;
42
43 class VTK_EXPORT MZCException : public std::exception
44 {
45 public:
46   MZCException(const std::string& s):_reason(s) { }
47   virtual const char *what() const throw() { return _reason.c_str(); }
48   virtual ~MZCException() throw() { }
49 private:
50   std::string _reason;
51 };
52
53 namespace VTKToMEDMem
54 {
55   class VTK_EXPORT Grp
56   {
57   public:
58     Grp(const std::string& name):_name(name) { }
59     void setFamilies(const std::vector<std::string>& fams) { _fams=fams; }
60     std::string getName() const { return _name; }
61     std::vector<std::string> getFamilies() const { return _fams; }
62   private:
63     std::string _name;
64     std::vector<std::string> _fams;
65   };
66
67   class VTK_EXPORT Fam
68   {
69   public:
70     Fam(const std::string& name);
71     std::string getName() const { return _name; }
72     int getID() const { return _id; }
73   private:
74     std::string _name;
75     int _id;
76   };
77 }
78
79 class vtkDataObject;
80
81 void VTK_EXPORT WriteMEDFileFromVTKDataSet(MEDCoupling::MEDFileData *mfd, vtkDataSet *ds, const std::vector<int>& context, double timeStep, int tsId);
82
83 void VTK_EXPORT WriteMEDFileFromVTKGDS(MEDCoupling::MEDFileData *mfd, vtkDataObject *input, double timeStep, int tsId);
84   
85 void VTK_EXPORT PutFamGrpInfoIfAny(MEDCoupling::MEDFileData *mfd, const std::string& meshName, const std::vector<VTKToMEDMem::Grp>& groups, const std::vector<VTKToMEDMem::Fam>& fams);
86
87 #endif
88