void GoOverOrderedPointsAndAddLabelObstacels(List <PointSet> orderedPoints, List <Point> innerPoints, List <Point> outerPoints, Point wh)
 {
     foreach (PointSet p in orderedPoints)
     {
         Point center = p.Center;
         innerPoints.Add(p.Inner);
         outerPoints.Add(p.Outer);
         var r = new RectangleObstacle(new Rectangle(center + wh, center - wh));
         AddLabelObstacle(r);
     }
 }
        /// <summary>
        /// </summary>
        /// <param name="label"></param>
        /// <returns></returns>
        public bool PlaceEdgeLabelHorizontally(Label label)
        {
            ValidateArg.IsNotNull(label, "label");
            var e = (Edge)label.GeometryParent;

            // approximate label with a rectangle
            // process candidate points for label ordered by priority
            // check candidate point for conflicts - if none then stop and keep placement
            label.InnerPoints = null;
            List <KeyValuePair <double, Point> > curvePoints = edgePoints[e];
            var wh = new Point(label.Width, label.Height);

            int bestConflictIndex = -1;
            var bestRectangle     = new Rectangle();

            foreach (int index in ExpandingSearch(StartIndex(label, curvePoints), 0, curvePoints.Count))
            {
                KeyValuePair <double, Point> cp = curvePoints[index];

                ICurve curve = e.Curve ?? new LineSegment(e.Source.Center, e.Target.Center);
                Point  der   = curve.Derivative(cp.Key);
                if (der.LengthSquared < ApproximateComparer.DistanceEpsilon)
                {
                    continue;
                }

                foreach (double side in GetPossibleSides(label.Side, der))
                {
                    Rectangle queryRect = GetLabelBounds(cp.Value, der, wh, side);

                    int conflictIndex = ConflictIndex(queryRect, label);
                    if (conflictIndex > bestConflictIndex)
                    {
                        bestConflictIndex = conflictIndex;
                        bestRectangle     = queryRect;

                        // If the best location was found, we're done
                        if (bestConflictIndex == int.MaxValue)
                        {
                            break;
                        }
                    }
                }

                // If the best location was found, we're done
                if (bestConflictIndex == int.MaxValue)
                {
                    break;
                }
            }

            if (bestConflictIndex >= 0)
            {
                SetLabelBounds(label, bestRectangle);

                var r = new RectangleObstacle(bestRectangle);
                AddLabelObstacle(r);

#if SHARPKIT //https://code.google.com/p/sharpkit/issues/detail?id=371
                if (bestConflictIndex == 0)
                {
                    label.PlacementResult = LabelPlacementResult.OverlapsOtherLabels;
                }
                else if (bestConflictIndex == 1)
                {
                    label.PlacementResult = LabelPlacementResult.OverlapsNodes;
                }
                else if (bestConflictIndex == 2)
                {
                    label.PlacementResult = LabelPlacementResult.OverlapsEdges;
                }
                else
                {
                    label.PlacementResult = LabelPlacementResult.OverlapsNothing;
                }
#else
                label.PlacementResult = (LabelPlacementResult)bestConflictIndex;
#endif
                return(true);
            }

            return(false);
        }