X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPlugins%2FMEDReader%2FIO%2FMEDFileFieldRepresentationTree.cxx;h=433e3c656f81bf9e1237c8fb311c40ba52fcd531;hb=aa1eabfa68abde019175886db5e066520d92169f;hp=9c19bfdfa90ce23aa6592802b6476d3d6ea40240;hpb=30e5ff6331a07f058b69b87f91a97e875a554088;p=modules%2Fparavis.git diff --git a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx index 9c19bfdf..433e3c65 100644 --- a/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx +++ b/src/Plugins/MEDReader/IO/MEDFileFieldRepresentationTree.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2015 CEA/DEN, EDF R&D +// Copyright (C) 2010-2016 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 @@ -42,6 +42,7 @@ #include "vtkInformationQuadratureSchemeDefinitionVectorKey.h" #include "vtkInformationIntegerKey.h" #include "vtkInformation.h" +#include "vtkDataArrayTemplate.h" #include "vtkIdTypeArray.h" #include "vtkDoubleArray.h" #include "vtkIntArray.h" @@ -68,6 +69,8 @@ const char MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_NODE_NAME[]="Family const char MEDFileFieldRepresentationLeavesArrays::NUM_ID_NODE_NAME[]="NumIdNode"; +const char MEDFileFieldRepresentationLeavesArrays::GLOBAL_NODE_ID_NAME[]="GlobalNodeIds";// WARNING DO NOT CHANGE IT BEFORE HAVING CHECKED IN PV SOURCES ! + const char MEDFileFieldRepresentationTree::ROOT_OF_GRPS_IN_TREE[]="zeGrps"; const char MEDFileFieldRepresentationTree::ROOT_OF_FAM_IDS_IN_TREE[]="zeFamIds"; @@ -175,6 +178,7 @@ vtkIdTypeArray *ELGACmp::createNew(const MEDCoupling::MEDFileFieldGlobsReal *glo _loc_names=locNames; _elgas=elgas; _defs.push_back(defs); + return elga; } void ELGACmp::appendELGAIfAny(vtkDataSet *ds) const @@ -194,25 +198,68 @@ ELGACmp::~ELGACmp() //= +template +class MEDFileVTKTraits +{ +public: + typedef void VtkType; + typedef void MCType; +}; + +template<> +class MEDFileVTKTraits +{ +public: + typedef vtkIntArray VtkType; + typedef MEDCoupling::DataArrayInt MCType; +}; + +template<> +class MEDFileVTKTraits +{ +public: + typedef vtkDoubleArray VtkType; + typedef MEDCoupling::DataArrayDouble MCType; +}; + +template +void AssignDataPointerToVTK(typename MEDFileVTKTraits::VtkType *vtkTab, typename MEDFileVTKTraits::MCType *mcTab, bool noCpyNumNodes) +{ + if(noCpyNumNodes) + vtkTab->SetArray(mcTab->getPointer(),mcTab->getNbOfElems(),1,vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE); + else + { vtkTab->SetArray(mcTab->getPointer(),mcTab->getNbOfElems(),0,vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE); mcTab->accessToMemArray().setSpecificDeallocator(0); } +} + +// here copy is always assumed. +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); +} + +//= + MEDFileFieldRepresentationLeavesArrays::MEDFileFieldRepresentationLeavesArrays():_id(-1) { } -MEDFileFieldRepresentationLeavesArrays::MEDFileFieldRepresentationLeavesArrays(const MEDCoupling::MEDCouplingAutoRefCountObjectPtr& arr):MEDCoupling::MEDCouplingAutoRefCountObjectPtr(arr),_activated(false),_id(-1) +MEDFileFieldRepresentationLeavesArrays::MEDFileFieldRepresentationLeavesArrays(const MEDCoupling::MCAuto& arr):MEDCoupling::MCAuto(arr),_activated(false),_id(-1) { std::vector< std::vector > typs((operator->())->getTypesOfFieldAvailable()); if(typs.size()<1) throw INTERP_KERNEL::Exception("There is a big internal problem in MEDLoader ! The field time spitting has failed ! A CRASH will occur soon !"); if(typs[0].size()!=1) throw INTERP_KERNEL::Exception("There is a big internal problem in MEDLoader ! The field spitting by spatial discretization has failed ! A CRASH will occur soon !"); - MEDCoupling::MEDCouplingAutoRefCountObjectPtr fd(MEDCouplingFieldDiscretization::New(typs[0][0])); + MEDCoupling::MCAuto fd(MEDCouplingFieldDiscretization::New(typs[0][0])); std::ostringstream oss2; oss2 << (operator->())->getName() << ZE_SEP << fd->getRepr(); _ze_name=oss2.str(); } MEDFileFieldRepresentationLeavesArrays& MEDFileFieldRepresentationLeavesArrays::operator=(const MEDFileFieldRepresentationLeavesArrays& other) { - MEDCoupling::MEDCouplingAutoRefCountObjectPtr::operator=(other); + MEDCoupling::MCAuto::operator=(other); _id=-1; _activated=false; _ze_name=other._ze_name; @@ -272,13 +319,12 @@ bool MEDFileFieldRepresentationLeavesArrays::setStatus(bool status) const void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, const MEDCoupling::MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDMeshMultiLev *mml, const MEDCoupling::MEDFileMeshStruct *mst, vtkDataSet *ds) const { - const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate::VTK_DATA_ARRAY_DELETE; tr->setNumberOfTS((operator->())->getNumberOfTS()); tr->initIterator(); for(int timeStepId=0;timeStepIdsize();timeStepId++,++(*tr)) { - MEDCouplingAutoRefCountObjectPtr f1ts((operator->())->getTimeStepAtPos(tr->getCurrent())); + MCAuto f1ts((operator->())->getTimeStepAtPos(tr->getCurrent())); MEDFileAnyTypeField1TS *f1tsPtr(f1ts); MEDFileField1TS *f1tsPtrDbl(dynamic_cast(f1tsPtr)); MEDFileIntField1TS *f1tsPtrInt(dynamic_cast(f1tsPtr)); @@ -291,7 +337,7 @@ void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, throw INTERP_KERNEL::Exception("MEDFileFieldRepresentationLeavesArrays::appendFields : only FLOAT64 and INT32 fields are dealt for the moment !"); MEDFileField1TSStructItem fsst(MEDFileField1TSStructItem::BuildItemFrom(f1ts,mst)); f1ts->loadArraysIfNecessary(); - MEDCouplingAutoRefCountObjectPtr v(mml->buildDataArray(fsst,globs,crudeArr)); + MCAuto v(mml->buildDataArray(fsst,globs,crudeArr)); postProcessedArr=v; // std::vector discs(f1ts->getTypesOfFieldAvailable()); @@ -330,14 +376,7 @@ void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, vtkd->SetNumberOfComponents(vd->getNumberOfComponents()); for(int i=0;igetNumberOfComponents();i++) vtkd->SetComponentName(i,vd->getInfoOnComponent(i).c_str()); - if(postProcessedArr!=crudeArr) - { - vtkd->SetArray(vd->getPointer(),vd->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); vd->accessToMemArray().setSpecificDeallocator(0); - } - else - { - vtkd->SetArray(vd->getPointer(),vd->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); - } + AssignDataPointerToVTK(vtkd,vd,postProcessedArr==crudeArr); std::string name(tr->buildName(f1ts->getName())); vtkd->SetName(name.c_str()); att->AddArray(vtkd); @@ -382,7 +421,7 @@ void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, vtkQuadratureSchemeDefinition *def(vtkQuadratureSchemeDefinition::New()); double *shape(new double[nbGaussPt*nbGaussPt]); std::size_t dummy; - const double *gsCoords(MEDCouplingFieldDiscretizationGaussNE::GetLocsFromGeometricType(ct,dummy)); + const double *gsCoords(MEDCouplingFieldDiscretizationGaussNE::GetRefCoordsFromGeometricType(ct,dummy));//GetLocsFromGeometricType const double *refCoords(MEDCouplingFieldDiscretizationGaussNE::GetRefCoordsFromGeometricType(ct,dummy)); const double *weights(MEDCouplingFieldDiscretizationGaussNE::GetWeightArrayFromGeometricType(ct,dummy)); std::vector gsCoords2(gsCoords,gsCoords+nbGaussPt*dim),refCoords2(refCoords,refCoords+nbGaussPt*dim); @@ -410,14 +449,7 @@ void MEDFileFieldRepresentationLeavesArrays::appendFields(const MEDTimeReq *tr, vtkd->SetNumberOfComponents(vi->getNumberOfComponents()); for(int i=0;igetNumberOfComponents();i++) vtkd->SetComponentName(i,vi->getVarOnComponent(i).c_str()); - if(postProcessedArr!=crudeArr) - { - vtkd->SetArray(vi->getPointer(),vi->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); vi->accessToMemArray().setSpecificDeallocator(0); - } - else - { - vtkd->SetArray(vi->getPointer(),vi->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); - } + AssignDataPointerToVTK(vtkd,vi,postProcessedArr==crudeArr); std::string name(tr->buildName(f1ts->getName())); vtkd->SetName(name.c_str()); att->AddArray(vtkd); @@ -439,8 +471,8 @@ MEDFileFieldRepresentationLeaves::MEDFileFieldRepresentationLeaves():_cached_ds( { } -MEDFileFieldRepresentationLeaves::MEDFileFieldRepresentationLeaves(const std::vector< MEDCoupling::MEDCouplingAutoRefCountObjectPtr >& arr, - const MEDCoupling::MEDCouplingAutoRefCountObjectPtr& fsp):_arrays(arr.size()),_fsp(fsp),_cached_ds(0) +MEDFileFieldRepresentationLeaves::MEDFileFieldRepresentationLeaves(const std::vector< MEDCoupling::MCAuto >& arr, + const MEDCoupling::MCAuto& fsp):_arrays(arr.size()),_fsp(fsp),_cached_ds(0) { for(std::size_t i=0;i mst(MEDFileMeshStruct::New(meshes->getMeshWithName(_arrays[0]->getMeshName().c_str()))); + MCAuto mst(MEDFileMeshStruct::New(meshes->getMeshWithName(_arrays[0]->getMeshName().c_str()))); for(std::vector::const_iterator it=_arrays.begin();it!=_arrays.end();it++) if((*it).getStatus()) { @@ -631,32 +663,31 @@ void MEDFileFieldRepresentationLeaves::appendFields(const MEDTimeReq *tr, const vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationUnstructured(MEDUMeshMultiLev *mm) const { - const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; DataArrayDouble *coordsMC(0); DataArrayByte *typesMC(0); DataArrayInt *cellLocationsMC(0),*cellsMC(0),*faceLocationsMC(0),*facesMC(0); bool statusOfCoords(mm->buildVTUArrays(coordsMC,typesMC,cellLocationsMC,cellsMC,faceLocationsMC,facesMC)); - MEDCouplingAutoRefCountObjectPtr coordsSafe(coordsMC); - MEDCouplingAutoRefCountObjectPtr typesSafe(typesMC); - MEDCouplingAutoRefCountObjectPtr cellLocationsSafe(cellLocationsMC),cellsSafe(cellsMC),faceLocationsSafe(faceLocationsMC),facesSafe(facesMC); + MCAuto coordsSafe(coordsMC); + MCAuto typesSafe(typesMC); + MCAuto cellLocationsSafe(cellLocationsMC),cellsSafe(cellsMC),faceLocationsSafe(faceLocationsMC),facesSafe(facesMC); // int nbOfCells(typesSafe->getNbOfElems()); vtkUnstructuredGrid *ret(vtkUnstructuredGrid::New()); vtkUnsignedCharArray *cellTypes(vtkUnsignedCharArray::New()); - cellTypes->SetArray(reinterpret_cast(typesSafe->getPointer()),nbOfCells,0,VTK_DATA_ARRAY_FREE); typesSafe->accessToMemArray().setSpecificDeallocator(0); + AssignDataPointerOther(cellTypes,typesSafe,nbOfCells); vtkIdTypeArray *cellLocations(vtkIdTypeArray::New()); - cellLocations->SetVoidArray(cellLocationsSafe->getPointer(),nbOfCells,0,VTK_DATA_ARRAY_FREE); cellLocationsSafe->accessToMemArray().setSpecificDeallocator(0); + AssignDataPointerOther(cellLocations,cellLocationsSafe,nbOfCells); vtkCellArray *cells(vtkCellArray::New()); vtkIdTypeArray *cells2(vtkIdTypeArray::New()); - cells2->SetVoidArray(cellsSafe->getPointer(),cellsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); cellsSafe->accessToMemArray().setSpecificDeallocator(0); + AssignDataPointerOther(cells2,cellsSafe,cellsSafe->getNbOfElems()); cells->SetCells(nbOfCells,cells2); cells2->Delete(); if(faceLocationsMC!=0 && facesMC!=0) { vtkIdTypeArray *faces(vtkIdTypeArray::New()); - faces->SetVoidArray(facesSafe->getPointer(),facesSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); facesSafe->accessToMemArray().setSpecificDeallocator(0); + AssignDataPointerOther(faces,facesSafe,facesSafe->getNbOfElems()); vtkIdTypeArray *faceLocations(vtkIdTypeArray::New()); - faceLocations->SetVoidArray(faceLocationsSafe->getPointer(),faceLocationsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); faceLocationsSafe->accessToMemArray().setSpecificDeallocator(0); + AssignDataPointerOther(faceLocations,faceLocationsSafe,faceLocationsSafe->getNbOfElems()); ret->SetCells(cellTypes,cellLocations,cells,faceLocations,faces); faceLocations->Delete(); faces->Delete(); @@ -669,13 +700,7 @@ vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInt vtkPoints *pts(vtkPoints::New()); vtkDoubleArray *pts2(vtkDoubleArray::New()); pts2->SetNumberOfComponents(3); - if(!statusOfCoords) - { - pts2->SetArray(coordsSafe->getPointer(),coordsSafe->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); - coordsSafe->accessToMemArray().setSpecificDeallocator(0); - } - else - pts2->SetArray(coordsSafe->getPointer(),coordsSafe->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); + AssignDataPointerToVTK(pts2,coordsSafe,statusOfCoords); pts->SetData(pts2); pts2->Delete(); ret->SetPoints(pts); @@ -686,7 +711,6 @@ vtkUnstructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInt vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationCartesian(MEDCoupling::MEDCMeshMultiLev *mm) const { - const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; bool isInternal; std::vector< DataArrayDouble * > arrs(mm->buildVTUArrays(isInternal)); vtkDoubleArray *vtkTmp(0); @@ -703,10 +727,7 @@ vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInte ret->SetDimensions(sizePerAxe[0],sizePerAxe[1],sizePerAxe[2]); vtkTmp=vtkDoubleArray::New(); vtkTmp->SetNumberOfComponents(1); - if(isInternal) - vtkTmp->SetArray(arrs[0]->getPointer(),arrs[0]->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); - else - { vtkTmp->SetArray(arrs[0]->getPointer(),arrs[0]->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); arrs[0]->accessToMemArray().setSpecificDeallocator(0); } + AssignDataPointerToVTK(vtkTmp,arrs[0],isInternal); ret->SetXCoordinates(vtkTmp); vtkTmp->Delete(); arrs[0]->decrRef(); @@ -714,10 +735,7 @@ vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInte { vtkTmp=vtkDoubleArray::New(); vtkTmp->SetNumberOfComponents(1); - if(isInternal) - vtkTmp->SetArray(arrs[1]->getPointer(),arrs[1]->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); - else - { vtkTmp->SetArray(arrs[1]->getPointer(),arrs[1]->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); arrs[1]->accessToMemArray().setSpecificDeallocator(0); } + AssignDataPointerToVTK(vtkTmp,arrs[1],isInternal); ret->SetYCoordinates(vtkTmp); vtkTmp->Delete(); arrs[1]->decrRef(); @@ -726,10 +744,7 @@ vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInte { vtkTmp=vtkDoubleArray::New(); vtkTmp->SetNumberOfComponents(1); - if(isInternal) - vtkTmp->SetArray(arrs[2]->getPointer(),arrs[2]->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); - else - { vtkTmp->SetArray(arrs[2]->getPointer(),arrs[2]->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); arrs[2]->accessToMemArray().setSpecificDeallocator(0); } + AssignDataPointerToVTK(vtkTmp,arrs[2],isInternal); ret->SetZCoordinates(vtkTmp); vtkTmp->Delete(); arrs[2]->decrRef(); @@ -739,7 +754,6 @@ vtkRectilinearGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInte vtkStructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolationCurveLinear(MEDCoupling::MEDCurveLinearMeshMultiLev *mm) const { - const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; int meshStr[3]={1,1,1}; DataArrayDouble *coords(0); std::vector nodeStrct; @@ -758,17 +772,11 @@ vtkStructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInter vtkDoubleArray *da(vtkDoubleArray::New()); da->SetNumberOfComponents(3); if(coords->getNumberOfComponents()==3) - { - if(isInternal) - da->SetArray(coords->getPointer(),coords->getNbOfElems(),1,VTK_DATA_ARRAY_FREE);//VTK has not the ownership of double * because MEDLoader main struct has it ! - else - { da->SetArray(coords->getPointer(),coords->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); coords->accessToMemArray().setSpecificDeallocator(0); } - } + AssignDataPointerToVTK(da,coords,isInternal);//if isIntenal==True VTK has not the ownership of double * because MEDLoader main struct has it ! else { - MEDCouplingAutoRefCountObjectPtr coords2(coords->changeNbOfComponents(3,0.)); - da->SetArray(coords2->getPointer(),coords2->getNbOfElems(),0,VTK_DATA_ARRAY_FREE);//let VTK deal with double * - coords2->accessToMemArray().setSpecificDeallocator(0); + MCAuto coords2(coords->changeNbOfComponents(3,0.)); + AssignDataPointerToVTK(da,coords2,false);//let VTK deal with double * } coords->decrRef(); vtkPoints *points=vtkPoints::New(); @@ -781,11 +789,10 @@ vtkStructuredGrid *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInter vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolation(const MEDTimeReq *tr, const MEDFileFieldGlobsReal *globs, const MEDCoupling::MEDFileMeshes *meshes) const { - const int VTK_DATA_ARRAY_FREE=vtkDataArrayTemplate::VTK_DATA_ARRAY_FREE; vtkDataSet *ret(0); //_fsp->isDataSetSupportEqualToThePreviousOne(i,globs); - MEDCouplingAutoRefCountObjectPtr mml(_fsp->buildFromScratchDataSetSupport(0,globs));//0=timestep Id. Make the hypothesis that support does not change - MEDCouplingAutoRefCountObjectPtr mml2(mml->prepare()); + MCAuto mml(_fsp->buildFromScratchDataSetSupport(0,globs));//0=timestep Id. Make the hypothesis that support does not change + MCAuto mml2(mml->prepare()); MEDMeshMultiLev *ptMML2(mml2); if(!_cached_ds) { @@ -826,10 +833,7 @@ vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolatio vtkIntArray *vtkTab(vtkIntArray::New()); vtkTab->SetNumberOfComponents(1); vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_CELL_NAME); - if(noCpyFamCells) - vtkTab->SetArray(famCells->getPointer(),famCells->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); - else - { vtkTab->SetArray(famCells->getPointer(),famCells->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); famCells->accessToMemArray().setSpecificDeallocator(0); } + AssignDataPointerToVTK(vtkTab,famCells,noCpyFamCells); ret->GetCellData()->AddArray(vtkTab); vtkTab->Delete(); famCells->decrRef(); @@ -840,10 +844,7 @@ vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolatio vtkIntArray *vtkTab(vtkIntArray::New()); vtkTab->SetNumberOfComponents(1); vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::NUM_ID_CELL_NAME); - if(noCpyNumCells) - vtkTab->SetArray(numCells->getPointer(),numCells->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); - else - { vtkTab->SetArray(numCells->getPointer(),numCells->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); numCells->accessToMemArray().setSpecificDeallocator(0); } + AssignDataPointerToVTK(vtkTab,numCells,noCpyNumCells); ret->GetCellData()->AddArray(vtkTab); vtkTab->Delete(); numCells->decrRef(); @@ -857,10 +858,7 @@ vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolatio vtkIntArray *vtkTab(vtkIntArray::New()); vtkTab->SetNumberOfComponents(1); vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::FAMILY_ID_NODE_NAME); - if(noCpyFamNodes) - vtkTab->SetArray(famNodes->getPointer(),famNodes->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); - else - { vtkTab->SetArray(famNodes->getPointer(),famNodes->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); famNodes->accessToMemArray().setSpecificDeallocator(0); } + AssignDataPointerToVTK(vtkTab,famNodes,noCpyFamNodes); ret->GetPointData()->AddArray(vtkTab); vtkTab->Delete(); famNodes->decrRef(); @@ -871,14 +869,23 @@ vtkDataSet *MEDFileFieldRepresentationLeaves::buildVTKInstanceNoTimeInterpolatio vtkIntArray *vtkTab(vtkIntArray::New()); vtkTab->SetNumberOfComponents(1); vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::NUM_ID_NODE_NAME); - if(noCpyNumNodes) - vtkTab->SetArray(numNodes->getPointer(),numNodes->getNbOfElems(),1,VTK_DATA_ARRAY_FREE); - else - { vtkTab->SetArray(numNodes->getPointer(),numNodes->getNbOfElems(),0,VTK_DATA_ARRAY_FREE); numNodes->accessToMemArray().setSpecificDeallocator(0); } + AssignDataPointerToVTK(vtkTab,numNodes,noCpyNumNodes); ret->GetPointData()->AddArray(vtkTab); vtkTab->Delete(); numNodes->decrRef(); } + // Global Node Ids if any ! (In // mode) + DataArrayInt *gni(ptMML2->retrieveGlobalNodeIdsIfAny()); + if(gni) + { + vtkIntArray *vtkTab(vtkIntArray::New()); + vtkTab->SetNumberOfComponents(1); + vtkTab->SetName(MEDFileFieldRepresentationLeavesArrays::GLOBAL_NODE_ID_NAME); + AssignDataPointerToVTK(vtkTab,gni,false); + ret->GetPointData()->AddArray(vtkTab); + vtkTab->Delete(); + gni->decrRef(); + } return ret; } @@ -1113,7 +1120,7 @@ void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileNam MEDCoupling::MEDFileMesh *tmp(_ms->getMeshAtPos(i)); MEDCoupling::MEDFileUMesh *tmp2(dynamic_cast(tmp)); if(tmp2) - MEDCouplingAutoRefCountObjectPtr tmp3(tmp2->zipCoords()); + MCAuto tmp3(tmp2->zipCoords()); } _fields=MEDFileFields::LoadPartOf(fileName,false,_ms);//false is important to not read the values #else @@ -1124,8 +1131,8 @@ void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileNam } else { - MEDCouplingAutoRefCountObjectPtr sr(MEDCoupling::SauvReader::New(fileName)); - MEDCouplingAutoRefCountObjectPtr mfd(sr->loadInMEDFileDS()); + MCAuto sr(MEDCoupling::SauvReader::New(fileName)); + MCAuto mfd(sr->loadInMEDFileDS()); _ms=mfd->getMeshes(); _ms->incrRef(); int nbMeshes(_ms->getNumberOfMeshes()); for(int i=0;icartesianizeMe(); _fields->removeFieldsWithoutAnyTimeStep(); std::vector meshNames(_ms->getMeshesNames()); - std::vector< MEDCouplingAutoRefCountObjectPtr > fields_per_mesh(meshNames.size()); + std::vector< MCAuto > fields_per_mesh(meshNames.size()); for(std::size_t i=0;ipartOfThisLyingOnSpecifiedMeshName(meshNames[i].c_str()); } - std::vector< MEDCouplingAutoRefCountObjectPtr > allFMTSLeavesToDisplaySafe; + std::vector< MCAuto > allFMTSLeavesToDisplaySafe; std::size_t k(0); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator fields=fields_per_mesh.begin();fields!=fields_per_mesh.end();fields++) + for(std::vector< MCAuto >::const_iterator fields=fields_per_mesh.begin();fields!=fields_per_mesh.end();fields++) { for(int j=0;j<(*fields)->getNumberOfFields();j++) { - MEDCouplingAutoRefCountObjectPtr fmts((*fields)->getFieldAtPos((int)j)); - std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > tmp(fmts->splitDiscretizations()); + MCAuto fmts((*fields)->getFieldAtPos((int)j)); + std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > tmp(fmts->splitDiscretizations()); // EDF 8655 - for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > >::const_iterator it=tmp.begin();it!=tmp.end();it++) + for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > >::const_iterator it=tmp.begin();it!=tmp.end();it++) { if(!(*it)->presenceOfMultiDiscPerGeoType()) allFMTSLeavesToDisplaySafe.push_back(*it); else {// The case of some parts of field have more than one discretization per geo type. - std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > subTmp((*it)->splitMultiDiscrPerGeoTypes()); + std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > subTmp((*it)->splitMultiDiscrPerGeoTypes()); std::size_t it0Cnt(0); - for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > >::iterator it0=subTmp.begin();it0!=subTmp.end();it0++,it0Cnt++)//not const because setName + for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > >::iterator it0=subTmp.begin();it0!=subTmp.end();it0++,it0Cnt++)//not const because setName { std::ostringstream oss; oss << (*it0)->getName() << "_" << std::setfill('M') << std::setw(3) << it0Cnt; (*it0)->setName(oss.str()); @@ -1190,7 +1197,7 @@ void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileNam } std::vector< std::vector > allFMTSLeavesPerTimeSeries(MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(allFMTSLeavesToDisplay)); // memory safety part - std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr > > allFMTSLeavesPerTimeSeriesSafe(allFMTSLeavesPerTimeSeries.size()); + std::vector< std::vector< MCAuto > > allFMTSLeavesPerTimeSeriesSafe(allFMTSLeavesPerTimeSeries.size()); for(std::size_t j=0;j meshNamesLoc; - std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr > > splitByMeshName; + std::vector< std::vector< MCAuto > > splitByMeshName; for(std::size_t j=0;jgetMeshName()); @@ -1223,13 +1230,13 @@ void MEDFileFieldRepresentationTree::loadMainStructureOfFile(const char *fileNam _data_structure[i].resize(meshNamesLoc.size()); for(std::size_t j=0;j > fsp; + std::vector< MCAuto > fsp; std::vector< MEDFileAnyTypeFieldMultiTS *> sbmn(splitByMeshName[j].size()); for(std::size_t k=0;k > commonSupSplit(MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(sbmn,_ms->getMeshWithName(meshNamesLoc[j].c_str()),fsp)); - std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr > > commonSupSplitSafe(commonSupSplit.size()); + std::vector< std::vector< MCAuto > > commonSupSplitSafe(commonSupSplit.size()); this->_data_structure[i][j].resize(commonSupSplit.size()); for(std::size_t k=0;kgetMeshAtPos(i)); std::vector levs(mm->getNonEmptyLevels()); - MEDCoupling::MEDCouplingAutoRefCountObjectPtr f1tsMultiLev(MEDCoupling::MEDFileField1TS::New()); + MEDCoupling::MCAuto f1tsMultiLev(MEDCoupling::MEDFileField1TS::New()); MEDFileUMesh *mmu(dynamic_cast(mm)); if(mmu) { @@ -1425,9 +1432,9 @@ void MEDFileFieldRepresentationTree::AppendFieldFromMeshes(const MEDCoupling::ME for(std::vector::const_iterator gt=gts.begin();gt!=gts.end();gt++) { MEDCoupling::MEDCouplingMesh *m(mmu->getDirectUndergroundSingleGeoTypeMesh(*gt)); - MEDCoupling::MEDCouplingAutoRefCountObjectPtr f(MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS)); + MEDCoupling::MCAuto f(MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS)); f->setMesh(m); - MEDCoupling::MEDCouplingAutoRefCountObjectPtr arr(MEDCoupling::DataArrayDouble::New()); arr->alloc(f->getNumberOfTuplesExpected()); + MEDCoupling::MCAuto arr(MEDCoupling::DataArrayDouble::New()); arr->alloc(f->getNumberOfTuplesExpected()); arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA)); arr->iota(); f->setArray(arr); @@ -1440,10 +1447,10 @@ void MEDFileFieldRepresentationTree::AppendFieldFromMeshes(const MEDCoupling::ME std::vector levsExt(mm->getNonEmptyLevelsExt()); if(levsExt.size()==levs.size()+1) { - MEDCoupling::MEDCouplingAutoRefCountObjectPtr m(mm->getMeshAtLevel(1)); - MEDCoupling::MEDCouplingAutoRefCountObjectPtr f(MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_NODES)); + MEDCoupling::MCAuto m(mm->getMeshAtLevel(1)); + MEDCoupling::MCAuto f(MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_NODES)); f->setMesh(m); - MEDCoupling::MEDCouplingAutoRefCountObjectPtr arr(MEDCoupling::DataArrayDouble::New()); arr->alloc(m->getNumberOfNodes()); + MEDCoupling::MCAuto arr(MEDCoupling::DataArrayDouble::New()); arr->alloc(m->getNumberOfNodes()); arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA)); arr->iota(); f->setArray(arr); f->setName(BuildAUniqueArrayNameForMesh(mm->getName(),ret)); @@ -1455,10 +1462,10 @@ void MEDFileFieldRepresentationTree::AppendFieldFromMeshes(const MEDCoupling::ME } else { - MEDCoupling::MEDCouplingAutoRefCountObjectPtr m(mm->getMeshAtLevel(0)); - MEDCoupling::MEDCouplingAutoRefCountObjectPtr f(MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS)); + MEDCoupling::MCAuto m(mm->getMeshAtLevel(0)); + MEDCoupling::MCAuto f(MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS)); f->setMesh(m); - MEDCoupling::MEDCouplingAutoRefCountObjectPtr arr(MEDCoupling::DataArrayDouble::New()); arr->alloc(f->getNumberOfTuplesExpected()); + MEDCoupling::MCAuto arr(MEDCoupling::DataArrayDouble::New()); arr->alloc(f->getNumberOfTuplesExpected()); arr->setInfoOnComponent(0,std::string(COMPO_STR_TO_LOCATE_MESH_DA)); arr->iota(); f->setArray(arr); @@ -1466,7 +1473,7 @@ void MEDFileFieldRepresentationTree::AppendFieldFromMeshes(const MEDCoupling::ME f1tsMultiLev->setFieldNoProfileSBT(f); } // - MEDCoupling::MEDCouplingAutoRefCountObjectPtr fmtsMultiLev(MEDCoupling::MEDFileFieldMultiTS::New()); + MEDCoupling::MCAuto fmtsMultiLev(MEDCoupling::MEDFileFieldMultiTS::New()); fmtsMultiLev->pushBackTimeStep(f1tsMultiLev); ret->pushField(fmtsMultiLev); } @@ -1488,7 +1495,7 @@ std::string MEDFileFieldRepresentationTree::BuildAUniqueArrayNameForMesh(const s MEDCoupling::MEDFileFields *MEDFileFieldRepresentationTree::BuildFieldFromMeshes(const MEDCoupling::MEDFileMeshes *ms) { - MEDCoupling::MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling::MEDFileFields::New()); + MEDCoupling::MCAuto ret(MEDCoupling::MEDFileFields::New()); AppendFieldFromMeshes(ms,ret); return ret.retn(); }