[Solved] Avoid creating inconsistent triangulation when slicing a box by planes

My group had developed a Blender based addon - BlenderPhotonics - which can be used as a front-end for 3D tetrahedral mesh generation (by calling our Iso2Mesh toolbox in the backend). The details of this work can be found in our paper:

Our workflow involves creating complex models using Blender’s built-in functions, and then, joining all mesh objects and perform intersection The output triangular mesh is then feed to tetgen to perform volumetric mesh generation. The tetrahedral mesh generator (tetgen) is extremely sensitive and refuses to mesh any triangular surfaces that

  1. are not water-tight,
  2. have self-intersecting triangles, and
  3. contain inconsistent triangles (such as vertices ended up in the middle of any edge or faces).

I found that Blender 2.9+ is quite good at resolving intersections with the Exact solver enabled. However, I have struggled to slice box objects with plane objects to create a multi-layered structure.

Here is an example. The scene contains a box, a plane of matching size, and a cone. My goal is to create tetrahedral mesh from this scene.

By performing 1) converting all objects to mesh, 2) join all triangular meshes to intersect, I got the attached intersected mesh. You can see, Blender did a good job for both top and bottom planes, but the intersection of the middle-plane creates inconsistent triangles - the 4 highlighted vertices are located in the middle of the edge of the triangles on the bounding box. This makes my tetrahedral mesh generator unhappy.

My question is - why Blender inserts these 4 nodes in the first place? is there an option for Blender to refine all connected triangles if it decides to insert a new node in the middle of any edge? or, even better, not to insert these nodes at all (like the top/bottom planes)?

any suggestion on how to consistently mesh such cut structure would be appreciated!

enter image description here

1 Like

here are the related python code that automates the object joining, intersecting and converts to triangular mesh

just to give some idea on what is the expected “consistent triangulation” should look like in this geometry, here is a manually edited image. What are missing are these 8 red-colored edges. With these edges, there will be no vertex located in the middle of any edge (and faces).

is there an option for Blender’s triangle surface tessellation algorithm to produce such triangulation?

I don’t see any calls to ‘triangulate’ in the script. bmesh.ops.triangulate for example.

it is achieved using bpy.ops.mesh.quads_convert_to_tris() at the end of the quoted code section

ah, I see it now.

And you are sure that convtri was True when you generated the mesh above?

Maybe try what happens if you do a ‘merge by distance’ on the result?

If it really is a quad that’s not converted by bpy.ops.mesh.quads_convert_to_tris() that would be a bug I think. But it would surprise me if there was a bug in that. My guess would be on that quad having double vertices or something like that.

no, the problem was not there were quads that were failed to be converted to triangles - the output mesh contains entirely triangles, but it is not a valid triangulation - a valid triangulation requires all nodes to be located at the two ends of any edges, but not in the middle of an edge or a face.

a triangle with a vert in the middle of one of it’s edges is a quad?

Those 2 ‘triangles’ where you drew an extra (red) edge in are quads. A quad is any polygon with 4 vertices, the shape doesn’t matter.

no, they are not quads.

here I selected the two triangles that I had to split - see the “rogue node” sitting in the middle the shared edge of both triangles? this is not a valid triangulation, to convert it to valid triangulation, I have to add the red-edges.

After testing various blender versions, now I see that this invalid triangulation issue is only a brief regression introduced in Blender 3.0.x, and it does not show up in either older (2.92) or newer (3.4.1) versions.

Here is a comparison of 3 blender versions:

  • Top-left: 3.0.1: show incorrect triangulation (the 4 rogue nodes were selected)
  • Top-right: 3.4.1: show correct triangulation
  • Bottom-right: 2.92.0: show correct triangulation

Both 3.0.1 and 3.4.1 were installed on Ubuntu 22.04 Linux. 2.92 were tested on Ubuntu 18.04 and Windows.

To reproduce this, here are the steps:

  1. start a new general scene with the default cube
  2. add a plane object
  3. select both, right-click, select “join”
  4. switch to “Edit mode”, select Face->Intersect (Knife)-> select self-intersecting in the tool option dialog
  5. again in Edit mode, select Face->Triangulation

I will mark this question as solved as it does not show up in the latest release (3.4.1).

1 Like