Convert surface area calculation to C++

Minimal conversion to make min/max work, and remove a few unused
variables.  This enables writing a C++ wrapper over the functionality,
as well as using the analysis neighborhood search internally to fix
several issues with the original algorithm.

Change-Id: If5089a749c8db9630e33edab3d2b79968a28a921