Due Date: Email your submission to your TA by midnight (EST) on Wednesday night, Jan. 28. Big problems may not show up until the end, so finish early!
Acknowledgement: This assignment is based on the work of others from previous sessions of this class.
E-mail your TA or instructor with questions or problems.
Before doing any ITK development, you will need to setup a working environment in which to compile your code. This includes
For further guidance on these procedures and how to test your build environment, you may wish to consult the slides from Lecture 3.
CMake can be downloaded from http://www.cmake.org/. The most recent version is 2.6.2. Binary installers are provided in the Resources:Download section of the CMake web site. Installing CMake is relatively painless and you probably won't run into any problems here. I do, however, recommend letting the Windows installer add CMake to your system path.
Note: When using newer versions of CMake with pre-existing software, feel free to ignore any warnings about either "cmake_minimum_required" or "Policy CMP0003".
Download fltk-1.1.9-source.zip and extract its contents
somewhere appropriate (such as C:\MIIA\ in a Windows environment
and ~/MIIA under Linux or OS X).
You will probably find it convenient to keep
all of your downloaded libraries (i.e., ITK, VTK, etc.) in this same root
directory.
After extraction you will have
the FLTK source tree residing at either C:\MIIA\fltk-1.1.9 or
~/MIIA/fltk-1.1.9.
Create a new directory to build FLTK in (e.g. C:\MIIA\FLTKBin).
At this point Mac users should fix a bug in the file fltk-1.1.9/test/CMakeLists.txt by changing the ADD_EXECUTABLE line to read as follows "ADD_EXECUTABLE(${NAME} MACOSX_BUNDLE ${srcs})".] |
Now run the CMake GUI.
On Windows it might be called either CMake or CMakeSetup, and in either case it should be in your Applications folder (or Start Menu) under CMake. At some point CMake will ask what compiler system you are using, e.g. Visual Studio 2005. At the top of the CMake GUI are two fields, one for source code and one for where to build the binaries; the source code directory is the directory where fltk has been extracted (e.g. C:\MIIA\fltk-1.1.9), and the binary directory is the directory you previously created (e.g. C:\MIIA\FLTKBin). |
On Linux and OS X you can use the command-line tool IMPORTANT: Note that "../ |
Once your CMake GUI is running, you want to "configure" the system. This will cause cmake to establish environment settings for the build process. Once finished, you will be presented with a list of optional or unknown values for you to change as needed. You should turn on BUILD_EXAMPLES and BUILD_TESTING and turn off BUILD_SHARED_LIBS. On Mac, you should also turn off Quartz.
Once these variables have been set, Configure again. Finally, you should be able to generate the build environment (i.e., on Windows you will eventually be able to click the "OK" button).
On Windows, this will create a Visual Studio workspace that can be used for the build. |
Under Mac OS X or other UNIX-like systems, this should generate either an Xcode project or a Makefile. To use a Makefile, simply issue the At this point Mac users need to copy fluid's OS X .app bundle files from the source tree to the build location, and then copy the fluid binary into it, as follows: cd FLTKBin/bin(/Debug) cp -r (../)../../fltk-1.1.9/fluid/fluid.app . cp fluid fluid.app/Contents/MacOS/ At this point mac users may also want to copy fluid.app to their applications folder and/or their taskbar. This can be easily done by opening the current folder ("open ."), and then using your mouse to "drag-and-drop." NOTE: In the past FLTK has had some syntax problems that would make Mac's Xcode gcc unhappy, so it's highly possible that FLTK will fail compilation under OS X at some point. The fix is relatively simple, so if you encounter any problems please e-mail the TA AND instructor with a copy of the error output. Similar minor issues may also arise when compiling VTK. |
Run the checkers program (Visual Studio places it in FLTKBin/bin/Debug), take a screenshot (on windows, you can press Alt-PrtScn on your keyboard; on Mac, you can use the included Grab program or the Command-Shift-4 shortcut.) Email the screenshot (with the rest of your submission) to your TA.
The VTK source code can be downloaded from
http://www.vtk.org/ (under
Download).
You want the latest official source release (vtk-5.2.1.zip).
You also need the vtkdata-5.2.1.zip file.
Regarding the windows installer listed on the VTK website, we have no experience with it, and recommend that for consistency across platforms you use the source release instead.
Create new directories for both of these files (in the same place
you extracted FLTK, e.g. C:\MIIA\VTK-5.2.1 and C:\MIIA\VTKData-5.2.1), and extract both of these archives into them.
Create a new directory in which to build VTK (e.g. C:\MIIA\VTKBin).
Now run the CMake GUI, as you did for FLTK, but using your newly created VTK source and build directories. You should turn on VTK_USE_PARALLEL and VTK_USE_RENDERING. Make sure that BUILD_SHARED_LIBS, BUILD_EXAMPLES, and BUILD_TESTING are turned off.
Also set VTK_DATA_ROOT to the directory where the VTKData archive
has been extracted (e.g., C:\MIIA\VTKData-5.2.1).
| On a Mac, you should also turn on only one of: VTK_USE_CARBON, VTK_USE_COCOA, or VTK_USE_X; carbon is recommended. |
Once these variables have been set, Configure again. Finally, you should be able to "Generate" the build environment. Build VTK (just like you built FLTK); this will take a considerable amount of time.
VTK-5.2.1 contains an Examples directory. Copy the Examples/Tutorial/Step6/Cxx directory out of VTK (e.g., to a new directory C:\MIIA\VTKTest-5.2.1).
Mac users should now fix a bug in the CMakeLists.txt file by changing the ADD_EXECUTABLE line to read as follows "ADD_EXECUTABLE(Cone6 MACOSX_BUNDLE Cone6.cxx)". |
C:\MIIA\VTKTestBin). Run the CMake GUI with the newly created source and build directories. Build it. Inside your build directory there will now be an executable program named Cone6. Run the Cone6 program.
Mac users should run the program by double-clicking on the application bundle icon or by typing "open Cone6.app" from the command line in the same directory as the newly built app. |
If you run into problems building VTK, and your TA cannot immediately resolve them, then please subscribe to the VTK users mailing list and ask for help.
The ITK source code is at
http://www.itk.org/, on the
Download page (available via the Resources menu). You want to grab both InsightToolkit-3.10.1.zip and InsightApplications-3.10.0.zip. If you haven't already done so, download the ITK Software Guide 2.4.0 PDF while you're at it.
Extract both archives. Create a new directory to build ITK in (e.g. C:\MIIA\InsightBin).
Now run the CMake GUI, as you did for FLTK, but using your newly created InsightBin and InsightToolkit-3.4.0 directories. Turn off BUILD_SHARED_LIBS, BUILD_EXAMPLES, and BUILD_TESTS. You may wish to enable advanced options
and then turn on ITK_USE_PATENTED in case you have interest in
using any of the patented algorithms in ITK (e.g. fuzzy connectedness).
Once these variables have been set, Configure again. Finally, you should be able to "Generate" the build environment. Build ITK (just like you built FLTK); this will take a considerable amount of time.
Follow the instructions in Lecture03 to perform the ITK installation test. Because HelloWorld.exe is a command-line program, you should probably run it either from within Visual Studio, or from a command-prompt. Email the text output (with the rest of your submission) to your TA.
Download SNAP-MIIA.zip, and extract it to your MIIA directory. Create a new directory to build SNAP in (e.g. C:\MIIA\SnapBin).
Now run the CMake GUI, as you did for FLTK, but using your newly created SnapBin and the SNAP-MIIA directories. CMake will either know or ask you for the paths to your ITK, VTK, and FLTK build directories.
On a mac, you will need to enable advanced mode in CMake and change OPENGL_INCLUDE_DIR to /usr/X11R6/include and set ITK_FLTK_RESOURCE to ../FLTKBin/FL/mac.r. You may have to repeatedly configure several times to be able to generate a project. |
Build SNAP.
On a Mac, you will now need to either copy or symbolically link the "ProgramData" directory from SnapBin into InsightSNAP.app/Contents/MacOS/. |
Run the SNAP program (InsightSNAP). Go to File -> Load Data -> Greyscale Image. Browse to the SNAP-MIIA source directory, and choose the file HeadMRVolume.mhd. Choose the "Axial MRI" orientation, and then choose the defaults through the rest of the dialogs. Now go to File -> Load Data -> Segmentation Data. Browse to the SNAP-MIIA source directory again, but this time choose the file HeadMRVolume-Segmentation.vtk. Choose the defaults through the rest of the dialogs. Now click the "update mesh" button at the bottom of the main window. Take a screenshot (Just like you did for FLTK), and email the screenshot (with the rest of your submission) to your TA. Also let him know if you were unable to get anything working, or had unusual difficulty doing so.
Warning: This is not necessary for this class, but it may prove helpful to you. This can take a very long time and a lot of disk space.
Create a new directory to build InsightApplications in (e.g. C:\MIIA\ITKAppsBin).
Now run the CMake GUI (but first, see the warning below), as you did for FLTK, but using your newly created ITKAppsBin and the InsightApplications-3.10.0 directories. Turn off BUILD_SHARED_LIBS and turn on USE_FLTK, USE_VTK,and BUILD_TESTING. You may have to repeatedly configure several times to get all these options turned on. Eventually, you should be able to turn on USE_SNAP. Once you have set all of the previously mentioned options, to save time and disk space, consider turning off some or all of the OTHER options that begin with "USE_".
On Mac and Unix, you should call ccmake with a command-line argument telling it the path to your FLTK installation. (This is to work around a bug in the included CMakeLists.txt file) Do it like this:
ccmake (-G Xcode) -D FLTK_DIR:STRING=/Users/galeotti/MIIA/FLTKBin ../InsightApplications-3.10.0/
Once all the variables have been set, Configure again. Finally, you should be able to "Generate" the build environment. Build InsightApplications (just like you built FLTK); this will take a very long time and a lot of disk space.
...or not. One thing you may try before contacting anyone is to ensure that your compiler system is up-to-date with the latest patches.
Microsoft publishes service packs for the Visual Studio suite that can be found at http://msdn.microsoft.com/.
Apple makes available the latest version of the Xcode Tools for download at http://developer.apple.com (may require setting up an account on the site - it's free).
If you are not using either of these systems, or you still run into compiler/linker errors after updating, please do not hesitate to copy and paste your errors to someone (preferably the TA). If he can't help you, he'll find someone who can.
Good luck!