Triangle add-on for Blender

Triangle: A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator.


Note the interior circle in the image above which uses a normal Bezier curve (two circles) as input.

From the website:

Triangle generates exact Delaunay triangulations, constrained Delaunay triangulations, conforming Delaunay triangulations, Voronoi diagrams, and high-quality triangular meshes. The latter can be generated with no small or large angles, and are thus suitable for finite element analysis.

This is a Python wrapper for the Triangle library referenced above. It uses ctypes. The add-on adds a ‘Triangulate’ operator (and button!) to Blender, which can take any planar meshable object (curves and meshes) and create a triangulated mesh based on specified input parameters.

Input parameters are provided via a text field and are described in the Triangle documentation.


Further work could be done to expand functionality and add support for meshing Ngon faces or some other way of operating out of the XY plane, but for now it is limited to this.

This is especially useful for creating meshes for sculpting or meshes with good face densities from 2d CAD data, for arch. viz or other uses. Interior edges are respected, meaning creating dense meshes with interior regions is possible.

UPDATE 190514

  • Fixed issue with crashes on newer Windows versions.
  • Added Linux support.
  • Regions and holes can be implemented, but I just need to figure out the best way of controlling / exposing this in Blender…

UPDATE 171208:

  • Added checkboxes and clearer options in the UI, with the option of specifying a argument string instead.
  • A vertex group (Triangle Boundary) is added to the new mesh, which contains all the original vertices from the input mesh / curve. This is great, but when edges are split / vertices are inserted between input vertices, these don’t get included. One option would be to keep track of input edges, and find the mesh shortest path between the ends after triangulation, and add these new vertices to the vertex group as well.

LINK: https://github.com/tsvilans/bpy_triangle

19 Likes

seems like it could be handy for text objects too. Converting text to a mesh often leaves you with lots and lots of skinny triangles.

Getting an error when running the operator on curves/meshes (doesn’t show panel either). Also you might want to include common parameters as enum presets for better ease of use.


This is super useful for cloth!

1 Like

Interesting. Some of the args for the entry box look like switchable functions or perhaps toggles. (Or at least it would make sense without understanding all the details, seems a bit technical.) Any chance it will be given a proper UI and some half-decent starting presets in regards to values? That would make it easier for people to play around with, might even be able to control-scroll and watch changes on the mesh like other Blender functions which would be awesome.

Hey, thanks for checking it out. Can you send me the file + params? I’ll try to find time to take a look. Contact info on the Github page…

Yep, the input string is a collection of flags and settings, described in the Triangle documentation, so it IS a bit technical at the moment…

I will try to find some time to expose them through a better UI soon.

Check out http://www.cs.cmu.edu/~quake/triangle.switch.html for info about the switches for now.

That’s a good point, I hadn’t thought too much about cloth! Would be cool to see how this could be combined with cloth simulation, esp. vertex groups for goals and such…

dll file… hi, will you make a linux port?

The params are default (invoked from panel). The meshes are two mesh circles with different sizes. Not too sure what actually causes the error. Also after messing around a bit I’m getting the same error but from return createMesh(out_mesh)

Cool, can you send them to me anyway? Sounds weird…

Haven’t got experience with compiling for Linux, but could give it a crack when I get some time. Alternatively, if someone wants to compile Triangle as an .so library and send it to me, I could see how to make it work on the Python side?

Was really surprised to see how well did it work heh.

There is a lot you can build upon it. For a start it could be super useful to have original vertices grouped in separate vertex group after the object creation, so that you can easily shrinkwrap it back to the original (3D) shape (can be also automated).

Thanks for this, I really like it.

UPDATE. See first post.

Check out the update. It has basic vertex group support now.
Triangulate -> Add Cloth / Softbody modifier -> Set goal to ‘Triangle Boundary’ vertex group

I’m getting error when clicking triangulate buttom. can you help me?

using last update.

blender 2.79.1 -> windows 10 x64 -> intel i7

res = dll.triangulate(args.encode('utf-8'), ctypes.byref(in_mesh), ctypes.byref(out_mesh), ctypes.byref(vor_mesh))

OSError: exception: access violation writing 0x00000000250A5890

location: <unknown location>:-1

Also noticed triangle.py has tabs as whitespace instead of 4 spaces, you might want to fix that. And usually you post addons in Released Scripts instead of Latest News. :stuck_out_tongue:

I’m getting the same thing, seems like my system doesn’t like dll.triangulate(). The actual arguments seem fine though when printing them.

Ok, that’s probably a better place for this thread. Any idea how to get it moved?

For these DLL problems, make sure to install the MS Visual C++ Redistributable 2015, since that’s what the library is compiled against. See if that helps…

Could you post the file?

Yes, I can, but it is very simple… two bezier circles only or one bezier closed curve. I open blender, I delete default box mesh and add circle shape, after to click on triangulate button I get the dll error.

Trying install vs 2015 redistributable, windows say I already have it installed.