-// 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
#include "vtkCellArray.h"
#include "vtkDoubleArray.h"
#include "vtkObjectFactory.h"
+#include "vtkInformationDataObjectMetaDataKey.h"
+
#ifdef MEDREADER_USE_MPI
#include "vtkMultiProcessController.h"
#endif
/*!
* This class stores properties in loading state mode (pvsm) when the MED file has not been read yet.
- * The file is not read beacause FileName has not been informed yet ! So this class stores properties of vtkMEDReader instance that
+ * The file is not read beacause FileName has not been informed yet ! So this class stores properties of vtkMEDReader instance that
* owns it and wait the vtkMEDReader::SetFileName to apply properties afterwards.
*/
class PropertyKeeper
vtkMEDReaderInternal(vtkMEDReader *master):TK(0),IsMEDOrSauv(true),IsStdOrMode(false),GenerateVect(false),SIL(0),LastLev0(-1),FirstCall0(2),PK(master),MyMTime(0)
{
}
-
+
bool PluginStart0()
{
+ return false; // TODO Useless and buggy
if(FirstCall0==0)
return false;
FirstCall0--;
return true;
}
-
+
~vtkMEDReaderInternal()
{
if(this->SIL)
int MyMTime;
std::set<std::string> _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<std::string,bool> _wonderful_ref;// this map stores the state before a SetFieldsStatus status.
+
private:
unsigned char FirstCall0;
};
vtkStandardNewMacro(vtkMEDReader);
+// vtkInformationKeyMacro(vtkMEDReader, META_DATA, DataObjectMetaData); // Here we need to customize vtkMEDReader::META_DATA method
+// start of overload of vtkInformationKeyMacro
+static vtkInformationDataObjectMetaDataKey *vtkMEDReader_META_DATA=new vtkInformationDataObjectMetaDataKey("META_DATA","vtkMEDReader");
+
+vtkInformationDataObjectMetaDataKey *vtkMEDReader::META_DATA()
+{
+ static const char ZE_KEY[]="vtkMEDReader::META_DATA";
+ vtkInformationDataObjectMetaDataKey *ret(vtkMEDReader_META_DATA);
+ ParaMEDMEM::GlobalDict *gd(ParaMEDMEM::GlobalDict::GetInstance());
+ if(!gd->hasKey(ZE_KEY))
+ {// here META_DATA is put on global var to be exchanged with other filters without dependancy of MEDReader. Please do not change ZE_KEY !
+ std::ostringstream oss; oss << ret;
+ gd->setKeyValue(ZE_KEY,oss.str());
+ }
+ return ret;
+}
+// end of overload of vtkInformationKeyMacro
+
vtkMEDReader::vtkMEDReader():Internal(new vtkMEDReaderInternal(this))
{
this->SetNumberOfInputPorts(0);
this->Internal = 0;
}
-void vtkMEDReader::Reload(int a)
+void vtkMEDReader::Reload()
{
- if(a==0)
- return;
- std::cerr << "vtkMEDReader::Reload" << a << std::endl;
std::string fName((const char *)this->GetFileName());
delete this->Internal;
this->Internal=new vtkMEDReaderInternal(this);
}
//not pvsm mode (general case)
this->Internal->IsStdOrMode=newMode!=0;
- //std::cerr << "vtkMEDReader::ChangeMode : " << this->Internal->IsStdOrMode << std::endl;
this->Modified();
}
int vtkMEDReader::RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
{
- //std::cerr << "########################################## RequestInformation ##########################################" << std::endl;
+// std::cout << "########################################## vtkMEDReader::RequestInformation ##########################################" << std::endl;
if(!this->Internal)
return 0;
try
{
+// request->Print(cout);
vtkInformation *outInfo(outputVector->GetInformationObject(0));
outInfo->Set(vtkDataObject::DATA_TYPE_NAME(),"vtkMultiBlockDataSet");
- this->UpdateSIL(outInfo);
- //
+ this->UpdateSIL(request, outInfo);
+
+ // Set the meta data graph as a meta data key in the information
+ // That's all that is needed to transfer it along the pipeline
+ outInfo->Set(vtkMEDReader::META_DATA(),this->Internal->SIL);
+
bool dummy(false);
this->PublishTimeStepsIfNeeded(outInfo,dummy);
}
int vtkMEDReader::RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
{
- //std::cerr << "########################################## RequestData ##########################################";
+// std::cout << "########################################## vtkMEDReader::RequestData ##########################################" << std::endl;
if(!this->Internal)
return 0;
try
{
+// request->Print(cout);
vtkInformation *outInfo(outputVector->GetInformationObject(0));
vtkMultiBlockDataSet *output(vtkMultiBlockDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())));
bool isUpdated(false);
double reqTS(0.);
if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()))
reqTS=outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
- //std::cerr << reqTS << std::endl;
this->FillMultiBlockDataSetInstance(output,reqTS);
output->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(),reqTS);
- this->UpdateSIL(outInfo);
- //this->UpdateProgress((float) progress/((float) maxprogress-1));
+
+ // Is it really needed ? TODO
+ this->UpdateSIL(request, outInfo);
}
catch(INTERP_KERNEL::Exception& e)
{
if(!this->Internal)
return 0;
return this->Internal->Tree.getNumberOfLeavesArrays();
- //std::cerr << "vtkMEDReader::GetNumberOfFieldsTreeArrays called ! " << ret << std::endl;
}
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)
return (int)this->Internal->TK.getTimesFlagArray()[pos].first;
}
-void vtkMEDReader::UpdateSIL(vtkInformation *info)
+void vtkMEDReader::UpdateSIL(vtkInformation* request, vtkInformation *info)
{
if(!this->Internal)
return;
vtkMutableDirectedGraph *sil(vtkMutableDirectedGraph::New());
+
+ // This Should be more clever, TODO
std::string meshName(this->BuildSIL(sil));
if(meshName!=this->Internal->DftMeshName)
{
this->Internal->SIL->Delete();
this->Internal->SIL=sil;
this->Internal->DftMeshName=meshName;
- info->Set(vtkDataObject::SIL(),this->Internal->SIL);
- //request->AppendUnique(vtkExecutive::KEYS_TO_COPY(),vtkDataObject::SIL());
}
else
{