Esempio n. 1
0
            public QuadNode(Rectangle box, TriangleQuadTree tree, bool init)
            {
                this.tree = tree;

                this.bounds = new Rectangle(box.Left, box.Bottom, box.Width, box.Height);
                this.pivot  = new Point((box.Left + box.Right) / 2, (box.Bottom + box.Top) / 2);

                this.bitRegions = 0;

                this.regions   = new QuadNode[4];
                this.triangles = new List <int>();

                if (init)
                {
                    int count = tree.triangles.Length;

                    // Allocate memory upfront
                    triangles.Capacity = count;

                    for (int i = 0; i < count; i++)
                    {
                        triangles.Add(i);
                    }
                }
            }
Esempio n. 2
0
        private ITriangle FindTriangleAt(float x, float y)
        {
            // Get mesh coordinates
            var p = new System.Drawing.PointF(x, y);
            renderControl.Zoom.ScreenToWorld(ref p);

            topoControlView.SetPosition(p);

            if (tree == null)
            {
                tree = new TriangleQuadTree(mesh, 5, 2);
            }

            return tree.Query(p.X, p.Y);
        }
Esempio n. 3
0
            void AddTriangleToRegion(Point[] triangle, int index)
            {
                bitRegions = 0;
                if (TriangleQuadTree.IsPointInTriangle(pivot, triangle[0], triangle[1], triangle[2]))
                {
                    AddToRegion(index, SW);
                    AddToRegion(index, SE);
                    AddToRegion(index, NW);
                    AddToRegion(index, NE);
                    return;
                }

                FindTriangleIntersections(triangle, index);

                if (bitRegions == 0)
                {
                    // we didn't find any intersection so we add this triangle to a point's region
                    int region = FindRegion(triangle[0]);
                    regions[region].triangles.Add(index);
                }
            }
            public QuadNode(Rectangle box, TriangleQuadTree tree, bool init)
            {
                this.tree = tree;

                this.bounds = new Rectangle(box.Left, box.Bottom, box.Width, box.Height);
                this.pivot = new Point((box.Left + box.Right) / 2, (box.Bottom + box.Top) / 2);

                this.bitRegions = 0;

                this.regions = new QuadNode[4];
                this.triangles = new List<int>();

                if (init)
                {
                    int count = tree.triangles.Length;

                    // Allocate memory upfront
                    triangles.Capacity = count;

                    for (int i = 0; i < count; i++)
                    {
                        triangles.Add(i);
                    }
                }
            }
 public QuadNode(Rectangle box, TriangleQuadTree tree)
     : this(box, tree, false)
 {
 }
Esempio n. 6
0
 public QuadNode(Rectangle box, TriangleQuadTree tree)
     : this(box, tree, false)
 {
 }