xtk / X

The X Toolkit
http://www.goXTK.com
Other
786 stars 263 forks source link

VTK Parser throws unhandled exception when trying to load empty mesh file #212

Open chucksspencer opened 4 years ago

chucksspencer commented 4 years ago

Hi there. We're attempting to use this library as part of an automated process that sometimes emits empty .vtk files. When we attempt to add a X.mesh from one of these empty .vtk files into a renderer3D object, the parser is throwing an unhandled error.

The do-while loop on line 442 of parserVTK.js doesn't check to see if the _geometries array is empty at the top of the loop - resulting in an error trying to access the length property of undefined on line 446.

I tried switching it to a while loop, and I also tried just returning if the _geometries array is empty - but in both cases it seemed to break other things - there are side effects happening that I don't understand.

It's worth noting that in our case this mesh is a child object of a parent mesh.

It'd be great to check the .vtk file to see if the mesh is empty, but since the Mesh object isn't really initialized until this parsing happens (and the exception happens), we're having trouble figuring out a good way to check the file. Ideas welcome.