From 685864c821e1b56b5833b645111027cd3ffc15b0 Mon Sep 17 00:00:00 2001 From: Christophe Bourcier Date: Fri, 14 Apr 2023 14:06:57 +0200 Subject: [PATCH] Fix streamlines representation not working since ParaView >= 5.10. Plus: - use Line seed in case of planar dataset - add tests --- .../cmp/MEDPresentationStreamLines.cxx | 6 ++- src/MEDCalc/test/medcalc_testutils.py.in | 4 ++ src/MEDCalc/test/tui/streamlines.py | 41 ++++++++++++++++++ src/MEDCalc/test/tui/streamlines_2d.py | 42 +++++++++++++++++++ src/MEDCalc/test/tui/tests.set | 2 + 5 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 src/MEDCalc/test/tui/streamlines.py create mode 100644 src/MEDCalc/test/tui/streamlines_2d.py diff --git a/src/MEDCalc/cmp/MEDPresentationStreamLines.cxx b/src/MEDCalc/cmp/MEDPresentationStreamLines.cxx index 8a071b784..96380ab6a 100644 --- a/src/MEDCalc/cmp/MEDPresentationStreamLines.cxx +++ b/src/MEDCalc/cmp/MEDPresentationStreamLines.cxx @@ -130,7 +130,9 @@ MEDPresentationStreamLines::internalGeneratePipeline() oss << _objVar << " = " << _objStreamCalc << ";"; oss << _objVar << ".UpdatePipeline();"; pushAndExecPyLine(oss.str()); oss.str(""); - oss << _objVar << " = pvs.StreamTracer(Input=" << _objVar << ", SeedType='Point Cloud' if pvs.GetParaViewVersion().GetVersion() > 5.8 else 'Point Source');"; + oss << _objVar << " = pvs.StreamTracer(Input=" << _objVar << + ", SeedType='Point Cloud' if not medcalc.IsPlanarObj(" << _objVar << + ") else 'Line');"; pushAndExecPyLine(oss.str()); oss.str(""); oss << _objVar << ".IntegrationDirection = '" << dirType << "';"; pushAndExecPyLine(oss.str()); oss.str(""); @@ -228,4 +230,4 @@ MEDPresentationStreamLines::scalarBarTitle() pushAndExecPyLine(oss.str()); } MEDPresentation::scalarBarTitle(); -} \ No newline at end of file +} diff --git a/src/MEDCalc/test/medcalc_testutils.py.in b/src/MEDCalc/test/medcalc_testutils.py.in index 21875df91..31fb15c0d 100755 --- a/src/MEDCalc/test/medcalc_testutils.py.in +++ b/src/MEDCalc/test/medcalc_testutils.py.in @@ -46,3 +46,7 @@ def GetMEDFileDirGUI(): def GetMEDFileDirTUI(): relativeDir = "@SALOME_FIELDS_INSTALL_RES_DATA@/tests/tui/medfiles" return os.path.join(__getRootDir(), relativeDir) + +def GetMEDFileDirResources(): + relativeDir = "@SALOME_FIELDS_INSTALL_RES_DATA@" + return os.path.join(__getRootDir(), relativeDir) diff --git a/src/MEDCalc/test/tui/streamlines.py b/src/MEDCalc/test/tui/streamlines.py new file mode 100644 index 000000000..52b882b95 --- /dev/null +++ b/src/MEDCalc/test/tui/streamlines.py @@ -0,0 +1,41 @@ +# Copyright (C) 2016-2022 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 +# + +import os +from time import sleep + +import medcalc +medcalc.medconsole.setConsoleGlobals(globals()) +import MEDCALC +from medcalc.medconsole import accessField + +from medcalc_testutils import GetMEDFileDirTUI + +datafile = os.path.join(GetMEDFileDirTUI(), "agitateur.med") +source_id = medcalc.LoadDataSource(datafile) + +# Field 55 = VITESSE_ELEM_DOM (ON_CELLS) at timestamp 0 +# Field 65 = VITESSE_ELEM_DOM (ON_CELLS) at timestamp 10 +presentation_id = medcalc.MakeStreamLines(accessField(65), viewMode=MEDCALC.VIEW_MODE_REPLACE, + colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW, + scalarBarRange=MEDCALC.SCALAR_BAR_CURRENT_TIMESTEP + ) +sleep(1) +medcalc.RemovePresentation(presentation_id) +sleep(1) diff --git a/src/MEDCalc/test/tui/streamlines_2d.py b/src/MEDCalc/test/tui/streamlines_2d.py new file mode 100644 index 000000000..24719f009 --- /dev/null +++ b/src/MEDCalc/test/tui/streamlines_2d.py @@ -0,0 +1,42 @@ +# Copyright (C) 2016-2022 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 +# + +import os +from time import sleep + +import medcalc +medcalc.medconsole.setConsoleGlobals(globals()) +import MEDCALC +from medcalc.medconsole import accessField + +from medcalc_testutils import GetMEDFileDirResources + +datafile = os.path.join(GetMEDFileDirResources(), "TimeStamps.med") +source_id = medcalc.LoadDataSource(datafile) + +# Field 55 = VITESSE_ELEM_DOM (ON_CELLS) at timestamp 0 +# Field 65 = VITESSE_ELEM_DOM (ON_CELLS) at timestamp 10 +presentation_id = medcalc.MakeStreamLines(accessField(264), viewMode=MEDCALC.VIEW_MODE_REPLACE, + colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW, + scalarBarRange=MEDCALC.SCALAR_BAR_CURRENT_TIMESTEP + ) +sleep(1) +medcalc.RemovePresentation(presentation_id) +sleep(1) + diff --git a/src/MEDCalc/test/tui/tests.set b/src/MEDCalc/test/tui/tests.set index 8892fc9ce..8ea87fb9d 100644 --- a/src/MEDCalc/test/tui/tests.set +++ b/src/MEDCalc/test/tui/tests.set @@ -31,4 +31,6 @@ SET(TEST_NAMES deflection_shape elno_field interpolate_field_float + streamlines + streamlines_2d ) -- 2.39.2