# Projected convex hull in plane

Consider an object like this one: Is it possible to, and if it is how, automatically generate a body that is convex for every cut along the xy-plane, without destroying the radial variation in along the z axis.

I realize that this can be tricky do on a general mesh, where the edge loops are not strictly planar. Instead I thought that following approach could work:

1. Manually add some horizontal edge loops to a new mesh, at chosen z coordinate
2. Use the shrinkwrap modifier, with the non-convex mesh as target
3. Scale each loop such that all vertices within one loop has the z coordinate

Instead of shrinkwraping and scaling, it should also be possible create new loops by intersecting radial edges with horizontal planes. Anyhow, we have created a set of horizontal edges, that encloses the geometry well.

1. Apply the convhull operator on the edge loops individually
2. Connect vertices to generate new faces

If I am not wrong, it should be possible to script steps 2-5. Here tips on appropriate python APIs is of interest. However, the procedure fails after step 4, since the convhull operator pollutes the mesh with new, coplanar and overlapping faces, that I do not want. Is it possible to remove that extra geometry automatically?

## 1 Answer

I solved the problem with the following algorithm

1. Create N horizontal planes of appropriate size
2. For each plane
1. Apply the boolean modifier (intersect the plane with the target object)
2. Extrude the plane in the z direction, giving it some height
3. Apply the convex hull operator
4. Remove the extra plane created in step 2
5. Remove any vertices inside triangles
3. Merge planes into one object
4. Bridge the edge loops
5. Remove interior faces (they were left from the convex hull operator)

Here is the Python script with room for some improvements: https://gist.github.com/milasudril/960f5c2c4c3735f3fdea566cfdc003d9