Salome HOME
Copyright update 2020
[modules/smesh.git] / src / Tools / blocFissure / materielCasTests / decoupeCylindre.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020  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
44 O = geompy.MakeVertex(0, 0, 0)
45 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
46 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
47 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
48 O_1 = geompy.MakeVertex(0, 0, 0)
49 OX_1 = geompy.MakeVectorDXDYDZ(1, 0, 0)
50 OY_1 = geompy.MakeVectorDXDYDZ(0, 1, 0)
51 OZ_1 = geompy.MakeVectorDXDYDZ(0, 0, 1)
52 Vertex_1 = geompy.MakeVertex(0, 0, 500)
53 Vertex_2 = geompy.MakeVertex(100, 0, 500)
54 Vertex_3 = geompy.MakeVertex(110, 0, 500)
55 Vertex_4 = geompy.MakeVertex(117.071068, -2.928932, 500)
56 Vertex_5 = geompy.MakeVertex(120, -10, 500)
57 Vertex_6 = geompy.MakeVertex(120, -30, 500)
58 Vertex_7 = geompy.MakeVertex(122.928932, -37.071068, 500)
59 Vertex_8 = geompy.MakeVertex(130, -40, 500)
60 Vertex_9 = geompy.MakeVertex(135, -40, 500)
61 Vertex_10 = geompy.MakeVertex(160, -40, 500)
62 Plane_1 = geompy.MakePlaneLCS(None, 2000, 2)
63 Mirror_1_1 = geompy.MakeMirrorByPlane(Vertex_2, Plane_1)
64 Mirror_1_2 = geompy.MakeMirrorByPlane(Vertex_3, Plane_1)
65 Mirror_1_3 = geompy.MakeMirrorByPlane(Vertex_4, Plane_1)
66 Mirror_1_4 = geompy.MakeMirrorByPlane(Vertex_5, Plane_1)
67 Mirror_1_5 = geompy.MakeMirrorByPlane(Vertex_6, Plane_1)
68 Mirror_1_6 = geompy.MakeMirrorByPlane(Vertex_7, Plane_1)
69 Mirror_1_7 = geompy.MakeMirrorByPlane(Vertex_8, Plane_1)
70 Mirror_1_8 = geompy.MakeMirrorByPlane(Vertex_9, Plane_1)
71 Mirror_1_9 = geompy.MakeMirrorByPlane(Vertex_10, Plane_1)
72 Curve_2 = geompy.MakeInterpol([Mirror_1_9, Mirror_1_8, Mirror_1_7, Mirror_1_6, Mirror_1_5, Mirror_1_4, Mirror_1_3, Mirror_1_2, Mirror_1_1, Vertex_1, Vertex_2, Vertex_3, Vertex_4, Vertex_5, Vertex_6, Vertex_7, Vertex_8, Vertex_9, Vertex_10], False, False)
73 Circle_1 = geompy.MakeCircle(Vertex_1, None, 145)
74 Vertex_11 = geompy.MakeVertex(0, -165, 500)
75 Curve_2_vertex_2 = geompy.GetSubShape(Curve_2, [2])
76 Curve_2_vertex_3 = geompy.GetSubShape(Curve_2, [3])
77 Arc_1 = geompy.MakeArc(Curve_2_vertex_2, Vertex_11, Curve_2_vertex_3)
78 FissInCylindre = geompy.MakeFaceWires([Curve_2, Arc_1], 1)
79 Divided_Cylinder_1 = geompy.MakeDividedCylinder(145, 800, GEOM.SQUARE)
80 CylindreSain = geompy.MakeRotation(Divided_Cylinder_1, OZ, 45*math.pi/180.0)
81 [Compound_1, vertical, radial, Compound_4] = geompy.Propagate(CylindreSain)
82 geompy.ExportBREP(FissInCylindre, os.path.join(gmu.pathBloc, "materielCasTests/FissInCylindre.brep"))
83 Vertex_12 = geompy.MakeVertex(0, -145, 500)
84 Circle_2 = geompy.MakeCircle(Vertex_12, None, 145)
85 Face_1 = geompy.MakeFaceWires([Circle_2], 1)
86 Vertex_13 = geompy.MakeVertex(0, 0, 500)
87 Disk_1 = geompy.MakeDiskPntVecR(Vertex_13, OZ_1, 170)
88 FissInCylindre2 = geompy.MakeCommon(Face_1, Disk_1)
89 geompy.ExportBREP(FissInCylindre2, os.path.join(gmu.pathBloc, "materielCasTests/FissInCylindre2.brep"))
90 geompy.addToStudy( O, 'O' )
91 geompy.addToStudy( OX, 'OX' )
92 geompy.addToStudy( OY, 'OY' )
93 geompy.addToStudy( OZ, 'OZ' )
94 geompy.addToStudy( O_1, 'O' )
95 geompy.addToStudy( OX_1, 'OX' )
96 geompy.addToStudy( OY_1, 'OY' )
97 geompy.addToStudy( OZ_1, 'OZ' )
98 geompy.addToStudy( Vertex_1, 'Vertex_1' )
99 geompy.addToStudy( Vertex_2, 'Vertex_2' )
100 geompy.addToStudy( Vertex_3, 'Vertex_3' )
101 geompy.addToStudy( Vertex_4, 'Vertex_4' )
102 geompy.addToStudy( Vertex_5, 'Vertex_5' )
103 geompy.addToStudy( Vertex_6, 'Vertex_6' )
104 geompy.addToStudy( Vertex_7, 'Vertex_7' )
105 geompy.addToStudy( Vertex_8, 'Vertex_8' )
106 geompy.addToStudy( Vertex_9, 'Vertex_9' )
107 geompy.addToStudy( Vertex_10, 'Vertex_10' )
108 geompy.addToStudy( Plane_1, 'Plane_1' )
109 geompy.addToStudy( Mirror_1_1, 'Mirror_1_1' )
110 geompy.addToStudy( Mirror_1_2, 'Mirror_1_2' )
111 geompy.addToStudy( Mirror_1_3, 'Mirror_1_3' )
112 geompy.addToStudy( Mirror_1_4, 'Mirror_1_4' )
113 geompy.addToStudy( Mirror_1_5, 'Mirror_1_5' )
114 geompy.addToStudy( Mirror_1_6, 'Mirror_1_6' )
115 geompy.addToStudy( Mirror_1_7, 'Mirror_1_7' )
116 geompy.addToStudy( Mirror_1_8, 'Mirror_1_8' )
117 geompy.addToStudy( Mirror_1_9, 'Mirror_1_9' )
118 geompy.addToStudy( Curve_2, 'Curve_2' )
119 geompy.addToStudy( Circle_1, 'Circle_1' )
120 geompy.addToStudy( Vertex_11, 'Vertex_11' )
121 geompy.addToStudyInFather( Curve_2, Curve_2_vertex_2, 'Curve_2:vertex_2' )
122 geompy.addToStudyInFather( Curve_2, Curve_2_vertex_3, 'Curve_2:vertex_3' )
123 geompy.addToStudy( Arc_1, 'Arc_1' )
124 geompy.addToStudy( FissInCylindre, 'FissInCylindre' )
125 geompy.addToStudy( Divided_Cylinder_1, 'Divided Cylinder_1' )
126 geompy.addToStudy( CylindreSain, 'CylindreSain' )
127 geompy.addToStudyInFather( CylindreSain, Compound_1, 'Compound_1' )
128 geompy.addToStudyInFather( CylindreSain, vertical, 'vertical' )
129 geompy.addToStudyInFather( CylindreSain, radial, 'radial' )
130 geompy.addToStudyInFather( CylindreSain, Compound_4, 'Compound_4' )
131 geompy.addToStudy( Vertex_12, 'Vertex_12' )
132 geompy.addToStudy( Circle_2, 'Circle_2' )
133 geompy.addToStudy( Face_1, 'Face_1' )
134 geompy.addToStudy( Vertex_13, 'Vertex_13' )
135 geompy.addToStudy( Disk_1, 'Disk_1' )
136 geompy.addToStudy( FissInCylindre2, 'FissInCylindre2' )
137
138 ###
139 ### SMESH component
140 ###
141
142 import  SMESH, SALOMEDS
143 from salome.smesh import smeshBuilder
144
145 smesh = smeshBuilder.New()
146 from salome.StdMeshers import StdMeshersBuilder
147 smeshObj_1 = smesh.CreateHypothesis('NumberOfSegments')
148 smeshObj_1.SetNumberOfSegments( 5 )
149 smeshObj_1.SetDistrType( 0 )
150 CylindreSain_1 = smesh.Mesh(CylindreSain)
151 Regular_1D = CylindreSain_1.Segment()
152 Nb_Segments_1 = Regular_1D.NumberOfSegments(15,[],[  ])
153 Nb_Segments_1.SetDistrType( 0 )
154 Quadrangle_2D = CylindreSain_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
155 Hexa_3D = CylindreSain_1.Hexahedron(algo=smeshBuilder.Hexa)
156 Regular_1D_1 = CylindreSain_1.Segment(geom=vertical)
157 Nb_Segments_2 = Regular_1D_1.NumberOfSegments(30,[],[  ])
158 Nb_Segments_2.SetDistrType( 0 )
159 Regular_1D_2 = CylindreSain_1.Segment(geom=radial)
160 Nb_Segments_3 = Regular_1D_2.NumberOfSegments(6,[],[  ])
161 Nb_Segments_3.SetDistrType( 0 )
162 isDone = CylindreSain_1.Compute()
163 smesh.SetName(CylindreSain_1, 'CylindreSain')
164 CylindreSain_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests//CylindreSain.med"))
165 SubMesh_1 = Regular_1D_1.GetSubMesh()
166 SubMesh_2 = Regular_1D_2.GetSubMesh()
167
168 ## some objects were removed
169 aStudyBuilder = salome.myStudy.NewBuilder()
170 SO = salome.myStudy.FindObjectIOR(salome.myStudy.ConvertObjectToIOR(smeshObj_1))
171 if SO is not None: aStudyBuilder.RemoveObjectWithChildren(SO)
172 ## set object names
173 smesh.SetName(CylindreSain_1.GetMesh(), 'CylindreSain')
174 smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
175 smesh.SetName(Nb_Segments_1, 'Nb. Segments_1')
176 smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
177 smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
178 smesh.SetName(Nb_Segments_2, 'Nb. Segments_2')
179 smesh.SetName(Nb_Segments_3, 'Nb. Segments_3')
180 smesh.SetName(SubMesh_1, 'SubMesh_1')
181 smesh.SetName(SubMesh_2, 'SubMesh_2')
182
183 if salome.sg.hasDesktop():
184   salome.sg.updateObjBrowser()