Grasshopper

algorithmic modeling for Rhino

I have a trimmed surface that I'm trying to perform a line/surface intersection on in VB.NET...

This produces a list of intersecting points, but it does so also for the portions of the surface that have been trimmed away:

Private Sub RunScript(ByVal lnLines As List(Of OnLine), ByVal srfEllipse As OnSurface, ByRef A As Object, ByRef B As Object) 

    Dim intPnts As Int16
    Dim intLines As Int16
    intPnts = 0

    Dim pntIntersection As New List(Of On3dPoint)

    For intLines = 0 To lnLines.Count - 1

      Dim arrX As New ArrayOnX_EVENT
      Dim linCheck As OnLine = lnLines(intLines)
      linCheck.IntersectSurface(srfEllipse, arrX)

      If arrX.Count() = 1 Then
        Dim X As New OnX_EVENT
        x = arrX(0)
        Dim ptA As New On3dPoint(X.m_pointA(0))
        pntIntersection.Add(ptA)

      End If

    Next

    A = pntIntersection

  End Sub

What do I need to do to return only the intersections between my list of lines and the trimmed portion of the surface?

thanks,

Dave

Views: 245

Replies to This Discussion

First off, if you're supplying a trimmed surface as an argument for an OnSurface, you are probably loosing all that trimming information within the scripting component. Surfaces do not contain any trimming information, so in order to have access to that, you'll need to use the OnBrep type for that variable instead of OnSurface

On to your issue...You have two options here. The first is to intersect the surface as is, and test the resulting point as to whether it lies on the trimmed brep or not. The second is just to intersect the physical line with the Brep.

With the first option, assuming you've switched the input to OnBrep, you'll have to extract the underlying OnSurface, since you won't be able to use the OnBrep directly. This can be done fairly easily with the surface property of the brep myBrep.m_S(0) After that, you can use RhUtil.RhinoIsPointOnFace to find out whether its valid.

With the second option, you'll have to make a curve from an OnCurve derived class, which in your case would be OnLineCurve. After that use RhUtil.RhinoCurveBrepIntersect to find the intersection(s). Note that the last two variables that need to be supplies will be filled by the method, and those should be used to check if the method produces any results. RhinoCurveBrepIntersect says that it will return a boolean, but you should not use that to determine whether or not proper intersections are found.
The first option sounds like the best solution to me. Thanks, Damien!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service