Convert planar faces to polygonal representations with inner loops
For the sake of 2D nesting we need realistic 2-dimensional parts with optional inner loops. Mobius (www.openmobius.org) comes with a JSON format that has to be respected. Here is one example:
{
"name": "a",
"outerPolygon": [[0, 0], [1, 0], [1, 1], [0, 1]],
"innerPolygons": {
"i0": [[0.25, 0.25], [0.35, 0.25], [0.35, 0.75], [0.25, 0.75]],
"i1": [[0.45, 0.25], [0.75, 0.25], [0.75, 0.75], [0.45, 0.75]]
},
"count": 1,
"angleStepDeg": 15
}
The properties count and angleStepDeg can be initialized with reasonsble defaults, e.g. 1 and 15 respectively.
There is already a similar function named misc-convert-curves-poly (https://analysissitus.org/commands.html#misc-convert-curves-poly, see also #326 (closed)) that works on a single wire (contour). Let's introduce another command named misc-convert-face-poly that would work as follows:
- If a face ID is provided, it uses the passed ID of the target face to convert.
- If no face ID is provided, the currently selected face is taken from the viewer.
- If a filename is provided, the dump is serialized to the specified file.
- If no filename is provided, the dump is rendered in the JSON UI dialog as we usually do.
The discretization can be taken from the facets of the target face. If a face hasn't been meshed, the facets should be automatically generated with autoselected precision values.
See also: https://quaoar.su/blog/page/true-shape-nesting-11-back-to-2d-with-a-testing-workbench