Salome HOME
Copyright update 2022
[modules/smesh.git] / src / Tools / blocFissure / gmu / toreFissure.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-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 """tore et plan de fissure"""
21
22 import logging
23 import math
24
25 from .geomsmesh import geompy
26 from .geomsmesh import geomPublish
27
28 from . import initLog
29
30 from .triedreBase import triedreBase
31
32 O, OX, OY, OZ = triedreBase()
33
34 def toreFissure(minRad,allonge,rayTore):
35   """
36   Construction de la geometrie du tore elliptique autour du front de fissure.
37   L'ellipse est construite dans le plan xoy, axe oy.
38   @param minRad :petit rayon
39   @param allonge :rapport grand rayon / petit rayon
40   @param rayTore :rayon du tore construit autour de la generatrice de l'ellipse
41   @return (generatrice, face_gen_fiss, pipe, face_fissure, plane, pipe_part) : ellipse, section du tore,
42   tore plein, face plane de le fissure, plan de la fissure, tore partitionĂ© par le plan de fissure.
43   """
44   logging.info("start %s %s %s", minRad, allonge, rayTore)
45
46   vertex_1 = geompy.MakeVertex( minRad, 0., 0.)
47   vertex_2 = geompy.MakeVertex(-minRad, 0., 0.)
48   vertex_3 = geompy.Makerotation(vertex_1, OZ,  45.*math.pi/180.0)
49   arc = geompy.MakeArc(vertex_1, vertex_2, vertex_3)
50   generatrice = geompy.MakeScaleAlongAxes(arc, O, 1, allonge, 1)
51
52   #geomPublish(initLog.debug,  vertex_1, 'vertex_1' )
53   #geomPublish(initLog.debug,  vertex_2, 'vertex_2' )
54   #geomPublish(initLog.debug,  vertex_3, 'vertex_3' )
55   #geomPublish(initLog.debug,  arc, 'arc' )
56   #geomPublish(initLog.debug,  generatrice, 'generatrice' )
57
58   # --- face circulaire sur la generatrice, pour extrusion
59
60   circle = geompy.MakeCircle(O, OY, rayTore)
61   rotation = geompy.MakeRotation(circle, OY, -90.*math.pi/180.0)
62   translation = geompy.MakeTranslation(rotation, minRad, 0., 0.)
63   face_gen_fiss = geompy.MakeFaceWires([translation], 1)
64
65   #geomPublish(initLog.debug,  circle, 'circle' )
66   #geomPublish(initLog.debug,  rotation, 'rotation' )
67   #geomPublish(initLog.debug,  translation, 'translation' )
68   #geomPublish(initLog.debug,  face_gen_fiss, 'face_gen_fiss' )
69
70   # --- tore extrude
71
72   pipe = geompy.MakePipe(face_gen_fiss, generatrice)
73
74   # --- plan fissure, delimite par la generatrice
75
76   scale_vertex_3 = geompy.GetSubShape(generatrice, [3])
77   line = geompy.MakeLineTwoPnt(vertex_1, scale_vertex_3)
78   face_fissure = geompy.MakeFaceWires([generatrice, line], 1)
79
80   #geomPublishInFather(initLog.debug, generatrice, scale_vertex_3, 'scale_1:vertex_3' )
81   #geomPublish(initLog.debug,  line, 'line' )
82   #geomPublish(initLog.debug,  face_fissure, 'face_fissure' )
83
84   # --- tore coupe en 2 demi tore de section 1/2 disque
85
86   plane = geompy.MakePlane(O, OZ, 2000)
87   pipe_part = geompy.MakePartition([pipe], [plane], [], [], geompy.ShapeType["SOLID"], 0, [], 1)
88   geomPublish(initLog.debug, pipe_part , 'pipe_part' )
89
90   return generatrice, face_gen_fiss, pipe, face_fissure, plane, pipe_part