Beispiel #1
0
        public void CenterTests(
            int minx, int miny, int minz,
            int maxx, int maxy, int maxz,
            int x, int y, int z,
            bool expected)
        {
            var ut     = new BoundingCuboid(new Point3Int(minx, miny, minz), new Point3Int(maxx, maxy, maxz));
            var point  = new Point3Int(x, y, z);
            var center = ut.CenterPoint();

            Assert.AreEqual(expected, point == center);
        }
        public void SubDivide(Point3Int <T>[] existingPoints,
                              Point3Int <T> newPoint,
                              BoundingCuboid boundary,
                              out OctTree <T> tlf,
                              out OctTree <T> trf,
                              out OctTree <T> tlb,
                              out OctTree <T> trb,
                              out OctTree <T> blf,
                              out OctTree <T> brf,
                              out OctTree <T> blb,
                              out OctTree <T> brb)
        {
            int maxItems = existingPoints.Length;
            var center   = boundary.CenterPoint();

            //blf
            var minBlf = boundary.LowerLeft;
            var mzxBlf = center;

            blf = new OctTree <T>(new BoundingCuboid(minBlf, mzxBlf), maxItems, this);

            //brf
            var minBrf = new Point3Int(center.X, boundary.LowerLeft.Y, boundary.LowerLeft.Z);
            var maxBrf = new Point3Int(boundary.UpperRight.X, center.Y, center.Z);

            brf = new OctTree <T>(new BoundingCuboid(minBrf, maxBrf), maxItems, this);

            //blb
            var minBlb = new Point3Int(boundary.LowerLeft.X, boundary.LowerLeft.Y, center.Z);
            var maxBlb = new Point3Int(center.X, center.Y, boundary.UpperRight.Z);

            blb = new OctTree <T>(new BoundingCuboid(minBlb, maxBlb), maxItems, this);

            //brb
            var minBrb = new Point3Int(center.X, boundary.LowerLeft.Y, center.Z);
            var maxBrb = new Point3Int(boundary.UpperRight.X, center.Y, boundary.UpperRight.Z);

            brb = new OctTree <T>(new BoundingCuboid(minBrb, maxBrb), maxItems, this);

            //tlf
            var minTlf = new Point3Int(boundary.LowerLeft.X, center.Y, boundary.LowerLeft.Z);
            var maxTlf = new Point3Int(center.X, boundary.UpperRight.Y, center.Z);

            tlf = new OctTree <T>(new BoundingCuboid(minTlf, maxTlf), maxItems, this);

            //trf
            var minTrf = new Point3Int(center.X, center.Y, boundary.LowerLeft.Z);
            var maxTrf = new Point3Int(boundary.UpperRight.X, boundary.UpperRight.Y, center.Z);

            trf = new OctTree <T>(new BoundingCuboid(minTrf, maxTrf), maxItems, this);

            //tlb
            var minTlb = new Point3Int(boundary.LowerLeft.X, center.Y, center.Z);
            var maxTlb = new Point3Int(center.X, boundary.UpperRight.Y, boundary.UpperRight.Z);

            tlb = new OctTree <T>(new BoundingCuboid(minTlb, maxTlb), maxItems, this);

            //trb
            var minTrb = center;
            var maxTrb = boundary.UpperRight;

            trb = new OctTree <T>(new BoundingCuboid(minTrb, maxTrb), maxItems, this);

            foreach (var point3Int in existingPoints)
            {
                AddPoint(blf, brf, blb, brb, tlf, trf, tlb, trb, point3Int, center);
            }

            AddPoint(blf, brf, blb, brb, tlf, trf, tlb, trb, newPoint, center);
        }