Exemplo n.º 1
0
        /* Draws the Minkowski Convolution (e.g. only the enlarged polygon)
         */
        public void DrawMinkConvol(System.Drawing.Graphics g, int w, int h)
        {
            System.Diagnostics.Debug.WriteLine("before drawing enlarged polygon, its pointCloud:");
            output.PrintVertices();

            cVertex v1 = output.head;
            //cVertex v2;

            //do
            //{
            //    v2 = v1.next;
            //    g.setColor(System.Drawing.Color.Pink);
            //    if (P.n >= 2)
            //        g.drawLine(v1.v.x, v1.v.y, v2.v.x, v2.v.y);
            //    g.fillOval(v1.v.x - (int)(w / 2), v1.v.y - (int)(h / 2), w, h);
            //    g.fillOval(v2.v.x - (int)(w / 2), v2.v.y - (int)(h / 2), w, h);
            //    v1 = v1.next;
            //} while (v1 != output.head.prev);
            //g.drawLine(v1.v.x, v1.v.y, v1.next.v.x, v1.next.v.y);
            //System.Diagnostics.Debug.WriteLine("the enlarged polygon has been drawn");
        }
        private void Vectorize()
        {
            int     i;
            cVertex v;

            v = P.head;
            System.Diagnostics.Debug.WriteLine("Vectorize: ");
            System.Diagnostics.Debug.WriteLine("list before victorization");
            P.PrintVertices();
            cVertex startB = P.GetElement(n);

            System.Diagnostics.Debug.WriteLine("startB !!!: ");
            startB.PrintVertex();

            SubVec(P.head.Point, startB.PrevVertex.Point, last);
            do
            {
                cPointi c = SubVec(v.NextVertex.Point, v.Point);
                System.Diagnostics.Debug.WriteLine("(" + v.NextVertex.Point.X + "," + v.NextVertex.Point.Y + ") - (" + v.Point.X + "," + v.Point.Y + ")");
                v.Point.X = c.X;
                v.Point.Y = c.Y;
                v         = v.NextVertex;
            } while (v != startB.PrevVertex);
            startB.PrevVertex.Point.X = last.X;
            startB.PrevVertex.Point.Y = last.Y;

            SubVec(startB.Point, P.head.PrevVertex.Point, last);
            v = startB;
            do
            {
                cPointi c = SubVec(v.NextVertex.Point, v.Point);
                System.Diagnostics.Debug.WriteLine("(" + v.NextVertex.Point.X + "," + v.NextVertex.Point.Y + ") - (" + v.Point.X + "," + v.Point.Y + ")");
                v.Point.X = c.X;
                v.Point.Y = c.Y;
                v         = v.NextVertex;
            } while (v != P.head.PrevVertex);
            P.head.PrevVertex.Point.X = last.X;
            P.head.PrevVertex.Point.Y = last.Y;
        }