From: geay Date: Tue, 25 Mar 2014 12:12:28 +0000 (+0100) Subject: Add MeshName property to ExtractGroup filter to ease the traduction of tests from... X-Git-Tag: V7_4_0a1^2~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c4aa69ad44eec5e669cb416a73ff7117c97624e3;p=modules%2Fparavis.git Add MeshName property to ExtractGroup filter to ease the traduction of tests from old MEDReader to new one --- diff --git a/src/Plugins/MEDReader/IO/vtkExtractGroup.cxx b/src/Plugins/MEDReader/IO/vtkExtractGroup.cxx index c2d3b155..5eab0e90 100644 --- a/src/Plugins/MEDReader/IO/vtkExtractGroup.cxx +++ b/src/Plugins/MEDReader/IO/vtkExtractGroup.cxx @@ -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 _groups; std::vector _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 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(); +} diff --git a/src/Plugins/MEDReader/IO/vtkExtractGroup.h b/src/Plugins/MEDReader/IO/vtkExtractGroup.h index 778b1d98..c13ed1b1 100644 --- a/src/Plugins/MEDReader/IO/vtkExtractGroup.h +++ b/src/Plugins/MEDReader/IO/vtkExtractGroup.h @@ -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(); diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml b/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml index 0006caf3..45e26622 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml +++ b/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml @@ -167,6 +167,17 @@ is kept. When 1 the complementary part is selected. + + + + This property returns the name of the mesh. + + diff --git a/src/Plugins/MEDReader/Test/CMakeLists.txt b/src/Plugins/MEDReader/Test/CMakeLists.txt index db1ddd50..a4cd1886 100644 --- a/src/Plugins/MEDReader/Test/CMakeLists.txt +++ b/src/Plugins/MEDReader/Test/CMakeLists.txt @@ -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) diff --git a/src/Plugins/MEDReader/Test/testMEDReader0.py b/src/Plugins/MEDReader/Test/testMEDReader0.py index 5b33b462..0ade05bb 100644 --- a/src/Plugins/MEDReader/Test/testMEDReader0.py +++ b/src/Plugins/MEDReader/Test/testMEDReader0.py @@ -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 index 00000000..2f402824 --- /dev/null +++ b/src/Plugins/MEDReader/Test/testMEDReader9.py @@ -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")