From: Anthony Geay Date: Thu, 28 Apr 2016 16:00:52 +0000 (+0200) Subject: EDF12599 : Addition of ShrinkFactor property for ELNO Mesh filter in MEDReader. X-Git-Tag: V7_8_0a2^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c6dbc9821b84a9733eab441b53bf12a9f9cc5c8b;p=modules%2Fparavis.git EDF12599 : Addition of ShrinkFactor property for ELNO Mesh filter in MEDReader. --- diff --git a/src/Plugins/MEDReader/IO/vtkELNOMeshFilter.cxx b/src/Plugins/MEDReader/IO/vtkELNOMeshFilter.cxx index a01b5d8b..62aa3e6e 100644 --- a/src/Plugins/MEDReader/IO/vtkELNOMeshFilter.cxx +++ b/src/Plugins/MEDReader/IO/vtkELNOMeshFilter.cxx @@ -41,7 +41,7 @@ vtkStandardNewMacro(vtkELNOMeshFilter); -vtkELNOMeshFilter::vtkELNOMeshFilter() +vtkELNOMeshFilter::vtkELNOMeshFilter():ShrinkFactor(0.9999) { } @@ -71,7 +71,7 @@ int vtkELNOMeshFilter::RequestData(vtkInformation *request, usgInClone->ShallowCopy(usgIn); vtkSmartPointer shrink(vtkSmartPointer::New()); shrink->SetInputData(usgInClone); - shrink->SetShrinkFactor(0.9999); + shrink->SetShrinkFactor(this->ShrinkFactor); shrink->Update(); vtkUnstructuredGrid *shrinked(shrink->GetOutput()); usgInClone->Delete(); diff --git a/src/Plugins/MEDReader/IO/vtkELNOMeshFilter.h b/src/Plugins/MEDReader/IO/vtkELNOMeshFilter.h index b3cc6038..f24958d6 100644 --- a/src/Plugins/MEDReader/IO/vtkELNOMeshFilter.h +++ b/src/Plugins/MEDReader/IO/vtkELNOMeshFilter.h @@ -29,15 +29,18 @@ public: vtkTypeMacro(vtkELNOMeshFilter,vtkUnstructuredGridAlgorithm); void PrintSelf(ostream& os, vtkIndent indent); + vtkGetMacro(ShrinkFactor, double); + vtkSetMacro(ShrinkFactor, double); protected: vtkELNOMeshFilter(); ~vtkELNOMeshFilter(); int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); - private: vtkELNOMeshFilter(const vtkELNOMeshFilter&); void operator =(const vtkELNOMeshFilter&); +private: + double ShrinkFactor; }; #endif diff --git a/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml b/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml index f4a772d6..6f751967 100644 --- a/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml +++ b/src/Plugins/MEDReader/ParaViewPlugin/Resources/MEDReaderServer.xml @@ -235,6 +235,7 @@ short_help="Create a Mesh with ELNO values mapped at each vertex."> "Create a Mesh with ELNO values mapped at each vertex." + @@ -245,6 +246,16 @@ + + + + The value of this property determines how far the points + will move in the mesh before to be colored using ELNO fields on it. A value of 0 positions the points at the centroid of the cell; a value of 1 leaves them at their original positions. + diff --git a/src/Plugins/MEDReader/Test/Baselines/testMEDReader20.png b/src/Plugins/MEDReader/Test/Baselines/testMEDReader20.png new file mode 100644 index 00000000..bd87d105 Binary files /dev/null and b/src/Plugins/MEDReader/Test/Baselines/testMEDReader20.png differ diff --git a/src/Plugins/MEDReader/Test/CMakeLists.txt b/src/Plugins/MEDReader/Test/CMakeLists.txt index d3ecf847..fd295007 100644 --- a/src/Plugins/MEDReader/Test/CMakeLists.txt +++ b/src/Plugins/MEDReader/Test/CMakeLists.txt @@ -17,7 +17,7 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SET(TEST_NUMBERS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19) +SET(TEST_NUMBERS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20) SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/MEDReader) diff --git a/src/Plugins/MEDReader/Test/testMEDReader20.py b/src/Plugins/MEDReader/Test/testMEDReader20.py new file mode 100644 index 00000000..f8ec9d54 --- /dev/null +++ b/src/Plugins/MEDReader/Test/testMEDReader20.py @@ -0,0 +1,191 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2015-2016 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, or (at your option) any later version. +# +# 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 (EDF R&D) + +from paraview.simple import * + +from MEDLoader import * + +""" This is a non regression EDF12599""" +fname="testMEDReader20.med" +imgName="testMEDReader20.png" +fieldName="MyField" +meshName="mesh" +m=MEDFileUMesh() +m0=MEDCouplingUMesh(meshName,1) +m0.setCoords(DataArrayDouble([(0.,0.,0),(1.,0.,0.),(2.,0.,0.)])) +m0.allocateCells() +m0.insertNextCell(NORM_SEG2,[0,1]) +m0.insertNextCell(NORM_SEG2,[1,2]) +m[0]=m0 +# +f=MEDCouplingFieldDouble(ON_GAUSS_NE) ; f.setName(fieldName) +f.setMesh(m0) ; f.setArray(DataArrayDouble([1.,7.,3.,2.])) +MEDLoader.WriteField(fname,f,True) +######## +testTotomed = MEDReader(FileName=fname) +testTotomed.AllArrays = ['TS0/%s/ComSup0/%s@@][@@GSSNE'%(meshName,fieldName)] +testTotomed.AllTimeSteps = ['0000'] +# get active view +renderView1 = GetActiveViewOrCreate('RenderView') +# uncomment following to set a specific view size +# renderView1.ViewSize = [739, 503] + +# show data in view +testTotomedDisplay = Show(testTotomed, renderView1) +# trace defaults for the display properties. +testTotomedDisplay.ColorArrayName = [None, ''] +testTotomedDisplay.GlyphType = 'Arrow' +testTotomedDisplay.ScalarOpacityUnitDistance = 1.5874010519681994 +testTotomedDisplay.SelectUncertaintyArray = [None, ''] +testTotomedDisplay.UncertaintyTransferFunction = 'PiecewiseFunction' +testTotomedDisplay.OpacityArray = [None, ''] +testTotomedDisplay.RadiusArray = [None, ''] +testTotomedDisplay.RadiusRange = [0.0, 2.0] +testTotomedDisplay.ConstantRadius = 2.0 +testTotomedDisplay.PointSpriteDefaultsInitialized = 1 +testTotomedDisplay.SelectInputVectors = [None, ''] +testTotomedDisplay.WriteLog = '' + +# reset view to fit data +renderView1.ResetCamera() + +#changing interaction mode based on data extents +renderView1.InteractionMode = '2D' +renderView1.CameraPosition = [1.0, 10000.0, 10000.0] +renderView1.CameraFocalPoint = [1.0, 0.0, 0.0] +renderView1.CameraViewUp = [1.0, 1.0, 0.0] + +# set scalar coloring +ColorBy(testTotomedDisplay, ('FIELD', 'vtkBlockColors')) + +# show color bar/color legend +testTotomedDisplay.SetScalarBarVisibility(renderView1, True) + +# get color transfer function/color map for 'vtkBlockColors' +vtkBlockColorsLUT = GetColorTransferFunction('vtkBlockColors') + +# get opacity transfer function/opacity map for 'vtkBlockColors' +vtkBlockColorsPWF = GetOpacityTransferFunction('vtkBlockColors') + +# create a new 'ELNO Mesh' +eLNOMesh1 = ELNOMesh(Input=testTotomed) + +# Properties modified on eLNOMesh1 +eLNOMesh1.ShrinkFactor = 0.5 # <- test is here !!!!!!!! + +# show data in view +eLNOMesh1Display = Show(eLNOMesh1, renderView1) +# trace defaults for the display properties. +eLNOMesh1Display.ColorArrayName = [None, ''] +eLNOMesh1Display.GlyphType = 'Arrow' +eLNOMesh1Display.ScalarOpacityUnitDistance = 1.1905507889761495 +eLNOMesh1Display.SelectUncertaintyArray = ['POINTS', 'MyField'] +eLNOMesh1Display.UncertaintyTransferFunction = 'PiecewiseFunction' +eLNOMesh1Display.OpacityArray = [None, ''] +eLNOMesh1Display.RadiusArray = [None, ''] +eLNOMesh1Display.RadiusRange = [0.25, 1.75] +eLNOMesh1Display.ConstantRadius = 1.75 +eLNOMesh1Display.PointSpriteDefaultsInitialized = 1 +eLNOMesh1Display.SelectInputVectors = [None, ''] +eLNOMesh1Display.WriteLog = '' + +# hide data in view +Hide(testTotomed, renderView1) + +# set scalar coloring +ColorBy(eLNOMesh1Display, ('FIELD', 'vtkBlockColors')) + +# show color bar/color legend +eLNOMesh1Display.SetScalarBarVisibility(renderView1, False) + +# set scalar coloring +ColorBy(eLNOMesh1Display, ('POINTS', 'MyField')) + +# rescale color and/or opacity maps used to include current data range +eLNOMesh1Display.RescaleTransferFunctionToDataRange(True) + +# show color bar/color legend +eLNOMesh1Display.SetScalarBarVisibility(renderView1, False) + +# get color transfer function/color map for 'MyField' +myFieldLUT = GetColorTransferFunction('MyField') + +# get opacity transfer function/opacity map for 'MyField' +myFieldPWF = GetOpacityTransferFunction('MyField') + +# hide color bar/color legend +eLNOMesh1Display.SetScalarBarVisibility(renderView1, False) + +# create a new 'Glyph' +glyph1 = Glyph(Input=eLNOMesh1, + GlyphType='Arrow') +glyph1.Scalars = ['POINTS', 'MyField'] +glyph1.Vectors = ['POINTS', 'None'] +glyph1.ScaleFactor = 0.15000000000000002 +glyph1.GlyphTransform = 'Transform2' + +# Properties modified on glyph1 +glyph1.GlyphType = 'Sphere' +glyph1.ScaleFactor = 0.15 + +# show data in view +glyph1Display = Show(glyph1, renderView1) +# trace defaults for the display properties. +glyph1Display.ColorArrayName = ['POINTS', 'MyField'] +glyph1Display.LookupTable = myFieldLUT +glyph1Display.GlyphType = 'Arrow' +glyph1Display.SelectUncertaintyArray = ['POINTS', 'MyField'] +glyph1Display.UncertaintyTransferFunction = 'PiecewiseFunction' +glyph1Display.OpacityArray = [None, ''] +glyph1Display.RadiusArray = [None, ''] +glyph1Display.RadiusRange = [0.17688040435314178, 1.8231196403503418] +glyph1Display.ConstantRadius = 1.8231196403503418 +glyph1Display.PointSpriteDefaultsInitialized = 1 +glyph1Display.SelectInputVectors = ['POINTS', 'Normals'] +glyph1Display.WriteLog = '' + +# show color bar/color legend +glyph1Display.SetScalarBarVisibility(renderView1, True) + +#### saving camera placements for all active views + +# current camera placement for renderView1 +renderView1.InteractionMode = '2D' +renderView1.CameraPosition = [0.9999999999999908, 9999.999999999995, 9999.999999999993] +renderView1.CameraFocalPoint = [1.0, 0.0, 0.0] +renderView1.CameraViewUp = [0.6331899945158901, 0.547298104713038, -0.5472981047130381] +renderView1.CameraParallelScale = 0.6930835077290218 +renderView1.ViewSize = [739,503] + +import os +import sys +try: + baselineIndex = sys.argv.index('-B')+1 + baselinePath = sys.argv[baselineIndex] +except: + print "Could not get baseline directory. Test failed." + exit(1) +baseline_file = os.path.join(baselinePath, imgName) +import vtk.test.Testing +vtk.test.Testing.VTK_TEMP_DIR = vtk.util.misc.vtkGetTempDir() +vtk.test.Testing.compareImage(GetActiveView().GetRenderWindow(), baseline_file, threshold=25) +vtk.test.Testing.interact() +