Salome HOME
MEDMEM suppression
[modules/med.git] / src / MEDMEM_I / MEDMEM_Group_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 //=============================================================================
24 // File      : MEDMEM_Group_i.cxx
25 // Project   : SALOME
26 // Author    : EDF 
27 // $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Group_i.cxx
28 //=============================================================================
29 //
30 #include <vector>
31
32 #include "utilities.h"
33 #include "Utils_CorbaException.hxx"
34
35 #include "MEDMEM_Group_i.hxx"
36 #include "MEDMEM_Family_i.hxx"
37
38 #include "MEDMEM_Group.hxx"
39 #include "MEDMEM_Family.hxx"
40 using namespace MEDMEM;
41
42 //=============================================================================
43 /*!
44  * Default constructor
45  */
46 //=============================================================================
47 GROUP_i::GROUP_i():_group((::GROUP*)NULL)
48 {
49 }
50 //=============================================================================
51 /*!
52  * Destructor
53  */
54 //=============================================================================
55 GROUP_i::~GROUP_i()
56 {
57 }
58 //=============================================================================
59 /*!
60  * Constructor
61  */
62 //=============================================================================
63 GROUP_i::GROUP_i(const ::GROUP * const g):SUPPORT_i(g),_group(g)
64 {
65 }
66 //=============================================================================
67 /*!
68  * Constructor par recopie
69  */
70 //=============================================================================
71 GROUP_i::GROUP_i(const GROUP_i & g):SUPPORT_i(g._group),_group(g._group)
72 {
73 }
74 //=============================================================================
75 /*!
76  * CORBA: Number of Families existing in the group
77  */
78 //=============================================================================
79
80 CORBA::Long  GROUP_i::getNumberOfFamilies() 
81 throw (SALOME::SALOME_Exception)
82 {
83         if (_group==NULL)
84                 THROW_SALOME_CORBA_EXCEPTION("No associated Group",\
85                                              SALOME::INTERNAL_ERROR);
86         try
87         {
88                 return _group->getNumberOfFamilies();
89         }
90         catch (MEDEXCEPTION &ex)
91         {
92                 MESSAGE("Unable to get number of families of the group");
93                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
94         }
95 }
96 //=============================================================================
97 /*!
98  * CORBA: Returns references for families within the group
99  */
100 //=============================================================================
101
102 SALOME_MED::Family_array* GROUP_i::getFamilies()         
103 throw (SALOME::SALOME_Exception)
104 {
105         if (_group==NULL)
106                 THROW_SALOME_CORBA_EXCEPTION("No associated Group",\
107                                              SALOME::INTERNAL_ERROR);
108         SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array;
109         try
110         {
111                 int nbfam= _group->getNumberOfFamilies();
112                 myseq->length(nbfam);
113                 vector<FAMILY*> fam(nbfam);
114                 fam = _group->getFamilies();
115                 for (int i=0;i<nbfam;i++)
116                 {
117                         FAMILY_i * f1=new FAMILY_i(fam[i]);
118                         myseq[i] = f1->_this();
119                 }
120         }
121         catch (MEDEXCEPTION &ex)
122         {
123                 MESSAGE("Unable to access families");
124                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
125         }
126         return myseq._retn();
127 }
128 //=============================================================================
129 /*!
130  * CORBA: Returns reference for family I within the group
131  */
132 //=============================================================================
133
134 SALOME_MED::FAMILY_ptr GROUP_i::getFamily(CORBA::Long i) 
135 throw (SALOME::SALOME_Exception)
136 {
137         if (_group==NULL)
138                 THROW_SALOME_CORBA_EXCEPTION("No associated Group",\
139                                              SALOME::INTERNAL_ERROR);
140         try
141         {
142                 FAMILY * fam=_group->getFamily(i);
143                 FAMILY_i * f1=new FAMILY_i(fam);
144                 return f1->_this();
145         }
146         catch (MEDEXCEPTION &ex)
147         {
148                 MESSAGE("Unable to acces to the specified family");
149                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
150         }
151 }