Salome HOME
OK thanks to INV !
[modules/med.git] / src / RENUMBER / renumbering.cxx
index 765fb7f8f87622d67b28440eab04651edba2e7b7..ce86bde6e44e2c638b89ce2e8a4959c6ae8caeee 100644 (file)
@@ -57,7 +57,7 @@ int main(int argc, char** argv)
     }
   // Reading file structure
   cout << "Reading : " << flush;
-  MEDCouplingAutoRefCountObjectPtr<MEDFileData> fd=MEDFileData::New(filename_in);
+  MEDCouplingAutoRefCountObjectPtr<MEDFileData> fd=MEDFileData::New(filename_in.c_str());
   MEDFileMesh *m=fd->getMeshes()->getMeshWithName(meshname.c_str());
   MEDFileUMesh *mc=dynamic_cast<MEDFileUMesh *>(m);
   if(!mc)
@@ -79,8 +79,9 @@ int main(int argc, char** argv)
   // Compute permutation iperm->new2old perm->old2new
   vector<int> iperm,perm;
   Renumbering *renumb=RenumberingFactory(type_renum);
-  renumb->renumber(graph,graph_index,nb_cell,iperm,perm);
+  renumb->renumber(graph,graph_index,workMesh->getNumberOfCells(),iperm,perm);
   delete renumb;
+  iperm.clear();//erase new2old, we are using only old 2 new
   t_compute_graph=clock();
   cout << " : " << (t_compute_graph-t_read_st)/(double) CLOCKS_PER_SEC << "s" << endl;
   cout.flush();
@@ -100,8 +101,26 @@ int main(int argc, char** argv)
   // Fields
   cout << "Reordering fields and writing : " << flush;
   MEDFileFields *fs=fd->getFields();
-  fs->renumberEntitiesLyingOnMesh(meshname.c_str(),code,code,&perm[0]);
-  fs->write();
+  if(fs)
+    {
+      for(int i=0;i<fs->getNumberOfFields();i++)
+        {
+          MEDFileFieldMultiTS *fmts=dynamic_cast<MEDFileFieldMultiTS *>(fs->getFieldAtPos(i));
+         if(!fmts) continue;
+          if(fmts->getMeshName()==meshname)
+            {
+              for(int j=0;j<fmts->getNumberOfTS();j++)
+                {
+                  MEDFileField1TS *f1ts=dynamic_cast<MEDFileField1TS*>(fmts->getTimeStepAtPos(j));
+                 if(!f1ts) continue;
+                  DataArrayDouble *arr=f1ts->getUndergroundDataArray();
+                  arr->renumberInPlace(&perm[0]);
+                }
+            }
+        }
+      fs->write(filename_out.c_str(),0);
+      //fs->renumberEntitiesLyingOnMesh(meshname.c_str(),code,code,o2n); bugged
+    }
   t_field=clock();
   cout << " : " << (t_field-t_family)/(double) CLOCKS_PER_SEC << "s" << endl << flush;
   return 0;