Salome HOME
sources v1.2c
[modules/visu.git] / src / CONVERTOR / VISU_Convertor_impl.hxx
1 //  Copyright (C) 2003  CEA/DEN, EDF R&D
2 //
3 //
4 //
5 //  File   : VISU_Convertor_impl.hxx
6 //  Author : Alexey PETROV
7 //  Module : VISU
8
9 #ifndef VISU_Convertor_impl_HeaderFile
10 #define VISU_Convertor_impl_HeaderFile
11
12 #include "VISU_Convertor.hxx"
13
14 extern "C"{
15 #include <med.h>
16 }  
17
18 #include <qstring.h>
19 #include <qfileinfo.h>
20
21 class VISU_Convertor_impl: public VISU_Convertor{
22 private:
23   void GetPoints(VISU::TVTKSource& theStorage, 
24                  const VISU::TMesh& theMesh) 
25     const throw (std::runtime_error&);
26   void GetCellsOnEntity(VISU::TVTKSource& theStorage,
27                         const VISU::TMeshOnEntity& theMeshOnEntity, 
28                         const std::string& theFamilyName) 
29     const throw (std::runtime_error&);
30   void GetCellsOnGroup(VISU::TVTKSource& theStorage,
31                        const VISU::TMesh& theMesh,
32                        const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) 
33     const throw (std::runtime_error&);
34   void GetField(VISU::TVTKSource& theStorage,
35                 const VISU::TMesh& theMesh,
36                 const VISU::TMeshOnEntity& theMeshOnEntity, 
37                 const VISU::TField& theField, 
38                 const VISU::TField::TValForTime& theValForTime) 
39     const throw (std::runtime_error&);
40
41
42 protected:
43   void FindMesh(const std::string& theMeshName, VISU::TMesh*& theMesh)
44     throw(std::runtime_error&);
45   void FindMeshOnEntity(const std::string& theMeshName, VISU::TMesh*& theMesh,
46                         const VISU::TEntity& theEntity, VISU::TMeshOnEntity*& theMeshOnEntity,
47                         const std::string& theFamilyName, VISU::TFamily*& theFamily)
48     throw (std::runtime_error&);
49
50   void FindMeshOnGroup(const std::string& theMeshName, VISU::TMesh*& theMesh,
51                        const std::string& theGroupName, VISU::TGroup*& theGroup)
52     throw (std::runtime_error&);
53
54   void FindField(const std::string& theMeshName, VISU::TMesh*& theMesh,
55                  const VISU::TEntity& theEntity, 
56                  VISU::TMeshOnEntity*& theMeshOnEntity,
57                  VISU::TMeshOnEntity*& theVTKMeshOnEntity,
58                  const std::string& theFieldName, VISU::TField*& theField)
59     throw (std::runtime_error&);
60   void FindTimeStamp(const std::string& theMeshName, VISU::TMesh*& theMesh,
61                      const VISU::TEntity& theEntity, 
62                      VISU::TMeshOnEntity*& theMeshOnEntity,
63                      VISU::TMeshOnEntity*& theVTKMeshOnEntity,
64                      const std::string& theFieldName, VISU::TField*& theField,
65                      int theStampsNum, VISU::TField::TValForTime*& theValForTime)
66     throw (std::runtime_error&);
67
68
69 public:
70   virtual vtkIdType GetMeshOnEntitySize(const std::string& theMeshName, 
71                                         const VISU::TEntity& theEntity,
72                                         const std::string& theFamilyName = "")
73     throw (std::runtime_error&);
74   virtual vtkIdType GetMeshOnGroupSize(const std::string& theMeshName, 
75                                        const std::string& theGroupName)
76     throw(std::runtime_error&);
77   virtual vtkIdType GetTimeStampSize(const std::string& theMeshName, 
78                                      const VISU::TEntity& theEntity,
79                                      const std::string& theFieldName,
80                                      int theStampsNum)
81     throw(std::runtime_error&);
82   virtual vtkIdType GetFieldOnMeshSize(const std::string& theMeshName, 
83                                        const VISU::TEntity& theEntity,
84                                        const std::string& theFieldName)
85     throw(std::runtime_error&);
86   virtual const VISU::TField& GetField(const std::string& theMeshName, 
87                                        VISU::TEntity theEntity, 
88                                        const std::string& theFieldName)
89     throw(std::runtime_error&);
90   virtual const VISU::TField::TValForTime& GetTimeStamp(const std::string& theMeshName, 
91                                                         const VISU::TEntity& theEntity,
92                                                         const std::string& theFieldName,
93                                                         int theStampsNum)
94     throw(std::runtime_error&);
95
96 public:
97   VISU_Convertor_impl();
98   virtual ~VISU_Convertor_impl();
99   virtual VISU_Convertor* Build() throw (std::runtime_error&) { return this;};
100   virtual TOutput* GetMeshOnEntity(const std::string& theMeshName, 
101                                    const VISU::TEntity& theEntity,
102                                    const std::string& theFamilyName = "")
103     throw(std::runtime_error&);
104   virtual TOutput* GetMeshOnGroup(const std::string& theMeshName, 
105                                   const std::string& theGroupName)
106     throw(std::runtime_error&);
107   virtual TOutput* GetTimeStampOnMesh(const std::string& theMeshName, 
108                                       const VISU::TEntity& theEntity,
109                                       const std::string& theFieldName,
110                                       int theStampsNum)
111     throw(std::runtime_error&);
112
113  protected:
114   virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, 
115                                const std::string& theFamilyName = "")
116     throw (std::runtime_error&) = 0;
117   virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, 
118                               const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
119     throw (std::runtime_error&) = 0;
120   virtual int LoadFieldOnMesh(VISU::TMesh& theMesh, 
121                               VISU::TMeshOnEntity& theMeshOnEntity, 
122                               VISU::TField& theField, 
123                               VISU::TField::TValForTime& theValForTime)
124     throw (std::runtime_error&) = 0;
125 };
126
127 template<class T> std::string dtos(const std::string& fmt, T val){
128   static QString aString;
129   aString.sprintf(fmt.c_str(),val);
130   return aString.latin1();
131 }
132
133 extern "C"{
134   int getNbMedConnect(int theMedType, int theMedEntity, int theMeshDim);
135   int getNbMedNodes(int theMedType);
136   int med2vtkCellType(int theMedType);
137   int vtk2medCellType(int theVtkType);
138   int getIdMedType(int medType);
139 }
140
141 struct Med2vtk {
142   med_geometrie_element medType;
143   const char *medName;
144   int medNbNodes;
145   int vtkType;
146   const char *vtkName;
147   int vtkNbNodes;
148 };
149 extern Med2vtk med2vtk[MED_NBR_GEOMETRIE_MAILLE];
150 #endif