From 1c356932084f5e9c4eb445becf40da1485a326a4 Mon Sep 17 00:00:00 2001 From: Christophe Bourcier Date: Thu, 11 Mar 2021 16:04:35 +0100 Subject: [PATCH] Add a new test for sessionless mode to check that creating a mesh on a shaperstudy object does not raise orb not found --- .../shaper_smesh_groups_without_session.py | 88 +++++++++++++++++++ doc/salome/examples/tests.set | 1 + 2 files changed, 89 insertions(+) create mode 100644 doc/salome/examples/shaper_smesh_groups_without_session.py diff --git a/doc/salome/examples/shaper_smesh_groups_without_session.py b/doc/salome/examples/shaper_smesh_groups_without_session.py new file mode 100644 index 000000000..592dc506a --- /dev/null +++ b/doc/salome/examples/shaper_smesh_groups_without_session.py @@ -0,0 +1,88 @@ + +""" +Check that creating a mesh on a shaperstudy object does not raise orb not found in GetExistingSubObjects. +It is called in SMESH GUI on Create mesh's Apply, in SMESHGUI_MeshOp::createSubMeshOnInternalEdges. +We explicitly call GetExistingSubObjects here to be able to test it in python. +""" + +import sys +import salome + +salome.standalone() +salome.salome_init() + +### +### 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) + +### Create Group +Group_1 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Bottom]")]) +Group_1.setName("edge_ox") +Group_1.result().setName("edge_ox") + +### Create Group +Group_2 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Left]")]) +Group_2.setName("edge_oz") +Group_2.result().setName("edge_oz") + +model.end() + +### +### SHAPERSTUDY component +### + +model.publishToShaperStudy() +import SHAPERSTUDY +Box_1_1, edge_ox, edge_oz = 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) + +Regular_1D = Mesh_1.Segment() +Local_Length_1 = Regular_1D.LocalLength(5) + +MEFISTO_2D = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO) + +ok = Mesh_1.Compute() + +if not ok: + raise Exception("Error when computing Mesh_1") + +edge_ox_1 = Mesh_1.GroupOnGeom(edge_ox,'edge_ox',SMESH.EDGE) +edge_oz_1 = Mesh_1.GroupOnGeom(edge_oz,'edge_oz',SMESH.EDGE) + +# check that ObjectToSObject works (called in GetExistingSubObjects) +Box_1_1_sobj = salome.ObjectToSObject(Box_1_1) +if not Box_1_1_sobj: + raise Exception("No SObject for Box_1_1") + +# check that GetExistingSubObjects works (called in SMESHGUI_MeshOp::createSubMeshOnInternalEdges) +shaperBuilder = salome.lcc.FindOrLoadComponent("FactoryServer","SHAPERSTUDY") +sOp = shaperBuilder.GetIShapesOperations() +geomGroups = sOp.GetExistingSubObjects(Box_1_1, True) + +assert(len(geomGroups)==2) + +assert(Mesh_1.GetMesh().NbTriangles()>16) diff --git a/doc/salome/examples/tests.set b/doc/salome/examples/tests.set index de0775473..89f21a798 100644 --- a/doc/salome/examples/tests.set +++ b/doc/salome/examples/tests.set @@ -188,6 +188,7 @@ SET(GOOD_TESTS set(SESSION_FREE_TESTS basic_geom_smesh_without_session.py basic_shaper_smesh_without_session.py + shaper_smesh_groups_without_session.py ) SET(EXAMPLES_TESTS ${BAD_TESTS} ${GOOD_TESTS} ${SESSION_FREE_TESTS} testme.py) -- 2.39.2