3
$\begingroup$

Is there a way to fill an ngon with Tri's, a way to automate an operator to achieve the image on the right, it should also keep the borders untouched:

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Could try quad fill. ie after easy bit of removing internal geometry, leaving just boundary edges, make an edge from top to bottom with enough verts such that region boundary is multiple of 4 and quad fill. ... or similarly with inset & quad fill. $\endgroup$
    – batFINGER
    Jul 12 at 14:37
  • $\begingroup$ can you upload your blender file ? $\endgroup$ Jul 12 at 14:50
0
+50
$\begingroup$

As in this thread: blenderartists.org: Triangle Fill Addon Update For Blender 2.80, you can use Petteri Aimonen’s Triangle Fill add-on (direct link to v 2.8). There's also another add-on mentioned in the thread, Tom Svilans' Delaunay Triangulator (Github link), which is a Python wrapper of a C library - sadly it no longer works in Blender 2.8, but I put instructions how to make it work at the bottom.

Comparison:

  • leftmost: Petteri's solution is straight-forward, N Numbers Panel > Tools tab;
  • rightmost: grid fill will depend on mesh, you can enable statistics in Viewport Overlays then remove/add vertices (XD Dissolve / CtrlR Loop Cut) until their number is divisible by 4, then grid fill, maybe some loopcuts, CtrlT Triangulate;
  • middle: Svilan's add-on - as I said, it doesn't work; unfortunately I'm not into add-ons, but I migrated the heart of the add-on to 2.8 so it can be used without interface - just paste the code below to Scripting tab, modify the first line to change options, then save the script to the folder with the rest of the add-on files and run it (with objects selected):
args = "pq20a1ziV"

"""
Copyright 2017 Tom Svilans

http://tomsvilans.com

A Python wrapper / Blender add-on for Triangle:

/*  A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator.      */
/*  (triangle.c)                                                             */
/*                                                                           */
/*  Version 1.6                                                              */
/*  July 28, 2005                                                            */
/*                                                                           */
/*  Copyright 1993, 1995, 1997, 1998, 2002, 2005                             */
/*  Jonathan Richard Shewchuk                                                */
/*  2360 Woolsey #H                                                          */
/*  Berkeley, California  94705-1927                                         */
/*  jrs@cs.berkeley.edu                                                      */

Permission is hereby granted, free of charge, to any person obtaining a copy of this 
software and associated documentation files (the "Software"), to deal in the Software 
without restriction, including without limitation the rights to use, copy, modify, merge, 
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons 
to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies 
or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
DEALINGS IN THE SOFTWARE.

"""

import bpy, bmesh
from mesh_triangle.triangle import triangulate

C = bpy.context


def get_nonmanifold_edges(mymesh):
    culprits=[]
    for e in mymesh.edges:
            shared = 0
            for f in mymesh.polygons:
                    for vf1 in f.vertices:
                            if vf1 == e.vertices[0]:
                                    for vf2 in f.vertices:
                                            if vf2 == e.vertices[1]:
                                                    shared = shared + 1
            if (shared > 2):
                    culprits.append((e.vertices[0], e.vertices[1]))
            if (shared < 2):
                    culprits.append((e.vertices[0], e.vertices[1]))
    return culprits

def triangulate_object(obj_in, args):
    mesh_in = obj_in.to_mesh()  # pre 2.8 args: (bpy.context.scene, True, 'RENDER')
    verts = [x.co for x in mesh_in.vertices]
    Nv = len(verts)
    faces = [[y for y in x.vertices] for x in mesh_in.polygons]
    border = get_nonmanifold_edges(mesh_in)

    #if ('v' in args or 'D' in args):
    #    return triangulate(verts, faces, border, args, True)[1]
    res = triangulate(verts, faces, border, args)
    return (res[0], res[1], Nv)

def add_mesh(verts, faces, mesh_name, obj_name):
    bm = bmesh.new()
    for v in verts:
        bm.verts.new(v)
    bm.verts.ensure_lookup_table()

    for f in faces:
        bm.faces.new([bm.verts[x] for x in f])
    bm.faces.ensure_lookup_table()
    bm.verts.index_update()

    m = bpy.data.meshes.new(mesh_name)
    bm.to_mesh(m)
    bm.free()

    o = bpy.data.objects.new(obj_name, m)

    return o

def main():
    for o in C.selected_objects:
        (verts, faces, N) = triangulate_object(o, args)
        obj = add_mesh(verts, faces, o.data.name + '_triangulated', o.name + '_triangulate')

        original_verts = [x for x in obj.data.vertices[:N]]
        vg = obj.vertex_groups.new(name="Triangle Boundary")
        vg.add(range(N), 1.0, 'ADD')
        for v in original_verts:
            v.select = True

        obj.matrix_world = o.matrix_world
        C.collection.objects.link(obj)
      
  
main()
$\endgroup$
1
  • $\begingroup$ Sorry for the aliasing on edges, I didn't predict that scaling artifact. $\endgroup$ Jul 15 at 12:05
1
$\begingroup$

Vanilla Blender 2.93

I made myself a ngon.

Ngon

I used Face->Grid Fill on it adjusting the parameters go get the most even result

Grid Fill

Settings

Finally I used Face->Triangulate Faces

Tris

This approach is not universal. Grid fill requires even number of vertices.

$\endgroup$
0
$\begingroup$

No there is no command for it.
Though gridfill might get you close to the result.
though then you need to loop select the edge, invert selection (inner edges) then delete the inner.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.