Grasshopper

algorithmic modeling for Rhino

This is the script of Daniel Abalde's Peacock tapered offset post, here:

http://www.grasshopper3d.com/photo/the-variable-offset-component-sp...

Views: 93813

Replies to This Discussion

You can also use Mesh.Normals.Unweld(0,true) to fix the normals like this without having to split the triangles.

You can't unweld normals, so help still needed. I managed to change the output by reversing the point order of my manually constructed tetrahedra meshes, actually, but the new problem isn't dark faces, but instead face shading artifacts, both shaded and rendered.

I'm already following the common Rhinocommon reference examples ( http://4.rhino3d.com/5/rhinocommon/?topic=html/M_Rhino_Geometry_Mes... ):

mesh.Faces.AddFace(0,2,1) # Manually build faces.
mesh.Faces.AddFace(0,3,2)
mesh.Faces.AddFace(0,1,3)
mesh.Faces.AddFace(1,2,3)

mesh.Normals.ComputeNormals()
mesh.UnifyNormals()
mesh.Compact()

The UnifyNormals is crucial to not have faces be invisible. The ComputeNormals is necessary for UnifyNormals to work. Compact is just a data clean-up pass. Most examples in the Rhinocommon reference don't even use UnifyNormals.

I had assumed the odd rendering was due to overly simple meshes. Minus any materials assignment in Grasshopper, just baking the mesh, shows many triangles have tight artifacts even in just shaded mode. Here is the same thing with multi-color materials added:

Something to do with texture mapping? UV maps?

Clue: if in Rhino I manually Unweld (Tolerance = 20, Modify Normals = True) the artifact disappears and I can then Weld again, but this fails in Python code when I do it to each Voronoi cell, giving the same shaded/rendered artifacts:

mesh.Normals.ComputeNormals() # Attach normal vectors.
mesh.UnifyNormals() # Make faces point outwards.
mesh.Compact()
mesh.Unweld(20,True)
mesh.Weld(20)

Magic! All I have to do is set the Unweld tolerance to 0 in Python as in your example:

I don't understand why my variations on manual face building didn't solve this, but perhaps Tetgen itself is failing to output face indices in any consistent order (outside clockwise for instance).

I guess UnifyNormals isn't the same as fixing real face direction, that Unweld and then Weld can fix? Very confusing.

Thanks to Daniel, no more weird tetrahedra.

Updated Tetgen Parser enclosed.

Attachments:

Hello Nik,

first, thank you very much for bringing Tetgen to GH.

I would like to have a gradient in size of the voronoi cells; from smaller on the outside to bigger in the inside of the mesh.

But I can´t find the right settings for that.

And you are using the vertex points of the mesh to write a .node file, right?

Is it possible to fill that file with other points? With points I generate on the mesh in GH? How can I do that?

A gradient arises naturally if you use a fine mesh and don't constrain much the maximum tetrahedron volume.

I'm not writing a .node file, Tetgen does that.

If you generate points on the mesh to use, I guess I'd try creating a mesh from those points. Tetgen only accepts a mesh.

However, there are advanced flags that could be changed by editing the Python code, which is fairly straightforward as far as Python goes.

chrome-extension://oemmndcbldboiebfnladdacbdfmadadm/http://wias-berlin.de/software/tetgen/1.5/doc/manual/manual.pdf

There's a way to add new points (-i flag), indeed, but that doesn't override the existing ones, and it adds tetrahedron points anywhere within the volume. This indeed requires its own separate .node file, it seems?

There's also a way to specify region attributes, (-A and -a) that I don't yet understand, as to whether it requires its own file or is somehow part of a full mesh input file alternative to the normal STL file that Tetgen reads. I'm creating an STL file from Python to make the script work and that's the only file I'm creating for Tetgen, so far.

5.2.2 .poly les
A .poly file is a B-Rep description of a piecewise linear complex (PLC) containing some additional information. It consists of four parts.

Part 4 - region attributes list
The optional fourth section lists regional attributes (to be assigned to all tetrahedra in a region) and regional constraints on the maximum tetrahedron volume. TetGen will read this section only if the -A switch is used or the -a switch without a number is invoked. Regional attributes and volume constraints are propagated in the same manner as holes.
One line: <# of region>
Following lines list # of region attributes:
<region #> <x> <y> <z> <region number> <region attribute>
...
If two values are written on a line after the x, y and z coordinate, the former is assumed to be a regional attribute (but will only be applied if the -A switch is selected), and the latter is assumed to be a regional volume constraint (but will only be applied if the -a switch is selected). It is possible to specify just one value after the coordinates. It can serve as both an attribute and a volume constraint, depending on the choice of switches. A negative maximum volume constraint allows to use the -A and the -a switches without imposing a volume constraint in this specific region.

Yeah, the manual sucks. I'm confused even what the workflow is and what are output files versus extra input files Tetgen reads from.

I basically have no idea what any of this means. What's the workflow for specifying a region's target tetrahedron maximum volume, and is that even possible?

Thank you for your answer, Nik.

That manual is not the easy thing for breakfast.

I will try it with a fine mesh and maximum tetrahedron volume set to 15?

FYI! I was going through my library of Voronoi scripts, where I assembled 2 scripts I put together some time ago. I was looking at using Voronoi on meshes to break meshes into pieces similarly to what you are doing now.

Mesh used was the Highly Decimated: BunnyMeshMachineOptimized.stl

Yikes! this thread is getting very complicated to follow in sequence

Attachments:

Yeah, I have to say a linear forum (with quotes where needed) would make much more sense to me.

ATM some of my comments stand behind a different post twice each day ;-)

Even though in theory the idea of being able to reply to specific posts makes sense, it creates a total mess in the end.

The indentation would have to be much more pronounced visually to make it possible to follow what is what.

Wow, fantastic!

I hope to be able to give it a try tomorrow.

Thank you!!!

Tom

A possibly faster 3D Voronoi clipping procedure was reported only in 2011, but I don't yet understand it since there's no actual code and most of the explanation is 2D, and the Grasshopper Voronoi3D I'm (via node-in-code) using already clips with a bounding box, so likely this will have to wait for a Tetgen update to rid its Voronoi cells bug (multiple nearby points per actual vertex)

https://hal.inria.fr/hal-00647979/file/main.pdf

Hey Nik,

I finally had the time to continue working on my project. I noticed the Voronoi Output gives extra interior edges on the outer Voronoi Cell faces, I think you referred to it as "deviled" earlier this thread (I have no idea what this means, by the way ;-) ). Is there any way to get the plain Voronoi out of your script? I looked into it but could not find anything. The Torus in your Post looks somewhat like what I am looking for.

Nico

Upload an example of the script with internalized geometry inputs, as I'm not sure how to reproduce it.

Deviled is this:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service