linus131 / StlSlicer

Slice stl file and generate movepath
MIT License
2 stars 0 forks source link

Memory allocation issue #2

Closed yvanblanchard closed 1 year ago

yvanblanchard commented 1 year ago

Hello,

I have a large input STL mesh file (binary, 325MB, with 6.5M polygons), but the system hangs and in the console it says that a bad memory allocation happened. Did your slicer works/suitable for such large meshes ?

Thank you

yvanblanchard commented 1 year ago

I did another test on another STL mesh, but smaller, and I get the same error in console: image

The common thing between this smaller and bigger mesh file, is it's a non-connex and manifold surfacic mesh. Is it supported by your algorithm ?

image

Here is the STL file: NidaSurf.zip

linus131 commented 1 year ago

Hi Yvan, The program can slice the STL file that you included. I am attaching the screenshot of the output and a plot of the sliced segments. Since the STL mesh has open areas (not a closed surface), the slicing lines generated will not be closed.  Much better-sliced contours can be generated by repairing the STL file. I am attaching a screenshot of repaired segments as well.

Edit: I opened the stl file via a STLViewer program that autocorrected the STL file. That was why I was able to slice the program. The problem with the provided STL file is that it reports that it has 1,970,216,992.

Best Regards,Sunil On Thursday, March 23, 2023, 01:45:25 PM EDT, Yvan Blanchard @.***> wrote:

I did another test on another STL mesh, but smaller, and I get the same error in console:

The common thing between this smaller and bigger mesh file, is it's a non-connex and manifold surfacic mesh. Is it supported by your algorithm ?

Here is the STL file: NidaSurf.zip

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

yvanblanchard commented 1 year ago

Hi Sunil,

Thank you for your reply. But I can't see the attached data in your reply (?).

And I'm not sure to understand why it does not work at my side. Is it how I compiled the sources ?

I know that this input STL mesh is not closed, and that would lead to open contours, but it's not a big deal for me (the results will not be used to build a slice surface t be filled by a toolpath).

linus131 commented 1 year ago

Hi Yvan,

The problem I came across is that the program reads the number of triangles as 1,970,216,992. Since the program tries to allocate memory to read about 2 billion triangles, and the computer does not have that much memory available (about 200 GB), the program reports that it cannot allocate the memory.

The first 80 bytes in a binary stl file is the header data which can be read as 80 uint8 or char. The next 4 bytes are read as uint32 which should be equal to the number of triangles in the file. But in the provided stl file, it is about 2 billion. I think that the error is propagated from the program that produced the STL file.

yvanblanchard commented 1 year ago

Thank you Sunil. I checked at my side, by opening the STL mesh file in MeshLab then exporting to STL again (so , new STL file generated), and it works fine now. Thank you again for your help.