Esempio n. 1
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();
        }
Esempio n. 2
0
 public void MergeResult(LargeSpanFillResult lsg, FloodFillResult ret)
 {
     lsg.resultSet.AddRange(ret.resultSet);
     lsg.Count += ret.resultCount;
 }