Salome HOME
Copyright update 2022
[modules/paravis.git] / src / Plugins / VoroGauss / plugin / VoroGaussModule / vtkVoroGauss.cxx
index afc599546204a292bcb94cd833406880ec0a566e..5379218166d43b88bf93f2177ce78feff5d15f19 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2019  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
@@ -87,7 +87,7 @@ using MEDCoupling::MEDCouplingFieldDouble;
 using MEDCoupling::ON_GAUSS_PT;
 using MEDCoupling::MCAuto;
 
-vtkStandardNewMacro(vtkVoroGauss);
+vtkStandardNewMacro(vtkVoroGauss)
 ///////////////////
 
 std::map<int,int> ComputeMapOfType()
@@ -205,7 +205,7 @@ DataArrayIdType *ConvertVTKArrayToMCArrayInt(vtkDataArray *data)
   vtkIdTypeArray *d2(vtkIdTypeArray::SafeDownCast(data));
   if(d2)
     {
-      const int *pt(d2->GetPointer(0));
+      const vtkIdType *pt(d2->GetPointer(0));
       std::copy(pt,pt+nbElts,ptOut);
       return ret.retn();
     }
@@ -287,13 +287,13 @@ void ConvertFromUnstructuredGrid(vtkUnstructuredGrid *ds, std::vector< MCAuto<ME
   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 INTERP_KERNEL::Exception("ConvertFromUnstructuredGrid : internal error");
   vtkIdTypeArray *cla(ds->GetCellLocationsArray());
-  const vtkIdType *claPtr(cla->GetPointer(0));
+  //const vtkIdType *claPtr(cla->GetPointer(0)); // todo: unused
   if(!cla)
     throw INTERP_KERNEL::Exception("ConvertFromUnstructuredGrid : internal error 2");
   const unsigned char *ctPtr(ct->GetPointer(0));
@@ -315,7 +315,7 @@ void ConvertFromUnstructuredGrid(vtkUnstructuredGrid *ds, std::vector< MCAuto<ME
         }
     }
   MCAuto<DataArrayInt> levs(lev->getDifferentValues());
-  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));
@@ -323,32 +323,31 @@ void ConvertFromUnstructuredGrid(vtkUnstructuredGrid *ds, std::vector< MCAuto<ME
       MCAuto<DataArrayIdType> cellIdsCurLev(lev->findIdsEqual(*curLev));
       for(const mcIdType *cellId=cellIdsCurLev->begin();cellId!=cellIdsCurLev->end();cellId++)
         {
-          std::map<int,int>::iterator it(m.find(ctPtr[*cellId]));
-          vtkIdType offset(claPtr[*cellId]);
-          vtkIdType sz(caPtr[offset]);
+          std::map<int,int>::iterator it(m.find(ds->GetCellType(*cellId)));
           INTERP_KERNEL::NormalizedCellType ct((INTERP_KERNEL::NormalizedCellType)(*it).second);
           if(ct!=INTERP_KERNEL::NORM_POLYHED)
             {
-              std::vector<mcIdType> conn2(sz);
-              for(int kk=0;kk<sz;kk++)
-                conn2[kk]=caPtr[offset+1+kk];
-              m0->insertNextCell(ct,sz,&conn2[0]);
+              vtkIdType szzz(0);
+              const vtkIdType *ptszz(nullptr);
+              ds->GetCellPoints(*cellId, szzz, ptszz);
+              std::vector<mcIdType> conn(ptszz,ptszz+szzz);
+              m0->insertNextCell(ct,szzz,conn.data());
             }
           else
             {
-              if(!faces || !faceLoc)
-                throw INTERP_KERNEL::Exception("ConvertFromUnstructuredGrid : faces are expected when there are polyhedra !");
-              const vtkIdType *facPtr(faces->GetPointer(0)),*facLocPtr(faceLoc->GetPointer(0));
+              // # de faces du polyèdre
+              vtkIdType nbOfFaces(0);
+              // connectivé des faces (numFace0Pts, id1, id2, id3, numFace1Pts,id1, id2, id3, ...)
+              const vtkIdType *facPtr(nullptr);
+              ds->GetFaceStream(*cellId, nbOfFaces, facPtr);
               std::vector<mcIdType> conn;
-              int off0(facLocPtr[*cellId]);
-              int nbOfFaces(facPtr[off0++]);
-              for(int k=0;k<nbOfFaces;k++)
+              for(vtkIdType k=0;k<nbOfFaces;k++)
                 {
-                  int nbOfNodesInFace(facPtr[off0++]);
-                  std::copy(facPtr+off0,facPtr+off0+nbOfNodesInFace,std::back_inserter(conn));
-                  off0+=nbOfNodesInFace;
+                  vtkIdType nbOfNodesInFace(*facPtr++);
+                  std::copy(facPtr,facPtr+nbOfNodesInFace,std::back_inserter(conn));
                   if(k<nbOfFaces-1)
                     conn.push_back(-1);
+                  facPtr+=nbOfNodesInFace;
                 }
               m0->insertNextCell(ct,ToIdType(conn.size()),&conn[0]);
             }
@@ -378,7 +377,7 @@ vtkSmartPointer<vtkUnstructuredGrid> ConvertUMeshFromMCToVTK(const MEDCouplingUM
     {
     case 3:
       {
-        int *cPtr(nullptr),*dPtr(nullptr);
+        vtkIdType *cPtr(nullptr),*dPtr(nullptr);
         unsigned char *aPtr(nullptr);
         vtkSmartPointer<vtkUnsignedCharArray> cellTypes(vtkSmartPointer<vtkUnsignedCharArray>::New());
         {
@@ -460,7 +459,7 @@ vtkSmartPointer<vtkUnstructuredGrid> ConvertUMeshFromMCToVTK(const MEDCouplingUM
           unsigned char *ptr(cellTypes->GetPointer(0));
           std::fill(ptr,ptr+nbCells,zeMapRev[(int)INTERP_KERNEL::NORM_POLYGON]);
         }
-        int *cPtr(0),*dPtr(0);
+        vtkIdType *cPtr(nullptr),*dPtr(nullptr);
         vtkSmartPointer<vtkIdTypeArray> cellLocations(vtkSmartPointer<vtkIdTypeArray>::New());
         {
           cellLocations->SetNumberOfComponents(1);
@@ -495,7 +494,7 @@ vtkSmartPointer<vtkUnstructuredGrid> ConvertUMeshFromMCToVTK(const MEDCouplingUM
           unsigned char *ptr(cellTypes->GetPointer(0));
           std::fill(ptr,ptr+nbCells,zeMapRev[(int)INTERP_KERNEL::NORM_SEG2]);
         }
-        int *cPtr(0),*dPtr(0);
+        vtkIdType *cPtr(nullptr),*dPtr(nullptr);
         vtkSmartPointer<vtkIdTypeArray> cellLocations(vtkSmartPointer<vtkIdTypeArray>::New());
         {
           cellLocations->SetNumberOfComponents(1);
@@ -661,7 +660,7 @@ vtkSmartPointer<vtkUnstructuredGrid> Voronize(const MEDCouplingUMesh *m, const D
           throw INTERP_KERNEL::Exception(oss.str());
         }
       int np(gaussLoc->GetNumberOfQuadraturePoints()),nbPtsPerCell((int)cm.getNumberOfNodes());
-      const double *sfw(gaussLoc->GetShapeFunctionWeights()),*w(gaussLoc->GetQuadratureWeights());;
+      const double /**sfw(gaussLoc->GetShapeFunctionWeights()),*/*w(gaussLoc->GetQuadratureWeights());; // todo: sfw is unused
       std::vector<double> refCoo,posInRefCoo,wCpp(w,w+np);
       FillAdvInfoFrom((*it2).second,GaussAdvData,np,nbPtsPerCell,refCoo,posInRefCoo);
       field->setGaussLocalizationOnType(*it,refCoo,posInRefCoo,wCpp);
@@ -698,7 +697,7 @@ vtkSmartPointer<vtkUnstructuredGrid> Voronize(const MEDCouplingUMesh *m, const D
         }
       if(elt4)
         {
-          vtkSmartPointer<vtkIdTypeArray> arr(ExtractFieldFieldArr<vtkIdTypeArray,int>(elt4,zeSizeOfOutCellArr,nbOfCellsOfInput,myOffsetsPtr,nbPtsPerCellArrPtr));
+          vtkSmartPointer<vtkIdTypeArray> arr(ExtractFieldFieldArr<vtkIdTypeArray,vtkIdType>(elt4,zeSizeOfOutCellArr,nbOfCellsOfInput,myOffsetsPtr,nbPtsPerCellArrPtr));
           ret->GetCellData()->AddArray(arr);
           continue;
         }
@@ -723,7 +722,7 @@ vtkSmartPointer<vtkUnstructuredGrid> Voronize(const MEDCouplingUMesh *m, const D
         }
       if(elt4)
         {
-          vtkSmartPointer<vtkIdTypeArray> arr(ExtractCellFieldArr<vtkIdTypeArray,int>(elt4,zeSizeOfOutCellArr,nbOfCellsOfInput,ids->begin(),nbPtsPerCellArrPtr));
+          vtkSmartPointer<vtkIdTypeArray> arr(ExtractCellFieldArr<vtkIdTypeArray,vtkIdType>(elt4,zeSizeOfOutCellArr,nbOfCellsOfInput,ids->begin(),nbPtsPerCellArrPtr));
           ret->GetCellData()->AddArray(arr);
           continue;
         }
@@ -839,7 +838,7 @@ vtkVoroGauss::~vtkVoroGauss()
 {
 }
 
-int vtkVoroGauss::RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
+int vtkVoroGauss::RequestInformation(vtkInformation * /*request*/, vtkInformationVector **inputVector, vtkInformationVector * /*outputVector*/)
 { 
   //std::cerr << "########################################## vtkVoroGauss::RequestInformation ##########################################" << std::endl;
   try
@@ -861,7 +860,7 @@ int vtkVoroGauss::RequestInformation(vtkInformation *request, vtkInformationVect
   return 1;
 }
 
-int vtkVoroGauss::RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
+int vtkVoroGauss::RequestData(vtkInformation * /*request*/, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
 {
   //std::cerr << "########################################## vtkVoroGauss::RequestData        ##########################################" << std::endl;
   try
@@ -875,7 +874,7 @@ int vtkVoroGauss::RequestData(vtkInformation *request, vtkInformationVector **in
       ExtractInfo(inputVector[0],usgIn);
       //
       vtkSmartPointer<vtkUnstructuredGrid> ret(ComputeVoroGauss(usgIn,GaussAdvData));
-      vtkInformation *inInfo(inputVector[0]->GetInformationObject(0));
+      //vtkInformation *inInfo(inputVector[0]->GetInformationObject(0)); // todo: unused
       vtkInformation *outInfo(outputVector->GetInformationObject(0));
       vtkUnstructuredGrid *output(vtkUnstructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())));
       output->ShallowCopy(ret);