1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2021 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 """Inventaire des faces de peau"""
26 from .geomsmesh import geompy
27 from .geomsmesh import geomPublish
29 from .sortFaces import sortFaces
30 from .extractionOrientee import extractionOrientee
32 def identifieFacesPeau(ifil, verticesPipePeau, facesOnside, wireFondFiss, \
33 verticesEdgesFondIn, pipexts, cercles, \
34 fillingFaceExterne, centreFondFiss, \
36 """Inventaire des faces de peau : face de peau percée du pipe, extrémités du pipe
38 La partition avec le pipe peut créer un vertex (et un edge) de trop sur le cercle projeté,
39 quand le cercle est très proche de la face.
40 dans ce cas, la projection du cercle sur la face suivie d'une partition permet
41 d'éviter le point en trop
45 facesAndFond = facesOnside
46 facesAndFond.append(wireFondFiss)
48 partitionPeauByPipe = geompy.MakePartition(facesAndFond, pipexts, [], [], geompy.ShapeType["FACE"], 0, [], 1)
50 logging.debug("probleme partition face pipe, contournement avec MakeSection")
52 for pipext in pipexts:
53 sections.append(geompy.MakeSection(facesOnside[0], pipext))
54 partitionPeauByPipe = geompy.MakePartition(facesAndFond, sections, [], [], geompy.ShapeType["FACE"], 0, [], 1)
56 # contrôle edge en trop sur edges circulaires
57 if len(verticesPipePeau) > 0: # --- au moins une extrémité du pipe sur cette face de peau
60 facesPeau = geompy.ExtractShapes(partitionPeauByPipe, geompy.ShapeType["FACE"], False)
61 facesPeauSorted, _, _ = sortFaces(facesPeau)
62 for face in facesPeauSorted[:-1]: # on ne teste que la ou les petites faces "circulaires"
63 nbv = geompy.NumberOfEdges(face)
64 logging.debug("nombre d'edges sur face circulaire: %s", nbv)
65 edgeEnTrop.append(bool(nbv > 3)) # TODO : distinguer les cas avec deux faces circulaires dont l'une est correcte
66 refaire = sum(edgeEnTrop)
68 l_aux = [(geompy.MinDistance(verticesEdgesFondIn[0], fac), i_aux) for i_aux, fac in enumerate(facesPeauSorted[:-1])]
70 logging.debug("l_aux sorted: %s", l_aux)
71 direct = bool(l_aux[0][1] == 0) # l_aux[0][1] = indice de facesPeauSorted qui correspond à verticesEdgesFondIn[0], donc 0 pour cercles
72 for i_aux, bad in enumerate(edgeEnTrop):
78 outilPart[j_aux] = geompy.MakeProjection(cercles[j_aux],facesOnside[0])
79 partitionPeauByPipe = geompy.MakePartition(facesAndFond, outilPart, [], [], geompy.ShapeType["FACE"], 0, [], 1)
81 name="partitionPeauByPipe_{}".format(ifil)
82 geomPublish(initLog.debug, partitionPeauByPipe, name)
83 [edgesPeauFondIn, _, _] = extractionOrientee(fillingFaceExterne, partitionPeauByPipe, centreFondFiss, "EDGE", 1.e-3)
84 [_, _, facesPeauFondOn] = extractionOrientee(fillingFaceExterne, partitionPeauByPipe, centreFondFiss, "FACE", 1.e-3)
86 if verticesPipePeau: # --- au moins une extrémité du pipe sur cette face de peau
87 facesPeauSorted, _, _ = sortFaces(facesPeauFondOn)
88 facePeau = facesPeauSorted[-1] # la plus grande face
90 facePeau =geompy.MakePartition(facesPeauFondOn, [], [], [], geompy.ShapeType["FACE"], 0, [], 1)
91 facesPeauSorted = [facePeau]
93 name="facePeau_{}".format(ifil)
94 geomPublish(initLog.always, facePeau, name, nro_cas)
96 return (facePeau, facesPeauSorted, edgesPeauFondIn)