Salome HOME
MEDReader ready -> debug in process
[tools/medcoupling.git] / src / RENUMBER / renumbering.cxx
index d429b2cffd310e030c4234fa1b2967c01bbcd330..ce86bde6e44e2c638b89ce2e8a4959c6ae8caeee 100644 (file)
@@ -81,6 +81,7 @@ int main(int argc, char** argv)
   Renumbering *renumb=RenumberingFactory(type_renum);
   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,10 +101,26 @@ int main(int argc, char** argv)
   // Fields
   cout << "Reordering fields and writing : " << flush;
   MEDFileFields *fs=fd->getFields();
-  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n=DataArrayInt::New();
-  o2n->useArray(&perm[0],false,CPP_DEALLOC,perm.size(),1);
-  fs->renumberEntitiesLyingOnMesh(meshname.c_str(),code,code,o2n);
-  fs->write(filename_out.c_str(),0);
+  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;