]> SALOME platform Git repositories - modules/visu.git/blob - src/CONVERTOR/VISU_Convertor_impl.hxx
Salome HOME
[Bug PAL7853] PAL-MESH-004 regress: Problem with presentation groups of Nodes in...
[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 #include <vtkSystemIncludes.h>
15
16 #include <vtkPoints.h>
17 #include <vtkUnstructuredGrid.h>
18 #include <vtkMergeDataObjectFilter.h>
19 #include <vtkFieldDataToAttributeDataFilter.h>
20 #include "VISU_ExtractUnstructuredGrid.hxx"
21
22 #include <qstring.h>
23 #include <qfileinfo.h>
24
25 #include <vtkSmartPointer.h>
26
27 #include <boost/tuple/tuple.hpp>
28
29 namespace VISU{
30
31   typedef vtkSmartPointer<vtkPoints> TVTKPoints;
32   typedef vtkSmartPointer<vtkUnstructuredGrid> TVTKSource;
33   typedef vtkSmartPointer<vtkMergeDataObjectFilter> TVTKMergetFilter;
34   typedef vtkSmartPointer<VISU_ExtractUnstructuredGrid> TVTKExtractFilter;
35   typedef vtkSmartPointer<vtkFieldDataToAttributeDataFilter> TVTKAttribyteFilter;
36
37   typedef float TCoord;
38
39   struct TMeshImpl: TMesh{
40     TVTKPoints myPoints;
41
42     typedef std::vector<TCoord> TPointsCoord;
43     TPointsCoord myPointsCoord;
44
45     typedef std::vector<std::string> TPointsDim;
46     TPointsDim myPointsDim;
47   };
48   typedef shared_ptr<TMeshImpl> PMeshImpl;
49
50   struct TMeshOnEntityImpl: TMeshOnEntity{
51     TVTKSource myStorage;
52     typedef std::vector<vtkIdType> TConnect;
53     typedef std::vector<TConnect> TConnForCellType;
54     typedef std::map<vtkIdType,TConnForCellType> TCellsConn;
55     TCellsConn myCellsConn;
56   };
57   typedef shared_ptr<TMeshOnEntityImpl> PMeshOnEntityImpl;
58
59   struct TFamilyImpl: TFamily{
60     TVTKSource myStorage;
61
62     typedef std::set<vtkIdType> TSubMeshOnCellType;
63     typedef std::map<vtkIdType,TSubMeshOnCellType> TSubMesh;
64     TSubMesh mySubMesh;
65   };
66   typedef shared_ptr<TFamilyImpl> PFamilyImpl;
67
68   struct TGroupImpl: TGroup{
69     TVTKSource myStorage;
70   };
71   typedef shared_ptr<TGroupImpl> PGroupImpl;
72
73   struct TFieldImpl: TField{
74     TVTKExtractFilter myExtractFilter;
75     ~TFieldImpl()
76     { 
77       if(myExtractFilter.GetPointer())
78         myExtractFilter->UnRegisterAllOutputs();
79     }
80   };
81   typedef shared_ptr<TFieldImpl> PFieldImpl;
82
83   struct TValForTimeImpl: TValForTime{
84     TVTKAttribyteFilter myAttribyteFilter;
85     TVTKMergetFilter myMergeFilter;
86     TVTKSource myStorage;
87
88     typedef std::vector<float> TValForCellsWithType;
89     typedef std::map<vtkIdType,TValForCellsWithType> TValForCells;
90     TValForCells myValForCells;
91
92     ~TValForTimeImpl()
93     { 
94       if(myMergeFilter.GetPointer())
95         myMergeFilter->UnRegisterAllOutputs();
96       if(myAttribyteFilter.GetPointer())
97         myAttribyteFilter->UnRegisterAllOutputs();
98     }
99   };
100   typedef shared_ptr<TValForTimeImpl> PValForTimeImpl;
101
102 }
103
104 class VISU_Convertor_impl: public VISU_Convertor{
105 public:
106   virtual float GetSize() ;
107
108   virtual 
109   float 
110   GetMeshOnEntitySize(const std::string& theMeshName, 
111                       const VISU::TEntity& theEntity,
112                       const std::string& theFamilyName = "");
113
114   virtual 
115   float 
116   GetMeshOnGroupSize(const std::string& theMeshName, 
117                      const std::string& theGroupName);
118
119   virtual 
120   float 
121   GetTimeStampSize(const std::string& theMeshName, 
122                    const VISU::TEntity& theEntity,
123                    const std::string& theFieldName,
124                    int theStampsNum);
125
126   virtual 
127   float 
128   GetFieldOnMeshSize(const std::string& theMeshName, 
129                      const VISU::TEntity& theEntity,
130                      const std::string& theFieldName);
131
132   virtual 
133   const VISU::PField 
134   GetField(const std::string& theMeshName, 
135            VISU::TEntity theEntity, 
136            const std::string& theFieldName);
137
138   virtual 
139   const VISU::PValForTime 
140   GetTimeStamp(const std::string& theMeshName, 
141                const VISU::TEntity& theEntity,
142                const std::string& theFieldName,
143                int theStampsNum);
144
145 public:
146   VISU_Convertor_impl();
147
148   virtual ~VISU_Convertor_impl();
149
150   virtual VISU_Convertor* Build()  { return this;};
151
152   virtual 
153   TOutput* 
154   GetMeshOnEntity(const std::string& theMeshName, 
155                   const VISU::TEntity& theEntity,
156                   const std::string& theFamilyName = "");
157
158   virtual 
159   TOutput* 
160   GetMeshOnGroup(const std::string& theMeshName, 
161                  const std::string& theGroupName);
162   
163   virtual
164   TOutput* 
165   GetTimeStampOnMesh(const std::string& theMeshName, 
166                      const VISU::TEntity& theEntity,
167                      const std::string& theFieldName,
168                      int theStampsNum);
169
170 protected:
171   VISU::PMeshImpl 
172   FindMesh(const std::string& theMeshName);
173
174   typedef boost::tuple<VISU::PMeshImpl,VISU::PMeshOnEntityImpl,VISU::PFamilyImpl> TFindMeshOnEntity;
175   TFindMeshOnEntity
176   FindMeshOnEntity(const std::string& theMeshName,
177                    const VISU::TEntity& theEntity,
178                    const std::string& theFamilyName);
179
180   typedef boost::tuple<VISU::PMeshImpl,VISU::PGroupImpl> TFindMeshOnGroup;
181   TFindMeshOnGroup
182   FindMeshOnGroup(const std::string& theMeshName, 
183                   const std::string& theGroupName);
184
185   typedef boost::tuple<VISU::PMeshImpl,
186                        VISU::PMeshOnEntityImpl,
187                        VISU::PMeshOnEntityImpl,
188                        VISU::PFieldImpl> TFindField;
189   TFindField
190   FindField(const std::string& theMeshName, 
191             const VISU::TEntity& theEntity, 
192             const std::string& theFieldName);
193
194   typedef boost::tuple<VISU::PMeshImpl,
195                        VISU::PMeshOnEntityImpl,
196                        VISU::PMeshOnEntityImpl,
197                        VISU::PFieldImpl,
198                        VISU::PValForTimeImpl> TFindTimeStamp;
199   TFindTimeStamp
200   FindTimeStamp(const std::string& theMeshName, 
201                 const VISU::TEntity& theEntity, 
202                 const std::string& theFieldName, 
203                 int theStampsNum);
204   
205 protected:
206   virtual int LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, 
207                                const std::string& theFamilyName = "") = 0;
208
209   virtual int LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
210                               const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) = 0;
211
212   virtual int LoadFieldOnMesh(VISU::PMeshImpl theMesh, 
213                               VISU::PMeshOnEntityImpl theMeshOnEntity, 
214                               VISU::PFieldImpl theField, 
215                               VISU::PValForTimeImpl theValForTime) = 0;
216 };
217
218 #endif