algorithmic modeling for Rhino
is it similar to this?
This has been broken for a while now. I worked around it by using mesh.ClosestPoint and checking whether the dot product of the normal at that point and the vector from the point to the closest point is positive. It's not ideal though, and a working IsPointInside would be much better.
I see what's going on. The low level implementation for this function was never completed and just returns false. I added an item to our internal bug tracker to have the developer who works on this complete the function.
In the meantime, I rewrote the IsPointInside function to get the right answer "most" of the time by
Thanks,
-Steve
How should I do this intersection ?
Function isPtInside(pt As point3d, msh As mesh) As Boolean
Dim fIdx As int32() = New Int32() {0,0}
Dim isIn As Boolean = False
Dim bbox As New rhino.Geometry.BoundingBox
bbox = msh.GetBoundingBox(True)
Dim fp As New point3d
fp = bbox.FurthestPoint(pt)
Dim vec As New vector3d(fp.X - pt.X, fp.Y - pt.Y, fp.Z - pt.Z)
Dim dist As Double = fp.DistanceTo(pt)
Dim xLine As New Line(pt, vec, dist * 10)
Dim xCrv As New rhino.Geometry.PolylineCurve
xCrv.SetStartPoint(xLine.From)
xCrv.SetEndPoint(xLine.To)
Dim interPt() As point3d = rhino.Geometry.Intersect.Intersection.MeshPolyline(msh, xCrv, fIdx)
If interPt.length mod 2 = 0 then
isIn = false
else
isIn = true
end if
Return isIn
End Function
This returns an error "Object reference not set to an instance of an object" (I guess that its related to interPt array)
I have to add 2 values (0,0) to fIdx array, otherwise I get a warning that it has no values and it may return a null.
+ you said "Using a line-mesh intersector" ... I cant find it (rhino 4), so I create a polylineCurve to use polyline-mesh intersector. (cant cast line to polyline).. is that how you do it ?
Not really sure where your error is, but this is how I'd write it:
Function IsPointInMesh(ByVal point As Point3d, ByVal mesh As Mesh) As Boolean
Dim box As BoundingBox = mesh.GetBoundingBox(True)
If (Not box.Contains(point)) Then Return False
Dim polyline As New Polyline()
polyline.Add(point)
polyline.Add(box.Max + New Vector3d(100, 100, 100))
Dim x As Point3d() = Intersect.Intersection.MeshPolyline(mesh, _
New PolylineCurve(polyline), Nothing)
If (x Is Nothing) Then Return False
Return (x.Length Mod 2) = 1
End Function
--
David Rutten
david@mcneel.com
Poprad, Slovakia
The IsPointInside function should now work if you get the latest V5 beta, since it contains the rewrite I mentioned above.
-Steve
Yes - mesh IsPointInside is working nicely now, as are mesh edge splitting and collapse. Thanks Steve!
Hi Guys,
Any chance of seeing mesh.InPointInside command in a script please as having trouble writing the code
Would be great if we can have it as a component.
Thanks
Matt
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by