Creating sloped Mass/Solid/Hatch from footprint

Hi,
I`m starting to work on project that would result in making sloped Solid/Hatch/Mass (it does not matter) from footprint lines - like Revit Roof by Footprint lines. So that I could input angle for every contour line and the Solid is generated.
For now I have no clue where to start to create Solid from footprint lines + angle inputs. Maybe there someone can guide me in the direction of calculation? How is Revit Roof by Footprint calculated ? Is this some crazy trigonometry calculation?

The first idea is to create solid triangles and substract them from main form.
Section: