From 9c7c33f2c238193c69e527e4817df807a74b2068 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 19 Dec 2019 16:30:10 +0300 Subject: [PATCH] LOT7: fix compilation at med_int==int64 --- src/Plugins/DevelopedSurface/CMakeLists.txt | 5 ++ .../IO/vtkDevelopedSurface.cxx | 15 ++-- .../vtkElevationSurfaceFilter.cxx | 2 +- .../vtkEllipseBuilderFilter.cxx | 4 +- src/Plugins/GaussToCell/CMakeLists.txt | 4 + src/Plugins/GaussToCell/vtkGaussToCell.cxx | 3 +- src/Plugins/MEDReader/CMakeLists.txt | 4 + .../IO/MEDFileFieldRepresentationTree.cxx | 83 ++++++++++++------- .../MEDReader/IO/vtkExtractCellType.cxx | 2 +- src/Plugins/MEDReader/IO/vtkExtractGroup.cxx | 15 ++-- .../MEDReader/IO/vtkGenerateVectors.cxx | 8 +- src/Plugins/MEDReader/IO/vtkMEDReader.cxx | 12 +-- .../MEDReader/ParaViewPlugin/CMakeLists.txt | 5 +- .../ParaViewPlugin/VectBoolSpreadSheet.cxx | 8 +- .../pqMEDReaderTimesFlagsWidget.cxx | 8 +- src/Plugins/MEDWriter/CMakeLists.txt | 4 + src/Plugins/MEDWriter/IO/VTKMEDTraits.hxx | 15 +++- src/Plugins/MEDWriter/IO/VTKToMEDMem.cxx | 72 +++++++++------- src/Plugins/MEDWriter/IO/VTKToMEDMem.hxx | 12 +-- .../VTKMEDCouplingUMeshClient.cxx | 8 +- .../ParaMEDCorba/vtkParaMEDCorbaSource.cxx | 4 +- src/Plugins/VoroGauss/CMakeLists.txt | 4 + src/Plugins/VoroGauss/IO/vtkVoroGauss.cxx | 76 ++++++++--------- 23 files changed, 224 insertions(+), 149 deletions(-) diff --git a/src/Plugins/DevelopedSurface/CMakeLists.txt b/src/Plugins/DevelopedSurface/CMakeLists.txt index 6b4eb8b0..3a592742 100644 --- a/src/Plugins/DevelopedSurface/CMakeLists.txt +++ b/src/Plugins/DevelopedSurface/CMakeLists.txt @@ -55,6 +55,11 @@ LIST(APPEND CMAKE_MODULE_PATH "${MEDCOUPLING_ROOT_DIR}/cmake_files") ## FIND_PACKAGE(SalomeMEDCoupling REQUIRED) +IF(MEDCOUPLING_USE_64BIT_IDS) + ADD_DEFINITIONS("-DMEDCOUPLING_USE_64BIT_IDS") +ENDIF(MEDCOUPLING_USE_64BIT_IDS) + + OPTION(BUILD_SHARED_LIBS "Build with shared libraries." ${VTK_BUILD_SHARED_LIBS}) SET(VTK_INSTALL_RUNTIME_DIR lib) diff --git a/src/Plugins/DevelopedSurface/IO/vtkDevelopedSurface.cxx b/src/Plugins/DevelopedSurface/IO/vtkDevelopedSurface.cxx index 2eb9ec5f..04b25eff 100644 --- a/src/Plugins/DevelopedSurface/IO/vtkDevelopedSurface.cxx +++ b/src/Plugins/DevelopedSurface/IO/vtkDevelopedSurface.cxx @@ -23,6 +23,7 @@ #include "vtkAdjacentVertexIterator.h" #include "vtkIntArray.h" +#include "vtkLongArray.h" #include "vtkCellData.h" #include "vtkPointData.h" #include "vtkCylinder.h" @@ -177,9 +178,9 @@ int vtkDevelopedSurface::RequestInformation(vtkInformation *request, vtkInformat return 1; } -std::vector UnWrapByDuplicatingNodes(vtkCellArray *ca, vtkIdType& offset, const MEDCoupling::DataArrayDouble *thetas) +std::vector UnWrapByDuplicatingNodes(vtkCellArray *ca, vtkIdType& offset, const MEDCoupling::DataArrayDouble *thetas) { - std::vector ret; + std::vector ret; vtkIdType nbCells(ca->GetNumberOfCells()); vtkIdType *conn(ca->GetPointer()); const double *tptr(thetas->begin()); @@ -298,11 +299,11 @@ void dealWith(vtkPolyData *outdata, const double center[3], const double axis[3] throw MZCException("Expecting unstructured one !"); MEDCoupling::MCAuto m0(mmu->getMeshAtLevel(0)); { - int v(0); - MEDCoupling::MCAuto c0s(m0->getCellIdsLyingOnNodes(&v,&v+1,false)); + mcIdType v(0); + MEDCoupling::MCAuto c0s(m0->getCellIdsLyingOnNodes(&v,&v+1,false)); if(c0s->empty()) throw MZCException("Orphan node 0 !"); - std::vector nodes0; + std::vector nodes0; m0->getNodeIdsOfCell(c0s->getIJ(0,0),nodes0); MEDCoupling::MCAuto tmp0(c_cyl->selectByTupleIdSafe(nodes0.data(),nodes0.data()+nodes0.size())); tmp0=tmp0->keepSelectedComponents({1}); @@ -343,7 +344,7 @@ void dealWith(vtkPolyData *outdata, const double center[3], const double axis[3] { MEDCoupling::MCAuto c_cyl_2(c_cyl->keepSelectedComponents({1})); c_cyl_2->abs(); - MEDCoupling::MCAuto poses(c_cyl_2->findIdsInRange(0.,eps)); + MEDCoupling::MCAuto poses(c_cyl_2->findIdsInRange(0.,eps)); c_cyl->setPartOfValuesSimple3(0.,poses->begin(),poses->end(),1,2,1); } // @@ -365,7 +366,7 @@ void dealWith(vtkPolyData *outdata, const double center[3], const double axis[3] } vtkCellArray *cb(outdata->GetPolys()); vtkIdType offset(nbNodes); - std::vector dupNodes(UnWrapByDuplicatingNodes(cb,offset,c_cyl_post)); + std::vector dupNodes(UnWrapByDuplicatingNodes(cb,offset,c_cyl_post)); // MEDCoupling::MCAuto c_cyl_post2(c_cyl_post->selectByTupleId(dupNodes.data(),dupNodes.data()+dupNodes.size())); c_cyl_post2->applyLin(1.,2*M_PI); diff --git a/src/Plugins/ElevationSurface/vtkElevationSurfaceFilter.cxx b/src/Plugins/ElevationSurface/vtkElevationSurfaceFilter.cxx index e0a04a72..e102b351 100644 --- a/src/Plugins/ElevationSurface/vtkElevationSurfaceFilter.cxx +++ b/src/Plugins/ElevationSurface/vtkElevationSurfaceFilter.cxx @@ -191,7 +191,7 @@ int vtkElevationSurfaceFilter::RequestData(vtkInformation *request, continue; unsigned char newCellType = VTK_EMPTY_CELL; - unsigned char oldCellType = cell->GetCellType(); + unsigned char oldCellType = (unsigned char)cell->GetCellType(); switch(oldCellType) { case VTK_TRIANGLE : diff --git a/src/Plugins/EllipseBuilder/vtkEllipseBuilderFilter.cxx b/src/Plugins/EllipseBuilder/vtkEllipseBuilderFilter.cxx index b3b5e236..dbeb7ac5 100644 --- a/src/Plugins/EllipseBuilder/vtkEllipseBuilderFilter.cxx +++ b/src/Plugins/EllipseBuilder/vtkEllipseBuilderFilter.cxx @@ -234,7 +234,7 @@ int vtkEllipseBuilderFilter::RequestData(vtkInformation* vtkNotUsed(request), y = y / aScaleFactor; double x_point, y_point; - for (int r = 0; r < circle.size(); r++) + for (std::size_t r = 0; r < circle.size(); r++) { x_point = (x*circle[r]).real(); y_point = (y*circle[r]).real(); @@ -284,7 +284,7 @@ int vtkEllipseBuilderFilter::RequestInformation(vtkInformation* request, anIter->Delete(); this->FieldList->Reset(); - this->FieldList->SetNumberOfValues(aList.size()); + this->FieldList->SetNumberOfValues((vtkIdType)aList.size()); list::const_iterator anIterName; int i = 0; for (anIterName = aList.begin(); anIterName != aList.end(); anIterName++) diff --git a/src/Plugins/GaussToCell/CMakeLists.txt b/src/Plugins/GaussToCell/CMakeLists.txt index 1701f21b..347a9bc5 100644 --- a/src/Plugins/GaussToCell/CMakeLists.txt +++ b/src/Plugins/GaussToCell/CMakeLists.txt @@ -51,6 +51,10 @@ SET(MEDCOUPLING_ROOT_DIR $ENV{MEDCOUPLING_ROOT_DIR} CACHE PATH "MEDCOUPLING_ROOT LIST(APPEND CMAKE_MODULE_PATH "${MEDCOUPLING_ROOT_DIR}/cmake_files") FIND_PACKAGE(SalomeMEDCoupling REQUIRED) +IF(MEDCOUPLING_USE_64BIT_IDS) + ADD_DEFINITIONS("-DMEDCOUPLING_USE_64BIT_IDS") +ENDIF(MEDCOUPLING_USE_64BIT_IDS) + OPTION(BUILD_SHARED_LIBS "Build with shared libraries." ${VTK_BUILD_SHARED_LIBS}) SET(VTK_INSTALL_RUNTIME_DIR lib) diff --git a/src/Plugins/GaussToCell/vtkGaussToCell.cxx b/src/Plugins/GaussToCell/vtkGaussToCell.cxx index 74b17f51..d3873c9d 100644 --- a/src/Plugins/GaussToCell/vtkGaussToCell.cxx +++ b/src/Plugins/GaussToCell/vtkGaussToCell.cxx @@ -76,7 +76,8 @@ #include using MEDCoupling::DataArray; -using MEDCoupling::DataArrayInt; +using MEDCoupling::DataArrayInt32; +using MEDCoupling::DataArrayInt64; using MEDCoupling::DataArrayDouble; using MEDCoupling::MEDCouplingMesh; using MEDCoupling::MEDCouplingUMesh; diff --git a/src/Plugins/MEDReader/CMakeLists.txt b/src/Plugins/MEDReader/CMakeLists.txt index 71ea1189..e53cbece 100644 --- a/src/Plugins/MEDReader/CMakeLists.txt +++ b/src/Plugins/MEDReader/CMakeLists.txt @@ -81,6 +81,10 @@ FIND_PACKAGE(SalomeHDF5 REQUIRED) FIND_PACKAGE(SalomeMEDCoupling REQUIRED) FIND_PACKAGE(SalomeMEDFile REQUIRED) +IF(MEDCOUPLING_USE_64BIT_IDS) + ADD_DEFINITIONS("-DMEDCOUPLING_USE_64BIT_IDS") +ENDIF(MEDCOUPLING_USE_64BIT_IDS) + SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS} ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}) SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}) diff --git a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx index 8048ca55..891814ef 100644 --- a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx +++ b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx @@ -27,6 +27,7 @@ #include "InterpKernelGaussCoords.hxx" #include "MEDFileData.hxx" #include "SauvReader.hxx" +#include "MEDCouplingMemArray.txx" #ifdef MEDREADER_USE_MPI #include "ParaMEDFileMesh.hxx" @@ -46,6 +47,7 @@ #include "vtkIdTypeArray.h" #include "vtkDoubleArray.h" #include "vtkIntArray.h" +#include "vtkLongArray.h" #include "vtkFloatArray.h" #include "vtkCellArray.h" #include "vtkPointData.h" @@ -167,7 +169,7 @@ vtkIdTypeArray *ELGACmp::createNew(const MEDCoupling::MEDFileFieldGlobsReal *glo for(vtkIdType cellId=0;cellIdGetCell(cellId)); - int delta(m[cell->GetCellType()]); + int delta(m[(unsigned char)cell->GetCellType()]); pt[cellId]=offset; offset+=delta; } @@ -219,6 +221,14 @@ public: typedef MEDCoupling::DataArrayInt MCType; }; +template<> +class MEDFileVTKTraits +{ +public: + typedef vtkLongArray VtkType; + typedef MEDCoupling::DataArrayInt64 MCType; +}; + template<> class MEDFileVTKTraits { @@ -235,6 +245,9 @@ public: typedef MEDCoupling::DataArrayDouble MCType; }; +typedef typename MEDFileVTKTraits::VtkType vtkMCIdTypeArray; + + template void AssignDataPointerToVTK(typename MEDFileVTKTraits::VtkType *vtkTab, typename MEDFileVTKTraits::MCType *mcTab, bool noCpyNumNodes) { @@ -248,8 +261,18 @@ void AssignDataPointerToVTK(typename MEDFileVTKTraits::VtkType *vtkTab, typen template void AssignDataPointerOther(VTKT *vtkTab, MCT *mcTab, int nbElems) { - vtkTab->SetVoidArray(reinterpret_cast(mcTab->getPointer()),nbElems,0,VTKT::VTK_DATA_ARRAY_FREE); - mcTab->accessToMemArray().setSpecificDeallocator(0); + typedef typename VTKT::ValueType VTKType; + if ( sizeof( VTKType ) == sizeof( typename MCT::Type )) + { + vtkTab->SetVoidArray(reinterpret_cast(mcTab->getPointer()),nbElems,0,VTKT::VTK_DATA_ARRAY_FREE); + mcTab->accessToMemArray().setSpecificDeallocator(0); + } + else + { + VTKType* newArray = new VTKType[ nbElems ]; + std::copy( mcTab->begin(), mcTab->begin() + nbElems, newArray ); + vtkTab->SetVoidArray(reinterpret_cast(newArray),nbElems,0,VTKT::VTK_DATA_ARRAY_DELETE); + } } template @@ -260,8 +283,8 @@ void AssignToFieldData(DataArray *vPtr, const MEDTimeReq *tr, vtkFieldData *att, const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; typename MEDFileVTKTraits::MCType *vi(static_cast::MCType *>(vPtr)); typename MEDFileVTKTraits::VtkType *vtkd(MEDFileVTKTraits::VtkType::New()); - vtkd->SetNumberOfComponents(vi->getNumberOfComponents()); - for(int i=0;igetNumberOfComponents();i++) + vtkd->SetNumberOfComponents((int)vi->getNumberOfComponents()); + for(unsigned int i=0;igetNumberOfComponents();i++) vtkd->SetComponentName(i,vi->getVarOnComponent(i).c_str()); AssignDataPointerToVTK(vtkd,vi,noCpyNumNodes); std::string name(tr->buildName(crudeName)); @@ -685,29 +708,29 @@ vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInt { DataArrayDouble *coordsMC(0); DataArrayByte *typesMC(0); - DataArrayInt *cellLocationsMC(0),*cellsMC(0),*faceLocationsMC(0),*facesMC(0); + DataArrayIdType *cellLocationsMC(0),*cellsMC(0),*faceLocationsMC(0),*facesMC(0); bool statusOfCoords(mm->buildVTUArrays(coordsMC,typesMC,cellLocationsMC,cellsMC,faceLocationsMC,facesMC)); MCAuto coordsSafe(coordsMC); MCAuto typesSafe(typesMC); - MCAuto cellLocationsSafe(cellLocationsMC),cellsSafe(cellsMC),faceLocationsSafe(faceLocationsMC),facesSafe(facesMC); + MCAuto cellLocationsSafe(cellLocationsMC),cellsSafe(cellsMC),faceLocationsSafe(faceLocationsMC),facesSafe(facesMC); // int nbOfCells(typesSafe->getNbOfElems()); vtkUnstructuredGrid *ret(vtkUnstructuredGrid::New()); vtkUnsignedCharArray *cellTypes(vtkUnsignedCharArray::New()); AssignDataPointerOther(cellTypes,typesSafe,nbOfCells); vtkIdTypeArray *cellLocations(vtkIdTypeArray::New()); - AssignDataPointerOther(cellLocations,cellLocationsSafe,nbOfCells); + AssignDataPointerOther(cellLocations,cellLocationsSafe,nbOfCells); vtkCellArray *cells(vtkCellArray::New()); vtkIdTypeArray *cells2(vtkIdTypeArray::New()); - AssignDataPointerOther(cells2,cellsSafe,cellsSafe->getNbOfElems()); + AssignDataPointerOther(cells2,cellsSafe,cellsSafe->getNbOfElems()); cells->SetCells(nbOfCells,cells2); cells2->Delete(); if(faceLocationsMC!=0 && facesMC!=0) { vtkIdTypeArray *faces(vtkIdTypeArray::New()); - AssignDataPointerOther(faces,facesSafe,facesSafe->getNbOfElems()); + AssignDataPointerOther(faces,facesSafe,facesSafe->getNbOfElems()); vtkIdTypeArray *faceLocations(vtkIdTypeArray::New()); - AssignDataPointerOther(faceLocations,faceLocationsSafe,faceLocationsSafe->getNbOfElems()); + AssignDataPointerOther(faceLocations,faceLocationsSafe,faceLocationsSafe->getNbOfElems()); ret->SetCells(cellTypes,cellLocations,cells,faceLocations,faces); faceLocations->Delete(); faces->Delete(); @@ -776,7 +799,7 @@ vtkStructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInter { int meshStr[3]={1,1,1}; DataArrayDouble *coords(0); - std::vector nodeStrct; + std::vector nodeStrct; bool isInternal; mm->buildVTUArrays(coords,nodeStrct,isInternal); std::size_t dim(nodeStrct.size()); @@ -845,15 +868,15 @@ vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolatio // appendFields(tr,globs,mml,meshes,ret,internalInfo); // The arrays links to mesh - DataArrayInt *famCells(0),*numCells(0); + DataArrayIdType *famCells(0),*numCells(0); bool noCpyFamCells(false),noCpyNumCells(false); ptMML2->retrieveFamilyIdsOnCells(famCells,noCpyFamCells); if(famCells) { - vtkIntArray *vtkTab(vtkIntArray::New()); + vtkMCIdTypeArray *vtkTab(vtkMCIdTypeArray::New()); vtkTab->SetNumberOfComponents(1); vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_CELL_NAME); - AssignDataPointerToVTK(vtkTab,famCells,noCpyFamCells); + AssignDataPointerToVTK(vtkTab,famCells,noCpyFamCells); ret->GetCellData()->AddArray(vtkTab); vtkTab->Delete(); famCells->decrRef(); @@ -861,24 +884,24 @@ vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolatio ptMML2->retrieveNumberIdsOnCells(numCells,noCpyNumCells); if(numCells) { - vtkIntArray *vtkTab(vtkIntArray::New()); + vtkMCIdTypeArray *vtkTab(vtkMCIdTypeArray::New()); vtkTab->SetNumberOfComponents(1); vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::NUM_ID_CELL_NAME); - AssignDataPointerToVTK(vtkTab,numCells,noCpyNumCells); + AssignDataPointerToVTK(vtkTab,numCells,noCpyNumCells); ret->GetCellData()->AddArray(vtkTab); vtkTab->Delete(); numCells->decrRef(); } // The arrays links to mesh - DataArrayInt *famNodes(0),*numNodes(0); + DataArrayIdType *famNodes(0),*numNodes(0); bool noCpyFamNodes(false),noCpyNumNodes(false); ptMML2->retrieveFamilyIdsOnNodes(famNodes,noCpyFamNodes); if(famNodes) { - vtkIntArray *vtkTab(vtkIntArray::New()); + vtkMCIdTypeArray *vtkTab(vtkMCIdTypeArray::New()); vtkTab->SetNumberOfComponents(1); vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_NODE_NAME); - AssignDataPointerToVTK(vtkTab,famNodes,noCpyFamNodes); + AssignDataPointerToVTK(vtkTab,famNodes,noCpyFamNodes); ret->GetPointData()->AddArray(vtkTab); vtkTab->Delete(); famNodes->decrRef(); @@ -886,22 +909,22 @@ vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolatio ptMML2->retrieveNumberIdsOnNodes(numNodes,noCpyNumNodes); if(numNodes) { - vtkIntArray *vtkTab(vtkIntArray::New()); + vtkMCIdTypeArray *vtkTab(vtkMCIdTypeArray::New()); vtkTab->SetNumberOfComponents(1); vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::NUM_ID_NODE_NAME); - AssignDataPointerToVTK(vtkTab,numNodes,noCpyNumNodes); + AssignDataPointerToVTK(vtkTab,numNodes,noCpyNumNodes); ret->GetPointData()->AddArray(vtkTab); vtkTab->Delete(); numNodes->decrRef(); } // Global Node Ids if any ! (In // mode) - DataArrayInt *gni(ptMML2->retrieveGlobalNodeIdsIfAny()); + DataArrayIdType *gni(ptMML2->retrieveGlobalNodeIdsIfAny()); if(gni) { - vtkIntArray *vtkTab(vtkIntArray::New()); + vtkMCIdTypeArray *vtkTab(vtkMCIdTypeArray::New()); vtkTab->SetNumberOfComponents(1); vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::GLOBAL_NODE_ID_NAME); - AssignDataPointerToVTK(vtkTab,gni,false); + AssignDataPointerToVTK(vtkTab,gni,false); ret->GetPointData()->AddArray(vtkTab); vtkTab->Delete(); gni->decrRef(); @@ -1282,7 +1305,7 @@ void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileNam MEDCoupling::MEDFileMesh *tmp(ms->getMeshAtPos(i)); MEDCoupling::MEDFileUMesh *tmp2(dynamic_cast(tmp)); if(tmp2) - MCAuto tmp3(tmp2->zipCoords()); + MCAuto tmp3(tmp2->zipCoords()); } fields=MEDFileFields::LoadPartOf(fileName,false,ms);//false is important to not read the values #else @@ -1365,9 +1388,9 @@ vtkDataSet *MEDFileFieldRepresentationTree::buildVTKInstance(bool isStdOrMode, d zeTimeId=std::distance(ts2.begin(),std::find_if(ts2.begin(),ts2.end(),std::bind2nd(std::less(),1e-14))); } //2nd chance - if(zeTimeId==(int)ts.size()) + if(zeTimeId==ts.size()) zeTimeId=std::distance(ts.begin(),std::find(ts.begin(),ts.end(),timeReq)); - if(zeTimeId==(int)ts.size()) + if(zeTimeId==ts.size()) {//OK the time requested does not fit time series given to ParaView. It is typically the case if more than one MEDReader instance are created or TimeInspector in real time mode. //In this case the default behaviour is taken. Keep the highest time step in this lower than timeReq. int pos(-1); @@ -1378,7 +1401,7 @@ vtkDataSet *MEDFileFieldRepresentationTree::buildVTKInstance(bool isStdOrMode, d { if(ts[i]>valAttachedToPos) { - pos=i; + pos=(int)i; valAttachedToPos=ts[i]; } } @@ -1390,7 +1413,7 @@ vtkDataSet *MEDFileFieldRepresentationTree::buildVTKInstance(bool isStdOrMode, d { if(ts[i]SILTime; + return (int)this->SILTime; } void vtkExtractCellType::PrintSelf(ostream& os, vtkIndent indent) diff --git a/src/Plugins/MEDReader/IO/vtkExtractGroup.cxx b/src/Plugins/MEDReader/IO/vtkExtractGroup.cxx index 8edfe1a7..2b2af12d 100644 --- a/src/Plugins/MEDReader/IO/vtkExtractGroup.cxx +++ b/src/Plugins/MEDReader/IO/vtkExtractGroup.cxx @@ -21,10 +21,12 @@ #include "vtkExtractGroup.h" #include "MEDFileFieldRepresentationTree.hxx" #include "vtkMEDReader.h" +#include "VTKMEDTraits.hxx" #include "vtkAdjacentVertexIterator.h" #include "vtkDataArrayTemplate.h" #include "vtkIntArray.h" +#include "vtkLongArray.h" #include "vtkCellData.h" #include "vtkPointData.h" @@ -357,6 +359,7 @@ int vtkExtractGroup::vtkExtractGroupInternal::getIdOfFamily(const std::string& f if((*it).getName()==famName) return (*it).getId(); } + return std::numeric_limits::max(); } ExtractGroupFam::ExtractGroupFam(const char *name):ExtractGroupStatus(name),_id(0) @@ -516,7 +519,8 @@ vtkDataSet *FilterFamilies(vtkSmartPointer& thres, if(!da) return 0; std::string daName(da->GetName()); - vtkIntArray *dai(vtkIntArray::SafeDownCast(da)); + typedef MEDFileVTKTraits::VtkType vtkMCIdTypeArray; + vtkMCIdTypeArray *dai(vtkMCIdTypeArray::SafeDownCast(da)); if(daName!=arrNameOfFamilyField || !dai) return 0; // @@ -526,7 +530,7 @@ vtkDataSet *FilterFamilies(vtkSmartPointer& thres, zeSelection->SetNumberOfComponents(1); char *pt(new char[nbOfTuples]); zeSelection->SetArray(pt,nbOfTuples,0,VTK_DATA_ARRAY_DELETE); - const int *inPtr(dai->GetPointer(0)); + const mcIdType *inPtr(dai->GetPointer(0)); std::fill(pt,pt+nbOfTuples,0); catchAll=true; catchSmth=false; std::vector pt2(nbOfTuples,false); @@ -577,13 +581,12 @@ public: private: vtkDataSet *_ds; }; - int vtkExtractGroup::RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) { try { -// std::cerr << "########################################## vtkExtractGroup::RequestData ##########################################" << std::endl; -// request->Print(cout); + // std::cerr << "########################################## vtkExtractGroup::RequestData ##########################################" << std::endl; + // request->Print(cout); vtkInformation* inputInfo=inputVector[0]->GetInformationObject(0); vtkMultiBlockDataSet *inputMB(vtkMultiBlockDataSet::SafeDownCast(inputInfo->Get(vtkDataObject::DATA_OBJECT()))); if(inputMB->GetNumberOfBlocks()!=1) @@ -690,7 +693,7 @@ int vtkExtractGroup::RequestData(vtkInformation *request, vtkInformationVector * int vtkExtractGroup::GetSILUpdateStamp() { - return this->SILTime; + return (int)this->SILTime; } void vtkExtractGroup::PrintSelf(ostream& os, vtkIndent indent) diff --git a/src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx b/src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx index 510071ac..36bc6bea 100644 --- a/src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx +++ b/src/Plugins/MEDReader/IO/vtkGenerateVectors.cxx @@ -85,10 +85,10 @@ vtkDoubleArray *vtkGenerateVectors::Operate2Compo(vtkDoubleArray *oldArr) { const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; vtkDoubleArray *ret(vtkDoubleArray::New()); - std::size_t nbOfTuples(oldArr->GetNumberOfTuples()); + vtkIdType nbOfTuples(oldArr->GetNumberOfTuples()); const double *inPt(oldArr->GetPointer(0)); double *pt((double *)malloc(nbOfTuples*3*sizeof(double))); - for(std::size_t i=0;i::VTK_DATA_ARRAY_FREE; vtkDoubleArray *ret(vtkDoubleArray::New()); int nbOfCompo(oldArr->GetNumberOfComponents()); - std::size_t nbOfTuples(oldArr->GetNumberOfTuples()); + vtkIdType nbOfTuples(oldArr->GetNumberOfTuples()); const double *inPt(oldArr->GetPointer(0)); double *pt((double *)malloc(nbOfTuples*3*sizeof(double))); - for(std::size_t i=0;i& data(ti.getData()); - outInfo->Set(vtkMEDReader::GAUSS_DATA(),&data[0],data.size()); + outInfo->Set(vtkMEDReader::GAUSS_DATA(),&data[0],(int)data.size()); request->Append(vtkExecutive::KEYS_TO_COPY(),vtkMEDReader::GAUSS_DATA());// Thank you to SciberQuest and DIPOLE_CENTER ! Don't understand why ! In RequestInformation it does not work ! } output->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(),reqTS); @@ -492,7 +492,7 @@ void vtkMEDReader::SetFieldsStatus(const char* name, int status) try { this->Internal->Tree.changeStatusOfAndUpdateToHaveCoherentVTKDataSet(this->Internal->Tree.getIdHavingZeName(name),status); - if(this->Internal->_wonderful_set.size()==GetNumberOfFieldsTreeArrays()) + if((int)this->Internal->_wonderful_set.size()==GetNumberOfFieldsTreeArrays()) { if(this->Internal->_wonderful_ref!=this->Internal->Tree.dumpState()) { @@ -553,7 +553,7 @@ void vtkMEDReader::SetTimesFlagsStatus(const char *name, int status) int pos(0); std::istringstream iss(name); iss >> pos; this->Internal->TK.getTimesFlagArray()[pos].first=(bool)status; - if(pos==this->Internal->TK.getTimesFlagArray().size()-1) + if(pos==(int)this->Internal->TK.getTimesFlagArray().size()-1) if(!this->Internal->PluginStart0()) { this->Modified(); @@ -657,7 +657,7 @@ double vtkMEDReader::PublishTimeStepsIfNeeded(vtkInformation *outInfo, bool& isU double timeRange[2]; timeRange[0]=tsteps.front(); timeRange[1]=tsteps.back(); - outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),&tsteps[0],tsteps.size()); + outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),&tsteps[0],(int)tsteps.size()); outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(),timeRange,2); this->Internal->LastLev0=lev0; } diff --git a/src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt b/src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt index 9e5335a3..5541c527 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt +++ b/src/Plugins/MEDReader/ParaViewPlugin/CMakeLists.txt @@ -17,7 +17,10 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../IO ) +INCLUDE_DIRECTORIES( + ${CMAKE_CURRENT_SOURCE_DIR}/../IO + ${CMAKE_CURRENT_SOURCE_DIR}/../../MEDWriter/IO + ) IF(PARAVIEW_BUILD_QT_GUI) diff --git a/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx index 8b9ce5b5..4bd937fc 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx +++ b/src/Plugins/MEDReader/ParaViewPlugin/VectBoolSpreadSheet.cxx @@ -160,13 +160,13 @@ void VectBoolModel::selectUnselectAll() emit layoutAboutToBeChanged(); if(nbOn>sz/2) { - for(std::size_t ii=0;iiGetNumberOfElements(); i += 2) + for (unsigned int i = 1; i < prop->GetNumberOfElements(); i += 2) { if (prop->GetElement(i)[0] == '1') { const char* leafString = prop->GetElement(i - 1); const char* tmp = strchr(leafString, '/'); size_t num = tmp - leafString; - char* dest = new char[num]; + char* dest = new char[num+1]; strncpy(dest, leafString, num); dest[num] = '\0'; - tsId = strtol(dest + 2, NULL, 10); - delete dest; + tsId = (vtkIdType)strtol(dest + 2, NULL, 10); + delete [] dest; break; } } diff --git a/src/Plugins/MEDWriter/CMakeLists.txt b/src/Plugins/MEDWriter/CMakeLists.txt index ffb5157d..6b2af517 100644 --- a/src/Plugins/MEDWriter/CMakeLists.txt +++ b/src/Plugins/MEDWriter/CMakeLists.txt @@ -51,6 +51,10 @@ FIND_PACKAGE(SalomeHDF5 REQUIRED) FIND_PACKAGE(SalomeMEDCoupling REQUIRED) FIND_PACKAGE(SalomeMEDFile REQUIRED) +IF(MEDCOUPLING_USE_64BIT_IDS) + ADD_DEFINITIONS("-DMEDCOUPLING_USE_64BIT_IDS") +ENDIF(MEDCOUPLING_USE_64BIT_IDS) + PV_PROCESS_MODULES() INCLUDE_DIRECTORIES( diff --git a/src/Plugins/MEDWriter/IO/VTKMEDTraits.hxx b/src/Plugins/MEDWriter/IO/VTKMEDTraits.hxx index ec49d6a3..08c53489 100644 --- a/src/Plugins/MEDWriter/IO/VTKMEDTraits.hxx +++ b/src/Plugins/MEDWriter/IO/VTKMEDTraits.hxx @@ -21,6 +21,11 @@ #ifndef __VTKMEDTRAITS_HXX__ #define __VTKMEDTRAITS_HXX__ +class vtkIntArray; +class vtkLongArray; +class vtkFloatArray; +class vtkDoubleArray; + template class MEDFileVTKTraits { @@ -34,7 +39,15 @@ class MEDFileVTKTraits { public: typedef vtkIntArray VtkType; - typedef MEDCoupling::DataArrayInt MCType; + typedef MEDCoupling::DataArrayInt32 MCType; +}; + +template<> +class MEDFileVTKTraits +{ +public: + typedef vtkLongArray VtkType; + typedef MEDCoupling::DataArrayInt64 MCType; }; template<> diff --git a/src/Plugins/MEDWriter/IO/VTKToMEDMem.cxx b/src/Plugins/MEDWriter/IO/VTKToMEDMem.cxx index 24907865..19090de0 100644 --- a/src/Plugins/MEDWriter/IO/VTKToMEDMem.cxx +++ b/src/Plugins/MEDWriter/IO/VTKToMEDMem.cxx @@ -78,7 +78,8 @@ using MEDCoupling::MEDFileIntFieldMultiTS; using MEDCoupling::MEDFileFieldMultiTS; using MEDCoupling::MEDFileAnyTypeFieldMultiTS; using MEDCoupling::DataArray; -using MEDCoupling::DataArrayInt; +using MEDCoupling::DataArrayInt32; +using MEDCoupling::DataArrayInt64; using MEDCoupling::DataArrayFloat; using MEDCoupling::DataArrayDouble; using MEDCoupling::MEDCouplingMesh; @@ -131,13 +132,13 @@ std::string GetMeshNameWithContext(const std::vector& context) return oss.str(); } -DataArrayInt *ConvertVTKArrayToMCArrayInt(vtkDataArray *data) +DataArrayIdType *ConvertVTKArrayToMCArrayInt(vtkDataArray *data) { if(!data) throw MZCException("ConvertVTKArrayToMCArrayInt : internal error !"); int nbTuples(data->GetNumberOfTuples()),nbComp(data->GetNumberOfComponents()); std::size_t nbElts(nbTuples*nbComp); - MCAuto ret(DataArrayInt::New()); + MCAuto ret(DataArrayIdType::New()); ret->alloc(nbTuples,nbComp); for(int i=0;isetInfoOnComponent(i,comp); } - int *ptOut(ret->getPointer()); + mcIdType *ptOut(ret->getPointer()); vtkIntArray *d0(vtkIntArray::SafeDownCast(data)); if(d0) { @@ -191,7 +192,7 @@ typename Traits::ArrayType *ConvertVTKArrayToMCArrayDouble(vtkDataArray *data if(nbComp>1 && nbComp<=3) { char tmp[2]; - tmp[0]='X'+i; tmp[1]='\0'; + tmp[0]=(char)('X'+i); tmp[1]='\0'; ret->setInfoOnComponent(i,tmp); } } @@ -258,17 +259,17 @@ MEDCouplingUMesh *BuildMeshFromCellArray(vtkCellArray *ca, DataArrayDouble *coor const vtkIdType *conn(ca->GetPointer()); for(int i=0;i conn2(sz); + mcIdType sz(ToIdType(*conn++)); + std::vector conn2(sz); for(int jj=0;jjinsertNextCell(type,sz,&conn2[0]); conn+=sz; } return subMesh.retn(); } -MEDCouplingUMesh *BuildMeshFromCellArrayTriangleStrip(vtkCellArray *ca, DataArrayDouble *coords, MCAuto& ids) +MEDCouplingUMesh *BuildMeshFromCellArrayTriangleStrip(vtkCellArray *ca, DataArrayDouble *coords, MCAuto& ids) { MCAuto subMesh(MEDCouplingUMesh::New("",2)); subMesh->setCoords(coords); subMesh->allocateCells(); @@ -277,7 +278,7 @@ MEDCouplingUMesh *BuildMeshFromCellArrayTriangleStrip(vtkCellArray *ca, DataArra return 0; vtkIdType nbEntries(ca->GetNumberOfConnectivityEntries()); const vtkIdType *conn(ca->GetPointer()); - ids=DataArrayInt::New() ; ids->alloc(0,1); + ids=DataArrayIdType::New() ; ids->alloc(0,1); for(int i=0;iinsertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn2); ids->pushBackSilent(i); } @@ -326,9 +327,9 @@ MicroField::MicroField(const std::vector< MicroField >& vs) vs2[ii]=vs[ii].getMesh(); arrs2[ii]=vs[ii].getCellFields(); if(nbElts<0) - nbElts=arrs2[ii].size(); + nbElts=(int)arrs2[ii].size(); else - if(arrs2[ii].size()!=nbElts) + if((int)arrs2[ii].size()!=nbElts) throw MZCException("MicroField cstor : internal error !"); } _cellFs.resize(nbElts); @@ -345,7 +346,7 @@ MicroField::MicroField(const std::vector< MicroField >& vs) } template -void AppendToFields(MEDCoupling::TypeOfField tf, MEDCouplingMesh *mesh, const DataArrayInt *n2oPtr, typename MEDFileVTKTraits::MCType *dadPtr, MEDFileFields *fs, double timeStep, int tsId) +void AppendToFields(MEDCoupling::TypeOfField tf, MEDCouplingMesh *mesh, const DataArrayIdType *n2oPtr, typename MEDFileVTKTraits::MCType *dadPtr, MEDFileFields *fs, double timeStep, int tsId) { std::string fieldName(dadPtr->getName()); MCAuto< typename Traits::FieldType > f(Traits::FieldType::New(tf)); @@ -369,7 +370,7 @@ void AppendToFields(MEDCoupling::TypeOfField tf, MEDCouplingMesh *mesh, const Da fs->pushField(fmts); } -void AppendMCFieldFrom(MEDCoupling::TypeOfField tf, MEDCouplingMesh *mesh, MEDFileData *mfd, MCAuto da, const DataArrayInt *n2oPtr, double timeStep, int tsId) +void AppendMCFieldFrom(MEDCoupling::TypeOfField tf, MEDCouplingMesh *mesh, MEDFileData *mfd, MCAuto da, const DataArrayIdType *n2oPtr, double timeStep, int tsId) { static const char FAMFIELD_FOR_CELLS[]="FamilyIdCell"; static const char FAMFIELD_FOR_NODES[]="FamilyIdNode"; @@ -392,11 +393,14 @@ void AppendMCFieldFrom(MEDCoupling::TypeOfField tf, MEDCouplingMesh *mesh, MEDFi return ; } MCAuto dai(MEDCoupling::DynamicCast(da)); - if(dai.isNotNull()) + MCAuto daId(MEDCoupling::DynamicCast(da)); + if(dai.isNotNull() || daId.isNotNull()) { std::string fieldName(dai->getName()); 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(tf,mesh,n2oPtr,dai,fs,timeStep,tsId); return ; } @@ -405,11 +409,13 @@ void AppendMCFieldFrom(MEDCoupling::TypeOfField tf, MEDCouplingMesh *mesh, MEDFi MEDFileMesh *mm(ms->getMeshWithName(mesh->getName())); if(!mm) throw MZCException("AppendMCFieldFrom : internal error 3 !"); + if(!daId) + throw MZCException("AppendMCFieldFrom : internal error 3 (not mcIdType) !"); if(!n2oPtr) - mm->setFamilyFieldArr(mesh->getMeshDimension()-mm->getMeshDimension(),dai); + mm->setFamilyFieldArr(mesh->getMeshDimension()-mm->getMeshDimension(),daId); else { - MCAuto dai2(dai->selectByTupleId(n2oPtr->begin(),n2oPtr->end())); + MCAuto dai2(daId->selectByTupleId(n2oPtr->begin(),n2oPtr->end())); mm->setFamilyFieldArr(mesh->getMeshDimension()-mm->getMeshDimension(),dai2); } } @@ -418,11 +424,13 @@ void AppendMCFieldFrom(MEDCoupling::TypeOfField tf, MEDCouplingMesh *mesh, MEDFi MEDFileMesh *mm(ms->getMeshWithName(mesh->getName())); if(!mm) throw MZCException("AppendMCFieldFrom : internal error 4 !"); + if(!daId) + throw MZCException("AppendMCFieldFrom : internal error 4 (not mcIdType) !"); if(!n2oPtr) - mm->setFamilyFieldArr(1,dai); + mm->setFamilyFieldArr(1,daId); else { - MCAuto dai2(dai->selectByTupleId(n2oPtr->begin(),n2oPtr->end())); + MCAuto dai2(daId->selectByTupleId(n2oPtr->begin(),n2oPtr->end())); mm->setFamilyFieldArr(1,dai2); } } @@ -439,11 +447,11 @@ void PutAtLevelDealOrder(MEDFileData *mfd, int meshDimRel, const MicroField& mf, throw MZCException("PutAtLevelDealOrder : internal error 2 !"); MCAuto mesh(mf.getMesh()); mesh->setName(mfd->getMeshes()->getMeshAtPos(0)->getName()); - MCAuto o2n(mesh->sortCellsInMEDFileFrmt()); - const DataArrayInt *o2nPtr(o2n); - MCAuto n2o; + MCAuto o2n(mesh->sortCellsInMEDFileFrmt()); + const DataArrayIdType *o2nPtr(o2n); + MCAuto n2o; mmu->setMeshAtLevel(meshDimRel,mesh); - const DataArrayInt *n2oPtr(0); + const DataArrayIdType *n2oPtr(0); if(o2n) { n2o=o2n->invertArrayO2N2N2O(mesh->getNumberOfCells()); @@ -541,7 +549,7 @@ void AddNodeFields(MEDFileData *mfd, vtkDataSetAttributes *dsa, double timeStep, } } -std::vector > AddPartFields(const DataArrayInt *part, vtkDataSetAttributes *dsa) +std::vector > AddPartFields(const DataArrayIdType *part, vtkDataSetAttributes *dsa) { std::vector< MCAuto > ret; if(!dsa) @@ -695,7 +703,7 @@ void ConvertFromPolyData(MEDFileData *ret, vtkPolyData *ds, const std::vectorGetStrips()); if(ca) { - MCAuto ids; + MCAuto ids; MCAuto subMesh(BuildMeshFromCellArrayTriangleStrip(ca,coords,ids)); if((const MEDCouplingUMesh *)subMesh) { @@ -770,8 +778,8 @@ void ConvertFromUnstructuredGrid(MEDFileData *ret, vtkUnstructuredGrid *ds, cons { MCAuto m0(MEDCouplingUMesh::New("",*curLev)); m0->setCoords(coords); m0->allocateCells(); - MCAuto cellIdsCurLev(lev->findIdsEqual(*curLev)); - for(const int *cellId=cellIdsCurLev->begin();cellId!=cellIdsCurLev->end();cellId++) + MCAuto cellIdsCurLev(lev->findIdsEqual(*curLev)); + for(const mcIdType *cellId=cellIdsCurLev->begin();cellId!=cellIdsCurLev->end();cellId++) { int vtkType(ctPtr[*cellId]); std::map::iterator it(m.find(vtkType)); @@ -780,7 +788,7 @@ void ConvertFromUnstructuredGrid(MEDFileData *ret, vtkUnstructuredGrid *ds, cons INTERP_KERNEL::NormalizedCellType ct=it!=m.end()?(INTERP_KERNEL::NormalizedCellType)((*it).second):INTERP_KERNEL::NORM_POINT1; if(ct!=INTERP_KERNEL::NORM_POLYHED && vtkType!=VTK_POLY_VERTEX) { - std::vector conn2(sz); + std::vector conn2(sz); for(int kk=0;kkinsertNextCell(ct,sz,&conn2[0]); @@ -790,7 +798,7 @@ void ConvertFromUnstructuredGrid(MEDFileData *ret, vtkUnstructuredGrid *ds, cons if(!faces || !faceLoc) throw MZCException("ConvertFromUnstructuredGrid : faces are expected when there are polyhedra !"); const vtkIdType *facPtr(faces->GetPointer(0)),*facLocPtr(faceLoc->GetPointer(0)); - std::vector conn; + std::vector conn; int off0(facLocPtr[*cellId]); int nbOfFaces(facPtr[off0++]); for(int k=0;kinsertNextCell(ct,conn.size(),&conn[0]); + m0->insertNextCell(ct,ToIdType(conn.size()),&conn[0]); } else { if(sz!=1) throw MZCException("ConvertFromUnstructuredGrid : non single poly vertex not managed by MED !"); - m0->insertNextCell(ct,1,caPtr+offset+1); + m0->insertNextCell(ct,1,(const mcIdType*)(caPtr+offset+1)); } } std::vector > cellFs(AddPartFields(cellIdsCurLev,ds->GetCellData())); diff --git a/src/Plugins/MEDWriter/IO/VTKToMEDMem.hxx b/src/Plugins/MEDWriter/IO/VTKToMEDMem.hxx index b78c3963..6f36d77f 100644 --- a/src/Plugins/MEDWriter/IO/VTKToMEDMem.hxx +++ b/src/Plugins/MEDWriter/IO/VTKToMEDMem.hxx @@ -23,14 +23,14 @@ #include "vtkSystemIncludes.h" //needed for exports -#include "MEDFileMesh.hxx" -#include "MEDFileField.hxx" -#include "MEDFileData.hxx" +#include "MEDCouplingRefCountObject.hxx" #include "MEDCouplingMemArray.hxx" -#include "MEDCouplingFieldInt.hxx" -#include "MEDCouplingFieldFloat.hxx" #include "MEDCouplingFieldDouble.hxx" -#include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingFieldFloat.hxx" +#include "MEDCouplingFieldInt.hxx" +#include "MEDFileData.hxx" +#include "MEDFileField.hxx" +#include "MEDFileMesh.hxx" #include "MEDLoaderTraits.hxx" #include diff --git a/src/Plugins/ParaMEDCorba/VTKMEDCouplingUMeshClient.cxx b/src/Plugins/ParaMEDCorba/VTKMEDCouplingUMeshClient.cxx index 18611414..1f664ce5 100644 --- a/src/Plugins/ParaMEDCorba/VTKMEDCouplingUMeshClient.cxx +++ b/src/Plugins/ParaMEDCorba/VTKMEDCouplingUMeshClient.cxx @@ -101,18 +101,18 @@ void ParaMEDMEM2VTK::FillMEDCouplingUMeshInstanceFrom(SALOME_MED::MEDCouplingUMe isPolyh=true; std::set s(tmp,tmp+nbOfNodeInCurCell); vtkSmartPointer faces=vtkSmartPointer::New(); - int nbOfFaces=std::count(tmp,tmp+nbOfNodeInCurCell,-1)+1; + std::size_t nbOfFaces=std::count(tmp,tmp+nbOfNodeInCurCell,-1)+1; vtkIdType *work=tmp; - for(int i=0;iInsertNextCell(nbOfNodesInFace,work); work=work2+1; } s.erase(-1); std::vector v(s.begin(),s.end()); - ret->InsertNextCell(VTK_POLYHEDRON,v.size(),&v[0],nbOfFaces,faces->GetPointer()); + ret->InsertNextCell(VTK_POLYHEDRON,(vtkIdType)v.size(),&v[0],(vtkIdType)nbOfFaces,faces->GetPointer()); } } delete [] tmp; diff --git a/src/Plugins/ParaMEDCorba/vtkParaMEDCorbaSource.cxx b/src/Plugins/ParaMEDCorba/vtkParaMEDCorbaSource.cxx index 043efd15..5aa24839 100644 --- a/src/Plugins/ParaMEDCorba/vtkParaMEDCorbaSource.cxx +++ b/src/Plugins/ParaMEDCorba/vtkParaMEDCorbaSource.cxx @@ -83,7 +83,7 @@ void vtkParaMEDCorbaSource::SetIORCorba(char *ior) return; if(ior[0]=='\0') return; - int length=strlen(ior); + std::size_t length=strlen(ior); IOR.resize(length+1); std::copy(ior,ior+length+1,&IOR[0]); this->Modified(); @@ -168,7 +168,7 @@ int vtkParaMEDCorbaSource::RequestInformation(vtkInformation* request, vtkInform double timeRange[2]; timeRange[0]=tsteps.front(); timeRange[1]=tsteps.back(); - myInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),&tsteps[0],tsteps.size()); + myInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(),&tsteps[0],(vtkIdType)tsteps.size()); myInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(),timeRange,2); } } diff --git a/src/Plugins/VoroGauss/CMakeLists.txt b/src/Plugins/VoroGauss/CMakeLists.txt index 58fe683e..ca8b3017 100644 --- a/src/Plugins/VoroGauss/CMakeLists.txt +++ b/src/Plugins/VoroGauss/CMakeLists.txt @@ -51,6 +51,10 @@ SET(MEDCOUPLING_ROOT_DIR $ENV{MEDCOUPLING_ROOT_DIR} CACHE PATH "MEDCOUPLING_ROOT LIST(APPEND CMAKE_MODULE_PATH "${MEDCOUPLING_ROOT_DIR}/cmake_files") FIND_PACKAGE(SalomeMEDCoupling REQUIRED) +IF(MEDCOUPLING_USE_64BIT_IDS) + ADD_DEFINITIONS("-DMEDCOUPLING_USE_64BIT_IDS") +ENDIF(MEDCOUPLING_USE_64BIT_IDS) + OPTION(BUILD_SHARED_LIBS "Build with shared libraries." ${VTK_BUILD_SHARED_LIBS}) SET(VTK_INSTALL_RUNTIME_DIR lib) diff --git a/src/Plugins/VoroGauss/IO/vtkVoroGauss.cxx b/src/Plugins/VoroGauss/IO/vtkVoroGauss.cxx index 5933c294..e251eb23 100644 --- a/src/Plugins/VoroGauss/IO/vtkVoroGauss.cxx +++ b/src/Plugins/VoroGauss/IO/vtkVoroGauss.cxx @@ -65,6 +65,7 @@ #include "vtkMultiBlockDataGroupFilter.h" #include "MEDCouplingMemArray.hxx" +#include "MEDCouplingMemArray.txx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingFieldDouble.hxx" #include "InterpKernelAutoPtr.hxx" @@ -76,7 +77,8 @@ #include using MEDCoupling::DataArray; -using MEDCoupling::DataArrayInt; +using MEDCoupling::DataArrayInt32; +using MEDCoupling::DataArrayInt64; using MEDCoupling::DataArrayDouble; using MEDCoupling::MEDCouplingMesh; using MEDCoupling::MEDCouplingUMesh; @@ -171,13 +173,13 @@ void ExtractInfo(vtkInformationVector *inputVector, vtkUnstructuredGrid *& usgIn throw INTERP_KERNEL::Exception("Input data set is not an unstructured mesh ! This filter works only on unstructured meshes !"); } -DataArrayInt *ConvertVTKArrayToMCArrayInt(vtkDataArray *data) +DataArrayIdType *ConvertVTKArrayToMCArrayInt(vtkDataArray *data) { if(!data) throw INTERP_KERNEL::Exception("ConvertVTKArrayToMCArrayInt : internal error !"); int nbTuples(data->GetNumberOfTuples()),nbComp(data->GetNumberOfComponents()); std::size_t nbElts(nbTuples*nbComp); - MCAuto ret(DataArrayInt::New()); + MCAuto ret(DataArrayIdType::New()); ret->alloc(nbTuples,nbComp); for(int i=0;isetInfoOnComponent(i,comp); } - int *ptOut(ret->getPointer()); + mcIdType *ptOut(ret->getPointer()); vtkIntArray *d0(vtkIntArray::SafeDownCast(data)); if(d0) { @@ -278,7 +280,7 @@ DataArrayDouble *BuildCoordsFrom(vtkPointSet *ds) return coords.retn(); } -void ConvertFromUnstructuredGrid(vtkUnstructuredGrid *ds, std::vector< MCAuto >& ms, std::vector< MCAuto >& ids) +void ConvertFromUnstructuredGrid(vtkUnstructuredGrid *ds, std::vector< MCAuto >& ms, std::vector< MCAuto >& ids) { MCAuto coords(BuildCoordsFrom(ds)); vtkIdType nbCells(ds->GetNumberOfCells()); @@ -318,8 +320,8 @@ void ConvertFromUnstructuredGrid(vtkUnstructuredGrid *ds, std::vector< MCAuto m0(MEDCouplingUMesh::New("",*curLev)); m0->setCoords(coords); m0->allocateCells(); - MCAuto cellIdsCurLev(lev->findIdsEqual(*curLev)); - for(const int *cellId=cellIdsCurLev->begin();cellId!=cellIdsCurLev->end();cellId++) + MCAuto cellIdsCurLev(lev->findIdsEqual(*curLev)); + for(const mcIdType *cellId=cellIdsCurLev->begin();cellId!=cellIdsCurLev->end();cellId++) { std::map::iterator it(m.find(ctPtr[*cellId])); vtkIdType offset(claPtr[*cellId]); @@ -327,7 +329,7 @@ void ConvertFromUnstructuredGrid(vtkUnstructuredGrid *ds, std::vector< MCAuto conn2(sz); + std::vector conn2(sz); for(int kk=0;kkinsertNextCell(ct,sz,&conn2[0]); @@ -337,7 +339,7 @@ void ConvertFromUnstructuredGrid(vtkUnstructuredGrid *ds, std::vector< MCAutoGetPointer(0)),*facLocPtr(faceLoc->GetPointer(0)); - std::vector conn; + std::vector conn; int off0(facLocPtr[*cellId]); int nbOfFaces(facPtr[off0++]); for(int k=0;kinsertNextCell(ct,conn.size(),&conn[0]); + m0->insertNextCell(ct,ToIdType(conn.size()),&conn[0]); } } ms.push_back(m0); ids.push_back(cellIdsCurLev); @@ -366,8 +368,8 @@ vtkSmartPointer ConvertUMeshFromMCToVTK(const MEDCouplingUM { const DataArrayDouble *vorCoords(mVor->getCoords()); vtkSmartPointer da(vtkSmartPointer::New()); - da->SetNumberOfComponents(vorCoords->getNumberOfComponents()); - da->SetNumberOfTuples(vorCoords->getNumberOfTuples()); + da->SetNumberOfComponents((vtkIdType)vorCoords->getNumberOfComponents()); + da->SetNumberOfTuples((vtkIdType)vorCoords->getNumberOfTuples()); std::copy(vorCoords->begin(),vorCoords->end(),da->GetPointer(0)); points->SetData(da); } @@ -392,18 +394,18 @@ vtkSmartPointer ConvertUMeshFromMCToVTK(const MEDCouplingUM } vtkSmartPointer cells(vtkSmartPointer::New()); { - MCAuto tmp2(mVor->computeEffectiveNbOfNodesPerCell()); + MCAuto tmp2(mVor->computeEffectiveNbOfNodesPerCell()); cells->SetNumberOfComponents(1); - cells->SetNumberOfTuples(tmp2->accumulate(0)+nbCells); + cells->SetNumberOfTuples(tmp2->accumulate((std::size_t)0)+nbCells); dPtr=cells->GetPointer(0); } - const int *connPtr(mVor->getNodalConnectivity()->begin()),*connIPtr(mVor->getNodalConnectivityIndex()->begin()); + const mcIdType *connPtr(mVor->getNodalConnectivity()->begin()),*connIPtr(mVor->getNodalConnectivityIndex()->begin()); int k(0),kk(0); std::vector ee,ff; for(int i=0;i(connPtr[connIPtr[0]])); - *aPtr++=zeMapRev[connPtr[connIPtr[0]]]; + *aPtr++=(unsigned char)zeMapRev[connPtr[connIPtr[0]]]; if(ct!=INTERP_KERNEL::NORM_POLYHED) { int sz(connIPtr[1]-connIPtr[0]-1); @@ -415,13 +417,13 @@ vtkSmartPointer ConvertUMeshFromMCToVTK(const MEDCouplingUM else { std::set s(connPtr+connIPtr[0]+1,connPtr+connIPtr[1]); s.erase(-1); - int nbFace(std::count(connPtr+connIPtr[0]+1,connPtr+connIPtr[1],-1)+1); + vtkIdType nbFace((vtkIdType)(std::count(connPtr+connIPtr[0]+1,connPtr+connIPtr[1],-1)+1)); ff.push_back(nbFace); - const int *work(connPtr+connIPtr[0]+1); + const mcIdType *work(connPtr+connIPtr[0]+1); for(int j=0;j ConvertUMeshFromMCToVTK(const MEDCouplingUM vtkSmartPointer faceLocations(vtkSmartPointer::New()); { faceLocations->SetNumberOfComponents(1); - faceLocations->SetNumberOfTuples(ee.size()); + faceLocations->SetNumberOfTuples((vtkIdType)ee.size()); std::copy(ee.begin(),ee.end(),faceLocations->GetPointer(0)); } vtkSmartPointer faces(vtkSmartPointer::New()); { faces->SetNumberOfComponents(1); - faces->SetNumberOfTuples(ff.size()); + faces->SetNumberOfTuples((vtkIdType)ff.size()); std::copy(ff.begin(),ff.end(),faces->GetPointer(0)); } vtkSmartPointer cells2(vtkSmartPointer::New()); @@ -471,7 +473,7 @@ vtkSmartPointer ConvertUMeshFromMCToVTK(const MEDCouplingUM cells->SetNumberOfTuples(mVor->getNodalConnectivity()->getNumberOfTuples()); dPtr=cells->GetPointer(0); } - const int *connPtr(mVor->getNodalConnectivity()->begin()),*connIPtr(mVor->getNodalConnectivityIndex()->begin()); + const mcIdType *connPtr(mVor->getNodalConnectivity()->begin()),*connIPtr(mVor->getNodalConnectivityIndex()->begin()); int k(0); for(int i=0;i ConvertUMeshFromMCToVTK(const MEDCouplingUM cells->SetNumberOfTuples(mVor->getNodalConnectivity()->getNumberOfTuples()); dPtr=cells->GetPointer(0); } - const int *connPtr(mVor->getNodalConnectivity()->begin()),*connIPtr(mVor->getNodalConnectivityIndex()->begin()); + const mcIdType *connPtr(mVor->getNodalConnectivity()->begin()),*connIPtr(mVor->getNodalConnectivityIndex()->begin()); for(int i=0;i offmc(ConvertVTKArrayToMCArrayInt(arr)); + MCAuto offmc(ConvertVTKArrayToMCArrayInt(arr)); _off_arr=offmc; _vtk_arr=arr; } const std::vector& getArrayGauss() const { return _da_on; } - const DataArrayInt *getOffsets() const { return _off_arr; } + const DataArrayIdType *getOffsets() const { return _off_arr; } vtkIdTypeArray *getVTKOffsets() const { return _vtk_arr; } private: std::vector _da_on; - MCAuto _off_arr; + MCAuto _off_arr; vtkIdTypeArray *_vtk_arr; }; @@ -571,7 +573,7 @@ void FillAdvInfoFrom(int vtkCT, const std::vector& GaussAdvData, int nbG } template -vtkSmartPointer ExtractFieldFieldArr(T *elt2, int sizeOfOutArr, int nbOfCellsOfInput, const int *offsetsPtr, const int *nbPtsPerCellPtr) +vtkSmartPointer ExtractFieldFieldArr(T *elt2, int sizeOfOutArr, int nbOfCellsOfInput, const mcIdType *offsetsPtr, const mcIdType *nbPtsPerCellPtr) { vtkSmartPointer elt3(vtkSmartPointer::New()); int nbc(elt2->GetNumberOfComponents()); @@ -593,7 +595,7 @@ vtkSmartPointer ExtractFieldFieldArr(T *elt2, int sizeOfOutArr, int nbOfCells } template -vtkSmartPointer ExtractCellFieldArr(T *elt2, int sizeOfOutArr, int nbOfCellsOfInput, const int *idsPtr, const int *nbPtsPerCellPtr) +vtkSmartPointer ExtractCellFieldArr(T *elt2, int sizeOfOutArr, int nbOfCellsOfInput, const mcIdType *idsPtr, const mcIdType *nbPtsPerCellPtr) { vtkSmartPointer elt3(vtkSmartPointer::New()); int nbc(elt2->GetNumberOfComponents()); @@ -615,7 +617,7 @@ vtkSmartPointer ExtractCellFieldArr(T *elt2, int sizeOfOutArr, int nbOfCellsO return elt3; } -vtkSmartPointer Voronize(const MEDCouplingUMesh *m, const DataArrayInt *ids, vtkIdTypeArray *vtkOff, const DataArrayInt *offsetsBase, const std::vector& arrGauss, const std::vector& GaussAdvData, const std::vector& arrsOnCells) +vtkSmartPointer Voronize(const MEDCouplingUMesh *m, const DataArrayIdType *ids, vtkIdTypeArray *vtkOff, const DataArrayIdType *offsetsBase, const std::vector& arrGauss, const std::vector& GaussAdvData, const std::vector& arrsOnCells) { if(arrGauss.empty()) throw INTERP_KERNEL::Exception("Voronize : no Gauss array !"); @@ -643,7 +645,7 @@ vtkSmartPointer Voronize(const MEDCouplingUMesh *m, const D field->setMesh(m); // Gauss Part int nbOfCellsOfInput(m->getNumberOfCells()); - MCAuto nbPtsPerCellArr(DataArrayInt::New()); nbPtsPerCellArr->alloc(nbOfCellsOfInput,1); + MCAuto nbPtsPerCellArr(DataArrayIdType::New()); nbPtsPerCellArr->alloc(nbOfCellsOfInput,1); std::map zeMapRev(ComputeRevMapOfType()),zeMap(ComputeMapOfType()); std::set agt(m->getAllGeoTypes()); for(std::set::const_iterator it=agt.begin();it!=agt.end();it++) @@ -663,10 +665,10 @@ vtkSmartPointer Voronize(const MEDCouplingUMesh *m, const D std::vector refCoo,posInRefCoo,wCpp(w,w+np); FillAdvInfoFrom((*it2).second,GaussAdvData,np,nbPtsPerCell,refCoo,posInRefCoo); field->setGaussLocalizationOnType(*it,refCoo,posInRefCoo,wCpp); - MCAuto ids2(m->giveCellsWithType(*it)); + MCAuto ids2(m->giveCellsWithType(*it)); nbPtsPerCellArr->setPartOfValuesSimple3(np,ids2->begin(),ids2->end(),0,1,1); } - int zeSizeOfOutCellArr(nbPtsPerCellArr->accumulate(0)); + int zeSizeOfOutCellArr(nbPtsPerCellArr->accumulate((std::size_t)0)); { MCAuto fakeArray(DataArrayDouble::New()); fakeArray->alloc(zeSizeOfOutCellArr,1); field->setArray(fakeArray); } field->checkConsistencyLight(); MCAuto vor(field->voronoize(1e-12));// The key is here ! @@ -674,8 +676,8 @@ vtkSmartPointer Voronize(const MEDCouplingUMesh *m, const D // vtkSmartPointer ret(ConvertUMeshFromMCToVTK(mVor)); // now fields... - MCAuto myOffsets(offsetsBase->selectByTupleIdSafe(ids->begin(),ids->end())); - const int *myOffsetsPtr(myOffsets->begin()),*nbPtsPerCellArrPtr(nbPtsPerCellArr->begin()); + MCAuto myOffsets(offsetsBase->selectByTupleIdSafe(ids->begin(),ids->end())); + const mcIdType *myOffsetsPtr(myOffsets->begin()),*nbPtsPerCellArrPtr(nbPtsPerCellArr->begin()); for(std::vector::const_iterator it=arrGauss.begin();it!=arrGauss.end();it++) { vtkDataArray *elt(*it); @@ -761,7 +763,7 @@ vtkSmartPointer ComputeVoroGauss(vtkUnstructuredGrid *usgIn throw INTERP_KERNEL::Exception("ComputeVoroGauss : no Gauss points fields in DataSet !"); } std::vector< MCAuto > ms; - std::vector< MCAuto > ids; + std::vector< MCAuto > ids; ConvertFromUnstructuredGrid(usgIn,ms,ids); { vtkDataArray *offTmp(usgIn->GetCellData()->GetArray(zeArrOffset.c_str())); @@ -807,7 +809,7 @@ vtkSmartPointer ComputeVoroGauss(vtkUnstructuredGrid *usgIn for(std::size_t i=0;i mmc(ms[i]); - MCAuto myIds(ids[i]); + MCAuto myIds(ids[i]); vtkSmartPointer vor(Voronize(mmc,myIds,zeOffsets.getVTKOffsets(),zeOffsets.getOffsets(),zeOffsets.getArrayGauss(),GaussAdvData,arrsOnCells)); res.push_back(vor); } -- 2.39.2