1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "Utils_CorbaException.hxx"
21 #include "UtilClient.hxx"
22 #include "SUPPORTClient.hxx"
23 #include "MESHClient.hxx"
24 #include "ReceiverFactory.hxx"
26 using namespace MEDMEM;
27 using namespace MED_EN;
29 //=============================================================================
33 //=============================================================================
35 SUPPORTClient::SUPPORTClient(const SALOME_MED::SUPPORT_ptr S,
38 IOR_Support(SALOME_MED::SUPPORT::_duplicate(S)),_refCounter(1)
40 BEGIN_OF("SUPPORTClient::SUPPORTClient(SALOME_MED::SUPPORT_ptr m)");
48 SALOME_MED::MESH_var ior_mesh=IOR_Support->getMesh();
49 _mesh=new MESHClient(ior_mesh);
53 END_OF("SUPPORTClient::SUPPORTClient(SALOME_MED::SUPPORT_ptr m)");
55 //=============================================================================
57 * Remplit les informations générales
59 //=============================================================================
60 void SUPPORTClient::blankCopy()
62 BEGIN_OF("SUPPORTClient::blankCopy");
66 SALOME_MED::SUPPORT::supportInfos_var all = IOR_Support->getSupportGlobal();
69 _description = all->description;
70 setAll(all->isOnAllElements);
71 setEntity(all->entity);
73 setNumberOfGeometricType(all->numberOfGeometricType);
74 convertCorbaArray2(_geometricType, _numberOfGeometricType, all->types);
79 int *nE = new int[_numberOfGeometricType];
81 for (i=0; i<_numberOfGeometricType; i++)
83 nE[i] = all->nbEltTypes[i];
85 setNumberOfElements(nE);
89 SCRUTE(_totalNumberOfElements);
90 _complete_support = false;
92 catch( const CORBA::Exception &ex )
94 MESSAGE("Erreur CORBA dans la communication" ) ;
95 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
96 SALOME::INTERNAL_ERROR);
99 END_OF("SUPPORTClient::blankCopy");
102 //=============================================================================
106 //=============================================================================
107 void SUPPORTClient::fillCopy()
109 BEGIN_OF("SUPPORTClient::fillCopy");
111 if (!_complete_support) {
113 const int * index, * value;
114 long n_index, n_value;
116 SALOME::SenderInt_var senderForValue=IOR_Support->getSenderForNumber(MED_ALL_ELEMENTS);
117 value=(const int *)ReceiverFactory::getValue(senderForValue,n_value);
118 SALOME::SenderInt_var senderForIndex=IOR_Support->getSenderForNumberIndex();
119 index=(const int *)ReceiverFactory::getValue(senderForIndex,n_index);
123 setNumber(index, value,true);
125 _complete_support = true;
128 END_OF("SUPPORTClient::fillCopy");
130 //=============================================================================
134 //=============================================================================
135 SUPPORTClient::~SUPPORTClient()
137 BEGIN_OF("SUPPORTClient::~SUPPORTClient");
138 IOR_Support->Destroy();
140 _mesh->removeReference();
141 END_OF("SUPPORTClient::~SUPPORTClient");
144 //=============================================================================
148 //=============================================================================
149 MEDSKYLINEARRAY * SUPPORTClient::getnumber() const throw (MEDEXCEPTION)
151 BEGIN_OF("SUPPORTClient::getnumber()");
153 if (!_complete_support) (const_cast<SUPPORTClient *>(this))->fillCopy();
154 MEDSKYLINEARRAY *m = SUPPORT::getnumber();
156 END_OF("SUPPORTClient::getnumber()");
160 //=============================================================================
164 //=============================================================================
165 const int * SUPPORTClient::getNumber(medGeometryElement GeometricType)
166 const throw (MEDEXCEPTION)
168 BEGIN_OF("SUPPORTClient::getnumber(medGeometryElement)");
170 if (!_complete_support) (const_cast<SUPPORTClient *>(this))->fillCopy();
171 const int *n = SUPPORT::getNumber(GeometricType);
173 END_OF("SUPPORTClient::getnumber(medGeometryElement)");
177 //=============================================================================
181 //=============================================================================
182 const int * SUPPORTClient::getNumberIndex() const throw (MEDEXCEPTION)
184 BEGIN_OF("SUPPORTClient::getnumberIndex()");
186 if (!_complete_support) (const_cast<SUPPORTClient *>(this))->fillCopy();
187 const int * n = SUPPORT::getNumberIndex();
189 END_OF("SUPPORTClient::getnumberIndex()");
193 //=============================================================================
197 //=============================================================================
198 int SUPPORTClient::getValIndFromGlobalNumber(const int number) const throw (MEDEXCEPTION)
200 BEGIN_OF("SUPPORTClient::getValIndFromGlobalNumber()");
202 if (!_complete_support) (const_cast<SUPPORTClient *>(this))->fillCopy();
203 const int n = SUPPORT::getValIndFromGlobalNumber(number);
205 END_OF("SUPPORTClient::getValIndFromGlobalNumber()");
209 //=============================================================================
213 //=============================================================================
214 void SUPPORTClient::addReference() const
219 //=============================================================================
223 //=============================================================================
224 void SUPPORTClient::removeReference() const
226 if (--_refCounter <= 0)