3
$\begingroup$

I have a complex mesh that I have imported from a .obj file. I would like to check whether it is genus-0, i.e. whether there are any holes in the object. If there are such holes I need to fix them. I have tried searching by eye but it appears there must be rather small holes that are not obvious on inspection.

When I search for things like "Blender fill holes" the results appear to relate to holes in the mesh itself, i.e. involving edges that only have a single adjacent face. This is not what I am trying to do. For example, the standard mesh "Torus" has no holes in its mesh, but it has a big hole in the object itself, which is the kind of thing that I need to be able to fix.

$\endgroup$
2
  • $\begingroup$ I would consider a "remesh" under object data properties, depend on resolution (voxel size) you set it will fill the holes that are too small. But it will will completely ruin the topology. $\endgroup$
    – Fowl
    Mar 10 '20 at 14:13
  • $\begingroup$ That can be about finding features points on a mesh, eventually finding the skeleton so that the topological structure can be found. But this is (i think) still research projects. Or your case is particular? Could you provide an example? $\endgroup$
    – lemon
    Mar 10 '20 at 19:14
2
$\begingroup$

Assuming you do have a closed, clean, manifold surface, and you're looking for the number of genuine topological holes, you could use the surface's Euler Characteristic? (You'd better get Math SE to check me up on that one) .. anyway...

Object mode, select the object, run this snippet..

import bpy

ob = bpy.context.object
me = ob.data
v = len(me.vertices)
e = len(me.edges) 
f = len (me.polygons)
g =  1 - ((v - e + f)/2)

print(g)

.. and the genus is returned in g.

$\endgroup$
7
  • $\begingroup$ This is a very helpful start, thank you! Although ideally it would be great to know where the holes are located, this will presumably just tell me how many there are. $\endgroup$ Mar 10 '20 at 18:08
  • 1
    $\begingroup$ @user2390246 at first sight, a strict solution to finding the holes seems a bit of a job $\endgroup$ Mar 10 '20 at 18:55
  • $\begingroup$ @RobinBetts, yes... commented in the same way below the question... but would be something great to have!! $\endgroup$
    – lemon
    Mar 10 '20 at 19:15
  • $\begingroup$ @lemon ... can imagine a few (not strict) divide-and conquer strategies.. as you commented, a characteristic shape would help. $\endgroup$ Mar 10 '20 at 19:29
  • $\begingroup$ @RobinBetts, a tesselation? That can do, but still complex I think. But I you have some idea about it, please go!! Man, if we had that, it can be included to blender core code, I think... many applications. $\endgroup$
    – lemon
    Mar 10 '20 at 19:33

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.