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