Salome HOME
Merge branch 'master' into V7_5_BR
[modules/paravis.git] / src / Plugins / MEDReader / IO / vtkMEDReader.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 769e87a..68add79
@@ -44,6 +44,9 @@
 #include "vtkCellArray.h"
 #include "vtkDoubleArray.h"
 #include "vtkObjectFactory.h"
+#ifdef MEDREADER_USE_MPI
+#include "vtkMultiProcessController.h"
+#endif
 
 #include "MEDFileFieldRepresentationTree.hxx"
 
@@ -257,7 +260,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());
@@ -292,7 +304,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 +312,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<char *>(oss.str().c_str()));
+      else
+        vtkOutputWindowDisplayErrorText(const_cast<char *>(oss.str().c_str()));
+      vtkObject::BreakOnError();
       return 0;
     }
   return 1;
@@ -328,7 +345,7 @@ int vtkMEDReader::RequestData(vtkInformation *request, vtkInformationVector **in
     }
   catch(INTERP_KERNEL::Exception& e)
     {
-      std::cerr << "Exception has been thrown in vtkMEDReader::RequestInformation : " << e.what() << std::endl;
+      std::cerr << "Exception has been thrown in vtkMEDReader::RequestData : " << e.what() << std::endl;
       return 0;
     }
   return 1;