Salome HOME
Copyright update 2021
[modules/smesh.git] / src / Tools / blocFissure / materielCasTests / vis.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2021  EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 import sys
22 import salome
23
24 salome.salome_init()
25
26 import salome_notebook
27 notebook = salome_notebook.notebook
28
29 import os
30 from blocFissure import gmu
31
32 ###
33 ### GEOM component
34 ###
35
36 import GEOM
37 from salome.geom import geomBuilder
38 import math
39 import SALOMEDS
40
41
42 geompy = geomBuilder.New()
43 O = geompy.MakeVertex(0, 0, 0)
44 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
45 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
46 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
47 geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
48 geomObj_2 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
49 sk = geompy.Sketcher2D()
50 sk.addPoint(0.000000, 0.000000)
51 sk.addSegmentAbsolute(10.000000, 0.000000)
52 sk.addSegmentAbsolute(10.000000, 98.750000)
53 sk.addArcAngleRadiusLength(0, -1.250000, 90.000000)
54 sk.addSegmentAbsolute(15.000000, 100.000000)
55 sk.addSegmentAbsolute(15.000000, 120.000000)
56 sk.addSegmentAbsolute(9.945000, 120.000000)
57 sk.addSegmentAbsolute(9.945000, 108.000000)
58 sk.addSegmentAbsolute(0.000000, 105.000000)
59 sk.close()
60 Sketch_1 = sk.wire(geomObj_2)
61 Face_1 = geompy.MakeFaceWires([Sketch_1], 1)
62 Vertex_1 = geompy.MakeVertex(15, 108, 0)
63 Vertex_2 = geompy.MakeVertex(0, 94, 0)
64 Vertex_3 = geompy.MakeVertex(10, 94, 0)
65 Face_1_vertex_17 = geompy.GetSubShape(Face_1, [17])
66 Line_1 = geompy.MakeLineTwoPnt(Vertex_1, Face_1_vertex_17)
67 Face_1_vertex_9 = geompy.GetSubShape(Face_1, [9])
68 Line_2 = geompy.MakeLineTwoPnt(Face_1_vertex_17, Face_1_vertex_9)
69 Face_1_vertex_19 = geompy.GetSubShape(Face_1, [19])
70 Face_1_vertex_7 = geompy.GetSubShape(Face_1, [7])
71 Line_3 = geompy.MakeLineTwoPnt(Face_1_vertex_19, Face_1_vertex_7)
72 Line_4 = geompy.MakeLineTwoPnt(Vertex_2, Vertex_3)
73 coupe_vis = geompy.MakePartition([Face_1], [Line_1, Line_2, Line_3, Line_4], [], [], geompy.ShapeType["FACE"], 0, [], 0)
74 [tige, section, tige_haute, rond, tete, section_tete] = geompy.Propagate(coupe_vis)
75 conge = geompy.CreateGroup(coupe_vis, geompy.ShapeType["EDGE"])
76 geompy.UnionIDs(conge, [25])
77 appui = geompy.CreateGroup(coupe_vis, geompy.ShapeType["EDGE"])
78 geompy.UnionIDs(appui, [39])
79 p_imp = geompy.CreateGroup(coupe_vis, geompy.ShapeType["EDGE"])
80 geompy.UnionIDs(p_imp, [11])
81
82 Vertex_4 = geompy.MakeVertex(11.25, 98.75, 0)
83 Vertex_5 = geompy.MakeVertexWithRef(Vertex_4, -0.5, 0.5, 0)
84 Vertex_6 = geompy.MakeVertexWithRef(Vertex_4, -5, 5, 0)
85 Line_5 = geompy.MakeLineTwoPnt(Vertex_5, Vertex_6)
86 Partition_1 = geompy.MakePartition([Line_5], [conge], [], [], geompy.ShapeType["EDGE"], 0, [], 1)
87 [Vertex_7] = geompy.SubShapes(Partition_1, [4])
88 Vertex_8 = geompy.MakeVertexWithRef(Vertex_7, -1.1, 1.1, 0)
89 generatrice = geompy.MakeLineTwoPnt(Vertex_5, Vertex_8)
90 Revolution_1 = geompy.MakeRevolution2Ways(generatrice, OY, 60*math.pi/180.0)
91 Partition_2 = geompy.MakePartition([Revolution_1], [conge], [], [], geompy.ShapeType["FACE"], 0, [], 1)
92 Partition_2_vertex_11 = geompy.GetSubShape(Partition_2, [11])
93 Plane_1 = geompy.MakePlane(Partition_2_vertex_11, OY, 2000)
94 Partition_3 = geompy.MakePartition([Revolution_1], [Plane_1], [], [], geompy.ShapeType["FACE"], 0, [], 0)
95 Vertex_9 = geompy.MakeVertex(0, 99.633883, 1.977320000000001)
96 Vertex_10 = geompy.MakeVertex(0, 99.633883, -8.977320000000001)
97 Vertex_11 = geompy.MakeVertexWithRef(Vertex_9, 0, 0, -1)
98 Vertex11x = geompy.MakeVertexWithRef(Vertex_11, 1, 0, 0)
99 Line_11x = geompy.MakeLineTwoPnt(Vertex_11, Vertex11x)
100 Vertex_12 = geompy.MakeVertexWithRef(Vertex_10, 0, 0, 1)
101 Vertex12x = geompy.MakeVertexWithRef(Vertex_12, 1, 0, 0)
102 Line_12x = geompy.MakeLineTwoPnt(Vertex_12, Vertex12x)
103 Vertex_13 = geompy.MakeVertexWithRef(Vertex_11, 0, 1, 0)
104 Vertex_14 = geompy.MakeVertexWithRef(Vertex_12, 0, 1, 0)
105 Vertex_15 = geompy.MakeRotation(Vertex_9, Line_11x, 30*math.pi/180.0)
106 Vertex_16 = geompy.MakeRotation(Vertex_10, Line_12x, -30*math.pi/180.0)
107 Arc_1 = geompy.MakeArc(Vertex_15, Vertex_9, Vertex_13,False)
108 Arc_2 = geompy.MakeArc(Vertex_14, Vertex_10, Vertex_16,False)
109 Line_6 = geompy.MakeLineTwoPnt(Vertex_13, Vertex_14)
110 Line_8 = geompy.MakeLineTwoPnt(Vertex_16, Vertex_15)
111 Wire_1 = geompy.MakeWire([Arc_1, Arc_2, Line_6, Line_8], 1e-07)
112 Face_2 = geompy.MakeFaceWires([Wire_1], 1)
113 Extrusion_1 = geompy.MakePrismVecH(Face_2, OX, 15)
114 Revolution_2 = geompy.MakeRevolution2Ways(generatrice, OY, 65*math.pi/180.0)
115 Fissure = geompy.MakeCommonList([Extrusion_1, Revolution_2], True)
116 fondFiss = geompy.CreateGroup(Fissure, geompy.ShapeType["EDGE"])
117 geompy.UnionIDs(fondFiss, [9, 7, 4])
118 geompy.ExportBREP(Fissure, os.path.join(gmu.pathBloc, "materielCasTests/visFiss.brep"))
119
120 geompy.addToStudy( O, 'O' )
121 geompy.addToStudy( OX, 'OX' )
122 geompy.addToStudy( OY, 'OY' )
123 geompy.addToStudy( OZ, 'OZ' )
124 geompy.addToStudy( Sketch_1, 'Sketch_1' )
125 geompy.addToStudy( Face_1, 'Face_1' )
126 geompy.addToStudy( Vertex_1, 'Vertex_1' )
127 geompy.addToStudy( Vertex_2, 'Vertex_2' )
128 geompy.addToStudy( Vertex_3, 'Vertex_3' )
129 geompy.addToStudyInFather( Face_1, Face_1_vertex_17, 'Face_1:vertex_17' )
130 geompy.addToStudy( Line_1, 'Line_1' )
131 geompy.addToStudyInFather( Face_1, Face_1_vertex_9, 'Face_1:vertex_9' )
132 geompy.addToStudy( Line_2, 'Line_2' )
133 geompy.addToStudyInFather( Face_1, Face_1_vertex_19, 'Face_1:vertex_19' )
134 geompy.addToStudyInFather( Face_1, Face_1_vertex_7, 'Face_1:vertex_7' )
135 geompy.addToStudy( Line_3, 'Line_3' )
136 geompy.addToStudy( Line_4, 'Line_4' )
137 geompy.addToStudy( coupe_vis, 'coupe_vis' )
138 geompy.addToStudyInFather( coupe_vis, tige, 'tige' )
139 geompy.addToStudyInFather( coupe_vis, section, 'section' )
140 geompy.addToStudyInFather( coupe_vis, tige_haute, 'tige_haute' )
141 geompy.addToStudyInFather( coupe_vis, rond, 'rond' )
142 geompy.addToStudyInFather( coupe_vis, tete, 'tete' )
143 geompy.addToStudyInFather( coupe_vis, section_tete, 'section_tete' )
144 geompy.addToStudyInFather( coupe_vis, conge, 'conge' )
145 geompy.addToStudyInFather( coupe_vis, appui, 'appui' )
146 geompy.addToStudyInFather( coupe_vis, p_imp, 'p_imp' )
147
148 geompy.addToStudy( Vertex_4, 'Vertex_4' )
149 geompy.addToStudy( Vertex_6, 'Vertex_6' )
150 geompy.addToStudy( Vertex_5, 'Vertex_5' )
151 geompy.addToStudy( Line_5, 'Line_5' )
152 geompy.addToStudy( Partition_1, 'Partition_1' )
153 geompy.addToStudyInFather( Partition_1, Vertex_7, 'Vertex_7' )
154 geompy.addToStudy( Vertex_8, 'Vertex_8' )
155 geompy.addToStudy( generatrice, 'generatrice' )
156 geompy.addToStudy( Revolution_1, 'Revolution_1' )
157 geompy.addToStudy( Partition_2, 'Partition_2' )
158 geompy.addToStudyInFather( Partition_2, Partition_2_vertex_11, 'Partition_2:vertex_11' )
159 geompy.addToStudy( Plane_1, 'Plane_1' )
160 geompy.addToStudy( Partition_3, 'Partition_3' )
161 geompy.addToStudy( Vertex_9, 'Vertex_9' )
162 geompy.addToStudy( Vertex_10, 'Vertex_10' )
163 geompy.addToStudy( Vertex_11, 'Vertex_11' )
164 geompy.addToStudy( Vertex_12, 'Vertex_12' )
165 geompy.addToStudy( Vertex_13, 'Vertex_13' )
166 geompy.addToStudy( Vertex_14, 'Vertex_14' )
167 geompy.addToStudy( Vertex_15, 'Vertex_15' )
168 geompy.addToStudy( Vertex_16, 'Vertex_16' )
169 geompy.addToStudy( Arc_1, 'Arc_1' )
170 geompy.addToStudy( Arc_2, 'Arc_2' )
171 geompy.addToStudy( Line_6, 'Line_6' )
172 geompy.addToStudy( Line_8, 'Line_8' )
173 geompy.addToStudy( Wire_1, 'Wire_1' )
174 geompy.addToStudy( Face_2, 'Face_2' )
175 geompy.addToStudy( Extrusion_1, 'Extrusion_1' )
176 geompy.addToStudy( Revolution_2, 'Revolution_2' )
177 geompy.addToStudy( Fissure, 'Fissure' )
178 geompy.addToStudyInFather( Fissure, fondFiss, 'fondFiss' )
179
180 ###
181 ### SMESH component
182 ###
183
184 import  SMESH, SALOMEDS
185 from salome.smesh import smeshBuilder
186
187 smesh = smeshBuilder.New()
188 coupe_vis_1 = smesh.Mesh(coupe_vis)
189 Regular_1D = coupe_vis_1.Segment()
190 Nb_Segments_1 = Regular_1D.NumberOfSegments(10)
191 Quadrangle_2D = coupe_vis_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
192 Regular_1D_1 = coupe_vis_1.Segment(geom=tige)
193 Nb_Segments_2 = Regular_1D_1.NumberOfSegments(30)
194 Regular_1D_2 = coupe_vis_1.Segment(geom=section)
195 Nb_Segments_3 = Regular_1D_2.NumberOfSegments(10,1,[ 7, 11, 16, 23 ])
196 isDone = coupe_vis_1.Compute()
197 isDone = coupe_vis_1.SplitQuad( [ 691 ], 1 )
198 tige_1 = coupe_vis_1.GroupOnGeom(tige,'tige',SMESH.EDGE)
199 section_1 = coupe_vis_1.GroupOnGeom(section,'section',SMESH.EDGE)
200 tige_haute_1 = coupe_vis_1.GroupOnGeom(tige_haute,'tige_haute',SMESH.EDGE)
201 rond_1 = coupe_vis_1.GroupOnGeom(rond,'rond',SMESH.EDGE)
202 tete_1 = coupe_vis_1.GroupOnGeom(tete,'tete',SMESH.EDGE)
203 section_tete_1 = coupe_vis_1.GroupOnGeom(section_tete,'section_tete',SMESH.EDGE)
204 conge_1 = coupe_vis_1.GroupOnGeom(conge,'conge',SMESH.EDGE)
205 appui_1 = coupe_vis_1.GroupOnGeom(appui,'appui',SMESH.EDGE)
206 p_imp_1 = coupe_vis_1.GroupOnGeom(p_imp,'p_imp',SMESH.EDGE)
207 visHex80 = smesh.CopyMesh( coupe_vis_1, 'visHex80', 1, 0)
208 [ tige_2, section_2, tige_haute_2, rond_2, tete_2, section_tete_2, conge_2, appui_2, p_imp_2 ] = visHex80.GetGroups()
209 [ 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 )
210 [ 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()
211 Sub_mesh_1 = Regular_1D_1.GetSubMesh()
212 Sub_mesh_2 = Regular_1D_2.GetSubMesh()
213 visHex80.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests/visSain.med"))
214  
215
216 ## Set names of Mesh objects
217 smesh.SetName(tige_2, 'tige')
218 smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
219 smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
220 smesh.SetName(Nb_Segments_2, 'Nb. Segments_2')
221 smesh.SetName(Nb_Segments_1, 'Nb. Segments_1')
222 smesh.SetName(Nb_Segments_3, 'Nb. Segments_3')
223 smesh.SetName(coupe_vis_1.GetMesh(), 'coupe_vis')
224 smesh.SetName(visHex80.GetMesh(), 'visHex80')
225 smesh.SetName(p_imp_top, 'p_imp_top')
226 smesh.SetName(appui_top, 'appui_top')
227 smesh.SetName(conge_top, 'conge_top')
228 smesh.SetName(section_tete_top, 'section_tete_top')
229 smesh.SetName(tete_top, 'tete_top')
230 smesh.SetName(rond_top, 'rond_top')
231 smesh.SetName(tige_haute_top, 'tige_haute_top')
232 smesh.SetName(section_top, 'section_top')
233 smesh.SetName(tige_top, 'tige_top')
234 smesh.SetName(Sub_mesh_2, 'Sub-mesh_2')
235 smesh.SetName(Sub_mesh_1, 'Sub-mesh_1')
236 smesh.SetName(p_imp_1, 'p_imp')
237 smesh.SetName(p_imp_rotated, 'p_imp_rotated')
238 smesh.SetName(appui_1, 'appui')
239 smesh.SetName(appui_rotated, 'appui_rotated')
240 smesh.SetName(conge_rotated, 'conge_rotated')
241 smesh.SetName(section_tete_rotated, 'section_tete_rotated')
242 smesh.SetName(tete_rotated, 'tete_rotated')
243 smesh.SetName(rond_rotated, 'rond_rotated')
244 smesh.SetName(tige_haute_rotated, 'tige_haute_rotated')
245 smesh.SetName(section_rotated, 'section_rotated')
246 smesh.SetName(tige_1, 'tige')
247 smesh.SetName(tige_rotated, 'tige_rotated')
248 smesh.SetName(tige_haute_1, 'tige_haute')
249 smesh.SetName(section_1, 'section')
250 smesh.SetName(tete_1, 'tete')
251 smesh.SetName(rond_1, 'rond')
252 smesh.SetName(conge_1, 'conge')
253 smesh.SetName(appui_2, 'appui')
254 smesh.SetName(section_tete_1, 'section_tete')
255 smesh.SetName(p_imp_2, 'p_imp')
256 smesh.SetName(section_tete_2, 'section_tete')
257 smesh.SetName(conge_2, 'conge')
258 smesh.SetName(rond_2, 'rond')
259 smesh.SetName(tete_2, 'tete')
260 smesh.SetName(section_2, 'section')
261 smesh.SetName(tige_haute_2, 'tige_haute')
262
263
264 if salome.sg.hasDesktop():
265   salome.sg.updateObjBrowser()