Closing shapes at non-endpoints Consider how one would represent the following image in vector graphics:



Pretty simple, right?  The entire shape can be represented by a single path element.

But suppose additionally that you want to color the heart at the top red.  The path element is an open shape, so trying to fill it results in an appropriately red heart but also implementation-dependent bleeding between the spiral endpoints.

Obviously, one could just draw the heart and the spiral tails as separate elements, but then the vector graphics representation no longer mirrors how a human being would draw the same image, and makes it more difficult to manipulate as a single object.  One needs a way to communicate to the computer that two particular path segments within the larger path intersect in such a manner that they close a sub-shape.

Is there a vector graphics format capable of doing this?  More relevantly, how is it implemented and are there any papers on it?
In CAD systems this is done


On user side

find intersection of two curves
split curves by their intersection
make closed path to form a polygon
fill polygon
you can still group separated line into one line and operate with it as previously, change in internal logic (math core side) will be hidden from you

On math core side

choose appropriate method of intersection of curves based on the type of the curves
do intersection either by exact intersection if lines types support this (eg straight lines) or by numerical method (usually iterative) in other cases (eg when you have splines underlying)
create new curves based on existent edges of lines and on the found intersection point
an so on