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