1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2023 EDF
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
20 """Géométries et maillages de base nécessaires aux cas-tests :
30 from salome.smesh import smeshBuilder
35 from blocFissure import gmu
36 from blocFissure.gmu.geomsmesh import geompy
37 from blocFissure.gmu.geomsmesh import geomPublish
39 from blocFissure.gmu.triedreBase import triedreBase
40 from blocFissure.gmu.putName import putName
41 from blocFissure.gmu import initLog
43 #=============== Options ====================
44 # 1. NOM_OBJET = nom de l'objet
45 NOM_OBJET = "CubeAngle"
46 #============================================
52 O, OX, OY, OZ = triedreBase()
54 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
55 Vertex_1 = geompy.MakeVertex(0, 0, 100)
56 Disk_1 = geompy.MakeDiskPntVecR(Vertex_1, OZ, 60)
57 Vertex_2 = geompy.MakeVertex(-5, -5, 90)
58 Vertex_3 = geompy.MakeVertex(65, 65, 110)
59 Box_2 = geompy.MakeBoxTwoPnt(Vertex_3, Vertex_2)
60 Common_1 = geompy.MakeCommon(Disk_1, Box_2)
62 geompy.addToStudy( Box_1, NOM_OBJET )
63 geomPublish(initLog.debug, Vertex_1, 'Vertex_1' )
64 geomPublish(initLog.debug, Disk_1, 'Disk_1' )
65 geomPublish(initLog.debug, Vertex_2, 'Vertex_2' )
66 geomPublish(initLog.debug, Vertex_3, 'Vertex_3' )
67 geomPublish(initLog.debug, Box_2, 'Box_2' )
68 geompy.addToStudy( Common_1, NOM_OBJET+'_Fissure' )
70 ficcao = os.path.join(gmu.pathBloc, "materielCasTests", "{}Fiss.brep".format(NOM_OBJET))
71 text = ".. Exportation de la géométrie de la fissure dans le fichier '{}'".format(ficcao)
73 geompy.ExportBREP(Common_1, ficcao)
79 smesh = smeshBuilder.New()
80 Mesh_1 = smesh.Mesh(Box_1)
81 putName(Mesh_1, NOM_OBJET)
83 Regular_1D = Mesh_1.Segment()
84 Nb_Segments_1 = Regular_1D.NumberOfSegments(15)
85 Nb_Segments_1.SetDistrType( 0 )
86 Quadrangle_2D = Mesh_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
87 Hexa_3D = Mesh_1.Hexahedron(algo=smeshBuilder.Hexa)
90 #putName(Regular_1D.GetAlgorithm(), 'Regular_1D')
91 #putName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
92 #putName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
93 putName(Nb_Segments_1, 'Nb. Segments_1', i_pref='cubeAngle')
95 is_done = Mesh_1.Compute()
96 text = "Mesh_1.Compute"
98 logging.info(text+" OK")
100 text = "Erreur au calcul du maillage.\n" + text
102 raise Exception(text)
104 ficmed = os.path.join(gmu.pathBloc, "materielCasTests","{}.med".format(NOM_OBJET))
105 text = ".. Archivage du maillage dans le fichier '{}'".format(ficmed)
107 Mesh_1.ExportMED(ficmed)
109 if salome.sg.hasDesktop():
110 salome.sg.updateObjBrowser()