Salome HOME
bos #24228 [CEA 24217][Windows] cannot compile SMESH: additional fix.
[modules/smesh.git] / src / Tools / blocFissure / materielCasTests / disque_perce.py
1 # -*- coding: iso-8859-1 -*-
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étrie et maillage de base nécessaire au cas-test :
21 . disque_perce
22 """
23
24 import os
25
26 import logging
27
28 import salome
29 from salome.smesh import smeshBuilder
30 from salome.StdMeshers import StdMeshersBuilder
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 from blocFissure.gmu.geomsmesh import geomPublishInFather
39
40 from blocFissure.gmu.triedreBase import triedreBase
41 from blocFissure.gmu.putName import putName
42 from blocFissure.gmu import initLog
43
44 ###
45 ### GEOM component
46 ###
47
48 O, OX, OY, OZ = triedreBase()
49
50 Cylinder_1 = geompy.MakeCylinderRH(100, 300)
51 Cylinder_2 = geompy.MakeCylinderRH(600, 200)
52 Cut_1 = geompy.MakeCut(Cylinder_2, Cylinder_1)
53 Face_1 = geompy.MakeFaceHW(500, 1500, 3)
54 Disque = geompy.MakePartition([Cut_1], [Face_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
55 [Compound_1, Compound_2, Compound_3, Compound_4] = geompy.Propagate(Disque)
56 geompy.addToStudy( Disque, 'Disque' )
57 geompy.addToStudyInFather( Disque, Compound_1, 'Compound_1' )
58 geompy.addToStudyInFather( Disque, Compound_2, 'Compound_2' )
59 geompy.addToStudyInFather( Disque, Compound_3, 'Compound_3' )
60 geompy.addToStudyInFather( Disque, Compound_4, 'Compound_4' )
61
62 geomPublish(initLog.debug, Cylinder_1, 'Cylinder_1' )
63 geomPublish(initLog.debug, Cylinder_2, 'Cylinder_2' )
64 geomPublish(initLog.debug, Cut_1, 'Cut_1' )
65 geomPublish(initLog.debug, Face_1, 'Face_1' )
66
67 ###
68 ### SMESH component
69 ###
70
71 smesh = smeshBuilder.New()
72 Disque_1 = smesh.Mesh(Disque)
73 putName(Disque_1.GetMesh(), 'Disque')
74
75 Regular_1D = Disque_1.Segment()
76 Nb_Segments_1 = Regular_1D.NumberOfSegments(10)
77 Nb_Segments_1.SetDistrType( 0 )
78 Hexa_3D = Disque_1.Hexahedron(algo=smeshBuilder.Hexa)
79 Regular_1D_1 = Disque_1.Segment(geom=Compound_3)
80 Nb_Segments_2 = Regular_1D_1.NumberOfSegments(20)
81 Nb_Segments_2.SetDistrType( 0 )
82 Regular_1D_2 = Disque_1.Segment(geom=Compound_4)
83 status = Disque_1.AddHypothesis(Nb_Segments_2,Compound_4)
84 Quadrangle_2D = Disque_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
85
86 ## set object names
87 #smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
88 #smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
89 #smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
90 putName(Nb_Segments_1, 'Nb. Segments_1', i_pref='Disque')
91 putName(Nb_Segments_2, 'Nb. Segments_2', i_pref='Disque')
92
93 is_done = Disque_1.Compute()
94 text = "Disque_1.Compute"
95 if is_done:
96   logging.info(text+" OK")
97 else:
98   text = "Erreur au calcul du maillage.\n" + text
99   logging.info(text)
100   raise Exception(text)
101
102 Disque_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests", "disque.med"))
103
104 if salome.sg.hasDesktop():
105   salome.sg.updateObjBrowser()