Salome HOME
Affichage
[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 """Géométries et maillages de base nécessaires aux cas-tests :
21 . cubeAngle
22 . cubeAngle2
23 """
24
25 import os
26
27 import logging
28
29 import salome
30 from salome.smesh import smeshBuilder
31 import GEOM
32 import SMESH
33 import SALOMEDS
34
35 from blocFissure import gmu
36 from blocFissure.gmu.geomsmesh import geompy
37 from blocFissure.gmu.geomsmesh import geomPublish
38
39 from blocFissure.gmu.triedreBase import triedreBase
40 from blocFissure.gmu.putName import putName
41 from blocFissure.gmu import initLog
42
43 #=============== Options ====================
44 # 1. NOM_OBJET = nom de l'objet
45 NOM_OBJET = "CubeAngle"
46 #============================================
47
48 ###
49 ### GEOM component
50 ###
51
52 O, OX, OY, OZ = triedreBase()
53
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)
61
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' )
69
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)
72 logging.info(text)
73 geompy.ExportBREP(Common_1, ficcao)
74
75 ###
76 ### SMESH component
77 ###
78
79 smesh = smeshBuilder.New()
80 Mesh_1 = smesh.Mesh(Box_1)
81 putName(Mesh_1, NOM_OBJET)
82
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)
88
89 ## set object names
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')
94
95 is_done = Mesh_1.Compute()
96 text = "Mesh_1.Compute"
97 if is_done:
98   logging.info(text+" OK")
99 else:
100   text = "Erreur au calcul du maillage.\n" + text
101   logging.info(text)
102   raise Exception(text)
103
104 ficmed = os.path.join(gmu.pathBloc, "materielCasTests","{}.med".format(NOM_OBJET))
105 text = ".. Archivage du maillage dans le fichier '{}'".format(ficmed)
106 logging.info(text)
107 Mesh_1.ExportMED(ficmed)
108
109 if salome.sg.hasDesktop():
110   salome.sg.updateObjBrowser()