Grasshopper

algorithmic modeling for Rhino

"TetGen is a program to generate tetrahedral meshes of any 3D polyhedral domains. TetGen generates exact constrained Delaunay tetrahedralizations, boundary conforming Delaunay meshes, and Voronoi partitions." (http://wias-berlin.de/software/index.jsp?id=TetGen&lang=1)

To continue with my wrapping career, TetRhino (or Tetrino) is a .NET wrapper for the well-known and pretty amazing TetGen mesh tetrahedralization program. It provides one new GH component for discretizing or remeshing objects using TetGen. Basic tetrahedralization functionality is exposed with a few different output types that can be controlled. At the moment, the only control for tetrahedra sizes is the minimum ratio, which is controlled by a slider. This is hardcoded to always be above 1.0-1.1, as it is very easy to generate a LOT of data (and crash)...

The libs are divided again into different modules to allow flexibility and fun with or without Rhino and GH, so have fun. All 4 libs should be placed in a folder (maybe called 'tetgen') in your GH libraries folder. Remember to unblock.

Once again, the libs are provided as-is, with no guarantee of support for now, as I use them internally and do not intend to develop this into a shiny, polished plug-in. If there is enough interest, I can tidy up the code-base and upload it somewhere if someone more savvy than me wants to play.

TetgenGH.gha - Grasshopper assembly which adds the 'Tetrahedralize' component to Mesh -> Triangulation.

TetgenRC.dll - RhinoCommon interface to the Tetgen wrapper.

TetgenSharp.dll - dotNET wrapper for Tetgen.

TetgenWrapper.dll - Actual wrapper for Tetgen.

Obviously, credit where credit is due for this excellent and tiny piece of software: 

"The development of TetGen is executed at the Weierstrass Institute for Applied Analysis and Stochastics in the research group of Numerical Mathematics and Scientific Computing." See http://wias-berlin.de/software/index.jsp?id=TetGen&lang=1 for more details about TetGen.

To wrap up, some notes about the inputs:

These are the possible integer Flags (F) values and resultant outputs for the GH component:

0 - Output M yields a closed boundary mesh. Useful for simply remeshing your input mesh.

1 - Output M yields a list of tetra meshes.

2 - Output I yields a DataTree of tetra indices, grouped in lists of 4. Output P yields a list of points to which the tetra indices correspond.

3 - Output I yields a DataTree of edge indices, grouped in lists of 2. Output P yields a list of points to which the edge indices correspond. Useful for lots of things, very easy to create lines from this to plug into K2 or something for some ropey FEA (or not so ropey!) ;)

As this component can potentially create a LOT of data, especially with dense meshes, care should be taken with the MinRatio (R) input. This will try to constrain the tetra to be more or less elongated, which also means that the lower this value gets, the more tetra need to be added to satisfy this constraint. Start with very high values and lower them until satisfactory.

Hopefully shouldn't be an issue, but it's possible that you need the 2015 Microsoft C++ Redistributable.

Happy tetrahedralizing...

UPDATE: The tetgen.zip has been updated with some fixes.

UPDATE2: This is now available on Food4Rhino: http://www.food4rhino.com/app/tetrino

Views: 3705

Attachments:

Replies to This Discussion

Hahahaha.

To continue with my wrapping career.

Nice one :)

To wrap up, some notes about the inputs:

So many puns. 

Simple example files. Compare the mesh of the input with the Tetgen mesh. Fiddle with the Flags and MinRatio parameters to get an idea.

TetRhino_Example01.gh

Most basic example.

TetRhino_Example02.gh

Example for getting tetra edges out as lines, and on to K2, etc.

Attachments:

Sweet!

Very nice Tom, thanks:)
A minor bug is that the integer Flags (F) 0 and 1 are switched (or their descriptions), and the descriptions for integer Flags 2 and 3 are missing. Also, the triangulated mesh has its normals flipped. I won't ask you to polish the component, but can you fix the mentioned bugs, and maybe add the appropriate (per integer flag) decriptions for the outputs? Or is that considered 'polishing'?
Kind regards.

Ah that seems reasonable :) It'll help me sleep better at night.

Here you go, let me know if it works...

Attachments:

Forgot the mesh normals bit, but I'm having trouble guaranteeing face normals that point outward... 

I'm calling Mesh.FaceNormals.ComputeNormals() and then Mesh.UnifyNormals(), and I tried it the other way around, as well as doing Mesh.Normals.ComputeNormals() in there too, but the boundary mesh still comes out flipped...

Am I nuts or is there a proper way of computing outward-facing mesh normals?!

There's some more off in triangulation mode: i.e.: several stray verts appear inside a triangulated vanilla [Mesh Box].
I imagined the output description to change according to the set integer flag.
Would it not be more logical to have flag 0 be triangulation, the 1 be all tetras, 2 be tetra verts indices and 3 be tetra edge start/end verts indices? It's hard to say you are nuts or not (I guess a little bit;)) without the code. Have you tried mesh.FaceNormals.ComputeFaceNormals?

Solved the stray points and (hopefully) the outward-facing normals.

Replace this .dll...

Attachments:

The original upload (tetgen.zip) has been updated with some fixes to TetgenGH.gha and TetgenRC.dll.

However, all my images were vandalized by McNeel this last week, so most of my descriptions are now nonsensical, here. Even screenshots of scripts are gone, all my inline images, nuked.

Vandalized? I've seen them explain multiple times the issue. You were banned for breaking forum rules (posting gore among other things) So shouldn't you be thankful they unbanned you? It's not like you got banned for the lol's. Also, when a mod or whoever deletes an image post from NING the entire post disappears completely (unlike yours which are blank images but still have description and title) which is obviously some sort of ban to unban bug. They told you it seems like the NING servers are clearing out the images (probably because you were marked as a banned or removed user). Isn't the real lesson here to just not do things that are gonna get you banned, despite whatever forum argument you are having that day? 

...most of my descriptions are now nonsensical...

This is accurate.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service