Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="poly1"></param>
        /// <param name="poly2"></param>
        /// <param name="poly"></param>
        /// <param name="curedge"></param>
        private static void SetInitData(Polygon2D poly1, Polygon2D poly2, ref Polygon2D poly, ref Double2 curPoint, ref int curedge)
        {
            if (poly1 == null || poly2 == null || poly1.GetEdgeNum() < 3 || poly2.GetEdgeNum() < 3)
            {
                return;
            }
            // 先找poly1 最小的。
            poly    = poly1;
            curedge = 0;
            Double2 min = poly1.GetPoint(0);

            for (int i = 1; i < poly1.GetEdgeNum(); i++)
            {
                Double2 point = poly1.GetPoint(i);
                if (point.y < min.y || (point.y == min.y && point.x < min.x))
                {
                    min     = point;
                    curedge = i;
                }
            }
            //
            for (int i = 0; i < poly2.GetEdgeNum(); i++)
            {
                Double2 point = poly2.GetPoint(i);
                if (point.y < min.y || (point.y == min.y && point.x < min.x))
                {
                    min     = point;
                    curedge = i;
                    poly    = poly2;
                }
            }
            curPoint = min;
        }
Exemple #2
0
 /// <summary>
 /// 与多边形的关系
 /// </summary>
 /// <param name="dbd1"></param>
 /// <returns>true 相交: false 不相交</returns>
 public override bool CheckIntersect(Polygon2D ab)
 {
     if (ab == null)
     {
         return(false);
     }
     for (int i = 0; i < ab.GetEdgeNum(); i++)
     {
         if (this.CheckIn(ab.GetPoint(i)) == true)
         {
             return(true);
         }
         if (this.CheckLineRelation(ab.GetEdge(i)) == LineRelation.Intersect)
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #3
0
        /// <summary>
        /// 主多边形上找到一个顶点,不在diff多边形内的。
        /// </summary>
        /// <param name="mainPoly"></param>
        /// <param name="diffpoly"></param>
        /// <param name="poly"></param>
        /// <param name="curedge"></param>
        public static bool FindOutDiffPointPoint(Polygon2D mainPoly, Polygon2D diffpoly, ref Double2 curPoint, ref int curedge)
        {
            if (mainPoly == null || diffpoly == null || mainPoly.GetEdgeNum() < 3 || diffpoly.GetEdgeNum() < 3)
            {
                return(false);
            }

            for (int i = 0; i < mainPoly.GetEdgeNum(); i++)
            {
                Double2 point = mainPoly.GetPoint(i);
                if (diffpoly.CheckIn(point) == false)
                {
                    curPoint = point;
                    curedge  = i;
                    return(true);
                }
            }
            return(false);
        }