boundary detection added, need to fix polygon cutting to not create two vertices for each intersecting segment