| Prepare for Boolean Operation |
All intersections are part of the graph now. This has divided
a 2D plane into seperate enclosed areas, that are formed by links and nodes.
If we can tell for each enclosed area if it is part of groupA and/or groupB,
we can also tell if this enclosed area is part of a certain boolean operation.
To achieve this we need to find for links that enclose a particular area
if the sides of those links are part of groupA or B. Using a scanbeam we
can calculate for each link in a beam, if its right or left side was inside
the polygon from which the link originated. After those values are known
for all the links in the graph, they will be used to calculate for each
link if the left and/or right side was part of the groupA and/or groupB
area ( See In/Out GroupA and/or
GroupB. ). This information will be used to set flags for each link,
to tell if the left or right side of the link is part of a boolean opera



For a flatbeam this method can not be used, because for all the links at for instance the low node, the Ysp and Ysn will be eqaul. During sorting of the beam records the order of those records in the beam is not fixed. This is why all flatbeams are skipped, still the graphnumber of new links inserted at the low node are recorded. The first coming normal beam will calculate the "inc" again ( See skipping flatbeams.. ). The flatbeam links will be calculated later, after rotating the whole graph 90 degrees in the end, and performing another sweep.

Those flags tell if the Left or Right side of the link is part of groupA or groupB. The principle for calculating those flags, is simular to calculating the "inc" flag for single polygons. Here we need to calculate how many polygons of a certain group are overlapping. If the number of overlaps is more then zero, it is clear that this area is part of the given group. The overlaps are calculated for groupA and groupB. The "inc" flag tells if we go deeper in a polygon of a certain group. If at the same time we where already in another polygon of the same group, we can say that the overlap for this group is "depth" polygon1 + "depth" polygon2. The "inc" + "the group flag" are used to calculate for each side of a link how deep the overlap of an enclosed area on that side of the link is for each group.
The same scanbeam is used for this. Because all intersection in the complete graph are known at this point, we only have to set the group flags once for each link. If the same link is still part of another following beam it does not need to be set again, the values in the next beam should be the same. Simple because the link does not cross any other link, each link is unique. To prevent setting the same flags again we set the mark flag for a link. In case the mark flag is set, we can perform a simplified calculation in the beam for calculating the groupA and groupB depth.
While traversing the scanbeam, the depth for each side of the link for each group is calculated using the "inc" flag of the link. The top side the link will be set based on the current depth of groupA and groupB, the bottom side of the link will be set according to the "inc" flag of the link. The top and bottom side maps to a side of the link depending on its direction (going left or right in the beam). The flags are boolean, if the depth is > zero for a certain group it is set to True else to False.
For links that are parallel with other links in the beam,
we can set the group flags only if we know the depth after we passed the
last of the parallel links. Between parallel links there are no enclosed
areas defined, only before and after a set of parallel links, we will find
enclosed areas. So for parallel links the group flags will be set if the
first enclosed area in the beam after the parallel links is known. The
flags for a set of parallel links will be set to the value of the area
just above the first parallel link and just below the last parallel link.
Still the directions of all the parallel links in between are needed to
calculate those areas. In See calculate
group left right. we can see for a given beam how the "A and B group
depth" are set according to the enclosed areas we pass inside the beam.
If the "inc" flag is True for a certain link, the depth of the group where
this link belongs to goes up, else down. The first and last area in the
beam will always have a depth of (0,0), because we are outside all polygons.
