Error when saving 2d rendering



  • Hello, I made a script to slice a volume into 2 axis interlocked net, it's the second part of my crafting process. I already had a V1 version but there were too many cases where the script produced the unmanageable error "Polygon is self intersecting" and I was happy that this error disappeared with V2. My original script still work fine and save to svg, so it is not a regression, but with another volume (required from a .obj ) "too much recursion" error is thrown when trying to save (to svg or dxf). At first, the error was "shape is not closed" but now the only error I have is this recursion one. It might be link to the fact that I use require to include the volume from an external file ? I can try to use my function to put it into a function to see if it works.
    Capture d’écran de 2020-11-13 09-25-09.png



  • @z3dev Thanks a lot for your suggestions, I will try to implement them. I have some marginal cases where it will certainly help to have exact vertices



  • @gilboonet thanks for the information.

    I looked over the design and have a few suggestions.

    Alway use toPolygons() to obtain the polygons, as this function will apply any transforms before returning the polygons.

    //P = geom.toPolygons();
    P = geom.polygons;
    

    The vol2surf() function is creating 2D points from 3D points, which is fine. However, the toOutlines() function requires 'exact' equal 2D points while finding the outlines.

    In addition, when performing the 2D boolean operations, the 2D geometry is converted to 3D geometry, and converted back to 2D geometry. There's a function called fromFakePolygons() that performs the conversion from 3D to 2D. (booleans/fromFakePolygons.js)

    I think the vol2surf() function should call this function, as there's some 'snapping' applied to the 2D points. If that's not possible then the vol2surf() function should apply some 'snapping' like line 24.



  • @gilboonet I rechecked today, trying to see if it was not an issue caused by the big size of my model (it's a small furniture model of 500x360x400) and render (with unions) it half size. It was ok, so I tried to render it full size and it was also ok. That is good news for me because otherwise I would had have lots to do on Inkscape to make the render without union usable for lasercut.



  • @z3dev Yes, the error appears into toOutlines()
    Capture d’écran de 2020-11-13 11-06-01.png

    If you can't reproduce this error with simple shapes, my code is here :
    https://github.com/gilboonet/designs/blob/master/index_v1_33.js
    (to make the error appear, switch lines 88/89 and 93/94 to uncomment unions)



  • @gilboonet JSON will not help in the conversion.

    I checked. The DXF serializer is also using geom2.toOutlines()



  • @gilboonet there's function called geom2.toOutlines() which converts the 2D geometry into a series of paths (path2). this is required when exporting to SVG (and DXF). i suspect that this function may be the cause of the issue when all the surfaces are unioned together.

    i'll try to reproduce with some simple shapes.



  • Apparently, the interlocking creates surfaces with notches that are too nested for svg/dxf export. When I export slices without notches, it works, and also when only exporting the first slice with its notches, but if I try to export the second one too, the "too many recursions" error pops. On my interlocking code, If I returned surfaces without "unioning" them, it can be saved to svg. Then with Inkscape I can select each slice and combine the segments to obtain the slices with their notches. At last it works.

    Capture d’écran de 2020-11-13 11-47-53.png



  • With the volume as a function into the script, there's the same behaviour : It cannot save to svg nor dxf. But it saves to json. Is there a way to convert data from this .json to svg ?


Log in to reply