From: Anthony Geay Date: Mon, 1 Feb 2021 21:04:33 +0000 (+0100) Subject: With a small test X-Git-Tag: V9_7_0a1~27^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=229951706125e2a6e16f31428db784066900eab1;p=modules%2Fsmesh.git With a small test --- diff --git a/doc/salome/examples/CMakeLists.txt b/doc/salome/examples/CMakeLists.txt index 8121124f7..52f2cf71f 100644 --- a/doc/salome/examples/CMakeLists.txt +++ b/doc/salome/examples/CMakeLists.txt @@ -41,7 +41,7 @@ SALOME_INSTALL_SCRIPTS("${EXAMPLES_TESTS}" ${SALOME_INSTALL_DOC}/examples/SMESH) # Application tests SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test) -INSTALL(FILES ${GOOD_TESTS} ${BAD_TESTS} DESTINATION ${TEST_INSTALL_DIRECTORY}) +INSTALL(FILES ${GOOD_TESTS} ${BAD_TESTS} ${SESSION_FREE_TESTS} DESTINATION ${TEST_INSTALL_DIRECTORY}) INSTALL(FILES CTestTestfileInstall.cmake DESTINATION ${TEST_INSTALL_DIRECTORY} diff --git a/doc/salome/examples/CTestTestfileInstall.cmake b/doc/salome/examples/CTestTestfileInstall.cmake index 9a38643c1..4e28b8bb3 100644 --- a/doc/salome/examples/CTestTestfileInstall.cmake +++ b/doc/salome/examples/CTestTestfileInstall.cmake @@ -29,3 +29,10 @@ FOREACH(tfile ${GOOD_TESTS} ${BAD_TESTS}) ADD_TEST(${TEST_NAME} python ${SALOME_TEST_DRIVER} ${TIMEOUT} ${tfile}) SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") ENDFOREACH() + +foreach(tfile ${SESSION_FREE_TESTS}) + get_filename_component(BASE_NAME ${tfile} NAME_WE) + set(TEST_NAME SMESH_${BASE_NAME}) + add_test(${TEST_NAME} python ${tfile}) + set_tests_properties(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") +endforeach() diff --git a/doc/salome/examples/basic_geom_smesh_without_session.py b/doc/salome/examples/basic_geom_smesh_without_session.py new file mode 100644 index 000000000..d10a23cee --- /dev/null +++ b/doc/salome/examples/basic_geom_smesh_without_session.py @@ -0,0 +1,53 @@ + +""" +Most basic test of GEOM/SMESH usecase, but it can be tested without any session launched. +""" + +import sys +import salome + +import os +salome.standalone() # <- key point of test is here +salome.salome_init() +import salome_notebook +notebook = salome_notebook.NoteBook() + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + +geompy = geomBuilder.New() +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Box_1, 'Box_1' ) +### +### SMESH component +### +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New() +smesh.SetEnablePublish( True ) # Set to False to avoid publish in study if not needed or in some particular situations: + # multiples meshes built in parallel, complex and numerous mesh edition (performance) +Mesh_1 = smesh.Mesh(Box_1) +NETGEN_1D_2D_3D = Mesh_1.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D) +isDone = Mesh_1.Compute() + + +## Set names of Mesh objects +smesh.SetName(NETGEN_1D_2D_3D.GetAlgorithm(), 'NETGEN 1D-2D-3D') +smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1') + +assert(Mesh_1.GetMesh().NbTetras()>=5) diff --git a/doc/salome/examples/basic_shaper_smesh_without_session.py b/doc/salome/examples/basic_shaper_smesh_without_session.py new file mode 100644 index 000000000..54594a194 --- /dev/null +++ b/doc/salome/examples/basic_shaper_smesh_without_session.py @@ -0,0 +1,74 @@ + +""" +Most basic test of SHAPE/SMESH usecase, but it can be tested without any session launched. +""" + +import sys +import salome +salome.standalone() # <- key point of test is here +salome.salome_init() + +#from salome.shaper import initConfig + +import os +print(os.getpid()) +#input("AAA") +### +### SHAPER component +### + +from salome.shaper import model +model.begin() +partSet = model.moduleDocument() + +### Create Part +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +### Create Box +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) + +model.end() + +### +### SHAPERSTUDY component +### +#import pdb; pdb.set_trace() +model.publishToShaperStudy() +import SHAPERSTUDY +#import pdb; pdb.set_trace() +Box_1_1, = SHAPERSTUDY.shape(model.featureStringId(Box_1)) +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New() +#smesh.SetEnablePublish( False ) # Set to False to avoid publish in study if not needed or in some particular situations: + # multiples meshes built in parallel, complex and numerous mesh edition (performance) + +Mesh_1 = smesh.Mesh(Box_1_1) +NETGEN_1D_2D_3D = Mesh_1.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D) +NETGEN_3D_Parameters_1 = NETGEN_1D_2D_3D.Parameters() +NETGEN_3D_Parameters_1.SetMaxSize( 5 ) +NETGEN_3D_Parameters_1.SetMinSize( 1 ) +NETGEN_3D_Parameters_1.SetSecondOrder( 0 ) +NETGEN_3D_Parameters_1.SetOptimize( 1 ) +NETGEN_3D_Parameters_1.SetFineness( 2 ) +NETGEN_3D_Parameters_1.SetChordalError( -1 ) +NETGEN_3D_Parameters_1.SetChordalErrorEnabled( 0 ) +NETGEN_3D_Parameters_1.SetUseSurfaceCurvature( 1 ) +NETGEN_3D_Parameters_1.SetFuseEdges( 1 ) +NETGEN_3D_Parameters_1.SetQuadAllowed( 0 ) +NETGEN_3D_Parameters_1.SetCheckChartBoundary( 152 ) +isDone = Mesh_1.Compute() + + +## Set names of Mesh objects +smesh.SetName(NETGEN_1D_2D_3D.GetAlgorithm(), 'NETGEN 1D-2D-3D') +smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1') +smesh.SetName(NETGEN_3D_Parameters_1, 'NETGEN 3D Parameters_1') + +assert(Mesh_1.GetMesh().NbTetras()>=5) diff --git a/doc/salome/examples/tests.set b/doc/salome/examples/tests.set index f903c04b4..de0775473 100644 --- a/doc/salome/examples/tests.set +++ b/doc/salome/examples/tests.set @@ -185,4 +185,9 @@ SET(GOOD_TESTS test_polyhedron_per_solid.py ) -SET(EXAMPLES_TESTS ${BAD_TESTS} ${GOOD_TESTS} testme.py) +set(SESSION_FREE_TESTS + basic_geom_smesh_without_session.py + basic_shaper_smesh_without_session.py +) + +SET(EXAMPLES_TESTS ${BAD_TESTS} ${GOOD_TESTS} ${SESSION_FREE_TESTS} testme.py)