memory is corrupt!!!

Discussion created by alcaraz on Jun 1, 2012

I need to know if two TINs intersect each other and I am getting an Access Violation Exception:

"Attempted to read or write protected memory this is often an indication that other memory is corrupt."

when I use iRelationalOperator3D.disjoint3d or .IsNear3D in this code:

        Dim pTriangleED As IPolygon4
        Dim pTinPolygonED As ITinPolygon
        Dim pTriangleING As IPolygon4
        Dim pTinPolygonING As ITinPolygon
        Dim pRelOp3D As IRelationalOperator3D2 
        Dim intersection As Boolean

        For i = 1 To pTinAdvTed.TriangleCount

            If pTinAdvTed.GetTriangle(i).IsInsideDataArea Then
                pTinPolygonED = pTinAdvTed.ExtractPolygon(pTinAdvTed.GetTriangle(i), Nothing, False)
                pTriangleED = pTinPolygonED.AsPolygon(Nothing, True)

                For j = 1 To pTinAdvTing.TriangleCount
                    If pTinAdvTing.GetTriangle(j).IsInsideDataArea Then
                        pTinPolygonING = pTinAdvTing.ExtractPolygon(pTinAdvTing.GetTriangle(i), Nothing, False)
                        pTriangleING = pTinPolygonING.AsPolygon(Nothing, True)
                        pRelOp3D = pTriangleED
                        intersection = pRelOp3D.IsNear3D(pTriangleING, 0)
                    End If

            End If

Any idea why???

Thanks!!! Mar