Diary #7: Progress with itkQuadEdgeMesh; Pair programming

If there is one thing that ITK is good at, it definitely is *not* writing good documentation. I have been piecing together the different method calls necessary to perform the basic iterations and traversals on `itkQuadEdgeMesh`, which is ITK’s data structure for representing 2-manifolds.

If you’ve done a little mesh work, you’re probably familiar with CGAL’s `Polyhedron_3` data structure, but if not, at least you have a nice documentation page that does a good job about teaching you the interface of the underlying halfedge data structure, and by the end of it, you know the name of the game and even have some example code to go off on. But don’t take my word for it, see it for yourself: http://doc.cgal.org/latest/Polyhedron/classCGAL_1_1Polyhedron__3.html

On the other hand, take a glance at the documentation for the quadedge data structure in ITK: http://www.itk.org/Doxygen/html/classitk_1_1QuadEdgeMesh.html

At a first glance, things are not promising. If you’ll notice, though, you’ll see the link to a PDF article that gives an overview of the data structure and actually does a great job about it. However, the article was written at the time the data structure was initially submitted for inclusion in ITK, and so the code snippets don’t reflect the current API, which doesn’t help someone who wants to get up and running with it.

You might also be in the know and realize that ITK might have code examples on its wiki. Sadly, the few examples that actually deal with the quadedge mesh don’t really demonstrate the basics of its usage.

In spite of all of this, I’ve been able to throw together some example code that I will write up in a nice tutorial, putting it side by side with the CGAL halfedge data structure. This is one small step in the direction of developing ITK branch of my project. I’ll switch over to the other branch tomorrow and see about making forward progress with research now that I’ve been able to scratch this itch.

In other news, I did some pair programming with Carlos finally. We got some good progress going with implementing the modified method we went over during the weekend. I think it was really productive. It’s really nice to work things out together on the board and also switch off on the computer. There were also moments where we just disagree and stop, and that’s important, too.

I think this involvement is important, and I want to do my best to encourage it. Not just between coders like Carlos/me, but between coders and end users, for example.

Advertisements

Diary #1 – Looking through a Boost.Python project; Mesh repair

This is the start of my attempt to write a daily account of the things I do. There won’t be much in-depth detail in these diaries, and I’m mostly writing for myself so that I have some sort of continuity of thought that persists beyond one day, so I’ll put Diary in the title to make it easy for you, the reader, to quickly skip these if you want.

I have been looking into Boost.Python recently and today I looked at the CGAL Python Bindings project. In retrospect, I should have known when I saw the handmade Makefile and instructions for the previous major version of CGAL that I was getting into some old, unmaintained code. On the other hand, it is a good thing I went through the exercise of going through the code and compiling some parts of it. For future reference, the current Python wrapper project for CGAL is actually called cgal-bindings and actually uses SWIG. I still don’t really want to get into SWIG because it’s another thing I have to learn, and my project already incorporates Boost so I’ll stick to that.

The other thing that I spent most of my time on was repairing the skull meshes that we have in the lab. A lot of these meshes have twists, tangles, and foldovers that are really gnarly and I didn’t know how to deal with them until recently I learned a thing or two about Blender. I remember when I first opened Blender up, couldn’t find a way to import my .off file, and just wanted to close it and be done with it. Now, I know enough to be able to do what I want as far as untangling these contorted meshes. I repaired 7 today, and I think I can finish the remaining 10 tomorrow.

twistedMesh

Above is an example of a gnarly part of the monkey skull mesh. What happened is that a narrow U-shaped patch actually crossed over on itself to become something like the lowercase Greek letter gamma. Here, you’re looking at it from the side, and the highlighted triangles indicate where two faces intersect with each other — this doesn’t happen in reality, so I have to manually pull them apart. Of course, the other gnarly part is the sharp triangles along the ridge line. I write a program to flatten meshes, but it blows up if the input mesh has such configuration of triangles.

untwistedMesh

Here’s an example of what I’m able to do through Blender now. I can pull the sides apart so that the self-intersections go away, and I can clean up the tuft of triangles along the ridge. It takes a bit of time, and it’s up to you to rebuild the shape in a reasonable way. But I’m glad that I can fix it now. I might make a video to demonstrate the technique at some point.

I didn’t get to read as much as I wanted to today. I have a paper on my stack about LDDMM and hippocampus shape that looks interesting, so I’ll read it tomorrow. For general reading, I’ve been saying that I want to get back into reading Chinese, but I’m sick of just reading the news. I bookmarked two blog portals (here and here) that my friends linked articles from on Facebook. I’ll probably spend a bit of time just browsing for a blog or two in a category I’m interested in tomorrow.