# ====================
SALOME_XVERSION(${PROJECT_NAME})
SALOME_CONFIGURE_FILE(PARAVISADDONS_version.h.in PARAVISADDONS_version.h INSTALL ${SALOME_INSTALL_HEADERS})
+OPTION(PARAVISADDONS_COMMON_BUILD_TESTS "Build PARAVISADDONS_COMMON tests." ON)
# Sources
# ========
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake files")
+SET(PARAVISADDONS_COMMON_INSTALL_TESTS tests CACHE PATH "Install path: PARAVISADDONS_COMMON tests")
IF(EXISTS ${CONFIGURATION_ROOT_DIR})
LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
INCLUDE(SalomeMacros)
ADD_SUBDIRECTORY(ElectromagnetismStreamTraceur)
ADD_SUBDIRECTORY(ElectromagnetismFluxDisc)
ADD_SUBDIRECTORY(ElectromagnetismRotation)
+
+
+# Tests
+configure_file(CTestTestfileInstall.cmake.in "CTestTestfileST.cmake" @ONLY)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfileST.cmake DESTINATION ${PARAVISADDONS_COMMON_INSTALL_TESTS} RENAME CTestTestfile.cmake)
--- /dev/null
+# Copyright (C) 2015-2020 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
+#
+
+SET(COMPONENT_NAME PARAVISADDONS_COMMON)
+SET(TIMEOUT 120)
+
+SUBDIRS(SerafinReader)
+SUBDIRS(ElectromagnetismFluxDisc)
+SUBDIRS(ElectromagnetismRotation)
+SUBDIRS(ElectromagnetismStreamTraceur)
+SUBDIRS(ElectromagnetismVecteur)
project(SerafinReader)
find_package(ParaView REQUIRED)
+IF(PARAVISADDONS_COMMON_BUILD_TESTS)
+ ADD_SUBDIRECTORY(Test)
+ENDIF(PARAVISADDONS_COMMON_BUILD_TESTS)
+
include(GNUInstallDirs)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
--- /dev/null
+# Copyright (C) 2012-2020 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 : Yoann Audouin (EDF)
+
+SET(test_SerafinReader_src
+ geo_3d_dp.slf
+ geo_dp.slf
+ geo_dp_le.slf
+ geo_sp.slf
+ geo_sp_le.slf
+ test_SerafinReader.py
+ )
+
+SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
+
+ADD_TEST(SerafinReader python test_SerafinReader.py)
+SET_TESTS_PROPERTIES(SerafinReader PROPERTIES ENVIRONMENT "${tests_env}")
+
+#INSTALL(TARGETS test_SerafinReader DESTINATION ${PARAVISADDONS_COMMON_INSTALL_BINS})
+
+# Application tests
+
+SET(TEST_INSTALL_DIRECTORY ${PARAVISADDONS_COMMON_INSTALL_TESTS}/SerafinReader)
+INSTALL(FILES ${test_SerafinReader_src} DESTINATION ${TEST_INSTALL_DIRECTORY})
+
+INSTALL(FILES CTestTestfileInstall.cmake
+ DESTINATION ${TEST_INSTALL_DIRECTORY}
+ RENAME CTestTestfile.cmake)
--- /dev/null
+# Copyright (C) 2015-2020 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
+#
+
+SET(TEST_NAMES
+ test_SerafinReader
+)
+
+FOREACH(tfile ${TEST_NAMES})
+ SET(TEST_NAME ${COMPONENT_NAME}_${tfile})
+ ADD_TEST(${TEST_NAME} python ${tfile}.py)
+ SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
+ LABELS "${COMPONENT_NAME}"
+ TIMEOUT ${TIMEOUT}
+ )
+ENDFOREACH()
--- /dev/null
+from paraview.simple import *
+from vtk.util import numpy_support
+import numpy as np
+
+paraview.simple._DisableFirstRenderCameraReset()
+
+# Normal single precision file
+reader = SerafinReader(FileName='geo_sp.slf')
+reader.UpdatePipeline()
+reader_ds = servermanager.Fetch(reader)
+# Checking that fields THING X THING Y are merged into THING *
+list_var = [reader_ds.GetPointData().GetArrayName(i).strip() for i in range(reader_ds.GetPointData().GetNumberOfArrays())]
+assert("THING *" in list_var)
+assert("THING X" not in list_var)
+assert("THING OTHER" in list_var)
+# Checking that fields VELOCITY U, VELOCITY V are merged into VELOCITY *
+assert("VELOCITY *" in list_var)
+assert("VELOCITY U" not in list_var)
+assert("VELOCITY STUFF" in list_var)
+# Checking that VELOCITY has 3 components shoulb be on 0
+assert(reader_ds.GetPointData().GetArray(0).GetNumberOfComponents() == 3)
+
+# Simple read of Litte Endian file (Would crash if issue in the plugin)
+reader = SerafinReader(FileName='geo_sp_le.slf')
+# Simple read of Litte Endian file (Would crash if issue in the plugin)
+reader = SerafinReader(FileName='geo_dp_le.slf')
+
+# Normal double precision file
+reader = SerafinReader(FileName='geo_dp.slf')
+reader.UpdatePipeline()
+reader_ds = servermanager.Fetch(reader)
+# Checking that values are properly read
+data = numpy_support.vtk_to_numpy(reader_ds.GetPointData().GetArray(0))
+assert(np.all(data <= 1e-8))
+
+# 3d mesh
+reader = SerafinReader(FileName='geo_3d_dp.slf')
+reader.UpdatePipeline()
+reader_ds = servermanager.Fetch(reader)