Example #1
0
        private void TestFlip(List <Vector3> points, Triangles triangles, WorkBuffer <Int2> stack, int a, int b, int x)
        {
            var y = triangles.Opposite(a, b);

            //Test boundary edge
            if (y < 0)
            {
                return;
            }

            //Swap edge if order flipped
            if (b < a)
            {
                var tmp = a;
                a   = b;
                b   = tmp;
                tmp = x;
                x   = y;
                y   = tmp;
            }

            //Test if edge is constrained
            if (triangles.IsConstraint(a, b))
            {
                return;
            }

            //Test if edge is delaunay
            if (Robust.InSphere(points[a], points[b], points[x], points[y]) < 0f)
            {
                var v = new Int2(a, b);
                stack.Push(ref v);
            }
        }
Example #2
0
        public void Fill(WorkBuffer <Int3> triangles)
        {
            var n = PrivateStars.Length;

            triangles.Extend(n);
            triangles.Clear();

            for (var i = 0; i < n; ++i)
            {
                var list = PrivateStars[i];
                var data = list.Data;
                var m    = list.UsedSize;
                for (var j = 0; j < m; ++j)
                {
                    var s = data[j];
                    if (i < Mathf.Min(s.x, s.y))
                    {
                        var v = new Int3(i, s.x, s.y);
                        triangles.Push(ref v);
                    }
                }
            }
        }