return _ze_full_name;
}
-void MEDFileFieldRepresentationLeavesArrays::feedSIL(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, const std::string& tsName, const std::string& meshName, const std::string& comSupStr, std::vector<std::string>& names) const
+void MEDFileFieldRepresentationLeavesArrays::feedSIL(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, std::vector<std::string>& names) const
{
vtkIdType refId(sil->AddChild(root,edge));
names.push_back(_ze_name);
- std::ostringstream oss3; oss3 << tsName << "/" << meshName << "/" << comSupStr << "/" << _ze_name;
- _ze_full_name=oss3.str();
//
if(MEDFileFieldRepresentationTree::IsFieldMeshRegardingInfo(((operator->())->getInfo())))
{
}
}
+void MEDFileFieldRepresentationLeavesArrays::computeFullNameInLeaves(const std::string& tsName, const std::string& meshName, const std::string& comSupStr) const
+{
+ std::ostringstream oss3; oss3 << tsName << "/" << meshName << "/" << comSupStr << "/" << _ze_name;
+ _ze_full_name=oss3.str();
+}
+
bool MEDFileFieldRepresentationLeavesArrays::getStatus() const
{
return _activated;
return _arrays[0]->getNumberOfTS();
}
+void MEDFileFieldRepresentationLeaves::computeFullNameInLeaves(const std::string& tsName, const std::string& meshName, const std::string& comSupStr) const
+{
+ for(std::vector<MEDFileFieldRepresentationLeavesArrays>::const_iterator it=_arrays.begin();it!=_arrays.end();it++)
+ (*it).computeFullNameInLeaves(tsName,meshName,comSupStr);
+}
+
/*!
* \param [in] ms is the meshes pointer. It can be used only for information of geometric types. No special processing will be requested on ms.
*/
-void MEDFileFieldRepresentationLeaves::feedSIL(const ParaMEDMEM::MEDFileMeshes *ms, vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, const std::string& tsName, const std::string& meshName, const std::string& comSupStr, std::vector<std::string>& names) const
+void MEDFileFieldRepresentationLeaves::feedSIL(const ParaMEDMEM::MEDFileMeshes *ms, const std::string& meshName, vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, std::vector<std::string>& names) const
{
vtkIdType root2(sil->AddChild(root,edge));
names.push_back(std::string("Arrs"));
for(std::vector<MEDFileFieldRepresentationLeavesArrays>::const_iterator it=_arrays.begin();it!=_arrays.end();it++)
- (*it).feedSIL(sil,root2,edge,tsName,meshName,comSupStr,names);
+ (*it).feedSIL(sil,root2,edge,names);
//
vtkIdType root3(sil->AddChild(root,edge));
names.push_back(std::string("InfoOnGeoType"));
for(std::vector< MEDFileFieldRepresentationLeaves >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
(*it2).setId(zeId);
}
+
+void MEDFileFieldRepresentationTree::computeFullNameInLeaves() const
+{
+ std::size_t it0Cnt(0);
+ for(std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > >::const_iterator it0=_data_structure.begin();it0!=_data_structure.end();it0++,it0Cnt++)
+ {
+ std::ostringstream oss; oss << MEDFileFieldRepresentationLeavesArrays::TS_STR << it0Cnt;
+ std::string tsName(oss.str());
+ for(std::vector< std::vector< MEDFileFieldRepresentationLeaves > >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
+ {
+ std::string meshName((*it1)[0].getMeshName());
+ std::size_t it2Cnt(0);
+ for(std::vector< MEDFileFieldRepresentationLeaves >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++,it2Cnt++)
+ {
+ std::ostringstream oss2; oss2 << MEDFileFieldRepresentationLeavesArrays::COM_SUP_STR << it2Cnt;
+ std::string comSupStr(oss2.str());
+ (*it2).computeFullNameInLeaves(tsName,meshName,comSupStr);
+ }
+ }
+ }
+}
+
void MEDFileFieldRepresentationTree::activateTheFirst() const
{
for(std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > >::const_iterator it0=_data_structure.begin();it0!=_data_structure.end();it0++)
std::string comSupStr(oss2.str());
vtkIdType typeId2(sil->AddChild(typeId1,edge));
names.push_back(comSupStr);
- (*it2).feedSIL(_ms,sil,typeId2,edge,tsName,meshName,comSupStr,names);
+ (*it2).feedSIL(_ms,meshName,sil,typeId2,edge,names);
}
}
}
}
this->removeEmptyLeaves();
this->assignIds();
+ this->computeFullNameInLeaves();
}
void MEDFileFieldRepresentationTree::removeEmptyLeaves()
MEDFileFieldRepresentationLeavesArrays& operator=(const MEDFileFieldRepresentationLeavesArrays& other);
int getId() const;
void setId(int& id) const;
- void feedSIL(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, const std::string& tsName, const std::string& meshName, const std::string& comSupStr, std::vector<std::string>& names) const;
+ void feedSIL(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, std::vector<std::string>& names) const;
+ void computeFullNameInLeaves(const std::string& tsName, const std::string& meshName, const std::string& comSupStr) const;
bool getStatus() const;
bool setStatus(bool status) const;
std::string getZeName() const;
std::string getMeshName() const;
int getNumberOfArrays() const;
int getNumberOfTS() const;
- void feedSIL(const ParaMEDMEM::MEDFileMeshes *ms, vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, const std::string& tsName, const std::string& meshName, const std::string& compSupStr, std::vector<std::string>& names) const;
+ void feedSIL(const ParaMEDMEM::MEDFileMeshes *ms, const std::string& meshName, vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, std::vector<std::string>& names) const;
+ void computeFullNameInLeaves(const std::string& tsName, const std::string& meshName, const std::string& comSupStr) const;
bool containId(int id) const;
bool containZeName(const char *name, int& id) const;
bool isActivated() const;
int getNumberOfLeavesArrays() const;
void assignIds() const;
void activateTheFirst() const;
+ void computeFullNameInLeaves() const;
void feedSIL(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, std::vector<std::string>& names) const;
std::string feedSILForFamsAndGrps(vtkMutableDirectedGraph* sil, vtkIdType root, vtkVariantArray *edge, std::vector<std::string>& names) const;
std::string getNameOf(int id) const;
#include <sstream>
#include <algorithm>
+/*!
+ * 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
+ * owns it and wait the vtkMEDReader::SetFileName to apply properties afterwards.
+ */
+class PropertyKeeper
+{
+public:
+ PropertyKeeper(vtkMEDReader *master):_master(master),IsGVActivated(false),GVValue(0),IsCMActivated(false),CMValue(0) { }
+ void assignPropertiesIfNeeded();
+ bool arePropertiesOnTreeToSetAfter() const;
+ //
+ void pushFieldStatusEntry(const char* name, int status);
+ void pushGenerateVectorsValue(int value);
+ void pushChangeModeValue(int value);
+ void pushTimesFlagsStatusEntry(const char* name, int status);
+protected:
+ // pool of pairs to assign in SetFieldsStatus if needed. The use case is the load using pvsm.
+ std::vector< std::pair<std::string,int> > SetFieldsStatusPairs;
+ // generate vector
+ bool IsGVActivated;
+ int GVValue;
+ // change mode
+ bool IsCMActivated;
+ int CMValue;
+ //
+ std::vector< std::pair<std::string,int> > TimesFlagsStatusPairs;
+ vtkMEDReader *_master;
+};
+
+void PropertyKeeper::assignPropertiesIfNeeded()
+{
+ if(!this->SetFieldsStatusPairs.empty())
+ {
+ for(std::vector< std::pair<std::string,int> >::const_iterator it=this->SetFieldsStatusPairs.begin();it!=this->SetFieldsStatusPairs.end();it++)
+ _master->SetFieldsStatus((*it).first.c_str(),(*it).second);
+ this->SetFieldsStatusPairs.clear();
+ }
+ if(!this->TimesFlagsStatusPairs.empty())
+ {
+ for(std::vector< std::pair<std::string,int> >::const_iterator it=this->TimesFlagsStatusPairs.begin();it!=this->TimesFlagsStatusPairs.end();it++)
+ _master->SetTimesFlagsStatus((*it).first.c_str(),(*it).second);
+ this->TimesFlagsStatusPairs.clear();
+ }
+ if(this->IsGVActivated)
+ {
+ _master->GenerateVectors(this->GVValue);
+ this->IsGVActivated=false;
+ }
+ if(this->IsCMActivated)
+ {
+ _master->ChangeMode(this->CMValue);
+ this->IsCMActivated=false;
+ }
+}
+
+void PropertyKeeper::pushFieldStatusEntry(const char* name, int status)
+{
+ bool found(false);
+ for(std::vector< std::pair<std::string,int> >::const_iterator it=this->SetFieldsStatusPairs.begin();it!=this->SetFieldsStatusPairs.end() && !found;it++)
+ found=(*it).first==name;
+ if(!found)
+ this->SetFieldsStatusPairs.push_back(std::pair<std::string,int>(name,status));
+}
+
+void PropertyKeeper::pushTimesFlagsStatusEntry(const char* name, int status)
+{
+ bool found(false);
+ for(std::vector< std::pair<std::string,int> >::const_iterator it=this->TimesFlagsStatusPairs.begin();it!=this->TimesFlagsStatusPairs.end() && !found;it++)
+ found=(*it).first==name;
+ if(!found)
+ this->TimesFlagsStatusPairs.push_back(std::pair<std::string,int>(name,status));
+}
+
+void PropertyKeeper::pushGenerateVectorsValue(int value)
+{
+ this->IsGVActivated=true;
+ this->GVValue=value;
+}
+
+void PropertyKeeper::pushChangeModeValue(int value)
+{
+ this->IsCMActivated=true;
+ this->CMValue=value;
+}
+
+bool PropertyKeeper::arePropertiesOnTreeToSetAfter() const
+{
+ return !SetFieldsStatusPairs.empty();
+}
+
class vtkMEDReader::vtkMEDReaderInternal
{
public:
- vtkMEDReaderInternal():TK(0),IsMEDOrSauv(true),IsStdOrMode(false),GenerateVect(false),SIL(0),LastLev0(-1),FirstCall0(2)
+ vtkMEDReaderInternal(vtkMEDReader *master):TK(0),IsMEDOrSauv(true),IsStdOrMode(false),GenerateVect(false),SIL(0),LastLev0(-1),FirstCall0(2),PK(master)
{
}
vtkMutableDirectedGraph* SIL;
// store the lev0 id in Tree corresponding to the TIME_STEPS in the pipeline.
int LastLev0;
+ // The property keeper is usable only in pvsm mode.
+ PropertyKeeper PK;
private:
unsigned char FirstCall0;
};
vtkStandardNewMacro(vtkMEDReader);
-vtkMEDReader::vtkMEDReader():Internal(new vtkMEDReaderInternal)
+vtkMEDReader::vtkMEDReader():Internal(new vtkMEDReaderInternal(this))
{
this->SetNumberOfInputPorts(0);
this->SetNumberOfOutputPorts(1);
std::cerr << "vtkMEDReader::Reload" << a << std::endl;
std::string fName((const char *)this->GetFileName());
delete this->Internal;
- this->Internal=new vtkMEDReaderInternal;
+ this->Internal=new vtkMEDReaderInternal(this);
this->SetFileName(fName.c_str());
}
void vtkMEDReader::GenerateVectors(int val)
{
+ if(this->Internal->FileName.empty())
+ {//pvsm mode
+ this->Internal->PK.pushGenerateVectorsValue(val);
+ return ;
+ }
+ //not pvsm mode (general case)
bool val2((bool)val);
if(val2!=this->Internal->GenerateVect)
{
void vtkMEDReader::ChangeMode(int newMode)
{
+ if(this->Internal->FileName.empty())
+ {//pvsm mode
+ this->Internal->PK.pushChangeModeValue(newMode);
+ return ;
+ }
+ //not pvsm mode (general case)
this->Internal->IsStdOrMode=newMode!=0;
//std::cerr << "vtkMEDReader::ChangeMode : " << this->Internal->IsStdOrMode << std::endl;
this->Modified();
if(this->Internal->Tree.getNumberOfLeavesArrays()==0)
{
this->Internal->Tree.loadMainStructureOfFile(this->Internal->FileName.c_str(),this->Internal->IsMEDOrSauv);
- this->Internal->Tree.activateTheFirst();//This line manually initialize the status of server (this) with the remote client.
+ 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());
}
this->Modified();
+ this->Internal->PK.assignPropertiesIfNeeded();
}
catch(INTERP_KERNEL::Exception& e)
{
void vtkMEDReader::SetFieldsStatus(const char* name, int status)
{
//std::cerr << "vtkMEDReader::SetFieldsStatus(" << name << "," << status << ") called !" << std::endl;
- 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->FileName.empty())
+ {//pvsm mode
+ this->Internal->PK.pushFieldStatusEntry(name,status);
+ return ;
+ }
+ //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();
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ if(!this->Internal->FileName.empty())
+ {
+ std::cerr << "vtkMEDReader::SetFieldsStatus error : " << e.what() << " *** WITH STATUS=" << status << endl;
+ return ;
+ }
+ }
}
int vtkMEDReader::GetNumberOfFieldsTreeArrays()
void vtkMEDReader::SetTimesFlagsStatus(const char *name, int status)
{
+ if(this->Internal->FileName.empty())
+ {//pvsm mode
+ this->Internal->PK.pushTimesFlagsStatusEntry(name,status);
+ return ;
+ }
+ //not pvsm mode (general case)
int pos(0);
std::istringstream iss(name); iss >> pos;
this->Internal->TK.getTimesFlagArray()[pos].first=(bool)status;