-
Notifications
You must be signed in to change notification settings - Fork 2
/
freecad-diff
executable file
·50 lines (35 loc) · 1.31 KB
/
freecad-diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set -e
echo ">>> starting freecad-diff $@"
FREECAD=freecadcmd
[[ -n "$INTERACTIVE" ]] && FREECAD="env XDG_SESSION_TYPE= freecad"
BINARY_DIR="$(dirname $(realpath "$0"))"
MACROS_DIR="$BINARY_DIR"
if [[ "$BINARY_DIR" = "/usr/local/bin" ]]; then
MACROS_DIR="/usr/share/freecad/Macro"
fi
MODIFIED="$1"
PREVIOUS="$2"
PREVIOUS_DIR="$(dirname "$PREVIOUS")"
MODIFIED_DIR="$(dirname "$MODIFIED")"
export FREECAD_USER_HOME=$(mktemp -d /tmp/freecad.XXXXXXX)
freecadcmd -c 'import FreeCADGui as Gui; Gui.setupWithoutGUI()'
TMP=$(mktemp -d /tmp/meshdiff.XXXXXXXX)
rsync -rt "${MODIFIED_DIR}/" "${TMP}/modified/"
rsync -rt "${MODIFIED_DIR}/" "${TMP}/previous/"
rsync -rt "${PREVIOUS_DIR}/" "${TMP}/previous/"
OLD="${TMP}/previous/$(basename $PREVIOUS)"
NEW="${TMP}/modified/$(basename $MODIFIED)"
OLD_MESH="${TMP}/previous.step"
NEW_MESH="${TMP}/modified.step"
DIFF_MESH="${TMP}/diff-output.step"
$FREECAD ${BINARY_DIR}/freecad-export.py "${OLD}" "${OLD_MESH}"
$FREECAD ${BINARY_DIR}/freecad-export.py "${NEW}" "${NEW_MESH}"
$FREECAD ${BINARY_DIR}/freecad-diff.py "$NEW_MESH" "$OLD_MESH" "$DIFF_MESH"
rm -rf "${FREECAD_USER_HOME}"
if [[ -f "$DIFF_MESH" ]]; then
XDG_SESSION_TYPE= freecad "$DIFF_MESH" ${MACROS_DIR}/show-diff.FCMacro
else
echo "!!! failed to generate diff for $NEW in $TMP"
fi
rm -rf "$TMP"