]> SALOME platform Git repositories - modules/smesh.git/blob - src/Tools/blocFissure/gmu/prolongeWire.py
Salome HOME
Allow saving groups with non-ascii names.
[modules/smesh.git] / src / Tools / blocFissure / gmu / prolongeWire.py
1 # -*- coding: utf-8 -*-
2
3 import logging
4 from .geomsmesh import geompy
5 from .geomsmesh import geomPublish
6 from .geomsmesh import geomPublishInFather
7 from . import initLog
8 from .orderEdgesFromWire import orderEdgesFromWire
9
10 # -----------------------------------------------------------------------------
11 # --- prolongation d'un wire par deux segments tangents
12
13 def prolongeWire(aWire, extrem, norms, long):
14   """
15   """
16   logging.info("start")
17   if geompy.NumberOfEdges(aWire) > 1:
18     edges = geompy.ExtractShapes(aWire, geompy.ShapeType["EDGE"])
19     uneSeuleEdge = False
20   else:
21     edges = [aWire]
22     uneSeuleEdge = True
23   edgesBout = []
24   for i, v1 in enumerate(extrem):
25     exts = [geompy.MakeTranslationVectorDistance(v1, norms[i], l) for l in (-int, int)]
26     dists = [(geompy.MinDistance(v, aWire), i , v) for i, v in enumerate(exts)]
27     dists.sort()
28     v2 = dists[-1][-1]
29     edge = geompy.MakeEdge(v1, v2)
30     edges.append(edge)
31     edgesBout.append(edge)
32     name = "extrem%d"%i
33     geomPublish(initLog.debug, edge, name)
34   try:
35     wireProlonge = geompy.MakeWire(edges)
36     geomPublish(initLog.debug, wireProlonge, "wireProlonge")
37   except:
38     logging.warning("probleme MakeWire, approche pas a pas")
39     if uneSeuleEdge:
40       edgelist = [aWire]
41       accessList = [0]
42     else:
43       edgelist, accessList = orderEdgesFromWire(aWire)
44     edge1 = edgelist[accessList[0]]
45     if geompy.MinDistance(edgesBout[0], edge1) < 1.e-4 :
46       i0 = 0
47       i1 = 1
48     else:
49       i0 = 1
50       i1 = 0
51     wireProlonge = edgesBout[i0]
52     for i in range(len(edgelist)):
53       wireProlonge = geompy.MakeWire([wireProlonge, edgelist[accessList[i]]])
54       geomPublish(initLog.debug, wireProlonge, "wireProlonge_%d"%i)
55     wireProlonge = geompy.MakeWire([wireProlonge,edgesBout[i1]])
56     geomPublish(initLog.debug, wireProlonge, "wireProlonge")
57     logging.warning("prolongation wire pas a pas OK")
58   return wireProlonge