Git Product home page Git Product logo

inp2stl's Introduction

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

inp2stl's People

Contributors

effepivi avatar codacy-badger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.