Salome HOME
Copyright update 2022
[modules/smesh.git] / src / Tools / ZCracksPlug / sphere.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2016-2022  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 ###
22 ### This file is generated automatically by SALOME v7.7.1 with dump python functionality
23 ###
24
25 import sys, numpy
26 import salome
27
28 salome.salome_init()
29
30 import salome_notebook
31 notebook = salome_notebook.NoteBook()
32
33 ###
34 ### GEOM component
35 ###
36
37 import GEOM
38 from salome.geom import geomBuilder
39 import math
40 import SALOMEDS
41 from . import utilityFunctions as uF
42 from .output import message
43
44 #import GEOM_Gen.ild
45
46 def generate(data_rayon,data_centre,outFile):
47   #data_rayon = 0.1
48   #data_centre = [1., 1., 01.]
49
50   geompy = geomBuilder.New()
51
52   O = geompy.MakeVertex(0, 0, 0)
53   OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
54   OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
55   OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
56
57   SPHERE = geompy.MakeSphereR(data_rayon)
58   geompy.TranslateDXDYDZ(SPHERE, data_centre[0], data_centre[1], data_centre[2])
59   [FACE_FISSURE] = geompy.ExtractShapes(SPHERE, geompy.ShapeType["FACE"], True)
60
61   #
62   # SMESH component
63   #
64
65   import  SMESH, SALOMEDS
66   from salome.smesh import smeshBuilder
67
68   smesh = smeshBuilder.New()
69
70   A=numpy.pi/(20.)
71   chordal, minSize = uF.calcElemSize(A, data_rayon)
72   maxSize=data_rayon/3.
73
74   Maillage=uF.meshCrack(FACE_FISSURE, minSize, maxSize, chordal, dim=3)
75
76   try:
77     Maillage.ExportMED(outFile)
78     smesh.SetName(Maillage.GetMesh(), 'MAILLAGE_FISSURE')
79   except:
80     print('ExportMED() failed. Invalid file name?')
81
82
83   ## Set names of Mesh objects
84
85
86   if salome.sg.hasDesktop():
87     salome.sg.updateObjBrowser()