Skip to main content
. Author manuscript; available in PMC: 2018 Nov 1.
Published in final edited form as: J Biomed Inform. 2017 Sep 22;75:48–62. doi: 10.1016/j.jbi.2017.09.010

Algorithm 4.

Loop Detection Algorithm

thread:{l(0,1), l(1, 2), … l(N − 1, N)} ▷ N num projected line segments
t: ▷ tool projection
1: procedure loopDetection(thread, t)
2: for i = 0 to N − 1 do
3:   for j = i+2 to N do
4:    eline-line-intersection(l(i, i + 1), l(j, j + 1))
5:    if (enull) then
6:     looppe, i + 1, … j, e
7:     intersection pairl(i, i + 1), l(j, j + 1)
8:     if (point-polygon-Inclusion(t, loopp)) then
9:      record loopp, intersection pair
10:      ij+ 1
11:      break
12:     end if
13:    end if
14:   end for
15: end for
16: end procedure