Wednesday, November 10, 2010

Building VTK with QT on a Mac

VTK libraries are built in a similar fashion as VXL. You will need Cmake installed and create directories fro source and build.
The configuration for using VTK with QT are borrowed from here
In summary:

  1. Grab Qt 4.5.3 here.
  2. Launch CMake. Set the build directory to where you want to build VTK and the source directory to the VTK source tree.
  3. Turn on the following options:
    1. BUILD_SHARED_LIBS
    2. VTK_USE_QT
    3. VTK_USE_CARBON
    4. VTK_USE_GUISUPPORT
  4. Turn off the VTK_USE_COCOA option.
  5. Click “Configure”.
  6. Set DESIRED_QT_VERSION to 4.
  7. Click “Configure” again.
  8. Turn on VTK_USE_QVTK_QTOPENGL
  9. Click “Configure” yet again.
  10. Click “Generate”.

Tuesday, June 1, 2010

Format Date in Xcode

By default, when using the field DATE in Xcode, the date is in month/day/year format. In order to change the format you could type in the terminal a command of the following form:

defaults write com.apple.xcode AppleICUDateFormatStrings '{ 1 = "d-MMM-yyyy"; }'

A good source for what fields can be used in Xcode templates see this link

Friday, February 26, 2010

Setting a vxl dashboard build on MacOS X

This entry discusses how to set up a nightly build of vxl libraries on MacOS X. The nightly build is posted in the vxl dashboard. You can read instructions and download the sample scripts from here. I will also attach my scripts with appropriate modifications.

To start, I created a location to have my dashboard projects e.g /Projects/dashboards. Within that location I have a folder for vxl_scripts and a folder for builds. In dashboard/builds I created folders vxl_nightly/src and vxl_nightly/bin. I downloaded the sources from vxl secure repository svn co https://vxl.svn.sourceforge.net/svnroot/vxl/trunk src ..
The next step is to configure your scripts. There are two main scripts as provided in the vxl instructions - vxl_nightly.cmake and vxl_common.cmake.  The main purpose of having two separate scripts is to separate what is common to most users and what is specific to your machine. So as the name indicates, vxl_common.cmake contains what is common to most users. You shouldn't need to modify it at least not in my case. In vxl_nightly, you will need to specify the locations of you sources and binaries. You will also specify any Cmake variable that you wish to set differently from the default. You can download my vxl_nightly script here for an example.

The last step in the processes is to create a script to call vxl_nightly and set up a schedule for it. One way (there are many) to do this on the mac is to place your script on /etc/periodic/daily. All the scripts at this location get called by launchd at the time specified in the system preferences. Usually the file names start with a number - execution order is determined by the numbers.

My script is called 600.dashboard and contains the following lines


#!/bin/sh
LOGFILE=/var/log/dashboard.log

echo "---------- Building VXL Nightly ----------" >> $LOGFILE
echo "---------- " `date` " ----------" >> $LOGFILE
cd /Projects/dashboards/vxl-scripts
ctest -V -S vxl_nightly.cmake >> $LOGFILE
echo "----------  Done ----------" >> $LOGFILE

So, if you want to test your script you can copy this code anywhere, call the script at test a build. If you are just testing make sure that on your vxl_nightly.cmake script you add the line set(dashboard_model Experimental). Note that as a local user, you cannot write too /var/log (but launchd will) so for testing purposes, change the path of your log file to something like ~/dashboard.log.

Note that the progress of your build will be shown in your log, not so much on the console/terminal.

Friday, January 29, 2010

Mac OS, Cmake linking troubles

Mac OS.... if you see ld: library not found for -lcrt1.10.6.o, then it may be that  either CMAKE_OSX_ARCHITECTURES or CMAKE_OSX_SYSROOT aren't properly set up. See this link for useful info http://public.kitware.com/Bug/view.php?id=6195

Comment/Uncomment python scripts in Xcode

The default Comment/Uncomment script in Xcode works for python and pearl only if the first line of your scripts is #! /... . However, most of the times this is not what I do for my python scripts. So we can change the default script so that it determines the type of file from the extension .py.  To do so, go to the scripts tab in Xcode -the little icon before help- the select Edit User Scripts. Select the Comment/Uncomment scripts and change it to be:


#! /usr/bin/perl -w
#
# un_commentLines.pl - Comments or uncomments the selected lines
# Uses '# ' for Perl and shell scripts; '// ' otherwise

my $outputString = "";
my $perlCmt = "#";
my $cCmt = "//";

# get path to document
my $headerPath = <<'HEADERPATH';
%%%{PBXFilePath}%%%
HEADERPATH
chomp $headerPath;my $commentString;
if ($headerPath =~m/\.(sh|pl|py)$/) {
    $commentString = $perlCmt;
} else {
    $commentString = $cCmt;
}
my @selection =  ;       # read the selection from standard input

# no chars in selection, so create an empty selection
if (!@selection) {
    push @selection, "";
};

# add or remove comment markers depending on the state of the first line of the selection
# if it is uncommented, comment all lines.  If it is commented, remove comment markers, if present
my $firstLineOfSelection = $selection[0]; #get first line
my $addingCommentsString = 1;
if ($firstLineOfSelection =~ /^$commentString/) { #selection starts with comment
    $addingCommentsString = 0;
}

foreach my $line (@selection) {
    if ($addingCommentsString == 1) {
        $outputString .= $commentString.$line;
    } else {
        $line =~ s/^$commentString//;
        $outputString .= $line;
    }
}

print "%%%{PBXSelection}%%%";
print $outputString;
print "%%%{PBXSelection}%%%";

Saturday, January 23, 2010

Blender: The beginning, fairly simple

So, I was given the task to build a somewhat realistic city scene a produce cameras and rendering for such scene. Initially the task didn't seem bad at all, so I jumped into building a scene right away. The rumors were that Blender was great (and in fact, so it seems ). So I decided to download it, learn how to use it and build a scene.
I downloaded it, things went easy and run across a tutorial that would guide me through how to build an 'impressive'-looking building (for a beginner) http://yorik.uncreated.net/tutorials/architecture-blender.html.

The estimated time to complete the tutorial said it was around 4 hours. Took me a little longer, I had never used Blender so finding the menus and getting used to all the keyboard shortcuts took some time. Manipulating the faces of my building wasn't always easy and some of the settings for the objects seem a bit alien, but after some time the model was done (not to the same level of detail)