public void ClearAll() { data = null; width = -1; height = -1; depth = -1; data = null; seed = new Int16Triple(-1, -1, -1); mask = null; if (overstepPointList != null) { for (int i = 0; i < 2; i++) { if (overstepPointList[i] != null) { overstepPointList[i].Clear(); } } } if (overstepRangeList != null) { for (int i = 0; i < 4; i++) { if (overstepRangeList[i] != null) { overstepRangeList[i].Clear(); } } } overstepPointList = null; overstepRangeList = null; }
public FloodFillInput() { this.data = null; this.flagsMap = null; this.width = -1; this.height = -1; this.depth = -1; this.overstepList = null; this.seed = new Int16Triple(-1, -1, -1); this.mask = null; }
public SpanFillInput() { this.data = null; this.width = -1; this.height = -1; this.depth = -1; this.overstepPointList = null; this.overstepRangeList = null; this.seed = new Int16Triple(-1, -1, -1); this.mask = null; }
public void ClearAll() { data = null; width = -1; height = -1; depth = -1; data = null; seed = new Int16Triple(-1, -1, -1); mask = null; flagsMap = null; if (overstepList != null) { for (int i = 0; i < 6; i++) { overstepList[i].Clear(); } } overstepList = null; }
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 } }