]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_CorbaMedConvertor.hxx
Salome HOME
b6715c9a1f5c8fb9f66a2449ead02528c9a32538
[modules/visu.git] / src / VISU_I / VISU_CorbaMedConvertor.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 //  VISU OBJECT : interactive object for VISU entities implementation
23 //  File   : VISU_CorbaMedConvertor.hxx
24 //  Author : Alexey PETROV
25 //  Module : VISU
26 //  $Header$
27 //
28 #ifndef VISU_CorbaMedConvertor_HeaderFile
29 #define VISU_CorbaMedConvertor_HeaderFile
30
31 #include "VISUConfig.hh"
32 #include "VISU_Convertor_impl.hxx"
33 #include "VISU_Structures_impl.hxx"
34 #include "VISU_PointCoords.hxx"
35 #include "VISU_MeshValue.hxx"
36
37 #include <string>       
38
39 namespace VISU
40 {
41   //---------------------------------------------------------------
42   typedef std::pair<int, int> TIndexAndSize; // 
43   typedef std::map<SALOME_MED::medGeometryElement, TIndexAndSize> TCellsFirstIndex; // key: SALOME_MED::medGeometryElement
44
45   //---------------------------------------------------------------
46   struct TCMEDCoordHolder: TCoordHolder<SALOME_MED::double_array_var>
47   {
48     virtual
49     const TCoord*
50     GetPointer() const
51     {
52       return &myCoord[0];
53     }
54
55     virtual
56     TCoord*
57     GetPointer()
58     {
59       return &myCoord[0];
60     }
61   };
62
63
64   //---------------------------------------------------------------
65   template<class TValueType, class TContainerType>
66   struct TTCMEDMeshValue: TTMeshValueHolder<TValueType, TContainerType>
67   {
68     typedef TTMeshValueHolder<TValueType, TContainerType> TSuperClass;
69     vtkIdType myStartIndex;
70
71     //! To initilize the class instance
72     void
73     Init(vtkIdType theNbElem,
74          vtkIdType theNbGauss,
75          vtkIdType theNbComp,
76          const TContainerType& theContainer,
77          vtkIdType theStartIndex)
78     {
79       TSuperClass::Init(theNbElem, theNbGauss, theNbComp, theContainer);
80       myStartIndex = theStartIndex;
81     }
82
83     virtual
84     const TValueType*
85     GetPointer() const
86     {
87       return &(this->myContainer[myStartIndex]);
88     }
89
90     virtual
91     TValueType*
92     GetPointer()
93     {
94       return &(this->myContainer[myStartIndex]);
95     }
96   };
97
98
99   //---------------------------------------------------------------
100   struct TCMesh: virtual TMeshImpl
101   {
102     SALOME_MED::MESH_var myMesh;
103   };
104   typedef MED::SharedPtr<TCMesh> PCMesh;
105
106   //---------------------------------------------------------------
107   struct TCSubProfile: virtual TSubProfileImpl
108   {
109     SALOME_MED::medGeometryElement myMGeom;
110   };
111   typedef SharedPtr<TCSubProfile> PCSubProfile;
112
113   //---------------------------------------------------------------
114   struct TCProfile: virtual TProfileImpl
115   {};
116   typedef MED::SharedPtr<TCProfile> PCProfile;
117
118   //---------------------------------------------------------------
119   struct TCGauss: virtual TGaussImpl
120   {
121   };
122   typedef SharedPtr<TCGauss> PCGauss;
123   
124   struct TCGaussSubMesh: virtual TGaussSubMeshImpl
125   {
126   };
127   typedef SharedPtr<TCGaussSubMesh> PCGaussSubMesh;
128
129
130   //---------------------------------------------------------------
131   struct TCGaussMesh: virtual TGaussMeshImpl
132   {};
133   typedef SharedPtr<TCGaussMesh> PCGaussMesh;
134
135
136   //---------------------------------------------------------------
137   struct TCSubMesh: virtual TSubMeshImpl
138   {};
139   typedef MED::SharedPtr<TCSubMesh> PCSubMesh;
140
141
142   //---------------------------------------------------------------
143   struct TCMeshOnEntity: virtual TMeshOnEntityImpl
144   {
145     SALOME_MED::SUPPORT_var mySupport;
146     TCellsFirstIndex myCellsFirstIndex;
147   };
148   typedef MED::SharedPtr<TCMeshOnEntity> PCMeshOnEntity;
149   
150
151   //---------------------------------------------------------------
152   struct TCFamily: virtual TFamilyImpl
153   {
154     SALOME_MED::FAMILY_var myFamily;
155   };
156   typedef MED::SharedPtr<TCFamily> PCFamily;
157   
158
159   //---------------------------------------------------------------
160   struct TCGroup: virtual TGroupImpl
161   {
162     SALOME_MED::GROUP_var myGroup;
163   };
164   typedef MED::SharedPtr<TCGroup> PCGroup;
165
166
167   //---------------------------------------------------------------
168   struct TCField: virtual TFieldImpl
169   {};
170   typedef MED::SharedPtr<TCField> PCField;
171
172
173   //---------------------------------------------------------------
174   struct TCValForTime: virtual TValForTimeImpl
175   {
176     SALOME_MED::FIELD_var myField;
177   };
178   typedef MED::SharedPtr<TCValForTime> PCValForTime;
179
180 }
181
182
183 //---------------------------------------------------------------
184 class VISU_MEDConvertor: public VISU_Convertor_impl
185 {
186  protected:
187   SALOMEDS::SObject_var mySObject;
188   VISU_MEDConvertor() {};
189
190  public:
191   VISU_MEDConvertor(SALOMEDS::SObject_ptr theMedSObject): 
192     mySObject(SALOMEDS::SObject::_duplicate(theMedSObject)) 
193   {}
194
195   virtual
196   VISU_Convertor* 
197   Build();
198
199  protected:
200
201   VISU_Convertor* 
202   Build(SALOME_MED::MED_ptr theMED);
203   
204   VISU_Convertor* 
205   Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator);
206
207   virtual
208   int
209   LoadMeshOnEntity(VISU::PMeshImpl theMesh,
210                    VISU::PMeshOnEntityImpl theMeshOnEntity);
211   
212   virtual
213   int
214   LoadFamilyOnEntity(VISU::PMeshImpl theMesh,
215                      VISU::PMeshOnEntityImpl theMeshOnEntity, 
216                      VISU::PFamilyImpl theFamily);
217   
218   virtual
219   int
220   LoadMeshOnGroup(VISU::PMeshImpl theMesh, 
221                   const VISU::TFamilySet& theFamilySet);
222
223   virtual 
224   int
225   LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, 
226                        VISU::PMeshOnEntityImpl theMeshOnEntity, 
227                        VISU::PFieldImpl theField, 
228                        VISU::PValForTimeImpl theValForTime);
229
230   virtual
231   int
232   LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh, 
233                            VISU::PMeshOnEntityImpl theMeshOnEntity, 
234                            VISU::PFieldImpl theField, 
235                            VISU::PValForTimeImpl theValForTime)
236   {
237     return 0;
238   }
239
240   int 
241   LoadPoints(VISU::PCMesh theMesh) ;
242
243   int 
244   LoadPointsOnFamily(VISU::PCMesh theMesh, 
245                      VISU::PCFamily theFamily) ;
246
247   int 
248   LoadCellsOnEntity(VISU::PCMesh theMesh,
249                     VISU::PCMeshOnEntity theMeshOnEntity);
250   
251   int 
252   LoadCellsOnFamily(VISU::PCMesh theMesh,
253                     VISU::PCMeshOnEntity theMeshOnEntity, 
254                     VISU::PCFamily theFamily);
255   
256   int 
257   LoadField(VISU::PCMesh theMesh,
258             VISU::PCMeshOnEntity theMeshOnEntity,
259             VISU::PField theField, 
260             VISU::PCValForTime theValForTime);
261
262 };
263
264
265 //---------------------------------------------------------------
266 class VISU_MEDFieldConvertor: public VISU_MEDConvertor
267 {
268  protected:
269   SALOME_MED::FIELD_var myField;
270
271  public:
272
273   VISU_MEDFieldConvertor(SALOME_MED::FIELD_ptr theField) : 
274     myField(SALOME_MED::FIELD::_duplicate(theField)) 
275   {}
276
277   virtual 
278   VISU_Convertor* 
279   Build();
280 };
281
282 extern "C" {
283   VISU_Convertor* CreateMEDConvertor(SALOMEDS::SObject_ptr theMedSObject) ;
284   VISU_Convertor* CreateMEDFieldConvertor(SALOME_MED::FIELD_ptr theField) ;
285 }
286
287 #endif
288