sryabinin Posted June 29, 2006 Share Posted June 29, 2006 hello all, Im trying to write a function that determines whether a given polyline is inside of another given closed polyline. I use the standard method of drawing a ray and checking how many intersections it has with the second polyline. I also try to take into account if the polyline starts on top of the other. here is the code: Private Function fncIsInside(ByVal obj1stEnt As AcadEntity, ByVal obj2ndEnt As AcadEntity) As Boolean Dim var1stEntPnts As Variant Dim var2ndEntPnts As Variant Dim varNoIntersect As Variant Dim intNoIntersect As Integer Dim intI As Integer Dim intJ As Integer Dim intK As Integer Dim testRay As AcadRay Dim firstPt(0 To 2) As Double Dim secondPt(0 To 2) As Double var1stEntPnts = obj1stEnt.Coordinates For intI = 0 To UBound(var1stEntPnts) intNoIntersect = 0 firstPt(0) = var1stEntPnts(intI) firstPt(1) = var1stEntPnts(intI + 1) firstPt(2) = 0 secondPt(0) = var1stEntPnts(intI) + 1 secondPt(1) = var1stEntPnts(intI + 1) secondPt(2) = 0 Set testRay = ThisDrawing.ModelSpace.AddRay(firstPt, secondPt) var2ndEntPnts = testRay.IntersectWith(obj2ndEnt, acExtendNone) If UBound(var2ndEntPnts) > 0 Then For intJ = 0 To UBound(var2ndEntPnts) If var1stEntPnts(intI) var2ndEntPnts(intJ) And var1stEntPnts(intI + 1) var2ndEntPnts(intJ + 1) Then intNoIntersect = intNoIntersect + 1 End If intJ = intJ + 3 Next intJ intNoIntersect = (intNoIntersect + 1) / 3 intNoIntersect = intNoIntersect Mod 2 End If If intNoIntersect = 0 Then fncIsInside = False Else fncIsInside = True End If intI = intI + 3 Next intI End Function my problem is that for some polylines it registers it as being outside when it clearly isnt, what am I doing wrong here? Quote Link to comment Share on other sites More sharing options...
puvijain Posted February 23, 2010 Share Posted February 23, 2010 could you provide some documentation Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.