CADMesh icon indicating copy to clipboard operation
CADMesh copied to clipboard

Error when loading .stl-files produced on Windows

Open HenningManke opened this issue 3 years ago • 4 comments

Within my working group we have been using CADMesh for a while now. It worked totally fine for all .stl files we produced by ourselves on MacOS. Now we are looking into another project, in which the .stl files are produced by the design office of our university. The design offices uses Windows and now the import of those .stl files gives an error:

-------- EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : LexerError
      issued by : CADMesh in Lexer

The CAD file appears to contain incorrect syntax:
	Error around line 1: STL files start with 'solid'.

*** Fatal Exception *** core dump ***
 **** Track information is not available at this moment
 **** Step information is not available at this moment

-------- EEEE -------- G4Exception-END --------- EEEE -------

The funny thing is: the original stl file starts with 'solid' as well. If I produce an empty .stl file on MacOS or even our cluster (Centos), and copy and paste whatever is written in the original .stl file, it all works again. So it has the same syntax and I didn't change anything written in that file.

My first guess is, that the windows stl file has some metadata or so, that CADMesh can't handle. Did you observe anything similar or do you know what's the actual problem?

HenningManke avatar Feb 19 '21 12:02 HenningManke

It could be as simple as not parsing the characters Windows uses to indicate the end of a line (CR LF, i.e., \r\n) vs. what Linux and MacOS use to indicate a newline (\n); see: newline characters. First thing to try would be to see if there is a difference in newline characters and convert those in your file, and try to load again.

jllanfranchi avatar Mar 15 '21 21:03 jllanfranchi

Thanks @jllanfranchi I think you are right, I will sort something out for this.

christopherpoole avatar Mar 16 '21 06:03 christopherpoole

Converting the *.stl files end of line (use dos2unix command) does not fix the problem. I have tried to change from upper case tokens to lower case tokens and I've got the same error with my STL files and with the 'bunny.stl' file.

@christopherpoole can you import 'bunny.stl'?

To me it seems the STL reader cannot parse the file.

dragos000 avatar Apr 15 '21 04:04 dragos000

UPDATE: The error text is misleading. In my case the path to the file was misspelled so the program could not find the STL file.

I am not sure why the program return an error about the file syntax. The error reporting needs to be fixed.

BTW it does not matter the end of line character. It works with both types of ASCII STL files, i.e. UNIX and Windows files.

I use Geant4 v10.07.p01 and CADMesh 2.0.3 on CentOS 7.

dragos000 avatar Apr 15 '21 05:04 dragos000