File: itkwish

package info (click to toggle)
insighttoolkit 3.20.1%2Bgit20120521-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 80,652 kB
  • sloc: cpp: 458,133; ansic: 196,223; fortran: 28,000; python: 3,839; tcl: 1,811; sh: 1,184; java: 583; makefile: 430; csh: 220; perl: 193; xml: 20
file content (102 lines) | stat: -rwxr-xr-x 3,298 bytes parent folder | download | duplicates (2)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/sh
#-----------------------------------------------------------------------------
# Program:   Insight Segmentation & Registration Toolkit
# Module:    itkwish
# Language:  C++
# Date:      $Date$
# Version:   $Revision$
#
# Copyright (c) Insight Software Consortium. All rights reserved.
# See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
#
# Portions of this code are covered under the VTK copyright.
# See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
#
#    This software is distributed WITHOUT ANY WARRANTY; without even 
#    the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
#    PURPOSE.  See the above copyright notices for more information.
#-----------------------------------------------------------------------------

#
# This is a shell script driving the ITK Tcl wrapper executable.  It
# sets up the environment and then executes the real executable.
# Alternatively, if the first command line argument is "--run", the rest
# of the command line will be invoked as a command in the proper
# environment.
#
# The real executable is located relative to this script in
#   ../lib/InsightToolkit
#

ITKWISH_Usage()
{
  echo "Insight Segmentation & Registration Toolkit (http://www.itk.org)"
  echo "This is the Tcl wrapper executable driver."
  echo ""
  echo "Usage:"
  echo "  itkwish           = Run itkwish interactively as a Tcl interpreter."
  echo "  itkwish foo.tcl   = Run \"foo.tcl\" in the ITK Tcl interpreter."
  echo "  itkwish --run ... = Run command \"...\" in the itkwish environment."
  echo ""
  echo "Example commands:"
  echo "  \"itkwish\""
  echo "    Provides a tcl prompt "%" from which ITK scripts can be written"
  echo "    interactively."
  echo ""
  echo "  \"itkwish myITKScript.tcl\""
  echo "    Runs the myITKScript.tcl script in the ITK Tcl interpreter.."
  echo ""
  echo "  \"itkwish --run wish\""
  echo "    Runs wish in an environment in which the ITK packages can be"
  echo "    loaded with \"package require InsightToolkit\"."
}

ITKWISH_SELFDIR=`cd \`echo "$0" | sed -n '/\//{s/\/[^\/]*$//;p;}'\`;pwd`

if [ -d "${ITKWISH_SELFDIR}/../lib/InsightToolkit" ]; then : ; else
  ITKWISH_Usage
  echo ""
  echo "Error:"
  echo "  This script is meant to be used from an itk installation directory."
  echo "  It will not run from the itk source tree."
  exit 1
fi

ITKWISH_LIBDIR=`cd "${ITKWISH_SELFDIR}/../lib/InsightToolkit"; pwd`

# Setup environment.
case "`uname`" in
Darwin)
  if [ -z "$DYLD_LIBRARY_PATH" ]; then
    export DYLD_LIBRARY_PATH="$ITKWISH_LIBDIR"
  else
    export DYLD_LIBRARY_PATH="$ITKWISH_LIBDIR:$DYLD_LIBRARY_PATH"
  fi
  ;;
*)
  if [ -z "$LD_LIBRARY_PATH" ]; then
    export LD_LIBRARY_PATH="$ITKWISH_LIBDIR"
  else
    export LD_LIBRARY_PATH="$ITKWISH_LIBDIR:$LD_LIBRARY_PATH"
  fi
esac

if [ -z "$TCLLIBPATH" ]; then
  export TCLLIBPATH="\"$ITKWISH_LIBDIR\""
else
  export TCLLIBPATH="\"$ITKWISH_LIBDIR\" $TCLLIBPATH"
fi

if [ "$1" = "--help" ]; then
  # Display usage.
  ITKWISH_Usage
  exit
elif [ "$1" = "--run" ]; then
  # Skip the "--run" argument.
  shift
  # Run exact command line given after "--run" in this environment.
  exec "$@"
else
  # Run real itkwish executable in this environment.
  exec "${ITKWISH_LIBDIR}/itkwish" "$@"
fi