X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPlugins%2FMEDReader%2FIO%2FvtkMEDReader.cxx;h=07d89f1b74021ad6f331516b6542e793cb8e47e2;hb=a833b1388f958c887b2b0886fc40a8be0256e2c8;hp=6f214ff158c1561912e8f37dad6d0434d2266989;hpb=37f29369fb9b048ee4673cd8da4a3b9025156ca6;p=modules%2Fparavis.git diff --git a/src/Plugins/MEDReader/IO/vtkMEDReader.cxx b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx index 6f214ff1..07d89f1b 100644 --- a/src/Plugins/MEDReader/IO/vtkMEDReader.cxx +++ b/src/Plugins/MEDReader/IO/vtkMEDReader.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2014 CEA/DEN, EDF R&D +// Copyright (C) 2010-2015 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 @@ -44,9 +44,13 @@ #include "vtkCellArray.h" #include "vtkDoubleArray.h" #include "vtkObjectFactory.h" +#ifdef MEDREADER_USE_MPI +#include "vtkMultiProcessController.h" +#endif #include "MEDFileFieldRepresentationTree.hxx" +#include #include #include #include @@ -147,7 +151,7 @@ class vtkMEDReader::vtkMEDReaderInternal { public: - vtkMEDReaderInternal(vtkMEDReader *master):TK(0),IsMEDOrSauv(true),IsStdOrMode(false),GenerateVect(false),SIL(0),LastLev0(-1),FirstCall0(2),PK(master) + vtkMEDReaderInternal(vtkMEDReader *master):TK(0),IsMEDOrSauv(true),IsStdOrMode(false),GenerateVect(false),SIL(0),LastLev0(-1),FirstCall0(2),PK(master),MyMTime(0) { } @@ -181,6 +185,9 @@ public: int LastLev0; // The property keeper is usable only in pvsm mode. PropertyKeeper PK; + int MyMTime; + std::set _wonderful_set;// this set is used by SetFieldsStatus method to detect the fact that SetFieldsStatus has been called for all items ! Great Items are not sorted ! Why ? + std::map _wonderful_ref;// this map stores the state before a SetFieldsStatus status. private: unsigned char FirstCall0; }; @@ -196,6 +203,7 @@ vtkMEDReader::vtkMEDReader():Internal(new vtkMEDReaderInternal(this)) vtkMEDReader::~vtkMEDReader() { delete this->Internal; + this->Internal = 0; } void vtkMEDReader::Reload(int a) @@ -209,8 +217,18 @@ void vtkMEDReader::Reload(int a) this->SetFileName(fName.c_str()); } +int vtkMEDReader::GetServerModifTime() +{ + if( !this->Internal ) + return -1; + return this->Internal->MyMTime; +} + void vtkMEDReader::GenerateVectors(int val) { + if ( !this->Internal ) + return; + if(this->Internal->FileName.empty()) {//pvsm mode this->Internal->PK.pushGenerateVectorsValue(val); @@ -227,6 +245,9 @@ void vtkMEDReader::GenerateVectors(int val) void vtkMEDReader::ChangeMode(int newMode) { + if ( !this->Internal ) + return; + if(this->Internal->FileName.empty()) {//pvsm mode this->Internal->PK.pushChangeModeValue(newMode); @@ -245,6 +266,8 @@ const char *vtkMEDReader::GetSeparator() void vtkMEDReader::SetFileName(const char *fname) { + if(!this->Internal) + return; try { this->Internal->FileName=fname; @@ -257,7 +280,16 @@ void vtkMEDReader::SetFileName(const char *fname) } if(this->Internal->Tree.getNumberOfLeavesArrays()==0) { - this->Internal->Tree.loadMainStructureOfFile(this->Internal->FileName.c_str(),this->Internal->IsMEDOrSauv); + int iPart(-1),nbOfParts(-1); +#ifdef MEDREADER_USE_MPI + vtkMultiProcessController *vmpc(vtkMultiProcessController::GetGlobalController()); + if(vmpc) + { + iPart=vmpc->GetLocalProcessId(); + nbOfParts=vmpc->GetNumberOfProcesses(); + } +#endif + this->Internal->Tree.loadMainStructureOfFile(this->Internal->FileName.c_str(),this->Internal->IsMEDOrSauv,iPart,nbOfParts); if(!this->Internal->PK.arePropertiesOnTreeToSetAfter()) this->Internal->Tree.activateTheFirst();//This line manually initialize the status of server (this) with the remote client. this->Internal->TK.setMaxNumberOfTimeSteps(this->Internal->Tree.getMaxNumberOfTimeSteps()); @@ -281,6 +313,8 @@ void vtkMEDReader::SetFileName(const char *fname) char *vtkMEDReader::GetFileName() { + if (!this->Internal) + return 0; return const_cast(this->Internal->FileName.c_str()); } @@ -292,7 +326,6 @@ int vtkMEDReader::RequestInformation(vtkInformation *request, vtkInformationVect try { vtkInformation *outInfo(outputVector->GetInformationObject(0)); - outInfo->Set(vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES(),-1); outInfo->Set(vtkDataObject::DATA_TYPE_NAME(),"vtkMultiBlockDataSet"); this->UpdateSIL(outInfo); // @@ -301,7 +334,13 @@ int vtkMEDReader::RequestInformation(vtkInformation *request, vtkInformationVect } catch(INTERP_KERNEL::Exception& e) { - std::cerr << "Exception has been thrown in vtkMEDReader::RequestInformation : " << e.what() << std::endl; + std::ostringstream oss; + oss << "Exception has been thrown in vtkMEDReader::RequestInformation : " << e.what() << std::endl; + if(this->HasObserver("ErrorEvent") ) + this->InvokeEvent("ErrorEvent",const_cast(oss.str().c_str())); + else + vtkOutputWindowDisplayErrorText(const_cast(oss.str().c_str())); + vtkObject::BreakOnError(); return 0; } return 1; @@ -336,19 +375,34 @@ int vtkMEDReader::RequestData(vtkInformation *request, vtkInformationVector **in void vtkMEDReader::SetFieldsStatus(const char* name, int status) { - //std::cerr << "vtkMEDReader::SetFieldsStatus(" << name << "," << status << ") called !" << std::endl; + if( !this->Internal ) + return; + + //this->Internal->_wonderful_set.insert(name); if(this->Internal->FileName.empty()) {//pvsm mode this->Internal->PK.pushFieldStatusEntry(name,status); return ; } + if(this->Internal->_wonderful_set.empty()) + this->Internal->_wonderful_ref=this->Internal->Tree.dumpState();// start of SetFieldsStatus serie -> store ref to compare at the end of the SetFieldsStatus serie. + this->Internal->_wonderful_set.insert(name); //not pvsm mode (general case) try { this->Internal->Tree.changeStatusOfAndUpdateToHaveCoherentVTKDataSet(this->Internal->Tree.getIdHavingZeName(name),status); - if(std::string(name)==GetFieldsTreeArrayName(GetNumberOfFieldsTreeArrays()-1)) - if(!this->Internal->PluginStart0()) - this->Modified(); + if(this->Internal->_wonderful_set.size()==GetNumberOfFieldsTreeArrays()) + { + if(this->Internal->_wonderful_ref!=this->Internal->Tree.dumpState()) + { + if(!this->Internal->PluginStart0()) + { + this->Modified(); + } + this->Internal->MyMTime++; + } + this->Internal->_wonderful_set.clear(); + } } catch(INTERP_KERNEL::Exception& e) { @@ -364,19 +418,23 @@ int vtkMEDReader::GetNumberOfFieldsTreeArrays() { if(!this->Internal) return 0; - int ret(this->Internal->Tree.getNumberOfLeavesArrays()); + return this->Internal->Tree.getNumberOfLeavesArrays(); //std::cerr << "vtkMEDReader::GetNumberOfFieldsTreeArrays called ! " << ret << std::endl; - return ret; } const char *vtkMEDReader::GetFieldsTreeArrayName(int index) { + if(!this->Internal) + return 0; return this->Internal->Tree.getNameOfC(index); //std::cerr << "vtkMEDReader::GetFieldsTreeArrayName(" << index << ") called ! " << ret << std::endl; } int vtkMEDReader::GetFieldsTreeArrayStatus(const char *name) { + if(!this->Internal) + return -1; + int zeId(this->Internal->Tree.getIdHavingZeName(name)); int ret(this->Internal->Tree.getStatusOf(zeId)); return ret; @@ -384,6 +442,9 @@ int vtkMEDReader::GetFieldsTreeArrayStatus(const char *name) void vtkMEDReader::SetTimesFlagsStatus(const char *name, int status) { + if (!this->Internal) + return; + if(this->Internal->FileName.empty()) {//pvsm mode this->Internal->PK.pushTimesFlagsStatusEntry(name,status); @@ -415,6 +476,8 @@ const char *vtkMEDReader::GetTimesFlagsArrayName(int index) int vtkMEDReader::GetTimesFlagsArrayStatus(const char *name) { + if(!this->Internal) + return -1; int pos(0); std::istringstream iss(name); iss >> pos; return (int)this->Internal->TK.getTimesFlagArray()[pos].first; @@ -423,7 +486,7 @@ int vtkMEDReader::GetTimesFlagsArrayStatus(const char *name) void vtkMEDReader::UpdateSIL(vtkInformation *info) { if(!this->Internal) - return ; + return; vtkMutableDirectedGraph *sil(vtkMutableDirectedGraph::New()); std::string meshName(this->BuildSIL(sil)); if(meshName!=this->Internal->DftMeshName) @@ -446,6 +509,8 @@ void vtkMEDReader::UpdateSIL(vtkInformation *info) */ std::string vtkMEDReader::BuildSIL(vtkMutableDirectedGraph* sil) { + if (!this->Internal) + return std::string(); sil->Initialize(); vtkSmartPointer childEdge(vtkSmartPointer::New()); childEdge->InsertNextValue(0); @@ -482,6 +547,9 @@ std::string vtkMEDReader::BuildSIL(vtkMutableDirectedGraph* sil) double vtkMEDReader::PublishTimeStepsIfNeeded(vtkInformation *outInfo, bool& isUpdated) { + if(!this->Internal) + return 0.0; + int lev0(-1); std::vector tsteps; if(!this->Internal->IsStdOrMode) @@ -504,6 +572,8 @@ double vtkMEDReader::PublishTimeStepsIfNeeded(vtkInformation *outInfo, bool& isU void vtkMEDReader::FillMultiBlockDataSetInstance(vtkMultiBlockDataSet *output, double reqTS) { + if( !this->Internal ) + return; std::string meshName; vtkDataSet *ret(this->Internal->Tree.buildVTKInstance(this->Internal->IsStdOrMode,reqTS,meshName,this->Internal->TK)); if(this->Internal->GenerateVect)