C++ code to automate the treatment planning process