1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2019 CEA/DEN, 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
22 from .geomsmesh import geompy
23 from .geomsmesh import geomPublish
24 from .geomsmesh import geomPublishInFather
26 from .orderEdgesFromWire import orderEdgesFromWire
28 # -----------------------------------------------------------------------------
29 # --- prolongation d'un wire par deux segments tangents
31 def prolongeWire(aWire, extrem, norms, lg):
35 if geompy.NumberOfEdges(aWire) > 1:
36 edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"])
42 for i, v1 in enumerate(extrem):
43 exts = [geompy.MakeTranslationVectorDistance(v1, norms[i], l) for l in (-lg, lg)]
44 dists = [(geompy.MinDistance(v, aWire), i , v) for i, v in enumerate(exts)]
47 edge = geompy.MakeEdge(v1, v2)
49 edgesBout.append(edge)
51 geomPublish(initLog.debug, edge, name)
53 wireProlonge = geompy.MakeWire(edges)
54 geomPublish(initLog.debug, wireProlonge, "wireProlonge")
56 logging.warning("probleme MakeWire, approche pas a pas")
61 edgelist, accessList = orderEdgesFromWire(aWire)
62 edge1 = edgelist[accessList[0]]
63 if geompy.MinDistance(edgesBout[0], edge1) < 1.e-4 :
69 wireProlonge = edgesBout[i0]
70 for i in range(len(edgelist)):
71 wireProlonge = geompy.MakeWire([wireProlonge, edgelist[accessList[i]]])
72 geomPublish(initLog.debug, wireProlonge, "wireProlonge_%d"%i)
73 wireProlonge = geompy.MakeWire([wireProlonge,edgesBout[i1]])
74 geomPublish(initLog.debug, wireProlonge, "wireProlonge")
75 logging.warning("prolongation wire pas a pas OK")