1 // Copyright (C) 2007-2022 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, or (at your option) any later version.
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 // SMESH DriverMED : driver to read and write 'med' files
24 // File : DriverMED_R_SMESHDS_Mesh.cxx
27 #include "DriverMED_R_SMESHDS_Mesh.h"
29 #include "DriverMED_Family.h"
30 #include "SMESHDS_Group.hxx"
31 #include "SMESHDS_Mesh.hxx"
32 #include "SMESH_Comment.hxx"
34 #include "MED_CoordUtils.hxx"
35 #include "MED_Factory.hxx"
36 #include "MED_Utilities.hxx"
38 #include <NCollection_Map.hxx>
39 #include <smIdType.hxx>
41 #include "utilities.h"
45 #define _EDF_NODE_IDS_
50 typedef std::map<int, DriverMED_FamilyPtr> TID2FamilyMap;
54 bool buildMeshGrille(const MED::PWrapper& theWrapper,
55 const MED::PMeshInfo& theMeshInfo,
56 SMESHDS_Mesh* theMesh,
57 const TID2FamilyMap& myFamilies);
59 * \brief Ensure aFamily has a required ID
60 * \param aFamily - a family to check
61 * \param anID - an ID aFamily should have
62 * \param myFamilies - a map of the family ID to the Family
63 * \retval bool - true if successful
65 bool checkFamilyID(DriverMED_FamilyPtr & aFamily,
67 const TID2FamilyMap& myFamilies);
70 const SMDS_MeshNode* FindNode(const SMDS_Mesh* theMesh, TInt theId)
72 const SMDS_MeshNode* aNode = theMesh->FindNode(theId);
73 if(aNode) return aNode;
74 EXCEPTION(runtime_error,"SMDS_Mesh::FindNode - cannot find a SMDS_MeshNode for ID = "<<theId);
79 //================================================================================
81 * \brief Stores a mesh name
83 //================================================================================
85 void DriverMED_R_SMESHDS_Mesh::SetMeshName(string theMeshName)
87 myMeshName = theMeshName;
90 //================================================================================
92 * \brief Reads a med file
94 //================================================================================
96 Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
98 using namespace DriverMED;
100 Status aResult = DRS_FAIL;
101 bool isDescConn = false; // Mantis issue 0020483
106 MESSAGE("Perform - myFile : "<<myFile);
107 PWrapper aMed = CrWrapperR(myFile);
110 TInt aNbMeshes = aMed->GetNbMeshes();
111 for (int iMesh = 0; iMesh < aNbMeshes; iMesh++)
113 // Reading the MED mesh
114 //---------------------
115 PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh+1);
118 if (myMeshId != -1) aMeshName = SMESH_Comment( myMeshId );
119 else aMeshName = myMeshName;
121 MESSAGE("Perform - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
122 if ( aMeshName != aMeshInfo->GetName() ) continue;
125 // Reading MED families to the temporary structure
126 //------------------------------------------------
128 TInt aNbFams = aMed->GetNbFamilies(aMeshInfo);
129 MESSAGE("Read " << aNbFams << " families");
130 for (TInt iFam = 0; iFam < aNbFams; iFam++)
132 PFamilyInfo aFamilyInfo = aMed->GetPFamilyInfo(aMeshInfo,iFam+1,&anErr);
134 TInt aFamId = aFamilyInfo->GetId();
135 MESSAGE("Family " << aFamId << " :");
137 DriverMED_FamilyPtr aFamily (new DriverMED_Family);
139 TInt aNbGrp = aFamilyInfo->GetNbGroup();
140 MESSAGE("belong to " << aNbGrp << " groups");
141 bool isAttrOk = false;
142 if(aFamilyInfo->GetNbAttr() == aNbGrp)
144 for (TInt iGr = 0; iGr < aNbGrp; iGr++)
146 string aGroupName = aFamilyInfo->GetGroupName(iGr);
148 TInt anAttrVal = aFamilyInfo->GetAttrVal(iGr);
149 aFamily->SetGroupAttributVal(anAttrVal);
152 if ( strncmp( aGroupName.c_str(), NIG_GROUP_PREFIX, strlen(NIG_GROUP_PREFIX) ) != 0 )
153 aFamily->AddGroupName( fixUTF8( aGroupName ));
155 aFamily->SetId( aFamId );
156 myFamilies[aFamId] = aFamily;
160 if (aMeshInfo->GetType() == MED::eSTRUCTURE)
162 /*bool aRes = */DriverMED::buildMeshGrille(aMed,aMeshInfo,myMesh,myFamilies);
166 // Reading MED nodes to the corresponding SMDS structure
167 //------------------------------------------------------
168 PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
170 aResult = addMessage("No nodes", /*isFatal=*/true );
173 aMeshInfo->myDim=aMeshInfo->mySpaceDim;// ignore meshdim in MEDFile because it can be false
174 PCoordHelper aCoordHelper = GetCoordHelper(aNodeInfo);
176 EBooleen anIsNodeNum = aNodeInfo->IsElemNum();
177 TInt aNbElems = aNodeInfo->GetNbElem();
178 MESSAGE("Perform - aNodeInfo->GetNbElem() = "<<aNbElems<<"; anIsNodeNum = "<<anIsNodeNum);
179 DriverMED_FamilyPtr aFamily;
180 for ( TInt iElem = 0; iElem < aNbElems; iElem++ )
182 TCCoordSlice aCoordSlice = aNodeInfo->GetCoordSlice(iElem);
183 double aCoords[3] = {0.0, 0.0, 0.0};
184 for(TInt iDim = 0; iDim < 3; iDim++)
185 aCoords[iDim] = aCoordHelper->GetCoord(aCoordSlice,iDim);
186 const SMDS_MeshNode* aNode;
188 aNode = myMesh->AddNodeWithID
189 (aCoords[0],aCoords[1],aCoords[2],aNodeInfo->GetElemNum(iElem));
192 aNode = myMesh->AddNodeWithID
193 (aCoords[0],aCoords[1],aCoords[2], iElem+1);
196 // Save reference to this node from its family
197 TInt aFamNum = aNodeInfo->GetFamNum(iElem);
198 if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies ))
200 aFamily->AddElement(aNode);
201 aFamily->SetType(SMDSAbs_Node);
205 // Are there any MED cells in descending connectivity
206 // Mantis issue 0020483
207 //---------------------------------------------------
208 NCollection_Map<EEntiteMaillage> aDescendingEntitiesMap;
210 MED::TEntityInfo aEntityInfoDesc = aMed->GetEntityInfo(aMeshInfo, eDESC);
211 MED::TEntityInfo::iterator anEntityIterDesc = aEntityInfoDesc.begin();
212 //for (; anEntityIterDesc != aEntityInfoDesc.end() && !isDescConn; anEntityIterDesc++) {
213 for (; anEntityIterDesc != aEntityInfoDesc.end(); anEntityIterDesc++) {
214 const EEntiteMaillage& anEntity = anEntityIterDesc->first;
215 aDescendingEntitiesMap.Add(anEntity);
216 //if (anEntity != eNOEUD) isDescConn = true;
220 // Reading pre information about all MED cells
221 //--------------------------------------------
222 typedef MED::TVector<smIdType> TNodeIds;
223 bool takeNumbers = true; // initially we trust the numbers from file
224 MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo, eNOD);
225 MED::TEntityInfo::iterator anEntityIter = aEntityInfo.begin();
227 for (; anEntityIter != aEntityInfo.end(); anEntityIter++)
229 const EEntiteMaillage& anEntity = anEntityIter->first;
230 aDescendingEntitiesMap.Remove(anEntity); // Mantis issue 0020483
231 if (anEntity == eNOEUD) continue;
233 // Reading MED cells to the corresponding SMDS structure
234 //------------------------------------------------------
235 const MED::TGeom2Size& aGeom2Size = anEntityIter->second;
236 MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
237 for ( ; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++)
239 const EGeometrieElement& aGeom = aGeom2SizeIter->first;
241 if ( anEntity == eSTRUCT_ELEMENT ) // MED_BALL (issue 0021459)
243 PBallInfo aBallInfo = aMed->GetPBallInfo(aMeshInfo);
244 TInt aNbBalls = aBallInfo->GetNbElem();
246 EBooleen anIsElemNum = takeNumbers ? aBallInfo->IsElemNum() : eFAUX;
247 if ( anIsElemNum && aBallInfo->myElemNum->empty() )
250 // get supporting nodes
252 #ifdef _EDF_NODE_IDS_
254 aNodeIds.resize( aNbBalls );
255 for(TInt iBall = 0; iBall < aNbBalls && anIsNodeNum; iBall++)
257 aNodeIds[iBall] = aNodeInfo->GetElemNum( (*aBallInfo->myConn)[ iBall ]-1 );
258 anIsNodeNum = myMesh->FindNode( aNodeIds[iBall] ) ? eVRAI : eFAUX;
263 aNodeIds.assign( aBallInfo->myConn->begin(), aBallInfo->myConn->end());
265 // allocate array of diameters
266 vtkIdType maxID = FromSmIdType<vtkIdType>(myMesh->MaxElementID() + aNbBalls);
267 if ( anIsElemNum && !aBallInfo->myElemNum->empty() )
268 maxID = *std::max_element( aBallInfo->myElemNum->begin(),
269 aBallInfo->myElemNum->end() );
270 myMesh->GetGrid()->AllocateDiameters( maxID ); // performance optimization
273 SMDS_MeshElement* anElement;
274 DriverMED_FamilyPtr aFamily;
275 for ( TInt iBall = 0; iBall < aNbBalls; iBall++)
279 if (!(anElement = myMesh->AddBallWithID( aNodeIds[iBall],
280 aBallInfo->myDiameters[iBall],
281 aBallInfo->GetElemNum(iBall))))
285 myMesh->AddBall( myMesh->FindNode( aNodeIds[iBall]),
286 aBallInfo->myDiameters[iBall] );
288 // Save reference to this element from its family
289 TInt aFamNum = aBallInfo->GetFamNum(iBall);
290 if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies ))
292 aFamily->AddElement(anElement);
293 aFamily->SetType( SMDSAbs_Ball );
298 ( takeNumbers && aBallInfo->IsElemNum() && !aBallInfo->myElemNum->empty() ))
299 if ( aResult < DRS_WARN_RENUMBER )
300 aResult = DRS_WARN_RENUMBER;
306 // case ePOINT1: ## PAL16410
311 PPolygoneInfo aPolygoneInfo = aMed->GetPPolygoneInfo(aMeshInfo,anEntity,aGeom);
312 EBooleen anIsElemNum = takeNumbers ? aPolygoneInfo->IsElemNum() : eFAUX;
314 typedef SMDS_MeshFace* (SMESHDS_Mesh::* FAddPolyWithID)
315 (const std::vector<smIdType> & nodes_ids, const smIdType ID);
316 typedef SMDS_MeshFace* (SMESHDS_Mesh::* FAddPolygon)
317 (const std::vector<const SMDS_MeshNode*> & nodes);
319 FAddPolyWithID addPolyWithID = & SMESHDS_Mesh::AddPolygonalFaceWithID;
320 FAddPolygon addPolygon = & SMESHDS_Mesh::AddPolygonalFace;
321 if ( aGeom == ePOLYGON2 ) {
322 addPolyWithID = & SMESHDS_Mesh::AddQuadPolygonalFaceWithID;
323 addPolygon = & SMESHDS_Mesh::AddQuadPolygonalFace;
326 vector<const SMDS_MeshNode*> aNodes;
327 const TInt aNbElem = aPolygoneInfo->GetNbElem();
328 for ( TInt iElem = 0; iElem < aNbElem; iElem++ )
330 MED::TCConnSlice aConnSlice = aPolygoneInfo->GetConnSlice(iElem);
331 TInt aNbConn = aPolygoneInfo->GetNbConn(iElem);
332 aNodeIds.resize( aNbConn );
333 #ifdef _EDF_NODE_IDS_
335 for(TInt iConn = 0; iConn < aNbConn; iConn++)
336 aNodeIds[iConn] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1);
338 for(TInt iConn = 0; iConn < aNbConn; iConn++)
339 aNodeIds[iConn] = aConnSlice[iConn];
341 for(TInt iConn = 0; iConn < aNbConn; iConn++)
342 aNodeIds[iConn] = aConnSlice[iConn];
344 bool isRenum = false;
345 SMDS_MeshElement* anElement = NULL;
346 TInt aFamNum = aPolygoneInfo->GetFamNum(iElem);
351 TInt anElemId = aPolygoneInfo->GetElemNum( iElem );
352 anElement = (myMesh->*addPolyWithID)( aNodeIds, ToSmIdType(anElemId) );
355 aNodes.resize( aNbConn );
356 for ( TInt iConn = 0; iConn < aNbConn; iConn++ )
357 aNodes[iConn] = FindNode( myMesh, aNodeIds[iConn] );
358 anElement = (myMesh->*addPolygon)( aNodes );
359 isRenum = anIsElemNum;
362 } catch(const std::exception& exc) {
363 aResult = addMessage( exc.what(), /*isFatal=*/true );
365 aResult = addMessage( "Unknown exception", /*isFatal=*/true );
369 aResult = DRS_WARN_SKIP_ELEM;
375 if(aResult < DRS_WARN_RENUMBER)
376 aResult = DRS_WARN_RENUMBER;
378 if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies ))
380 // Save reference to this element from its family
381 aFamily->AddElement(anElement);
382 aFamily->SetType(anElement->GetType());
389 PPolyedreInfo aPolyedreInfo = aMed->GetPPolyedreInfo(aMeshInfo,anEntity,aGeom);
390 EBooleen anIsElemNum = takeNumbers ? aPolyedreInfo->IsElemNum() : eFAUX;
392 TInt aNbElem = aPolyedreInfo->GetNbElem();
393 for(TInt iElem = 0; iElem < aNbElem; iElem++){
394 MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(iElem);
395 TInt aNbFaces = aConnSliceArr.size();
396 typedef MED::TVector<int> TQuantities;
397 TQuantities aQuantities(aNbFaces);
398 TInt aNbNodes = aPolyedreInfo->GetNbNodes(iElem);
399 TNodeIds aNodeIds(aNbNodes);
400 for(TInt iFace = 0, iNode = 0; iFace < aNbFaces; iFace++){
401 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
402 TInt aNbConn = aConnSlice.size();
403 aQuantities[iFace] = aNbConn;
404 #ifdef _EDF_NODE_IDS_
406 for(TInt iConn = 0; iConn < aNbConn; iConn++)
408 aNodeIds[iNode] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1);
412 for(TInt iConn = 0; iConn < aNbConn; iConn++)
414 aNodeIds[iNode++] = aConnSlice[iConn];
417 for(TInt iConn = 0; iConn < aNbConn; iConn++)
419 aNodeIds[iNode++] = aConnSlice[iConn];
424 bool isRenum = false;
425 SMDS_MeshElement* anElement = NULL;
426 TInt aFamNum = aPolyedreInfo->GetFamNum(iElem);
432 TInt anElemId = aPolyedreInfo->GetElemNum(iElem);
433 anElement = myMesh->AddPolyhedralVolumeWithID(aNodeIds,aQuantities,ToSmIdType(anElemId));
436 vector<const SMDS_MeshNode*> aNodes(aNbNodes);
437 for(TInt iConn = 0; iConn < aNbNodes; iConn++)
438 aNodes[iConn] = FindNode(myMesh,aNodeIds[iConn]);
439 anElement = myMesh->AddPolyhedralVolume(aNodes,aQuantities);
440 isRenum = anIsElemNum;
443 }catch(const std::exception& exc){
450 aResult = DRS_WARN_SKIP_ELEM;
455 if (aResult < DRS_WARN_RENUMBER)
456 aResult = DRS_WARN_RENUMBER;
458 if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies )) {
459 // Save reference to this element from its family
460 aFamily->AddElement(anElement);
461 aFamily->SetType(anElement->GetType());
468 PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom);
469 EBooleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : eFAUX;
470 TInt aNbElems = aCellInfo->GetNbElem();
471 MESSAGE("Perform - anEntity = "<<anEntity<<"; anIsElemNum = "<<anIsElemNum);
472 MESSAGE("Perform - aGeom = "<<aGeom<<"; aNbElems = "<<aNbElems);
476 case eSEG2: aNbNodes = 2; break;
477 case eSEG3: aNbNodes = 3; break;
478 case eTRIA3: aNbNodes = 3; break;
479 case eTRIA6: aNbNodes = 6; break;
480 case eTRIA7: aNbNodes = 7; break;
481 case eQUAD4: aNbNodes = 4; break;
482 case eQUAD8: aNbNodes = 8; break;
483 case eQUAD9: aNbNodes = 9; break;
484 case eTETRA4: aNbNodes = 4; break;
485 case eTETRA10: aNbNodes = 10; break;
486 case ePYRA5: aNbNodes = 5; break;
487 case ePYRA13: aNbNodes = 13; break;
488 case ePENTA6: aNbNodes = 6; break;
489 case ePENTA15: aNbNodes = 15; break;
490 case ePENTA18: aNbNodes = 18; break;
491 case eHEXA8: aNbNodes = 8; break;
492 case eHEXA20: aNbNodes = 20; break;
493 case eHEXA27: aNbNodes = 27; break;
494 case eOCTA12: aNbNodes = 12; break;
495 case ePOINT1: aNbNodes = 1; break;
498 vector<TInt> aNodeIds(aNbNodes);
499 for ( TInt iElem = 0; iElem < aNbElems; iElem++ )
501 bool anIsValidConnect = false;
502 TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem);
506 #ifdef _EDF_NODE_IDS_
508 for(int iNode = 0; iNode < aNbNodes; iNode++)
509 aNodeIds[iNode] = aNodeInfo->GetElemNum(aConnSlice[iNode] - 1);
511 for(int iNode = 0; iNode < aNbNodes; iNode++)
512 aNodeIds[iNode] = aConnSlice[iNode];
514 for(int iNode = 0; iNode < aNbNodes; iNode++)
515 aNodeIds[iNode] = aConnSlice[iNode];
517 anIsValidConnect = true;
519 }catch(const std::exception& exc){
520 INFOS("Following exception was caught:\n\t"<<exc.what());
521 aResult = addMessage( exc.what(), /*isFatal=*/true );
523 INFOS("Unknown exception was caught !!!");
524 aResult = addMessage( "Unknown exception", /*isFatal=*/true );
527 if(!anIsValidConnect)
530 bool isRenum = false;
531 const SMDS_MeshElement* anElement = NULL;
532 TInt aFamNum = aCellInfo->GetFamNum(iElem);
536 //MESSAGE("Try to create element # " << iElem << " with id = "
537 // << aCellInfo->GetElemNum(iElem));
540 //anElement = FindNode(myMesh,aNodeIds[0]);
542 anElement = myMesh->Add0DElementWithID
543 (aNodeIds[0], aCellInfo->GetElemNum(iElem));
545 anElement = myMesh->Add0DElement(FindNode(myMesh,aNodeIds[0]));
546 isRenum = anIsElemNum;
551 anElement = myMesh->AddEdgeWithID(aNodeIds[0],
553 aCellInfo->GetElemNum(iElem));
555 anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds[0]),
556 FindNode(myMesh,aNodeIds[1]));
557 isRenum = anIsElemNum;
562 anElement = myMesh->AddEdgeWithID(aNodeIds[0],
565 aCellInfo->GetElemNum(iElem));
567 anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds[0]),
568 FindNode(myMesh,aNodeIds[1]),
569 FindNode(myMesh,aNodeIds[2]));
570 isRenum = anIsElemNum;
576 anElement = myMesh->AddFaceWithID(aNodeIds[0],
579 aCellInfo->GetElemNum(iElem));
581 anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
582 FindNode(myMesh,aNodeIds[1]),
583 FindNode(myMesh,aNodeIds[2]));
584 isRenum = anIsElemNum;
590 anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
591 aNodeIds[2], aNodeIds[3],
592 aNodeIds[4], aNodeIds[5],
593 aCellInfo->GetElemNum(iElem));
595 anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
596 FindNode(myMesh,aNodeIds[1]),
597 FindNode(myMesh,aNodeIds[2]),
598 FindNode(myMesh,aNodeIds[3]),
599 FindNode(myMesh,aNodeIds[4]),
600 FindNode(myMesh,aNodeIds[5]));
601 isRenum = anIsElemNum;
607 anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
608 aNodeIds[2], aNodeIds[3],
609 aNodeIds[4], aNodeIds[5], aNodeIds[6],
610 aCellInfo->GetElemNum(iElem));
612 anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
613 FindNode(myMesh,aNodeIds[1]),
614 FindNode(myMesh,aNodeIds[2]),
615 FindNode(myMesh,aNodeIds[3]),
616 FindNode(myMesh,aNodeIds[4]),
617 FindNode(myMesh,aNodeIds[5]),
618 FindNode(myMesh,aNodeIds[6]));
619 isRenum = anIsElemNum;
625 anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
626 aNodeIds[2], aNodeIds[3],
627 aCellInfo->GetElemNum(iElem));
629 anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
630 FindNode(myMesh,aNodeIds[1]),
631 FindNode(myMesh,aNodeIds[2]),
632 FindNode(myMesh,aNodeIds[3]));
633 isRenum = anIsElemNum;
639 anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
640 aNodeIds[2], aNodeIds[3],
641 aNodeIds[4], aNodeIds[5],
642 aNodeIds[6], aNodeIds[7],
643 aCellInfo->GetElemNum(iElem));
645 anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
646 FindNode(myMesh,aNodeIds[1]),
647 FindNode(myMesh,aNodeIds[2]),
648 FindNode(myMesh,aNodeIds[3]),
649 FindNode(myMesh,aNodeIds[4]),
650 FindNode(myMesh,aNodeIds[5]),
651 FindNode(myMesh,aNodeIds[6]),
652 FindNode(myMesh,aNodeIds[7]));
653 isRenum = anIsElemNum;
659 anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
660 aNodeIds[2], aNodeIds[3],
661 aNodeIds[4], aNodeIds[5],
662 aNodeIds[6], aNodeIds[7], aNodeIds[8],
663 aCellInfo->GetElemNum(iElem));
665 anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
666 FindNode(myMesh,aNodeIds[1]),
667 FindNode(myMesh,aNodeIds[2]),
668 FindNode(myMesh,aNodeIds[3]),
669 FindNode(myMesh,aNodeIds[4]),
670 FindNode(myMesh,aNodeIds[5]),
671 FindNode(myMesh,aNodeIds[6]),
672 FindNode(myMesh,aNodeIds[7]),
673 FindNode(myMesh,aNodeIds[8]));
674 isRenum = anIsElemNum;
680 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
681 aNodeIds[2], aNodeIds[3],
682 aCellInfo->GetElemNum(iElem));
684 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
685 FindNode(myMesh,aNodeIds[1]),
686 FindNode(myMesh,aNodeIds[2]),
687 FindNode(myMesh,aNodeIds[3]));
688 isRenum = anIsElemNum;
694 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
695 aNodeIds[2], aNodeIds[3],
696 aNodeIds[4], aNodeIds[5],
697 aNodeIds[6], aNodeIds[7],
698 aNodeIds[8], aNodeIds[9],
699 aCellInfo->GetElemNum(iElem));
701 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
702 FindNode(myMesh,aNodeIds[1]),
703 FindNode(myMesh,aNodeIds[2]),
704 FindNode(myMesh,aNodeIds[3]),
705 FindNode(myMesh,aNodeIds[4]),
706 FindNode(myMesh,aNodeIds[5]),
707 FindNode(myMesh,aNodeIds[6]),
708 FindNode(myMesh,aNodeIds[7]),
709 FindNode(myMesh,aNodeIds[8]),
710 FindNode(myMesh,aNodeIds[9]));
711 isRenum = anIsElemNum;
717 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
718 aNodeIds[2], aNodeIds[3],
720 aCellInfo->GetElemNum(iElem));
722 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
723 FindNode(myMesh,aNodeIds[1]),
724 FindNode(myMesh,aNodeIds[2]),
725 FindNode(myMesh,aNodeIds[3]),
726 FindNode(myMesh,aNodeIds[4]));
727 isRenum = anIsElemNum;
733 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
734 aNodeIds[2], aNodeIds[3],
735 aNodeIds[4], aNodeIds[5],
736 aNodeIds[6], aNodeIds[7],
737 aNodeIds[8], aNodeIds[9],
738 aNodeIds[10], aNodeIds[11],
740 aCellInfo->GetElemNum(iElem));
742 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
743 FindNode(myMesh,aNodeIds[1]),
744 FindNode(myMesh,aNodeIds[2]),
745 FindNode(myMesh,aNodeIds[3]),
746 FindNode(myMesh,aNodeIds[4]),
747 FindNode(myMesh,aNodeIds[5]),
748 FindNode(myMesh,aNodeIds[6]),
749 FindNode(myMesh,aNodeIds[7]),
750 FindNode(myMesh,aNodeIds[8]),
751 FindNode(myMesh,aNodeIds[9]),
752 FindNode(myMesh,aNodeIds[10]),
753 FindNode(myMesh,aNodeIds[11]),
754 FindNode(myMesh,aNodeIds[12]));
755 isRenum = anIsElemNum;
761 anElement = myMesh->AddVolumeWithID(aNodeIds[0],
767 aCellInfo->GetElemNum(iElem));
769 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
770 FindNode(myMesh,aNodeIds[1]),
771 FindNode(myMesh,aNodeIds[2]),
772 FindNode(myMesh,aNodeIds[3]),
773 FindNode(myMesh,aNodeIds[4]),
774 FindNode(myMesh,aNodeIds[5]));
775 isRenum = anIsElemNum;
781 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
782 aNodeIds[2], aNodeIds[3],
783 aNodeIds[4], aNodeIds[5],
784 aNodeIds[6], aNodeIds[7],
785 aNodeIds[8], aNodeIds[9],
786 aNodeIds[10], aNodeIds[11],
787 aNodeIds[12], aNodeIds[13],
789 aCellInfo->GetElemNum(iElem));
791 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
792 FindNode(myMesh,aNodeIds[1]),
793 FindNode(myMesh,aNodeIds[2]),
794 FindNode(myMesh,aNodeIds[3]),
795 FindNode(myMesh,aNodeIds[4]),
796 FindNode(myMesh,aNodeIds[5]),
797 FindNode(myMesh,aNodeIds[6]),
798 FindNode(myMesh,aNodeIds[7]),
799 FindNode(myMesh,aNodeIds[8]),
800 FindNode(myMesh,aNodeIds[9]),
801 FindNode(myMesh,aNodeIds[10]),
802 FindNode(myMesh,aNodeIds[11]),
803 FindNode(myMesh,aNodeIds[12]),
804 FindNode(myMesh,aNodeIds[13]),
805 FindNode(myMesh,aNodeIds[14]));
806 isRenum = anIsElemNum;
812 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
813 aNodeIds[2], aNodeIds[3],
814 aNodeIds[4], aNodeIds[5],
815 aNodeIds[6], aNodeIds[7],
816 aNodeIds[8], aNodeIds[9],
817 aNodeIds[10], aNodeIds[11],
818 aNodeIds[12], aNodeIds[13],
819 aNodeIds[14], aNodeIds[15],
820 aNodeIds[16], aNodeIds[17],
821 aCellInfo->GetElemNum(iElem));
823 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
824 FindNode(myMesh,aNodeIds[1]),
825 FindNode(myMesh,aNodeIds[2]),
826 FindNode(myMesh,aNodeIds[3]),
827 FindNode(myMesh,aNodeIds[4]),
828 FindNode(myMesh,aNodeIds[5]),
829 FindNode(myMesh,aNodeIds[6]),
830 FindNode(myMesh,aNodeIds[7]),
831 FindNode(myMesh,aNodeIds[8]),
832 FindNode(myMesh,aNodeIds[9]),
833 FindNode(myMesh,aNodeIds[10]),
834 FindNode(myMesh,aNodeIds[11]),
835 FindNode(myMesh,aNodeIds[12]),
836 FindNode(myMesh,aNodeIds[13]),
837 FindNode(myMesh,aNodeIds[14]),
838 FindNode(myMesh,aNodeIds[15]),
839 FindNode(myMesh,aNodeIds[16]),
840 FindNode(myMesh,aNodeIds[17]));
841 isRenum = anIsElemNum;
847 anElement = myMesh->AddVolumeWithID(aNodeIds[0],
855 aCellInfo->GetElemNum(iElem));
857 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
858 FindNode(myMesh,aNodeIds[1]),
859 FindNode(myMesh,aNodeIds[2]),
860 FindNode(myMesh,aNodeIds[3]),
861 FindNode(myMesh,aNodeIds[4]),
862 FindNode(myMesh,aNodeIds[5]),
863 FindNode(myMesh,aNodeIds[6]),
864 FindNode(myMesh,aNodeIds[7]));
865 isRenum = anIsElemNum;
872 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
873 aNodeIds[2], aNodeIds[3],
874 aNodeIds[4], aNodeIds[5],
875 aNodeIds[6], aNodeIds[7],
876 aNodeIds[8], aNodeIds[9],
877 aNodeIds[10], aNodeIds[11],
878 aNodeIds[12], aNodeIds[13],
879 aNodeIds[14], aNodeIds[15],
880 aNodeIds[16], aNodeIds[17],
881 aNodeIds[18], aNodeIds[19],
882 aCellInfo->GetElemNum(iElem));
884 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
885 FindNode(myMesh,aNodeIds[1]),
886 FindNode(myMesh,aNodeIds[2]),
887 FindNode(myMesh,aNodeIds[3]),
888 FindNode(myMesh,aNodeIds[4]),
889 FindNode(myMesh,aNodeIds[5]),
890 FindNode(myMesh,aNodeIds[6]),
891 FindNode(myMesh,aNodeIds[7]),
892 FindNode(myMesh,aNodeIds[8]),
893 FindNode(myMesh,aNodeIds[9]),
894 FindNode(myMesh,aNodeIds[10]),
895 FindNode(myMesh,aNodeIds[11]),
896 FindNode(myMesh,aNodeIds[12]),
897 FindNode(myMesh,aNodeIds[13]),
898 FindNode(myMesh,aNodeIds[14]),
899 FindNode(myMesh,aNodeIds[15]),
900 FindNode(myMesh,aNodeIds[16]),
901 FindNode(myMesh,aNodeIds[17]),
902 FindNode(myMesh,aNodeIds[18]),
903 FindNode(myMesh,aNodeIds[19]));
904 isRenum = anIsElemNum;
911 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
912 aNodeIds[2], aNodeIds[3],
913 aNodeIds[4], aNodeIds[5],
914 aNodeIds[6], aNodeIds[7],
915 aNodeIds[8], aNodeIds[9],
916 aNodeIds[10], aNodeIds[11],
917 aNodeIds[12], aNodeIds[13],
918 aNodeIds[14], aNodeIds[15],
919 aNodeIds[16], aNodeIds[17],
920 aNodeIds[18], aNodeIds[19],
921 aNodeIds[20], aNodeIds[21],
922 aNodeIds[22], aNodeIds[23],
923 aNodeIds[24], aNodeIds[25],
925 aCellInfo->GetElemNum(iElem));
927 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
928 FindNode(myMesh,aNodeIds[1]),
929 FindNode(myMesh,aNodeIds[2]),
930 FindNode(myMesh,aNodeIds[3]),
931 FindNode(myMesh,aNodeIds[4]),
932 FindNode(myMesh,aNodeIds[5]),
933 FindNode(myMesh,aNodeIds[6]),
934 FindNode(myMesh,aNodeIds[7]),
935 FindNode(myMesh,aNodeIds[8]),
936 FindNode(myMesh,aNodeIds[9]),
937 FindNode(myMesh,aNodeIds[10]),
938 FindNode(myMesh,aNodeIds[11]),
939 FindNode(myMesh,aNodeIds[12]),
940 FindNode(myMesh,aNodeIds[13]),
941 FindNode(myMesh,aNodeIds[14]),
942 FindNode(myMesh,aNodeIds[15]),
943 FindNode(myMesh,aNodeIds[16]),
944 FindNode(myMesh,aNodeIds[17]),
945 FindNode(myMesh,aNodeIds[18]),
946 FindNode(myMesh,aNodeIds[19]),
947 FindNode(myMesh,aNodeIds[20]),
948 FindNode(myMesh,aNodeIds[21]),
949 FindNode(myMesh,aNodeIds[22]),
950 FindNode(myMesh,aNodeIds[23]),
951 FindNode(myMesh,aNodeIds[24]),
952 FindNode(myMesh,aNodeIds[25]),
953 FindNode(myMesh,aNodeIds[26]));
954 isRenum = anIsElemNum;
961 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
962 aNodeIds[2], aNodeIds[3],
963 aNodeIds[4], aNodeIds[5],
964 aNodeIds[6], aNodeIds[7],
965 aNodeIds[8], aNodeIds[9],
966 aNodeIds[10], aNodeIds[11],
967 aCellInfo->GetElemNum(iElem));
969 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
970 FindNode(myMesh,aNodeIds[1]),
971 FindNode(myMesh,aNodeIds[2]),
972 FindNode(myMesh,aNodeIds[3]),
973 FindNode(myMesh,aNodeIds[4]),
974 FindNode(myMesh,aNodeIds[5]),
975 FindNode(myMesh,aNodeIds[6]),
976 FindNode(myMesh,aNodeIds[7]),
977 FindNode(myMesh,aNodeIds[8]),
978 FindNode(myMesh,aNodeIds[9]),
979 FindNode(myMesh,aNodeIds[10]),
980 FindNode(myMesh,aNodeIds[11]));
981 isRenum = anIsElemNum;
990 } catch(const std::exception& exc) {
991 INFOS("The following exception was caught:\n\t"<<exc.what());
992 aResult = addMessage( exc.what(), /*isFatal=*/true );
994 INFOS("Unknown exception was caught !!!");
995 aResult = addMessage( "Unknown exception", /*isFatal=*/true );
999 aResult = DRS_WARN_SKIP_ELEM;
1003 anIsElemNum = eFAUX;
1004 takeNumbers = false;
1005 if (aResult < DRS_WARN_RENUMBER)
1006 aResult = DRS_WARN_RENUMBER;
1008 if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies )) {
1009 // Save reference to this element from its family
1010 aFamily->AddElement(anElement);
1011 aFamily->SetType(anElement->GetType());
1014 } // loop on aNbElems
1016 } // loop on aGeom2Size
1017 } // loop on aEntityInfo
1019 if (aDescendingEntitiesMap.Extent()) isDescConn = true; // Mantis issue 0020483
1021 } // for(int iMesh = 0; iMesh < aNbMeshes; iMesh++)
1024 catch(const std::exception& exc)
1026 INFOS("The following exception was caught:\n\t"<<exc.what());
1027 aResult = addMessage( exc.what(), /*isFatal=*/true );
1031 INFOS("Unknown exception was caught !!!");
1032 aResult = addMessage( "Unknown exception", /*isFatal=*/true );
1036 // Mantis issue 0020483
1037 if (aResult == DRS_OK && isDescConn) {
1038 INFOS("There are some elements in descending connectivity in med file. They were not read !!!");
1039 aResult = DRS_WARN_DESCENDING;
1042 MESSAGE("Perform - aResult status = "<<aResult);
1046 list<string> DriverMED_R_SMESHDS_Mesh::GetMeshNames(Status& theStatus)
1048 list<string> aMeshNames;
1051 MESSAGE("GetMeshNames - myFile : " << myFile);
1053 PWrapper aMed = CrWrapperR(myFile);
1055 if (TInt aNbMeshes = aMed->GetNbMeshes()) {
1056 for (int iMesh = 0; iMesh < aNbMeshes; iMesh++) {
1057 // Reading the MED mesh
1058 //---------------------
1059 PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh+1);
1060 aMeshNames.push_back(aMeshInfo->GetName());
1063 } catch(const std::exception& exc) {
1064 INFOS("Following exception was caught:\n\t"<<exc.what());
1065 theStatus = DRS_FAIL;
1067 INFOS("Unknown exception was caught !!!");
1068 theStatus = DRS_FAIL;
1074 list<TNameAndType> DriverMED_R_SMESHDS_Mesh::GetGroupNamesAndTypes()
1076 list<TNameAndType> aResult;
1077 set<TNameAndType> aResGroupNames;
1079 map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
1080 for (; aFamsIter != myFamilies.end(); aFamsIter++)
1082 DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
1083 const MED::TStringSet& aGroupNames = aFamily->GetGroupNames();
1084 set<string>::const_iterator aGrNamesIter = aGroupNames.begin();
1085 for (; aGrNamesIter != aGroupNames.end(); aGrNamesIter++)
1087 const ElemTypeSet& types = aFamily->GetTypes();
1088 ElemTypeSet::const_iterator type = types.begin();
1089 for ( ; type != types.end(); ++type )
1091 TNameAndType aNameAndType = make_pair( *aGrNamesIter, *type );
1092 if ( aResGroupNames.insert( aNameAndType ).second ) {
1093 aResult.push_back( aNameAndType );
1102 void DriverMED_R_SMESHDS_Mesh::GetGroup(SMESHDS_Group* theGroup)
1104 TFamilyVec * famVecPtr;
1106 if ( myGroups2FamiliesMap.IsEmpty() ) // PAL23514
1108 TFamilyVec famVector( 1 );
1109 map<int, DriverMED_FamilyPtr>::iterator famIter = myFamilies.begin();
1110 for ( ; famIter != myFamilies.end(); famIter++ )
1112 DriverMED_FamilyPtr family = famIter->second;
1113 const MED::TStringSet& groups = family->GetGroupNames();
1114 famVector[ 0 ] = family;
1115 MED::TStringSet::const_iterator grpIter = groups.begin();
1116 for ( ; grpIter != groups.end(); ++grpIter )
1118 TCollection_AsciiString groupName = grpIter->c_str();
1119 if (( famVecPtr = myGroups2FamiliesMap.ChangeSeek( groupName )))
1120 famVecPtr->push_back( family );
1122 myGroups2FamiliesMap.Bind( groupName, famVector );
1127 const char* aGroupName = theGroup->GetStoreName();
1128 MESSAGE("Get Group " << aGroupName);
1130 if (( famVecPtr = myGroups2FamiliesMap.ChangeSeek( aGroupName )))
1132 size_t groupSize = 0;
1133 for ( size_t i = 0; i < famVecPtr->size(); ++i )
1135 DriverMED_FamilyPtr aFamily = (*famVecPtr)[i];
1136 groupSize += aFamily->NbElements( theGroup->GetType() );
1138 theGroup->SMDSGroup().Reserve( groupSize );
1140 for ( size_t i = 0; i < famVecPtr->size(); ++i )
1142 DriverMED_FamilyPtr aFamily = (*famVecPtr)[i];
1143 if ( aFamily->GetTypes().count( theGroup->GetType() ))
1145 const ElementsSet& anElements = aFamily->GetElements();
1146 ElementsSet::const_iterator anElemsIter = anElements.begin();
1147 for (; anElemsIter != anElements.end(); anElemsIter++)
1149 const SMDS_MeshElement * element = *anElemsIter;
1150 if ( element->GetType() == theGroup->GetType() ) // Issue 0020576
1151 theGroup->SMDSGroup().Add(element);
1153 int aGroupAttrVal = aFamily->GetGroupAttributVal();
1154 if( aGroupAttrVal != 0 )
1155 theGroup->SetColorGroup(aGroupAttrVal);
1161 void DriverMED_R_SMESHDS_Mesh::GetSubMesh (SMESHDS_SubMesh* theSubMesh,
1164 char submeshGrpName[ 30 ];
1165 sprintf( submeshGrpName, "SubMesh %d", theId );
1166 string aName (submeshGrpName);
1167 map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
1168 for (; aFamsIter != myFamilies.end(); aFamsIter++)
1170 DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
1171 if (aFamily->MemberOf(aName))
1173 const ElementsSet& anElements = aFamily->GetElements();
1174 ElementsSet::const_iterator anElemsIter = anElements.begin();
1175 if (aFamily->GetType() == SMDSAbs_Node)
1177 for (; anElemsIter != anElements.end(); anElemsIter++)
1179 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>(*anElemsIter);
1180 theSubMesh->AddNode(node);
1185 for (; anElemsIter != anElements.end(); anElemsIter++)
1187 theSubMesh->AddElement(*anElemsIter);
1194 void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes ()
1196 map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
1197 for (; aFamsIter != myFamilies.end(); aFamsIter++)
1199 DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
1200 MED::TStringSet aGroupNames = aFamily->GetGroupNames();
1201 set<string>::iterator aGrNamesIter = aGroupNames.begin();
1202 for (; aGrNamesIter != aGroupNames.end(); aGrNamesIter++)
1204 string aName = *aGrNamesIter;
1205 // Check, if this is a Group or SubMesh name
1206 if (aName.substr(0, 7) == string("SubMesh"))
1208 int Id = atoi(string(aName).substr(7).c_str());
1209 const ElementsSet& anElements = aFamily->GetElements();
1210 ElementsSet::const_iterator anElemsIter = anElements.begin();
1211 if (aFamily->GetType() == SMDSAbs_Node)
1213 for (; anElemsIter != anElements.end(); anElemsIter++)
1215 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( *anElemsIter );
1216 // find out a shape type
1217 TopoDS_Shape aShape = myMesh->IndexToShape( Id );
1218 int aShapeType = ( aShape.IsNull() ? -1 : aShape.ShapeType() );
1219 switch ( aShapeType ) {
1221 myMesh->SetNodeOnFace(node, Id); break;
1223 myMesh->SetNodeOnEdge(node, Id); break;
1225 myMesh->SetNodeOnVertex(node, Id); break;
1227 myMesh->SetNodeInVolume(node, Id);
1233 for (; anElemsIter != anElements.end(); anElemsIter++)
1235 myMesh->SetMeshElementOnShape(*anElemsIter, Id);
1243 * \brief Ensure aFamily to have required ID
1244 * \param aFamily - a family to check and update
1245 * \param anID - an ID aFamily should have
1246 * \retval bool - true if successful
1248 bool DriverMED::checkFamilyID(DriverMED_FamilyPtr & aFamily,
1250 const TID2FamilyMap& myFamilies)
1252 if ( !aFamily || aFamily->GetId() != anID ) {
1253 map<int, DriverMED_FamilyPtr>::const_iterator i_fam = myFamilies.find(anID);
1254 if ( i_fam == myFamilies.end() )
1256 aFamily = i_fam->second;
1258 return ( aFamily->GetId() == anID );
1262 * \brief Reading the structured mesh and convert to non structured
1263 * (by filling of smesh structure for non structured mesh)
1264 * \param theWrapper - PWrapper const pointer
1265 * \param theMeshInfo - PMeshInfo const pointer
1266 * \param myFamilies - a map of the family ID to the Family
1267 * \return TRUE, if successfully. Else FALSE
1269 bool DriverMED::buildMeshGrille(const MED::PWrapper& theWrapper,
1270 const MED::PMeshInfo& theMeshInfo,
1271 SMESHDS_Mesh* myMesh,
1272 const TID2FamilyMap& myFamilies)
1276 MED::PGrilleInfo aGrilleInfo = theWrapper->GetPGrilleInfo(theMeshInfo);
1277 MED::TInt aNbNodes = aGrilleInfo->GetNbNodes();
1278 MED::TInt aNbCells = aGrilleInfo->GetNbCells();
1279 MED::TInt aMeshDim = theMeshInfo->GetDim();
1280 DriverMED_FamilyPtr aFamily;
1281 for(MED::TInt iNode=0;iNode < aNbNodes; iNode++){
1282 double aCoords[3] = {0.0, 0.0, 0.0};
1283 const SMDS_MeshNode* aNode;
1284 MED::TNodeCoord aMEDNodeCoord = aGrilleInfo->GetCoord(iNode);
1285 for(MED::TInt iDim=0;iDim<aMeshDim;iDim++)
1286 aCoords[(int)iDim] = aMEDNodeCoord[(int)iDim];
1287 aNode = myMesh->AddNodeWithID(aCoords[0],aCoords[1],aCoords[2],iNode+1);
1289 EXCEPTION(runtime_error,"buildMeshGrille Error. Node not created! "<<(int)iNode);
1292 if((aGrilleInfo->myFamNumNode).size() > 0){
1293 TInt aFamNum = aGrilleInfo->GetFamNumNode(iNode);
1294 if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies ))
1296 aFamily->AddElement(aNode);
1297 aFamily->SetType(SMDSAbs_Node);
1303 SMDS_MeshElement* anElement = NULL;
1304 MED::TIntVector aNodeIds;
1305 for(MED::TInt iCell=0;iCell < aNbCells; iCell++){
1306 aNodeIds = aGrilleInfo->GetConn(iCell);
1307 switch(aGrilleInfo->GetGeom()){
1309 if(aNodeIds.size() != 2){
1311 EXCEPTION(runtime_error,"buildMeshGrille Error. Incorrect size of ids 2!="<<aNodeIds.size());
1313 anElement = myMesh->AddEdgeWithID(aNodeIds[0]+1,
1318 if(aNodeIds.size() != 4){
1320 EXCEPTION(runtime_error,"buildMeshGrille Error. Incorrect size of ids 4!="<<aNodeIds.size());
1322 anElement = myMesh->AddFaceWithID(aNodeIds[0]+1,
1329 if(aNodeIds.size() != 8){
1331 EXCEPTION(runtime_error,"buildMeshGrille Error. Incorrect size of ids 8!="<<aNodeIds.size());
1333 anElement = myMesh->AddVolumeWithID(aNodeIds[0]+1,
1347 EXCEPTION(runtime_error,"buildMeshGrille Error. Element not created! "<<iCell);
1349 if((aGrilleInfo->myFamNum).size() > 0){
1350 TInt aFamNum = aGrilleInfo->GetFamNum(iCell);
1351 if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies )){
1352 aFamily->AddElement(anElement);
1353 aFamily->SetType(anElement->GetType());