Salome HOME
Merge branch 'V9_9_BR'
[modules/smesh.git] / src / Tools / blocFissure / gmu / ajustePointsEdgePipeFissure.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2022  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 """Ajustement précis des points sur edgesPipeFissureExterneC"""
21
22 import logging
23
24 from .geomsmesh import geompy
25 from .findWireIntermediateVertices import findWireIntermediateVertices
26 from .projettePointSurCourbe import projettePointSurCourbe
27
28 def ajustePointsEdgePipeFissure(edgesPipeFissureExterneC, wirePipeFissureExterne, gptsdisks, idisklim):
29   """Ajustement précis des points sur edgesPipeFissureExterneC"""
30   logging.info('start')
31
32   edgesPFE = geompy.ExtractShapes(edgesPipeFissureExterneC, geompy.ShapeType["EDGE"], False)
33   verticesPFE, _ = findWireIntermediateVertices(wirePipeFissureExterne)  # vertices intermédiaires (des points en trop dans ptsInWireFissExtPipe)
34   idiskmin = idisklim[0] + 1 # on ne prend pas le disque sur la peau, déjà ajusté
35   idiskmax = idisklim[1]
36   idiskint = list()
37
38   for vtx in verticesPFE:
39     distPtVt = list()
40     for idisk in range(idiskmin, idiskmax):
41       gptdsk = gptsdisks[idisk]
42       point = gptdsk[0][-1]       # le point sur l'edge de la fissure externe au pipe
43       distPtVt.append((geompy.MinDistance(point, vtx), idisk))
44     distPtVt.sort()
45     idiskint.append(distPtVt[0][1])
46     gptsdisks[idiskint[-1]][0][-1] = vtx
47     logging.debug("ajustement point sur edgePipeFissureExterne, vertex: %s %s", idiskint[-1], distPtVt[0][0])
48
49   for idisk in range(idiskmin, idiskmax):
50     if idisk in idiskint:
51       break
52     logging.debug("ajustement point sur edgePipeFissureExterne: %s", idisk)
53     gptdsk = gptsdisks[idisk]
54     point = gptdsk[0][-1]       # le point sur l'edge de la fissure externe au pipe
55     distPtEd = [(geompy.MinDistance(point, edgePFE), k, edgePFE) for k, edgePFE in enumerate(edgesPFE)]
56     distPtEd.sort()
57     edgePFE = distPtEd[0][2]
58     point_bis = projettePointSurCourbe(point, edgePFE)
59     ptproj = geompy.MakeVertexOnCurve(edgePFE, point_bis)
60     gptsdisks[idisk][0][-1] = ptproj
61
62   return gptsdisks