Salome HOME
Fix to avoid dependence of mesh on itself (it leaded to cycle in 'SetRemovedFromStudy').
[modules/smesh.git] / src / SMESH_I / SMESH_MEDFamily_i.cxx
1 // Copyright (C) 2007-2013  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 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
24 //  File   : SMESH_MEDFamily_i.cxx
25 //  Module : SMESH
26 //
27 #include "SMESH_MEDFamily_i.hxx"
28 #include "utilities.h"
29 #include "Utils_CorbaException.hxx"
30
31 using namespace std;
32
33 //=============================================================================
34 /*!
35  * Default constructor
36  */
37 //=============================================================================
38 SMESH_MEDFamily_i::SMESH_MEDFamily_i()
39 {
40   BEGIN_OF("Default Constructor SMESH_MEDFamily_i");
41   END_OF("Default Constructor SMESH_MEDFamily_i");
42 }
43 //=============================================================================
44 /*!
45  * constructor par recopie
46  */
47 //=============================================================================
48 SMESH_MEDFamily_i::SMESH_MEDFamily_i(const SMESH_MEDFamily_i & f): 
49   SMESH_MEDSupport_i(f._subMesh_i,f._name,f._description,f._entity),
50   _subMesh_i(f._subMesh_i),
51   _identifier(f._identifier),
52   _numberOfAttribute(f._numberOfAttribute),
53   _numberOfGroup(f._numberOfGroup), 
54   _attributeValue(f._attributeValue)
55 {
56   BEGIN_OF("Copy Constructor SMESH_MEDFamily_i");
57   _attributeDescription=new string[_numberOfAttribute];
58   for (int i=0;i<_numberOfAttribute;i++) {
59     _attributeDescription[i]=f._attributeDescription[i];
60   };
61   _groupName=new string[_numberOfGroup];
62   for (int i=0;i<_numberOfAttribute;i++) {
63     _groupName[i]=f._groupName[i];
64   };
65   END_OF("Copy Constructor SMESH_MEDFamily_i");
66 }
67 //=============================================================================
68 /*!
69  * Destructor
70  */
71 //=============================================================================
72 SMESH_MEDFamily_i::~SMESH_MEDFamily_i()
73 {
74 }
75 //=============================================================================
76 /*!
77  * Constructor
78  */
79 //=============================================================================
80 SMESH_MEDFamily_i::SMESH_MEDFamily_i(int identifier, SMESH_subMesh_i* sm,
81                                      string name, string description, SALOME_MED::medEntityMesh entity): 
82   SMESH_MEDSupport_i( sm, name, description, entity ),
83   
84   _subMesh_i(sm),
85   _identifier(identifier),
86   _numberOfAttribute(0),
87   _attributeIdentifier((int*)NULL),
88   _attributeValue((int*)NULL), 
89   _attributeDescription((string*)NULL),
90   _numberOfGroup(0), 
91   _groupName((string*)NULL)
92 {
93   BEGIN_OF("Constructor SMESH_MEDFamily_i");
94   END_OF("Constructor SMESH_MEDFamily_i");
95 }
96 //=============================================================================
97 /*!
98  * CORBA: Accessor for Family's Identifier
99  */
100 //=============================================================================
101
102 CORBA::Long SMESH_MEDFamily_i::getIdentifier()      
103 throw (SALOME::SALOME_Exception)
104 {
105   if (_subMesh==NULL)
106     THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
107                                  SALOME::INTERNAL_ERROR); 
108   return _identifier;
109   
110 }
111 //=============================================================================
112 /*!
113  * CORBA: Accessor for number of attributes
114  */
115 //=============================================================================
116 CORBA::Long SMESH_MEDFamily_i::getNumberOfAttributes() 
117 throw (SALOME::SALOME_Exception)
118 {
119   if (_subMesh==NULL)
120     THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
121                                  SALOME::INTERNAL_ERROR);
122   return _numberOfAttribute;
123 }
124 //=============================================================================
125 /*!
126  * CORBA: Accessor for attributes identifiers
127  */
128 //=============================================================================
129 SALOME_TYPES::ListOfLong*  SMESH_MEDFamily_i::getAttributesIdentifiers() 
130 throw (SALOME::SALOME_Exception)
131 {
132   if (_subMesh==NULL)
133     THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
134                                  SALOME::INTERNAL_ERROR);
135   if (_numberOfAttribute == 0)
136     {
137       MESSAGE("Les familles SMESH n ont pas d attribut");
138       THROW_SALOME_CORBA_EXCEPTION("No attributes"\
139                                    ,SALOME::BAD_PARAM);
140     };
141   
142   SALOME_TYPES::ListOfLong_var myseq= new SALOME_TYPES::ListOfLong;
143   myseq->length(_numberOfAttribute);
144   for (int i=0;i<_numberOfAttribute;i++)
145     {
146       myseq[i]=_attributeIdentifier[i];
147     };
148   return myseq._retn();
149
150 }
151 //=============================================================================
152 /*!
153  * CORBA: Accessor for attribute identifier I
154  */
155 //=============================================================================
156 CORBA::Long SMESH_MEDFamily_i::getAttributeIdentifier(CORBA::Long i) 
157   throw (SALOME::SALOME_Exception)
158 {    
159   if (_subMesh==NULL)
160     THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
161                                  SALOME::INTERNAL_ERROR);
162   MESSAGE("Les familles SMESH n ont pas d attribut");
163   THROW_SALOME_CORBA_EXCEPTION("No attributes"\
164                                ,SALOME::BAD_PARAM);
165   if (_numberOfAttribute == 0)
166     {
167       MESSAGE("Les familles SMESH n ont pas d attribut");
168       THROW_SALOME_CORBA_EXCEPTION("No attributes"\
169                                    ,SALOME::BAD_PARAM);
170     };
171   ASSERT (i <= _numberOfAttribute);
172   return _attributeIdentifier[i];
173 }
174 //=============================================================================
175 /*!
176  * CORBA: Accessor for attributes values
177  */
178 //=============================================================================
179 SALOME_TYPES::ListOfLong*  SMESH_MEDFamily_i::getAttributesValues() 
180   throw (SALOME::SALOME_Exception)
181 {
182   if (_subMesh==NULL)
183     THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
184                                  SALOME::INTERNAL_ERROR);
185
186   if (_numberOfAttribute == 0)
187     {
188       MESSAGE("Les familles SMESH n ont pas d attribut");
189       THROW_SALOME_CORBA_EXCEPTION("No attributes"\
190                                    ,SALOME::BAD_PARAM);
191     };
192
193   SALOME_TYPES::ListOfLong_var myseq= new SALOME_TYPES::ListOfLong;
194   myseq->length(_numberOfAttribute);
195   for (int i=0;i<_numberOfAttribute;i++)
196     {
197       myseq[i]=_attributeValue[i];
198     };
199   return myseq._retn();
200 }
201 //=============================================================================
202 /*!
203  * CORBA: Accessor for attribute value I
204  */
205 //=============================================================================
206 CORBA::Long  SMESH_MEDFamily_i::getAttributeValue(CORBA::Long i) 
207   throw (SALOME::SALOME_Exception)
208 {   
209   if (_subMesh==NULL)
210     THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
211                                  SALOME::INTERNAL_ERROR);
212   if (_numberOfAttribute == 0)
213     {
214       MESSAGE("Les familles SMESH n ont pas d attribut");
215       THROW_SALOME_CORBA_EXCEPTION("No attributes"\
216                                    ,SALOME::BAD_PARAM);
217     }
218
219   ASSERT (i <= _numberOfAttribute);
220   return _attributeValue[i];
221 }
222 //=============================================================================
223 /*!
224  * CORBA: Accessor for attributes desriptions
225  */
226 //=============================================================================
227 SALOME_TYPES::ListOfString * SMESH_MEDFamily_i::getAttributesDescriptions() 
228   throw (SALOME::SALOME_Exception)
229 {
230   if (_subMesh==NULL)
231     THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
232                                  SALOME::INTERNAL_ERROR);
233   if (_numberOfAttribute == 0)
234     {
235       MESSAGE("Les familles SMESH n ont pas d attribut");
236       THROW_SALOME_CORBA_EXCEPTION("No attributes"\
237                                    ,SALOME::BAD_PARAM);
238     }
239   SALOME_TYPES::ListOfString_var myseq = new SALOME_TYPES::ListOfString;
240   for (int i=0;i<_numberOfAttribute;i++)
241     {
242       myseq[i]=CORBA::string_dup(_attributeDescription[i].c_str());
243     }
244   return myseq._retn();
245 }
246 //=============================================================================
247 /*!
248  * CORBA: Accessor for attribute description i
249  */
250 //=============================================================================
251 char *  SMESH_MEDFamily_i::getAttributeDescription( CORBA::Long i) 
252   throw (SALOME::SALOME_Exception)
253 {   
254   if (_subMesh==NULL)
255     THROW_SALOME_CORBA_EXCEPTION("No associated Family",\
256                                  SALOME::INTERNAL_ERROR);
257   if (_numberOfAttribute == 0)
258     {
259       MESSAGE("Les familles SMESH n ont pas d attribut");
260       THROW_SALOME_CORBA_EXCEPTION("No attributes"\
261                                    ,SALOME::BAD_PARAM);
262     }
263   ASSERT (i <= _numberOfAttribute);
264   return CORBA::string_dup(_attributeDescription[i].c_str());
265 }
266 //=============================================================================
267 /*!
268  * CORBA: Accessor for the number of groups
269  */
270 //=============================================================================
271 CORBA::Long SMESH_MEDFamily_i::getNumberOfGroups()
272     throw (SALOME::SALOME_Exception)
273 {
274   MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
275   THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
276   return 0;
277 }
278 //=============================================================================
279 /*!
280  * CORBA: Accessor for the name of the group i
281  */
282 //=============================================================================
283 char * SMESH_MEDFamily_i::getGroupName( CORBA::Long i)
284   throw (SALOME::SALOME_Exception)
285 {
286   MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
287   THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
288   return NULL;
289 }
290 //=============================================================================
291 /*!
292  * CORBA: Accessor for all the groups name
293  */
294 //=============================================================================
295 SALOME_TYPES::ListOfString* SMESH_MEDFamily_i::getGroupsNames()
296   throw (SALOME::SALOME_Exception)
297 {
298   MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
299   THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
300   return NULL;
301 }