Salome HOME
f5446196ec11c102315f00c57323141154311441
[modules/smesh.git] / src / Tools / blocFissure / materielCasTests / cubeAngle.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
21 """Géométries nécessaires aux cas-tests :
22 . cubeAngle
23 . cubeAngle2
24 """
25
26 import os
27
28 import logging
29
30 import salome
31 from salome.smesh import smeshBuilder
32 import GEOM
33 import SMESH
34 import SALOMEDS
35
36 from blocFissure import gmu
37 from blocFissure.gmu.geomsmesh import geompy
38 from blocFissure.gmu.geomsmesh import geomPublish
39
40 from blocFissure.gmu.triedreBase import triedreBase
41 from blocFissure.gmu.putName import putName
42 from blocFissure.gmu import initLog
43
44 #=============== Options ====================
45 # 1. NOM_OBJET = nom de l'objet
46 NOM_OBJET = "CubeAngle"
47 #============================================
48
49 ###
50 ### GEOM component
51 ###
52
53 O, OX, OY, OZ = triedreBase()
54
55 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
56 Vertex_1 = geompy.MakeVertex(0, 0, 100)
57 Disk_1 = geompy.MakeDiskPntVecR(Vertex_1, OZ, 60)
58 Vertex_2 = geompy.MakeVertex(-5, -5, 90)
59 Vertex_3 = geompy.MakeVertex(65, 65, 110)
60 Box_2 = geompy.MakeBoxTwoPnt(Vertex_3, Vertex_2)
61 Common_1 = geompy.MakeCommon(Disk_1, Box_2)
62
63 geompy.addToStudy( Box_1, NOM_OBJET )
64 geomPublish(initLog.debug, Vertex_1, 'Vertex_1' )
65 geomPublish(initLog.debug, Disk_1, 'Disk_1' )
66 geomPublish(initLog.debug, Vertex_2, 'Vertex_2' )
67 geomPublish(initLog.debug, Vertex_3, 'Vertex_3' )
68 geomPublish(initLog.debug, Box_2, 'Box_2' )
69 geompy.addToStudy( Common_1, NOM_OBJET+'_Fissure' )
70
71 ficcao = os.path.join(gmu.pathBloc, "materielCasTests", "{}Fiss.brep".format(NOM_OBJET))
72 text = ".. Exportation de la géométrie de la fissure dans le fichier '{}'".format(ficcao)
73 logging.info(text)
74 geompy.ExportBREP(Common_1, ficcao)
75
76 ###
77 ### SMESH component
78 ###
79
80 smesh = smeshBuilder.New()
81 Mesh_1 = smesh.Mesh(Box_1)
82 putName(Mesh_1, NOM_OBJET)
83
84 Regular_1D = Mesh_1.Segment()
85 Nb_Segments_1 = Regular_1D.NumberOfSegments(15)
86 Nb_Segments_1.SetDistrType( 0 )
87 Quadrangle_2D = Mesh_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
88 Hexa_3D = Mesh_1.Hexahedron(algo=smeshBuilder.Hexa)
89
90 ## set object names
91 #putName(Regular_1D.GetAlgorithm(), 'Regular_1D')
92 #putName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
93 #putName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
94 putName(Nb_Segments_1, 'Nb. Segments_1', i_pref='cubeAngle')
95
96 is_done = Mesh_1.Compute()
97 text = "Mesh_1.Compute"
98 if is_done:
99   logging.info(text+" OK")
100 else:
101   text = "Erreur au calcul du maillage.\n" + text
102   logging.info(text)
103   raise Exception(text)
104
105 ficmed = os.path.join(gmu.pathBloc, "materielCasTests","{}.med".format(NOM_OBJET))
106 text = ".. Archivage du maillage dans le fichier '{}'".format(ficmed)
107 logging.info(text)
108 Mesh_1.ExportMED(ficmed)
109
110 if salome.sg.hasDesktop():
111   salome.sg.updateObjBrowser()