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.

Advertisements

Blender notes from a Meshlab user

When I first started working with meshes, the first tool that people told me to get started with was Meshlab. It’s an open source mesh processing tool that lets you visualize your meshes, do some mesh editing, and also lets you pick from a kitchen sink full of filters with various tools. See my previous post for an example of computing triangle surface area on a mesh by putting together a few of these filters. However, if you want to get more “hands-on” with your mesh, touch up certain areas in a fine-grained way, Meshlab disappoints.

This is where Blender comes in. It’s another nice open-source tool that everyone will recommend, but it’s loaded with so much stuff that it is probably less intuitive to use. I’m not a professional at 3d modeling but I do need to curate the data that I work with in my research, so here’s a few notes about Blender that I’ve taken that have been helpful to me in my mesh editing work.

You can focus on selected primitives by right-clicking in Edit mode and hitting PERIOD.

You can select boundaries by going into Edit mode, then going to Select -> Edges -> Non-manifold. Blender actually has a nice scripting environment

You can fill holes by selecting a hole and pressing ALT + F.

You can hit TAB to go between Object and Edit mode. Tab out of Edit mode before exporting your mesh so that any changes are committed to the model first.

You can open the properties panel by hitting N. This is context-dependent what it contains. You’ll watch some videos or read some tutorial and it will refer you to this, but it might be mysterious at first how this is even reached, so now you know.

For context-dependent actions on edges, press CTRL + E.

For context-dependent actions on vertices, press CTRL + V.

Importing/exporting with OBJ file format works best if you want to keep mesh data consistent across Meshlab and Blender.

For reference, the latest version of Blender at the time of this post is 2.69. There’s a lot of good tutorial videos for users, such as this one. I just wished that there was a web page to go with some of these so I don’t have to browse a lengthy video to review content, hence this mini- cheat sheet of things that were helpful to me.