I have two faces ($S_1$ and $S_2$), each bounded by a series of Vertex $V$. These two faces may or may not intersect. In addition to that there are two vertical faces $S_3$ and $S_4$, that connect between $S_1$ and $S_2$ vertically, as shown in the below diagram. The question is how to find the polyhedrons that are formed by the bounding of the four faces?
An example of this is shown below:
In the above example, there should be two polyhedrons returned, one above $S_2$, another below $S_1$.
Both $S_1$ and $S_2$ are defined by 3D coordinates. Let's say the coordinates for $S_1$ is ($P_1$,$P_2$, $P_3$, $P_4$) and $S_2$ is $P_5$,$P_6$, $P_7$, $P_8$, and the intersected points are $P_9$ and $P_{10}$. I want a program that returns me two polyhedrons:
$$P_1,P_2,P_9,P_{10},P_5,P_6$$
and
$$P_3,P_4,P_{10},P_9,P_7,P_8$$
One way to do this is to find the intersecting line of the two faces, and then construct polyhedron from there. But is there a more elegant method?