Ejemplo n.º 1
0
            public BitmaskShape3(string[][] shape)
            {
                int columnMax = shape.Max(row => row.Length);
                int rowMax    = shape.SelectMany(c => c).Max(c => c.Length);

                var bounds = new GridBounds(GridPoint3.Zero, new GridPoint3(rowMax, columnMax, shape.Length));

                grid = new Grid3 <bool>(bounds);

                foreach (var point in grid.Points)
                {
                    if (point.Y < shape[point.Z].Length)
                    {
                        if (point.X < shape[point.Z][point.Y].Length)
                        {
                            grid[point] = shape[point.Z][point.Y][point.X] != '0';
                        }
                        else
                        {
                            grid[point] = false;
                        }
                    }
                    else
                    {
                        grid[point] = false;
                    }
                }
            }
Ejemplo n.º 2
0
        public static IExplicitShape <GridPoint3> Translate(this IExplicitShape <GridPoint3> shape, GridPoint3 n)
        {
            var newBounds = GridBounds.Translate(shape.Bounds, n);
            var newShape  = ImplicitShape.Translate(shape, n).ToExplicit(newBounds);

            return(newShape);
        }
Ejemplo n.º 3
0
            public ExplicitShape3 Intersection(ExplicitShape3 shape2)
            {
                var newRect  = GridBounds.Intersection(storageBounds, shape2.storageBounds);
                var newShape = ImplicitShape.Intersection(implicitShape, shape2.implicitShape);

                return(new ExplicitShape3(newShape, newRect));
            }
Ejemplo n.º 4
0
            public ExplicitShape3 Union(ExplicitShape3 shape2)
            {
                var newRect  = GridBounds.UnionBoundingBox(storageBounds, shape2.storageBounds);
                var newShape = ImplicitShape.Union(implicitShape, shape2.implicitShape);

                return(new ExplicitShape3(newShape, newRect));
            }
Ejemplo n.º 5
0
        public static IExplicitShape <GridPoint3> Layer(this IExplicitShape <GridPoint2> shape, int layerCount)
        {
            var bounds    = shape.Bounds;
            var newBounds = new GridBounds(bounds.Point.To3DXY(0), bounds.Size.To3DXY(layerCount));

            // static call is necessary so that this method does not get called instead
            //Remember: explicit shapes _are_ implicit shapes too.
            return(ImplicitShape.Layer(shape, layerCount).ToExplicit(newBounds));
        }
Ejemplo n.º 6
0
            public ExplicitShape3 Translate(GridPoint3 offset)
            {
                var map = Map.Translate(offset);

                var newRect  = GridBounds.Translate(storageBounds, offset);
                var newShape = ImplicitShape.Transform(implicitShape, map);

                return(new ExplicitShape3(newShape, newRect));
            }
Ejemplo n.º 7
0
        public static IExplicitShape <GridPoint3> SwapToZYX(this IExplicitShape <GridPoint3> shape)
        {
            var bounds = shape.Bounds;
            var point  = bounds.Point;
            var size   = bounds.Size;

            var newBounds = new GridBounds(
                new GridPoint3(point.Z, point.Y, point.X), new GridPoint3(size.Z, size.Y, size.X));

            return(ImplicitShape.SwapToZYX(shape).ToExplicit(newBounds));
        }