Skip to content

STL reading of binary files > 2Gb

Summary

stl files > 2Gb cannot be read

Steps to reproduce

Run below python script (thanks Devin West) to generate a big surface in binary stl:

import numpy
from stl import mesh
safe_size = False
if safe_size:
    numTris = 42949000 #should be a safe size
    fname = "safe_size.stl"
else:
    numTris = 42949773 #should be over two GB
    fname = "unsafe_size.stl"
#create the empty stl data
data = numpy.zeros(numTris,dtype=mesh.Mesh.dtype)
#replace stl data with random triangles
for indx in range(numTris):
    data['vectors'][indx] = numpy.random.rand(3,3)*10
#create the stl mesh
my_mesh = mesh.Mesh(data, remove_empty_areas=False)
#save the stl file
my_mesh.save(fname)

Run

surfaceConvert unsafe_size.stl unsave_size.obj

It will fail trying to detect the binary-ness. Happens with 32 and 64 bit labels.

(See also https://exchange.openfoam.com/node/2458)

Environment information

  • OpenFOAM version : v2312

Possible fixes

@mark