Salome HOME
Add a new test for sessionless mode to check that creating a mesh on a shaperstudy...
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Thu, 11 Mar 2021 15:04:35 +0000 (16:04 +0100)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Thu, 11 Mar 2021 15:04:35 +0000 (16:04 +0100)
doc/salome/examples/shaper_smesh_groups_without_session.py [new file with mode: 0644]
doc/salome/examples/tests.set

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 (file)
index 0000000..592dc50
--- /dev/null
@@ -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)
index de077547349877f6d74f318a3d967447ea455fb1..89f21a798dd99a7a21e9fb33caa8787a406ff012 100644 (file)
@@ -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)