JSCAD User Group
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Error when saving 2d rendering

    Scheduled Pinned Locked Moved General Discussions
    9 Posts 2 Posters 1.6k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • gilboonetG Offline
      gilboonet
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • gilboonetG Offline
        gilboonet
        last edited by

        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 ?

        z3devZ 1 Reply Last reply Reply Quote 0
        • gilboonetG Offline
          gilboonet
          last edited by gilboonet

          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

          z3devZ 1 Reply Last reply Reply Quote 0
          • z3devZ Offline
            z3dev @gilboonet
            last edited by z3dev

            @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.

            gilboonetG 1 Reply Last reply Reply Quote 0
            • z3devZ Offline
              z3dev @gilboonet
              last edited by

              @gilboonet JSON will not help in the conversion.

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

              1 Reply Last reply Reply Quote 0
              • gilboonetG Offline
                gilboonet @z3dev
                last edited by

                @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)

                gilboonetG z3devZ 2 Replies Last reply Reply Quote 0
                • gilboonetG Offline
                  gilboonet @gilboonet
                  last edited by

                  @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.

                  1 Reply Last reply Reply Quote 0
                  • z3devZ Offline
                    z3dev @gilboonet
                    last edited by z3dev

                    @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.

                    gilboonetG 1 Reply Last reply Reply Quote 0
                    • gilboonetG Offline
                      gilboonet @z3dev
                      last edited by

                      @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

                      1 Reply Last reply Reply Quote 0

                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                      With your input, this post could be even better 💗

                      Register Login
                      • First post
                        Last post
                      Powered by NodeBB | Contributors