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/
20 #include "MEDMEM_convert.hxx"
21 #include "Utils_CorbaException.hxx"
22 #include "UtilClient.hxx"
23 #include "CONNECTIVITYClient.hxx"
25 #include "ReceiverFactory.hxx"
26 using namespace MEDMEM;
27 //=============================================================================
31 //=============================================================================
33 CONNECTIVITYClient::CONNECTIVITYClient(const SALOME_MED::MESH_ptr m,
34 medEntityMesh Entity) :
35 CONNECTIVITY(m->getNumberOfTypes(Entity), Entity),
36 IOR_Mesh(SALOME_MED::MESH::_duplicate(m)),
37 _numberOfElements_client(0),
40 BEGIN_OF("CONNECTIVITYClient::CONNECTIVITYClient()");
46 END_OF("CONNECTIVITYClient::CONNECTIVITYClient()");
49 //=============================================================================
53 //=============================================================================
54 CONNECTIVITYClient::~CONNECTIVITYClient()
56 BEGIN_OF("CONNECTIVITYClient::~CONNECTIVITYClient()");
58 if (_numberOfElements_client)
59 delete [] _numberOfElements_client;
61 END_OF("CONNECTIVITYClient::~CONNECTIVITYClient()");
64 //=============================================================================
66 * Remplit les informations nécessaires
69 //=============================================================================
70 void CONNECTIVITYClient::blankCopy()
72 BEGIN_OF("CONNECTIVITYClient::blankCopy()");
73 SALOME_MED::MESH::connectivityInfos_var all;
74 medEntityMesh Entity = getEntity();
77 all= IOR_Mesh->getConnectGlobal(Entity);
79 catch (const exception & ex)
81 MESSAGE("Unable to acces Global information");
82 THROW_SALOME_CORBA_EXCEPTION(ex.what() ,SALOME::INTERNAL_ERROR);
85 _numberOfNodes = all->numberOfNodes;
86 _entityDimension = all->entityDimension;
87 medGeometryElement * Types;
89 long iT, nTwithPoly, nT=getNumberOfTypes(Entity);
90 convertCorbaArray<MED_EN::medGeometryElement,SALOME_MED::medGeometryElement_array *, long>
91 (Types, nTwithPoly, &all->meshTypes);
93 //ASSERT(nT == (int) getNumberOfTypes(Entity)); FALSE with POLY
96 setGeometricTypes(Types, Entity);
98 _totalNumberOfElements_client = 0L;
99 _numberOfElements_client = new long[nTwithPoly];
100 for (iT=0; iT<nT; iT++)
102 _numberOfElements_client[iT] = all->numberOfElements[iT];
103 _totalNumberOfElements_client += _numberOfElements_client[iT];
105 SCRUTE(_numberOfElements_client[iT]);
108 if ( nT != nTwithPoly )
110 _numberOfElements_client[iT] = all->numberOfElements[iT];
111 _polyType_client = Types[iT];
115 _polyType_client = MED_EN::MED_NONE;
120 END_OF("CONNECTIVITYClient::blankCopy()");
123 //=============================================================================
126 //=============================================================================
127 // template< class T>
128 // void dumpArray(const T* array, int size, const char* msg)
131 // std::cout << msg << " " << std::endl;
132 // std::cout << "Size: " << size << std::endl;
133 // for ( int i = 0; i < size; i++ )
134 // std::cout << " " << array[ i ];
135 // std::cout << endl;
138 void CONNECTIVITYClient::fillCopy()
140 BEGIN_OF("void CONNECTIVITYClient::fillCopy()");
148 medEntityMesh Entity = getEntity();
149 int iT, nT = getNumberOfTypes(Entity);
151 const medGeometryElement * T = getGeometricTypes(Entity);
153 int * Count = new int[nT+1] ;
156 for (iT=0; iT<nT; iT++) {
157 Count[iT+1]=Count[iT] + _numberOfElements_client[iT];
160 setCount(Count, Entity) ;
162 for (iT=0; iT<nT; iT++) {
165 int kT = Count[iT+1]-Count[iT];
168 SALOME::SenderInt_var senderForConnectivity=IOR_Mesh->getSenderForConnectivity(MED_FULL_INTERLACE, MED_NODAL, Entity, T[iT]);
169 pC=ReceiverFactory::getValue(senderForConnectivity,nC);
171 ASSERT(nC == (T[iT]%100) * kT);
173 setNodal(pC, Entity, T[iT]);
177 if ( _polyType_client == MED_POLYGON )
179 const medConnectivity ConType = MED_NODAL;
180 SALOME::SenderInt_var senderForConnectivity=IOR_Mesh->getSenderForPolygonsConnectivity (ConType, Entity);
181 SALOME::SenderInt_var senderForConnectivityIndex=IOR_Mesh->getSenderForPolygonsConnectivityIndex (ConType, Entity);
183 pC=ReceiverFactory::getValue(senderForConnectivity,nC);
185 int * pCI=ReceiverFactory::getValue(senderForConnectivityIndex,nP);
186 // dumpArray( pC, nC, "POLYGON Connectivity: ");
187 // dumpArray( pCI, nP, "POLYGON ConnectivityIndex: ");
189 setPolygonsConnectivity(ConType, Entity, pC, pCI, nC, nP-1);
194 if ( _polyType_client == MED_POLYHEDRA )
196 const medConnectivity ConType = MED_NODAL;
197 SALOME::SenderInt_var senderForConnectivity=IOR_Mesh->getSenderForPolyhedronConnectivity (ConType);
198 SALOME::SenderInt_var senderForPolyhedronIndex=IOR_Mesh->getSenderForPolyhedronIndex (ConType);
199 SALOME::SenderInt_var senderForPolyhedronFacesIndex=IOR_Mesh->getSenderForPolyhedronFacesIndex ();
201 pC=ReceiverFactory::getValue(senderForConnectivity,nC);
203 int * pPI=ReceiverFactory::getValue(senderForPolyhedronIndex,nP);
204 int * pFI=ReceiverFactory::getValue(senderForPolyhedronFacesIndex,nF);
206 // dumpArray( pC, nC, "POLYHedron Connectivity: ");
207 // dumpArray( pFI, nF, "POLYHedron Face Index: ");
208 // dumpArray( pPI, nP, "POLYHedron Index: ");
210 setPolyhedronConnectivity(ConType, pC, pPI, nC, nP-1, pFI, nF-1);
221 END_OF("void CONNECTIVITYClient::fillCopy()");
224 //=============================================================================
227 //=============================================================================
228 int CONNECTIVITYClient::getNumberOf(medEntityMesh Entity,
229 medGeometryElement Type) const
231 BEGIN_OF("void CONNECTIVITYClient::getNumberOf()");
240 if (Entity == _entity) {
242 if (Type==MED_ALL_ELEMENTS)
243 n = _totalNumberOfElements_client;
245 for (int i=0; i<_numberOfTypes; i++) {
246 SCRUTE(_geometricTypes[i]);
247 if (_geometricTypes[i] == Type) {
248 n = _numberOfElements_client[i];
253 else if (_constituent != NULL)
254 n = _constituent->getNumberOf(Entity,Type);
258 n = CONNECTIVITY::getNumberOf(Entity, Type);
261 END_OF("void CONNECTIVITYClient::getNumberOf()");
265 //=============================================================================
268 //=============================================================================
269 const int * CONNECTIVITYClient::getConnectivity
270 (medConnectivity ConnectivityType,
271 medEntityMesh Entity,
272 medGeometryElement Type)
274 BEGIN_OF("void CONNECTIVITYClient::getConnectivity()");
279 const int * c = CONNECTIVITY::getConnectivity
280 (ConnectivityType, Entity, Type);
282 END_OF("void CONNECTIVITYClient::getConnectivity()");
286 //=============================================================================
289 //=============================================================================
290 const int * CONNECTIVITYClient::getConnectivityIndex
291 (medConnectivity ConnectivityType,
292 medEntityMesh Entity)
294 BEGIN_OF("void CONNECTIVITYClient::getConnectivityIndex()");
299 const int *c = CONNECTIVITY::getConnectivityIndex
300 (ConnectivityType, Entity);
302 END_OF("void CONNECTIVITYClient::getConnectivityIndex()");
306 //=============================================================================
309 //=============================================================================
310 void CONNECTIVITYClient::calculateConnectivity
311 (medConnectivity connectivityType,
312 medEntityMesh Entity)
314 BEGIN_OF("void CONNECTIVITYClient::calculateConnectivity()");
319 CONNECTIVITY::calculateConnectivity(connectivityType, Entity);
321 END_OF("void CONNECTIVITYClient::calculateConnectivity()");
324 //=============================================================================
327 //=============================================================================
328 void CONNECTIVITYClient::updateFamily (vector<FAMILY*> myFamilies)
330 BEGIN_OF("void CONNECTIVITYClient::updateFamily()");
335 CONNECTIVITY::updateFamily(myFamilies);
337 END_OF("void CONNECTIVITYClient::updateFamily()");
340 //=============================================================================
343 //=============================================================================
344 const int * CONNECTIVITYClient::getGlobalNumberingIndex
345 (medEntityMesh Entity) const throw (MEDEXCEPTION)
347 BEGIN_OF("void CONNECTIVITYClient::getGlobalNumberingIndex()");
350 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
352 const int * c = CONNECTIVITY::getGlobalNumberingIndex(Entity);
354 END_OF("void CONNECTIVITYClient::getGlobalNumberingIndex()");
359 //=============================================================================
362 //=============================================================================
363 bool CONNECTIVITYClient::existConnectivity(medConnectivity ConnectivityType,
364 medEntityMesh Entity) const
366 BEGIN_OF("void CONNECTIVITYClient::existConnectivity()");
369 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
371 bool b = CONNECTIVITY::existConnectivity(ConnectivityType, Entity);
373 END_OF("void CONNECTIVITYClient::existConnectivity()");
378 //=============================================================================
381 //=============================================================================
382 const int * CONNECTIVITYClient::getReverseConnectivity
383 (medConnectivity ConnectivityType,
384 medEntityMesh Entity) throw (MEDEXCEPTION)
386 BEGIN_OF("void CONNECTIVITYClient::getReverseConnectivity()");
391 const int *c = CONNECTIVITY::getReverseConnectivity
392 (ConnectivityType, Entity);
394 END_OF("void CONNECTIVITYClient::getReverseConnectivity()");
399 //=============================================================================
402 //=============================================================================
403 const int * CONNECTIVITYClient::getReverseConnectivityIndex
404 (medConnectivity ConnectivityType,
405 medEntityMesh Entity) throw (MEDEXCEPTION)
407 BEGIN_OF("void CONNECTIVITYClient::getReverseConnectivityIndex()");
412 const int *c = CONNECTIVITY::getReverseConnectivityIndex
413 (ConnectivityType, Entity);
415 END_OF("void CONNECTIVITYClient::getReverseConnectivityIndex()");
420 //=============================================================================
423 //=============================================================================
424 const int* CONNECTIVITYClient::getValue(medConnectivity TypeConnectivity,
425 medGeometryElement Type)
427 BEGIN_OF("void CONNECTIVITYClient::getValue()");
432 const int * c = CONNECTIVITY::getValue(TypeConnectivity, Type);
434 END_OF("void CONNECTIVITYClient::()");
439 //=============================================================================
442 //=============================================================================
443 const int* CONNECTIVITYClient::getValueIndex(medConnectivity TypeConnectivity)
445 BEGIN_OF("void CONNECTIVITYClient::getValueIndex()");
450 const int * c = CONNECTIVITY::getValueIndex(TypeConnectivity);
452 END_OF("void CONNECTIVITYClient::getValueIndex()");
457 //=============================================================================
460 //=============================================================================
461 const int* CONNECTIVITYClient::getNeighbourhood() const
463 BEGIN_OF("void CONNECTIVITYClient::getNeighbourhood()");
466 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
468 const int * c = CONNECTIVITY::getNeighbourhood();
470 END_OF("void CONNECTIVITYClient::getNeighbourhood()");
475 //=======================================================================
476 //function : existPolygonsConnectivity
478 //=======================================================================
480 bool CONNECTIVITYClient::existPolygonsConnectivity(medConnectivity connectivityType,
481 medEntityMesh Entity) const
483 BEGIN_OF("void CONNECTIVITYClient::existPolygonsConnectivity()");
486 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
488 bool b = CONNECTIVITY::existPolygonsConnectivity( connectivityType, Entity );
490 END_OF("void CONNECTIVITYClient::existPolygonsConnectivity(connectivityType, Entity)");
495 //=======================================================================
496 //function : existPolyhedronConnectivity
498 //=======================================================================
500 bool CONNECTIVITYClient::existPolyhedronConnectivity(medConnectivity connectivityType,
501 medEntityMesh Entity) const
503 BEGIN_OF("void CONNECTIVITYClient::existPolyhedronConnectivity()");
506 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
508 bool b = CONNECTIVITY::existPolyhedronConnectivity( connectivityType, Entity );
510 END_OF("void CONNECTIVITYClient::existPolyhedronConnectivity(connectivityType, Entity)");
515 //=======================================================================
516 //function : getPolygonsConnectivity
518 //=======================================================================
520 const int* CONNECTIVITYClient::getPolygonsConnectivity(medConnectivity ConnectivityType,
521 medEntityMesh Entity)
523 BEGIN_OF("void CONNECTIVITYClient::getPolygonsConnectivity()");
528 const int * c = CONNECTIVITY::getPolygonsConnectivity (ConnectivityType, Entity);
530 END_OF("void CONNECTIVITYClient::getPolygonsConnectivity()");
534 //=======================================================================
535 //function : getPolygonsConnectivityIndex
537 //=======================================================================
539 const int* CONNECTIVITYClient::getPolygonsConnectivityIndex(medConnectivity ConnectivityType,
540 medEntityMesh Entity)
542 BEGIN_OF("void CONNECTIVITYClient::getPolygonsConnectivityIndex()");
547 const int * c = CONNECTIVITY::getPolygonsConnectivityIndex (ConnectivityType, Entity);
549 END_OF("void CONNECTIVITYClient::getPolygonsConnectivityIndex()");
553 //=======================================================================
554 //function : getPolyhedronConnectivity
556 //=======================================================================
558 const int* CONNECTIVITYClient::getPolyhedronConnectivity(medConnectivity ConnectivityType) const
560 BEGIN_OF("void CONNECTIVITYClient::getPolyhedronConnectivity()");
563 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
565 const int * c = CONNECTIVITY::getPolyhedronConnectivity (ConnectivityType);
567 END_OF("void CONNECTIVITYClient::getPolyhedronConnectivity()");
571 //=======================================================================
572 //function : getPolyhedronFacesIndex
574 //=======================================================================
576 const int* CONNECTIVITYClient::getPolyhedronFacesIndex() const
578 BEGIN_OF("void CONNECTIVITYClient::getPolyhedronFacesIndex()");
581 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
583 const int * c = CONNECTIVITY::getPolyhedronFacesIndex();
585 END_OF("void CONNECTIVITYClient::getPolyhedronFacesIndex()");
589 //=======================================================================
590 //function : getPolyhedronIndex
592 //=======================================================================
594 const int* CONNECTIVITYClient::getPolyhedronIndex(medConnectivity ConnectivityType) const
596 BEGIN_OF("void CONNECTIVITYClient::getPolyhedronIndex()");
599 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
601 const int * c = CONNECTIVITY::getPolyhedronIndex (ConnectivityType);
603 END_OF("void CONNECTIVITYClient::getPolyhedronIndex()");
607 //=======================================================================
608 //function : getNumberOfPolygons
610 //=======================================================================
612 int CONNECTIVITYClient::getNumberOfPolygons() const
614 BEGIN_OF("void CONNECTIVITYClient::getNumberOfPolygons()");
619 if ( _polyType_client == MED_POLYGON )
620 n = _numberOfElements_client[ getNumberOfTypes( _entity )];
623 n = CONNECTIVITY::getNumberOfPolygons();
627 END_OF("void CONNECTIVITYClient::getNumberOfPolygons()");
631 //=======================================================================
632 //function : getNumberOfPolyhedronFaces
634 //=======================================================================
636 int CONNECTIVITYClient::getNumberOfPolyhedronFaces() const
638 BEGIN_OF("void CONNECTIVITYClient::getNumberOfPolyhedronFaces()");
641 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
643 int n = CONNECTIVITY::getNumberOfPolyhedronFaces ();
647 END_OF("void CONNECTIVITYClient::getNumberOfPolyhedronFaces()");
651 //=======================================================================
652 //function : getNumberOfPolyhedron
654 //=======================================================================
656 int CONNECTIVITYClient::getNumberOfPolyhedron() const
658 BEGIN_OF("void CONNECTIVITYClient::getNumberOfPolyhedron()");
663 if ( _polyType_client == MED_POLYHEDRA )
664 n = _numberOfElements_client[ getNumberOfTypes( _entity )];
667 n = CONNECTIVITY::getNumberOfPolyhedron();
671 END_OF("void CONNECTIVITYClient::getNumberOfPolyhedron()");