// // If a cycle has an edge that is EXTENDED, there exist two regions, one on each side of the segment; compose the two segments. // // Fixed point algorithm: while there exists a cycle with an extended segment, compose. private static void ComposeCycles(UndirectedPlanarGraph.PlanarGraph graph, List <MinimalCycle> cycles) { for (int cycleIndex = HasComposableCycle(graph, cycles); cycleIndex != -1; cycleIndex = HasComposableCycle(graph, cycles)) { // Get the cycle and remove it from the list. MinimalCycle thisCycle = cycles[cycleIndex]; cycles.RemoveAt(cycleIndex); // Get the extended segment which is the focal segment of composition. GeometryTutorLib.ConcreteAST.Segment extendedSeg = thisCycle.GetExtendedSegment(graph); // Find the matching cycle that has the same Extended segment int otherIndex = GetComposableCycleWithSegment(graph, cycles, extendedSeg); MinimalCycle otherCycle = cycles[otherIndex]; cycles.RemoveAt(otherIndex); // Compose the two cycles into a single cycle. MinimalCycle composed = thisCycle.Compose(otherCycle, extendedSeg); // Add the new, composed cycle cycles.Add(composed); } }