From 217595b043e342bae8db187eb63ac9bd8c483b20 Mon Sep 17 00:00:00 2001 From: Christophe Bourcier Date: Wed, 30 Aug 2017 16:18:23 +0200 Subject: [PATCH] Adding support of salome test and make test --- CMakeLists.txt | 2 +- doc/salome/examples/CMakeLists.txt | 29 ++++++- doc/salome/examples/blsurfdemo.py | 6 +- doc/salome/examples/examples.set | 23 +++++ ...dicity_precad.py => periodicity_prepro.py} | 0 doc/salome/examples/testme.py | 56 ++++++++++++ .../input/blsurfplugin_python_interface.doc | 2 +- tests/CMakeLists.txt | 46 ++++++---- tests/CTestTestfileInstall.cmake | 32 +++++++ ..._vertex.py => enforced_internal_vertex.py} | 0 ..._enforced_vertex.py => enforced_vertex.py} | 0 ..._cadsurf_multithread.py => multithread.py} | 0 ..._2D_precad.py => periodicity_2D_prepro.py} | 0 ...dicity_precad.py => periodicity_prepro.py} | 0 ....py => periodicity_reflexion_2D_prepro.py} | 0 ...cad.py => periodicity_reflexion_prepro.py} | 0 ...y => periodicity_with_points_2D_prepro.py} | 0 ...tersections.py => prepro_intersections.py} | 0 ...recad_keep_gaps.py => prepro_keep_gaps.py} | 0 tests/{test_proximity.py => proximity.py} | 0 tests/quadrangles.py | 87 +++++++++++++++++++ ..._gradation.py => quadrangles_gradation.py} | 0 ...ove_tiny_edges.py => remove_tiny_edges.py} | 0 tests/{test_sphere.py => sphere.py} | 0 tests/tests.set | 35 ++++++++ 25 files changed, 294 insertions(+), 24 deletions(-) create mode 100644 doc/salome/examples/examples.set rename doc/salome/examples/{test_periodicity_precad.py => periodicity_prepro.py} (100%) create mode 100755 doc/salome/examples/testme.py create mode 100644 tests/CTestTestfileInstall.cmake rename tests/{test_enforced_internal_vertex.py => enforced_internal_vertex.py} (100%) rename tests/{test_enforced_vertex.py => enforced_vertex.py} (100%) rename tests/{test_cadsurf_multithread.py => multithread.py} (100%) rename tests/{test_periodicity_2D_precad.py => periodicity_2D_prepro.py} (100%) rename tests/{test_periodicity_precad.py => periodicity_prepro.py} (100%) rename tests/{test_periodicity_reflexion_2D_precad.py => periodicity_reflexion_2D_prepro.py} (100%) rename tests/{test_periodicity_reflexion_precad.py => periodicity_reflexion_prepro.py} (100%) rename tests/{test_periodicity_with_points_2D_precad.py => periodicity_with_points_2D_prepro.py} (100%) rename tests/{test_precad_intersections.py => prepro_intersections.py} (100%) rename tests/{test_precad_keep_gaps.py => prepro_keep_gaps.py} (100%) rename tests/{test_proximity.py => proximity.py} (100%) create mode 100644 tests/quadrangles.py rename tests/{test_quadrangles_gradation.py => quadrangles_gradation.py} (100%) rename tests/{test_remove_tiny_edges.py => remove_tiny_edges.py} (100%) rename tests/{test_sphere.py => sphere.py} (100%) create mode 100644 tests/tests.set diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e21fc0..74fe737 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,7 +202,7 @@ SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME # Specific to BLSURFPLUGIN: SET(SALOME_BLSURFPLUGIN_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/blsurfplugin" CACHE PATH "Install path: SALOME BLSURFPLUGIN specific data") -SET(SALOME_BLSURFPLUGIN_INSTALL_TESTS ${SALOME_INSTALL_BINS}) +SET(SALOME_BLSURFPLUGIN_INSTALL_TESTS "${SALOME_INSTALL_BINS}/test") MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS) MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON) diff --git a/doc/salome/examples/CMakeLists.txt b/doc/salome/examples/CMakeLists.txt index e9b983e..6df339d 100644 --- a/doc/salome/examples/CMakeLists.txt +++ b/doc/salome/examples/CMakeLists.txt @@ -17,5 +17,30 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -FILE(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/*.py") -INSTALL(FILES ${files} DESTINATION ${SALOME_INSTALL_DOC}/examples/BLSURFPLUGIN) +# FILE(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/*.py") + +INCLUDE(examples.set) + +SET(COMPONENT_NAME BLSURFPLUGIN) + +SET(TEST_INSTALL_DIRECTORY ${SALOME_BLSURFPLUGIN_INSTALL_TESTS}) + +# make test +SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) + +FOREACH(tfile ${EXAMPLE_NAMES}) + SET(TEST_NAME ${COMPONENT_NAME}_${tfile}) + ADD_TEST(NAME ${TEST_NAME} + COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/doc/salome/examples/testme.py ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES ENVIRONMENT "${tests_env}") + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") + INSTALL(FILES ${tfile}.py DESTINATION ${SALOME_INSTALL_DOC}/examples/BLSURFPLUGIN) +ENDFOREACH() + +# salome test +FOREACH(tfile ${EXAMPLE_NAMES}) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py + DESTINATION ${TEST_INSTALL_DIRECTORY}) +ENDFOREACH() + +INSTALL(FILES examples.set DESTINATION ${TEST_INSTALL_DIRECTORY}) \ No newline at end of file diff --git a/doc/salome/examples/blsurfdemo.py b/doc/salome/examples/blsurfdemo.py index 75221c1..bececef 100644 --- a/doc/salome/examples/blsurfdemo.py +++ b/doc/salome/examples/blsurfdemo.py @@ -122,15 +122,17 @@ Partition_1 = geompy.MakePartition([Face_3, Vertex_2], [], [], [], geompy.ShapeT OX = geompy.MakeVectorDXDYDZ(1, 0, 0) OY = geompy.MakeVectorDXDYDZ(0, 1, 0) Multi_Translation_1 = geompy.MakeMultiTranslation2D(Partition_1, OX, 1, 10, OY, 1, 10) +Multi_Translation_glued = geompy.MakeGlueEdges(Multi_Translation_1, 1e-7) geompy.addToStudy( Face_3, 'Face_3' ) geompy.addToStudy( Vertex_2, 'Vertex_2' ) geompy.addToStudy( Partition_1, 'Partition_1' ) geompy.addToStudy( OX, 'OX' ) geompy.addToStudy( OY, 'OY' ) -geompy.addToStudy( Multi_Translation_1, 'Multi-Translation_1' ) +geompy.addToStudy( Multi_Translation_1, 'Multi_Translation_1' ) +geompy.addToStudy( Multi_Translation_glued, 'Multi_Translation_glued' ) # The mesh on the geometry with internal vertices -cadsurfMesh_internal = smesh.Mesh(Multi_Translation_1, "cadsurfMesh_internal") +cadsurfMesh_internal = smesh.Mesh(Multi_Translation_glued, "cadsurfMesh_internal") algo2d = cadsurfMesh_internal.Triangle(algo=smeshBuilder.MG_CADSurf) algo2d.SetPhySize( 0.1 ) diff --git a/doc/salome/examples/examples.set b/doc/salome/examples/examples.set new file mode 100644 index 0000000..c0a63af --- /dev/null +++ b/doc/salome/examples/examples.set @@ -0,0 +1,23 @@ +# Copyright (C) 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 +# + +SET(EXAMPLE_NAMES + blsurfdemo + periodicity_prepro +) diff --git a/doc/salome/examples/test_periodicity_precad.py b/doc/salome/examples/periodicity_prepro.py similarity index 100% rename from doc/salome/examples/test_periodicity_precad.py rename to doc/salome/examples/periodicity_prepro.py diff --git a/doc/salome/examples/testme.py b/doc/salome/examples/testme.py new file mode 100755 index 0000000..6a502d0 --- /dev/null +++ b/doc/salome/examples/testme.py @@ -0,0 +1,56 @@ +# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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 +# + +#!/usr/bin/env python + +import unittest, sys, os + +class SalomeSession(object): + def __init__(self, script): + import runSalome + run_script = "runSalome.py" + if sys.platform == 'win32': + module_dir = os.getenv("KERNEL_ROOT_DIR") + if module_dir: run_script = os.path.join(module_dir, "bin", "salome", run_script) + pass + sys.argv = [run_script] + sys.argv += ["--terminal"] + sys.argv += ["--modules=GEOM,MED,SMESH"] + sys.argv += ["%s" % script] + if sys.platform == 'win32': + main_module_path = sys.modules['__main__'].__file__ + sys.modules['__main__'].__file__ = '' + clt, d = runSalome.main() + if sys.platform == 'win32': + sys.modules['__main__'].__file__ = main_module_path + return + + def __del__(self): + port = os.getenv('NSPORT') + import killSalomeWithPort + killSalomeWithPort.killMyPort(port) + return + pass + +class MyTest(unittest.TestCase): + def testFunction(self): + SalomeSession(sys.argv[1]) + pass + +unittest.main(argv=sys.argv[:1]) diff --git a/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc b/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc index 710043e..21bb414 100644 --- a/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc +++ b/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc @@ -27,6 +27,6 @@ Below you can see examples of usage of this class for 2D mesh generation. \anchor tui_blsurf_periodicity_preCAD

Example of periodicity definition with preCAD

-\tui_script{test_periodicity_precad.py} +\tui_script{periodicity_prepro.py} */ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 07dec00..101290a 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -17,21 +17,31 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SET(BLSURFPLUGIN_TEST_FILES - test_cadsurf_multithread.py - test_enforced_internal_vertex.py - test_enforced_vertex.py - test_periodicity_2D_precad.py - test_periodicity_precad.py - test_periodicity_reflexion_2D_precad.py - test_periodicity_reflexion_precad.py - test_periodicity_with_points_2D_precad.py - test_precad_intersections.py - test_precad_keep_gaps.py - test_proximity.py - test_quadrangles_gradation.py - test_remove_tiny_edges.py - test_sphere.py -) - -INSTALL(FILES ${BLSURFPLUGIN_TEST_FILES} DESTINATION ${SALOME_BLSURFPLUGIN_INSTALL_TESTS}) +INCLUDE(tests.set) + +SET(COMPONENT_NAME BLSURFPLUGIN) + +SET(TEST_INSTALL_DIRECTORY ${SALOME_BLSURFPLUGIN_INSTALL_TESTS}) + +# make test +SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) + +FOREACH(tfile ${TEST_NAMES}) + SET(TEST_NAME ${COMPONENT_NAME}_${tfile}) + ADD_TEST(NAME ${TEST_NAME} + COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/doc/salome/examples/testme.py ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES ENVIRONMENT "${tests_env}") + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") +ENDFOREACH() + +# salome test +FOREACH(tfile ${TEST_NAMES}) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py + DESTINATION ${TEST_INSTALL_DIRECTORY}) +ENDFOREACH() + +INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${TEST_INSTALL_DIRECTORY} + RENAME CTestTestfile.cmake) + +INSTALL(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY}) \ No newline at end of file diff --git a/tests/CTestTestfileInstall.cmake b/tests/CTestTestfileInstall.cmake new file mode 100644 index 0000000..681a342 --- /dev/null +++ b/tests/CTestTestfileInstall.cmake @@ -0,0 +1,32 @@ +# Copyright (C) 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 +# + +INCLUDE(tests.set) +INCLUDE(examples.set) + +SET(COMPONENT_NAME BLSURFPLUGIN) +SET(SALOME_TEST_DRIVER "$ENV{KERNEL_ROOT_DIR}/bin/salome/appliskel/salome_test_driver.py") +SET(TIMEOUT 300) + + +FOREACH(tfile ${TEST_NAMES} ${EXAMPLE_NAMES}) + SET(TEST_NAME ${COMPONENT_NAME}_${tfile}) + ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ${tfile}.py) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") +ENDFOREACH() diff --git a/tests/test_enforced_internal_vertex.py b/tests/enforced_internal_vertex.py similarity index 100% rename from tests/test_enforced_internal_vertex.py rename to tests/enforced_internal_vertex.py diff --git a/tests/test_enforced_vertex.py b/tests/enforced_vertex.py similarity index 100% rename from tests/test_enforced_vertex.py rename to tests/enforced_vertex.py diff --git a/tests/test_cadsurf_multithread.py b/tests/multithread.py similarity index 100% rename from tests/test_cadsurf_multithread.py rename to tests/multithread.py diff --git a/tests/test_periodicity_2D_precad.py b/tests/periodicity_2D_prepro.py similarity index 100% rename from tests/test_periodicity_2D_precad.py rename to tests/periodicity_2D_prepro.py diff --git a/tests/test_periodicity_precad.py b/tests/periodicity_prepro.py similarity index 100% rename from tests/test_periodicity_precad.py rename to tests/periodicity_prepro.py diff --git a/tests/test_periodicity_reflexion_2D_precad.py b/tests/periodicity_reflexion_2D_prepro.py similarity index 100% rename from tests/test_periodicity_reflexion_2D_precad.py rename to tests/periodicity_reflexion_2D_prepro.py diff --git a/tests/test_periodicity_reflexion_precad.py b/tests/periodicity_reflexion_prepro.py similarity index 100% rename from tests/test_periodicity_reflexion_precad.py rename to tests/periodicity_reflexion_prepro.py diff --git a/tests/test_periodicity_with_points_2D_precad.py b/tests/periodicity_with_points_2D_prepro.py similarity index 100% rename from tests/test_periodicity_with_points_2D_precad.py rename to tests/periodicity_with_points_2D_prepro.py diff --git a/tests/test_precad_intersections.py b/tests/prepro_intersections.py similarity index 100% rename from tests/test_precad_intersections.py rename to tests/prepro_intersections.py diff --git a/tests/test_precad_keep_gaps.py b/tests/prepro_keep_gaps.py similarity index 100% rename from tests/test_precad_keep_gaps.py rename to tests/prepro_keep_gaps.py diff --git a/tests/test_proximity.py b/tests/proximity.py similarity index 100% rename from tests/test_proximity.py rename to tests/proximity.py diff --git a/tests/quadrangles.py b/tests/quadrangles.py new file mode 100644 index 0000000..bb1e0c3 --- /dev/null +++ b/tests/quadrangles.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Face_1 = geompy.MakeFaceHW(100, 100, 1) +Disk_1 = geompy.MakeDiskR(20, 1) +Partition_1 = geompy.MakePartition([Face_1, Disk_1], Limit=geompy.ShapeType["FACE"]) +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Face_1, 'Face_1' ) +geompy.addToStudy( Disk_1, 'Disk_1' ) +geompy.addToStudy( Partition_1, 'Partition_1' ) + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +from salome.BLSURFPlugin import BLSURFPluginBuilder + +smesh = smeshBuilder.New(theStudy) +Mesh_1 = smesh.Mesh(Partition_1) +MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf) +MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters() +MG_CADSurf_Parameters_1.SetPhySize( 10 ) +MG_CADSurf_Parameters_1.SetMaxSize( 10 ) +MG_CADSurf_Parameters_1.SetChordalError( -1 ) + + +# Test quadrangle dominant +MG_CADSurf_Parameters_1.SetElementType( BLSURFPluginBuilder.QuadrangleDominant ) +isDone = Mesh_1.Compute() + +assert Mesh_1.NbQuadrangles() > 0 +assert Mesh_1.NbTriangles() > 0 +assert Mesh_1.NbQuadrangles() > Mesh_1.NbTriangles() + + +# Test quadrangles only +MG_CADSurf_Parameters_1.SetElementType( BLSURFPluginBuilder.Quadrangles ) +isDone = Mesh_1.Compute() + +assert Mesh_1.NbQuadrangles() > 0 +assert Mesh_1.NbTriangles() == 0 + + +# Test triangles only +MG_CADSurf_Parameters_1.SetElementType( BLSURFPluginBuilder.Triangles ) +isDone = Mesh_1.Compute() + +assert Mesh_1.NbQuadrangles() == 0 +assert Mesh_1.NbTriangles() > 0 + +# Test quadrangle dominant compatibility (to be deprecated in Salome 9) +MG_CADSurf_Parameters_1.SetQuadAllowed( True ) +isDone = Mesh_1.Compute() + +assert Mesh_1.NbQuadrangles() > 0 +assert Mesh_1.NbTriangles() > 0 +assert Mesh_1.NbQuadrangles() > Mesh_1.NbTriangles() + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(True) diff --git a/tests/test_quadrangles_gradation.py b/tests/quadrangles_gradation.py similarity index 100% rename from tests/test_quadrangles_gradation.py rename to tests/quadrangles_gradation.py diff --git a/tests/test_remove_tiny_edges.py b/tests/remove_tiny_edges.py similarity index 100% rename from tests/test_remove_tiny_edges.py rename to tests/remove_tiny_edges.py diff --git a/tests/test_sphere.py b/tests/sphere.py similarity index 100% rename from tests/test_sphere.py rename to tests/sphere.py diff --git a/tests/tests.set b/tests/tests.set new file mode 100644 index 0000000..b1dde31 --- /dev/null +++ b/tests/tests.set @@ -0,0 +1,35 @@ +# Copyright (C) 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 +# + +SET(TEST_NAMES + enforced_internal_vertex + enforced_vertex + multithread + periodicity_2D_prepro + #periodicity_prepro # already tested in examples + periodicity_reflexion_2D_prepro + periodicity_reflexion_prepro + periodicity_with_points_2D_prepro + prepro_intersections + prepro_keep_gaps + proximity + quadrangles_gradation + remove_tiny_edges + sphere +) -- 2.39.2