The C++ source code for the model-to-model distance module is here.
It uses the vtkDistancePolyDataFilter which also has a Python wrapper. I have a Python module that uses this filter here which may help as an example.