Salome HOME
simplification
[modules/smesh.git] / src / Tools / blocFissure / gmu / construitPartitionsPeauFissure.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 """peau et face de fissure
21
22 partition peau défaut - face de fissure prolongée - wire de fond de fissure prolongée
23 il peut y avoir plusieurs faces externes, dont certaines sont découpées par la fissure
24 liste de faces externes : facesDefaut
25 liste de partitions face externe - fissure : partitionPeauFissFond (None quand pas d'intersection)
26 """
27
28 import logging
29
30 from . import initLog
31
32 from .geomsmesh import geompy
33 from .geomsmesh import geomPublish
34 from .geomsmesh import geomPublishInFather
35
36 from .checkDecoupePartition import checkDecoupePartition
37
38 def construitPartitionsPeauFissure(facesDefaut, fissPipe):
39   """partition peau défaut - face de fissure prolongée - wire de fond de fissure prolongée.
40
41   Il peut y avoir plusieurs faces externes, dont certaines sont découpées par la fissure.
42   @param facesDefaut liste de faces externes
43   @param fissPipe    partition face de fissure etendue par pipe prolongé
44   @return partitionsPeauFissFond : liste de partitions face externe - fissure (None quand pas d'intersection)
45   """
46
47   logging.info('start')
48   partitionsPeauFissFond = list()
49   ipart = 0
50   for filling in facesDefaut:
51     part = geompy.MakePartition([fissPipe, filling], list(), list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
52     # on recrée la partition avec toutes les faces filling en outil pour avoir une face de fissure correcte
53     if checkDecoupePartition([fissPipe, filling], part):
54       otherFD = [fd for fd in facesDefaut if fd != filling]
55       if otherFD:
56         fissPipePart = geompy.MakePartition([fissPipe], otherFD, list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
57       else:
58         fissPipePart = fissPipe
59       part = geompy.MakePartition([fissPipePart, filling], list(), list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
60       partitionsPeauFissFond.append(part)
61       geomPublish(initLog.debug, part, 'partitionPeauFissFond%d'%ipart )
62     else:
63       partitionsPeauFissFond.append(None)
64     ipart += 1
65
66   return partitionsPeauFissFond