Ejemplo n.º 1
0
 protected virtual void ExcuteScanlineFill(BitMap3d data, Int16Triple seed)
 {
     this.bmp = data;
     data.ResetVisitCount();
     flagsMap = new FlagMap3d(data.width, data.height, data.depth);
     flagsMap.SetFlagOn(seed.X, seed.Y, seed.Z, true);
     container.Push(seed);
     Process(seed);
     while (!container.Empty())
     {
         Int16Triple p      = container.Pop();
         int         xleft  = FindXLeft(p);
         int         xright = FindXRight(p);
         if (p.Y - 1 >= 0)
         {
             CheckRange(xleft, xright, p.Y - 1, p.Z);
         }
         if (p.Y + 1 < data.height)
         {
             CheckRange(xleft, xright, p.Y + 1, p.Z);
         }
         if (p.Z - 1 >= 0)
         {
             CheckRange(xleft, xright, p.Y, p.Z - 1);
         }
         if (p.Z + 1 < data.depth)
         {
             CheckRange(xleft, xright, p.Y, p.Z + 1);
         }
     }
 }//该函数为扫描线法主体
Ejemplo n.º 2
0
 protected virtual void ExcuteFloodFill(BitMap3d data, Int16Triple seed)
 {
     this.bmp = data;
     data.ResetVisitCount();
     flagsMap = new FlagMap3d(data.width, data.height, data.depth);
     Int16Triple[] adjPoints6 = new Int16Triple[6];
     flagsMap.SetFlagOn(seed.X, seed.Y, seed.Z, true);
     container.Push(seed);
     Process(seed);
     while (!container.Empty())
     {
         Int16Triple p = container.Pop();
         InitAdj6(ref adjPoints6, ref p);
         for (int adjIndex = 0; adjIndex < 6; adjIndex++)
         {
             Int16Triple t = adjPoints6[adjIndex];
             if (t.X < data.width && t.X >= 0 && t.Y < data.height && t.Y >= 0 && t.Z < data.depth && t.Z >= 0)
             {
                 if (!flagsMap.GetFlagOn(t.X, t.Y, t.Z) && IncludePredicate(t))
                 {
                     flagsMap.SetFlagOn(t.X, t.Y, t.Z, true);
                     container.Push(t);
                     Process(t);
                 }
             }
         }
     }
     return;
 }
Ejemplo n.º 3
0
 public OctreeSurfaceGenerator(BitMap3d image)
 {
     this.bmp  = image;
     nodequeue = new Queue <OctreeNode <NodeParms> >();
     tempArray = new Int16Triple[8];
     tree      = new RegionOctree <NodeParms>(bmp.width, bmp.height, bmp.depth);
     mb        = new MeshBuilder_IntegerVertex(bmp.width, bmp.height, bmp.depth);
 }
Ejemplo n.º 4
0
 public static void ProcessImage(BitMap3d bmp)
 {
     byte[] data = bmp.data;
     for (int i = 0; i < data.Length; i++)
     {
         if (data[i] == 200)
         {
             data[i] = 0;
         }
     }
 }
Ejemplo n.º 5
0
        static Int16Triple RunOSMC(BitMap3d bmp, string type)
        {
            watch.Reset();
            watch.Start();
            OctreeSurfaceGenerator mc = new OctreeSurfaceGenerator(bmp);
            Mesh mesh = mc.GenerateSurface();

            watch.Stop();
            Console.WriteLine("OSMC Run time : " + watch.ElapsedMilliseconds + "ms," + "v: " + mesh.GetVertexCount() + " f:" + mesh.GetFaceCount());
            if (output)
            {
                PlyManager.Output(mesh, type + "_" + mesh.GetVertexCount() + "_" + mesh.GetFaceCount() + ".ply");
            }
            return(new Int16Triple(mesh.GetVertexCount(), mesh.GetFaceCount(), 0));
        }
Ejemplo n.º 6
0
        internal static BitMap3d GetLayers(BitMap3d bmp, int p1, int p2)
        {
            BitMap3d bmp2 = new BitMap3d(bmp.width, bmp.height, p2 - p1 + 1, 0);

            for (int i = 0; i < bmp.width; i++)
            {
                for (int j = 0; j < bmp.height; j++)
                {
                    for (int k = p1; k <= p2; k++)
                    {
                        bmp2.SetPixel(i, j, k - p1, bmp.GetPixel(i, j, k));
                    }
                }
            }
            return(bmp2);
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            //BitMap3d bmp = ImageReader.ReadSegImage(@"D:\Uproj\WI_3093_P_iso.seg");
            //BitMap3d nbmp = ImageReader.GetLayers(bmp, 70, 99);
            //nbmp.SaveRaw(@"D:\Uproj\WI_3093_P_iso70.99.raw");
            BitMap3d bmp = new BitMap3d(512, 512, 30, 0);

            bmp.ReadRaw(@"D:\Uproj\WI_3093_P_iso70.99.raw");
            //ImageReader.ProcessImage(bmp);
            ConcreteMCP mc = new ConcreteMCP(bmp);

            mc.SetThreshold(180.5f);
            Mesh m = mc.GenerateSurface();

            PlyManager.Output(m, @"D:\Uproj\WI_3093_P_iso70.99.180.5r.ply");
        }
Ejemplo n.º 8
0
 public void ExcuteSpanFill_Stack(BitMap3d data, Int16Triple seed)
 {
     watch.Start();
     container = new Container_Stack <Span>();
     base.ExcuteSpanFill(data, seed);
     watch.Stop();
     report.time = watch.ElapsedMilliseconds;
     report.result_point_count   = count;
     report.bmp_get_count        = data.action_get_count;
     report.bmp_set_count        = data.action_set_count;
     report.container_pop_count  = container.action_pop_count;
     report.container_push_count = container.action_push_count;
     report.container_max_size   = container.max_contain_count;
     report.flag_get_count       = flagsMap.action_get_count;
     report.flag_set_count       = flagsMap.action_set_count;
     return;
 }
Ejemplo n.º 9
0
 static void ClearBoundary(BitMap3d image)
 {
     byte[] data = image.data;
     for (int k = 0; k < image.depth; k++)
     {
         for (int j = 0; j < image.height; j++)
         {
             for (int i = 0; i < image.width; i++)
             {
                 int index = k * image.width * image.height + j * image.width + i;
                 if (i == 0 || i == image.width - 1 || j == 0 || j == image.height - 1 || k == 0 || k == image.depth - 1)
                 {
                     data[index] = BitMap3d.BLACK;
                 }
             }
         }
     }
 }
Ejemplo n.º 10
0
        private byte GetConfig(Int16Triple[] temp, BitMap3d flagsMap, int indexInWidth, int indexInHeight, int indexInDepth)
        {
            byte value = 0;

            for (int pi = 0; pi < 8; pi++)
            {
                temp[pi].X = indexInWidth + PointIndexToPointDelta[pi].X;
                temp[pi].Y = indexInHeight + PointIndexToPointDelta[pi].Y;
                temp[pi].Z = indexInDepth + PointIndexToPointDelta[pi].Z;
                if (temp[pi].X < w && temp[pi].X >= 0 &&
                    temp[pi].Y < h && temp[pi].Y >= 0 &&
                    temp[pi].Z < d && temp[pi].Z >= 0 &&
                    IsInsideIsoSurface(temp[pi].X, temp[pi].Y, temp[pi].Z))
                {
                    value |= PointIndexToFlag[pi];
                }
            }
            return(value);
        }
Ejemplo n.º 11
0
        private byte GetConfig(Int16Triple[] temp, BitMap3d flagsMap, int indexInWidth, int indexInHeight, int indexInDepth)
        {
            byte value = 0;

            for (int pi = 0; pi < 8; pi++)
            {
                temp[pi].X = indexInWidth + Cube.PointIndexToPointDelta[pi].X;
                temp[pi].Y = indexInHeight + Cube.PointIndexToPointDelta[pi].Y;
                temp[pi].Z = indexInDepth + Cube.PointIndexToPointDelta[pi].Z;
                if (temp[pi].X < w && temp[pi].X >= 0 &&
                    temp[pi].Y < h && temp[pi].Y >= 0 &&
                    temp[pi].Z < d && temp[pi].Z >= 0 &&
                    bmp.data[temp[pi].X + w * (temp[pi].Y) + wh * (temp[pi].Z)] == BitMap3d.WHITE)
                {
                    value |= Cube.PointIndexToFlag[pi];
                }
            }
            return(value);
        }
Ejemplo n.º 12
0
        public static BitMap3d CreateSampleTedX4()
        {
            BitMap3d image = new BitMap3d(400, 400, 400, BitMap3d.BLACK);

            image.ReadRaw(@"D:\VTKproj\TreeRaw\Ted_400.raw");
            byte[] data = image.data;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] > 128)
                {
                    data[i] = BitMap3d.WHITE;
                }
                else
                {
                    data[i] = BitMap3d.BLACK;
                }
            }
            return(image);
        }
Ejemplo n.º 13
0
        public static BitMap3d CreateSampleForFanX4()
        {
            BitMap3d image = new BitMap3d(400, 400, 400, BitMap3d.BLACK);

            image.ReadRaw("D://VTKproj//TreeRaw//marschnerlobb_400_400_400.raw");
            byte[] data = image.data;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] >= 89 && data[i] <= 255)
                {
                    data[i] = BitMap3d.BLACK;
                }
                else
                {
                    data[i] = BitMap3d.WHITE;
                }
            }
            ClearBoundary(image);
            return(image);
        }
Ejemplo n.º 14
0
        public static BitMap3d CreateSampleForMRIX2()
        {
            BitMap3d image = new BitMap3d(512, 512, 248, BitMap3d.BLACK);

            image.ReadRaw(@"D:\VTKproj\TreeRaw\mri_ventricles_512_512_248.raw");
            byte[] data = image.data;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] >= 84 && data[i] <= 255)
                {
                    data[i] = BitMap3d.WHITE;
                }
                else
                {
                    data[i] = BitMap3d.BLACK;
                }
            }
            ClearBoundary(image);
            return(image);
        }
Ejemplo n.º 15
0
        public static BitMap3d CreateSampleForProneX1()
        {
            BitMap3d image = new BitMap3d(512, 512, 463, BitMap3d.BLACK);

            image.ReadRaw(@"D:\VTKproj\TreeRaw\prone8_512_512_463.raw");
            byte[] data = image.data;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] >= 88 && data[i] <= 255)
                {
                    data[i] = BitMap3d.WHITE;
                }
                else
                {
                    data[i] = BitMap3d.BLACK;
                }
            }
            ClearBoundary(image);
            return(image);
        }
Ejemplo n.º 16
0
        public static BitMap3d CreateSampleForTeapotX2()
        {
            BitMap3d image = new BitMap3d(512, 512, 356, BitMap3d.BLACK);

            image.ReadRaw(@"D:\VTKproj\TreeRaw\BostonTeapot_512_512_356.raw");
            byte[] data = image.data;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] >= 24 && data[i] <= 255)
                {
                    data[i] = BitMap3d.WHITE;
                }
                else
                {
                    data[i] = BitMap3d.BLACK;
                }
            }
            ClearBoundary(image);
            return(image);
        }
Ejemplo n.º 17
0
        public static BitMap3d CreateSampleForSkullX1()
        {
            BitMap3d image = new BitMap3d(256, 256, 256, BitMap3d.BLACK);

            image.ReadRaw(@"D:\VTKproj\TreeRaw\skull_256_256_256.raw");
            byte[] data = image.data;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] >= 43 && data[i] <= 255)
                {
                    data[i] = BitMap3d.WHITE;
                }
                else
                {
                    data[i] = BitMap3d.BLACK;
                }
            }
            ClearBoundary(image);
            return(image);
        }
Ejemplo n.º 18
0
        public static BitMap3d CreateSampleForLobsterX2()
        {
            BitMap3d image = new BitMap3d(602, 648, 112, BitMap3d.BLACK);

            image.ReadRaw(@"D:\VTKproj\TreeRaw\lobster_602_648_112.raw");
            byte[] data = image.data;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] >= 37 && data[i] <= 255)
                {
                    data[i] = BitMap3d.WHITE;
                }
                else
                {
                    data[i] = BitMap3d.BLACK;
                }
            }
            ClearBoundary(image);
            return(image);
        }
Ejemplo n.º 19
0
        public static BitMap3d CreateSampleForTableX4()
        {
            BitMap3d image = new BitMap3d(788, 280, 406, BitMap3d.BLACK);

            image.ReadRaw(@"D:\VTKproj\TreeRaw\table_788_280_406.raw");
            byte[] data = image.data;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] >= 37 && data[i] <= 255)
                {
                    data[i] = BitMap3d.WHITE;
                }
                else
                {
                    data[i] = BitMap3d.BLACK;
                }
            }
            ClearBoundary(image);
            return(image);
        }
Ejemplo n.º 20
0
        public static BitMap3d CreateSampleEngineX4()
        {
            BitMap3d image;

            image = new BitMap3d(1024, 1024, 512, BitMap3d.BLACK);
            image.ReadRaw("D://VTKproj//TreeRaw//engine_1024_1024_512.raw");
            byte[] data = image.data;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] >= 64 && data[i] <= 255)
                {
                    data[i] = BitMap3d.WHITE;
                }
                else
                {
                    data[i] = BitMap3d.BLACK;
                }
            }
            ClearBoundary(image);
            return(image);
        }
Ejemplo n.º 21
0
        public static BitMap3d ReadSegImage(string path)
        {
            byte[] data = System.IO.File.ReadAllBytes(path);
            byte[] size = new byte[4];
            size[0] = data[0]; size[1] = data[1]; size[2] = data[2]; size[3] = data[3];
            int width = BitConverter.ToInt32(size, 0);

            size[0] = data[4]; size[1] = data[5]; size[2] = data[6]; size[3] = data[7];
            int height = BitConverter.ToInt32(size, 0);

            size[0] = data[8]; size[1] = data[9]; size[2] = data[10]; size[3] = data[11];
            int depth = BitConverter.ToInt32(size, 0);

            byte[] newdata = new byte[data.Length - 12];
            for (int i = 0; i < data.Length - 12; i++)
            {
                newdata[i] = data[i + 12];
            }
            BitMap3d bmp = new BitMap3d(newdata, width, height, depth);

            return(bmp);
        }
Ejemplo n.º 22
0
 static void OutputData(BitMap3d bmp, string type)
 {
     RunMC(bmp, type + "_mc");
     RunSMC(bmp, type + "_smc");
     RunOSMC(bmp, type + "_osmc");
 }
Ejemplo n.º 23
0
        public virtual void ExecuteSeededGrow(SpanFillInput input, SpanFillResult ret)
        {
            this.data = new BitMap3d(input.data, input.width, input.height, input.depth);
            if (input.flagsMap == null)
            {
                this.flagsMap = new FlagMap3d(input.width, input.height, input.depth);
            }
            else
            {
                this.flagsMap = input.flagsMap;
            }
            this.result = ret;
            this.mask   = input.mask;

            if (input.GetIsFirst())
            {
                ProcessFirstSeed(input);
            }
            else
            {
                ProcessYZSeedRanges(input);
                ProcessXSeeds(input);
            }

            while (!container.Empty())
            {
                Span span = container.Pop();
                #region AllRez
                if (span.Extended == ExtendTypes.AllRez)
                {
                    if (span.ParentDirection == ParentDirections.Y2)
                    {
                        if (span.Y - 1 >= 0)//[spx-spy,y-1,z]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        else
                        {
                            OnOverstepY0RangeFound(span.XLeft, span.XRight, span.Y - 1, span.Z);
                        }

                        if (span.Z - 1 >= 0)//[spx-spy,y,z-1]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepZ0RangeFound(span.XLeft, span.XRight, span.Y, span.Z - 1);
                        }

                        if (span.Z + 1 < data.depth)//[spx-spy,y,z+1]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepZ2RangeFound(span.XLeft, span.XRight, span.Y, span.Z + 1);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Y0)
                    {
                        if (span.Y + 1 < data.height)//[spx-spy,y+1,z]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        else
                        {
                            OnOverstepY2RangeFound(span.XLeft, span.XRight, span.Y + 1, span.Z);
                        }

                        if (span.Z - 1 >= 0)//[spx-spy,y,z-1]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepZ0RangeFound(span.XLeft, span.XRight, span.Y, span.Z - 1);
                        }

                        if (span.Z + 1 < data.depth)//[spx-spy,y,z+1]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepZ2RangeFound(span.XLeft, span.XRight, span.Y, span.Z + 1);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z2)
                    {
                        if (span.Y - 1 >= 0)//[spx-spy,y-1,z]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        else
                        {
                            OnOverstepY0RangeFound(span.XLeft, span.XRight, span.Y - 1, span.Z);
                        }

                        if (span.Y + 1 < data.height)//[spx-spy,y+1,z]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        else
                        {
                            OnOverstepY2RangeFound(span.XLeft, span.XRight, span.Y + 1, span.Z);
                        }

                        if (span.Z - 1 >= 0)//[spx-spy,y,z-1]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepZ0RangeFound(span.XLeft, span.XRight, span.Y, span.Z - 1);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z0)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        else
                        {
                            OnOverstepY0RangeFound(span.XLeft, span.XRight, span.Y - 1, span.Z);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        else
                        {
                            OnOverstepY2RangeFound(span.XLeft, span.XRight, span.Y + 1, span.Z);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepZ2RangeFound(span.XLeft, span.XRight, span.Y, span.Z + 1);
                        }
                        continue;
                    }
                    throw new Exception();
                }
                #endregion
                #region UnRez
                if (span.Extended == ExtendTypes.UnRez)
                {
                    int xl = FindXLeft(span.XLeft, span.Y, span.Z);
                    int xr = FindXRight(span.XRight, span.Y, span.Z);
                    if (span.ParentDirection == ParentDirections.Y2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        else
                        {
                            OnOverstepY0RangeFound(xl, xr, span.Y - 1, span.Z);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            if (xl != span.XLeft)
                            {
                                CheckRange(xl, span.XLeft, span.Y + 1, span.Z, ParentDirections.Y0);
                            }
                            if (span.XRight != xr)
                            {
                                CheckRange(span.XRight, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                            }
                        }
                        else
                        {
                            if (xl != span.XLeft)
                            {
                                OnOverstepY2RangeFound(xl, span.XLeft, span.Y + 1, span.Z);
                            }
                            if (span.XRight != xr)
                            {
                                OnOverstepY2RangeFound(span.XRight, xr, span.Y + 1, span.Z);
                            }
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepZ0RangeFound(xl, xr, span.Y, span.Z - 1);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepZ2RangeFound(xl, xr, span.Y, span.Z + 1);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Y0)
                    {
                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(xl, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        else
                        {
                            OnOverstepY2RangeFound(xl, xr, span.Y + 1, span.Z);
                        }

                        if (span.Y - 1 >= 0)
                        {
                            if (xl != span.XLeft)
                            {
                                CheckRange(xl, span.XLeft, span.Y - 1, span.Z, ParentDirections.Y2);
                            }
                            if (span.XRight != xr)
                            {
                                CheckRange(span.XRight, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                            }
                        }
                        else
                        {
                            if (xl != span.XLeft)
                            {
                                OnOverstepY0RangeFound(xl, span.XLeft, span.Y - 1, span.Z);
                            }
                            if (span.XRight != xr)
                            {
                                OnOverstepY0RangeFound(span.XRight, xr, span.Y - 1, span.Z);
                            }
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepZ0RangeFound(xl, xr, span.Y, span.Z - 1);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepZ2RangeFound(xl, xr, span.Y, span.Z + 1);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        else
                        {
                            OnOverstepY0RangeFound(xl, xr, span.Y - 1, span.Z);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(xl, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        else
                        {
                            OnOverstepY2RangeFound(xl, xr, span.Y + 1, span.Z);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepZ0RangeFound(xl, xr, span.Y, span.Z - 1);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            if (xl != span.XLeft)
                            {
                                CheckRange(xl, span.XLeft, span.Y, span.Z + 1, ParentDirections.Z0);
                            }
                            if (span.XRight != xr)
                            {
                                CheckRange(span.XRight, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                            }
                        }
                        else
                        {
                            if (xl != span.XLeft)
                            {
                                OnOverstepZ2RangeFound(xl, span.XLeft, span.Y, span.Z + 1);
                            }
                            if (span.XRight != xr)
                            {
                                OnOverstepZ2RangeFound(span.XRight, xr, span.Y, span.Z + 1);
                            }
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z0)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        else
                        {
                            OnOverstepY0RangeFound(xl, xr, span.Y - 1, span.Z);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(xl, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        else
                        {
                            OnOverstepY2RangeFound(xl, xr, span.Y + 1, span.Z);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            if (xl != span.XLeft)
                            {
                                CheckRange(xl, span.XLeft, span.Y, span.Z - 1, ParentDirections.Z2);
                            }
                            if (span.XRight != xr)
                            {
                                CheckRange(span.XRight, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                            }
                        }
                        else
                        {
                            if (xl != span.XLeft)
                            {
                                OnOverstepZ0RangeFound(xl, span.XLeft, span.Y, span.Z - 1);
                            }
                            if (span.XRight != xr)
                            {
                                OnOverstepZ0RangeFound(span.XRight, xr, span.Y, span.Z - 1);
                            }
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepZ2RangeFound(xl, xr, span.Y, span.Z + 1);
                        }

                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Non)
                    {
                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(xl, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        else
                        {
                            OnOverstepY2RangeFound(xl, xr, span.Y + 1, span.Z);
                        }

                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        else
                        {
                            OnOverstepY0RangeFound(xl, xr, span.Y - 1, span.Z);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepZ0RangeFound(xl, xr, span.Y, span.Z - 1);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepZ2RangeFound(xl, xr, span.Y, span.Z + 1);
                        }
                        continue;
                    }
                    throw new Exception();
                }
                #endregion
                #region LeftRequired
                if (span.Extended == ExtendTypes.LeftRequired)
                {
                    int xl = FindXLeft(span.XLeft, span.Y, span.Z);
                    if (span.ParentDirection == ParentDirections.Y2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        else
                        {
                            OnOverstepY0RangeFound(xl, span.XRight, span.Y - 1, span.Z);
                        }

                        if (span.Y + 1 < data.height && xl != span.XLeft)
                        {
                            CheckRange(xl, span.XLeft, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        else if (xl != span.XLeft)
                        {
                            OnOverstepY2RangeFound(xl, span.XLeft, span.Y + 1, span.Z);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepZ0RangeFound(xl, span.XRight, span.Y, span.Z - 1);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepZ2RangeFound(xl, span.XRight, span.Y, span.Z + 1);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Y0)
                    {
                        if (span.Y - 1 >= 0 && xl != span.XLeft)
                        {
                            CheckRange(xl, span.XLeft, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        else if (xl != span.XLeft)
                        {
                            OnOverstepY0RangeFound(xl, span.XLeft, span.Y - 1, span.Z);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(xl, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        else
                        {
                            OnOverstepY2RangeFound(xl, span.XRight, span.Y + 1, span.Z);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepZ0RangeFound(xl, span.XRight, span.Y, span.Z - 1);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepZ2RangeFound(xl, span.XRight, span.Y, span.Z + 1);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        else
                        {
                            OnOverstepY0RangeFound(xl, span.XRight, span.Y - 1, span.Z);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(xl, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        else
                        {
                            OnOverstepY2RangeFound(xl, span.XRight, span.Y + 1, span.Z);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepZ0RangeFound(xl, span.XRight, span.Y, span.Z - 1);
                        }

                        if (span.Z + 1 < data.depth && xl != span.XLeft)
                        {
                            CheckRange(xl, span.XLeft, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else if (xl != span.XLeft)
                        {
                            OnOverstepZ2RangeFound(xl, span.XLeft, span.Y, span.Z + 1);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z0)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        else
                        {
                            OnOverstepY0RangeFound(xl, span.XRight, span.Y - 1, span.Z);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(xl, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        else
                        {
                            OnOverstepY2RangeFound(xl, span.XRight, span.Y + 1, span.Z);
                        }

                        if (span.Z - 1 >= 0 && xl != span.XLeft)
                        {
                            CheckRange(xl, span.XLeft, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else if (xl != span.XLeft)
                        {
                            OnOverstepZ0RangeFound(xl, span.XLeft, span.Y, span.Z - 1);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepZ2RangeFound(xl, span.XRight, span.Y, span.Z + 1);
                        }
                        continue;
                    }
                    throw new Exception();
                }
                #endregion
                #region RightRequired
                if (span.Extended == ExtendTypes.RightRequired)
                {
                    int xr = FindXRight(span.XRight, span.Y, span.Z);

                    if (span.ParentDirection == ParentDirections.Y2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        else
                        {
                            OnOverstepY0RangeFound(span.XLeft, xr, span.Y - 1, span.Z);
                        }

                        if (span.Y + 1 < data.height && span.XRight != xr)
                        {
                            CheckRange(span.XRight, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        else if (span.XRight != xr)
                        {
                            OnOverstepY2RangeFound(span.XRight, xr, span.Y + 1, span.Z);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepZ0RangeFound(span.XLeft, xr, span.Y, span.Z - 1);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepZ2RangeFound(span.XLeft, xr, span.Y, span.Z + 1);
                        }
                        continue;
                    }

                    if (span.ParentDirection == ParentDirections.Y0)
                    {
                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(span.XLeft, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        else
                        {
                            OnOverstepY2RangeFound(span.XLeft, xr, span.Y + 1, span.Z);
                        }

                        if (span.Y - 1 >= 0 && span.XRight != xr)
                        {
                            CheckRange(span.XRight, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        else if (span.XRight != xr)
                        {
                            OnOverstepY0RangeFound(span.XRight, xr, span.Y - 1, span.Z);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepZ0RangeFound(span.XLeft, xr, span.Y, span.Z - 1);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepZ2RangeFound(span.XLeft, xr, span.Y, span.Z + 1);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        else
                        {
                            OnOverstepY0RangeFound(span.XLeft, xr, span.Y - 1, span.Z);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(span.XLeft, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        else
                        {
                            OnOverstepY2RangeFound(span.XLeft, xr, span.Y + 1, span.Z);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepZ0RangeFound(span.XLeft, xr, span.Y, span.Z - 1);
                        }

                        if (span.Z + 1 < data.depth && span.XRight != xr)
                        {
                            CheckRange(span.XRight, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else if (span.XRight != xr)
                        {
                            OnOverstepZ2RangeFound(span.XRight, xr, span.Y, span.Z + 1);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z0)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        else
                        {
                            OnOverstepY0RangeFound(span.XLeft, xr, span.Y - 1, span.Z);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(span.XLeft, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        else
                        {
                            OnOverstepY2RangeFound(span.XLeft, xr, span.Y + 1, span.Z);
                        }

                        if (span.Z - 1 >= 0 && span.XRight != xr)
                        {
                            CheckRange(span.XRight, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else if (span.XRight != xr)
                        {
                            OnOverstepZ0RangeFound(span.XRight, xr, span.Y, span.Z - 1);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepZ2RangeFound(span.XLeft, xr, span.Y, span.Z + 1);
                        }
                        continue;
                    }
                    throw new Exception();
                }
                #endregion
            }
        }
Ejemplo n.º 24
0
 public ConcreteMCP(BitMap3d bmp)
     : base(bmp)
 {
 }
Ejemplo n.º 25
0
        protected Container <Span> container;//以Span为单位的Queue或Stack容器
        protected virtual void ExcuteSpanFill(BitMap3d data, Int16Triple seed)
        {
            this.bmp = data;
            data.ResetVisitCount();
            flagsMap = new FlagMap3d(data.width, data.height, data.depth);
            Process(seed);
            flagsMap.SetFlagOn(seed.X, seed.Y, seed.Z, true);
            Span seedspan = new Span();

            seedspan.XLeft           = seed.X;
            seedspan.XRight          = seed.X;
            seedspan.Y               = seed.Y;
            seedspan.Z               = seed.Z;
            seedspan.ParentDirection = ParentDirections.Non;
            seedspan.Extended        = ExtendTypes.UnRez;
            container.Push(seedspan);

            while (!container.Empty())
            {
                Span span = container.Pop();
                #region AllRez
                if (span.Extended == ExtendTypes.AllRez)
                {
                    if (span.ParentDirection == ParentDirections.Y2)
                    {
                        if (span.Y - 1 >= 0)//[spx-spy,y-1,z]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Z - 1 >= 0)//[spx-spy,y,z-1]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        if (span.Z + 1 < data.depth)//[spx-spy,y,z+1]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Y0)
                    {
                        if (span.Y + 1 < bmp.height)//[spx-spy,y+1,z]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        if (span.Z - 1 >= 0)//[spx-spy,y,z-1]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        if (span.Z + 1 < data.depth)//[spx-spy,y,z+1]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z2)
                    {
                        if (span.Y - 1 >= 0)//[spx-spy,y-1,z]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Y + 1 < bmp.height)//[spx-spy,y+1,z]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        if (span.Z - 1 >= 0)//[spx-spy,y,z-1]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z0)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Y + 1 < bmp.height)
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        continue;
                    }
                    throw new Exception();
                }
                #endregion
                #region UnRez
                if (span.Extended == ExtendTypes.UnRez)
                {
                    int xl = FindXLeft(span.XLeft, span.Y, span.Z);
                    int xr = FindXRight(span.XRight, span.Y, span.Z);
                    if (span.ParentDirection == ParentDirections.Y2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Y + 1 < bmp.height)
                        {
                            if (xl != span.XLeft)
                            {
                                CheckRange(xl, span.XLeft, span.Y + 1, span.Z, ParentDirections.Y0);
                            }
                            if (span.XRight != xr)
                            {
                                CheckRange(span.XRight, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                            }
                        }
                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        if (span.Z + 1 < bmp.depth)
                        {
                            CheckRange(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Y0)
                    {
                        if (span.Y + 1 < bmp.height)
                        {
                            CheckRange(xl, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        if (span.Y - 1 >= 0)
                        {
                            if (xl != span.XLeft)
                            {
                                CheckRange(xl, span.XLeft, span.Y - 1, span.Z, ParentDirections.Y2);
                            }
                            if (span.XRight != xr)
                            {
                                CheckRange(span.XRight, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                            }
                        }
                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        if (span.Z + 1 < bmp.depth)
                        {
                            CheckRange(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Y + 1 < bmp.height)
                        {
                            CheckRange(xl, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        if (span.Z + 1 < bmp.depth)
                        {
                            if (xl != span.XLeft)
                            {
                                CheckRange(xl, span.XLeft, span.Y, span.Z + 1, ParentDirections.Z0);
                            }
                            if (span.XRight != xr)
                            {
                                CheckRange(span.XRight, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                            }
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z0)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Y + 1 < bmp.height)
                        {
                            CheckRange(xl, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        if (span.Z - 1 >= 0)
                        {
                            if (xl != span.XLeft)
                            {
                                CheckRange(xl, span.XLeft, span.Y, span.Z - 1, ParentDirections.Z2);
                            }
                            if (span.XRight != xr)
                            {
                                CheckRange(span.XRight, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                            }
                        }
                        if (span.Z + 1 < bmp.depth)
                        {
                            CheckRange(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Non)
                    {
                        if (span.Y + 1 < bmp.height)
                        {
                            CheckRange(xl, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        if (span.Z + 1 < bmp.depth)
                        {
                            CheckRange(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        continue;
                    }
                    throw new Exception();
                }
                #endregion
                #region LeftRequired
                if (span.Extended == ExtendTypes.LeftRequired)
                {
                    int xl = FindXLeft(span.XLeft, span.Y, span.Z);
                    if (span.ParentDirection == ParentDirections.Y2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Y + 1 < bmp.height && xl != span.XLeft)
                        {
                            CheckRange(xl, span.XLeft, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        if (span.Z + 1 < bmp.depth)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Y0)
                    {
                        if (span.Y - 1 >= 0 && xl != span.XLeft)
                        {
                            CheckRange(xl, span.XLeft, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Y + 1 < bmp.height)
                        {
                            CheckRange(xl, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        if (span.Z + 1 < bmp.depth)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Y + 1 < bmp.height)
                        {
                            CheckRange(xl, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        if (span.Z + 1 < bmp.depth && xl != span.XLeft)
                        {
                            CheckRange(xl, span.XLeft, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z0)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Y + 1 < bmp.height)
                        {
                            CheckRange(xl, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        if (span.Z - 1 >= 0 && xl != span.XLeft)
                        {
                            CheckRange(xl, span.XLeft, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        if (span.Z + 1 < bmp.depth)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        continue;
                    }
                    throw new Exception();
                }
                #endregion
                #region RightRequired
                if (span.Extended == ExtendTypes.RightRequired)
                {
                    int xr = FindXRight(span.XRight, span.Y, span.Z);

                    if (span.ParentDirection == ParentDirections.Y2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Y + 1 < bmp.height && span.XRight != xr)
                        {
                            CheckRange(span.XRight, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        if (span.Z + 1 < bmp.depth)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        continue;
                    }

                    if (span.ParentDirection == ParentDirections.Y0)
                    {
                        if (span.Y + 1 < bmp.height)
                        {
                            CheckRange(span.XLeft, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        if (span.Y - 1 >= 0 && span.XRight != xr)
                        {
                            CheckRange(span.XRight, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        if (span.Z + 1 < bmp.depth)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Y + 1 < bmp.height)
                        {
                            CheckRange(span.XLeft, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        if (span.Z + 1 < bmp.depth && span.XRight != xr)
                        {
                            CheckRange(span.XRight, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z0)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Y + 1 < bmp.height)
                        {
                            CheckRange(span.XLeft, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }
                        if (span.Z - 1 >= 0 && span.XRight != xr)
                        {
                            CheckRange(span.XRight, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        if (span.Z + 1 < bmp.depth)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        continue;
                    }
                    throw new Exception();
                }
                #endregion
            }
        }
Ejemplo n.º 26
0
 public MCProcessor(BitMap3d bitmap)
 {
     this.bmp = bitmap;
 }
Ejemplo n.º 27
0
 public MarchingCube(BitMap3d bitmap)
 {
     this.bmp = bitmap;
 }
    private void OnSceneGUI()
    {
        UnityEngine.Mesh mesh = null;
        int          cellNum  = 10;
        MarchingCube mc       = target as MarchingCube;
        Dictionary <int, List <Vector3> > ss = new Dictionary <int, List <Vector3> >();

        if (mc.gameObject != null)
        {
            mesh = mc.gameObject.GetComponent <MeshFilter>().sharedMesh;

            Vector3[] verts = mesh.vertices;

            for (int i = 0; i < verts.Length; i++)
            {
                Vector3 worldPos = mc.gameObject.transform.TransformPoint(verts[i]);
                Vector3 pos      = worldPos;
                //check bound
                if (pos.x < 0 || pos.y < 0 || pos.z < 0)
                {
                    continue;
                }

                int hash = mc.MakeHash(pos);
                if (ss.ContainsKey(hash))
                {
                    ss[hash].Add(pos);
                }
                else
                {
                    List <Vector3> ptlist = new List <Vector3>();
                    ptlist.Add(pos);
                    ss.Add(hash, ptlist);
                }
            }
        }

        gizmoLines = new Vector3[cellNum * cellNum * cellNum];
        int cnt = 0;

        BitMap3d bm3d = new BitMap3d(cellNum, cellNum, cellNum);

        for (int i = 0; i < cellNum; i++)
        {
            for (int j = 0; j < cellNum; j++)
            {
                for (int k = 0; k < cellNum; k++)
                {
                    Vector3 start = new Vector3(k, j, i);
                    int     hash  = mc.MakeHash(start);

                    float dens = 0;
                    if (ss.ContainsKey(hash))
                    {                                       //verts inside cellgrid, calculate density
                        List <Vector3> objverts = ss[hash]; //obj verts in cell
                        //for (int ii = 0; ii < 8; ii++)
                        {
                            float dd = 0;
                            foreach (var vert in objverts)
                            {
                                dd += Vector3.Magnitude(vert - start);
                            }
                            dd = dd / objverts.Count;
                            if (dd > 0 && dd < densityThreshold)
                            {
                                Handles.color = new Color(dd, 0.5f, 0.0f);
                                //Handles.DrawLine(vert, cubePts[ii]);
                                Handles.SphereHandleCap(0, start, Quaternion.identity, 0.2f, EventType.Repaint);
                                Handles.Label(start, start.ToString());
                            }
                        }
                    }
                    else
                    {
                        dens = 0;
                    }

                    gizmoLines[cnt] = start;
                    Handles.color   = new Color(0.3f, 0.5f, 0.5f);
                    Vector3 gizmoCubeCenter = start + Vector3.one * 0.5f;
                    if (gizmoCube)
                    {
                        Handles.DrawWireCube(gizmoCubeCenter, Vector3.one);
                    }

                    cnt++;
                }
            }
        }
    }
Ejemplo n.º 29
0
        public virtual SpanFillResult ExecuteSeededGrow(SpanFillInput input)
        {
            this.data = new BitMap3d(input.data, input.width, input.height, input.depth);
            flagsMap  = input.flag;
            //result.Clear()
            resultCount = 0;
            container.Clear();
            SpanFillResult ret = new SpanFillResult();

            ret.Init();
            if (input.IsFirst)
            {
                Int16Triple seed = input.seed;
                Process(seed);
                flagsMap.SetFlagOn(seed.X, seed.Y, seed.Z, true);
                Span seedspan = new Span();
                seedspan.XLeft           = seed.X;
                seedspan.XRight          = seed.X;
                seedspan.Y               = seed.Y;
                seedspan.Z               = seed.Z;
                seedspan.ParentDirection = ParentDirections.Non;
                seedspan.Extended        = ExtendTypes.UnRez;
                container.Push(seedspan);
            }
            else
            {
                ParentDirections p = (input.spanlist[0].Z == 0) ? ParentDirections.Z0 : ParentDirections.Z2;
                for (int i = 0; i < input.spanlist.Count; i++)
                {
                    Range r = input.spanlist[i];
                    CheckRange(r.XLeft, r.XRight, r.Y, r.Z, p);
                }
            }

            while (!container.Empty())
            {
                Span span = container.Pop();
                #region AllRez
                if (span.Extended == ExtendTypes.AllRez)
                {
                    if (span.ParentDirection == ParentDirections.Y2)
                    {
                        if (span.Y - 1 >= 0)//[spx-spy,y-1,z]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }

                        if (span.Z - 1 >= 0)//[spx-spy,y,z-1]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepSpanFound(span.XLeft, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                        }

                        if (span.Z + 1 < data.depth)//[spx-spy,y,z+1]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepSpanFound(span.XLeft, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Y0)
                    {
                        if (span.Y + 1 < data.height)//[spx-spy,y+1,z]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }

                        if (span.Z - 1 >= 0)//[spx-spy,y,z-1]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepSpanFound(span.XLeft, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                        }

                        if (span.Z + 1 < data.depth)//[spx-spy,y,z+1]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepSpanFound(span.XLeft, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z2)
                    {
                        if (span.Y - 1 >= 0)//[spx-spy,y-1,z]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }

                        if (span.Y + 1 < data.height)//[spx-spy,y+1,z]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }

                        if (span.Z - 1 >= 0)//[spx-spy,y,z-1]
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepSpanFound(span.XLeft, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z0)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(span.XLeft, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepSpanFound(span.XLeft, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                        }
                        continue;
                    }
                    throw new Exception();
                }
                #endregion
                #region UnRez
                if (span.Extended == ExtendTypes.UnRez)
                {
                    int xl = FindXLeft(span.XLeft, span.Y, span.Z);
                    int xr = FindXRight(span.XRight, span.Y, span.Z);
                    if (span.ParentDirection == ParentDirections.Y2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }
                        if (span.Y + 1 < data.height)
                        {
                            if (xl != span.XLeft)
                            {
                                CheckRange(xl, span.XLeft, span.Y + 1, span.Z, ParentDirections.Y0);
                            }
                            if (span.XRight != xr)
                            {
                                CheckRange(span.XRight, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                            }
                        }
                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepSpanFound(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepSpanFound(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Y0)
                    {
                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(xl, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }

                        if (span.Y - 1 >= 0)
                        {
                            if (xl != span.XLeft)
                            {
                                CheckRange(xl, span.XLeft, span.Y - 1, span.Z, ParentDirections.Y2);
                            }
                            if (span.XRight != xr)
                            {
                                CheckRange(span.XRight, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                            }
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepSpanFound(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepSpanFound(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(xl, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepSpanFound(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            if (xl != span.XLeft)
                            {
                                CheckRange(xl, span.XLeft, span.Y, span.Z + 1, ParentDirections.Z0);
                            }
                            if (span.XRight != xr)
                            {
                                CheckRange(span.XRight, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                            }
                        }
                        else
                        {
                            if (xl != span.XLeft)
                            {
                                OnOverstepSpanFound(xl, span.XLeft, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                            }
                            if (span.XRight != xr)
                            {
                                OnOverstepSpanFound(span.XRight, xr, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                            }
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z0)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(xl, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            if (xl != span.XLeft)
                            {
                                CheckRange(xl, span.XLeft, span.Y, span.Z - 1, ParentDirections.Z2);
                            }
                            if (span.XRight != xr)
                            {
                                CheckRange(span.XRight, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                            }
                        }
                        else
                        {
                            if (xl != span.XLeft)
                            {
                                OnOverstepSpanFound(xl, span.XLeft, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                            }
                            if (span.XRight != xr)
                            {
                                OnOverstepSpanFound(span.XRight, xr, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                            }
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepSpanFound(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                        }

                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Non)
                    {
                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(xl, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }

                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepSpanFound(xl, xr, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepSpanFound(xl, xr, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                        }
                        continue;
                    }
                    throw new Exception();
                }
                #endregion
                #region LeftRequired
                if (span.Extended == ExtendTypes.LeftRequired)
                {
                    int xl = FindXLeft(span.XLeft, span.Y, span.Z);
                    if (span.ParentDirection == ParentDirections.Y2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }

                        if (span.Y + 1 < data.height && xl != span.XLeft)
                        {
                            CheckRange(xl, span.XLeft, span.Y + 1, span.Z, ParentDirections.Y0);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepSpanFound(xl, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepSpanFound(xl, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Y0)
                    {
                        if (span.Y - 1 >= 0 && xl != span.XLeft)
                        {
                            CheckRange(xl, span.XLeft, span.Y - 1, span.Z, ParentDirections.Y2);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(xl, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepSpanFound(xl, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepSpanFound(xl, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(xl, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepSpanFound(xl, span.XRight, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                        }

                        if (span.Z + 1 < data.depth && xl != span.XLeft)
                        {
                            CheckRange(xl, span.XLeft, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else if (xl != span.XLeft)
                        {
                            OnOverstepSpanFound(xl, span.XLeft, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z0)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(xl, span.XRight, span.Y - 1, span.Z, ParentDirections.Y2);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(xl, span.XRight, span.Y + 1, span.Z, ParentDirections.Y0);
                        }

                        if (span.Z - 1 >= 0 && xl != span.XLeft)
                        {
                            CheckRange(xl, span.XLeft, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else if (xl != span.XLeft)
                        {
                            OnOverstepSpanFound(xl, span.XLeft, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(xl, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepSpanFound(xl, span.XRight, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                        }
                        continue;
                    }
                    throw new Exception();
                }
                #endregion
                #region RightRequired
                if (span.Extended == ExtendTypes.RightRequired)
                {
                    int xr = FindXRight(span.XRight, span.Y, span.Z);

                    if (span.ParentDirection == ParentDirections.Y2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }

                        if (span.Y + 1 < data.height && span.XRight != xr)
                        {
                            CheckRange(span.XRight, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepSpanFound(span.XLeft, xr, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepSpanFound(span.XLeft, xr, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                        }
                        continue;
                    }

                    if (span.ParentDirection == ParentDirections.Y0)
                    {
                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(span.XLeft, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }

                        if (span.Y - 1 >= 0 && span.XRight != xr)
                        {
                            CheckRange(span.XRight, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepSpanFound(span.XLeft, xr, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepSpanFound(span.XLeft, xr, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z2)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(span.XLeft, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }

                        if (span.Z - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else
                        {
                            OnOverstepSpanFound(span.XLeft, xr, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                        }

                        if (span.Z + 1 < data.depth && span.XRight != xr)
                        {
                            CheckRange(span.XRight, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else if (span.XRight != xr)
                        {
                            OnOverstepSpanFound(span.XRight, xr, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                        }
                        continue;
                    }
                    if (span.ParentDirection == ParentDirections.Z0)
                    {
                        if (span.Y - 1 >= 0)
                        {
                            CheckRange(span.XLeft, xr, span.Y - 1, span.Z, ParentDirections.Y2);
                        }

                        if (span.Y + 1 < data.height)
                        {
                            CheckRange(span.XLeft, xr, span.Y + 1, span.Z, ParentDirections.Y0);
                        }

                        if (span.Z - 1 >= 0 && span.XRight != xr)
                        {
                            CheckRange(span.XRight, xr, span.Y, span.Z - 1, ParentDirections.Z2);
                        }
                        else if (span.XRight != xr)
                        {
                            OnOverstepSpanFound(span.XRight, xr, span.Y, span.Z - 1, ParentDirections.Z2, ref ret);
                        }

                        if (span.Z + 1 < data.depth)
                        {
                            CheckRange(span.XLeft, xr, span.Y, span.Z + 1, ParentDirections.Z0);
                        }
                        else
                        {
                            OnOverstepSpanFound(span.XLeft, xr, span.Y, span.Z + 1, ParentDirections.Z0, ref ret);
                        }
                        continue;
                    }
                    throw new Exception();
                }
                #endregion
            }
            //ret.resultPointSet = this.result;
            ret.resultCount = this.resultCount;
            return(ret);
        }