1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2023 EDF
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 """Recherche des points en trop (externes au volume à remailler)"""
24 from .geomsmesh import geompy
25 from .whichSideVertex import whichSideVertex
27 def elimineExtremitesPipe(ptEdgeFond, facesDefaut, centres, gptsdisks, nbsegCercle):
28 """Recherche des points en trop (externes au volume à remailler)
30 - on associe chaque extrémité du pipe à une face filling
31 - on part des disques aux extrémités du pipe
32 - pour chaque disque, on prend les vertices de géométrie,
33 on marque leur position relative à la face.
34 - on s'arrete quand tous les noeuds sont dedans
41 idFillingFromBout = [None, None] # contiendra l'index du filling pour les extrémités 0 et 1
42 nbFacesFilling = len(ptEdgeFond)
43 for ifil in range(nbFacesFilling):
44 for point in ptEdgeFond[ifil]: # il y a un ou deux points débouchant sur cette face
45 if geompy.MinDistance(point,point_0) < geompy.MinDistance(point,point_1): # TODO: trouver plus fiable pour les cas tordus...
46 idFillingFromBout[0] = ifil
48 idFillingFromBout[1] = ifil
49 logging.debug("association bouts du pipe - faces de filling: %s", idFillingFromBout)
51 logging.debug("recherche des disques de noeuds complètement internes")
52 idisklim = list() # indices des premier et dernier disques internes
53 idiskout = list() # indices des premier et dernier disques externes
61 idisk = len(gptsdisks)
63 numout = len(gptsdisks)
69 logging.debug("examen disque %s", idisk)
70 gptdsk = gptsdisks[idisk]
72 for n_seg in range(nbsegCercle):
73 points = gptdsk[n_seg]
75 side = whichSideVertex(facesDefaut[idFillingFromBout[bout]], point)
77 if outside: # premier point detecté dedans
79 numout = idisk -inc # le disque précédent était dehors
81 inside = False # ce point est dehors
82 if not inside and not outside:
85 idisklim.append(idisk) # premier et dernier disques internes
86 idiskout.append(numout) # premier et dernier disques externes
88 return (idFillingFromBout, idisklim, idiskout)