How to select internal faces of an object

Good morning,
It may seem like something so simple to select the internal faces of an object, but I have been researching for several hours and I can’t find a way to do it. Does anyone have a clue where I can start?
Basically I need to select all the faces that are not visible that due to some modeling error were left inside.

I attach an image so that you understand what I mean. Thanks a lot

If the internal faces are attached to other faces of the object (not just separate and totally inside, like your picture), there is a “Select All By Trait > Interior Faces” on the Select menu in Edit mode.

If you just want to remove the interior things, and the outer object is nice and manifold and volume enclosing (unfortunately, Suzanne is not), the you could try using Exact Boolean, with Self and no operand at all, the Union operation, and it should remove the interior stuff.

in edit mode, select a single vertex on suzanne’s surface. Hit Ctrl L to select all connected vertices. Now hit Ctrl I to select the inverse (anything not selected) you should have it. You may want to turn on xray mode.

Hello, sorry if I did not know how to explain my problem.

Imagine that you have one geometry that intersects another, then you combine both geometries. Now internally there are faces that are not visible and need to be removed.

Obviously I can do that with a Boolean Intersect operation, but let’s say that the objects are already combined, also there are many objects to which you have to do that.
I think there must be a way to do it by begging Python.

I attach a reference image.

Hi Howardt.
Boolean operation doesn’t work and neither does selecting inner faces, I tried but it doesn’t work for me

This is harder than it feels it should be to program. I have been working on a similar thing in C++ right now, trying to make Exact Boolean behave better when operands are not all manifold/volume enclosing.

The way I’m trying now is: from a point on a face to be tested, shoot six rays in approximately (but not exactly) the six axes ± directions and for each ray, add up the parity of the faces hit (positive parity if it goes through the face from the non-normal facing side, else negative parity). Add up the parities and divide by six, and use some number (e.g., .7) as the threshold for deciding “inside”. Using BVH trees speeds up the ray shooting enormously if the models are big.

this will delete everything inside suzanne.

  1. edit mode
  2. select a vert on suzanne
  3. ctrl L
  4. hit p, choose ‘selection’
  5. object mode
  6. select newly created suzanne object
  7. edit mode, select all verts, mesh menu, normals, flip
  8. add a cube (still in edit mode) and scale cube larger than everyhting else in scene)
  9. object mode, select original object,
  10. add boolean modifier, choose ‘intersect’ and set the 2nd object within modifier
  11. apply modifier

Howardt, I feel like that may be the way, however in python-blender I have no idea where to start.
If you have any clue that is helpful, I will thank you forever, good man. :slight_smile:

Start be reading about the Python API for BVH trees.

You would want to build one using FromBMesh.

Then loop through all the faces f of your mesh. For each, find a point p in it (the centroid, say, though that is not exactly right for some weirdly shaped faces). The use the bvhtree’s raycast function using p as origin and trying several directions as I suggested above. I haven’t tried this, but it looks like it will return a tuple of hits on faces with the index being the index of the face hit (I hope - you should try to see). Using that you can either just count hits, or if you want to do the parity calculation, you need to know how the ray direction compares with the normal direction of the hit face (maybe the normal result in the raycast result vector is the normal of the hit face, which would make this easy).

P.S., the reason I suggest using directions that are a little off from (±1, 0, 0), (0, ±1, 0), (0, 0, ±1) is that the way models are typically built, it is often quite likely that rays in those directions will hit the seams between faces, which may result in those hits being reported for both faces or neither (I’m not sure about the latter - depends on whether or not the internal code is using “watertight” ray casting).

Select interior faces (AO bake)

This solution is based on AO map baking. Normaly you would want to do a “bake to vertex” but this is not possible right now in b2.8. So, I am baking to image and then I am interpolating face/vertex position inside the UV map. Everything completely black in the AO map is hidden behind some geometry. For some reason, the baker is leaking light sometimes in areas where it should not be. You might get some false selection here. I am still trying to figure this one out.

Screenshot

Gorion103, Thank you very much my dear, this is much closer to what I was looking for, it had not occurred to me to do it with a BakeMap.

Howardt what you propose also sounds very interesting, without a doubt there is a lot of mathematics here to lock me up to study in this quarantine. :slight_smile: