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