Started converting my C# version into C++ code to be re-used in the Qt/qml project.