Salome HOME
Update copyright information
[modules/visu.git] / src / CONVERTOR / VISU_Convertor_impl.hxx
1 // Copyright (C) 2007-2012  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
23 //  SALOME VTKViewer : build VTK viewer into Salome desktop
24 //  File   : 
25 //  Author : 
26 //  Module : SALOME
27 //  $Header$
28 //
29 #ifndef VISU_Convertor_impl_HeaderFile
30 #define VISU_Convertor_impl_HeaderFile
31
32 #include "VISU_Convertor.hxx"
33 #include "VISU_ConvertorDef_impl.hxx"
34
35 #include <boost/tuple/tuple.hpp>
36
37
38 //---------------------------------------------------------------
39 //! This class perfroms mapping of intermediate data strucutres into corresponding VTK representation
40 /*!
41   It implements VISU_Convertor public interface and declare new pure virtual functions
42   to fill its intermediate data structure from a MED source
43 */
44 class VISU_CONVERTOR_EXPORT VISU_Convertor_impl: public VISU_Convertor
45 {
46 public:
47   VISU_Convertor_impl();
48
49   virtual
50   ~VISU_Convertor_impl();
51
52   //! Just to define default behaviour
53   virtual
54   VISU_Convertor* 
55   Build();
56
57   //! Just to define default behaviour
58   virtual
59   VISU_Convertor* 
60   BuildEntities();
61
62   //! Just to define default behaviour
63   virtual
64   VISU_Convertor* 
65   BuildFields();
66
67   //! Just to define default behaviour
68   virtual
69   VISU_Convertor* 
70   BuildMinMax();
71
72   //! Just to define default behaviour
73   virtual
74   VISU_Convertor* 
75   BuildGroups();
76
77   //! Implemention of the VISU_Convertor::GetSize
78   virtual 
79   size_t
80   GetSize();
81
82   //! Implemention of the VISU_Convertor::GetMeshOnEntity
83   virtual 
84   VISU::PNamedIDMapper 
85   GetMeshOnEntity(const std::string& theMeshName, 
86                   const VISU::TEntity& theEntity);
87
88   //! Implemention of the VISU_Convertor::GetMeshOnEntitySize
89   virtual 
90   size_t 
91   GetMeshOnEntitySize(const std::string& theMeshName, 
92                        const VISU::TEntity& theEntity);
93
94   //! Implemention of the VISU_Convertor::GetFamilyOnEntity
95   virtual 
96   VISU::PUnstructuredGridIDMapper 
97   GetFamilyOnEntity(const std::string& theMeshName, 
98                     const VISU::TEntity& theEntity,
99                     const std::string& theFamilyName);
100
101   //! Implemention of the VISU_Convertor::GetFamilyOnEntitySize
102   virtual 
103   size_t 
104   GetFamilyOnEntitySize(const std::string& theMeshName, 
105                         const VISU::TEntity& theEntity,
106                         const std::string& theFamilyName);
107
108   //! Implemention of the VISU_Convertor::GetMeshOnGroup
109   virtual 
110   VISU::PUnstructuredGridIDMapper 
111   GetMeshOnGroup(const std::string& theMeshName, 
112                  const std::string& theGroupName);
113   
114   //! Implemention of the VISU_Convertor::GetMeshOnGroupSize
115   virtual 
116   size_t 
117   GetMeshOnGroupSize(const std::string& theMeshName, 
118                      const std::string& theGroupName);
119
120   //! Implemention of the VISU_Convertor::GetTimeStampOnMesh
121   virtual
122   VISU::PUnstructuredGridIDMapper 
123   GetTimeStampOnMesh( const std::string& theMeshName, 
124                       const VISU::TEntity& theEntity,
125                       const std::string& theFieldName,
126                       int theTimeStampNumber );
127
128   //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on mesh
129   virtual 
130   size_t
131   GetTimeStampOnMeshSize(const std::string& theMeshName, 
132                          const VISU::TEntity& theEntity,
133                          const std::string& theFieldName,
134                          int theTimeStampNumber,
135                          bool& theIsEstimated);
136     
137   //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on Gauss Points
138   virtual 
139   size_t
140   GetTimeStampOnGaussPtsSize(const std::string& theMeshName, 
141                              const VISU::TEntity& theEntity,
142                              const std::string& theFieldName,
143                              int theTimeStampNumber,
144                              bool& theIsEstimated);
145
146   //! Implemention of the VISU_Convertor::GetTimeStampOnGaussPts
147   virtual
148   VISU::PGaussPtsIDMapper 
149   GetTimeStampOnGaussPts(const std::string& theMeshName, 
150                          const VISU::TEntity& theEntity,
151                          const std::string& theFieldName,
152                          int theTimeStampNumber);
153   
154   //! Implemention of the VISU_Convertor::GetFieldOnMeshSize
155   virtual 
156   size_t 
157   GetFieldOnMeshSize(const std::string& theMeshName, 
158                      const VISU::TEntity& theEntity,
159                      const std::string& theFieldName);
160
161   //! Implemention of the VISU_Convertor::GetField
162   virtual 
163   const VISU::PField 
164   GetField(const std::string& theMeshName, 
165            VISU::TEntity theEntity, 
166            const std::string& theFieldName);
167
168   //! Implemention of the VISU_Convertor::GetTimeStamp
169   virtual 
170   const VISU::PValForTime 
171   GetTimeStamp(const std::string& theMeshName, 
172                const VISU::TEntity& theEntity,
173                const std::string& theFieldName,
174                int theStampsNum);
175
176 protected:
177   //! An utility method to find TMesh by its name
178   VISU::PMeshImpl 
179   FindMesh(const std::string& theMeshName);
180
181   //! An utility method to find TMeshOnEntity by name of its parent mesh and entity
182   typedef boost::tuple<VISU::PMeshImpl,
183                        VISU::PMeshOnEntityImpl> TFindMeshOnEntity;
184   TFindMeshOnEntity
185   FindMeshOnEntity(const std::string& theMeshName,
186                    const VISU::TEntity& theEntity);
187
188   //! An utility method to find TFamily by name of its parent mesh, corresponding entity and its name
189   typedef boost::tuple<VISU::PMeshImpl,
190                        VISU::PMeshOnEntityImpl,VISU::PFamilyImpl> TFindFamilyOnEntity;
191   TFindFamilyOnEntity
192   FindFamilyOnEntity(const std::string& theMeshName,
193                     const VISU::TEntity& theEntity,
194                     const std::string& theFamilyName);
195
196   //! An utility method to find Group by name of its parent mesh and its name
197   typedef boost::tuple<VISU::PMeshImpl,
198                        VISU::PGroupImpl> TFindMeshOnGroup;
199   TFindMeshOnGroup
200   FindMeshOnGroup(const std::string& theMeshName, 
201                   const std::string& theGroupName);
202
203   //! An utility method to find TField by name of its parent mesh, corresponding entity and its name
204   typedef boost::tuple<VISU::PMeshImpl,
205                        VISU::PMeshOnEntityImpl,
206                        VISU::PMeshOnEntityImpl,
207                        VISU::PFieldImpl> TFindField;
208   TFindField
209   FindField( const std::string& theMeshName, 
210              const VISU::TEntity& theEntity, 
211              const std::string& theFieldName );
212
213   //! An utility method to find TTimeStamp by name of its parent mesh, corresponding entity, field name and its number
214   typedef boost::tuple<VISU::PMeshImpl,
215                        VISU::PMeshOnEntityImpl,
216                        VISU::PMeshOnEntityImpl,
217                        VISU::PFieldImpl,
218                        VISU::PValForTimeImpl> TFindTimeStamp;
219   TFindTimeStamp
220   FindTimeStamp(const std::string& theMeshName, 
221                 const VISU::TEntity& theEntity, 
222                 const std::string& theFieldName, 
223                 int theStampsNum);
224
225   vtkUnstructuredGrid*
226   GetTimeStampOnProfile( const VISU::PMeshImpl& theMesh,
227                          const VISU::PMeshOnEntityImpl& theMeshOnEntity,
228                          const VISU::PFieldImpl& theField,
229                          const VISU::PValForTimeImpl& theValForTime,
230                          const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter,
231                          const VISU::PProfileImpl& theProfile,
232                          const VISU::TEntity& theEntity );
233
234 protected:
235   //! Implemention of the VISU_Convertor::GetTimeStampSize
236   virtual 
237   size_t 
238   GetTimeStampSize(const std::string& theMeshName, 
239                    const VISU::TEntity& theEntity,
240                    const std::string& theFieldName,
241                    int theStampsNum);
242
243   //! To fill intermeiate representation of TMeshOnEntity from a MED source
244   virtual
245   int
246   LoadMeshOnEntity(VISU::PMeshImpl theMesh,
247                    VISU::PMeshOnEntityImpl theMeshOnEntity) = 0;
248
249   //! To fill intermeiate representation of TFamily from a MED source
250   virtual
251   int
252   LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
253                      VISU::PMeshOnEntityImpl theMeshOnEntity, 
254                      VISU::PFamilyImpl theFamily) = 0;
255
256   //! To fill intermeiate representation of TGroup from a MED source
257   virtual 
258   int
259   LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
260                   const VISU::TFamilySet& theFamilySet) = 0;
261
262   //! To fill intermeiate representation of TValForTime for ordinary mesh from a MED source
263   virtual 
264   int
265   LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, 
266                        VISU::PMeshOnEntityImpl theMeshOnEntity, 
267                        VISU::PFieldImpl theField, 
268                        VISU::PValForTimeImpl theValForTime) = 0;
269
270   //! To fill intermeiate representation of TValForTime for mesh on Gauss Points from a MED source
271   virtual 
272   int
273   LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh, 
274                            VISU::PMeshOnEntityImpl theMeshOnEntity, 
275                            VISU::PFieldImpl theField, 
276                            VISU::PValForTimeImpl theValForTime) = 0;
277 };
278
279 #endif