Salome HOME
86c950a6b3273c874a7b7b7dceffbde2d19ad837
[modules/visu.git] / src / CONVERTOR / VISU_Convertor_impl.hxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SALOME VTKViewer : build VTK viewer into Salome desktop
23 //  File   : 
24 //  Author : 
25 //  Module : SALOME
26 //  $Header$
27 //
28 #ifndef VISU_Convertor_impl_HeaderFile
29 #define VISU_Convertor_impl_HeaderFile
30
31 #include "VISU_Convertor.hxx"
32 #include "VISU_ConvertorDef_impl.hxx"
33
34 #include <boost/tuple/tuple.hpp>
35
36
37 //---------------------------------------------------------------
38 //! This class perfroms mapping of intermediate data strucutres into corresponding VTK representation
39 /*!
40   It implements VISU_Convertor public interface and declare new pure virtual functions
41   to fill its intermediate data structure from a MED source
42 */
43 class VISU_CONVERTOR_EXPORT VISU_Convertor_impl: public VISU_Convertor
44 {
45 public:
46   VISU_Convertor_impl();
47
48   virtual
49   ~VISU_Convertor_impl();
50
51   //! Just to define default behaviour
52   virtual
53   VISU_Convertor* 
54   Build();
55
56   //! Just to define default behaviour
57   virtual
58   VISU_Convertor* 
59   BuildEntities();
60
61   //! Just to define default behaviour
62   virtual
63   VISU_Convertor* 
64   BuildFields();
65
66   //! Just to define default behaviour
67   virtual
68   VISU_Convertor* 
69   BuildMinMax();
70
71   //! Just to define default behaviour
72   virtual
73   VISU_Convertor* 
74   BuildGroups();
75
76   //! Implemention of the VISU_Convertor::GetSize
77   virtual 
78   size_t
79   GetSize();
80
81   //! Implemention of the VISU_Convertor::GetMeshOnEntity
82   virtual 
83   VISU::PNamedIDMapper 
84   GetMeshOnEntity(const std::string& theMeshName, 
85                   const VISU::TEntity& theEntity);
86
87   //! Implemention of the VISU_Convertor::GetMeshOnEntitySize
88   virtual 
89   size_t 
90   GetMeshOnEntitySize(const std::string& theMeshName, 
91                        const VISU::TEntity& theEntity);
92
93   //! Implemention of the VISU_Convertor::GetFamilyOnEntity
94   virtual 
95   VISU::PUnstructuredGridIDMapper 
96   GetFamilyOnEntity(const std::string& theMeshName, 
97                     const VISU::TEntity& theEntity,
98                     const std::string& theFamilyName);
99
100   //! Implemention of the VISU_Convertor::GetFamilyOnEntitySize
101   virtual 
102   size_t 
103   GetFamilyOnEntitySize(const std::string& theMeshName, 
104                         const VISU::TEntity& theEntity,
105                         const std::string& theFamilyName);
106
107   //! Implemention of the VISU_Convertor::GetMeshOnGroup
108   virtual 
109   VISU::PUnstructuredGridIDMapper 
110   GetMeshOnGroup(const std::string& theMeshName, 
111                  const std::string& theGroupName);
112   
113   //! Implemention of the VISU_Convertor::GetMeshOnGroupSize
114   virtual 
115   size_t 
116   GetMeshOnGroupSize(const std::string& theMeshName, 
117                      const std::string& theGroupName);
118
119   //! Implemention of the VISU_Convertor::GetTimeStampOnMesh
120   virtual
121   VISU::PUnstructuredGridIDMapper 
122   GetTimeStampOnMesh( const std::string& theMeshName, 
123                       const VISU::TEntity& theEntity,
124                       const std::string& theFieldName,
125                       int theTimeStampNumber );
126
127   //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on mesh
128   virtual 
129   size_t
130   GetTimeStampOnMeshSize(const std::string& theMeshName, 
131                          const VISU::TEntity& theEntity,
132                          const std::string& theFieldName,
133                          int theTimeStampNumber,
134                          bool& theIsEstimated);
135     
136   //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on Gauss Points
137   virtual 
138   size_t
139   GetTimeStampOnGaussPtsSize(const std::string& theMeshName, 
140                              const VISU::TEntity& theEntity,
141                              const std::string& theFieldName,
142                              int theTimeStampNumber,
143                              bool& theIsEstimated);
144
145   //! Implemention of the VISU_Convertor::GetTimeStampOnGaussPts
146   virtual
147   VISU::PGaussPtsIDMapper 
148   GetTimeStampOnGaussPts(const std::string& theMeshName, 
149                          const VISU::TEntity& theEntity,
150                          const std::string& theFieldName,
151                          int theTimeStampNumber);
152   
153   //! Implemention of the VISU_Convertor::GetFieldOnMeshSize
154   virtual 
155   size_t 
156   GetFieldOnMeshSize(const std::string& theMeshName, 
157                      const VISU::TEntity& theEntity,
158                      const std::string& theFieldName);
159
160   //! Implemention of the VISU_Convertor::GetField
161   virtual 
162   const VISU::PField 
163   GetField(const std::string& theMeshName, 
164            VISU::TEntity theEntity, 
165            const std::string& theFieldName);
166
167   //! Implemention of the VISU_Convertor::GetTimeStamp
168   virtual 
169   const VISU::PValForTime 
170   GetTimeStamp(const std::string& theMeshName, 
171                const VISU::TEntity& theEntity,
172                const std::string& theFieldName,
173                int theStampsNum);
174
175 protected:
176   //! An utility method to find TMesh by its name
177   VISU::PMeshImpl 
178   FindMesh(const std::string& theMeshName);
179
180   //! An utility method to find TMeshOnEntity by name of its parent mesh and entity
181   typedef boost::tuple<VISU::PMeshImpl,
182                        VISU::PMeshOnEntityImpl> TFindMeshOnEntity;
183   TFindMeshOnEntity
184   FindMeshOnEntity(const std::string& theMeshName,
185                    const VISU::TEntity& theEntity);
186
187   //! An utility method to find TFamily by name of its parent mesh, corresponding entity and its name
188   typedef boost::tuple<VISU::PMeshImpl,
189                        VISU::PMeshOnEntityImpl,VISU::PFamilyImpl> TFindFamilyOnEntity;
190   TFindFamilyOnEntity
191   FindFamilyOnEntity(const std::string& theMeshName,
192                     const VISU::TEntity& theEntity,
193                     const std::string& theFamilyName);
194
195   //! An utility method to find Group by name of its parent mesh and its name
196   typedef boost::tuple<VISU::PMeshImpl,
197                        VISU::PGroupImpl> TFindMeshOnGroup;
198   TFindMeshOnGroup
199   FindMeshOnGroup(const std::string& theMeshName, 
200                   const std::string& theGroupName);
201
202   //! An utility method to find TField by name of its parent mesh, corresponding entity and its name
203   typedef boost::tuple<VISU::PMeshImpl,
204                        VISU::PMeshOnEntityImpl,
205                        VISU::PMeshOnEntityImpl,
206                        VISU::PFieldImpl> TFindField;
207   TFindField
208   FindField( const std::string& theMeshName, 
209              const VISU::TEntity& theEntity, 
210              const std::string& theFieldName );
211
212   //! An utility method to find TTimeStamp by name of its parent mesh, corresponding entity, field name and its number
213   typedef boost::tuple<VISU::PMeshImpl,
214                        VISU::PMeshOnEntityImpl,
215                        VISU::PMeshOnEntityImpl,
216                        VISU::PFieldImpl,
217                        VISU::PValForTimeImpl> TFindTimeStamp;
218   TFindTimeStamp
219   FindTimeStamp(const std::string& theMeshName, 
220                 const VISU::TEntity& theEntity, 
221                 const std::string& theFieldName, 
222                 int theStampsNum);
223
224   vtkUnstructuredGrid*
225   GetTimeStampOnProfile( const VISU::PMeshImpl& theMesh,
226                          const VISU::PMeshOnEntityImpl& theMeshOnEntity,
227                          const VISU::PFieldImpl& theField,
228                          const VISU::PValForTimeImpl& theValForTime,
229                          const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter,
230                          const VISU::PProfileImpl& theProfile,
231                          const VISU::TEntity& theEntity );
232
233 protected:
234   //! Implemention of the VISU_Convertor::GetTimeStampSize
235   virtual 
236   size_t 
237   GetTimeStampSize(const std::string& theMeshName, 
238                    const VISU::TEntity& theEntity,
239                    const std::string& theFieldName,
240                    int theStampsNum);
241
242   //! To fill intermeiate representation of TMeshOnEntity from a MED source
243   virtual
244   int
245   LoadMeshOnEntity(VISU::PMeshImpl theMesh,
246                    VISU::PMeshOnEntityImpl theMeshOnEntity) = 0;
247
248   //! To fill intermeiate representation of TFamily from a MED source
249   virtual
250   int
251   LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
252                      VISU::PMeshOnEntityImpl theMeshOnEntity, 
253                      VISU::PFamilyImpl theFamily) = 0;
254
255   //! To fill intermeiate representation of TGroup from a MED source
256   virtual 
257   int
258   LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
259                   const VISU::TFamilySet& theFamilySet) = 0;
260
261   //! To fill intermeiate representation of TValForTime for ordinary mesh from a MED source
262   virtual 
263   int
264   LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, 
265                        VISU::PMeshOnEntityImpl theMeshOnEntity, 
266                        VISU::PFieldImpl theField, 
267                        VISU::PValForTimeImpl theValForTime) = 0;
268
269   //! To fill intermeiate representation of TValForTime for mesh on Gauss Points from a MED source
270   virtual 
271   int
272   LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh, 
273                            VISU::PMeshOnEntityImpl theMeshOnEntity, 
274                            VISU::PFieldImpl theField, 
275                            VISU::PValForTimeImpl theValForTime) = 0;
276 };
277
278 #endif