private BlockIR_SP GetBlockIR(int x, int y, int z) { if (blockIRMap[x, y, z] == null) { blockIRMap[x, y, z] = new BlockIR_SP(); } return blockIRMap[x, y, z]; }
private void MarshalInputAndOutput(SpanFillInput input, SpanFillResult ret, Block block, BlockIR_SP 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.overstepPointList = null; input.overstepRangeList = null; ret.resultCount=0; ret.resultSet.Clear(); } 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.overstepPointList = bir.boundarySeedXsInside; input.overstepRangeList = bir.boundaryRangesYZInside; ret.resultCount = 0; ret.resultSet.Clear(); } }
public void ExecuteSeededGrow(Int16Triple firstseed) { if (buffer == null || seedGrowExecutor == null || dataProvider == null) throw new Exception(); SpanFillInput input = new SpanFillInput(); SpanFillResult ret = new SpanFillResult(); resultSum = new LargeSeededGrowResult(); queue = new Container_Stack<Block>(); Block firstB = GetFirstBlock(firstseed); BlockIR_SP 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_SP 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 < 2;i++ ) { if (ret.GetNeedsToSeekX(i)) { Block t = image.GetBlock(block.indexX + AdX[i].X, block.indexY, block.indexZ); if (t.VisitedCount < 1) { ConvertThisBlockCoordsToOtherBlockCoords(block, t, ret.boundaryPoints_X[i]); BlockIR_SP tbir = GetBlockIR(t.indexX, t.indexY, t.indexZ); List<Int16Triple> oppInput = tbir.boundarySeedXsInside[OppositePos_X[i]]; if (oppInput != null && oppInput.Count != 0) { oppInput.AddRange(ret.boundaryPoints_X[i]); ret.boundaryPoints_X[i].Clear(); tbir.boundarySeedXsInside[OppositePos_X[i]] = oppInput; } else { oppInput = ret.boundaryPoints_X[i]; ret.boundaryPoints_X[i] = new List<Int16Triple>(); tbir.boundarySeedXsInside[OppositePos_X[i]] = oppInput; } queue.Push(t); } else { ret.boundaryPoints_X[i].Clear(); } } } for (int i = 0; i < 4; i++) { if (ret.GetNeedsToSeekYZ(i)) { Block t = image.GetBlock(block.indexX, block.indexY + AdYZ[i].Y, block.indexZ + AdYZ[i].Z); if (t.VisitedCount < 1000) { ConvertThisBlockRangesToOtherBlockRanges(block, t, ret.boundaryRanges_YZ[i]); BlockIR_SP tbir = GetBlockIR(t.indexX, t.indexY, t.indexZ); List<Range> oppInput = tbir.boundaryRangesYZInside[OppositePos_YZ[i]]; if (oppInput != null && oppInput.Count != 0) { oppInput.AddRange(ret.boundaryRanges_YZ[i]); ret.boundaryRanges_YZ[i].Clear(); tbir.boundaryRangesYZInside[OppositePos_YZ[i]] = oppInput; } else { oppInput = ret.boundaryRanges_YZ[i]; ret.boundaryRanges_YZ[i] = new List<Range>(); tbir.boundaryRangesYZInside[OppositePos_YZ[i]] = oppInput; } queue.Push(t); } else { ret.boundaryRanges_YZ[i].Clear(); } } } input.ClearAll(); } ClearTail(); }