There isn't one function that will do it. As Randall says you have to write code that uses a series of different functions to do it even if all you want to do is what you describe. Basically working through the contours, finding the gaps, appending onto a new vector with the points adjust to be the same etc. That's the only way I know to do it.
I use scripts to automate the Aspire UI itself when I want to do something like that as it's quicker and easier than creating the LUA code.