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