Salome HOME
Merge branch 'V9_8_BR'
[modules/shaper_study.git] / test / testBuilder.py
1 #!/usr/bin/env python
2
3 ###
4 ### This file is generated automatically by SALOME v9.4.0 with dump python functionality
5 ###
6
7 import sys
8 import salome
9 salome.salome_init()
10
11 ###
12 ### SHAPER component
13 ###
14
15 from salome.shaper import model
16
17 model.begin()
18 partSet = model.moduleDocument()
19 Part_1 = model.addPart(partSet)
20 Part_1_doc = Part_1.document()
21 Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
22 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Box_1_1/Top")])
23
24 model.end()
25
26 ###
27 ### SHAPERSTUDY component
28 ###
29
30 import SHAPERSTUDY
31 import GEOM
32
33 model.begin()
34 anExportFeature = Part_1_doc.addFeature("PublishToStudy")
35 model.end()
36
37
38 face = salome.myStudy.FindObjectByPath("/ShaperResults/Face_1_1").GetObject()
39
40 shaper = face.GetGen()
41 print(shaper.ComponentDataType())
42
43 import shaperBuilder
44 shaper = shaperBuilder.New()
45
46 from salome.smesh import smeshBuilder
47 smesh = smeshBuilder.New(instanceGeom=shaper)
48
49 vv = shaper.ExtractShapes( face, shaper.ShapeType["VERTEX"])
50 assert len(vv) == 4
51 assert vv[0].GetShapeType() == GEOM.VERTEX
52 ee = shaper.ExtractShapes( face, shaper.ShapeType["EDGE"])
53 assert len(ee) == 4
54 assert ee[0].GetShapeType() == GEOM.EDGE
55
56 eGroup = shaper.CreateGroup( face, shaper.ShapeType["EDGE"])
57 eGroup.SetEntry("eGroup") # enable adding to study
58 shaper.addToStudyInFather( face, eGroup, "eGroup" )
59 shaper.UnionList( eGroup, ee )
60
61 meshOnFace = smesh.Mesh( face )
62 meshOnEdge = smesh.Mesh( ee[0] )
63
64 ind = shaper.GetSubShapeID( face, vv[0] )
65 assert ind == 4
66
67 d = shaper.MinDistance( vv[0], vv[1] )
68 assert d == 10
69
70 # SubShapeAll()
71 # PointCoordinates()
72 axis = smesh.GetAxisStruct( face )
73 print(axis)
74
75 # GetSubShape()
76 s = shaper.GetSubShape( face, [2] )
77 print (s.GetShapeType())
78 assert s.GetShapeType() == GEOM.WIRE
79 name = meshOnFace.GetSubShapeName( 2 )
80 print( name )
81
82 #NumberOfEdges()
83 #NumberOfFaces()
84 dim = meshOnFace.MeshDimension()
85 assert dim == 2
86 dim = meshOnEdge.MeshDimension()
87 assert dim == 1
88
89 #SubShapeName()
90 smeshBuilder.AssureGeomPublished( meshOnFace, ee[0] )
91
92 #Tolerance()
93 #GetVertexByIndex()
94 algo = meshOnFace.Segment()
95 l = algo.ReversedEdgeIndices([(ee[0],vv[0])])
96
97
98 ### unnecessary methods that can be accidentally called from any module
99 import SALOMEDS
100 face.GetTopologyType()
101 face.GetMinShapeType()
102 face.GetMaxShapeType()
103 face.GetSubShapeName(1)
104 face.SetColor(SALOMEDS.Color( 0,0,0 ))
105 face.GetColor()
106 face.SetAutoColor(0)
107 face.GetAutoColor()
108 face.SetMarkerStd(GEOM.MT_NONE, GEOM.MS_NONE)
109 face.SetMarkerTexture(0)
110 face.GetMarkerType()
111 face.GetMarkerSize()
112 face.GetMarkerTexture()
113
114
115 if salome.sg.hasDesktop():
116   salome.sg.updateObjBrowser()