Salome HOME
Build under Windows.
[modules/smesh.git] / src / Tools / blocFissure / exemple2.py
1 # -*- coding: iso-8859-1 -*-
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
28 ###
29 ### GEOM component
30 ###
31
32 import GEOM
33 from salome.geom import geomBuilder
34 import math
35 import SALOMEDS
36
37 geompy = geomBuilder.New()
38
39 O = geompy.MakeVertex(0, 0, 0)
40 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
41 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
42 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
43 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
44 Vertex_1 = geompy.MakeVertex(0, 0, 100)
45 Disk_1 = geompy.MakeDiskPntVecR(Vertex_1, OZ, 50)
46 Rotation_1 = geompy.MakeRotation(Box_1, OZ, 45*math.pi/180.0)
47 geompy.TranslateDXDYDZ(Rotation_1, -50, -250, 0)
48 Cut_1 = geompy.MakeCut(Disk_1, Rotation_1)
49 geompy.Export(Cut_1, "disk.brep", "BREP")
50 geompy.addToStudy( O, 'O' )
51 geompy.addToStudy( OX, 'OX' )
52 geompy.addToStudy( OY, 'OY' )
53 geompy.addToStudy( OZ, 'OZ' )
54 geompy.addToStudy( Box_1, 'Box_1' )
55 geompy.addToStudy( Vertex_1, 'Vertex_1' )
56 geompy.addToStudy( Disk_1, 'Disk_1' )
57 geompy.addToStudy( Rotation_1, 'Rotation_1' )
58 geompy.addToStudy( Cut_1, 'Cut_1' )
59
60 ###
61 ### SMESH component
62 ###
63
64 import  SMESH, SALOMEDS
65 from salome.smesh import smeshBuilder
66
67 smesh = smeshBuilder.New()
68 from salome.StdMeshers import StdMeshersBuilder
69 boite = smesh.Mesh(Box_1)
70 Regular_1D = boite.Segment()
71 Nb_Segments_1 = Regular_1D.NumberOfSegments(15)
72 Nb_Segments_1.SetDistrType( 0 )
73 Quadrangle_2D = boite.Quadrangle(algo=smeshBuilder.QUADRANGLE)
74 Hexa_3D = boite.Hexahedron(algo=smeshBuilder.Hexa)
75 isDone = boite.Compute()
76 smesh.SetName(boite, 'boite')
77 boite.ExportMED(r'boite.med')
78
79 ## set object names
80 smesh.SetName(boite.GetMesh(), 'boite')
81 smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
82 smesh.SetName(Nb_Segments_1, 'Nb. Segments_1')
83 smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
84 smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
85
86 import os
87 from blocFissure import gmu
88 from blocFissure.gmu import initLog
89 #initLog.setDebug()
90 initLog.setVerbose()
91
92 from blocFissure.gmu.casStandard import casStandard
93
94 dicoParams = dict(nomCas            = 'angleCube2',
95                   maillageSain      = 'boite.med',
96                   brepFaceFissure   = "disk.brep",
97                   edgeFissIds       = [4],
98                   lgInfluence       = 50,
99                   meshBrep          = (5,10),
100                   rayonPipe         = 15,
101                   lenSegPipe        = 20,
102                   nbSegRad          = 5,
103                   nbSegCercle       = 12,
104                   areteFaceFissure  = 2)
105
106 execInstance = casStandard(dicoParams)
107
108 if salome.sg.hasDesktop():
109   salome.sg.updateObjBrowser()