Due Date: Email your submission to your TA by midnight (EST) on Tuesday night, Feb. 5. 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.4.8. Binary installers are provided in the Download section of the CMake web site. Installing CMake is relatively painless and you probably won't run into any problems here.
Download fltk-1.1.7-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.7 or
~/MIIA/fltk-1.1.7.
Create a new directory to build FLTK in (e.g. C:\MIIA\FLTKBin).
Update for Mac: At this point Mac users should fix a bug in the file fltk-1.1.7/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. You will first need to tell CMake what compiler system you are using. For the input (CMakeLists.txt) file, point to the directory where fltk has been extracted (e.g. C:\MIIA\fltk-1.1.7).
On Linux and OS X you can use the command-line tool ccmake by issuing the following command within your FLTKBin directory:
ccmake (-G Xcode) ../fltk-1.1.7
IMPORTANT: Note that "../fltk-1.1.7" should be the path to the directory where you extracted FLTK. Change this if necessary.
Updated for Mac: Once either of these tools 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.
On Windows, this will create a Visual Studio workspace that can be used for the build.
Under OS X or other UNIX-like systems, this should generate either an Xcode project or a Makefile. To use a Makefile, simply issue the make command from within the FLTKBin directory. After the build completes, your FLTKBin/bin/(Debug/)(or similar) directory
will contain the compiled binaries necessary for linking to FLTK. This directory will also conain several example programs, one of which is checkers.
Update for Mac: At this point you need to copy fluid's OS X .app bundle files from the source tree to the build location, and copy the fluid binary into it, as follows:
cd FLTKBin/bin(/Debug) cp -r (../)../../fltk-1.1.7/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, and then using your mouse to "drag-and-drop."
Run the checkers program, take a screenshot (on windows, you can press Alt-PrtScn on your keyboard; on Mac, you can use the included Grab program.) Email the screenshot (with the rest of your submission) to your TA.
NOTE: In the past FLTK has had some syntax problems that would make 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.
The ITK source code is at
http://www.itk.org/, on the
Download page. You'll have to fill out a small form before
continuing with the download, and once you reach the actual download
page you want to grab both InsightToolkit-3.4.0.zip and InsightApplications-3.4.0.zip.
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. Email the output (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.0.4.zip).
You also need the vtkdata-5.0.4.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.0.4 and C:\MIIA\VTKData-5.0.4), 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 and BUILD_EXAMPLES are turned off.
Also set VTK_DATA_ROOT to the directory where the VTKData archive
has been extracted (e.g., C:\MIIA\VTKData-5.0.4). 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.0.4 contains an Examples directory, similar to the one in ITK. As you did with ITK, copy the Examples/Tutorial/Step6/Cxx directory out of VTK (e.g., to a new directory C:\MIIA\VTKTest-5.0.4). [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)".] Creat a build directory (e.g. 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 all you see is white then press the "r" key on your keyboard. Take a screenshot (Just like you did for FLTK), and email the screenshot (with the rest of your submission) to your TA.
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.
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 I 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.4.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.4.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!