示例#1
0
        public void ContainsPointCases(int x, int y, int z, bool shouldPass)
        {
            var point = new Point3Int(x, y, z);
            var box   = new BoundingCuboid(new Point3Int(-1, -1, -1), new Point3Int(1, 1, 1));

            Assert.AreEqual(shouldPass, box.ContainsPoint(point));
        }
示例#2
0
        public void AssertValuesHold(int llx, int lly, int llz, int urx, int ury, int urz)
        {
            var lowerLeft  = new Point3Int(llx, lly, llz);
            var upperRight = new Point3Int(urx, ury, urz);

            var ut = new BoundingCuboid(lowerLeft, upperRight);

            Assert.AreEqual(lowerLeft, ut.LowerLeft);
            Assert.AreEqual(upperRight, ut.UpperRight);
        }
示例#3
0
        public void BoundaryTests(int minx, int miny, int minz, int maxx, int maxy, int maxz, bool shouldPass)
        {
            var bottomLeft = new Point3Int(minx, miny, minz);
            var upperRight = new Point3Int(maxx, maxy, maxz);

            var ut = new BoundingCuboid(bottomLeft, upperRight);

            var box = new BoundingCuboid(new Point3Int(-2, -2, -2), new Point3Int(2, 2, 2));

            Assert.AreEqual(shouldPass, box.DoesBoundaryCuboidIntersect(ut));
        }
示例#4
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 GetPointsInBoundingArea(int octMinX, int octMinY, int octMinZ, int octMaxX, int octMaxY, int octMaxZ,
                                            int boundaryMinX, int boundaryMinY, int boundaryMinZ, int boundaryMaxX, int boundaryMaxY, int boundaryMaxZ,
                                            int x, int y, int z,
                                            bool expected)
        {
            var octTreeBoundingBox = new BoundingCuboid(new Point3Int(octMinX, octMinY, octMinZ), new Point3Int(octMaxX, octMaxY, octMaxZ));

            var area = new BoundingCuboid(new Point3Int(boundaryMinX, boundaryMinY, boundaryMinZ), new Point3Int(boundaryMaxX, boundaryMaxY, boundaryMaxZ));

            var obj   = new object();
            var point = new Point3Int <object>(x, y, z, obj);

            var ut = new OctTree <object>(octTreeBoundingBox, 10, new SimpleOctTreeDivisionStrategy <object>());

            ut.Add(point);

            var points = new List <Point3Int <object> >();

            ut.GetPointsWithinBoundary(area, ref points);

            Assert.AreEqual(expected, points.Contains(point));
        }
        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);
        }