Salome HOME
With a small test
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 1 Feb 2021 21:04:33 +0000 (22:04 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 1 Feb 2021 21:04:33 +0000 (22:04 +0100)
doc/salome/examples/CMakeLists.txt
doc/salome/examples/CTestTestfileInstall.cmake
doc/salome/examples/basic_geom_smesh_without_session.py [new file with mode: 0644]
doc/salome/examples/basic_shaper_smesh_without_session.py [new file with mode: 0644]
doc/salome/examples/tests.set

index 8121124f7794be360e9f7f0b54e74bc3a63f87c5..52f2cf71f855d84c9644f6d3d20be0275939090c 100644 (file)
@@ -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)
 # 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}
 
 INSTALL(FILES CTestTestfileInstall.cmake
         DESTINATION ${TEST_INSTALL_DIRECTORY}
index 9a38643c10a61488c723b485e0a65541ced86405..4e28b8bb32b58a82c0fd0df4f1d8e65071e27c18 100644 (file)
@@ -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()
   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 (file)
index 0000000..d10a23c
--- /dev/null
@@ -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 (file)
index 0000000..54594a1
--- /dev/null
@@ -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)
index f903c04b4dc5afa175922e7057890e361c21b126..de077547349877f6d74f318a3d967447ea455fb1 100644 (file)
@@ -185,4 +185,9 @@ SET(GOOD_TESTS
   test_polyhedron_per_solid.py
 )
 
   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)