コード例 #1
0
        public static IEnumerable <Subpath> Unify(IEnumerable <Subpath> subpaths)
        {
            var collection = new SubpathCollection();

            foreach (var subpath in subpaths)
            {
                if (subpath.AreSegmentsClosed)
                {
                    if (HasFillArea(subpath))
                    {
                        yield return(subpath);
                    }
                }
                else
                {
                    collection.Add(subpath);
                }
            }
            var subpath1 = collection.Dequeue();

            while (subpath1 != null)
            {
                var concatenations = collection.GetAll(subpath1.EndPoint).ToArray();
                Debugger.BreakWhen(concatenations.Length == 0);
                if (concatenations.Length > 0)
                {
                    var subpath2 = ChooseConcatenation(subpath1, concatenations);
                    collection.Remove(subpath2);
                    subpath1 = new Subpath(subpath1.StartPoint, subpath1.Segments.Concat(subpath2.Segments), false);
                    if (!subpath1.AreSegmentsClosed)
                    {
                        continue;
                    }
                }
                if (HasFillArea(subpath1))
                {
                    yield return(subpath1);
                }
                subpath1 = collection.Dequeue();
            }
        }
コード例 #2
0
 public static IEnumerable<Subpath> Unify(IEnumerable<Subpath> subpaths)
 {
     var collection = new SubpathCollection();
     foreach (var subpath in subpaths)
     {
         if (subpath.AreSegmentsClosed)
         {
             if (HasFillArea(subpath))
             {
                 yield return subpath;
             }
         }
         else
         {
             collection.Add(subpath);
         }
     }
     var subpath1 = collection.Dequeue();
     while (subpath1 != null)
     {
         var concatenations = collection.GetAll(subpath1.EndPoint).ToArray();
         Debugger.BreakWhen(concatenations.Length == 0);
         if (concatenations.Length > 0)
         {
             var subpath2 = ChooseConcatenation(subpath1, concatenations);
             collection.Remove(subpath2);
             subpath1 = new Subpath(subpath1.StartPoint, subpath1.Segments.Concat(subpath2.Segments), false);
             if (!subpath1.AreSegmentsClosed)
             {
                 continue;
             }
         }
         if (HasFillArea(subpath1))
         {
             yield return subpath1;
         }
         subpath1 = collection.Dequeue();
     }
 }