Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rcooke-warwick committed Jun 16, 2020
1 parent 5c2b098 commit 59a33b0
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 0 deletions.
58 changes: 58 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
20 changes: 20 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
12 changes: 12 additions & 0 deletions build-files/build_freetype.sh
Original file line number Diff line number Diff line change
@@ -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"

12 changes: 12 additions & 0 deletions build-files/build_oce.sh
Original file line number Diff line number Diff line change
@@ -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"

17 changes: 17 additions & 0 deletions build-files/build_pythonocc_core.sh
Original file line number Diff line number Diff line change
@@ -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"

12 changes: 12 additions & 0 deletions build-files/build_smesh.sh
Original file line number Diff line number Diff line change
@@ -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"

15 changes: 15 additions & 0 deletions build-files/build_swig.sh
Original file line number Diff line number Diff line change
@@ -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"

20 changes: 20 additions & 0 deletions convert-stl.py
Original file line number Diff line number Diff line change
@@ -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")

20 changes: 20 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 59a33b0

Please sign in to comment.