Salome HOME
Final version of the V2_2_0 in the main trunk of the CVS tree.
[modules/med.git] / src / MedClient / src / SUPPORTClient.cxx
1 #include "Utils_CorbaException.hxx"
2 #include "UtilClient.hxx"
3 #include "SUPPORTClient.hxx"
4 #include "MESHClient.hxx"
5 #include "ReceiverFactory.hxx"
6
7 using namespace MEDMEM;
8 using namespace MED_EN;
9
10 //=============================================================================
11 /*!
12  * Constructeur
13  */
14 //=============================================================================
15
16 SUPPORTClient::SUPPORTClient(const SALOME_MED::SUPPORT_ptr S,
17                              MESH * M) : 
18   SUPPORT(), 
19   IOR_Support(SALOME_MED::SUPPORT::_duplicate(S)),
20   _ownMesh(false)
21 {
22   BEGIN_OF("SUPPORTClient::SUPPORTClient(SALOME_MED::SUPPORT_ptr m)");
23
24   SCRUTE(S);
25   SCRUTE(M);
26   if(M)
27     _mesh=M;
28   else
29     {
30       _mesh=new MESHClient(IOR_Support->getMesh());
31       _ownMesh=true;
32     }
33   blankCopy();
34
35   END_OF("SUPPORTClient::SUPPORTClient(SALOME_MED::SUPPORT_ptr m)");
36 }
37 //=============================================================================
38 /*!
39  * Remplit les informations générales
40  */
41 //=============================================================================
42 void SUPPORTClient::blankCopy()
43 {
44   BEGIN_OF("SUPPORTClient::blankCopy");
45
46  try
47   {
48         SALOME_MED::SUPPORT::supportInfos_var all = IOR_Support->getSupportGlobal();
49
50         _name = all->name;
51         _description = all->description;
52         setAll(all->isOnAllElements);
53         setEntity(all->entity);
54 // modifs PN 
55         setNumberOfGeometricType(all->numberOfGeometricType);
56         convertCorbaArray(_geometricType, _numberOfGeometricType,
57                            &all->types);
58
59         //_name = IOR_Support->getName();
60         //_description = IOR_Support->getDescription();
61         //setAll(IOR_Support->isOnAllElements());
62         //setEntity(IOR_Support->getEntity());
63
64         SCRUTE(_name);
65         SCRUTE(_description);
66         //convertCorbaArray(_geometricType, _numberOfGeometricType,
67         //          IOR_Support->getTypes());
68
69         int *nE = new int[_numberOfGeometricType];
70         int i;
71         for (i=0; i<_numberOfGeometricType; i++)
72         {
73                 nE[i] = all->nbEltTypes[i];
74         }
75         setNumberOfElements(nE);
76
77         delete [] nE;
78
79         SCRUTE(_totalNumberOfElements);
80         _complete_support = false;
81   }
82   catch( const CORBA::Exception &ex )
83   {
84          MESSAGE("Erreur CORBA dans la communication" ) ;
85          THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
86                                        SALOME::INTERNAL_ERROR);
87   }
88
89   END_OF("SUPPORTClient::blankCopy");
90
91 }
92 //=============================================================================
93 /*!
94  *  
95  */
96 //=============================================================================
97 void SUPPORTClient::fillCopy()
98 {
99   BEGIN_OF("SUPPORTClient::fillCopy");
100
101   if (!_complete_support) {
102
103     const int * index, * value;
104     long n_index, n_value;
105
106     value=(const int *)ReceiverFactory::getValue(IOR_Support->getSenderForNumber(MED_ALL_ELEMENTS),n_value);
107     index=(const int *)ReceiverFactory::getValue(IOR_Support->getSenderForNumberIndex(),n_index);
108     
109     SCRUTE(n_index);
110     SCRUTE(n_value);
111     setNumber(index, value,true);
112
113     _complete_support = true;
114   }
115
116   END_OF("SUPPORTClient::fillCopy");
117 }
118 //=============================================================================
119 /*!
120  * Destructeur
121  */
122 //=============================================================================
123 SUPPORTClient::~SUPPORTClient()
124 {
125   BEGIN_OF("SUPPORTClient::~SUPPORTClient");
126   IOR_Support->release();
127   if(_ownMesh)
128      delete _mesh;
129   END_OF("SUPPORTClient::~SUPPORTClient");
130 }
131
132 //=============================================================================
133 /*!
134  * Destructeur
135  */
136 //=============================================================================
137 MEDSKYLINEARRAY *  SUPPORTClient::getnumber() const throw (MEDEXCEPTION)
138 {
139   BEGIN_OF("SUPPORTClient::getnumber()");
140
141   if (!_complete_support) (const_cast<SUPPORTClient *>(this))->fillCopy();
142   MEDSKYLINEARRAY *m = SUPPORT::getnumber();
143
144   END_OF("SUPPORTClient::getnumber()");
145   return m;
146 }
147
148 //=============================================================================
149 /*!
150  * 
151  */
152 //=============================================================================
153 const int *  SUPPORTClient::getNumber(medGeometryElement GeometricType) 
154     const throw (MEDEXCEPTION)
155 {
156   BEGIN_OF("SUPPORTClient::getnumber(medGeometryElement)");
157
158   if (!_complete_support) (const_cast<SUPPORTClient *>(this))->fillCopy();
159   const int *n = SUPPORT::getNumber(GeometricType);
160
161   END_OF("SUPPORTClient::getnumber(medGeometryElement)");
162   return n;
163 }
164
165 //=============================================================================
166 /*!
167  * 
168  */
169 //=============================================================================
170 const int *  SUPPORTClient::getNumberIndex() const throw (MEDEXCEPTION) 
171 {
172   BEGIN_OF("SUPPORTClient::getnumberIndex()");
173
174   if (!_complete_support) (const_cast<SUPPORTClient *>(this))->fillCopy();
175   const int * n = SUPPORT::getNumberIndex();
176
177   END_OF("SUPPORTClient::getnumberIndex()");
178   return n;
179 }
180