1 // Copyright (C) 2007-2020 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>
40 #include "utilities.h"
45 static int MYDEBUG = 0;
48 static int MYDEBUG = 0;
51 #define _EDF_NODE_IDS_
56 typedef std::map<int, DriverMED_FamilyPtr> TID2FamilyMap;
60 bool buildMeshGrille(const MED::PWrapper& theWrapper,
61 const MED::PMeshInfo& theMeshInfo,
62 SMESHDS_Mesh* theMesh,
63 const TID2FamilyMap& myFamilies);
65 * \brief Ensure aFamily has a required ID
66 * \param aFamily - a family to check
67 * \param anID - an ID aFamily should have
68 * \param myFamilies - a map of the family ID to the Family
69 * \retval bool - true if successful
71 bool checkFamilyID(DriverMED_FamilyPtr & aFamily,
73 const TID2FamilyMap& myFamilies);
76 const SMDS_MeshNode* FindNode(const SMDS_Mesh* theMesh, TInt theId)
78 const SMDS_MeshNode* aNode = theMesh->FindNode(theId);
79 if(aNode) return aNode;
80 EXCEPTION(runtime_error,"SMDS_Mesh::FindNode - cannot find a SMDS_MeshNode for ID = "<<theId);
85 //================================================================================
87 * \brief Stores a mesh name
89 //================================================================================
91 void DriverMED_R_SMESHDS_Mesh::SetMeshName(string theMeshName)
93 myMeshName = theMeshName;
96 //================================================================================
98 * \brief Reads a med file
100 //================================================================================
102 Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
104 using namespace DriverMED;
106 Status aResult = DRS_FAIL;
107 bool isDescConn = false; // Mantis issue 0020483
112 if(MYDEBUG) MESSAGE("Perform - myFile : "<<myFile);
113 PWrapper aMed = CrWrapperR(myFile);
116 TInt aNbMeshes = aMed->GetNbMeshes();
117 for (int iMesh = 0; iMesh < aNbMeshes; iMesh++)
119 // Reading the MED mesh
120 //---------------------
121 PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh+1);
124 if (myMeshId != -1) aMeshName = SMESH_Comment( myMeshId );
125 else aMeshName = myMeshName;
127 if(MYDEBUG) MESSAGE("Perform - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
128 if ( aMeshName != aMeshInfo->GetName() ) continue;
131 // Reading MED families to the temporary structure
132 //------------------------------------------------
134 TInt aNbFams = aMed->GetNbFamilies(aMeshInfo);
135 if(MYDEBUG) MESSAGE("Read " << aNbFams << " families");
136 for (TInt iFam = 0; iFam < aNbFams; iFam++)
138 PFamilyInfo aFamilyInfo = aMed->GetPFamilyInfo(aMeshInfo,iFam+1,&anErr);
140 TInt aFamId = aFamilyInfo->GetId();
141 if(MYDEBUG) MESSAGE("Family " << aFamId << " :");
143 DriverMED_FamilyPtr aFamily (new DriverMED_Family);
145 TInt aNbGrp = aFamilyInfo->GetNbGroup();
146 if(MYDEBUG) MESSAGE("belong to " << aNbGrp << " groups");
147 bool isAttrOk = false;
148 if(aFamilyInfo->GetNbAttr() == aNbGrp)
150 for (TInt iGr = 0; iGr < aNbGrp; iGr++)
152 string aGroupName = aFamilyInfo->GetGroupName(iGr);
154 TInt anAttrVal = aFamilyInfo->GetAttrVal(iGr);
155 aFamily->SetGroupAttributVal(anAttrVal);
157 if(MYDEBUG) MESSAGE(aGroupName);
158 if ( strncmp( aGroupName.c_str(), NIG_GROUP_PREFIX, strlen(NIG_GROUP_PREFIX) ) != 0 )
159 aFamily->AddGroupName( fixUTF8( aGroupName ));
161 aFamily->SetId( aFamId );
162 myFamilies[aFamId] = aFamily;
166 if (aMeshInfo->GetType() == MED::eSTRUCTURE)
168 /*bool aRes = */DriverMED::buildMeshGrille(aMed,aMeshInfo,myMesh,myFamilies);
172 // Reading MED nodes to the corresponding SMDS structure
173 //------------------------------------------------------
174 PNodeInfo aNodeInfo = aMed->GetPNodeInfo(aMeshInfo);
176 aResult = addMessage("No nodes", /*isFatal=*/true );
179 aMeshInfo->myDim=aMeshInfo->mySpaceDim;// ignore meshdim in MEDFile because it can be false
180 PCoordHelper aCoordHelper = GetCoordHelper(aNodeInfo);
182 EBooleen anIsNodeNum = aNodeInfo->IsElemNum();
183 TInt aNbElems = aNodeInfo->GetNbElem();
184 if(MYDEBUG) MESSAGE("Perform - aNodeInfo->GetNbElem() = "<<aNbElems<<"; anIsNodeNum = "<<anIsNodeNum);
185 DriverMED_FamilyPtr aFamily;
186 for ( TInt iElem = 0; iElem < aNbElems; iElem++ )
188 TCCoordSlice aCoordSlice = aNodeInfo->GetCoordSlice(iElem);
189 double aCoords[3] = {0.0, 0.0, 0.0};
190 for(TInt iDim = 0; iDim < 3; iDim++)
191 aCoords[iDim] = aCoordHelper->GetCoord(aCoordSlice,iDim);
192 const SMDS_MeshNode* aNode;
194 aNode = myMesh->AddNodeWithID
195 (aCoords[0],aCoords[1],aCoords[2],aNodeInfo->GetElemNum(iElem));
198 aNode = myMesh->AddNodeWithID
199 (aCoords[0],aCoords[1],aCoords[2], iElem+1);
202 // Save reference to this node from its family
203 TInt aFamNum = aNodeInfo->GetFamNum(iElem);
204 if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies ))
206 aFamily->AddElement(aNode);
207 aFamily->SetType(SMDSAbs_Node);
211 // Are there any MED cells in descending connectivity
212 // Mantis issue 0020483
213 //---------------------------------------------------
214 NCollection_Map<EEntiteMaillage> aDescendingEntitiesMap;
216 MED::TEntityInfo aEntityInfoDesc = aMed->GetEntityInfo(aMeshInfo, eDESC);
217 MED::TEntityInfo::iterator anEntityIterDesc = aEntityInfoDesc.begin();
218 //for (; anEntityIterDesc != aEntityInfoDesc.end() && !isDescConn; anEntityIterDesc++) {
219 for (; anEntityIterDesc != aEntityInfoDesc.end(); anEntityIterDesc++) {
220 const EEntiteMaillage& anEntity = anEntityIterDesc->first;
221 aDescendingEntitiesMap.Add(anEntity);
222 //if (anEntity != eNOEUD) isDescConn = true;
226 // Reading pre information about all MED cells
227 //--------------------------------------------
228 typedef MED::TVector<int> TNodeIds;
229 bool takeNumbers = true; // initially we trust the numbers from file
230 MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo, eNOD);
231 MED::TEntityInfo::iterator anEntityIter = aEntityInfo.begin();
233 for (; anEntityIter != aEntityInfo.end(); anEntityIter++)
235 const EEntiteMaillage& anEntity = anEntityIter->first;
236 aDescendingEntitiesMap.Remove(anEntity); // Mantis issue 0020483
237 if (anEntity == eNOEUD) continue;
239 // Reading MED cells to the corresponding SMDS structure
240 //------------------------------------------------------
241 const MED::TGeom2Size& aGeom2Size = anEntityIter->second;
242 MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
243 for ( ; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++)
245 const EGeometrieElement& aGeom = aGeom2SizeIter->first;
247 if ( anEntity == eSTRUCT_ELEMENT ) // MED_BALL (issue 0021459)
249 PBallInfo aBallInfo = aMed->GetPBallInfo(aMeshInfo);
250 TInt aNbBalls = aBallInfo->GetNbElem();
252 EBooleen anIsElemNum = takeNumbers ? aBallInfo->IsElemNum() : eFAUX;
253 if ( anIsElemNum && aBallInfo->myElemNum->empty() )
256 // get supporting nodes
258 #ifdef _EDF_NODE_IDS_
260 aNodeIds.resize( aNbBalls );
261 for(TInt iBall = 0; iBall < aNbBalls && anIsNodeNum; iBall++)
263 aNodeIds[iBall] = aNodeInfo->GetElemNum( (*aBallInfo->myConn)[ iBall ]-1 );
264 anIsNodeNum = myMesh->FindNode( aNodeIds[iBall] ) ? eVRAI : eFAUX;
269 aNodeIds.assign( aBallInfo->myConn->begin(), aBallInfo->myConn->end());
271 // allocate array of diameters
272 vtkIdType maxID = myMesh->MaxElementID() + aNbBalls;
273 if ( anIsElemNum && !aBallInfo->myElemNum->empty() )
274 maxID = *std::max_element( aBallInfo->myElemNum->begin(),
275 aBallInfo->myElemNum->end() );
276 myMesh->GetGrid()->AllocateDiameters( maxID ); // performance optimization
279 SMDS_MeshElement* anElement;
280 DriverMED_FamilyPtr aFamily;
281 for ( TInt iBall = 0; iBall < aNbBalls; iBall++)
285 if (!(anElement = myMesh->AddBallWithID( aNodeIds[iBall],
286 aBallInfo->myDiameters[iBall],
287 aBallInfo->GetElemNum(iBall))))
291 myMesh->AddBall( myMesh->FindNode( aNodeIds[iBall]),
292 aBallInfo->myDiameters[iBall] );
294 // Save reference to this element from its family
295 TInt aFamNum = aBallInfo->GetFamNum(iBall);
296 if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies ))
298 aFamily->AddElement(anElement);
299 aFamily->SetType( SMDSAbs_Ball );
304 ( takeNumbers && aBallInfo->IsElemNum() && !aBallInfo->myElemNum->empty() ))
305 if ( aResult < DRS_WARN_RENUMBER )
306 aResult = DRS_WARN_RENUMBER;
312 // case ePOINT1: ## PAL16410
317 PPolygoneInfo aPolygoneInfo = aMed->GetPPolygoneInfo(aMeshInfo,anEntity,aGeom);
318 EBooleen anIsElemNum = takeNumbers ? aPolygoneInfo->IsElemNum() : eFAUX;
320 typedef SMDS_MeshFace* (SMESHDS_Mesh::* FAddPolyWithID)
321 (const std::vector<int> & nodes_ids, const int ID);
322 typedef SMDS_MeshFace* (SMESHDS_Mesh::* FAddPolygon)
323 (const std::vector<const SMDS_MeshNode*> & nodes);
325 FAddPolyWithID addPolyWithID = & SMESHDS_Mesh::AddPolygonalFaceWithID;
326 FAddPolygon addPolygon = & SMESHDS_Mesh::AddPolygonalFace;
327 if ( aGeom == ePOLYGON2 ) {
328 addPolyWithID = & SMESHDS_Mesh::AddQuadPolygonalFaceWithID;
329 addPolygon = & SMESHDS_Mesh::AddQuadPolygonalFace;
332 vector<const SMDS_MeshNode*> aNodes;
333 const TInt aNbElem = aPolygoneInfo->GetNbElem();
334 for ( TInt iElem = 0; iElem < aNbElem; iElem++ )
336 MED::TCConnSlice aConnSlice = aPolygoneInfo->GetConnSlice(iElem);
337 TInt aNbConn = aPolygoneInfo->GetNbConn(iElem);
338 aNodeIds.resize( aNbConn );
339 #ifdef _EDF_NODE_IDS_
341 for(TInt iConn = 0; iConn < aNbConn; iConn++)
342 aNodeIds[iConn] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1);
344 for(TInt iConn = 0; iConn < aNbConn; iConn++)
345 aNodeIds[iConn] = aConnSlice[iConn];
347 for(TInt iConn = 0; iConn < aNbConn; iConn++)
348 aNodeIds[iConn] = aConnSlice[iConn];
350 bool isRenum = false;
351 SMDS_MeshElement* anElement = NULL;
352 TInt aFamNum = aPolygoneInfo->GetFamNum(iElem);
357 TInt anElemId = aPolygoneInfo->GetElemNum( iElem );
358 anElement = (myMesh->*addPolyWithID)( aNodeIds, anElemId );
361 aNodes.resize( aNbConn );
362 for ( TInt iConn = 0; iConn < aNbConn; iConn++ )
363 aNodes[iConn] = FindNode( myMesh, aNodeIds[iConn] );
364 anElement = (myMesh->*addPolygon)( aNodes );
365 isRenum = anIsElemNum;
368 } catch(const std::exception& exc) {
369 aResult = addMessage( exc.what(), /*isFatal=*/true );
371 aResult = addMessage( "Unknown exception", /*isFatal=*/true );
375 aResult = DRS_WARN_SKIP_ELEM;
381 if(aResult < DRS_WARN_RENUMBER)
382 aResult = DRS_WARN_RENUMBER;
384 if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies ))
386 // Save reference to this element from its family
387 aFamily->AddElement(anElement);
388 aFamily->SetType(anElement->GetType());
395 PPolyedreInfo aPolyedreInfo = aMed->GetPPolyedreInfo(aMeshInfo,anEntity,aGeom);
396 EBooleen anIsElemNum = takeNumbers ? aPolyedreInfo->IsElemNum() : eFAUX;
398 TInt aNbElem = aPolyedreInfo->GetNbElem();
399 for(TInt iElem = 0; iElem < aNbElem; iElem++){
400 MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(iElem);
401 TInt aNbFaces = aConnSliceArr.size();
402 typedef MED::TVector<int> TQuantities;
403 TQuantities aQuantities(aNbFaces);
404 TInt aNbNodes = aPolyedreInfo->GetNbNodes(iElem);
405 TNodeIds aNodeIds(aNbNodes);
406 for(TInt iFace = 0, iNode = 0; iFace < aNbFaces; iFace++){
407 MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
408 TInt aNbConn = aConnSlice.size();
409 aQuantities[iFace] = aNbConn;
410 #ifdef _EDF_NODE_IDS_
412 for(TInt iConn = 0; iConn < aNbConn; iConn++)
414 aNodeIds[iNode] = aNodeInfo->GetElemNum(aConnSlice[iConn] - 1);
418 for(TInt iConn = 0; iConn < aNbConn; iConn++)
420 aNodeIds[iNode++] = aConnSlice[iConn];
423 for(TInt iConn = 0; iConn < aNbConn; iConn++)
425 aNodeIds[iNode++] = aConnSlice[iConn];
430 bool isRenum = false;
431 SMDS_MeshElement* anElement = NULL;
432 TInt aFamNum = aPolyedreInfo->GetFamNum(iElem);
438 TInt anElemId = aPolyedreInfo->GetElemNum(iElem);
439 anElement = myMesh->AddPolyhedralVolumeWithID(aNodeIds,aQuantities,anElemId);
442 vector<const SMDS_MeshNode*> aNodes(aNbNodes);
443 for(TInt iConn = 0; iConn < aNbNodes; iConn++)
444 aNodes[iConn] = FindNode(myMesh,aNodeIds[iConn]);
445 anElement = myMesh->AddPolyhedralVolume(aNodes,aQuantities);
446 isRenum = anIsElemNum;
449 }catch(const std::exception& exc){
456 aResult = DRS_WARN_SKIP_ELEM;
461 if (aResult < DRS_WARN_RENUMBER)
462 aResult = DRS_WARN_RENUMBER;
464 if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies )) {
465 // Save reference to this element from its family
466 aFamily->AddElement(anElement);
467 aFamily->SetType(anElement->GetType());
474 PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom);
475 EBooleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : eFAUX;
476 TInt aNbElems = aCellInfo->GetNbElem();
477 if(MYDEBUG) MESSAGE("Perform - anEntity = "<<anEntity<<"; anIsElemNum = "<<anIsElemNum);
478 if(MYDEBUG) MESSAGE("Perform - aGeom = "<<aGeom<<"; aNbElems = "<<aNbElems);
482 case eSEG2: aNbNodes = 2; break;
483 case eSEG3: aNbNodes = 3; break;
484 case eTRIA3: aNbNodes = 3; break;
485 case eTRIA6: aNbNodes = 6; break;
486 case eTRIA7: aNbNodes = 7; break;
487 case eQUAD4: aNbNodes = 4; break;
488 case eQUAD8: aNbNodes = 8; break;
489 case eQUAD9: aNbNodes = 9; break;
490 case eTETRA4: aNbNodes = 4; break;
491 case eTETRA10: aNbNodes = 10; break;
492 case ePYRA5: aNbNodes = 5; break;
493 case ePYRA13: aNbNodes = 13; break;
494 case ePENTA6: aNbNodes = 6; break;
495 case ePENTA15: aNbNodes = 15; break;
496 case ePENTA18: aNbNodes = 18; break;
497 case eHEXA8: aNbNodes = 8; break;
498 case eHEXA20: aNbNodes = 20; break;
499 case eHEXA27: aNbNodes = 27; break;
500 case eOCTA12: aNbNodes = 12; break;
501 case ePOINT1: aNbNodes = 1; break;
504 vector<TInt> aNodeIds(aNbNodes);
505 for ( int iElem = 0; iElem < aNbElems; iElem++ )
507 bool anIsValidConnect = false;
508 TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem);
512 #ifdef _EDF_NODE_IDS_
514 for(int iNode = 0; iNode < aNbNodes; iNode++)
515 aNodeIds[iNode] = aNodeInfo->GetElemNum(aConnSlice[iNode] - 1);
517 for(int iNode = 0; iNode < aNbNodes; iNode++)
518 aNodeIds[iNode] = aConnSlice[iNode];
520 for(int iNode = 0; iNode < aNbNodes; iNode++)
521 aNodeIds[iNode] = aConnSlice[iNode];
523 anIsValidConnect = true;
525 }catch(const std::exception& exc){
526 INFOS("Following exception was caught:\n\t"<<exc.what());
527 aResult = addMessage( exc.what(), /*isFatal=*/true );
529 INFOS("Unknown exception was caught !!!");
530 aResult = addMessage( "Unknown exception", /*isFatal=*/true );
533 if(!anIsValidConnect)
536 bool isRenum = false;
537 const SMDS_MeshElement* anElement = NULL;
538 TInt aFamNum = aCellInfo->GetFamNum(iElem);
542 //MESSAGE("Try to create element # " << iElem << " with id = "
543 // << aCellInfo->GetElemNum(iElem));
546 //anElement = FindNode(myMesh,aNodeIds[0]);
548 anElement = myMesh->Add0DElementWithID
549 (aNodeIds[0], aCellInfo->GetElemNum(iElem));
551 anElement = myMesh->Add0DElement(FindNode(myMesh,aNodeIds[0]));
552 isRenum = anIsElemNum;
557 anElement = myMesh->AddEdgeWithID(aNodeIds[0],
559 aCellInfo->GetElemNum(iElem));
561 anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds[0]),
562 FindNode(myMesh,aNodeIds[1]));
563 isRenum = anIsElemNum;
568 anElement = myMesh->AddEdgeWithID(aNodeIds[0],
571 aCellInfo->GetElemNum(iElem));
573 anElement = myMesh->AddEdge(FindNode(myMesh,aNodeIds[0]),
574 FindNode(myMesh,aNodeIds[1]),
575 FindNode(myMesh,aNodeIds[2]));
576 isRenum = anIsElemNum;
582 anElement = myMesh->AddFaceWithID(aNodeIds[0],
585 aCellInfo->GetElemNum(iElem));
587 anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
588 FindNode(myMesh,aNodeIds[1]),
589 FindNode(myMesh,aNodeIds[2]));
590 isRenum = anIsElemNum;
596 anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
597 aNodeIds[2], aNodeIds[3],
598 aNodeIds[4], aNodeIds[5],
599 aCellInfo->GetElemNum(iElem));
601 anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
602 FindNode(myMesh,aNodeIds[1]),
603 FindNode(myMesh,aNodeIds[2]),
604 FindNode(myMesh,aNodeIds[3]),
605 FindNode(myMesh,aNodeIds[4]),
606 FindNode(myMesh,aNodeIds[5]));
607 isRenum = anIsElemNum;
613 anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
614 aNodeIds[2], aNodeIds[3],
615 aNodeIds[4], aNodeIds[5], aNodeIds[6],
616 aCellInfo->GetElemNum(iElem));
618 anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
619 FindNode(myMesh,aNodeIds[1]),
620 FindNode(myMesh,aNodeIds[2]),
621 FindNode(myMesh,aNodeIds[3]),
622 FindNode(myMesh,aNodeIds[4]),
623 FindNode(myMesh,aNodeIds[5]),
624 FindNode(myMesh,aNodeIds[6]));
625 isRenum = anIsElemNum;
631 anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
632 aNodeIds[2], aNodeIds[3],
633 aCellInfo->GetElemNum(iElem));
635 anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
636 FindNode(myMesh,aNodeIds[1]),
637 FindNode(myMesh,aNodeIds[2]),
638 FindNode(myMesh,aNodeIds[3]));
639 isRenum = anIsElemNum;
645 anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
646 aNodeIds[2], aNodeIds[3],
647 aNodeIds[4], aNodeIds[5],
648 aNodeIds[6], aNodeIds[7],
649 aCellInfo->GetElemNum(iElem));
651 anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
652 FindNode(myMesh,aNodeIds[1]),
653 FindNode(myMesh,aNodeIds[2]),
654 FindNode(myMesh,aNodeIds[3]),
655 FindNode(myMesh,aNodeIds[4]),
656 FindNode(myMesh,aNodeIds[5]),
657 FindNode(myMesh,aNodeIds[6]),
658 FindNode(myMesh,aNodeIds[7]));
659 isRenum = anIsElemNum;
665 anElement = myMesh->AddFaceWithID(aNodeIds[0], aNodeIds[1],
666 aNodeIds[2], aNodeIds[3],
667 aNodeIds[4], aNodeIds[5],
668 aNodeIds[6], aNodeIds[7], aNodeIds[8],
669 aCellInfo->GetElemNum(iElem));
671 anElement = myMesh->AddFace(FindNode(myMesh,aNodeIds[0]),
672 FindNode(myMesh,aNodeIds[1]),
673 FindNode(myMesh,aNodeIds[2]),
674 FindNode(myMesh,aNodeIds[3]),
675 FindNode(myMesh,aNodeIds[4]),
676 FindNode(myMesh,aNodeIds[5]),
677 FindNode(myMesh,aNodeIds[6]),
678 FindNode(myMesh,aNodeIds[7]),
679 FindNode(myMesh,aNodeIds[8]));
680 isRenum = anIsElemNum;
686 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
687 aNodeIds[2], aNodeIds[3],
688 aCellInfo->GetElemNum(iElem));
690 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
691 FindNode(myMesh,aNodeIds[1]),
692 FindNode(myMesh,aNodeIds[2]),
693 FindNode(myMesh,aNodeIds[3]));
694 isRenum = anIsElemNum;
700 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
701 aNodeIds[2], aNodeIds[3],
702 aNodeIds[4], aNodeIds[5],
703 aNodeIds[6], aNodeIds[7],
704 aNodeIds[8], aNodeIds[9],
705 aCellInfo->GetElemNum(iElem));
707 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
708 FindNode(myMesh,aNodeIds[1]),
709 FindNode(myMesh,aNodeIds[2]),
710 FindNode(myMesh,aNodeIds[3]),
711 FindNode(myMesh,aNodeIds[4]),
712 FindNode(myMesh,aNodeIds[5]),
713 FindNode(myMesh,aNodeIds[6]),
714 FindNode(myMesh,aNodeIds[7]),
715 FindNode(myMesh,aNodeIds[8]),
716 FindNode(myMesh,aNodeIds[9]));
717 isRenum = anIsElemNum;
723 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
724 aNodeIds[2], aNodeIds[3],
726 aCellInfo->GetElemNum(iElem));
728 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
729 FindNode(myMesh,aNodeIds[1]),
730 FindNode(myMesh,aNodeIds[2]),
731 FindNode(myMesh,aNodeIds[3]),
732 FindNode(myMesh,aNodeIds[4]));
733 isRenum = anIsElemNum;
739 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
740 aNodeIds[2], aNodeIds[3],
741 aNodeIds[4], aNodeIds[5],
742 aNodeIds[6], aNodeIds[7],
743 aNodeIds[8], aNodeIds[9],
744 aNodeIds[10], aNodeIds[11],
746 aCellInfo->GetElemNum(iElem));
748 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
749 FindNode(myMesh,aNodeIds[1]),
750 FindNode(myMesh,aNodeIds[2]),
751 FindNode(myMesh,aNodeIds[3]),
752 FindNode(myMesh,aNodeIds[4]),
753 FindNode(myMesh,aNodeIds[5]),
754 FindNode(myMesh,aNodeIds[6]),
755 FindNode(myMesh,aNodeIds[7]),
756 FindNode(myMesh,aNodeIds[8]),
757 FindNode(myMesh,aNodeIds[9]),
758 FindNode(myMesh,aNodeIds[10]),
759 FindNode(myMesh,aNodeIds[11]),
760 FindNode(myMesh,aNodeIds[12]));
761 isRenum = anIsElemNum;
767 anElement = myMesh->AddVolumeWithID(aNodeIds[0],
773 aCellInfo->GetElemNum(iElem));
775 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
776 FindNode(myMesh,aNodeIds[1]),
777 FindNode(myMesh,aNodeIds[2]),
778 FindNode(myMesh,aNodeIds[3]),
779 FindNode(myMesh,aNodeIds[4]),
780 FindNode(myMesh,aNodeIds[5]));
781 isRenum = anIsElemNum;
787 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
788 aNodeIds[2], aNodeIds[3],
789 aNodeIds[4], aNodeIds[5],
790 aNodeIds[6], aNodeIds[7],
791 aNodeIds[8], aNodeIds[9],
792 aNodeIds[10], aNodeIds[11],
793 aNodeIds[12], aNodeIds[13],
795 aCellInfo->GetElemNum(iElem));
797 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
798 FindNode(myMesh,aNodeIds[1]),
799 FindNode(myMesh,aNodeIds[2]),
800 FindNode(myMesh,aNodeIds[3]),
801 FindNode(myMesh,aNodeIds[4]),
802 FindNode(myMesh,aNodeIds[5]),
803 FindNode(myMesh,aNodeIds[6]),
804 FindNode(myMesh,aNodeIds[7]),
805 FindNode(myMesh,aNodeIds[8]),
806 FindNode(myMesh,aNodeIds[9]),
807 FindNode(myMesh,aNodeIds[10]),
808 FindNode(myMesh,aNodeIds[11]),
809 FindNode(myMesh,aNodeIds[12]),
810 FindNode(myMesh,aNodeIds[13]),
811 FindNode(myMesh,aNodeIds[14]));
812 isRenum = anIsElemNum;
818 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
819 aNodeIds[2], aNodeIds[3],
820 aNodeIds[4], aNodeIds[5],
821 aNodeIds[6], aNodeIds[7],
822 aNodeIds[8], aNodeIds[9],
823 aNodeIds[10], aNodeIds[11],
824 aNodeIds[12], aNodeIds[13],
825 aNodeIds[14], aNodeIds[15],
826 aNodeIds[16], aNodeIds[17],
827 aCellInfo->GetElemNum(iElem));
829 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
830 FindNode(myMesh,aNodeIds[1]),
831 FindNode(myMesh,aNodeIds[2]),
832 FindNode(myMesh,aNodeIds[3]),
833 FindNode(myMesh,aNodeIds[4]),
834 FindNode(myMesh,aNodeIds[5]),
835 FindNode(myMesh,aNodeIds[6]),
836 FindNode(myMesh,aNodeIds[7]),
837 FindNode(myMesh,aNodeIds[8]),
838 FindNode(myMesh,aNodeIds[9]),
839 FindNode(myMesh,aNodeIds[10]),
840 FindNode(myMesh,aNodeIds[11]),
841 FindNode(myMesh,aNodeIds[12]),
842 FindNode(myMesh,aNodeIds[13]),
843 FindNode(myMesh,aNodeIds[14]),
844 FindNode(myMesh,aNodeIds[15]),
845 FindNode(myMesh,aNodeIds[16]),
846 FindNode(myMesh,aNodeIds[17]));
847 isRenum = anIsElemNum;
853 anElement = myMesh->AddVolumeWithID(aNodeIds[0],
861 aCellInfo->GetElemNum(iElem));
863 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
864 FindNode(myMesh,aNodeIds[1]),
865 FindNode(myMesh,aNodeIds[2]),
866 FindNode(myMesh,aNodeIds[3]),
867 FindNode(myMesh,aNodeIds[4]),
868 FindNode(myMesh,aNodeIds[5]),
869 FindNode(myMesh,aNodeIds[6]),
870 FindNode(myMesh,aNodeIds[7]));
871 isRenum = anIsElemNum;
878 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
879 aNodeIds[2], aNodeIds[3],
880 aNodeIds[4], aNodeIds[5],
881 aNodeIds[6], aNodeIds[7],
882 aNodeIds[8], aNodeIds[9],
883 aNodeIds[10], aNodeIds[11],
884 aNodeIds[12], aNodeIds[13],
885 aNodeIds[14], aNodeIds[15],
886 aNodeIds[16], aNodeIds[17],
887 aNodeIds[18], aNodeIds[19],
888 aCellInfo->GetElemNum(iElem));
890 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
891 FindNode(myMesh,aNodeIds[1]),
892 FindNode(myMesh,aNodeIds[2]),
893 FindNode(myMesh,aNodeIds[3]),
894 FindNode(myMesh,aNodeIds[4]),
895 FindNode(myMesh,aNodeIds[5]),
896 FindNode(myMesh,aNodeIds[6]),
897 FindNode(myMesh,aNodeIds[7]),
898 FindNode(myMesh,aNodeIds[8]),
899 FindNode(myMesh,aNodeIds[9]),
900 FindNode(myMesh,aNodeIds[10]),
901 FindNode(myMesh,aNodeIds[11]),
902 FindNode(myMesh,aNodeIds[12]),
903 FindNode(myMesh,aNodeIds[13]),
904 FindNode(myMesh,aNodeIds[14]),
905 FindNode(myMesh,aNodeIds[15]),
906 FindNode(myMesh,aNodeIds[16]),
907 FindNode(myMesh,aNodeIds[17]),
908 FindNode(myMesh,aNodeIds[18]),
909 FindNode(myMesh,aNodeIds[19]));
910 isRenum = anIsElemNum;
917 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
918 aNodeIds[2], aNodeIds[3],
919 aNodeIds[4], aNodeIds[5],
920 aNodeIds[6], aNodeIds[7],
921 aNodeIds[8], aNodeIds[9],
922 aNodeIds[10], aNodeIds[11],
923 aNodeIds[12], aNodeIds[13],
924 aNodeIds[14], aNodeIds[15],
925 aNodeIds[16], aNodeIds[17],
926 aNodeIds[18], aNodeIds[19],
927 aNodeIds[20], aNodeIds[21],
928 aNodeIds[22], aNodeIds[23],
929 aNodeIds[24], aNodeIds[25],
931 aCellInfo->GetElemNum(iElem));
933 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
934 FindNode(myMesh,aNodeIds[1]),
935 FindNode(myMesh,aNodeIds[2]),
936 FindNode(myMesh,aNodeIds[3]),
937 FindNode(myMesh,aNodeIds[4]),
938 FindNode(myMesh,aNodeIds[5]),
939 FindNode(myMesh,aNodeIds[6]),
940 FindNode(myMesh,aNodeIds[7]),
941 FindNode(myMesh,aNodeIds[8]),
942 FindNode(myMesh,aNodeIds[9]),
943 FindNode(myMesh,aNodeIds[10]),
944 FindNode(myMesh,aNodeIds[11]),
945 FindNode(myMesh,aNodeIds[12]),
946 FindNode(myMesh,aNodeIds[13]),
947 FindNode(myMesh,aNodeIds[14]),
948 FindNode(myMesh,aNodeIds[15]),
949 FindNode(myMesh,aNodeIds[16]),
950 FindNode(myMesh,aNodeIds[17]),
951 FindNode(myMesh,aNodeIds[18]),
952 FindNode(myMesh,aNodeIds[19]),
953 FindNode(myMesh,aNodeIds[20]),
954 FindNode(myMesh,aNodeIds[21]),
955 FindNode(myMesh,aNodeIds[22]),
956 FindNode(myMesh,aNodeIds[23]),
957 FindNode(myMesh,aNodeIds[24]),
958 FindNode(myMesh,aNodeIds[25]),
959 FindNode(myMesh,aNodeIds[26]));
960 isRenum = anIsElemNum;
967 anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
968 aNodeIds[2], aNodeIds[3],
969 aNodeIds[4], aNodeIds[5],
970 aNodeIds[6], aNodeIds[7],
971 aNodeIds[8], aNodeIds[9],
972 aNodeIds[10], aNodeIds[11],
973 aCellInfo->GetElemNum(iElem));
975 anElement = myMesh->AddVolume(FindNode(myMesh,aNodeIds[0]),
976 FindNode(myMesh,aNodeIds[1]),
977 FindNode(myMesh,aNodeIds[2]),
978 FindNode(myMesh,aNodeIds[3]),
979 FindNode(myMesh,aNodeIds[4]),
980 FindNode(myMesh,aNodeIds[5]),
981 FindNode(myMesh,aNodeIds[6]),
982 FindNode(myMesh,aNodeIds[7]),
983 FindNode(myMesh,aNodeIds[8]),
984 FindNode(myMesh,aNodeIds[9]),
985 FindNode(myMesh,aNodeIds[10]),
986 FindNode(myMesh,aNodeIds[11]));
987 isRenum = anIsElemNum;
996 } catch(const std::exception& exc) {
997 INFOS("The following exception was caught:\n\t"<<exc.what());
998 aResult = addMessage( exc.what(), /*isFatal=*/true );
1000 INFOS("Unknown exception was caught !!!");
1001 aResult = addMessage( "Unknown exception", /*isFatal=*/true );
1005 aResult = DRS_WARN_SKIP_ELEM;
1009 anIsElemNum = eFAUX;
1010 takeNumbers = false;
1011 if (aResult < DRS_WARN_RENUMBER)
1012 aResult = DRS_WARN_RENUMBER;
1014 if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies )) {
1015 // Save reference to this element from its family
1016 aFamily->AddElement(anElement);
1017 aFamily->SetType(anElement->GetType());
1020 } // loop on aNbElems
1022 } // loop on aGeom2Size
1023 } // loop on aEntityInfo
1025 if (aDescendingEntitiesMap.Extent()) isDescConn = true; // Mantis issue 0020483
1027 } // for(int iMesh = 0; iMesh < aNbMeshes; iMesh++)
1030 catch(const std::exception& exc)
1032 INFOS("The following exception was caught:\n\t"<<exc.what());
1033 aResult = addMessage( exc.what(), /*isFatal=*/true );
1037 INFOS("Unknown exception was caught !!!");
1038 aResult = addMessage( "Unknown exception", /*isFatal=*/true );
1042 // Mantis issue 0020483
1043 if (aResult == DRS_OK && isDescConn) {
1044 INFOS("There are some elements in descending connectivity in med file. They were not read !!!");
1045 aResult = DRS_WARN_DESCENDING;
1048 if(MYDEBUG) MESSAGE("Perform - aResult status = "<<aResult);
1052 list<string> DriverMED_R_SMESHDS_Mesh::GetMeshNames(Status& theStatus)
1054 list<string> aMeshNames;
1057 if(MYDEBUG) MESSAGE("GetMeshNames - myFile : " << myFile);
1059 PWrapper aMed = CrWrapperR(myFile);
1061 if (TInt aNbMeshes = aMed->GetNbMeshes()) {
1062 for (int iMesh = 0; iMesh < aNbMeshes; iMesh++) {
1063 // Reading the MED mesh
1064 //---------------------
1065 PMeshInfo aMeshInfo = aMed->GetPMeshInfo(iMesh+1);
1066 aMeshNames.push_back(aMeshInfo->GetName());
1069 } catch(const std::exception& exc) {
1070 INFOS("Following exception was caught:\n\t"<<exc.what());
1071 theStatus = DRS_FAIL;
1073 INFOS("Unknown exception was caught !!!");
1074 theStatus = DRS_FAIL;
1080 list<TNameAndType> DriverMED_R_SMESHDS_Mesh::GetGroupNamesAndTypes()
1082 list<TNameAndType> aResult;
1083 set<TNameAndType> aResGroupNames;
1085 map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
1086 for (; aFamsIter != myFamilies.end(); aFamsIter++)
1088 DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
1089 const MED::TStringSet& aGroupNames = aFamily->GetGroupNames();
1090 set<string>::const_iterator aGrNamesIter = aGroupNames.begin();
1091 for (; aGrNamesIter != aGroupNames.end(); aGrNamesIter++)
1093 const ElemTypeSet& types = aFamily->GetTypes();
1094 ElemTypeSet::const_iterator type = types.begin();
1095 for ( ; type != types.end(); ++type )
1097 TNameAndType aNameAndType = make_pair( *aGrNamesIter, *type );
1098 if ( aResGroupNames.insert( aNameAndType ).second ) {
1099 aResult.push_back( aNameAndType );
1108 void DriverMED_R_SMESHDS_Mesh::GetGroup(SMESHDS_Group* theGroup)
1110 TFamilyVec * famVecPtr;
1112 if ( myGroups2FamiliesMap.IsEmpty() ) // PAL23514
1114 TFamilyVec famVector( 1 );
1115 map<int, DriverMED_FamilyPtr>::iterator famIter = myFamilies.begin();
1116 for ( ; famIter != myFamilies.end(); famIter++ )
1118 DriverMED_FamilyPtr family = famIter->second;
1119 const MED::TStringSet& groups = family->GetGroupNames();
1120 famVector[ 0 ] = family;
1121 MED::TStringSet::const_iterator grpIter = groups.begin();
1122 for ( ; grpIter != groups.end(); ++grpIter )
1124 TCollection_AsciiString groupName = grpIter->c_str();
1125 if (( famVecPtr = myGroups2FamiliesMap.ChangeSeek( groupName )))
1126 famVecPtr->push_back( family );
1128 myGroups2FamiliesMap.Bind( groupName, famVector );
1133 const char* aGroupName = theGroup->GetStoreName();
1134 if(MYDEBUG) MESSAGE("Get Group " << aGroupName);
1136 if (( famVecPtr = myGroups2FamiliesMap.ChangeSeek( aGroupName )))
1138 size_t groupSize = 0;
1139 for ( size_t i = 0; i < famVecPtr->size(); ++i )
1141 DriverMED_FamilyPtr aFamily = (*famVecPtr)[i];
1142 groupSize += aFamily->NbElements( theGroup->GetType() );
1144 theGroup->SMDSGroup().Reserve( groupSize );
1146 for ( size_t i = 0; i < famVecPtr->size(); ++i )
1148 DriverMED_FamilyPtr aFamily = (*famVecPtr)[i];
1149 if ( aFamily->GetTypes().count( theGroup->GetType() ))
1151 const ElementsSet& anElements = aFamily->GetElements();
1152 ElementsSet::const_iterator anElemsIter = anElements.begin();
1153 for (; anElemsIter != anElements.end(); anElemsIter++)
1155 const SMDS_MeshElement * element = *anElemsIter;
1156 if ( element->GetType() == theGroup->GetType() ) // Issue 0020576
1157 theGroup->SMDSGroup().Add(element);
1159 int aGroupAttrVal = aFamily->GetGroupAttributVal();
1160 if( aGroupAttrVal != 0 )
1161 theGroup->SetColorGroup(aGroupAttrVal);
1167 void DriverMED_R_SMESHDS_Mesh::GetSubMesh (SMESHDS_SubMesh* theSubMesh,
1170 char submeshGrpName[ 30 ];
1171 sprintf( submeshGrpName, "SubMesh %d", theId );
1172 string aName (submeshGrpName);
1173 map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
1174 for (; aFamsIter != myFamilies.end(); aFamsIter++)
1176 DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
1177 if (aFamily->MemberOf(aName))
1179 const ElementsSet& anElements = aFamily->GetElements();
1180 ElementsSet::const_iterator anElemsIter = anElements.begin();
1181 if (aFamily->GetType() == SMDSAbs_Node)
1183 for (; anElemsIter != anElements.end(); anElemsIter++)
1185 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>(*anElemsIter);
1186 theSubMesh->AddNode(node);
1191 for (; anElemsIter != anElements.end(); anElemsIter++)
1193 theSubMesh->AddElement(*anElemsIter);
1200 void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes ()
1202 map<int, DriverMED_FamilyPtr>::iterator aFamsIter = myFamilies.begin();
1203 for (; aFamsIter != myFamilies.end(); aFamsIter++)
1205 DriverMED_FamilyPtr aFamily = (*aFamsIter).second;
1206 MED::TStringSet aGroupNames = aFamily->GetGroupNames();
1207 set<string>::iterator aGrNamesIter = aGroupNames.begin();
1208 for (; aGrNamesIter != aGroupNames.end(); aGrNamesIter++)
1210 string aName = *aGrNamesIter;
1211 // Check, if this is a Group or SubMesh name
1212 if (aName.substr(0, 7) == string("SubMesh"))
1214 int Id = atoi(string(aName).substr(7).c_str());
1215 const ElementsSet& anElements = aFamily->GetElements();
1216 ElementsSet::const_iterator anElemsIter = anElements.begin();
1217 if (aFamily->GetType() == SMDSAbs_Node)
1219 for (; anElemsIter != anElements.end(); anElemsIter++)
1221 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( *anElemsIter );
1222 // find out a shape type
1223 TopoDS_Shape aShape = myMesh->IndexToShape( Id );
1224 int aShapeType = ( aShape.IsNull() ? -1 : aShape.ShapeType() );
1225 switch ( aShapeType ) {
1227 myMesh->SetNodeOnFace(node, Id); break;
1229 myMesh->SetNodeOnEdge(node, Id); break;
1231 myMesh->SetNodeOnVertex(node, Id); break;
1233 myMesh->SetNodeInVolume(node, Id);
1239 for (; anElemsIter != anElements.end(); anElemsIter++)
1241 myMesh->SetMeshElementOnShape(*anElemsIter, Id);
1249 * \brief Ensure aFamily to have required ID
1250 * \param aFamily - a family to check and update
1251 * \param anID - an ID aFamily should have
1252 * \retval bool - true if successful
1254 bool DriverMED::checkFamilyID(DriverMED_FamilyPtr & aFamily,
1256 const TID2FamilyMap& myFamilies)
1258 if ( !aFamily || aFamily->GetId() != anID ) {
1259 map<int, DriverMED_FamilyPtr>::const_iterator i_fam = myFamilies.find(anID);
1260 if ( i_fam == myFamilies.end() )
1262 aFamily = i_fam->second;
1264 return ( aFamily->GetId() == anID );
1268 * \brief Reading the structured mesh and convert to non structured
1269 * (by filling of smesh structure for non structured mesh)
1270 * \param theWrapper - PWrapper const pointer
1271 * \param theMeshInfo - PMeshInfo const pointer
1272 * \param myFamilies - a map of the family ID to the Family
1273 * \return TRUE, if successfully. Else FALSE
1275 bool DriverMED::buildMeshGrille(const MED::PWrapper& theWrapper,
1276 const MED::PMeshInfo& theMeshInfo,
1277 SMESHDS_Mesh* myMesh,
1278 const TID2FamilyMap& myFamilies)
1282 MED::PGrilleInfo aGrilleInfo = theWrapper->GetPGrilleInfo(theMeshInfo);
1283 MED::TInt aNbNodes = aGrilleInfo->GetNbNodes();
1284 MED::TInt aNbCells = aGrilleInfo->GetNbCells();
1285 MED::TInt aMeshDim = theMeshInfo->GetDim();
1286 DriverMED_FamilyPtr aFamily;
1287 for(MED::TInt iNode=0;iNode < aNbNodes; iNode++){
1288 double aCoords[3] = {0.0, 0.0, 0.0};
1289 const SMDS_MeshNode* aNode;
1290 MED::TNodeCoord aMEDNodeCoord = aGrilleInfo->GetCoord(iNode);
1291 for(MED::TInt iDim=0;iDim<aMeshDim;iDim++)
1292 aCoords[(int)iDim] = aMEDNodeCoord[(int)iDim];
1293 aNode = myMesh->AddNodeWithID(aCoords[0],aCoords[1],aCoords[2],iNode+1);
1295 EXCEPTION(runtime_error,"buildMeshGrille Error. Node not created! "<<(int)iNode);
1298 if((aGrilleInfo->myFamNumNode).size() > 0){
1299 TInt aFamNum = aGrilleInfo->GetFamNumNode(iNode);
1300 if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies ))
1302 aFamily->AddElement(aNode);
1303 aFamily->SetType(SMDSAbs_Node);
1309 SMDS_MeshElement* anElement = NULL;
1310 MED::TIntVector aNodeIds;
1311 for(MED::TInt iCell=0;iCell < aNbCells; iCell++){
1312 aNodeIds = aGrilleInfo->GetConn(iCell);
1313 switch(aGrilleInfo->GetGeom()){
1315 if(aNodeIds.size() != 2){
1317 EXCEPTION(runtime_error,"buildMeshGrille Error. Incorrect size of ids 2!="<<aNodeIds.size());
1319 anElement = myMesh->AddEdgeWithID(aNodeIds[0]+1,
1324 if(aNodeIds.size() != 4){
1326 EXCEPTION(runtime_error,"buildMeshGrille Error. Incorrect size of ids 4!="<<aNodeIds.size());
1328 anElement = myMesh->AddFaceWithID(aNodeIds[0]+1,
1335 if(aNodeIds.size() != 8){
1337 EXCEPTION(runtime_error,"buildMeshGrille Error. Incorrect size of ids 8!="<<aNodeIds.size());
1339 anElement = myMesh->AddVolumeWithID(aNodeIds[0]+1,
1353 EXCEPTION(runtime_error,"buildMeshGrille Error. Element not created! "<<iCell);
1355 if((aGrilleInfo->myFamNum).size() > 0){
1356 TInt aFamNum = aGrilleInfo->GetFamNum(iCell);
1357 if ( DriverMED::checkFamilyID ( aFamily, aFamNum, myFamilies )){
1358 aFamily->AddElement(anElement);
1359 aFamily->SetType(anElement->GetType());