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