Salome HOME
Fix PAL8562: rpath (rpath-link) option needs parameter - directory to search shared...
[modules/smesh.git] / src / SMESH_I / SMESH_MEDSupport_i.cxx
1 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESH_MEDSupport_i.cxx
25 //  Module : SMESH
26
27 using namespace std;
28 #include "SMESH_MEDSupport_i.hxx"
29 #include "utilities.h"
30 #include "Utils_CorbaException.hxx"
31 #include "Utils_ExceptHandlers.hxx"
32
33 #include <TopoDS_Iterator.hxx>
34 #include "SMESHDS_Mesh.hxx"
35
36 #include "SMESH_subMesh.hxx"
37 #include "SMESH_Mesh_i.hxx"
38 #include "SMESH_subMesh_i.hxx"
39
40
41 //=============================================================================
42 /*!
43  * Default constructor
44  */
45 //=============================================================================
46 SMESH_MEDSupport_i::SMESH_MEDSupport_i()
47 {
48         BEGIN_OF("Default Constructor SMESH_MEDSupport_i");
49         END_OF("Default Constructor SMESH_MEDSupport_i");
50 }
51
52 //=============================================================================
53 /*!
54  * Constructor
55  */
56 //=============================================================================
57 SMESH_MEDSupport_i::SMESH_MEDSupport_i(SMESH_subMesh_i * sm, string name,
58         string description, SALOME_MED::medEntityMesh entity)
59         :_subMesh_i(sm), _name(name), _description(description), _entity(entity),
60         _seqNumber(false), _seqLength(0)
61 {
62         BEGIN_OF("Constructor SMESH_MEDSupport_i");
63
64         _meshDS = _subMesh_i->_mesh_i->GetImpl().GetMeshDS();
65
66         int subMeshId = _subMesh_i->GetId();
67
68         MESSAGE(" subMeshId " << subMeshId)
69
70         if (_subMesh_i->_mesh_i->_mapSubMesh.find(subMeshId) !=
71                 _subMesh_i->_mesh_i->_mapSubMesh.end())
72         {
73                 ::SMESH_subMesh * subMesh = _subMesh_i->_mesh_i->_mapSubMesh[subMeshId];
74                 _subMeshDS = subMesh->GetSubMeshDS();
75         }
76
77         if (_entity == SALOME_MED::MED_NODE)
78         {
79                 _numberOfGeometricType = 1;
80                 _geometricType = new SALOME_MED::medGeometryElement[1];
81                 _geometricType[0] = SALOME_MED::MED_NONE;
82         }
83         else
84         {
85                 MESSAGE("Pas implemente dans cette version");
86                 THROW_SALOME_CORBA_EXCEPTION
87                         ("Seules les familles de noeuds sont implementees ",
88                         SALOME::BAD_PARAM);
89         }
90
91         END_OF("Constructor SMESH_MEDSupport_i");
92 }
93
94 //=============================================================================
95 /*!
96  * Constructor
97  */
98 //=============================================================================
99 SMESH_MEDSupport_i::
100 SMESH_MEDSupport_i(const SMESH_MEDSupport_i & s):_subMesh_i(s._subMesh_i),
101 _name(s._name), _description(s._description), _entity(s._entity),
102 _seqNumber(false), _seqLength(0)
103 {
104         BEGIN_OF("Constructor SMESH_MEDSupport_i");
105
106         _meshDS = _subMesh_i->_mesh_i->GetImpl().GetMeshDS();
107
108         int subMeshId = _subMesh_i->GetId();
109         if (_subMesh_i->_mesh_i->_mapSubMesh.find(subMeshId) !=
110                 _subMesh_i->_mesh_i->_mapSubMesh.end())
111         {
112                 ::SMESH_subMesh * subMesh = _subMesh_i->_mesh_i->_mapSubMesh[subMeshId];
113                 _subMeshDS = subMesh->GetSubMeshDS();
114         }
115
116         END_OF("Constructor SMESH_MEDSupport_i");
117 }
118
119 //=============================================================================
120 /*!
121  * Destructor
122  */
123 //=============================================================================
124
125 SMESH_MEDSupport_i::~SMESH_MEDSupport_i()
126 {
127 }
128
129 //=============================================================================
130 /*!
131  * CORBA: Accessor for Corba Index 
132  */
133 //=============================================================================
134
135 CORBA::Long SMESH_MEDSupport_i::getCorbaIndex()throw(SALOME::SALOME_Exception)
136 {
137         if (_subMeshDS == NULL)
138                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
139                         SALOME::INTERNAL_ERROR);
140         MESSAGE("Not implemented for SMESH_i");
141         THROW_SALOME_CORBA_EXCEPTION("Not Implemented ", SALOME::BAD_PARAM);
142
143 }
144
145 //=============================================================================
146 /*!
147  * CORBA: Accessor for Name 
148  */
149 //=============================================================================
150
151 char *SMESH_MEDSupport_i::getName() throw(SALOME::SALOME_Exception)
152 {
153         if (_subMeshDS==NULL)
154                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
155                         SALOME::INTERNAL_ERROR);
156         return CORBA::string_dup(_name.c_str());
157
158 }
159
160 //=============================================================================
161 /*!
162  * CORBA: Accessor for Description 
163  */
164 //=============================================================================
165
166 char *SMESH_MEDSupport_i::getDescription() throw(SALOME::SALOME_Exception)
167 {
168         if (_subMeshDS==NULL)
169                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
170                         SALOME::INTERNAL_ERROR);
171         return CORBA::string_dup(_description.c_str());
172 }
173
174 //=============================================================================
175 /*!
176  * CORBA: Accessor for Mesh 
177  */
178 //=============================================================================
179
180 SALOME_MED::MESH_ptr SMESH_MEDSupport_i::getMesh()throw(SALOME::
181         SALOME_Exception)
182 {
183         if (_subMeshDS==NULL)
184                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
185                         SALOME::INTERNAL_ERROR);
186
187         return _subMesh_i->_mesh_i->GetMEDMesh();
188 }
189
190 //=============================================================================
191 /*!
192  * CORBA: boolean indicating if support concerns all elements 
193  */
194 //=============================================================================
195
196 CORBA::Boolean SMESH_MEDSupport_i::isOnAllElements()throw(SALOME::
197         SALOME_Exception)
198 {
199         if (_subMeshDS==NULL)
200                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
201                         SALOME::INTERNAL_ERROR);
202         if (_seqNumber == false)
203         {
204                 if (_entity != SALOME_MED::MED_NONE)
205                 {
206                         _seqLength = _subMeshDS->NbNodes();
207                         _seqNumber = true;
208                 }
209                 else
210                 {
211                         MESSAGE("Only Node Families are implemented ");
212                         THROW_SALOME_CORBA_EXCEPTION("Not implemented Yet ",
213                                 SALOME::BAD_PARAM);
214                 }
215         }
216         try
217         {
218                 _isOnAllElements = (_seqLength == _meshDS->NbNodes());
219         }
220         catch(...)
221         {
222                 MESSAGE("unable to acces related Mesh");
223                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
224                         SALOME::INTERNAL_ERROR);
225         };
226         return _isOnAllElements;
227 }
228
229 //=============================================================================
230 /*!
231  * CORBA: Accessor for type of support's entity 
232  */
233 //=============================================================================
234
235 SALOME_MED::medEntityMesh SMESH_MEDSupport_i::getEntity()throw(SALOME::
236         SALOME_Exception)
237 {
238         if (_subMeshDS==NULL)
239                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
240                         SALOME::INTERNAL_ERROR);
241         return _entity;
242 }
243
244 //=============================================================================
245 /*!
246  * CORBA: Accessor for types of geometry elements 
247  */
248 //=============================================================================
249
250 SALOME_MED::medGeometryElement_array *
251         SMESH_MEDSupport_i::getTypes()throw(SALOME::SALOME_Exception)
252 {
253         if (_subMeshDS==NULL)
254                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
255                         SALOME::INTERNAL_ERROR);
256         SALOME_MED::medGeometryElement_array_var myseq =
257                 new SALOME_MED::medGeometryElement_array;
258         try
259         {
260                 int mySeqLength = _numberOfGeometricType;
261                 myseq->length(mySeqLength);
262                 for (int i = 0; i < mySeqLength; i++)
263                 {
264                         myseq[i] = _geometricType[i];
265                 }
266         }
267         catch(...)
268         {
269                 MESSAGE("Exception lors de la recherche des differents types");
270                 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support Types",
271                         SALOME::INTERNAL_ERROR);
272         }
273         return myseq._retn();
274 }
275
276 //=============================================================================
277 /*!
278  * CORBA: Number of different types of geometry elements
279  *        existing in the support
280  */
281 //=============================================================================
282 CORBA::Long SMESH_MEDSupport_i::getNumberOfElements(SALOME_MED::
283         medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
284 {
285         if (_subMeshDS==NULL)
286                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
287                         SALOME::INTERNAL_ERROR);
288         return _numberOfGeometricType;
289
290 }
291
292 //=============================================================================
293 /*!
294  * CORBA: get Nodes 
295  */
296 //=============================================================================
297
298 SALOME_MED::long_array * SMESH_MEDSupport_i::getNumber(
299         SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
300 {
301   Unexpect aCatch(SALOME_SalomeException);
302         if (_subMeshDS==NULL)
303                 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
304                         SALOME::INTERNAL_ERROR);
305
306         // A changer s'il ne s agit plus seulement de famille de noeuds
307         if (geomElement != SALOME_MED::MED_NONE)
308                 THROW_SALOME_CORBA_EXCEPTION("Not implemented", SALOME::BAD_PARAM);
309
310         SALOME_MED::long_array_var myseq = new SALOME_MED::long_array;
311
312         int i = 0;
313         myseq->length(_subMeshDS->NbNodes());
314
315         SMDS_NodeIteratorPtr it = _subMeshDS->GetNodes();
316         while(it->more())
317         {
318                 myseq[i] = it->next()->GetID();
319                 i++;
320         };
321
322         SCRUTE(myseq->length());
323         MESSAGE("End of SMESH_MEDSupport_i::getNumber");
324         return myseq._retn();
325
326 }
327
328 //=============================================================================
329 /*!
330  * CORBA: Global Nodes Index (optionnaly designed by the user)
331  * CORBA:  ??????????????????????????????
332  */
333 //=============================================================================
334
335 SALOME_MED::long_array *
336         SMESH_MEDSupport_i::getNumberIndex()throw(SALOME::SALOME_Exception)
337 {
338         MESSAGE("Not implemented for SMESH_i");
339         THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
340         return NULL;
341 }
342 //=============================================================================
343 /*!
344  * CORBA: Array containing indexes for elements included in the support  
345  */
346 //=============================================================================
347
348 CORBA::Long SMESH_MEDSupport_i::getNumberOfGaussPoint(SALOME_MED::
349         medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
350 {
351         MESSAGE("Not implemented for SMESH_i");
352         return 0;
353 }
354 //=============================================================================
355 /*!
356  * Gives the number of types of elements included in the support 
357  */
358 //=============================================================================
359 CORBA::Long SMESH_MEDSupport_i::getNumberOfTypes()
360   throw (SALOME::SALOME_Exception)
361 {
362   MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
363   THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
364   return 0;
365 }
366 //=============================================================================
367 /*!
368  * Gives CORBA: Array containing the numbers of Gauss point of elements
369  * included in the support 
370  */
371 //=============================================================================
372 SALOME_MED::long_array* SMESH_MEDSupport_i::getNumbersOfGaussPoint()
373   throw (SALOME::SALOME_Exception)
374 {
375   MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
376   THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
377   return NULL;
378 }
379 //=============================================================================
380 /*!
381  * build the object which will contain all the boundary elements of the mesh.
382  */
383 //=============================================================================
384 void SMESH_MEDSupport_i::getBoundaryElements()
385   throw (SALOME::SALOME_Exception)
386 {
387   MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
388   THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
389 }
390 //=============================================================================
391 /*!
392  * Gives information on the support
393  */
394 //=============================================================================
395 SALOME_MED::SUPPORT::supportInfos * SMESH_MEDSupport_i::getSupportGlobal()
396   throw (SALOME::SALOME_Exception)
397 {
398   MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
399   THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
400   return NULL;
401 }