private BlockIR_FF GetBlockIR(int x, int y, int z) { if (blockIRMap[x, y, z] == null) { blockIRMap[x, y, z] = new BlockIR_FF(); } return(blockIRMap[x, y, z]); }
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(); }
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(); } }