# Finding polys inside geometry

On 26/06/2015 at 16:41, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   16
Platform:   Windows  ;
Language(s) :     C++  ;

---------
Hello,

does someone knows an algorithm to find all polygons which are inside the geometry or has an idea to do that? My idea is to proof every poly if the front and the back are pointing to the backside of another poly.

would be nice, if someone has an idea

thanks
crush4

On 26/06/2015 at 17:15, xxxxxxxx wrote:

Not sure if I follow.  Are you looking to know if a polygon's normal/winding-order is reversed (pointing 'inside' a closed form)?  Or do you want to find polygons that are actually inside a closed geometry mesh?

On 26/06/2015 at 17:33, xxxxxxxx wrote:

Originally posted by xxxxxxxx

Or do you want to find polygons that are actually inside a closed geometry mesh?

this is what I want

On 26/06/2015 at 18:51, xxxxxxxx wrote:

Part of this may depend on the closed mesh behaving.  That is, all of the polygons' normals face outward on the surface.  If so, then instead of focusing on the entire polygon, you focus on the polygon's vertices (3D point inside mesh is a good search term in Google).  You may need to consider interpenetrating polygons, those that are mostly inside but have part going through the mesh to the outside or even just one point or edge coincident with an outside boundary polygon.

On 27/06/2015 at 07:09, xxxxxxxx wrote:

Thanks Robert for your advise. I figured out that cinema has a select function to select only visible polygons in the viewport. Would be nice to use that

On 27/06/2015 at 17:18, xxxxxxxx wrote:

The problem with that is that it is basically a user-interactive selection that only selects polygons visible at the current view of the viewport camera.  This will not benefit you unless you can cajole the user to go around the object and select all of the 'visible' external polygons themselves.

The real (and dangerous) problem is specifying the selection space between valid surface polygons and those that are internal is the myriad possible scenarios.  I have been considering this for a bit and it is daunting.  Unless your mesh in a convex, closed one, then determinations for 'internal' polygons become very difficult to resolve.  Consider that you have a concave mesh where part of the mesh dimples into the center of the object (e.g.: a bowling bowl with finger holes).  Are those polygons 'internal'?  Not really.  So what is the criteria?  Surface continuity could help.  Normal direction could help.  Polygon connection might help (disjoint polygons might be considered rogue and marked as such).  Convex hulls won't work with concave topologies.  You are going to need to implement algorithms incrementally and find a best way that is sub-optimal but optimal enough.  The determination space is filled with local minima and maxima.