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