Пример #1
0
 private void MarshalInputAndOutput(FloodFillInput input, FloodFillResult ret, Block block, BlockIR_FF bir)
 {
     if (bir.GetIsFirst())
     {
         input.width        = block.actualWidth;
         input.height       = block.actualHeight;
         input.depth        = block.actualDepth;
         input.data         = buffer;
         input.seed         = bir.singleSeed;
         input.mask         = block.boundaryMask;
         input.flagsMap     = block.GetFlagMap3d();
         input.overstepList = null;
         ret.ClearResult();
     }
     else
     {
         input.width        = block.actualWidth;
         input.height       = block.actualHeight;
         input.depth        = block.actualDepth;
         input.data         = buffer;
         input.mask         = block.boundaryMask;
         input.flagsMap     = block.GetFlagMap3d();
         input.seed         = new Int16Triple(-1, -1, -1);
         input.overstepList = bir.boundarySeedsInside;
         ret.ClearResult();
     }
 }
Пример #2
0
        public void ExecuteSeededGrow(Int16Triple firstseed)
        {
            if (buffer == null || seedGrowExecutor == null || dataProvider == null)
            {
                throw new Exception();
            }
            FloodFillInput  input = new FloodFillInput();
            FloodFillResult ret   = new FloodFillResult();

            resultSum = new LargeSpanFillResult();
            queue     = new Container_Stack <Block>();
            Block      firstB   = GetFirstBlock(firstseed);
            BlockIR_FF firstBir = GetBlockIR(firstB.indexX, firstB.indexY, firstB.indexZ);

            firstBir.singleSeed = ConvertGlobalCoodToBlockCoord(firstB, firstseed);
            queue.Push(firstB);
            while (!queue.Empty())
            {
                Block block = queue.Pop();
                block.VisitedCount++;
                BlockIR_FF bir = GetBlockIR(block.indexX, block.indexY, block.indexZ);
                FillBlockData(block);

                MarshalInputAndOutput(input, ret, block, bir);
                seedGrowExecutor.ExecuteSeededGrow(input, ret);

                if (input.GetIsFirst())
                {
                    bir.singleSeed = new Int16Triple(-1, -1, -1);
                }

                ConvertBlockCoordsToGlobalCoords(block, ret.resultSet);
                MergeResult(resultSum, ret);

                for (int i = 0; i < 6; i++)
                {
                    if (ret.GetNeedsSeekAdj(i))
                    {
                        Block t = image.GetBlock(block.indexX + Ad[i].X, block.indexY + Ad[i].Y, block.indexZ + Ad[i].Z);
                        if (t.VisitedCount < 1)
                        {
                            ConvertThisBlockCoordsToOtherBlockCoords(block, t, ret.boundaryRequestPoints[i]);
                            BlockIR_FF         tbir     = GetBlockIR(t.indexX, t.indexY, t.indexZ);
                            List <Int16Triple> oppInput = tbir.boundarySeedsInside[OppositePos[i]];
                            if (oppInput != null && oppInput.Count != 0)
                            {
                                oppInput.AddRange(ret.boundaryRequestPoints[i]);
                                ret.boundaryRequestPoints[i].Clear();
                                tbir.boundarySeedsInside[OppositePos[i]] = oppInput;
                            }
                            else
                            {
                                oppInput = ret.boundaryRequestPoints[i];
                                ret.boundaryRequestPoints[i]             = new List <Int16Triple>();
                                tbir.boundarySeedsInside[OppositePos[i]] = oppInput;
                            }
                            queue.Push(t);
                        }
                        else
                        {
                            ret.boundaryRequestPoints[i].Clear();
                        }
                    }
                }
                input.ClearAll();
            }
            ClearTail();
        }
Пример #3
0
 public void MergeResult(LargeSpanFillResult lsg, FloodFillResult ret)
 {
     lsg.resultSet.AddRange(ret.resultSet);
     lsg.Count += ret.resultCount;
 }
Пример #4
0
        public void ExecuteSeededGrow(FloodFillInput input, FloodFillResult ret)
        {
            queue.Clear();
            result      = ret;
            this.width  = input.width;
            this.height = input.height;
            this.depth  = input.depth;
            this.data   = input.data;
            if (input.flagsMap != null)
            {
                this.flagsMap = input.flagsMap;
            }
            else
            {
                this.flagsMap = new FlagMap3d(input.width, input.height, input.depth);
            }

            Int16Triple[] adjPoints6 = new Int16Triple[6];
            if (!input.GetIsFirst())
            {
                List <Int16Triple>[] oversteps = input.overstepList;
                for (int j = 0; j < 6; j++)
                {
                    for (int i = 0; i < oversteps[j].Count; i++)
                    {
                        Int16Triple p = oversteps[j][i];
                        if (!flagsMap.GetFlagOn(p.X, p.Y, p.Z) && IncludeConditionMeets(p))
                        {
                            flagsMap.SetFlagOn(p.X, p.Y, p.Z, true);
                            Process(p);
                            queue.Push(new Int16TripleWithDirection(p, j));
                        }
                    }
                }
            }
            else
            {
                Int16Triple seed = input.seed;
                flagsMap.SetFlagOn(seed.X, seed.Y, seed.Z, true);
                queue.Push(new Int16TripleWithDirection(seed, 6));
                Process(seed);
            }
            while (!queue.Empty())
            {
                Int16TripleWithDirection p = queue.Pop();
                InitAdj6(adjPoints6, p.Poistion);
                for (int adjIndex = 0; adjIndex < 6; adjIndex++)
                {
                    if (adjIndex == p.PDirection)
                    {
                        continue;
                    }
                    Int16Triple t = adjPoints6[adjIndex];
                    if (t.X < width && t.X >= 0 && t.Y < height && t.Y >= 0 && t.Z < depth && t.Z >= 0)
                    {
                        int indext = t.X + width * t.Y + width * height * t.Z;
                        if (!flagsMap.GetFlagOn(t.X, t.Y, t.Z) && IncludeConditionMeets(t))
                        {
                            flagsMap.SetFlagOn(t.X, t.Y, t.Z, true);
                            queue.Push(new Int16TripleWithDirection(t, OppositePos[adjIndex]));
                            Process(t);
                        }
                    }
                    else
                    {
                        if (input.GetCanSeekAdj(adjIndex))
                        {
                            result.boundaryRequestPoints[adjIndex].Add(t);
                        }
                    }
                }
            }
        }