1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2021 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 """Cas-test de blocFissure pour un cube"""
26 from blocFissure import gmu
30 from salome.geom import geomBuilder
32 from salome.smesh import smeshBuilder
34 #=============== Options ====================
35 # 1. NOM_OBJET = nom de l'objet
36 NOM_OBJET = "CubeAngle"
37 #============================================
45 geompy = geomBuilder.New()
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)
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 )
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)
68 geompy.ExportBREP(Common_1, ficcao)
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)
84 is_done = Mesh_1.Compute()
85 text = "Mesh_1.Compute"
87 logging.info(text+" OK")
89 text = "Erreur au calcul du maillage.\n" + text
93 ficmed = os.path.join(gmu.pathBloc, "materielCasTests","{}.med".format(NOM_OBJET))
94 text = ".. Archivage du maillage dans le fichier '{}'".format(ficmed)
96 Mesh_1.ExportMED(ficmed)
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')
104 if salome.sg.hasDesktop():
105 salome.sg.updateObjBrowser()