- /* nombre de familles */
- nfam = MEDnFam(myFileId,nommaa,0,MED_FAMILLE);
- if (nfam < 0)
- {
- fprintf(stderr,">> ERREUR : lecture du nombre de familles \n");
- exit(EXIT_FAILURE);
- }
- fprintf(stdout,"- Nombre de familles : %d \n",nfam);
-
- vector<int> family[nfam];
-
- /****************************************************************************
- * LECTURE DES NOEUDS *
- ****************************************************************************/
- fprintf(stdout,"\n(************************)\n");
- fprintf(stdout,"(* NOEUDS DU MAILLAGE : *)\n");
- fprintf(stdout,"(************************)\n");
-
- /* Allocations memoires */
- /* table des coordonnees
- profil : (dimension * nombre de noeuds ) */
- coo = (med_float*) malloc(sizeof(med_float)*nnoe*mdim);
- /* table des numeros, des numeros de familles des noeuds
- profil : (nombre de noeuds) */
- numnoe = (med_int*) malloc(sizeof(med_int)*nnoe);
- nufano = (med_int*) malloc(sizeof(med_int)*nnoe);
- /* table des noms des noeuds
- profil : (nnoe*MED_TAILLE_PNOM+1) */
- nomnoe = (char*) malloc(MED_TAILLE_PNOM*nnoe+1);
-
- /* lecture des noeuds :
- - coordonnees
- - noms (optionnel dans un fichier MED)
- - numeros (optionnel dans un fichier MED)
- - numeros des familles */
- ret = MEDnoeudsLire(myFileId,nommaa,mdim,coo,mode_coo,&rep,
- nomcoo,unicoo,nomnoe,&inonoe,numnoe,&inunoe,
- nufano,nnoe);
- if (ret < 0)
- strcpy(message,">> ERREUR : lecture des noeuds \n");
-
- if (inunoe) {
- for (int i=0;i<nnoe;i++) {
- ok = mySMESHDSMesh->AddNodeWithID(coo[i*3],coo[i*3+1],coo[i*3+2],numnoe[i]);
- //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],coo[i*3+2]);
- }
- }
- else {
- for (int i=0;i<nnoe;i++) {
- ok = mySMESHDSMesh->AddNodeWithID(coo[i*3],coo[i*3+1],coo[i*3+2],i+1);
- //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],i);
- family[*(nufano+i)].push_back(numnoe[i]);
- }
- }
-
- fprintf(stdout,"\n- Numeros des familles des noeuds : \n");
- for (i=0;i<nnoe;i++)
- fprintf(stdout," %d ",*(nufano+i));
- fprintf(stdout,"\n");
-
- /* liberation memoire */
- free(coo);
- free(nomnoe);
- free(numnoe);
- free(nufano);
-
- /****************************************************************************
- * LECTURE DES ELEMENTS *
- ****************************************************************************/
- fprintf(stdout,"\n(**************************)\n");
- fprintf(stdout,"(* ELEMENTS DU MAILLAGE : *)\n");
- fprintf(stdout,"(**************************)");
- //fprintf(Out,"CELLS\n");
- /* Lecture des connectivites, noms, numeros des mailles */
- //printf("%d %d %d %d\n",nmailles[3],nmailles[4],nmailles[5],nmailles[9]);
-
- if (ret == 0)
- for (i=0;i<MED_NBR_GEOMETRIE_MAILLE;i++)
- {
- if (nmailles[i] > 0 && ret == 0)
- {
- /* dimension de la maille */
- edim = typmai[i] / 100;
- nsup = 0;
- if (mdim == 2 || mdim == 3)
- if (edim == 1)
- nsup = 1;
- if (mdim == 3)
- if (edim == 2)
- nsup = 1;
-
- taille = nsup+typmai[i]%100;
- //taille = typmai[i]%100;
-
- /* allocation memoire */
- connectivite = (med_int*)malloc(sizeof(med_int)*
- taille*nmailles[i]);
- nomele = (char*)malloc(sizeof(char)*MED_TAILLE_PNOM*
- nmailles[i]+1);
- numele = (med_int*)malloc(sizeof(med_int)*
- nmailles[i]);
- nufael = (med_int*)malloc(sizeof(med_int)*
- nmailles[i]);
-
- /* lecture des données */
- ret = MEDelementsLire(myFileId,nommaa,mdim,connectivite,mode_coo,
- nomele,&inoele,numele,&inuele,nufael,
- nmailles[i],MED_MAILLE,typmai[i],
- typ_con);
-
- switch (typmai[i])
- {
- case MED_TRIA3 : {
- if (inuele) {
- for (j=0;j<nmailles[i];j++) {
- elem_id=*(numele+j);
- ok = mySMESHDSMesh->AddFaceWithID(*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),elem_id);
- //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2));
+ EBooleen anIsNodeNum = aNodeInfo->IsElemNum();
+ TInt aNbElems = aNodeInfo->GetNbElem();
+ if(MYDEBUG) MESSAGE("Perform - aNodeInfo->GetNbElem() = "<<aNbElems<<"; anIsNodeNum = "<<anIsNodeNum);
+ DriverMED_FamilyPtr aFamily = myFamilies.begin()->second;
+ for(TInt iElem = 0; iElem < aNbElems; iElem++){
+ double aCoords[3] = {0.0, 0.0, 0.0};
+ for(TInt iDim = 0; iDim < 3; iDim++)
+ aCoords[iDim] = aCoordHelperPtr->GetCoord(iElem,iDim);
+ const SMDS_MeshNode* aNode;
+ if(anIsNodeNum) {
+ aNode = myMesh->AddNodeWithID
+ (aCoords[0],aCoords[1],aCoords[2],aNodeInfo->GetElemNum(iElem));
+ } else {
+ aNode = myMesh->AddNode
+ (aCoords[0],aCoords[1],aCoords[2]);
+ }
+ //cout<<aNode->GetID()<<": "<<aNode->X()<<", "<<aNode->Y()<<", "<<aNode->Z()<<endl;
+
+ // Save reference to this node from its family
+ TInt aFamNum = aNodeInfo->GetFamNum(iElem);
+ if ( checkFamilyID ( aFamily, aFamNum ))
+ {
+ aFamily->AddElement(aNode);
+ aFamily->SetType(SMDSAbs_Node);
+ }
+ }
+
+ // Reading pre information about all MED cells
+ //--------------------------------------------
+ bool takeNumbers = true; // initially we trust the numbers from file
+ MED::TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo);
+ MED::TEntityInfo::iterator anEntityIter = aEntityInfo.begin();
+ for(; anEntityIter != aEntityInfo.end(); anEntityIter++){
+ const EEntiteMaillage& anEntity = anEntityIter->first;
+ if(anEntity == eNOEUD) continue;
+ // Reading MED cells to the corresponding SMDS structure
+ //------------------------------------------------------
+ const MED::TGeom& aTGeom = anEntityIter->second;
+ MED::TGeom::const_iterator anTGeomIter = aTGeom.begin();
+ for(; anTGeomIter != aTGeom.end(); anTGeomIter++){
+ const EGeometrieElement& aGeom = anTGeomIter->first;
+
+ if (aGeom == ePOINT1) {
+ continue;
+
+ } else if (aGeom == ePOLYGONE) {
+ PPolygoneInfo aPolygoneInfo = aMed->GetPPolygoneInfo(aMeshInfo,anEntity,aGeom);
+ EBooleen anIsElemNum = takeNumbers ? aPolygoneInfo->IsElemNum() : eFAUX;
+
+ TElemNum aConn = aPolygoneInfo->GetConnectivite();
+ TElemNum aIndex = aPolygoneInfo->GetIndex();
+
+ TInt nbPolygons = aPolygoneInfo->GetNbElem();
+
+ for (TInt iPG = 0; iPG < nbPolygons; iPG++) {
+ // get nodes
+ TInt aCurrPG_FirstNodeIndex = aIndex[iPG] - 1;
+ int nbNodes = aPolygoneInfo->GetNbConn(iPG);
+ std::vector<int> nodes_ids (nbNodes);
+ //for (TInt inode = 0; inode < nbNodes; inode++) {
+ // nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode];
+ //}
+#ifdef _EDF_NODE_IDS_
+ if (anIsNodeNum) {
+ for (TInt inode = 0; inode < nbNodes; inode++) {
+ nodes_ids[inode] = aNodeInfo->GetElemNum(aConn[aCurrPG_FirstNodeIndex + inode] - 1);
+ }
+ } else {
+ for (TInt inode = 0; inode < nbNodes; inode++) {
+ nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode];