Salome HOME
oubli de l'import
[modules/smesh.git] / src / Tools / blocFissure / materielCasTests / cubeAngle.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020  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
21 import logging
22
23 import sys
24 import salome
25
26 salome.salome_init()
27
28 import salome_notebook
29
30 import os
31 from blocFissure import gmu
32
33 ###
34 ### GEOM component
35 ###
36
37 import GEOM
38 from salome.geom import geomBuilder
39 import math
40 import SALOMEDS
41
42
43 geompy = geomBuilder.New()
44
45 O = geompy.MakeVertex(0, 0, 0)
46 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
47 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
48 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
49 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
50 Vertex_1 = geompy.MakeVertex(0, 0, 100)
51 Disk_1 = geompy.MakeDiskPntVecR(Vertex_1, OZ, 60)
52 Vertex_2 = geompy.MakeVertex(-5, -5, 90)
53 Vertex_3 = geompy.MakeVertex(65, 65, 110)
54 Box_2 = geompy.MakeBoxTwoPnt(Vertex_3, Vertex_2)
55 Common_1 = geompy.MakeCommon(Disk_1, Box_2)
56 geompy.ExportBREP(Common_1, os.path.join(gmu.pathBloc, "materielCasTests", "CubeAngleFiss.brep"))
57 geompy.addToStudy( O, 'O' )
58 geompy.addToStudy( OX, 'OX' )
59 geompy.addToStudy( OY, 'OY' )
60 geompy.addToStudy( OZ, 'OZ' )
61 geompy.addToStudy( Box_1, 'Box_1' )
62 geompy.addToStudy( Vertex_1, 'Vertex_1' )
63 geompy.addToStudy( Disk_1, 'Disk_1' )
64 geompy.addToStudy( Vertex_2, 'Vertex_2' )
65 geompy.addToStudy( Vertex_3, 'Vertex_3' )
66 geompy.addToStudy( Box_2, 'Box_2' )
67 geompy.addToStudy( Common_1, 'Common_1' )
68
69 ###
70 ### SMESH component
71 ###
72
73 import  SMESH, SALOMEDS
74 from salome.smesh import smeshBuilder
75
76 smesh = smeshBuilder.New()
77 from salome.StdMeshers import StdMeshersBuilder
78 Mesh_1 = smesh.Mesh(Box_1)
79 smesh.SetName(Mesh_1, 'Mesh_1')
80 Regular_1D = Mesh_1.Segment()
81 Nb_Segments_1 = Regular_1D.NumberOfSegments(15)
82 Nb_Segments_1.SetDistrType( 0 )
83 Quadrangle_2D = Mesh_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
84 Hexa_3D = Mesh_1.Hexahedron(algo=smeshBuilder.Hexa)
85 is_done = Mesh_1.Compute()
86 text = "Mesh_1.Compute"
87 if is_done:
88   logging.info(text+" OK")
89 else:
90   text = "Erreur au calcul du maillage.\n" + text
91   logging.info(text)
92   raise Exception(text)
93 Mesh_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests", "CubeAngle.med"))
94
95 ## set object names
96 smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
97 smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
98 smesh.SetName(Nb_Segments_1, 'Nb. Segments_1')
99 smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
100 smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
101
102 if salome.sg.hasDesktop():
103   salome.sg.updateObjBrowser()