Salome HOME
Copyright update 2022
[modules/smesh.git] / src / Tools / blocFissure / gmu / facesFissure.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 """Faces fissure dans et hors tore, et edges face hors tore"""
21
22 import logging
23
24 import GEOM
25
26 from . import initLog
27
28 from .geomsmesh import geompy
29 from .geomsmesh import geomPublishInFather
30
31 def facesFissure(blocp, faceFissure, extrusionDefaut, genint):
32   """Extraction des faces de fissure dans et hors tore, des edges le long du tore et en paroi
33
34   @param faceFissure : la face de fissure avec la partie dans le tore elliptique et la partie externe
35   @return (facefissintore, facefissoutore, edgeint, edgeext)
36   """
37   logging.info('start')
38
39   [face_0,face_1] = geompy.ExtractShapes(faceFissure, geompy.ShapeType["FACE"], True)
40   ed0 = geompy.ExtractShapes(face_0, geompy.ShapeType["EDGE"], True)
41   ed1 = geompy.ExtractShapes(face_1, geompy.ShapeType["EDGE"], True)
42   if len(ed0) > len(ed1):
43     facefissintore = face_0
44     facefissoutore = face_1
45   else:
46     facefissintore = face_1
47     facefissoutore = face_0
48
49   geomPublishInFather(initLog.debug, faceFissure, facefissintore,'facefissintore')
50   geomPublishInFather(initLog.debug, faceFissure, facefissoutore,'facefissoutore')
51
52   edgeint = geompy.GetShapesOnShape(extrusionDefaut, facefissoutore, geompy.ShapeType["EDGE"], GEOM.ST_IN)
53   edgeext = geompy.GetShapesOnShape(extrusionDefaut, facefissoutore, geompy.ShapeType["EDGE"], GEOM.ST_ON)
54
55   for i_aux, edge in enumerate(edgeint):
56     name = "edgeint_{}".format(i_aux)
57     geomPublishInFather(initLog.debug, facefissoutore, edge,name)
58   for i_aux, edge in enumerate(edgeext):
59     name = "edgeext_{}".format(i_aux)
60     geomPublishInFather(initLog.debug, facefissoutore, edge,name)
61
62   reverext = list()
63   if len(edgeext) > 1:
64     vertices = geompy.ExtractShapes(genint, geompy.ShapeType["VERTEX"], False)
65     for edge in edgeext:
66       vertedge = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], False)
67       if ((geompy.GetSubShapeID(blocp, vertedge[0]) == geompy.GetSubShapeID(blocp, vertices[0])) or
68           (geompy.GetSubShapeID(blocp, vertedge[0]) == geompy.GetSubShapeID(blocp, vertices[1]))):
69         reverext.append(0)
70       else:
71         reverext.append(1)
72
73   return facefissintore, facefissoutore, edgeint, edgeext, reverext