]> SALOME platform Git repositories - modules/paravis.git/commitdiff
Salome HOME
GroupsFlagsInfo property of ExtractGroup can be set at any time independantly from...
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 28 Sep 2018 07:33:26 +0000 (09:33 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 28 Sep 2018 09:05:40 +0000 (11:05 +0200)
src/Plugins/MEDReader/IO/vtkExtractGroup.cxx
src/Plugins/MEDReader/Test/testMEDReader0.py
src/Plugins/MEDReader/Test/testMEDReader16.py
src/Plugins/MEDReader/Test/testMEDReader17.py
src/Plugins/MEDReader/Test/testMEDReader18.py
src/Plugins/MEDReader/Test/testMEDReader8.py
src/Plugins/MEDReader/Test/testMEDReader9.py

index 255ccc5b9e1b2e4d2c6e990493909f59354d0d3b..4197a98727db922d55ccd91d0f035e1a48d60871 100644 (file)
@@ -71,14 +71,15 @@ public:
   ExtractGroupStatus():_status(false) { }
   ExtractGroupStatus(const char *name);
   bool getStatus() const { return _status; }
-  void setStatus(bool status) { _status=status; }
+  void setStatus(bool status) const { _status=status; }
   void cpyStatusFrom(const ExtractGroupStatus& other) { _status=other._status; }
   std::string getName() const { return _name; }
+  void resetStatus() const { _status=false; }
   const char *getKeyOfEntry() const { return _ze_key_name.c_str(); }
   virtual void printMySelf(std::ostream& os) const;
   virtual bool isSameAs(const ExtractGroupStatus& other) const;
 protected:
-bool _status;
+mutable bool _status;
 std::string _name;
 std::string _ze_key_name;
 };
@@ -120,6 +121,7 @@ public:
   void setStatusOfEntryStr(const char *entry, bool status);
   void printMySelf(std::ostream& os) const;
   std::set<int> getIdsToKeep() const;
+  void clearSelection() const;
   int getIdOfFamily(const std::string& famName) const;
   static bool IsInformationOK(vtkInformation *info);
 private:
@@ -129,6 +131,7 @@ private:
 private:
   std::vector<ExtractGroupGrp> _groups;
   std::vector<ExtractGroupFam> _fams;
+  mutable std::vector< std::pair<std::string,bool> > _selection;
   std::string _mesh_name;
 };
 
@@ -308,8 +311,7 @@ bool vtkExtractGroup::vtkExtractGroupInternal::getStatusOfEntryStr(const char *e
 
 void vtkExtractGroup::vtkExtractGroupInternal::setStatusOfEntryStr(const char *entry, bool status)
 {
-  ExtractGroupStatus& elt(getEntry(entry));
-  elt.setStatus(status);
+  _selection.emplace_back(entry,status);
 }
 
 const ExtractGroupStatus& vtkExtractGroup::vtkExtractGroupInternal::getEntry(const char *entry) const
@@ -392,6 +394,11 @@ void ExtractGroupFam::fillIdsToKeep(std::set<int>& s) const
 
 std::set<int> vtkExtractGroup::vtkExtractGroupInternal::getIdsToKeep() const
 {
+  for(auto it: _selection)
+    {
+      const ExtractGroupStatus& elt(getEntry(it.first.c_str()));
+      elt.setStatus(it.second);
+    }
   std::map<std::string,int> m(this->computeFamStrIdMap());
   std::set<int> s;
   for(std::vector<ExtractGroupGrp>::const_iterator it0=_groups.begin();it0!=_groups.end();it0++)
@@ -413,6 +420,15 @@ std::set<int> vtkExtractGroup::vtkExtractGroupInternal::getIdsToKeep() const
   return s;
 }
 
+void vtkExtractGroup::vtkExtractGroupInternal::clearSelection() const
+{
+  _selection.clear();
+  for(auto it : _groups)
+    it.resetStatus();
+  for(auto it : _fams)
+    it.resetStatus();
+}
+
 std::map<std::string,int> vtkExtractGroup::vtkExtractGroupInternal::computeFamStrIdMap() const
 {
   std::map<std::string,int> ret;
@@ -585,6 +601,7 @@ int vtkExtractGroup::RequestData(vtkInformation *request, vtkInformationVector *
       vtkInformation *outInfo(outputVector->GetInformationObject(0));
       vtkMultiBlockDataSet *output(vtkMultiBlockDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())));
       std::set<int> idsToKeep(this->Internal->getIdsToKeep());
+      this->Internal->clearSelection();
       // first shrink the input
       bool catchAll,catchSmth;
       vtkSmartPointer<vtkThreshold> thres1(vtkSmartPointer<vtkThreshold>::New()),thres2(vtkSmartPointer<vtkThreshold>::New());
@@ -705,11 +722,8 @@ int vtkExtractGroup::GetGroupsFlagsArrayStatus(const char *name)
 void vtkExtractGroup::SetGroupsFlagsStatus(const char *name, int status)
 {
   //std::cerr << "vtkExtractGroup::SetFieldsStatus(" << name << "," << status << ")" << std::endl;
-  if (GetNumberOfGroupsFlagsArrays()<1)
-    return;
   this->Internal->setStatusOfEntryStr(name,(bool)status);
-  if(std::string(name)==GetGroupsFlagsArrayName(GetNumberOfGroupsFlagsArrays()-1))
-     this->Modified();
+  this->Modified();
   //this->Internal->printMySelf(std::cerr);
 }
 
index 214ab1986e12c1f0bcd26933473f5827e38cbb75..55a0e422b55e7d929bc1e2f304a152d872394d44 100644 (file)
@@ -88,7 +88,7 @@ myMedReader.AllArrays=keys
 RenderView1 = GetRenderView()
 ELNOfieldToSurface1=ELNOfieldToSurface(Input=myMedReader)
 ExtractGroup1=ExtractGroup(Input=ELNOfieldToSurface1)
-ExtractGroup1.UpdatePipelineInformation()
+#ExtractGroup1.UpdatePipelineInformation()
 ExtractGroup1.AllGroups=['GRP_ba2','GRP_to1','GRP_web']
 assert(isinstance(ExtractGroup1.GetProperty("MeshName")[0],str))
 assert(ExtractGroup1.GetProperty("MeshName")[0]=="mesh")
index fb9219c47d860925d44e722b712b56ebd178fd1d..201092282f2f57c01946ea4463fcb03221dcf9c4 100644 (file)
@@ -48,7 +48,7 @@ ExpectedEntries=['TS0/Mesh/ComSup0/MyField@@][@@GSSNE','TS1/Mesh/ComSup0/Mesh@@]
 assert(reader.GetProperty("FieldsTreeInfo")[::2]==ExpectedEntries)
 reader.AllArrays=['TS0/Mesh/ComSup0/MyField@@][@@GSSNE']
 ExtractGroup1 = ExtractGroup(Input=reader)
-ExtractGroup1.UpdatePipelineInformation()
+#ExtractGroup1.UpdatePipelineInformation()
 ExtractGroup1.AllGroups=["GRP_grp1"]
 ELNOfieldToSurface1=ELNOfieldToSurface(Input=ExtractGroup1)
 ELNOfieldToPointGaussian1=ELNOfieldToPointGaussian(Input=ExtractGroup1)
index 7668e4d7fdd841628d9a04324358ca38fd833219..f6edd58f4c713e5a31df50605d63415f08d942de 100644 (file)
@@ -48,7 +48,7 @@ ExpectedEntries=['TS0/Mesh/ComSup0/MyField@@][@@GSSNE','TS1/Mesh/ComSup0/Mesh@@]
 assert(reader.GetProperty("FieldsTreeInfo")[::2]==ExpectedEntries)
 reader.AllArrays=['TS0/Mesh/ComSup0/MyField@@][@@GSSNE']
 ExtractGroup1 = ExtractGroup(Input=reader)
-ExtractGroup1.UpdatePipelineInformation()
+#ExtractGroup1.UpdatePipelineInformation()
 ExtractGroup1.AllGroups=["GRP_grp1"]
 ELNOfieldToPointGaussian1=ELNOfieldToPointGaussian(Input=ExtractGroup1)
 ELNOfieldToPointGaussian1.SelectSourceArray=['ELNO@MyField']
@@ -56,9 +56,9 @@ ELNOfieldToPointGaussian1.SelectSourceArray=['ELNO@MyField']
 ELNOfieldToPointGaussian1=ELNOfieldToPointGaussian(Input=reader)
 ELNOfieldToPointGaussian1.SelectSourceArray=['ELNO@MyField']
 ExtractGroup1 = ExtractGroup(Input=ELNOfieldToPointGaussian1)
-ExtractGroup1.UpdatePipelineInformation()
+#ExtractGroup1.UpdatePipelineInformation()
 ExtractGroup1.AllGroups=["GRP_grp1"]
-ExtractGroup1.UpdatePipeline()
+#ExtractGroup1.UpdatePipeline()
 res=servermanager.Fetch(ExtractGroup1,0)
 assert(res.GetBlock(0).GetNumberOfCells()==8)
 vtkArrToTest=res.GetBlock(0).GetPointData().GetArray("MyField")
index 957c458681d4c827912b033b5b192a1895b34c3f..2cd3f14a1ea318cf87e948378be5bb48abece080 100644 (file)
@@ -47,7 +47,7 @@ reader=MEDReader(FileName=fname)
 reader.AllArrays=['TS0/mesh/ComSup0/mesh@@][@@P0']
 ExtractGroup1 = ExtractGroup(Input=reader)
 ExtractGroup1.AllGroups=["GRP_grp0","GRP_grp1"]
-ExtractGroup1.UpdatePipelineInformation()
+#ExtractGroup1.UpdatePipelineInformation()
 res=servermanager.Fetch(ExtractGroup1,0)
 assert(res.GetNumberOfBlocks()==2)
 assert(res.GetBlock(1).GetNumberOfCells()==1)
index e4dfb78fa80def99aba0e48f33339bdf754103ca..5d52751606502b0390992267734c54c446e3cdb4 100644 (file)
@@ -76,7 +76,7 @@ assert(list(extractCT.GetProperty("GeoTypesInfo"))==['TRI3','0','QUAD4','0'])
 extractCT.AllGeoTypes=['TRI3']
 
 extGrp=ExtractGroup(Input=extractCT)
-extGrp.UpdatePipelineInformation()
+#extGrp.UpdatePipelineInformation()
 assert([x for x in list(extGrp.GetProperty("GroupsFlagsInfo")[::2]) if x[:4]=="GRP_"]==['GRP_grp0'])
 extGrp.AllGroups="GRP_grp0"
 
index 61c5cc6076f3caf283529666a4461c815de2b7a2..f94723a45ca1a32781a6ee14e26b29e45de24b4b 100644 (file)
@@ -44,12 +44,12 @@ from paraview.simple import *
 
 myMedReader=MEDReader(FileName=fname)
 myMedReader.AllArrays=['TS0/m1/ComSup0/f1@@][@@P0']
-myMedReader.UpdatePipelineInformation()
+#myMedReader.UpdatePipelineInformation()
 ExtractGroup1=ExtractGroup(Input=myMedReader)
-ExtractGroup1.UpdatePipelineInformation()
+#ExtractGroup1.UpdatePipelineInformation()
 assert(ExtractGroup1.GetProperty("MeshName")[0]=="m1")
 myMedReader.AllArrays=['TS0/m2/ComSup0/f2@@][@@P0']
-myMedReader.UpdatePipeline()
+#myMedReader.UpdatePipeline()
 ExtractGroup2=ExtractGroup(Input=myMedReader)
-ExtractGroup2.UpdatePipelineInformation()
+#ExtractGroup2.UpdatePipelineInformation()
 assert(ExtractGroup2.GetProperty("MeshName")[0]=="m2")