Salome HOME
bos #29171 Refactor testing procedure
[modules/smesh.git] / test / shaper_smesh_groups_without_session.py
1
2 """
3 Check that creating a mesh on a shaperstudy object does not raise orb not found in GetExistingSubObjects.
4 It is called in SMESH GUI on Create mesh's Apply, in SMESHGUI_MeshOp::createSubMeshOnInternalEdges.
5 We explicitly call GetExistingSubObjects here to be able to test it in python.
6 """
7
8 import sys
9 import salome
10
11 salome.standalone()
12 salome.salome_init()
13
14 ###
15 ### SHAPER component
16 ###
17
18 from salome.shaper import model
19
20 model.begin()
21 partSet = model.moduleDocument()
22
23 ### Create Part
24 Part_1 = model.addPart(partSet)
25 Part_1_doc = Part_1.document()
26
27 ### Create Box
28 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
29
30 ### Create Group
31 Group_1 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Bottom]")])
32 Group_1.setName("edge_ox")
33 Group_1.result().setName("edge_ox")
34
35 ### Create Group
36 Group_2 = model.addGroup(Part_1_doc, "Edges", [model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Left]")])
37 Group_2.setName("edge_oz")
38 Group_2.result().setName("edge_oz")
39
40 model.end()
41
42 ###
43 ### SHAPERSTUDY component
44 ###
45
46 model.publishToShaperStudy()
47 import SHAPERSTUDY
48 Box_1_1, edge_ox, edge_oz = SHAPERSTUDY.shape(model.featureStringId(Box_1))
49
50 ###
51 ### SMESH component
52 ###
53
54 import  SMESH, SALOMEDS
55 from salome.smesh import smeshBuilder
56
57 smesh = smeshBuilder.New()
58 #smesh.SetEnablePublish( False ) # Set to False to avoid publish in study if not needed or in some particular situations:
59                                  # multiples meshes built in parallel, complex and numerous mesh edition (performance)
60
61 Mesh_1 = smesh.Mesh(Box_1_1)
62
63 Regular_1D = Mesh_1.Segment()
64 Local_Length_1 = Regular_1D.LocalLength(5)
65
66 MEFISTO_2D = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO)
67
68 ok = Mesh_1.Compute()
69
70 if not ok:
71   raise Exception("Error when computing Mesh_1")
72
73 edge_ox_1 = Mesh_1.GroupOnGeom(edge_ox,'edge_ox',SMESH.EDGE)
74 edge_oz_1 = Mesh_1.GroupOnGeom(edge_oz,'edge_oz',SMESH.EDGE)
75
76 # check that ObjectToSObject works (called in GetExistingSubObjects)
77 Box_1_1_sobj = salome.ObjectToSObject(Box_1_1)
78 if not Box_1_1_sobj:
79   raise Exception("No SObject for Box_1_1")
80
81 # check that GetExistingSubObjects works (called in SMESHGUI_MeshOp::createSubMeshOnInternalEdges)
82 shaperBuilder = salome.lcc.FindOrLoadComponent("FactoryServer","SHAPERSTUDY")
83 sOp = shaperBuilder.GetIShapesOperations()
84 geomGroups = sOp.GetExistingSubObjects(Box_1_1, True)
85
86 assert(len(geomGroups)==2)
87
88 assert(Mesh_1.GetMesh().NbTriangles()>16)