Salome HOME
oubli de l'import
[modules/smesh.git] / src / Tools / blocFissure / materielCasTests / cubeFin.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 logging
22
23 import sys
24 import salome
25
26 salome.salome_init()
27
28 import salome_notebook
29
30 import os
31 from blocFissure import gmu
32
33 ###
34 ### GEOM component
35 ###
36
37 import GEOM
38 from salome.geom import geomBuilder
39 import math
40 import SALOMEDS
41
42
43 geompy = geomBuilder.New()
44
45 O = geompy.MakeVertex(0, 0, 0)
46 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
47 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
48 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
49 cubeFin = geompy.MakeBoxDXDYDZ(200, 200, 200)
50 [DEPL,ENCASTR] = geompy.SubShapes(cubeFin, [27, 23])
51 origCoin = geompy.MakeVertex(0, 160, 200)
52 Disk_1 = geompy.MakeDiskPntVecR(origCoin, OY, 50)
53 Translation_1 = geompy.MakeTranslation(origCoin, 0, 10, 0)
54 Vector_1 = geompy.MakeVector(origCoin, Translation_1)
55 Rotation_1 = geompy.MakeRotation(Disk_1, Vector_1, 90*math.pi/180.0)
56 origMilieu = geompy.MakeVertex(0, 160, 100)
57 Translation_2 = geompy.MakeTranslationTwoPoints(Rotation_1, origCoin, origMilieu)
58 Scale_1 = geompy.MakeScaleAlongAxes(Translation_2, origMilieu, 0.984, 1, 1.2)
59 Vertex_1 = geompy.MakeVertex(-10, 160, 210)
60 Vertex_2 = geompy.MakeVertex(50, 160, 210)
61 Vertex_3 = geompy.MakeVertex(50, 160, -10)
62 Vertex_4 = geompy.MakeVertex(-10, 160, -10)
63 Line_1 = geompy.MakeLineTwoPnt(Vertex_1, Vertex_2)
64 Line_2 = geompy.MakeLineTwoPnt(Vertex_2, Vertex_3)
65 Line_3 = geompy.MakeLineTwoPnt(Vertex_3, Vertex_4)
66 Line_4 = geompy.MakeLineTwoPnt(Vertex_4, Vertex_1)
67 cubeFin_Transverse = geompy.MakeFaceWires([Line_1, Line_2, Line_3, Line_4], 1)
68 Vertex_5 = geompy.MakeVertex(55, 160, 100)
69 Line_1_vertex_3 = geompy.GetSubShape(Line_1, [3])
70 Line_3_vertex_2 = geompy.GetSubShape(Line_3, [2])
71 Arc_1 = geompy.MakeArc(Line_1_vertex_3, Vertex_5, Line_3_vertex_2)
72 Face_1 = geompy.MakeFaceWires([Line_1, Line_3, Line_4, Arc_1], 1)
73 cubeFin_Coin = geompy.MakeCommonList([Rotation_1, Face_1], True)
74 cubeFin_Milieu = geompy.MakeCommonList([Scale_1, cubeFin_Transverse], True)
75 O_1 = geompy.MakeVertex(0, 0, 0)
76 OX_1 = geompy.MakeVectorDXDYDZ(1, 0, 0)
77 OY_1 = geompy.MakeVectorDXDYDZ(0, 1, 0)
78 OZ_1 = geompy.MakeVectorDXDYDZ(0, 0, 1)
79 geompy.addToStudy( O, 'O' )
80 geompy.addToStudy( OX, 'OX' )
81 geompy.addToStudy( OY, 'OY' )
82 geompy.addToStudy( OZ, 'OZ' )
83 geompy.addToStudy( cubeFin, 'cubeFin' )
84 geompy.addToStudyInFather( cubeFin, DEPL, 'DEPL' )
85 geompy.addToStudyInFather( cubeFin, ENCASTR, 'ENCASTR' )
86 geompy.addToStudy( origCoin, 'origCoin' )
87 geompy.addToStudy( Disk_1, 'Disk_1' )
88 geompy.addToStudy( Translation_1, 'Translation_1' )
89 geompy.addToStudy( Vector_1, 'Vector_1' )
90 geompy.addToStudy( Rotation_1, 'Rotation_1' )
91 geompy.addToStudy( origMilieu, 'origMilieu' )
92 geompy.addToStudy( Translation_2, 'Translation_2' )
93 geompy.addToStudy( Scale_1, 'Scale_1' )
94 geompy.addToStudy( Vertex_1, 'Vertex_1' )
95 geompy.addToStudy( Vertex_2, 'Vertex_2' )
96 geompy.addToStudy( Vertex_3, 'Vertex_3' )
97 geompy.addToStudy( Vertex_4, 'Vertex_4' )
98 geompy.addToStudy( Line_1, 'Line_1' )
99 geompy.addToStudy( Line_2, 'Line_2' )
100 geompy.addToStudy( Line_3, 'Line_3' )
101 geompy.addToStudy( Line_4, 'Line_4' )
102 geompy.addToStudy( cubeFin_Transverse, 'cubeFin_Transverse' )
103 geompy.addToStudyInFather( Line_1, Line_1_vertex_3, 'Line_1:vertex_3' )
104 geompy.addToStudy( Vertex_5, 'Vertex_5' )
105 geompy.addToStudyInFather( Line_3, Line_3_vertex_2, 'Line_3:vertex_2' )
106 geompy.addToStudy( Arc_1, 'Arc_1' )
107 geompy.addToStudy( Face_1, 'Face_1' )
108 geompy.addToStudy( cubeFin_Coin, 'cubeFin_Coin' )
109 geompy.addToStudy( cubeFin_Milieu, 'cubeFin_Milieu' )
110 geompy.addToStudy( O_1, 'O' )
111 geompy.addToStudy( OX_1, 'OX' )
112 geompy.addToStudy( OY_1, 'OY' )
113 geompy.addToStudy( OZ_1, 'OZ' )
114 geompy.ExportBREP(cubeFin_Transverse, os.path.join(gmu.pathBloc, "materielCasTests", "cubeFin_Transverse.brep"))
115 geompy.ExportBREP(cubeFin_Coin, os.path.join(gmu.pathBloc, "materielCasTests", "cubeFin_Coin.brep"))
116 geompy.ExportBREP(cubeFin_Milieu, os.path.join(gmu.pathBloc, "materielCasTests", "cubeFin_Milieu.brep"))
117
118 ###
119 ### SMESH component
120 ###
121
122 import  SMESH, SALOMEDS
123 from salome.smesh import smeshBuilder
124
125 smesh = smeshBuilder.New()
126 cubeFin_1 = smesh.Mesh(cubeFin)
127 Regular_1D = cubeFin_1.Segment()
128 Nb_Segments_1 = Regular_1D.NumberOfSegments(20)
129 Nb_Segments_1.SetDistrType( 0 )
130 Quadrangle_2D = cubeFin_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
131 Hexa_3D = cubeFin_1.Hexahedron(algo=smeshBuilder.Hexa)
132 DEPL_1 = cubeFin_1.GroupOnGeom(DEPL,'DEPL',SMESH.FACE)
133 ENCASTR_1 = cubeFin_1.GroupOnGeom(ENCASTR,'ENCASTR',SMESH.FACE)
134 is_done = cubeFin_1.Compute()
135 text = "cubeFin_1.Compute"
136 if is_done:
137   logging.info(text+" OK")
138 else:
139   text = "Erreur au calcul du maillage.\n" + text
140   logging.info(text)
141   raise Exception(text)
142 ## Set names of Mesh objects
143 smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
144 smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
145 smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
146 smesh.SetName(DEPL_1, 'DEPL')
147 smesh.SetName(ENCASTR_1, 'ENCASTR')
148 smesh.SetName(cubeFin_1.GetMesh(), 'cubeFin')
149 smesh.SetName(Nb_Segments_1, 'Nb. Segments_1')
150
151 cubeFin_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests", "cubeFin.med"))
152
153 if salome.sg.hasDesktop():
154   salome.sg.updateObjBrowser()