Thursday, March 13

pointcloud filling volume























This is somehow my first script, it plots random points into any picked solid (closed surface or polysurface).
To deal with the "any", the idea was to first draw the points into an enclosing volume and then decide whether they fit into the desired solid or not. I guess there are smarter ways to do it, so - something to keep thinking about:




Option Explicit
'written by philipp hoppe on March 13th, 2008
'plots random points within picked volume; points stored in array


Call Main
Sub Main

Dim strVolume
Dim arrPts()
Dim extX : extX = 20
Dim extY : extY = 20
Dim extZ : extZ = 20
Dim i
Dim n : n = 0

strVolume = Rhino.GetObject ("Pick a closed surface or polysurface", 8 + 16)

Rhino.EnableRedraw (False)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
For i = 1 To 10000
ReDim Preserve arrPts(n)
arrPts(n) = Array(Rnd * extX, Rnd * extY, Rnd * extZ)

If Rhino.IsPointInSurface (strVolume, arrPts(n)) Then
Call Rhino.AddPoint (arrPts(n))
End If

n = n + 1
Next
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Rhino.EnableRedraw (True)

End Sub



No comments: