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