Ejemplo n.º 1
0
        private Vector2 GetCenterPoint(IVerticalEdge vertical)
        {
            double topY, bottomY,
                   centerX = vertical.XPosition;

            var  vertex           = vertical.Vertex;
            bool isLowerExtension = vertical.IsLowerExtension;

            if (isLowerExtension)
            {
                topY = vertex.Position.Y;

                var bottom = vertical.LeftTrapezoid.BottomSegment;
                Debug.Assert(vertical.RightTrapezoid.BottomSegment == bottom);

                if (bottom == null)
                {
                    bottomY = trapezoidalMap.BoundingBox.Bottom;
                }
                else
                {
                    bottomY = GetYComponent(bottom, centerX);
                }
            }
            else
            {
                bottomY = vertex.Position.Y;

                var top = vertical.LeftTrapezoid.TopSegment;
                Debug.Assert(vertical.RightTrapezoid.TopSegment == top);

                if (top == null)
                {
                    topY = trapezoidalMap.BoundingBox.Top;
                }
                else
                {
                    topY = GetYComponent(top, centerX);
                }
            }

            var centerY = (topY + bottomY) / 2;

            return(new Vector2(centerX, centerY));
        }
        private Vector2 GetCenterPoint(IVerticalEdge vertical)
        {
            double topY, bottomY,
                centerX = vertical.XPosition;

            var vertex = vertical.Vertex;
            bool isLowerExtension = vertical.IsLowerExtension;
            if (isLowerExtension)
            {
                topY = vertex.Position.Y;

                var bottom = vertical.LeftTrapezoid.BottomSegment;
                Debug.Assert(vertical.RightTrapezoid.BottomSegment == bottom);

                if (bottom == null)
                    bottomY = trapezoidalMap.BoundingBox.Bottom;
                else
                    bottomY = GetYComponent(bottom, centerX);
            }
            else
            {
                bottomY = vertex.Position.Y;

                var top = vertical.LeftTrapezoid.TopSegment;
                Debug.Assert(vertical.RightTrapezoid.TopSegment == top);

                if (top == null)
                    topY = trapezoidalMap.BoundingBox.Top;
                else
                    topY = GetYComponent(top, centerX);
            }

            var centerY = (topY + bottomY) / 2;
            return new Vector2(centerX, centerY);
        }