Salome HOME
simplification
[modules/smesh.git] / src / Tools / blocFissure / gmu / identifieEdgesPeau_b.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 """edges de bord de la face de peau"""
21
22 import logging
23
24 from . import initLog
25
26 from .geomsmesh import geompy
27 from .geomsmesh import geomPublishInFather
28
29 def identifieEdgesPeau_b(facePeau, edgesListees, \
30                          fillingFaceExterne, aretesVivesC, aretesVivesCoupees, \
31                           nro_cas=None):
32   """edges de bord de la face de peau"""
33   logging.info('start')
34
35   edgesFilling = geompy.ExtractShapes(fillingFaceExterne, geompy.ShapeType["EDGE"], False)
36   edgesBords = list()
37   for i_aux, edge in enumerate(edgesFilling):
38     edgepeau = geompy.GetInPlace(facePeau, edge)
39     name = "edgepeau{}".format(i_aux)
40     geomPublishInFather(initLog.debug, facePeau,edgepeau, name)
41     logging.debug("edgepeau %s", geompy.ShapeInfo(edgepeau))
42     if geompy.ShapeInfo(edgepeau)['EDGE'] > 1:
43       logging.debug("  EDGES multiples")
44       l_edges = geompy.ExtractShapes(edgepeau, geompy.ShapeType["EDGE"], False)
45       edgesBords += l_edges
46       edgesListees += l_edges
47     else:
48       logging.debug("  EDGE")
49       edgesBords.append(edgepeau)
50       edgesListees.append(edgepeau)
51
52   groupEdgesBordPeau = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"])
53   geompy.UnionList(groupEdgesBordPeau, edgesBords)
54   bordsVifs = None
55   if aretesVivesC is not None:
56     logging.debug("identification des bords vifs par GetInPlace")
57     bordsVifs = geompy.GetInPlace(facePeau, aretesVivesC)
58     if bordsVifs is None:
59       logging.debug("pas d'identification des bords vifs par GetInPlace: test par distance")
60       edvifs = list()
61       arvives = geompy.ExtractShapes(aretesVivesC, geompy.ShapeType["EDGE"], False)
62       l_edges = geompy.ExtractShapes(facePeau, geompy.ShapeType["EDGE"], False)
63       for edge in l_edges:
64         vxs = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], False)
65         for arete in arvives:
66           dist = geompy.MinDistance(vxs[0], arete)
67           dist += geompy.MinDistance(vxs[1], arete)
68           logging.debug("test distance bord face peau - arete vive: %s",dist)
69           if ( dist < 0.001 ):
70             edvifs.append(edge)
71             break
72       if len(edvifs) >0:
73         bordsVifs = geompy.CreateGroup(facePeau,geompy.ShapeType["EDGE"])
74         for edge in edvifs:
75           geompy.AddObject(bordsVifs, geompy.GetSubShapeID(facePeau, edge))
76
77   if bordsVifs is not None:
78     geomPublishInFather(initLog.always, facePeau, bordsVifs, "bordsVifs")
79     groupEdgesBordPeau = geompy.CutGroups(groupEdgesBordPeau, bordsVifs)
80     grptmp = None
81     if len(aretesVivesCoupees) > 0:
82       grpc = geompy.MakeCompound(aretesVivesCoupees)
83       grptmp = geompy.GetInPlace(facePeau, grpc)
84     if grptmp is not None:
85       grpnew = geompy.CutGroups(bordsVifs, grptmp) # ce qui est nouveau dans bordsVifs
86     else:
87       grpnew = bordsVifs
88     if grpnew is not None:
89       edv = geompy.ExtractShapes(grpnew, geompy.ShapeType["EDGE"], False)
90       aretesVivesCoupees += edv
91
92   logging.debug("aretesVivesCoupees %s",aretesVivesCoupees)
93   geomPublishInFather(initLog.always, facePeau, groupEdgesBordPeau , "EdgesBords")
94
95   return groupEdgesBordPeau, bordsVifs