Splitting a GoJs Group

I am looking for a functionality to split a group in 2 when a polyline is drawn over a group which starts from one of the edges of the group and ends at the same or any other edge of the group. The original group can be a polygon or a rectangle. Also the two newly created groups after the split can also be of either shapes. Something like below –



The steps can be –
first, check if the polyline has two intersections with group edges, which basically suffices the condition for the split.
second, if first point is true, remove the older group and create two new groups with a little offset.
restructure the older group to create two new groups.

So this is basically how to compute two Geometry instances given the original Geometry and a polyline. Remember that you cannot modify the original Geometry – instead call Geometry.copy twice and then modify their PathFigure(s).

You’ll need to compute the intersection points of the drawn line with the existing polygon’s borders and then construct the two resulting polygons caused by adding the same intersecting edges to each polygon.

You’ll need to worry about what should happen when the line that the user draws does not intersect the original polygon’s borders at exactly two points. Not only might the user’s line zig-zag many times across the original polygon, but the original polygon might not be convex.

In case, the user has more than two intersections with the edges, only the first two would be considered.
I was even thinking of cancelling the polyline tool when two intersections have been achieved.

Those both sound like reasonable possibilities. If you run into any problems, just ask.