# [OpenSCAD] Discuss manifoldness, co-incident faces edges etc

Doug Moen doug at moens.org
Thu Nov 14 10:13:25 EST 2019

```On Thu, Nov 14, 2019, at 8:39 AM, Ronaldo Persiano wrote:
> @doug
>
> How a self-intersection could be repaired? Before figuring a process out to do it I need to understand what outcome the process should have. What would be the repair of the linear_extrusion of a single polygon tracking the figure of an 8?

I have never written a mesh repair algorithm, so I'm not an expert.

A mesh is self intersecting if any two faces intersect. Repairing the intersection of two faces involves splitting both faces into smaller triangles.

In a linear extrusion of a figure "8", there will be two rectangular faces that intersect, and these each need to be split into two smaller rectangles.

If I was doing this, then I would add a `repair_self_intersections` module to OpenSCAD, using C++. I would call the libIGL API for repairing self intersections. I wouldn't attempt to implement the algorithm myself. Then I would apply the `repair_self_intersections` module to the linear extrusion of a figure 8, and see what the output looks like.

Note: According to my intuition, a repair algorithm would need topology information (a vertex table), and it would require the mesh to be manifold, in order to succeed.

Note: In the polygon shaped like an "8", if there is a single point in the "points" list at the location where the lines cross, and if this point is referenced twice in the path, then the polygon is not manifold. The linear extrude of a non-manifold polygon creates a non-manifold mesh. I would expect the repair process to fail. To make the polygon manifold, each point in the points list must be referenced only once in the path. With the current design of OpenSCAD, you also need to ensure that there are no duplicated points in the points list, which means that the point at the location where the lines path cannot be a vertex. This puts some otherwise valid polygons off limits in OpenSCAD. In the future, OpenSCAD should preserve the topology information in the representation of polygons and meshes. With this change, it will be possible to have duplicated points in the points list.

-------------- next part --------------
An HTML attachment was scrubbed...