Ramer–Douglas–Peucker algorithm implementation in C++