diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f52a3ef --- /dev/null +++ b/Dockerfile @@ -0,0 +1,58 @@ +FROM python:3.6 + +RUN apt-get update && \ + apt-get install -y \ + automake \ + bison \ + build-essential \ + cmake \ + libboost-dev \ + libgl1-mesa-dev \ + libglu1-mesa-dev \ + libharfbuzz-dev \ + libpcre3-dev \ + libsm6 \ + wget + +WORKDIR /tmp/build + +ARG SWIG_VERSION=3.0.9 +ARG FREETYPE_VERSION=2.6.3 +ARG OCE_VERSION=0.18.3 +ARG SMESH_VERSION=6.7.6 +ARG PYTHONOCC_CORE_VERSION=0.18.1 + +COPY build-files/build_swig.sh /tmp +COPY build-files/build_freetype.sh /tmp +COPY build-files/build_oce.sh /tmp +COPY build-files/build_smesh.sh /tmp +COPY build-files/build_pythonocc_core.sh /tmp + +copy convert-stl.py / + +RUN chmod +x ../*.sh +RUN chmod +x /convert-stl.py + +RUN ../build_swig.sh $SWIG_VERSION +RUN ../build_freetype.sh $FREETYPE_VERSION +RUN ../build_oce.sh $OCE_VERSION +RUN ../build_smesh.sh $SMESH_VERSION +RUN ../build_pythonocc_core.sh $PYTHONOCC_CORE_VERSION + + + +WORKDIR / + +RUN apt-get remove --auto-remove -y \ + automake \ + bison \ + build-essential \ + cmake \ + libboost-dev \ + libpcre3-dev \ + wget && \ + rm -rf /var/lib/apt/lists/* + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..82da4d3 --- /dev/null +++ b/action.yml @@ -0,0 +1,20 @@ +name: '.STEP to .STL Action' +description: 'Convert videos in the folder to the given format' +inputs: + step-file: + description: 'original file' + required: true + default: '' + output-folder: + description: 'Folder in which converted file is stored' + required: true + default: 'output' +outputs: + time: # id of output + description: 'The time we greeted you' +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.file }} + - ${{ inputs.output-folder }} \ No newline at end of file diff --git a/build-files/build_freetype.sh b/build-files/build_freetype.sh new file mode 100644 index 0000000..55cc3ed --- /dev/null +++ b/build-files/build_freetype.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +FREETYPE_VERSION=$1 + +wget -q https://download.savannah.gnu.org/releases/freetype/freetype-$FREETYPE_VERSION.tar.gz +tar -xf freetype-$FREETYPE_VERSION.tar.gz +./freetype-$FREETYPE_VERSION/configure +make +make install +rm -rf * .* +echo -en "\007" + diff --git a/build-files/build_oce.sh b/build-files/build_oce.sh new file mode 100644 index 0000000..e59b6fb --- /dev/null +++ b/build-files/build_oce.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +OCE_VERSION=$1 + +wget -q https://github.com/tpaviot/oce/archive/OCE-$OCE_VERSION.tar.gz +tar -xf OCE-$OCE_VERSION.tar.gz +cmake ./oce-OCE-$OCE_VERSION +make -j$(nproc --all) +make install/strip +rm -rf * .* +echo -en "\007" + diff --git a/build-files/build_pythonocc_core.sh b/build-files/build_pythonocc_core.sh new file mode 100644 index 0000000..b087f77 --- /dev/null +++ b/build-files/build_pythonocc_core.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +PYTHON_OCC_CORE_VERSION=$1 + +wget -q https://github.com/tpaviot/pythonocc-core/archive/$PYTHON_OCC_CORE_VERSION.tar.gz +tar -xf $PYTHON_OCC_CORE_VERSION.tar.gz + +cmake ./pythonocc-core-$PYTHON_OCC_CORE_VERSION \ + -DPYTHON_INCLUDE_DIR=/usr/local/include/python3.6m \ + -DPYTHON_LIBRARY=/usr/local/lib/libpython3.6m.so \ + -DPYTHONOCC_WRAP_SMESH=TRUE + +make -j$(nproc --all) +make install +rm -rf * .* +echo -en "\007" + diff --git a/build-files/build_smesh.sh b/build-files/build_smesh.sh new file mode 100644 index 0000000..36a0d1a --- /dev/null +++ b/build-files/build_smesh.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +SMESH_VERSION=$1 + +wget -q https://github.com/tpaviot/smesh/archive/$SMESH_VERSION.tar.gz +tar -xf $SMESH_VERSION.tar.gz +cmake smesh-$SMESH_VERSION +make -j$(nproc --all) +make install +rm -rf * .* +echo -en "\007" + diff --git a/build-files/build_swig.sh b/build-files/build_swig.sh new file mode 100644 index 0000000..5a4927d --- /dev/null +++ b/build-files/build_swig.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +SWIG_VERSION=$1 + +wget -q https://github.com/swig/swig/archive/rel-$SWIG_VERSION.tar.gz +tar -xf rel-$SWIG_VERSION.tar.gz +cd swig-rel-$SWIG_VERSION +./autogen.sh +cd .. +./swig-rel-$SWIG_VERSION/configure +make +make install +rm -rf * .* +echo -en "\007" + diff --git a/convert-stl.py b/convert-stl.py new file mode 100644 index 0000000..e3b7e91 --- /dev/null +++ b/convert-stl.py @@ -0,0 +1,20 @@ +from OCC.STEPControl import STEPControl_Reader +from OCC.StlAPI import StlAPI_Writer +import sys + +input_file = sys.argv[1][0] +output_file = sys.argv[1][1] + + +step_reader = STEPControl_Reader() +step_reader.ReadFile( input_file ) +step_reader.TransferRoot() +myshape = step_reader.Shape() +print("File read") + +# Export to STL +stl_writer = StlAPI_Writer() +stl_writer.SetASCIIMode(True) +stl_writer.Write(myshape, output_file) +print("Written") + diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..5db73fb --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,20 @@ + +#!/bin/sh -l + +OIFS="$IFS" +IFS=$'\n' +for IN in `find $1 -iname "*.*"` +do +OUT=${IN/$1/$3} +DIR=$(dirname $OUT) +FILE_NAME="${IN##*/}" +FILE_EXTENSION="${FILE_NAME##*.}" +FILE_TYPE=".stl" +mkdir -p "$DIR" + +echo "Converting $IN" +python convert-stl $IN ${OUT/$FILE_EXTENSION/$FILE_TYPE} + + +done +IFS="$OIFS" \ No newline at end of file