Salome HOME
Copyright update 2022
[modules/paravis.git] / src / Plugins / MEDWriter / plugin / MEDWriterIO / VTKToMEDMem.cxx
index 6f4644828bd2193c5739e879e6ca0ae4147622f9..ffdb58115b55a61e144421eaff08dbb75c1787ae 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2020  CEA/DEN, EDF R&D
+// Copyright (C) 2017-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -23,6 +23,7 @@
 #include "vtkAdjacentVertexIterator.h"
 #include "vtkIntArray.h"
 #include "vtkLongArray.h"
+#include "vtkLongLongArray.h"
 #include "vtkCellData.h"
 #include "vtkPointData.h"
 #include "vtkFloatArray.h"
@@ -72,7 +73,8 @@ using MEDCoupling::MEDFileUMesh;
 using MEDCoupling::MEDFileFields;
 using MEDCoupling::MEDFileMeshes;
 
-using MEDCoupling::MEDFileIntField1TS;
+using MEDCoupling::MEDFileInt32Field1TS;
+using MEDCoupling::MEDFileInt64Field1TS;
 using MEDCoupling::MEDFileField1TS;
 using MEDCoupling::MEDFileIntFieldMultiTS;
 using MEDCoupling::MEDFileFieldMultiTS;
@@ -88,6 +90,7 @@ using MEDCoupling::MEDCouplingCMesh;
 using MEDCoupling::MEDCouplingFieldDouble;
 using MEDCoupling::MEDCouplingFieldFloat;
 using MEDCoupling::MEDCouplingFieldInt;
+using MEDCoupling::MEDCouplingFieldInt64;
 using MEDCoupling::MCAuto;
 using MEDCoupling::Traits;
 using MEDCoupling::MLFieldTraits;
@@ -161,6 +164,13 @@ DataArrayIdType *ConvertVTKArrayToMCArrayInt(vtkDataArray *data)
       std::copy(pt,pt+nbElts,ptOut);
       return ret.retn();
     }
+  vtkLongLongArray *d1l(vtkLongLongArray::SafeDownCast(data));
+  if(d1l)
+    {
+      const long long *pt(d1l->GetPointer(0));
+      std::copy(pt,pt+nbElts,ptOut);
+      return ret.retn();
+    }
   vtkIdTypeArray *d3(vtkIdTypeArray::SafeDownCast(data));
   if(d3)
     {
@@ -249,7 +259,8 @@ DataArray *ConvertVTKArrayToMCArray(vtkDataArray *data)
   vtkLongArray *d3(vtkLongArray::SafeDownCast(data));
   vtkUnsignedCharArray *d4(vtkUnsignedCharArray::SafeDownCast(data));
   vtkIdTypeArray *d5(vtkIdTypeArray::SafeDownCast(data));
-  if(d2 || d3 || d4 || d5)
+  vtkLongLongArray *d6(vtkLongLongArray::SafeDownCast(data));
+  if(d2 || d3 || d4 || d5 || d6)
     return ConvertVTKArrayToMCArrayInt(data);
   std::ostringstream oss;
   oss << "ConvertVTKArrayToMCArray : unrecognized array \"" << typeid(*data).name() << "\" type !";
@@ -263,7 +274,7 @@ MEDCouplingUMesh *BuildMeshFromCellArray(vtkCellArray *ca, DataArrayDouble *coor
   int nbCells(ca->GetNumberOfCells());
   if(nbCells==0)
     return 0;
-  vtkIdType nbEntries(ca->GetNumberOfConnectivityEntries());
+  //vtkIdType nbEntries(ca->GetNumberOfConnectivityEntries()); // todo: unused
   const vtkIdType *conn(ca->GetData()->GetPointer(0));
   for(int i=0;i<nbCells;i++)
     {
@@ -284,7 +295,7 @@ MEDCouplingUMesh *BuildMeshFromCellArrayTriangleStrip(vtkCellArray *ca, DataArra
   int nbCells(ca->GetNumberOfCells());
   if(nbCells==0)
     return 0;
-  vtkIdType nbEntries(ca->GetNumberOfConnectivityEntries());
+  //vtkIdType nbEntries(ca->GetNumberOfConnectivityEntries()); // todo: unused
   const vtkIdType *conn(ca->GetData()->GetPointer(0));
   ids=DataArrayIdType::New() ; ids->alloc(0,1);
   for(int i=0;i<nbCells;i++)
@@ -408,8 +419,9 @@ void AppendMCFieldFrom(MEDCoupling::TypeOfField tf, MEDCouplingMesh *mesh, MEDFi
       if((fieldName!=FAMFIELD_FOR_CELLS || tf!=MEDCoupling::ON_CELLS) && (fieldName!=FAMFIELD_FOR_NODES || tf!=MEDCoupling::ON_NODES))
         {
           if(!dai)
-            throw MZCException("AppendMCFieldFrom : internal error 3 (not int32) !");
-          AppendToFields<int>(tf,mesh,n2oPtr,dai,fs,timeStep,tsId);
+            AppendToFields<mcIdType>(tf,mesh,n2oPtr,daId,fs,timeStep,tsId);
+          else
+            AppendToFields<int>(tf,mesh,n2oPtr,dai,fs,timeStep,tsId);
           return ;
         }
       else if(fieldName==FAMFIELD_FOR_CELLS && tf==MEDCoupling::ON_CELLS)
@@ -456,7 +468,7 @@ void PutAtLevelDealOrder(MEDFileData *mfd, int meshDimRel, const MicroField& mf,
   MCAuto<MEDCouplingUMesh> mesh(mf.getMesh());
   mesh->setName(mfd->getMeshes()->getMeshAtPos(0)->getName());
   MCAuto<DataArrayIdType> o2n(mesh->sortCellsInMEDFileFrmt());
-  const DataArrayIdType *o2nPtr(o2n);
+  //const DataArrayIdType *o2nPtr(o2n); // todo: unused
   MCAuto<DataArrayIdType> n2o;
   mmu->setMeshAtLevel(meshDimRel,mesh);
   const DataArrayIdType *n2oPtr(0);
@@ -569,8 +581,8 @@ std::vector<MCAuto<DataArray> > AddPartFields(const DataArrayIdType *part, vtkDa
       if(!arr)
         continue;
       const char *name(arr->GetName());
-      int nbCompo(arr->GetNumberOfComponents());
-      vtkIdType nbTuples(arr->GetNumberOfTuples());
+      //int nbCompo(arr->GetNumberOfComponents()); // todo: unused
+      //vtkIdType nbTuples(arr->GetNumberOfTuples()); // todo: unused
       MCAuto<DataArray> mcarr(ConvertVTKArrayToMCArray(arr));
       if(part)
         mcarr=mcarr->selectByTupleId(part->begin(),part->end());
@@ -592,8 +604,8 @@ std::vector<MCAuto<DataArray> > AddPartFields2(int bg, int end, vtkDataSetAttrib
       if(!arr)
         continue;
       const char *name(arr->GetName());
-      int nbCompo(arr->GetNumberOfComponents());
-      vtkIdType nbTuples(arr->GetNumberOfTuples());
+      //int nbCompo(arr->GetNumberOfComponents()); // todo: unused
+      //vtkIdType nbTuples(arr->GetNumberOfTuples()); // todo: unused
       MCAuto<DataArray> mcarr(ConvertVTKArrayToMCArray(arr));
       mcarr=mcarr->selectByTupleIdSafeSlice(bg,end,1);
       mcarr->setName(name);
@@ -743,13 +755,13 @@ void ConvertFromUnstructuredGrid(MEDFileData *ret, vtkUnstructuredGrid *ds, cons
   vtkCellArray *ca(ds->GetCells());
   if(!ca)
     return ;
-  vtkIdType nbEnt(ca->GetNumberOfConnectivityEntries());
-  vtkIdType *caPtr(ca->GetData()->GetPointer(0));
+  //vtkIdType nbEnt(ca->GetNumberOfConnectivityEntries()); // todo: unused
+  //vtkIdType *caPtr(ca->GetData()->GetPointer(0)); // todo: unused
   vtkUnsignedCharArray *ct(ds->GetCellTypesArray());
   if(!ct)
     throw MZCException("ConvertFromUnstructuredGrid : internal error");
   vtkIdTypeArray *cla(ds->GetCellLocationsArray());
-  const vtkIdType *claPtr(cla->GetPointer(0));
+  //const vtkIdType *claPtr(cla->GetPointer(0)); // todo: unused
   if(!cla)
     throw MZCException("ConvertFromUnstructuredGrid : internal error 2");
   const unsigned char *ctPtr(ct->GetPointer(0));
@@ -778,10 +790,9 @@ void ConvertFromUnstructuredGrid(MEDFileData *ret, vtkUnstructuredGrid *ds, cons
             }
         }
     }
-  int dummy(0);
   MCAuto<DataArrayInt> levs(lev->getDifferentValues());
   std::vector< MicroField > ms;
-  vtkIdTypeArray *faces(ds->GetFaces()),*faceLoc(ds->GetFaceLocations());
+  //vtkIdTypeArray *faces(ds->GetFaces()),*faceLoc(ds->GetFaceLocations()); // todo: unused
   for(const int *curLev=levs->begin();curLev!=levs->end();curLev++)
     {
       MCAuto<MEDCouplingUMesh> m0(MEDCouplingUMesh::New("",*curLev));