Exemplo n.º 1
0
        /// <summary>
        /// Replaces the P or Q vertices of the actualLayer with their
        /// segment on the next layer.
        /// </summary>
        /// <param name="alternatingLayer">The actual alternating layer. It will be modified.</param>
        /// <param name="straightSweep">If true, we are sweeping down else we're sweeping up.</param>
        private void AppendSegmentsToAlternatingLayer(AlternatingLayer alternatingLayer, bool straightSweep)
        {
            var type = straightSweep ? VertexTypes.PVertex : VertexTypes.QVertex;

            for (int i = 1; i < alternatingLayer.Count; i += 2)
            {
                var vertex = alternatingLayer[i] as SugiVertex;
                if (vertex.Type == type)
                {
                    var precedingContainer  = alternatingLayer[i - 1] as SegmentContainer;
                    var succeedingContainer = alternatingLayer[i + 1] as SegmentContainer;
                    precedingContainer.Append(vertex.Segment);
                    precedingContainer.Join(succeedingContainer);

                    //remove the vertex and the succeeding container from the alternating layer
                    alternatingLayer.RemoveRange(i, 2);
                    i -= 2;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Replaces the P or Q vertices of the <paramref name="alternatingLayer"/> with their segment on the next layer.
        /// </summary>
        /// <param name="alternatingLayer">The actual alternating layer. It will be modified.</param>
        /// <param name="straightSweep">If true, we are sweeping down else we're sweeping up.</param>
        private static void AppendSegmentsToAlternatingLayer(
            [NotNull, ItemNotNull] AlternatingLayer alternatingLayer,
            bool straightSweep)
        {
            Debug.Assert(alternatingLayer != null);

            VertexTypes type = straightSweep ? VertexTypes.PVertex : VertexTypes.QVertex;

            for (int i = 1; i < alternatingLayer.Count; i += 2)
            {
                var vertex = (SugiVertex)alternatingLayer[i];
                if (vertex.Type == type)
                {
                    var precedingContainer  = (SegmentContainer)alternatingLayer[i - 1];
                    var succeedingContainer = (SegmentContainer)alternatingLayer[i + 1];
                    precedingContainer.Append(vertex.Segment);
                    precedingContainer.Join(succeedingContainer);

                    // Remove the vertex and the succeeding container from the alternating layer
                    alternatingLayer.RemoveRange(i, 2);
                    i -= 2;
                }
            }
        }