Grasshopper

algorithmic modeling for Rhino

Hi, 

I need to make a Delaunay mesh within a VB component. I have done the following and the mesh seems pretty nice; except it acts strangely when I try to extract its normal vectors and then they are null (it may also cause Rhino crash!). Does anyone know what is wrong with this mesh?

Private Sub RunScript(ByVal x As List(Of Point3d), ByRef A As Object) 

Dim N2L As New grasshopper.Kernel.Geometry.Node2List(x)
Dim DF = grasshopper.Kernel.Geometry.Delaunay.Solver.Solve_Faces(N2L, 1)
Dim Faces As New list(Of MeshFace)
For Each DFace As grasshopper.Kernel.Geometry.Delaunay.FaceEx In DF
Faces.Add(New MeshFace(DFace.A, Dface.B, DFace.C))
Next
Dim DM As new Mesh
DM.Vertices.AddVertices(x)
DM.Faces.AddFaces(Faces)
A = DM

End Sub

Ps. the reason I am introducing vertices in this way is that I want the mesh be a 3D mesh, just like the Delaunay mesh generated by the native component of GH. 

Thanks,

Pirouz

Views: 1663

Replies to This Discussion

You should probably specifically tell the Mesh to compute vertex and face normals.

Mesh.Normals.ComputeNormals()

--

David Rutten

david@mcneel.com

Yes! that's it! Thanks a lot! 

But as Richard has also noticed, it sometimes puts out self-intersecting results. I wonder what is the role of that jitter value in there? I tried changing it and checking the differences with your Delaunay component, I thought it should be set to 1 but this was just a wet finger method. Could you please shed some light on this matter? Is that because a Delaunay triangulation is not unique and by changing the way points are sorted every time we get a different one?

If there are more than 3 points on the same circle then the delaunay triangulation becomes non-unique. It shouldn't lead to problems, but just in case it does, the jitter allows you to randomly move points a bit before triangulating the point-set.

Use jitter=0.0 unless you run into problems.

--

David Rutten

david@mcneel.com

Thanks for the explanation. Could you please also suggest a way around the problem of the 3D mesh? How to compute the mesh according to a Grasshopper.Kernel.Geometry.Node3List(x), so that the Delaunay mesh becomes a 3D mesh? (I noticed that none of the grasshopper.kernel.geometry.delaunay methods support points of Node3list type!?) 

Use you script and just set the jitter value to 0.0.

Yep! : ) Thanks Richard!

Hallo Pirouz,

copy and pasted your code. I am not entirely sure but the resulting Delaunay triangulation seams wrong. You can explore that by using Populate2D, at least in my case there are overlapping faces...

 

Hi Richard, yes. Thanks for pointing to this. I have noticed that as well. Any ideas why?

I would guess that the vertices are resorted in one of these two lines, but that's just a wild guess:

Dim N2L As New grasshopper.Kernel.Geometry.Node2List(x)
Dim DF = grasshopper.Kernel.Geometry.Delaunay.Solver.Solve_Faces(N2L, 1)

The thing is, when you use this method, you always get a 2D triangulation, as you are using 2D GH_points as vertices. This is why I have used the faces only and made a mesh with 3D vertices. And this is perhaps why it acts strangely sometimes as the faces have been computed for a set of non-elevated vertices and then I use the original vertices to define the mesh geometry. I wonder what is the right way of doing it!? because I could not find the Delaunay methods for 3d points.

No perfectly fine way to do it, but if the jitter makes me guess that the nodes are resorted (for what reason I can not tell since I never implemented a Delaunay algorithm. But I would guess that this might be to overcome rounding errors.->ask David for more details (solved while typing)).

You can see it even better when using your algorithmen on a grid. If you set it to something else than 0 nodes with the same y-value are resorted and therfore you can not simply replace them with the nodes they where generated with.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service