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