Thanks to visit codestin.com
Credit goes to github.com

Skip to content
forked from effepivi/inp2stl

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

License

Notifications You must be signed in to change notification settings

Ttw0626/inp2stl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
  • Convert the INP file into an STL file:
$ ./inp2stl.py --input male_model.inp --output male_model.stl
  • Check the direction of the normal vectors, e.g. using MeshLab

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

It's not pretty, isn't it?

  • I've seen vertex ordering using left-hand rule and right-hand rule. It's why we can flip the normals, e.g.:
$ ./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

  • In MeshLab, export the mesh as a binary STL file.

export the mesh as

  • Use a different filename, e.g. I added -bin at the end of the filename.

I added -bin at the end of the filename

  • Make sure the format is binary

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
  • Install gvxrPython3

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
  • I add this path in PYTHONPATH in my .bashrc file with:
$ echo "" >> ~/.bashrc
$ echo "# Install of gvxrPython3" >> ~/.bashrc
$ echo "export PYTHONPATH=/home/franck/gvxrWrapper-1.0.1/python3:$PYTHONPATH" >> ~/.bashrc
  • Run the X-ry simulation:
$ ./gvxrPythonTest.py

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%