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 """Géométries nécessaires aux cas-tests :
31 from salome.smesh import smeshBuilder
36 from blocFissure import gmu
37 from blocFissure.gmu.geomsmesh import geompy
38 from blocFissure.gmu.geomsmesh import geomPublish
40 from blocFissure.gmu.triedreBase import triedreBase
41 from blocFissure.gmu.putName import putName
42 from blocFissure.gmu import initLog
44 #=============== Options ====================
45 # 1. NOM_OBJET = nom de l'objet
46 NOM_OBJET = "CubeAngle"
47 #============================================
53 O, OX, OY, OZ = triedreBase()
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)
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' )
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)
74 geompy.ExportBREP(Common_1, ficcao)
80 smesh = smeshBuilder.New()
81 Mesh_1 = smesh.Mesh(Box_1)
82 putName(Mesh_1, NOM_OBJET)
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)
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')
96 is_done = Mesh_1.Compute()
97 text = "Mesh_1.Compute"
99 logging.info(text+" OK")
101 text = "Erreur au calcul du maillage.\n" + text
103 raise Exception(text)
105 ficmed = os.path.join(gmu.pathBloc, "materielCasTests","{}.med".format(NOM_OBJET))
106 text = ".. Archivage du maillage dans le fichier '{}'".format(ficmed)
108 Mesh_1.ExportMED(ficmed)
110 if salome.sg.hasDesktop():
111 salome.sg.updateObjBrowser()