Exemple #1
0
        private void CheckRange(int yleft, int yright, int x, ParentDirectionsY ptype)
        {
            for (int i = yleft; i <= yright;)
            {
                if ((!flagsMap.GetFlagOn(x, i)) && IncludePredicate(x, i))
                {
                    int lb = i;
                    int rb = i + 1;
                    while (rb <= yright && (!flagsMap.GetFlagOn(x, rb)) && IncludePredicate(x, rb))
                    {
                        rb++;
                    }
                    rb--;

                    SpanY span = new SpanY();
                    span.YLeft  = lb;
                    span.YRight = rb;
                    span.X      = x;
                    if (lb == yleft && rb == yright)
                    {
                        span.Extended = ExtendTypesY.UnRez;
                    }
                    else if (rb == yright)
                    {
                        span.Extended = ExtendTypesY.RightRequired;
                    }
                    else if (lb == yleft)
                    {
                        span.Extended = ExtendTypesY.LeftRequired;
                    }
                    else
                    {
                        span.Extended = ExtendTypesY.AllRez;
                    }
                    span.ParentDirection = ptype;
                    for (int j = lb; j <= rb; j++)
                    {
                        flagsMap.SetFlagOn(x, j, true);
                        Process(new Int16Double(x, j));
                    }
                    queue.Push(span);

                    i = rb + 1;
                }
                else
                {
                    i++;
                }
            }
        }
Exemple #2
0
        protected void CheckRange(int xleft, int xright, int y, ParentDirections ptype)
        {
            for (int i = xleft; i <= xright;)
            {
                if ((!flagsMap.GetFlagOn(i, y)) && IncludePredicate(i, y))
                {
                    int lb = i;
                    int rb = i + 1;
                    while (rb <= xright && (!flagsMap.GetFlagOn(rb, y)) && IncludePredicate(rb, y))
                    {
                        rb++;
                    }
                    rb--;

                    Span span = new Span();
                    span.XLeft  = lb;
                    span.XRight = rb;
                    span.Y      = y;
                    if (lb == xleft && rb == xright)
                    {
                        span.Extended = ExtendTypes.UnRez;
                    }
                    else if (rb == xright)
                    {
                        span.Extended = ExtendTypes.RightRequired;
                    }
                    else if (lb == xleft)
                    {
                        span.Extended = ExtendTypes.LeftRequired;
                    }
                    else
                    {
                        span.Extended = ExtendTypes.AllRez;
                    }
                    span.ParentDirection = ptype;
                    for (int j = lb; j <= rb; j++)
                    {
                        flagsMap.SetFlagOn(j, y, true);
                        Process(new Int16Double(j, y));
                    }
                    container.Push(span);

                    i = rb + 1;
                }
                else
                {
                    i++;
                }
            }
        }//区段法的CheckRange 注意与扫描线的CheckRange的不同
Exemple #3
0
 protected virtual void ExcuteFloodFill(BitMap2d data, Int16Double seed)
 {
     this.bmp = data;
     data.ResetVisitCount();
     flagsMap = new FlagMap2d(data.width, data.height);
     Int16Double[] adjPoints4 = new Int16Double[4];
     flagsMap.SetFlagOn(seed.X, seed.Y, true);
     container.Push(seed);
     Process(seed);
     while (!container.Empty())
     {
         Int16Double p = container.Pop();
         InitAdj4(ref adjPoints4, ref p);
         for (int adjIndex = 0; adjIndex < 4; adjIndex++)
         {
             Int16Double t = adjPoints4[adjIndex];
             if (t.X < data.width && t.X >= 0 && t.Y < data.height && t.Y >= 0)
             {
                 if (!flagsMap.GetFlagOn(t.X, t.Y) && IncludePredicate(t))
                 {
                     flagsMap.SetFlagOn(t.X, t.Y, true);
                     container.Push(t);
                     Process(t);
                 }
             }
         }
     }
     return;
 }
Exemple #4
0
        }//该函数为扫描线法主体

        protected void CheckRange(int xleft, int xright, int y)
        {
            for (int i = xleft; i <= xright;)
            {
                if ((!flagsMap.GetFlagOn(i, y)) && IncludePredicate(i, y))
                {
                    int rb = i + 1;
                    while (rb <= xright && (!flagsMap.GetFlagOn(rb, y)) && IncludePredicate(rb, y))
                    {
                        rb++;
                    }
                    rb--;
                    Int16Double t = new Int16Double(rb, y);
                    flagsMap.SetFlagOn(rb, y, true);
                    container.Push(t);
                    Process(t);
                    i = rb + 1;
                }
                else
                {
                    i++;
                }
            }
        }//CheckRange操作
Exemple #5
0
 public void OutPutMap(FlagMap2d flagsmap, string path)
 {
     System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(flagsmap.width, flagsmap.height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
     for (int i = 0; i < flagsmap.width; i++)
     {
         for (int j = 0; j < flagsmap.height; j++)
         {
             bool s = flagsmap.GetFlagOn(i, j);
             if (s)
             {
                 bmp.SetPixel(i, j, System.Drawing.Color.White);
             }
             else
             {
                 bmp.SetPixel(i, j, System.Drawing.Color.Black);
             }
         }
     }
     bmp.Save(path);
 }