Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.

Commit

Permalink
completion of path intersection utility
Browse files Browse the repository at this point in the history
  • Loading branch information
patmo141 committed Sep 4, 2013
1 parent 37f0d8f commit 0c8ae50
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions scripts/addons/contour_tools/contour_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -1433,23 +1433,36 @@ def intersect_paths(path1, path2, cyclic1 = False, cyclic2 = False, threshold =
inds = []
for i in range(0,len(path1)-1 + 1*cyclic1):

n = int(math.fmod(i+1), len(path1))
n = int(math.fmod(i+1, len(path1)))
v1 = path1[n]
v2 = path1[i]

print([i,n])
for j in range(0,len(path2)-1 + 1*cyclic2):

m = int(math.fmod(j+1, len(path1)))
v3 = path1[m]
v4 = path1[j]
m = int(math.fmod(j+1, len(path2)))
v3 = path2[m]
v4 = path2[j]

#closes point on path1 edge, closes_point on path 2 edge
inter_1, inter_2 = intersect_line_line(v1,v2,v3,v4)

diff = inter_2 - inter_1
if diff.length < threshold:
intersections.append(inter_1)
inds.append([i,j])
intersect = intersect_line_line(v1,v2,v3,v4)

if intersect:
#make sure the intersection is within the segment



inter_1 = intersect[0]
verif1 = intersect_point_line(inter_1, v1,v2)

inter_2 = intersect[1]
verif2 = intersect_point_line(inter_1, v3,v4)

diff = inter_2 - inter_1
if diff.length < threshold and verif1[1] > 0 and verif2[1] > 0 and verif1[1] < 1 and verif2[1] < 1:
intersections.append(.5 * (inter_1 + inter_2))
inds.append([i,j])

return intersections, inds

Expand Down Expand Up @@ -1493,7 +1506,7 @@ def pole_detector(bme):
pole_inds = []

for vert in bme.verts:
if len(vert.link_edges) in {3,5}:
if len(vert.link_edges) in {3,5,6}:
pole_inds.append(vert.index)

return pole_inds
Expand Down

0 comments on commit 0c8ae50

Please sign in to comment.