effepivi / inp2stl

Python script to convert a file in Abacus' INP format into the STL (STereoLithography) file format
BSD 3-Clause "New" or "Revised" License
2 stars 2 forks source link

inp2stl

Codacy Badge

Python script to convert a file in Abacus' INP format into the STL (STereoLithography) file format

Requirements

Install the requirements if needed using:

$ python3 -m pip install --user numpy

Usage

inp2stl.py [-h] --input INPUT --output OUTPUT [--flip [FLIP]]

Detect peas.

optional arguments:
  -h, --help       show this help message and exit
  --input INPUT    Name of the input INP file.
  --output OUTPUT  Name of the output STL file.
  --flip [FLIP]    Flip normal vectors.

Example

$ wget https://ndownloader.figshare.com/files/10269141
$ mv 10269141 male_model.inp
$ ./inp2stl.py --input male_model.inp --output male_model.stl

The mesh visualised using MeshLab when the normal vectors were not flipped.

It's not pretty, isn't it?

$ ./inp2stl.py --flip --input male_model.inp --output male_model.stl

The mesh visualised using MeshLab when the normal vectors were flipped.

Case study: X-ray simulation using gVirtualXRay

export the mesh as

I added `-bin` at the end of the filename

Make sure the format is binary

The file name should be much smaller than the ASCII file

$ ls -l male_model*.stl
-rw-r--r-- 1 franck users  5738284 Aug 19 16:29 male_model-bin.stl
-rw-r--r-- 1 franck users 27048282 Aug 19 16:28 male_model.stl

See...

The Python wrapper is installed in `/home/franck/gvxrWrapper-1.0.1/python3 on my computer.

$ cd /home/franck/gvxrWrapper-1.0.1/python3
$ ls
gvxrPython3.py  _gvxrPython3.so  test.py
$ echo "" >> ~/.bashrc
$ echo "# Install of gvxrPython3" >> ~/.bashrc
$ echo "export PYTHONPATH=/home/franck/gvxrWrapper-1.0.1/python3:$PYTHONPATH" >> ~/.bashrc
$ ./gvxrPythonTest.py