1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "Utils_CorbaException.hxx"
23 #include "UtilClient.hxx"
24 #include "SUPPORTClient.hxx"
25 #include "MESHClient.hxx"
26 #include "ReceiverFactory.hxx"
28 using namespace MEDMEM;
29 using namespace MED_EN;
31 //=============================================================================
35 //=============================================================================
37 SUPPORTClient::SUPPORTClient(const SALOME_MED::SUPPORT_ptr S,
40 IOR_Support(SALOME_MED::SUPPORT::_duplicate(S)),_refCounter(1)
42 const char* LOC = "SUPPORTClient::SUPPORTClient(SALOME_MED::SUPPORT_ptr m)";
51 SALOME_MED::MESH_var ior_mesh=IOR_Support->getMesh();
52 _mesh=new MESHClient(ior_mesh);
58 //=============================================================================
60 * Remplit les informations générales
62 //=============================================================================
63 void SUPPORTClient::blankCopy()
65 const char* LOC = "SUPPORTClient::blankCopy";
70 SALOME_MED::SUPPORT::supportInfos_var all = IOR_Support->getSupportGlobal();
73 _description = all->description;
74 setAll(all->isOnAllElements);
75 setEntity(all->entity);
77 setNumberOfGeometricType(all->numberOfGeometricType);
78 convertCorbaArray2(_geometricType, _numberOfGeometricType, all->types);
83 int *nE = new int[_numberOfGeometricType];
85 for (i=0; i<_numberOfGeometricType; i++)
87 nE[i] = all->nbEltTypes[i];
89 setNumberOfElements(nE);
93 SCRUTE(_totalNumberOfElements);
94 _complete_support = false;
96 catch( const CORBA::Exception &ex )
98 MESSAGE("Erreur CORBA dans la communication" ) ;
99 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
100 SALOME::INTERNAL_ERROR);
106 //=============================================================================
110 //=============================================================================
111 void SUPPORTClient::fillCopy()
113 const char* LOC = "SUPPORTClient::fillCopy";
116 if (!_complete_support) {
118 const int * index, * value;
119 long n_index, n_value;
121 SALOME::SenderInt_var senderForValue=IOR_Support->getSenderForNumber(MED_ALL_ELEMENTS);
122 value=(const int *)ReceiverFactory::getValue(senderForValue,n_value);
123 SALOME::SenderInt_var senderForIndex=IOR_Support->getSenderForNumberIndex();
124 index=(const int *)ReceiverFactory::getValue(senderForIndex,n_index);
128 setNumber(index, value,true);
130 _complete_support = true;
135 //=============================================================================
139 //=============================================================================
140 SUPPORTClient::~SUPPORTClient()
142 const char* LOC = "SUPPORTClient::~SUPPORTClient";
144 IOR_Support->Destroy();
146 _mesh->removeReference();
150 //=============================================================================
154 //=============================================================================
155 MEDSKYLINEARRAY * SUPPORTClient::getnumber() const throw (MEDEXCEPTION)
157 const char* LOC = "SUPPORTClient::getnumber()";
160 if (!_complete_support) (const_cast<SUPPORTClient *>(this))->fillCopy();
161 MEDSKYLINEARRAY *m = SUPPORT::getnumber();
167 //=============================================================================
171 //=============================================================================
172 const int * SUPPORTClient::getNumber(medGeometryElement GeometricType)
173 const throw (MEDEXCEPTION)
175 const char* LOC = "SUPPORTClient::getnumber(medGeometryElement)";
178 if (!_complete_support) (const_cast<SUPPORTClient *>(this))->fillCopy();
179 const int *n = SUPPORT::getNumber(GeometricType);
185 //=============================================================================
189 //=============================================================================
190 const int * SUPPORTClient::getNumberIndex() const throw (MEDEXCEPTION)
192 const char* LOC = "SUPPORTClient::getnumberIndex()";
195 if (!_complete_support) (const_cast<SUPPORTClient *>(this))->fillCopy();
196 const int * n = SUPPORT::getNumberIndex();
202 //=============================================================================
206 //=============================================================================
207 int SUPPORTClient::getValIndFromGlobalNumber(const int number) const throw (MEDEXCEPTION)
209 const char* LOC = "SUPPORTClient::getValIndFromGlobalNumber()";
212 if (!_complete_support) (const_cast<SUPPORTClient *>(this))->fillCopy();
213 const int n = SUPPORT::getValIndFromGlobalNumber(number);
219 //=============================================================================
223 //=============================================================================
224 void SUPPORTClient::addReference() const
229 //=============================================================================
233 //=============================================================================
234 void SUPPORTClient::removeReference() const
236 if (--_refCounter <= 0)