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