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;
118 // create a constituent (PAL10556)
119 if ( Entity == MED_CELL ) {
120 Entity = ( IOR_Mesh->getMeshDimension() == 3 ? MED_FACE : MED_EDGE );
121 _constituent = new CONNECTIVITYClient( IOR_Mesh, Entity );
126 END_OF("CONNECTIVITYClient::blankCopy()");
129 //=============================================================================
132 //=============================================================================
133 // template< class T>
134 // void dumpArray(const T* array, int size, const char* msg)
137 // std::cout << msg << " " << std::endl;
138 // std::cout << "Size: " << size << std::endl;
139 // for ( int i = 0; i < size; i++ )
140 // std::cout << " " << array[ i ];
141 // std::cout << endl;
144 void CONNECTIVITYClient::fillCopy()
146 BEGIN_OF("void CONNECTIVITYClient::fillCopy()");
154 medEntityMesh Entity = getEntity();
155 int iT, nT = getNumberOfTypes(Entity);
157 const medGeometryElement * T = getGeometricTypes(Entity);
159 int * Count = new int[nT+1] ;
162 for (iT=0; iT<nT; iT++) {
163 Count[iT+1]=Count[iT] + _numberOfElements_client[iT];
166 setCount(Count, Entity) ;
168 for (iT=0; iT<nT; iT++) {
171 int kT = Count[iT+1]-Count[iT];
174 SALOME::SenderInt_var senderForConnectivity=IOR_Mesh->getSenderForConnectivity(MED_FULL_INTERLACE, MED_NODAL, Entity, T[iT]);
175 pC=ReceiverFactory::getValue(senderForConnectivity,nC);
177 ASSERT(nC == (T[iT]%100) * kT);
179 setNodal(pC, Entity, T[iT]);
183 if ( _polyType_client == MED_POLYGON )
185 const medConnectivity ConType = MED_NODAL;
186 SALOME::SenderInt_var senderForConnectivity=IOR_Mesh->getSenderForPolygonsConnectivity (ConType, Entity);
187 SALOME::SenderInt_var senderForConnectivityIndex=IOR_Mesh->getSenderForPolygonsConnectivityIndex (ConType, Entity);
189 pC=ReceiverFactory::getValue(senderForConnectivity,nC);
191 int * pCI=ReceiverFactory::getValue(senderForConnectivityIndex,nP);
192 // dumpArray( pC, nC, "POLYGON Connectivity: ");
193 // dumpArray( pCI, nP, "POLYGON ConnectivityIndex: ");
195 setPolygonsConnectivity(ConType, Entity, pC, pCI, nC, nP-1);
200 if ( _polyType_client == MED_POLYHEDRA )
202 const medConnectivity ConType = MED_NODAL;
203 SALOME::SenderInt_var senderForConnectivity=IOR_Mesh->getSenderForPolyhedronConnectivity (ConType);
204 SALOME::SenderInt_var senderForPolyhedronIndex=IOR_Mesh->getSenderForPolyhedronIndex (ConType);
205 SALOME::SenderInt_var senderForPolyhedronFacesIndex=IOR_Mesh->getSenderForPolyhedronFacesIndex ();
207 pC=ReceiverFactory::getValue(senderForConnectivity,nC);
209 int * pPI=ReceiverFactory::getValue(senderForPolyhedronIndex,nP);
210 int * pFI=ReceiverFactory::getValue(senderForPolyhedronFacesIndex,nF);
212 // dumpArray( pC, nC, "POLYHedron Connectivity: ");
213 // dumpArray( pFI, nF, "POLYHedron Face Index: ");
214 // dumpArray( pPI, nP, "POLYHedron Index: ");
216 setPolyhedronConnectivity(ConType, pC, pPI, nC, nP-1, pFI, nF-1);
227 END_OF("void CONNECTIVITYClient::fillCopy()");
230 //=============================================================================
233 //=============================================================================
234 int CONNECTIVITYClient::getNumberOf(medEntityMesh Entity,
235 medGeometryElement Type) const
237 BEGIN_OF("void CONNECTIVITYClient::getNumberOf()");
246 if (Entity == _entity) {
248 if (Type==MED_ALL_ELEMENTS)
249 n = _totalNumberOfElements_client;
251 for (int i=0; i<_numberOfTypes; i++) {
252 SCRUTE(_geometricTypes[i]);
253 if (_geometricTypes[i] == Type) {
254 n = _numberOfElements_client[i];
259 else if (_constituent != NULL)
260 n = _constituent->getNumberOf(Entity,Type);
264 n = CONNECTIVITY::getNumberOf(Entity, Type);
267 END_OF("void CONNECTIVITYClient::getNumberOf()");
271 //=============================================================================
274 //=============================================================================
275 const int * CONNECTIVITYClient::getConnectivity
276 (medConnectivity ConnectivityType,
277 medEntityMesh Entity,
278 medGeometryElement Type)
280 BEGIN_OF("void CONNECTIVITYClient::getConnectivity()");
285 const int * c = CONNECTIVITY::getConnectivity
286 (ConnectivityType, Entity, Type);
288 END_OF("void CONNECTIVITYClient::getConnectivity()");
292 //=============================================================================
295 //=============================================================================
296 const int * CONNECTIVITYClient::getConnectivityIndex
297 (medConnectivity ConnectivityType,
298 medEntityMesh Entity)
300 BEGIN_OF("void CONNECTIVITYClient::getConnectivityIndex()");
305 const int *c = CONNECTIVITY::getConnectivityIndex
306 (ConnectivityType, Entity);
308 END_OF("void CONNECTIVITYClient::getConnectivityIndex()");
312 //=============================================================================
315 //=============================================================================
316 void CONNECTIVITYClient::calculateConnectivity
317 (medConnectivity connectivityType,
318 medEntityMesh Entity)
320 BEGIN_OF("void CONNECTIVITYClient::calculateConnectivity()");
325 CONNECTIVITY::calculateConnectivity(connectivityType, Entity);
327 END_OF("void CONNECTIVITYClient::calculateConnectivity()");
330 //=============================================================================
333 //=============================================================================
334 void CONNECTIVITYClient::updateFamily (vector<FAMILY*> myFamilies)
336 BEGIN_OF("void CONNECTIVITYClient::updateFamily()");
341 CONNECTIVITY::updateFamily(myFamilies);
343 END_OF("void CONNECTIVITYClient::updateFamily()");
346 //=============================================================================
349 //=============================================================================
350 const int * CONNECTIVITYClient::getGlobalNumberingIndex
351 (medEntityMesh Entity) const throw (MEDEXCEPTION)
353 BEGIN_OF("void CONNECTIVITYClient::getGlobalNumberingIndex()");
356 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
358 const int * index = CONNECTIVITY::getGlobalNumberingIndex(Entity);
360 END_OF("void CONNECTIVITYClient::getGlobalNumberingIndex()");
365 //=============================================================================
368 //=============================================================================
369 bool CONNECTIVITYClient::existConnectivity(medConnectivity ConnectivityType,
370 medEntityMesh Entity) const
372 BEGIN_OF("void CONNECTIVITYClient::existConnectivity()");
375 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
377 bool b = CONNECTIVITY::existConnectivity(ConnectivityType, Entity);
379 END_OF("void CONNECTIVITYClient::existConnectivity()");
384 //=============================================================================
387 //=============================================================================
388 const int * CONNECTIVITYClient::getReverseConnectivity
389 (medConnectivity ConnectivityType,
390 medEntityMesh Entity) throw (MEDEXCEPTION)
392 BEGIN_OF("void CONNECTIVITYClient::getReverseConnectivity()");
397 const int *c = CONNECTIVITY::getReverseConnectivity
398 (ConnectivityType, Entity);
400 END_OF("void CONNECTIVITYClient::getReverseConnectivity()");
405 //=============================================================================
408 //=============================================================================
409 const int * CONNECTIVITYClient::getReverseConnectivityIndex
410 (medConnectivity ConnectivityType,
411 medEntityMesh Entity) throw (MEDEXCEPTION)
413 BEGIN_OF("void CONNECTIVITYClient::getReverseConnectivityIndex()");
418 const int *c = CONNECTIVITY::getReverseConnectivityIndex
419 (ConnectivityType, Entity);
421 END_OF("void CONNECTIVITYClient::getReverseConnectivityIndex()");
426 //=============================================================================
429 //=============================================================================
430 const int* CONNECTIVITYClient::getValue(medConnectivity TypeConnectivity,
431 medGeometryElement Type)
433 BEGIN_OF("void CONNECTIVITYClient::getValue()");
438 const int * c = CONNECTIVITY::getValue(TypeConnectivity, Type);
440 END_OF("void CONNECTIVITYClient::()");
445 //=============================================================================
448 //=============================================================================
449 const int* CONNECTIVITYClient::getValueIndex(medConnectivity TypeConnectivity)
451 BEGIN_OF("void CONNECTIVITYClient::getValueIndex()");
456 const int * c = CONNECTIVITY::getValueIndex(TypeConnectivity);
458 END_OF("void CONNECTIVITYClient::getValueIndex()");
463 //=============================================================================
466 //=============================================================================
467 const int* CONNECTIVITYClient::getNeighbourhood() const
469 BEGIN_OF("void CONNECTIVITYClient::getNeighbourhood()");
472 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
474 const int * c = CONNECTIVITY::getNeighbourhood();
476 END_OF("void CONNECTIVITYClient::getNeighbourhood()");
481 //=======================================================================
482 //function : existPolygonsConnectivity
484 //=======================================================================
486 bool CONNECTIVITYClient::existPolygonsConnectivity(medConnectivity connectivityType,
487 medEntityMesh Entity) const
489 BEGIN_OF("void CONNECTIVITYClient::existPolygonsConnectivity()");
492 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
494 bool b = CONNECTIVITY::existPolygonsConnectivity( connectivityType, Entity );
496 END_OF("void CONNECTIVITYClient::existPolygonsConnectivity(connectivityType, Entity)");
501 //=======================================================================
502 //function : existPolyhedronConnectivity
504 //=======================================================================
506 bool CONNECTIVITYClient::existPolyhedronConnectivity(medConnectivity connectivityType,
507 medEntityMesh Entity) const
509 BEGIN_OF("void CONNECTIVITYClient::existPolyhedronConnectivity()");
512 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
514 bool b = CONNECTIVITY::existPolyhedronConnectivity( connectivityType, Entity );
516 END_OF("void CONNECTIVITYClient::existPolyhedronConnectivity(connectivityType, Entity)");
521 //=======================================================================
522 //function : getPolygonsConnectivity
524 //=======================================================================
526 const int* CONNECTIVITYClient::getPolygonsConnectivity(medConnectivity ConnectivityType,
527 medEntityMesh Entity)
529 BEGIN_OF("void CONNECTIVITYClient::getPolygonsConnectivity()");
534 const int * c = CONNECTIVITY::getPolygonsConnectivity (ConnectivityType, Entity);
536 END_OF("void CONNECTIVITYClient::getPolygonsConnectivity()");
540 //=======================================================================
541 //function : getPolygonsConnectivityIndex
543 //=======================================================================
545 const int* CONNECTIVITYClient::getPolygonsConnectivityIndex(medConnectivity ConnectivityType,
546 medEntityMesh Entity)
548 BEGIN_OF("void CONNECTIVITYClient::getPolygonsConnectivityIndex()");
553 const int * c = CONNECTIVITY::getPolygonsConnectivityIndex (ConnectivityType, Entity);
555 END_OF("void CONNECTIVITYClient::getPolygonsConnectivityIndex()");
559 //=======================================================================
560 //function : getPolyhedronConnectivity
562 //=======================================================================
564 const int* CONNECTIVITYClient::getPolyhedronConnectivity(medConnectivity ConnectivityType) const
566 BEGIN_OF("void CONNECTIVITYClient::getPolyhedronConnectivity()");
569 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
571 const int * c = CONNECTIVITY::getPolyhedronConnectivity (ConnectivityType);
573 END_OF("void CONNECTIVITYClient::getPolyhedronConnectivity()");
577 //=======================================================================
578 //function : getPolyhedronFacesIndex
580 //=======================================================================
582 const int* CONNECTIVITYClient::getPolyhedronFacesIndex() const
584 BEGIN_OF("void CONNECTIVITYClient::getPolyhedronFacesIndex()");
587 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
589 const int * c = CONNECTIVITY::getPolyhedronFacesIndex();
591 END_OF("void CONNECTIVITYClient::getPolyhedronFacesIndex()");
595 //=======================================================================
596 //function : getPolyhedronIndex
598 //=======================================================================
600 const int* CONNECTIVITYClient::getPolyhedronIndex(medConnectivity ConnectivityType) const
602 BEGIN_OF("void CONNECTIVITYClient::getPolyhedronIndex()");
605 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
607 const int * c = CONNECTIVITY::getPolyhedronIndex (ConnectivityType);
609 END_OF("void CONNECTIVITYClient::getPolyhedronIndex()");
613 //=======================================================================
614 //function : getNumberOfPolygons
616 //=======================================================================
618 int CONNECTIVITYClient::getNumberOfPolygons() const
620 BEGIN_OF("void CONNECTIVITYClient::getNumberOfPolygons()");
625 if ( _polyType_client == MED_POLYGON )
626 n = _numberOfElements_client[ getNumberOfTypes( _entity )];
629 n = CONNECTIVITY::getNumberOfPolygons();
633 END_OF("void CONNECTIVITYClient::getNumberOfPolygons()");
637 //=======================================================================
638 //function : getNumberOfPolyhedronFaces
640 //=======================================================================
642 int CONNECTIVITYClient::getNumberOfPolyhedronFaces() const
644 BEGIN_OF("void CONNECTIVITYClient::getNumberOfPolyhedronFaces()");
647 (const_cast<CONNECTIVITYClient *>(this))->fillCopy();
649 int n = CONNECTIVITY::getNumberOfPolyhedronFaces ();
653 END_OF("void CONNECTIVITYClient::getNumberOfPolyhedronFaces()");
657 //=======================================================================
658 //function : getNumberOfPolyhedron
660 //=======================================================================
662 int CONNECTIVITYClient::getNumberOfPolyhedron() const
664 BEGIN_OF("void CONNECTIVITYClient::getNumberOfPolyhedron()");
669 if ( _polyType_client == MED_POLYHEDRA )
670 n = _numberOfElements_client[ getNumberOfTypes( _entity )];
673 n = CONNECTIVITY::getNumberOfPolyhedron();
677 END_OF("void CONNECTIVITYClient::getNumberOfPolyhedron()");