With a small test

This commit is contained in:
Anthony Geay 2021-02-01 22:04:33 +01:00
parent b8cc25cce5
commit 2299517061
5 changed files with 141 additions and 2 deletions

View 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)
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}

View 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()
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()

View File

@ -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)

View File

@ -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)

View File

@ -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)