Salome HOME
oubli de l'import
[modules/smesh.git] / src / Tools / blocFissure / materielCasTests / fissureGauche2.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 notebook = salome_notebook.notebook
30
31 import os
32 from blocFissure import gmu
33
34 ###
35 ### GEOM component
36 ###
37
38 import GEOM
39 from salome.geom import geomBuilder
40 import math
41 import SALOMEDS
42
43
44 geompy = geomBuilder.New()
45
46 O = geompy.MakeVertex(0, 0, 0)
47 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
48 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
49 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
50 Circle_1 = geompy.MakeCircle(O, OX, 500)
51 Extrusion_1 = geompy.MakePrismVecH2Ways(Circle_1, OX, 500)
52 Vertex_1 = geompy.MakeVertex(500, 0, 0)
53 Circle_3 = geompy.MakeCircle(Vertex_1, OZ, 300)
54 Extrusion_2 = geompy.MakePrismVecH(Circle_3, OZ, 1000)
55 Partition_1 = geompy.MakePartition([Extrusion_1], [Extrusion_2], [], [], geompy.ShapeType["FACE"], 0, [], 0)
56 [Face_1,Face_2] = geompy.SubShapes(Partition_1, [18, 13])
57 FaceFissExt = geompy.MakeFuse(Face_2, Face_1)
58 geompy.ExportBREP(FaceFissExt, os.path.join(gmu.pathBloc, "materielCasTests", "faceGauche2Fiss.brep"))
59 Vertex_2 = geompy.MakeVertex(0, -500, 0)
60 Vertex_3 = geompy.MakeVertex(400, 500, 800)
61 objetSain = geompy.MakeBoxTwoPnt(Vertex_3, Vertex_2)
62 Rotation_1 = geompy.MakeRotation(Extrusion_1, OX, 180*math.pi/180.0)
63 Partition_2 = geompy.MakePartition([Rotation_1], [Extrusion_2], [], [], geompy.ShapeType["FACE"], 0, [], 0)
64 geompy.addToStudy( Partition_2, 'Partition_2' )
65 [FaceFissExtSimple] = geompy.SubShapes(Partition_2, [13])
66 geompy.addToStudyInFather( Partition_2, FaceFissExtSimple, 'FaceFissExtSimple' )
67 Plane_1 = geompy.MakePlaneLCS(None, 2000, 3)
68 FaceFissExtCoupe = geompy.MakePartition([FaceFissExtSimple], [Plane_1], [], [], geompy.ShapeType["FACE"], 0, [], 0)
69 geompy.ExportBREP(FaceFissExtCoupe, os.path.join(gmu.pathBloc, "materielCasTests", "faceGauche2FissCoupe.brep"))
70 geompy.addToStudy( O, 'O' )
71 geompy.addToStudy( OX, 'OX' )
72 geompy.addToStudy( OY, 'OY' )
73 geompy.addToStudy( OZ, 'OZ' )
74 geompy.addToStudy( Circle_1, 'Circle_1' )
75 geompy.addToStudy( Extrusion_1, 'Extrusion_1' )
76 geompy.addToStudy( Vertex_1, 'Vertex_1' )
77 geompy.addToStudy( Circle_3, 'Circle_3' )
78 geompy.addToStudy( Extrusion_2, 'Extrusion_2' )
79 geompy.addToStudy( Partition_1, 'Partition_1' )
80 geompy.addToStudyInFather( Partition_1, Face_1, 'Face_1' )
81 geompy.addToStudyInFather( Partition_1, Face_2, 'Face_2' )
82 geompy.addToStudy( FaceFissExt, 'FaceFissExt' )
83 geompy.addToStudy( Vertex_2, 'Vertex_2' )
84 geompy.addToStudy( Vertex_3, 'Vertex_3' )
85 geompy.addToStudy( objetSain, 'objetSain' )
86 geompy.addToStudy( Rotation_1, 'Rotation_1' )
87 geompy.addToStudy( Plane_1, 'Plane_1' )
88 geompy.addToStudy( FaceFissExtCoupe, 'FaceFissExtCoupe' )
89
90 ###
91 ### SMESH component
92 ###
93
94 import  SMESH, SALOMEDS
95 from salome.smesh import smeshBuilder
96
97 smesh = smeshBuilder.New()
98 from salome.StdMeshers import StdMeshersBuilder
99 Mesh_1 = smesh.Mesh(objetSain)
100 smesh.SetName(Mesh_1, 'Mesh_1')
101 Regular_1D = Mesh_1.Segment()
102 Nb_Segments_1 = Regular_1D.NumberOfSegments(15,[],[  ])
103 Nb_Segments_1.SetDistrType( 0 )
104 Quadrangle_2D = Mesh_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
105 Hexa_3D = Mesh_1.Hexahedron(algo=smeshBuilder.Hexa)
106 is_done = Mesh_1.Compute()
107 text = "Mesh_1.Compute"
108 if is_done:
109   logging.info(text+" OK")
110 else:
111   text = "Erreur au calcul du maillage.\n" + text
112   logging.info(text)
113   raise Exception(text)
114 Mesh_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests", "boiteSaine.med"))
115
116 ## set object names
117 smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
118 smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
119 smesh.SetName(Nb_Segments_1, 'Nb. Segments_1')
120 smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
121 smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
122
123 if salome.sg.hasDesktop():
124   salome.sg.updateObjBrowser()