]> SALOME platform Git repositories - modules/paravis.git/commitdiff
Salome HOME
Add MeshName property to ExtractGroup filter to ease the traduction of tests from...
authorgeay <anthony.geay@cea.fr>
Tue, 25 Mar 2014 12:12:28 +0000 (13:12 +0100)
committergeay <anthony.geay@cea.fr>
Tue, 25 Mar 2014 12:12:28 +0000 (13:12 +0100)
src/Plugins/MEDReader/IO/vtkExtractGroup.cxx
src/Plugins/MEDReader/IO/vtkExtractGroup.h
src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml
src/Plugins/MEDReader/Test/CMakeLists.txt
src/Plugins/MEDReader/Test/testMEDReader0.py
src/Plugins/MEDReader/Test/testMEDReader9.py [new file with mode: 0644]

index c2d3b1551df11a91544e6174a7d43a7029e88835..5eab0e9011aa5e435ae1036245fd9b960ca307f9 100644 (file)
@@ -111,6 +111,7 @@ class vtkExtractGroup::vtkExtractGroupInternal
 public:
   void loadFrom(vtkMutableDirectedGraph *sil);
   int getNumberOfEntries() const;
+  const char *getMeshName() const;
   const char *getKeyOfEntry(int i) const;
   bool getStatusOfEntryStr(const char *entry) const;
   void setStatusOfEntryStr(const char *entry, bool status);
@@ -125,6 +126,7 @@ private:
 private:
   std::vector<ExtractGroupGrp> _groups;
   std::vector<ExtractGroupFam> _fams;
+  std::string _mesh_name;
 };
 
 const char ExtractGroupGrp::START[]="GRP_";
@@ -180,6 +182,11 @@ bool vtkExtractGroup::vtkExtractGroupInternal::IsInformationOK(vtkInformation *i
   return false;
 }
 
+const char *vtkExtractGroup::vtkExtractGroupInternal::getMeshName() const
+{
+  return this->_mesh_name.c_str();
+}
+
 void vtkExtractGroup::vtkExtractGroupInternal::loadFrom(vtkMutableDirectedGraph *sil)
 {
   std::vector<ExtractGroupGrp> oldGrps(_groups); _groups.clear();
@@ -207,6 +214,7 @@ void vtkExtractGroup::vtkExtractGroupInternal::loadFrom(vtkMutableDirectedGraph
     {
       vtkIdType id1(it0->Next());
       std::string meshName((const char *)verticesNames2->GetValue(id1));
+      this->_mesh_name=meshName;
       vtkAdjacentVertexIterator *it1(vtkAdjacentVertexIterator::New());
       sil->GetAdjacentVertices(id1,it1);
       vtkIdType idZeGrps(it1->Next());//zeGroups
@@ -671,3 +679,8 @@ void vtkExtractGroup::SetGroupsFlagsStatus(const char *name, int status)
      this->Modified();
   //this->Internal->printMySelf(std::cerr);
 }
+
+const char *vtkExtractGroup::GetMeshName()
+{
+  return this->Internal->getMeshName();
+}
index 778b1d982822dfc24b3994b78346096ec739b5b6..c13ed1b1a1930b5b8be12e824fb21c705948c44c 100644 (file)
@@ -39,7 +39,7 @@ public:
   // Description:
   // Every time the SIL is updated a this will return a different value.
   virtual int GetSILUpdateStamp();
-
+  const char *GetMeshName();
 protected:
   vtkExtractGroup();
   ~vtkExtractGroup();
index 0006caf330045bef5ab1ecf802d54521ed14bb36..45e26622eca4ec6b51aa2fc0e4989e011ed444bd 100644 (file)
        is kept. When 1 the complementary part is selected.
        </Documentation>
       </IntVectorProperty>
+
+      <StringVectorProperty
+          name="MeshName"
+          command="GetMeshName"
+          number_of_elements="1"
+          animateable="0"
+          information_only="1">
+        <Documentation>
+          This property returns the name of the mesh.
+        </Documentation>
+      </StringVectorProperty>
     </SourceProxy>
   </ProxyGroup>
   
index db1ddd5055e082975c23e7b44051f5b6b1e8f77d..a4cd1886c20df81f29619240b93fdb3a7c2d5b1c 100644 (file)
@@ -26,3 +26,4 @@ ADD_TEST(testMEDReader5 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMED
 ADD_TEST(testMEDReader6 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader6.py)
 ADD_TEST(testMEDReader7 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader7.py)
 ADD_TEST(testMEDReader8 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader8.py)
+ADD_TEST(testMEDReader9 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader9.py)
index 5b33b462eeb87023e13a106a5c9d7b19138e6914..0ade05bb60f842d8d3467452ea6f9bb4af6eaf65 100644 (file)
@@ -93,6 +93,8 @@ ExtractGroup1=ExtractGroup()
 ExtractGroup1.Input=ELNOMesh1
 ExtractGroup1.UpdatePipelineInformation()
 ExtractGroup1.AllGroups=['GRP_ba2','GRP_to1','GRP_web']
+assert(isinstance(ExtractGroup1.GetProperty("MeshName")[0],str))
+assert(ExtractGroup1.GetProperty("MeshName")[0]=="mesh")
 #
 DataRepresentation3 = Show()
 DataRepresentation3.ScaleFactor = 0.008999999705702066
diff --git a/src/Plugins/MEDReader/Test/testMEDReader9.py b/src/Plugins/MEDReader/Test/testMEDReader9.py
new file mode 100644 (file)
index 0000000..2f40282
--- /dev/null
@@ -0,0 +1,55 @@
+#  -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2014  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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author : Anthony Geay
+
+from MEDLoader import *
+
+""" This test is a non regression test. Test that ExtractGroup adapt to the current mesh of MEDReader. A MED file containing 2 fields on a 2 different meshes.
+This test checks that the MeshName follows.
+"""
+
+fname="testMEDReader9.med"
+#########
+m1=MEDCouplingUMesh("m1",2) ; m1.setCoords(DataArrayDouble([(0.,0.),(1.,0.),(0.,1.)])) ; m1.allocateCells() ; m1.insertNextCell(NORM_TRI3,[0,1,2])
+m2=MEDCouplingUMesh("m2",2) ; m2.setCoords(DataArrayDouble([(0.,0.),(1.,0.),(0.,1.),(1.,1.)])) ; m2.allocateCells() ; m2.insertNextCell(NORM_QUAD4,[0,1,3,2])
+mm1=MEDFileUMesh() ; mm2=MEDFileUMesh()
+mm1.setMeshAtLevel(0,m1) ; mm2.setMeshAtLevel(0,m2)
+ms=MEDFileMeshes() ; ms.pushMesh(mm1) ; ms.pushMesh(mm2)
+f1=MEDCouplingFieldDouble(ON_CELLS) ; f1.setName("f1") ; f1.setMesh(m1) ; f1.setArray(DataArrayDouble([1.111]))
+f2=MEDCouplingFieldDouble(ON_CELLS) ; f2.setName("f2") ; f2.setMesh(m2) ; f2.setArray(DataArrayDouble([2.2222]))
+ff1=MEDFileField1TS() ; ff2=MEDFileField1TS()
+ff1.setFieldNoProfileSBT(f1) ; ff2.setFieldNoProfileSBT(f2)
+ms.write(fname,2)
+ff1.write(fname,0)
+ff2.write(fname,0)
+################### MED write is done -> Go to MEDReader
+from paraview.simple import *
+
+myMedReader=MEDReader(FileName=fname)
+myMedReader.AllArrays=['TS0/m1/ComSup0/f1@@][@@P0']
+myMedReader.UpdatePipelineInformation()
+ExtractGroup1=ExtractGroup(Input=myMedReader)
+ExtractGroup1.UpdatePipelineInformation()
+assert(ExtractGroup1.GetProperty("MeshName")[0]=="m1")
+myMedReader.AllArrays=['TS0/m2/ComSup0/f2@@][@@P0']
+myMedReader.UpdatePipeline()
+ExtractGroup2=ExtractGroup(Input=myMedReader)
+ExtractGroup2.UpdatePipelineInformation()
+assert(ExtractGroup2.GetProperty("MeshName")[0]=="m2")