Contours implementation

squirrelI thought it would be a nice experiment to log my progress on implementing suggestive contours for my thesis on a minute-by-minute basis.

Whether this turns out to be an interesting log or a boring concatenation of my sloppy coding adventures, we’ll see. I might discover what’s eating the most of my time …

  • 18:00
    I need to re-read the suggestive contours paper, since I didn’t pay much attention to implementation details uptil now.
  • 18:30
    The object-space algorithm is based on finding the points where the radial curvature (K_r) is zero. It searches over the entire mesh. It then “trims” the solution using the directional derivative. So at the end, I’ll have a reduced set of points. How to connect them then? We’ll see.
  • 18:40
    Computing the radial curvature is done using this formula:
    K_r(point) = K_1(point)cos²(phi) + K_2(point)cos²(phi)
    So, first things first, what are K_1 and K_2?
  • 18:50
    Thanks to Wikipedia, I now know that K_1 and K_2 of a certain point p depict the principal curvatures in that point. Now, I hope that TriMesh2 already has some magic functionality to compute these, since it involves stuff like Taubin Smoothing and something called the T-algorithm – never heard of.
  • 19:15
    Since TriMesh2 doesn’t offer any kind of documentation, it’s looking-at-the-source time again. In TriMesh.h I discover that the standard mesh has the principal directions and the principal curvatures stored in a vector. All I need to do is call need_curvatures. The file contains the implementation, but I suppose this will Just Work ™.
  • 19:30
    I wonder whether I could compute the radial curvatures just one time (as a pre-process).
  • 19:37
    This turns out to be a silly thought, since the formula also contains the factor phi, which is the angle between the view vector (pointing to the camera) in that vertex and the first principal direction.
    I had to compute the view vector for regular contours too, so I’ve got that part covered. Computing the angle between the view vector and the first principal direction vertex probably can be done using the dot product.
  • 19:53
    Realized the current code I’m adding to is getting a bit messy. I’m going to try and clean it up a bit by moving my contour-related functions to seperate files. Might have to browse through my C++ book to find out how to do that the clean way.
  • 20:10
    Reading parts of Accelerated C++ by A. Koenig again. And …
    dinner break time
  • 23:30
    Had to work on something else first, so it was a rather long break.
  • 0:05
    Succesfully created some header files which allow me to use mesh_viewer global variables in other files.
  • 0:10
    I noticed all facenormals get recomputed at every draw. Going to write normals caching.
  • 1:00
    Got facenormals caching working. Rendering speed has improved. Might work this into the TriMesh2 library itself, in order to reduce ugly code …
  • 1:53
    Worked facenormals vector into TriMesh2 and recompiled library. Now I’ve got TriMesh2-JeroenRemix ;) Never done this before, but it seems to work. I somehow feel those were 3 hours well spent, although it didn’t really have anything to do with suggestive contours.
    Time for a break. After that, I’ll implement compute_radial_curvature (*vertex)