]> SALOME platform Git repositories - modules/paravis.git/commitdiff
Salome HOME
fix bug of extract group after extract cell type.
authorgeay <anthony.geay@cea.fr>
Mon, 17 Feb 2014 15:26:18 +0000 (16:26 +0100)
committergeay <anthony.geay@cea.fr>
Mon, 17 Feb 2014 15:26:18 +0000 (16:26 +0100)
src/Plugins/MEDReader/IO/vtkExtractGroup.cxx
src/Plugins/MEDReader/Test/CMakeLists.txt
src/Plugins/MEDReader/Test/testMEDReader8.py [new file with mode: 0644]

index 280e4d8837cca2e87c4eabf075225287b63e5995..c2d3b1551df11a91544e6174a7d43a7029e88835 100644 (file)
@@ -117,6 +117,7 @@ public:
   void printMySelf(std::ostream& os) const;
   std::set<int> getIdsToKeep() const;
   int getIdOfFamily(const std::string& famName) const;
+  static bool IsInformationOK(vtkInformation *info);
 private:
   std::map<std::string,int> computeFamStrIdMap() const;
   const ExtractGroupStatus& getEntry(const char *entry) const;
@@ -158,6 +159,27 @@ bool ExtractGroupGrp::isSameAs(const ExtractGroupGrp& other) const
     return false;
 }
 
+bool vtkExtractGroup::vtkExtractGroupInternal::IsInformationOK(vtkInformation *info)
+{
+  if(!info->Has(vtkDataObject::SIL()))
+    return false;
+  vtkMutableDirectedGraph *sil(vtkMutableDirectedGraph::SafeDownCast(info->Get(vtkDataObject::SIL())));
+  if(!sil)
+    return false;
+  int idNames(0);
+  vtkAbstractArray *verticesNames(sil->GetVertexData()->GetAbstractArray("Names",idNames));
+  vtkStringArray *verticesNames2(vtkStringArray::SafeDownCast(verticesNames));
+  if(!verticesNames2)
+    return false;
+  for(int i=0;i<verticesNames2->GetNumberOfValues();i++)
+    {
+      vtkStdString &st(verticesNames2->GetValue(i));
+      if(st=="MeshesFamsGrps")
+        return true;
+    }
+  return false;
+}
+
 void vtkExtractGroup::vtkExtractGroupInternal::loadFrom(vtkMutableDirectedGraph *sil)
 {
   std::vector<ExtractGroupGrp> oldGrps(_groups); _groups.clear();
@@ -406,7 +428,7 @@ int vtkExtractGroup::RequestInformation(vtkInformation *request, vtkInformationV
       vtkExecutive *exe(GetExecutive());
       vtkAlgorithm *alg(this);
       vtkInformation *infoOnSIL(alg->GetOutputInformation(0));
-      while(!infoOnSIL->Has(vtkDataObject::SIL()))// skipping vtkPVPostFilter
+      while(!vtkExtractGroup::vtkExtractGroupInternal::IsInformationOK(infoOnSIL))// skipping vtkPVPostFilter
        {
          if(exe->GetNumberOfInputConnections(0)<1)
            {
index 425a61ade94026321b8cc722d05e0482ea13262c..db1ddd5055e082975c23e7b44051f5b6b1e8f77d 100644 (file)
@@ -25,3 +25,4 @@ ADD_TEST(testMEDReader4 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMED
 ADD_TEST(testMEDReader5 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader5.py)
 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)
diff --git a/src/Plugins/MEDReader/Test/testMEDReader8.py b/src/Plugins/MEDReader/Test/testMEDReader8.py
new file mode 100644 (file)
index 0000000..3571776
--- /dev/null
@@ -0,0 +1,109 @@
+#  -*- 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. ExtractCellType then ExtractGroup.
+"""
+
+fname="testMEDReader8.med"
+outImgName="testMEDReader8.png"
+#########
+arr=DataArrayDouble([(0,0,0),(1,0,0),(2,0,0),(3,0,0),(0,1,0),(1,1,0),(2,1,0),(3,1,0),(0,2,0),(1,2,0),(2,2,0),(3,2,0),(0,3,0),(1,3,0),(2,3,0),(3,3,0)])
+m0=MEDCouplingUMesh("mesh",2) ; m0.setCoords(arr) ; m0.allocateCells()
+for elt in [[2,3,6],[3,7,6],[6,9,5],[6,10,9]]:
+    m0.insertNextCell(NORM_TRI3,elt)
+    pass
+for elt in [[0,4,5,1],[5,6,2,1],[4,8,9,5],[6,10,11,7],[8,12,13,9],[9,13,14,10],[10,14,15,11]]:
+    m0.insertNextCell(NORM_QUAD4,elt)
+    pass
+mm=MEDFileUMesh()
+mm.setMeshAtLevel(0,m0)
+grp0=DataArrayInt([0,1,2,5]) ; grp0.setName("grp0")
+mm.setGroupsAtLevel(0,[grp0])
+fmts=MEDFileFieldMultiTS()
+#
+fNode=MEDCouplingFieldDouble(ON_NODES) ; fNode.setName("fNode")
+fNode.setMesh(m0)
+fNode.setArray(DataArrayDouble([3,2,1,0,3.16,2.23,1.41,1,3.6,2.82,2.23,2,4.24,3.6,3.16,3]))
+fNode.getArray().setInfoOnComponent(0,"C0")
+fNode.setTime(0.5,1,1)
+f1ts=MEDFileField1TS() ; f1ts.setFieldNoProfileSBT(fNode) ; fmts.pushBackTimeStep(f1ts)
+#
+fNode.getArray().reverse()
+fNode.setTime(0.5,1,2)
+f1ts=MEDFileField1TS() ; f1ts.setFieldNoProfileSBT(fNode) ; fmts.pushBackTimeStep(f1ts)
+#
+fNode.getArray().reverse()
+fNode.setTime(0.5,2,1)
+f1ts=MEDFileField1TS() ; f1ts.setFieldNoProfileSBT(fNode) ; fmts.pushBackTimeStep(f1ts)
+#
+fNode.getArray().reverse()
+fNode.setTime(0.5,2,2)
+f1ts=MEDFileField1TS() ; f1ts.setFieldNoProfileSBT(fNode) ; fmts.pushBackTimeStep(f1ts)
+#
+mm.write(fname,2)
+fmts.write(fname,0)
+################### MED write is done -> Go to MEDReader
+from paraview.simple import *
+
+myMedReader=MEDReader(FileName=fname)
+myMedReader.AllArrays = ['TS0/mesh/ComSup0/fNode@@][@@P1']
+assert(list(myMedReader.TimestepValues)==[0.,1.,2.,3.])
+myMedReader.UpdatePipeline()
+
+extractCT=ExtractCellType()
+extractCT.Input=myMedReader
+extractCT.UpdatePipelineInformation()
+assert(list(extractCT.GetProperty("GeoTypesInfo"))==['TRI3','0','QUAD4','0'])
+extractCT.AllGeoTypes=['TRI3']
+
+extGrp=ExtractGroup()
+extGrp.Input=extractCT
+extGrp.UpdatePipelineInformation()
+assert(filter(lambda x:x[:4]=="GRP_",list(extGrp.GetProperty("GroupsFlagsInfo")[::2]))==['GRP_grp0'])
+extGrp.AllGroups="GRP_grp0"
+
+RenderView1 = GetRenderView()
+RenderView1.CameraFocalPoint = [1.5, 1.5, 0.0]
+RenderView1.CameraPosition = [1.5, 1.5, 10000.0]
+RenderView1.InteractionMode = '3D'
+RenderView1.CameraPosition = [1.5, 1.5, 8.196152422706632]
+RenderView1.CameraClippingRange = [7.825640906782493, 8.682319698595558]
+RenderView1.CameraParallelScale = 2.1213203435596424
+RenderView1.CenterOfRotation = [1.5, 1.5, 0.0]
+
+DataRepresentation4 = Show()
+DataRepresentation4.EdgeColor = [0.0, 0.0, 0.5000076295109483]
+DataRepresentation4.SelectionPointFieldDataArrayName = 'fNode'
+DataRepresentation4.ScaleFactor = 0.3182729169726372
+
+a1_fGauss_PVLookupTable = GetLookupTableForArray( "fNode", 1, RGBPoints=[0.22, 0.23, 0.299, 0.754, 2.95, 0.706, 0.016, 0.15], VectorMode='Magnitude', NanColor=[0.25, 0.0, 0.0], ColorSpace='Diverging', ScalarRangeInitialized=1.0, AllowDuplicateScalars=1 )
+a1_fGauss_PiecewiseFunction = CreatePiecewiseFunction( Points=[0.0, 0.0, 0.5, 0.0, 1.0, 1.0, 0.5, 0.0] )
+DataRepresentation4.ColorArrayName = 'fNode'
+DataRepresentation4.LookupTable = a1_fGauss_PVLookupTable
+a1_fGauss_PVLookupTable.ScalarOpacityFunction = a1_fGauss_PiecewiseFunction
+
+RenderView1.ViewTime = 1.0 #### Important # red is in right bottom
+RenderView1.CacheKey = 1.0
+RenderView1.UseCache = 1
+RenderView1.ViewSize=[300,300]
+WriteImage(outImgName)