00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 #include <med.h>
00027 #define MESGERR 1
00028 #include <med_utils.h>
00029 
00030 #ifdef DEF_LECT_ECR
00031 #define MODE_ACCES MED_ACC_RDWR
00032 #elif DEF_LECT_AJOUT
00033 #define MODE_ACCES MED_ACC_RDEXT
00034 #else
00035 #define MODE_ACCES MED_ACC_CREAT
00036 #endif
00037 
00038 int main (int argc, char **argv)
00039 
00040 
00041 {
00042   med_idt fid;
00043   med_int nse2 = 5;
00044   med_int se2[10] = {1,2,1,3,2,4,3,4,2,3};
00045   
00046   char nomse2[MED_SNAME_SIZE*5+1]="se1             se2             se3             se4             se5             ";
00047   med_int numse2[5] = {1,2,3,4,5};
00048   med_int nufase2[5] = {-1,-1,0,-2,-3};
00049   med_int ntr3 = 2;
00050   med_int tr3[6] = {1,2,-5,-5,3,-4};
00051   
00052   char nomtr3[MED_SNAME_SIZE*2+1] = "tr1             tr2             ";
00053   med_int numtr3[2] = {4,5};
00054   med_int nufatr3[2] = {0,-1};
00055   char maa[MED_NAME_SIZE+1] = "maa1";
00056   med_int mdim = 2;
00057   char nomcoo[2*MED_SNAME_SIZE+1] = "x               y               ";
00058   char unicoo[2*MED_SNAME_SIZE+1] = "cm              cm              ";
00059 
00060   
00061   if ((fid = MEDfileOpen("test6.med",MODE_ACCES)) < 0) {
00062     MESSAGE("Impossible de creer le fichier test6.med : ");
00063     return -1;
00064   }
00065 
00066   if (MEDmeshCr( fid, maa, mdim, mdim, MED_UNSTRUCTURED_MESH,
00067                  "un maillage pour test6","s", MED_SORT_DTIT,
00068                  MED_CARTESIAN, nomcoo, unicoo) < 0) {
00069     MESSAGE("Erreur a la creation du maillage : "); SSCRUTE(maa);
00070     return -1;
00071   }
00072 
00073 
00074   
00075   if ( MEDmeshElementConnectivityWr(fid,maa, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
00076                                     MED_DESCENDING_EDGE, MED_SEG2, MED_DESCENDING,
00077                                     MED_FULL_INTERLACE, nse2,se2) < 0 ) {
00078     MESSAGE("Impossible d'ecrire la connectivité des segments: ");
00079     return -1;
00080   }
00081 
00082 
00083 
00084   
00085    if (MEDmeshEntityNameWr(fid,maa,MED_NO_DT,MED_NO_IT,
00086                            MED_DESCENDING_EDGE,MED_SEG2,nse2,nomse2) < 0) {
00087     MESSAGE("Erreur a l'ecriture des noms des segments");
00088     return -1;
00089   }
00090 
00091   
00092   if (MEDmeshEntityNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
00093                             MED_DESCENDING_EDGE,MED_SEG2,nse2,numse2) < 0) {
00094     MESSAGE("Erreur a l'ecriture des numeros des segments");
00095     return -1;
00096   }
00097 
00098   
00099   if (MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
00100                                   MED_DESCENDING_EDGE,MED_SEG2,nse2,nufase2) < 0) {
00101     MESSAGE("Erreur a l'ecriture des numeros de familles des segments");
00102     return -1;
00103   }
00104 
00105   
00106   if ( MEDmeshElementConnectivityWr(fid,maa, MED_NO_DT, MED_NO_IT, MED_UNDEF_DT,
00107                                     MED_CELL, MED_TRIA3, MED_DESCENDING,
00108                                     MED_FULL_INTERLACE, ntr3,tr3) < 0 ) {
00109     MESSAGE("Impossible d'ecrire la connectivité des triangles : ");
00110     return -1;
00111   }
00112 
00113   
00114    if (MEDmeshEntityNameWr(fid,maa,MED_NO_DT,MED_NO_IT,
00115                            MED_CELL, MED_TRIA3,ntr3,nomtr3) < 0) {
00116     MESSAGE("Erreur a l'ecriture des noms des triangles");
00117     return -1;
00118   }
00119 
00120   
00121   if (MEDmeshEntityNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
00122                             MED_CELL, MED_TRIA3,ntr3,numtr3) < 0) {
00123     MESSAGE("Erreur a l'ecriture des numeros des triangles");
00124     return -1;
00125   }
00126 
00127   
00128   if (MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,
00129                                   MED_CELL, MED_TRIA3,ntr3,nufatr3) < 0) {
00130     MESSAGE("Erreur a l'ecriture des numeros de familles des triangles");
00131     return -1;
00132   }
00133 
00134   
00135   if ( MEDfileClose(fid) < 0 ) {
00136     MESSAGE("Impossible de fermerle fichier : ");
00137     return -1;
00138   }
00139 
00140   return 0;
00141  
00142 }
00143 
00144 
00145