1 // Copyright (C) 2007-2013 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
23 #include "MEDMEM_convert.hxx"
24 #include "Utils_CorbaException.hxx"
25 #include "UtilClient.hxx"
26 #include "CONNECTIVITYClient.hxx"
28 #include "ReceiverFactory.hxx"
29 using namespace MEDMEM;
30 //=============================================================================
34 //=============================================================================
36 CONNECTIVITYClient::CONNECTIVITYClient(const SALOME_MED::MESH_ptr m,
37 medEntityMesh Entity) :
38 CONNECTIVITY(m->getNumberOfTypes(Entity), Entity),
39 _numberOfElements_client(0),
41 IOR_Mesh(SALOME_MED::MESH::_duplicate(m))
48 //=============================================================================
52 //=============================================================================
53 CONNECTIVITYClient::~CONNECTIVITYClient()
55 if (_numberOfElements_client)
56 delete [] _numberOfElements_client;
59 //=============================================================================
61 * Remplit les informations nécessaires
64 //=============================================================================
65 void CONNECTIVITYClient::blankCopy()
67 SALOME_MED::MESH::connectivityInfos_var all;
68 medEntityMesh Entity = getEntity();
71 all= IOR_Mesh->getConnectGlobal(Entity);
73 catch (const exception & ex)
75 MESSAGE("Unable to acces Global information");
76 THROW_SALOME_CORBA_EXCEPTION(ex.what() ,SALOME::INTERNAL_ERROR);
79 _numberOfNodes = all->numberOfNodes;
80 _entityDimension = all->entityDimension;
81 medGeometryElement * Types;
84 convertCorbaArray<MED_EN::medGeometryElement,SALOME_MED::medGeometryElement_array *, long>
85 (Types, nT, &all->meshTypes);
87 ASSERT(nT == (int) getNumberOfTypes(Entity));
90 setGeometricTypes(Types, Entity);
92 _totalNumberOfElements_client = 0L;
93 if (_numberOfElements_client)
94 delete [] _numberOfElements_client;
95 _numberOfElements_client = new long[nT];
96 for (iT=0; iT<nT; iT++)
98 _numberOfElements_client[iT] = all->numberOfElements[iT];
99 _totalNumberOfElements_client += _numberOfElements_client[iT];
101 SCRUTE(_numberOfElements_client[iT]);
107 // create a constituent (PAL10556)
108 // The consequence is that, if the remote server
109 // has not calculated nodal connectivity of dimension d-1, heavy method
110 // (CPU and memory) calculateDecsendingConnectivity is called on this
111 // server for a potentially useless information for client side . (by Anthony GEAY)
112 if ( Entity == MED_CELL ) {
113 Entity = ( IOR_Mesh->getMeshDimension() == 3 ? MED_FACE : MED_EDGE );
116 _constituent = new CONNECTIVITYClient( IOR_Mesh, Entity );
122 //=============================================================================
125 //=============================================================================
126 // template< class T>
127 // void dumpArray(const T* array, int size, const char* msg)
130 // std::cout << msg << " " << std::endl;
131 // std::cout << "Size: " << size << std::endl;
132 // for ( int i = 0; i < size; i++ )
133 // std::cout << " " << array[ i ];
134 // std::cout << endl;
137 void CONNECTIVITYClient::fillCopy()
144 medEntityMesh Entity = getEntity();
145 int iT, nT = getNumberOfTypes(Entity);
147 const medGeometryElement * T = getGeometricTypes(Entity);
149 int * Count = new int[nT+1] ;
152 for (iT=0; iT<nT; iT++) {
153 Count[iT+1]=Count[iT] + _numberOfElements_client[iT];
156 setCount(Count, Entity) ;
158 for (iT=0; iT<nT; iT++) {
161 SCRUTE(Count[iT+1]-Count[iT]);
163 SALOME::SenderInt_var senderForConnectivity=IOR_Mesh->getSenderForConnectivity(MED_NODAL, Entity, T[iT]);
164 pC=ReceiverFactory::getValue(senderForConnectivity,nC);
166 ASSERT(nC == (T[iT]%100) * (Count[iT+1]-Count[iT]));
169 if ( T[iT] == MED_EN::MED_POLYGON || T[iT] == MED_EN::MED_POLYHEDRA )
171 SALOME::SenderInt_var senderForIndex=IOR_Mesh->getSenderForConnectivityIndex(MED_NODAL, Entity, T[iT]);
172 index=ReceiverFactory::getValue(senderForIndex,nC);
173 ASSERT(nC == (Count[iT+1]-Count[iT]+1));
176 setNodal(pC, Entity, T[iT], index);
183 ((CONNECTIVITYClient *)_constituent)->fillCopy();
188 //=============================================================================
191 //=============================================================================
192 int CONNECTIVITYClient::getNumberOf(medEntityMesh Entity,
193 medGeometryElement Type) const
202 if (Entity == _entity) {
204 if (Type==MED_ALL_ELEMENTS)
205 n = _totalNumberOfElements_client;
207 for (int i=0; i<_numberOfTypes; i++) {
208 SCRUTE(_geometricTypes[i]);
209 if (_geometricTypes[i] == Type) {
210 n = _numberOfElements_client[i];
215 else if (_constituent != NULL)
216 n = _constituent->getNumberOf(Entity,Type);
220 n = CONNECTIVITY::getNumberOf(Entity, Type);
226 //=============================================================================
229 //=============================================================================
230 const int * CONNECTIVITYClient::getConnectivity (medConnectivity ConnectivityType,
231 medEntityMesh Entity,
232 medGeometryElement Type) const
235 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
237 const int * c = CONNECTIVITY::getConnectivity (ConnectivityType, Entity, Type);
242 int CONNECTIVITYClient::getConnectivityLength(medConnectivity ConnectivityType,
243 medEntityMesh Entity,
244 medGeometryElement Type) const
247 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
249 const int l = CONNECTIVITY::getConnectivityLength (ConnectivityType, Entity, Type);
254 //=============================================================================
257 //=============================================================================
258 const int * CONNECTIVITYClient::getConnectivityIndex (medConnectivity ConnectivityType,
259 medEntityMesh Entity) const
262 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
264 const int *c = CONNECTIVITY::getConnectivityIndex
265 (ConnectivityType, Entity);
270 //=============================================================================
273 //=============================================================================
274 void CONNECTIVITYClient::calculateConnectivity (medConnectivity connectivityType,
275 medEntityMesh Entity)
280 CONNECTIVITY::calculateConnectivity(connectivityType, Entity);
283 //=============================================================================
286 //=============================================================================
287 void CONNECTIVITYClient::updateFamily (vector<FAMILY*> myFamilies)
292 CONNECTIVITY::updateFamily(myFamilies);
295 //=============================================================================
298 //=============================================================================
299 const int * CONNECTIVITYClient::getGlobalNumberingIndex (medEntityMesh Entity) const
303 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
305 const int * index = CONNECTIVITY::getGlobalNumberingIndex(Entity);
310 //=============================================================================
313 //=============================================================================
314 bool CONNECTIVITYClient::existConnectivity(medConnectivity ConnectivityType,
315 medEntityMesh Entity) const
318 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
320 bool b = CONNECTIVITY::existConnectivity(ConnectivityType, Entity);
325 //=============================================================================
328 //=============================================================================
329 const int * CONNECTIVITYClient::getReverseConnectivity (medConnectivity ConnectivityType,
330 medEntityMesh Entity) const
334 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
336 const int *c = CONNECTIVITY::getReverseConnectivity
337 (ConnectivityType, Entity);
342 //=============================================================================
345 //=============================================================================
346 const int * CONNECTIVITYClient::getReverseConnectivityIndex (medConnectivity ConnectivityType,
347 medEntityMesh Entity) const
351 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
353 const int *c = CONNECTIVITY::getReverseConnectivityIndex
354 (ConnectivityType, Entity);
359 //=============================================================================
362 //=============================================================================
363 const int* CONNECTIVITYClient::getValue(medConnectivity TypeConnectivity,
364 medGeometryElement Type) const
367 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
369 const int * c = CONNECTIVITY::getValue(TypeConnectivity, Type);
374 //=============================================================================
377 //=============================================================================
378 const int* CONNECTIVITYClient::getValueIndex(medConnectivity TypeConnectivity) const
381 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
383 const int * c = CONNECTIVITY::getValueIndex(TypeConnectivity);
388 //=============================================================================
391 //=============================================================================
392 const int* CONNECTIVITYClient::getNeighbourhood() const
395 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
397 const int * c = CONNECTIVITY::getNeighbourhood();