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 """Prolongation d'un wire par deux segments tangents"""
24 from .geomsmesh import geompy
25 from .geomsmesh import geomPublish
29 from .orderEdgesFromWire import orderEdgesFromWire
31 def prolongeWire(aWire, extrem, norms, longueur):
32 """Prolongation d'un wire par deux segments tangents"""
35 if ( geompy.NumberOfEdges(aWire) > 1 ):
36 edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"])
43 for i_aux, v_1 in enumerate(extrem):
44 exts = [geompy.MakeTranslationVectorDistance(v_1, norms[i_aux], lg_aux) for lg_aux in (-longueur, longueur)]
45 dists = [(geompy.MinDistance(v, aWire), j_aux , v) for j_aux, v in enumerate(exts)]
48 edge = geompy.MakeEdge(v_1, v_2)
50 edgesBout.append(edge)
51 name = "extrem{}".format(i_aux)
52 geomPublish(initLog.debug, edge, name)
55 wireProlonge = geompy.MakeWire(edges)
56 geomPublish(initLog.debug, wireProlonge, "wireProlonge")
58 logging.warning("probleme MakeWire, approche pas a pas")
63 edgelist, accessList = orderEdgesFromWire(aWire)
64 edge1 = edgelist[accessList[0]]
65 if geompy.MinDistance(edgesBout[0], edge1) < 1.e-4 :
71 wireProlonge = edgesBout[i_0]
73 for i_aux in range(len(edgelist)):
74 wireProlonge = geompy.MakeWire([wireProlonge, edgelist[accessList[i_aux]]])
75 geomPublish(initLog.debug, wireProlonge, "wireProlonge_{}".format(i_aux))
77 wireProlonge = geompy.MakeWire([wireProlonge,edgesBout[i_1]])
78 geomPublish(initLog.debug, wireProlonge, "wireProlonge")
79 logging.warning("prolongation wire pas a pas OK")