public bool L_L_IntersectVertex(G_Line pFirst, G_Line pSecond)
        {
            double dist = new ToolForStroke().distanceP2P(pFirst.startPt, pSecond.startPt);

            if (dist < 500)
            {
                return(true);
            }

            dist = new ToolForStroke().distanceP2P(pFirst.startPt, pSecond.endPt);
            if (dist < 500)
            {
                return(true);
            }

            dist = new ToolForStroke().distanceP2P(pFirst.endPt, pSecond.startPt);
            if (dist < 500)
            {
                return(true);
            }

            dist = new ToolForStroke().distanceP2P(pFirst.endPt, pSecond.endPt);
            if (dist < 500)
            {
                return(true);
            }

            return(false);
        }
        public void setLenth()
        {
            Point p1 = startPoint;

            lenth = 0;
            for (int i = 1; i < points.Length; i++)
            {
                lenth += new ToolForStroke().distanceP2P(points[i - 1], points[i]);
            }
        }
Beispiel #3
0
        public void drawBoundingBoxtoTestGrouppingResult()
        {
            //画出ReGroup后的group的包围盒,测试group是否正确

            //统计有多少个group
            SKContextDGNode head     = sketch.sketchContextDG.firstNode;
            SKContextDGNode nextNode = new SKContextDGNode();
            SKContextDGNode curNode  = new SKContextDGNode();

            curNode  = head;
            nextNode = curNode.tPointer;

            int nGroupCount = -1;

            foreach (SKContextDGNode nd in sketch.sketchContextDG.DGNodeList)
            {
                if (nd.groupID > nGroupCount)
                {
                    nGroupCount = nd.groupID;
                }
            }

            Rectangle[] boundingBoxArray;
            boundingBoxArray = new Rectangle[nGroupCount];
            for (int i = 0; i < nGroupCount; i++)
            {
                boundingBoxArray[i] = new Rectangle(1000000, 1000000, -2000000, -2000000);
            }
            int index = 0;

            foreach (SKContextDGNode nd in sketch.sketchContextDG.DGNodeList)
            {
                index = nd.groupID;
                int Left   = boundingBoxArray[index - 1].Left;
                int Right  = boundingBoxArray[index - 1].Right;
                int Top    = boundingBoxArray[index - 1].Top;
                int Bottom = boundingBoxArray[index - 1].Bottom;


                Rectangle rect = nd.strokeGroup.boundingBox;
                Console.Write("node" + nd.ID + "boundingbox:" + "(" + rect.Left + "," + rect.Top + "," + rect.Width + "," + rect.Height + ")");

                if (rect.Left < Left)
                {
                    Left = rect.Left;
                }
                if (rect.Right > Right)
                {
                    Right = rect.Right;
                }
                if (rect.Top < Top)
                {
                    Top = rect.Top;
                }
                if (rect.Bottom > Bottom)
                {
                    Bottom = rect.Bottom;
                }

                boundingBoxArray[index - 1] = new Rectangle(Left, Top, System.Math.Abs(Right - Left), System.Math.Abs(Bottom - Top));
            }

            //绘制出所有的group的包围盒
            Graphics g     = inkPanel.CreateGraphics();
            Pen      mypen = new Pen(Color.Blue);

            for (int i = 0; i < nGroupCount; i++)
            {
                Rectangle rt = new ToolForStroke().InkSpaceToPixelRect(inkPanel.Handle, drawingInk.Renderer, boundingBoxArray[i]);
                g.DrawRectangle(mypen, rt);
                Console.Write("Group" + i + "boundingbox:" + "(" + boundingBoxArray[i].Left + "," + boundingBoxArray[i].Top + "," + boundingBoxArray[i].Width + "," + boundingBoxArray[i].Height + ")");
            }
        }