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