+ if (anElem->IsPoly()) {
+ // fill indices for polygonal element
+ TInt aPrevPos = aPolygoneInds.back();
+ aPolygoneInds.push_back(aPrevPos + aNbNodes);
+ }
+
+ anElemNums->push_back(anElem->GetID());
+
+ if (anElemFamMap.find(anElem) != anElemFamMap.end())
+ aFamilyNums->push_back(anElemFamMap[anElem]);
+ else
+ aFamilyNums->push_back(myFacesDefaultFamilyId);
+ }
+ if(TInt aNbElems = anTriaElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ eTRIA3,
+ aTriaConn,
+ SMDS_MED_CONNECTIVITY,
+ aTriaFamilyNums,
+ anTriaElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eTRIA3<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
+ }
+ if(TInt aNbElems = aQuadElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ eQUAD4,
+ aQuadConn,
+ SMDS_MED_CONNECTIVITY,
+ aQuadFamilyNums,
+ aQuadElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eQUAD4<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
+ }
+ if(TInt aNbElems = anTria6ElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ eTRIA6,
+ aTria6Conn,
+ SMDS_MED_CONNECTIVITY,
+ aTria6FamilyNums,
+ anTria6ElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eTRIA6<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
+ }
+ if(TInt aNbElems = aQuad8ElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ eQUAD8,
+ aQuad8Conn,
+ SMDS_MED_CONNECTIVITY,
+ aQuad8FamilyNums,
+ aQuad8ElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eQUAD8<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
+ }
+ if(TInt aNbElems = aPolygoneElemNums.size()){
+ // add one element in connectivities,
+ // referenced by the last element in indices
+ aPolygoneConn.push_back(0);
+
+ PPolygoneInfo aCellInfo = myMed->CrPolygoneInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ ePOLYGONE,
+ aPolygoneInds,
+ aPolygoneConn,
+ SMDS_MED_CONNECTIVITY,
+ aPolygoneFamilyNums,
+ aPolygoneElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePOLYGONE<<"; aNbElems = "<<aNbElems);
+ myMed->SetPolygoneInfo(aCellInfo);
+ }
+ }
+
+ // Storing SMDS Volumes
+ if(TInt aNbElems = myMesh->NbVolumes()){
+ SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator();
+#ifdef _ELEMENTS_BY_DIM_
+ SMDS_MED_ENTITY = eMAILLE;
+#endif
+ TInt aNbTetraConn = MED::GetNbNodes(eTETRA4);
+ MED::TIntVector anTetraElemNums;
+ anTetraElemNums.reserve(aNbElems);
+ MED::TIntVector aTetraFamilyNums;
+ aTetraFamilyNums.reserve(aNbElems);
+ MED::TIntVector aTetraConn;
+ aTetraConn.reserve(aNbElems*aNbTetraConn);
+
+ TInt aNbPyraConn = MED::GetNbNodes(ePYRA5);
+ MED::TIntVector anPyraElemNums;
+ anPyraElemNums.reserve(aNbElems);
+ MED::TIntVector aPyraFamilyNums;
+ aPyraFamilyNums.reserve(aNbElems);
+ MED::TIntVector aPyraConn;
+ aPyraConn.reserve(aNbElems*aNbPyraConn);
+
+ TInt aNbPentaConn = MED::GetNbNodes(ePENTA6);
+ MED::TIntVector anPentaElemNums;
+ anPentaElemNums.reserve(aNbElems);
+ MED::TIntVector aPentaFamilyNums;
+ aPentaFamilyNums.reserve(aNbElems);
+ MED::TIntVector aPentaConn;
+ aPentaConn.reserve(aNbElems*aNbPentaConn);
+
+ TInt aNbHexaConn = MED::GetNbNodes(eHEXA8);
+ MED::TIntVector aHexaElemNums;
+ aHexaElemNums.reserve(aNbElems);
+ MED::TIntVector aHexaFamilyNums;
+ aHexaFamilyNums.reserve(aNbElems);
+ MED::TIntVector aHexaConn;
+ aHexaConn.reserve(aNbElems*aNbHexaConn);
+
+ TInt aNbTetra10Conn = MED::GetNbNodes(eTETRA10);
+ MED::TIntVector anTetra10ElemNums;
+ anTetra10ElemNums.reserve(aNbElems);
+ MED::TIntVector aTetra10FamilyNums;
+ aTetra10FamilyNums.reserve(aNbElems);
+ MED::TIntVector aTetra10Conn;
+ aTetra10Conn.reserve(aNbElems*aNbTetra10Conn);
+
+ TInt aNbPyra13Conn = MED::GetNbNodes(ePYRA13);
+ MED::TIntVector anPyra13ElemNums;
+ anPyra13ElemNums.reserve(aNbElems);
+ MED::TIntVector aPyra13FamilyNums;
+ aPyra13FamilyNums.reserve(aNbElems);
+ MED::TIntVector aPyra13Conn;
+ aPyra13Conn.reserve(aNbElems*aNbPyra13Conn);
+
+ TInt aNbPenta15Conn = MED::GetNbNodes(ePENTA15);
+ MED::TIntVector anPenta15ElemNums;
+ anPenta15ElemNums.reserve(aNbElems);
+ MED::TIntVector aPenta15FamilyNums;
+ aPenta15FamilyNums.reserve(aNbElems);
+ MED::TIntVector aPenta15Conn;
+ aPenta15Conn.reserve(aNbElems*aNbPenta15Conn);
+
+ TInt aNbHexa20Conn = MED::GetNbNodes(eHEXA20);
+ MED::TIntVector aHexa20ElemNums;
+ aHexa20ElemNums.reserve(aNbElems);
+ MED::TIntVector aHexa20FamilyNums;
+ aHexa20FamilyNums.reserve(aNbElems);
+ MED::TIntVector aHexa20Conn;
+ aHexa20Conn.reserve(aNbElems*aNbHexa20Conn);
+
+ MED::TIntVector aPolyedreElemNums;
+ aPolyedreElemNums.reserve(aNbElems);
+ MED::TIntVector aPolyedreInds;
+ aPolyedreInds.reserve(aNbElems + 1);
+ aPolyedreInds.push_back(1); // reference on the first element in the faces
+ MED::TIntVector aPolyedreFaces;
+ aPolyedreFaces.reserve(aNbElems + 1);
+ aPolyedreFaces.push_back(1); // reference on the first element in the connectivities
+ MED::TIntVector aPolyedreFamilyNums;
+ aPolyedreFamilyNums.reserve(aNbElems);
+ MED::TIntVector aPolyedreConn;
+ aPolyedreConn.reserve(aNbElems*aNbHexaConn);
+
+ for(TInt iElem = 0; iElem < aNbElems && anIter->more(); iElem++){
+ const SMDS_MeshVolume* anElem = anIter->next();
+
+ MED::TIntVector* anElemNums;
+ MED::TIntVector* aFamilyNums;
+
+ if (anElem->IsPoly()) {
+ const SMDS_PolyhedralVolumeOfNodes* aPolyedre =
+ (const SMDS_PolyhedralVolumeOfNodes*) anElem;
+ if (!aPolyedre) {
+ MESSAGE("Warning: bad volumic element");
+ continue;
+ }
+
+ anElemNums = &aPolyedreElemNums;
+ aFamilyNums = &aPolyedreFamilyNums;
+
+ TInt aNodeId, aNbFaces = aPolyedre->NbFaces();
+ for (int iface = 1; iface <= aNbFaces; iface++) {
+ int aNbFaceNodes = aPolyedre->NbFaceNodes(iface);
+ for (int inode = 1; inode <= aNbFaceNodes; inode++) {
+ aNodeId = aPolyedre->GetFaceNode(iface, inode)->GetID();
+#ifdef _EDF_NODE_IDS_
+ aPolyedreConn.push_back(aNodeIdMap[aNodeId]);
+#else
+ aPolyedreConn.push_back(aNodeId);
+#endif
+ }
+ TInt aPrevPos = aPolyedreFaces.back();
+ aPolyedreFaces.push_back(aPrevPos + aNbFaceNodes);
+ }
+ TInt aPrevPos = aPolyedreInds.back();
+ aPolyedreInds.push_back(aPrevPos + aNbFaces);
+
+ }
+ else {
+ TInt aNbNodes = anElem->NbNodes();
+ SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
+ TInt aNbConnectivity;
+ MED::TIntVector* aConnectivity;
+ switch(aNbNodes){
+ case 4:
+ aNbConnectivity = aNbTetraConn;
+ anElemNums = &anTetraElemNums;
+ aFamilyNums = &aTetraFamilyNums;
+ aConnectivity = &aTetraConn;
+ break;
+ case 5:
+ aNbConnectivity = aNbPyraConn;
+ anElemNums = &anPyraElemNums;
+ aFamilyNums = &aPyraFamilyNums;
+ aConnectivity = &aPyraConn;
+ break;
+ case 6:
+ aNbConnectivity = aNbPentaConn;
+ anElemNums = &anPentaElemNums;
+ aFamilyNums = &aPentaFamilyNums;
+ aConnectivity = &aPentaConn;
+ break;
+ case 8:
+ aNbConnectivity = aNbHexaConn;
+ anElemNums = &aHexaElemNums;
+ aFamilyNums = &aHexaFamilyNums;
+ aConnectivity = &aHexaConn;
+ break;
+ case 10:
+ aNbConnectivity = aNbTetra10Conn;
+ anElemNums = &anTetra10ElemNums;
+ aFamilyNums = &aTetra10FamilyNums;
+ aConnectivity = &aTetra10Conn;
+ break;
+ case 13:
+ aNbConnectivity = aNbPyra13Conn;
+ anElemNums = &anPyra13ElemNums;
+ aFamilyNums = &aPyra13FamilyNums;
+ aConnectivity = &aPyra13Conn;
+ break;
+ case 15:
+ aNbConnectivity = aNbPenta15Conn;
+ anElemNums = &anPenta15ElemNums;
+ aFamilyNums = &aPenta15FamilyNums;
+ aConnectivity = &aPenta15Conn;
+ break;
+ case 20:
+ aNbConnectivity = aNbHexa20Conn;
+ anElemNums = &aHexa20ElemNums;
+ aFamilyNums = &aHexa20FamilyNums;
+ aConnectivity = &aHexa20Conn;
+ }
+
+ TInt aSize = aConnectivity->size();
+ aConnectivity->resize(aSize + aNbConnectivity);
+
+ MED::TIntVector aVector(aNbNodes);
+ for(TInt iNode = 0; aNodesIter->more(); iNode++){
+ const SMDS_MeshElement* aNode = aNodesIter->next();
+#ifdef _EDF_NODE_IDS_
+ aVector[iNode] = aNodeIdMap[aNode->GetID()];
+#else
+ aVector[iNode] = aNode->GetID();
+#endif
+ }
+ // There is some difference between SMDS and MED in cells mapping
+ switch(aNbNodes){
+ case 5:
+ (*aConnectivity)[aSize+0] = aVector[0];
+ (*aConnectivity)[aSize+1] = aVector[3];
+ (*aConnectivity)[aSize+2] = aVector[2];
+ (*aConnectivity)[aSize+3] = aVector[1];
+ (*aConnectivity)[aSize+4] = aVector[4];
+ default:
+ for(TInt iNode = 0; iNode < aNbNodes; iNode++)
+ (*aConnectivity)[aSize+iNode] = aVector[iNode];
+ }
+ }
+
+ anElemNums->push_back(anElem->GetID());
+
+ if (anElemFamMap.find(anElem) != anElemFamMap.end())
+ aFamilyNums->push_back(anElemFamMap[anElem]);
+ else
+ aFamilyNums->push_back(myVolumesDefaultFamilyId);
+ }
+
+ if(TInt aNbElems = anTetraElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ eTETRA4,
+ aTetraConn,
+ SMDS_MED_CONNECTIVITY,
+ aTetraFamilyNums,
+ anTetraElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eTETRA4<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
+ }
+ if(TInt aNbElems = anPyraElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ ePYRA5,
+ aPyraConn,
+ SMDS_MED_CONNECTIVITY,
+ aPyraFamilyNums,
+ anPyraElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePYRA5<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
+ }
+ if(TInt aNbElems = anPentaElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ ePENTA6,
+ aPentaConn,
+ SMDS_MED_CONNECTIVITY,
+ aPentaFamilyNums,
+ anPentaElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePENTA6<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
+ }
+ if(TInt aNbElems = aHexaElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ eHEXA8,
+ aHexaConn,
+ SMDS_MED_CONNECTIVITY,
+ aHexaFamilyNums,
+ aHexaElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eHEXA8<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
+ }
+ if(TInt aNbElems = anTetra10ElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ eTETRA10,
+ aTetra10Conn,
+ SMDS_MED_CONNECTIVITY,
+ aTetra10FamilyNums,
+ anTetra10ElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eTETRA10<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
+ }
+ if(TInt aNbElems = anPyra13ElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ ePYRA13,
+ aPyra13Conn,
+ SMDS_MED_CONNECTIVITY,
+ aPyra13FamilyNums,
+ anPyra13ElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePYRA13<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
+ }
+ if(TInt aNbElems = anPenta15ElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ ePENTA15,
+ aPenta15Conn,
+ SMDS_MED_CONNECTIVITY,
+ aPenta15FamilyNums,
+ anPenta15ElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePENTA15<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
+ }
+ if(TInt aNbElems = aHexa20ElemNums.size()){
+ PCellInfo aCellInfo = myMed->CrCellInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ eHEXA20,
+ aHexa20Conn,
+ SMDS_MED_CONNECTIVITY,
+ aHexa20FamilyNums,
+ aHexa20ElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eHEXA20<<"; aNbElems = "<<aNbElems);
+ myMed->SetCellInfo(aCellInfo);
+ }
+
+ if(TInt aNbElems = aPolyedreElemNums.size()){
+ // add one element in connectivities,
+ // referenced by the last element in faces
+ aPolyedreConn.push_back(0);
+
+ PPolyedreInfo aCellInfo = myMed->CrPolyedreInfo(aMeshInfo,
+ SMDS_MED_ENTITY,
+ ePOLYEDRE,
+ aPolyedreInds,
+ aPolyedreFaces,
+ aPolyedreConn,
+ SMDS_MED_CONNECTIVITY,
+ aPolyedreFamilyNums,
+ aPolyedreElemNums);
+ MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePOLYEDRE<<"; aNbElems = "<<aNbElems);
+ myMed->SetPolyedreInfo(aCellInfo);
+ }
+ }
+ }
+ catch(const std::exception& exc) {
+ INFOS("Follow exception was cought:\n\t"<<exc.what());
+ }
+ catch(...) {
+ INFOS("Unknown exception was cought !!!");
+ }
+
+ myMeshId = -1;
+ myGroups.clear();
+ mySubMeshes.clear();
+ return aResult;