Exemple #1
0
        /// <summary>
        /// 按逆时针方向获得边界圈
        /// </summary>
        /// <param name="first"></param>
        /// <returns></returns>
        private BorderCircleList BuildCircle ( BorderPoint first )
        {
            BorderCircleList result = new BorderCircleList();

            BorderNode firstNode = new BorderNode( first );
            result.AddLast( firstNode );

            Point prePoint = new Point();
            Point curPoint = firstNode.value.p;

            try
            {
                //set the prePoint at the first time!
                SetPrePointFirstTime( firstNode.value.p, ref prePoint );


                bool linked = false;
                while (!linked)
                {
                    bool findNext = false;

                    foreach (Point p in SurroundQueue( curPoint, prePoint ))
                    {
                        if (borderMap[p.X, p.Y] && p != prePoint)
                        {
                            findNext = true;

                            if (p == firstNode.value.p)
                            {
                                linked = true;
                                result.LinkLastAndFirst();
                                break;
                            }

                            result.AddLast( new BorderPoint( p ) );
                            prePoint = curPoint;
                            curPoint = p;
                            break;
                        }
                    }
                    if (!findNext)
                    {
#if SHOWERROR
                        //ShowDataToConsole();
                        //ShowCurListResult( result );
#endif
                        throw new BorderBulidException( curPoint, prePoint, borderMap );
                    }
                }

            }
            // 如果此处出现异常,往往是导入的图片不能满足要求。
            // 将在输出中打印出图片上具体出错的位置。
            // 需要重新修改图片以正常使用。
            catch (BorderBulidException e)
            {
#if SHOWERROR
                //ShowDataToConsole();
                //ShowCurListResult( result );
#endif
                throw e;
                //return result;
            }
            return result;
        }
Exemple #2
0
        /// <summary>
        /// 按逆时针方向获得边界圈
        /// </summary>
        /// <param name="first"></param>
        /// <returns></returns>
        private BorderCircleList BuildCircle(BorderPoint first)
        {
            BorderCircleList result = new BorderCircleList();

            BorderNode firstNode = new BorderNode(first);

            result.AddLast(firstNode);

            Point prePoint = new Point();
            Point curPoint = firstNode.value.p;

            try
            {
                //set the prePoint at the first time!
                SetPrePointFirstTime(firstNode.value.p, ref prePoint);


                bool linked = false;
                while (!linked)
                {
                    bool findNext = false;

                    foreach (Point p in SurroundQueue(curPoint, prePoint))
                    {
                        if (borderMap[p.X, p.Y] && p != prePoint)
                        {
                            findNext = true;

                            if (p == firstNode.value.p)
                            {
                                linked = true;
                                result.LinkLastAndFirst();
                                break;
                            }

                            result.AddLast(new BorderPoint(p));
                            prePoint = curPoint;
                            curPoint = p;
                            break;
                        }
                    }
                    if (!findNext)
                    {
#if SHOWERROR
                        //ShowDataToConsole();
                        //ShowCurListResult( result );
#endif
                        throw new BorderBulidException(curPoint, prePoint, borderMap);
                    }
                }
            }
            // 如果此处出现异常,往往是导入的图片不能满足要求。
            // 将在输出中打印出图片上具体出错的位置。
            // 需要重新修改图片以正常使用。
            catch (BorderBulidException e)
            {
#if SHOWERROR
                //ShowDataToConsole();
                //ShowCurListResult( result );
#endif
                throw e;
                //return result;
            }
            return(result);
        }