Beispiel #1
0
        private void BuildWebNode(int a, int b, int c)
        {
            Point2D point = this.Polygon.GetPoint(a);

            if (this.GetArea(b, c, point.X, point.Y) < 0)
            {
                int tmp;
                tmp = b;
                b   = c;
                c   = tmp;
            }

            //Debug.Assert(this.GetArea(b, c, point.X, point.Y ) >= 0);

            //if (this.GetArea(b, c, point.X, point.Y) < 0)
            //{
            //	this.available = false;
            //	return;
            //}

            if (webNodes[a] == null)
            {
                webNodes[a] = new WebNode(b, c, a);
            }

            else
            {
                webNodes[a].Add(new WebNode(b, c, a));
            }
        }
Beispiel #2
0
        private double[] GetValue(int index)
        {
            double[] d = new double[8];

            WebNode Router = this.webNodes[index];

            int count = 0;

            while (Router != null)
            {
                Point2D p1 = this.Polygon.GetPoint(Router.firstIndex);
                Point2D p2 = this.Polygon.GetPoint(Router.secondIndex);

                double dx = p2.X - p1.X;
                double dy = p1.Y - p2.Y;

                d[0] += dx;                 // x2 - x1;
                d[1] += dy;                 // y1 - y2;
                d[2] += dx * dx;
                d[3] += dy * dy;
                d[4] += dx * dy;
                d[5] += (p1.X * p2.Y - p2.X * p1.Y) * dy;
                d[6] += (p1.X * p2.Y - p2.X * p1.Y) * dx;
                d[7] += this.GetArea(Router.firstIndex, Router.secondIndex, 0.0, 0.0);

                Router = Router.Next;
                count++;
            }

            d[7] /= count;

            return(d);
        }
Beispiel #3
0
        public WebNode(int x, int y, int index)
        {
            vertexIndex = index;
            firstIndex  = x;
            secondIndex = y;

            Next = null;
            Last = this;
        }
Beispiel #4
0
        private bool isRegular(int index, Point2D point)
        {
            WebNode Router = this.webNodes[index];

            while (Router != null)
            {
                if (this.GetArea(Router.firstIndex, Router.secondIndex, point.X, point.Y) < GhostWeb.AreaTolerance)
                {
                    return(false);
                }
                Router = Router.Next;
            }
            return(true);
        }
Beispiel #5
0
        private double GetPolygonArea(int index)
        {
            double  d      = 0.0;
            WebNode Router = this.webNodes[index];

            int count = 0;

            while (Router != null)
            {
                d     += this.GetArea(Router.firstIndex, Router.secondIndex, 0.0, 0.0);
                Router = Router.Next;
                count++;
            }

            return(d / count);
        }
Beispiel #6
0
        public void Fitting()
        {
            GhostWeb ghostWeb = new GhostWeb(this.sourcePolygon, this.ghostTriangles);

            Vector[] vectors = new Vector[this.sourcePolygon.PointCount];

            for (int i = 0; i < vectors.Length; i++)
            {
                vectors[i]    = new Vector(vectors.Length);
                vectors[i][i] = 1;

                if (i < this.sourcePolygon.VertexCount || this.sourcePolygon.isOnEdge(this.sourcePolygon.GetPoint(i)))
                {
                    continue;
                }

                else
                {
                    vectors[i][i] = 0;
                    WebNode webNode = ghostWeb.webNodes[i];

                    while (webNode != null)
                    {
                        vectors[i][i]++;
                        vectors[i][webNode.firstIndex]  = -1;
                        vectors[i][webNode.secondIndex] = -1;

                        webNode = webNode.Next;
                    }
                }
            }

            Vector valx = new Vector(this.sourcePolygon.PointCount);
            Vector valy = new Vector(this.sourcePolygon.PointCount);

            for (int i = 0; i < this.targetPolygon.VertexCount; i++)
            {
                valx[i] = this.targetPolygon.GetPoint(i).X;
                valy[i] = this.targetPolygon.GetPoint(i).Y;
            }

            for (int i = this.sourcePolygon.VertexCount; i < this.sourcePolygon.PointCount; i++)
            {
                Point2D point = this.sourcePolygon.GetPoint(i);
                if (this.sourcePolygon.isOnEdge(point))
                {
                    int           x    = this.sourcePolygon.OnEdge(point);
                    LineSegment2D line = this.sourcePolygon.GetEdge(x);

                    double pos = line.GetPosition(point);
                    line = this.targetPolygon.GetEdge(x);

                    Point2D newPoint = line.GetPoint(pos);

                    valx[i] = newPoint.X;
                    valy[i] = newPoint.Y;
                }
            }

            Matrix m = new Matrix(vectors).Translate();

            UpdateStatus(this, "Constructing...");

            LinearSystem lsx = new LinearSystem(new Matrix(m), valx);

            UpdateStatus(this, "Done");

            lsx.UpdateStatus += new Microsoft.VS.Akira.Triangulations.LinearSystem.ShowStatus(UpdateStatus);
            lsx.Gaussian(this.sourcePolygon.VertexCount);

            LinearSystem lsy = new LinearSystem(new Matrix(m), valy);

            lsy.UpdateStatus += new Microsoft.VS.Akira.Triangulations.LinearSystem.ShowStatus(UpdateStatus);
            lsy.Gaussian(this.sourcePolygon.VertexCount);

            Polygon2DEditor pe = new Polygon2DEditor(this.targetPolygon);

            UpdateStatus(this, "AddInner..");

            for (int i = this.sourcePolygon.VertexCount; i < this.sourcePolygon.PointCount; i++)
            {
                Point2D point = new Point2D(lsx.Value[i], lsy.Value[i]);
                pe.AddInnerPoint(point);
            }

            UpdateStatus(this, "Done");
        }
Beispiel #7
0
 public void Add(WebNode webNode)
 {
     Last.Next = webNode;
     Last = webNode;
 }
Beispiel #8
0
        public WebNode(int x, int y, int index)
        {
            vertexIndex = index;
            firstIndex = x;
            secondIndex = y;

            Next = null;
            Last = this;
        }
Beispiel #9
0
        private void BuildWebNode(int a, int b, int c)
        {
            Point2D point = this.Polygon.GetPoint(a);

            if (this.GetArea(b, c, point.X, point.Y) < 0)
            {
                int tmp;
                tmp = b;
                b = c;
                c = tmp;
            }

            //Debug.Assert(this.GetArea(b, c, point.X, point.Y ) >= 0);

            //if (this.GetArea(b, c, point.X, point.Y) < 0)
            //{
            //	this.available = false;
            //	return;
            //}

            if (webNodes[a] == null)
            {
                webNodes[a] = new WebNode(b, c, a);
            }

            else
            {
                webNodes[a].Add(new WebNode(b, c, a));
            }
        }
Beispiel #10
0
 public void Add(WebNode webNode)
 {
     Last.Next = webNode;
     Last      = webNode;
 }