Salome HOME
Merge remote branch 'origin/V8_5_asterstudy'
[modules/smesh.git] / src / Tools / blocFissure / materielCasTests / vis.py
1 # -*- coding: utf-8 -*-
2
3 import sys
4 import salome
5
6 salome.salome_init()
7
8 import salome_notebook
9 notebook = salome_notebook.notebook
10
11 import os
12 from blocFissure import gmu
13
14 ###
15 ### GEOM component
16 ###
17
18 import GEOM
19 from salome.geom import geomBuilder
20 import math
21 import SALOMEDS
22
23
24 geompy = geomBuilder.New()
25 O = geompy.MakeVertex(0, 0, 0)
26 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
27 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
28 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
29 geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
30 geomObj_2 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
31 sk = geompy.Sketcher2D()
32 sk.addPoint(0.000000, 0.000000)
33 sk.addSegmentAbsolute(10.000000, 0.000000)
34 sk.addSegmentAbsolute(10.000000, 98.750000)
35 sk.addArcAngleRadiusLength(0, -1.250000, 90.000000)
36 sk.addSegmentAbsolute(15.000000, 100.000000)
37 sk.addSegmentAbsolute(15.000000, 120.000000)
38 sk.addSegmentAbsolute(9.945000, 120.000000)
39 sk.addSegmentAbsolute(9.945000, 108.000000)
40 sk.addSegmentAbsolute(0.000000, 105.000000)
41 sk.close()
42 Sketch_1 = sk.wire(geomObj_2)
43 Face_1 = geompy.MakeFaceWires([Sketch_1], 1)
44 Vertex_1 = geompy.MakeVertex(15, 108, 0)
45 Vertex_2 = geompy.MakeVertex(0, 94, 0)
46 Vertex_3 = geompy.MakeVertex(10, 94, 0)
47 Face_1_vertex_17 = geompy.GetSubShape(Face_1, [17])
48 Line_1 = geompy.MakeLineTwoPnt(Vertex_1, Face_1_vertex_17)
49 Face_1_vertex_9 = geompy.GetSubShape(Face_1, [9])
50 Line_2 = geompy.MakeLineTwoPnt(Face_1_vertex_17, Face_1_vertex_9)
51 Face_1_vertex_19 = geompy.GetSubShape(Face_1, [19])
52 Face_1_vertex_7 = geompy.GetSubShape(Face_1, [7])
53 Line_3 = geompy.MakeLineTwoPnt(Face_1_vertex_19, Face_1_vertex_7)
54 Line_4 = geompy.MakeLineTwoPnt(Vertex_2, Vertex_3)
55 coupe_vis = geompy.MakePartition([Face_1], [Line_1, Line_2, Line_3, Line_4], [], [], geompy.ShapeType["FACE"], 0, [], 0)
56 [tige, section, tige_haute, rond, tete, section_tete] = geompy.Propagate(coupe_vis)
57 conge = geompy.CreateGroup(coupe_vis, geompy.ShapeType["EDGE"])
58 geompy.UnionIDs(conge, [25])
59 appui = geompy.CreateGroup(coupe_vis, geompy.ShapeType["EDGE"])
60 geompy.UnionIDs(appui, [39])
61 p_imp = geompy.CreateGroup(coupe_vis, geompy.ShapeType["EDGE"])
62 geompy.UnionIDs(p_imp, [11])
63
64 Vertex_4 = geompy.MakeVertex(11.25, 98.75, 0)
65 Vertex_5 = geompy.MakeVertexWithRef(Vertex_4, -0.5, 0.5, 0)
66 Vertex_6 = geompy.MakeVertexWithRef(Vertex_4, -5, 5, 0)
67 Line_5 = geompy.MakeLineTwoPnt(Vertex_5, Vertex_6)
68 Partition_1 = geompy.MakePartition([Line_5], [conge], [], [], geompy.ShapeType["EDGE"], 0, [], 1)
69 [Vertex_7] = geompy.SubShapes(Partition_1, [4])
70 Vertex_8 = geompy.MakeVertexWithRef(Vertex_7, -1.1, 1.1, 0)
71 generatrice = geompy.MakeLineTwoPnt(Vertex_5, Vertex_8)
72 Revolution_1 = geompy.MakeRevolution2Ways(generatrice, OY, 60*math.pi/180.0)
73 Partition_2 = geompy.MakePartition([Revolution_1], [conge], [], [], geompy.ShapeType["FACE"], 0, [], 1)
74 Partition_2_vertex_11 = geompy.GetSubShape(Partition_2, [11])
75 Plane_1 = geompy.MakePlane(Partition_2_vertex_11, OY, 2000)
76 Partition_3 = geompy.MakePartition([Revolution_1], [Plane_1], [], [], geompy.ShapeType["FACE"], 0, [], 0)
77 Vertex_9 = geompy.MakeVertex(0, 99.633883, 1.977320000000001)
78 Vertex_10 = geompy.MakeVertex(0, 99.633883, -8.977320000000001)
79 Vertex_11 = geompy.MakeVertexWithRef(Vertex_9, 0, 0, -1)
80 Vertex11x = geompy.MakeVertexWithRef(Vertex_11, 1, 0, 0)
81 Line_11x = geompy.MakeLineTwoPnt(Vertex_11, Vertex11x)
82 Vertex_12 = geompy.MakeVertexWithRef(Vertex_10, 0, 0, 1)
83 Vertex12x = geompy.MakeVertexWithRef(Vertex_12, 1, 0, 0)
84 Line_12x = geompy.MakeLineTwoPnt(Vertex_12, Vertex12x)
85 Vertex_13 = geompy.MakeVertexWithRef(Vertex_11, 0, 1, 0)
86 Vertex_14 = geompy.MakeVertexWithRef(Vertex_12, 0, 1, 0)
87 Vertex_15 = geompy.MakeRotation(Vertex_9, Line_11x, 30*math.pi/180.0)
88 Vertex_16 = geompy.MakeRotation(Vertex_10, Line_12x, -30*math.pi/180.0)
89 Arc_1 = geompy.MakeArc(Vertex_15, Vertex_9, Vertex_13,False)
90 Arc_2 = geompy.MakeArc(Vertex_14, Vertex_10, Vertex_16,False)
91 Line_6 = geompy.MakeLineTwoPnt(Vertex_13, Vertex_14)
92 Line_8 = geompy.MakeLineTwoPnt(Vertex_16, Vertex_15)
93 Wire_1 = geompy.MakeWire([Arc_1, Arc_2, Line_6, Line_8], 1e-07)
94 Face_2 = geompy.MakeFaceWires([Wire_1], 1)
95 Extrusion_1 = geompy.MakePrismVecH(Face_2, OX, 15)
96 Revolution_2 = geompy.MakeRevolution2Ways(generatrice, OY, 65*math.pi/180.0)
97 Fissure = geompy.MakeCommonList([Extrusion_1, Revolution_2], True)
98 fondFiss = geompy.CreateGroup(Fissure, geompy.ShapeType["EDGE"])
99 geompy.UnionIDs(fondFiss, [9, 7, 4])
100 geompy.ExportBREP(Fissure, os.path.join(gmu.pathBloc, "materielCasTests/visFiss.brep"))
101
102 geompy.addToStudy( O, 'O' )
103 geompy.addToStudy( OX, 'OX' )
104 geompy.addToStudy( OY, 'OY' )
105 geompy.addToStudy( OZ, 'OZ' )
106 geompy.addToStudy( Sketch_1, 'Sketch_1' )
107 geompy.addToStudy( Face_1, 'Face_1' )
108 geompy.addToStudy( Vertex_1, 'Vertex_1' )
109 geompy.addToStudy( Vertex_2, 'Vertex_2' )
110 geompy.addToStudy( Vertex_3, 'Vertex_3' )
111 geompy.addToStudyInFather( Face_1, Face_1_vertex_17, 'Face_1:vertex_17' )
112 geompy.addToStudy( Line_1, 'Line_1' )
113 geompy.addToStudyInFather( Face_1, Face_1_vertex_9, 'Face_1:vertex_9' )
114 geompy.addToStudy( Line_2, 'Line_2' )
115 geompy.addToStudyInFather( Face_1, Face_1_vertex_19, 'Face_1:vertex_19' )
116 geompy.addToStudyInFather( Face_1, Face_1_vertex_7, 'Face_1:vertex_7' )
117 geompy.addToStudy( Line_3, 'Line_3' )
118 geompy.addToStudy( Line_4, 'Line_4' )
119 geompy.addToStudy( coupe_vis, 'coupe_vis' )
120 geompy.addToStudyInFather( coupe_vis, tige, 'tige' )
121 geompy.addToStudyInFather( coupe_vis, section, 'section' )
122 geompy.addToStudyInFather( coupe_vis, tige_haute, 'tige_haute' )
123 geompy.addToStudyInFather( coupe_vis, rond, 'rond' )
124 geompy.addToStudyInFather( coupe_vis, tete, 'tete' )
125 geompy.addToStudyInFather( coupe_vis, section_tete, 'section_tete' )
126 geompy.addToStudyInFather( coupe_vis, conge, 'conge' )
127 geompy.addToStudyInFather( coupe_vis, appui, 'appui' )
128 geompy.addToStudyInFather( coupe_vis, p_imp, 'p_imp' )
129
130 geompy.addToStudy( Vertex_4, 'Vertex_4' )
131 geompy.addToStudy( Vertex_6, 'Vertex_6' )
132 geompy.addToStudy( Vertex_5, 'Vertex_5' )
133 geompy.addToStudy( Line_5, 'Line_5' )
134 geompy.addToStudy( Partition_1, 'Partition_1' )
135 geompy.addToStudyInFather( Partition_1, Vertex_7, 'Vertex_7' )
136 geompy.addToStudy( Vertex_8, 'Vertex_8' )
137 geompy.addToStudy( generatrice, 'generatrice' )
138 geompy.addToStudy( Revolution_1, 'Revolution_1' )
139 geompy.addToStudy( Partition_2, 'Partition_2' )
140 geompy.addToStudyInFather( Partition_2, Partition_2_vertex_11, 'Partition_2:vertex_11' )
141 geompy.addToStudy( Plane_1, 'Plane_1' )
142 geompy.addToStudy( Partition_3, 'Partition_3' )
143 geompy.addToStudy( Vertex_9, 'Vertex_9' )
144 geompy.addToStudy( Vertex_10, 'Vertex_10' )
145 geompy.addToStudy( Vertex_11, 'Vertex_11' )
146 geompy.addToStudy( Vertex_12, 'Vertex_12' )
147 geompy.addToStudy( Vertex_13, 'Vertex_13' )
148 geompy.addToStudy( Vertex_14, 'Vertex_14' )
149 geompy.addToStudy( Vertex_15, 'Vertex_15' )
150 geompy.addToStudy( Vertex_16, 'Vertex_16' )
151 geompy.addToStudy( Arc_1, 'Arc_1' )
152 geompy.addToStudy( Arc_2, 'Arc_2' )
153 geompy.addToStudy( Line_6, 'Line_6' )
154 geompy.addToStudy( Line_8, 'Line_8' )
155 geompy.addToStudy( Wire_1, 'Wire_1' )
156 geompy.addToStudy( Face_2, 'Face_2' )
157 geompy.addToStudy( Extrusion_1, 'Extrusion_1' )
158 geompy.addToStudy( Revolution_2, 'Revolution_2' )
159 geompy.addToStudy( Fissure, 'Fissure' )
160 geompy.addToStudyInFather( Fissure, fondFiss, 'fondFiss' )
161
162 ###
163 ### SMESH component
164 ###
165
166 import  SMESH, SALOMEDS
167 from salome.smesh import smeshBuilder
168
169 smesh = smeshBuilder.New()
170 coupe_vis_1 = smesh.Mesh(coupe_vis)
171 Regular_1D = coupe_vis_1.Segment()
172 Nb_Segments_1 = Regular_1D.NumberOfSegments(10)
173 Quadrangle_2D = coupe_vis_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
174 Regular_1D_1 = coupe_vis_1.Segment(geom=tige)
175 Nb_Segments_2 = Regular_1D_1.NumberOfSegments(30)
176 Regular_1D_2 = coupe_vis_1.Segment(geom=section)
177 Nb_Segments_3 = Regular_1D_2.NumberOfSegments(10,1,[ 7, 11, 16, 23 ])
178 isDone = coupe_vis_1.Compute()
179 isDone = coupe_vis_1.SplitQuad( [ 691 ], 1 )
180 tige_1 = coupe_vis_1.GroupOnGeom(tige,'tige',SMESH.EDGE)
181 section_1 = coupe_vis_1.GroupOnGeom(section,'section',SMESH.EDGE)
182 tige_haute_1 = coupe_vis_1.GroupOnGeom(tige_haute,'tige_haute',SMESH.EDGE)
183 rond_1 = coupe_vis_1.GroupOnGeom(rond,'rond',SMESH.EDGE)
184 tete_1 = coupe_vis_1.GroupOnGeom(tete,'tete',SMESH.EDGE)
185 section_tete_1 = coupe_vis_1.GroupOnGeom(section_tete,'section_tete',SMESH.EDGE)
186 conge_1 = coupe_vis_1.GroupOnGeom(conge,'conge',SMESH.EDGE)
187 appui_1 = coupe_vis_1.GroupOnGeom(appui,'appui',SMESH.EDGE)
188 p_imp_1 = coupe_vis_1.GroupOnGeom(p_imp,'p_imp',SMESH.EDGE)
189 visHex80 = smesh.CopyMesh( coupe_vis_1, 'visHex80', 1, 0)
190 [ tige_2, section_2, tige_haute_2, rond_2, tete_2, section_tete_2, conge_2, appui_2, p_imp_2 ] = visHex80.GetGroups()
191 [ tige_rotated, section_rotated, tige_haute_rotated, rond_rotated, tete_rotated, section_tete_rotated, conge_rotated, appui_rotated, p_imp_rotated, tige_top, section_top, tige_haute_top, rond_top, tete_top, section_tete_top, conge_top, appui_top, p_imp_top ] = visHex80.RotationSweepObjects( [ visHex80 ], [ visHex80 ], [ visHex80 ], SMESH.AxisStruct( 0, 0, 0, 0, 10, 0 ), 0.0785398, 40, 1e-05, 1 )
192 [ tige_2, section_2, tige_haute_2, rond_2, tete_2, section_tete_2, conge_2, appui_2, p_imp_2, tige_rotated, tige_top, section_rotated, section_top, tige_haute_rotated, tige_haute_top, rond_rotated, rond_top, tete_rotated, tete_top, section_tete_rotated, section_tete_top, conge_rotated, conge_top, appui_rotated, appui_top, p_imp_rotated, p_imp_top ] = visHex80.GetGroups()
193 Sub_mesh_1 = Regular_1D_1.GetSubMesh()
194 Sub_mesh_2 = Regular_1D_2.GetSubMesh()
195 visHex80.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests/visSain.med"))
196  
197
198 ## Set names of Mesh objects
199 smesh.SetName(tige_2, 'tige')
200 smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
201 smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
202 smesh.SetName(Nb_Segments_2, 'Nb. Segments_2')
203 smesh.SetName(Nb_Segments_1, 'Nb. Segments_1')
204 smesh.SetName(Nb_Segments_3, 'Nb. Segments_3')
205 smesh.SetName(coupe_vis_1.GetMesh(), 'coupe_vis')
206 smesh.SetName(visHex80.GetMesh(), 'visHex80')
207 smesh.SetName(p_imp_top, 'p_imp_top')
208 smesh.SetName(appui_top, 'appui_top')
209 smesh.SetName(conge_top, 'conge_top')
210 smesh.SetName(section_tete_top, 'section_tete_top')
211 smesh.SetName(tete_top, 'tete_top')
212 smesh.SetName(rond_top, 'rond_top')
213 smesh.SetName(tige_haute_top, 'tige_haute_top')
214 smesh.SetName(section_top, 'section_top')
215 smesh.SetName(tige_top, 'tige_top')
216 smesh.SetName(Sub_mesh_2, 'Sub-mesh_2')
217 smesh.SetName(Sub_mesh_1, 'Sub-mesh_1')
218 smesh.SetName(p_imp_1, 'p_imp')
219 smesh.SetName(p_imp_rotated, 'p_imp_rotated')
220 smesh.SetName(appui_1, 'appui')
221 smesh.SetName(appui_rotated, 'appui_rotated')
222 smesh.SetName(conge_rotated, 'conge_rotated')
223 smesh.SetName(section_tete_rotated, 'section_tete_rotated')
224 smesh.SetName(tete_rotated, 'tete_rotated')
225 smesh.SetName(rond_rotated, 'rond_rotated')
226 smesh.SetName(tige_haute_rotated, 'tige_haute_rotated')
227 smesh.SetName(section_rotated, 'section_rotated')
228 smesh.SetName(tige_1, 'tige')
229 smesh.SetName(tige_rotated, 'tige_rotated')
230 smesh.SetName(tige_haute_1, 'tige_haute')
231 smesh.SetName(section_1, 'section')
232 smesh.SetName(tete_1, 'tete')
233 smesh.SetName(rond_1, 'rond')
234 smesh.SetName(conge_1, 'conge')
235 smesh.SetName(appui_2, 'appui')
236 smesh.SetName(section_tete_1, 'section_tete')
237 smesh.SetName(p_imp_2, 'p_imp')
238 smesh.SetName(section_tete_2, 'section_tete')
239 smesh.SetName(conge_2, 'conge')
240 smesh.SetName(rond_2, 'rond')
241 smesh.SetName(tete_2, 'tete')
242 smesh.SetName(section_2, 'section')
243 smesh.SetName(tige_haute_2, 'tige_haute')
244
245
246 if salome.sg.hasDesktop():
247   salome.sg.updateObjBrowser()