/// <summary> /// Recursively searches for the highest point connected to the startindex. The search stops when the maximum searchdepth is reached. /// </summary> /// <param name="currentIndex"></param> /// <param name="searchDepth"></param> /// <returns></returns> public static int GetHighestConnectingPoint(int currentIndex, int searchDepth) { float currentDepth = GlobVar.SubtractedFilteredPointCloud[currentIndex].Z; int[] neighbours = GlobUtils.GetNeighbour5X5IndexList(currentIndex); int highestNeighbourIndex = currentIndex; float shallowestNeighbourDepth = currentDepth; for (int i = 0; i < neighbours.Length; i++) { int neighbourIndex = neighbours[i]; if (!GlobUtils.BoundaryCheck(neighbourIndex)) { continue; } CameraSpacePoint neighbour = GlobVar.SubtractedFilteredPointCloud[neighbourIndex]; if (neighbour.Z < shallowestNeighbourDepth && !float.IsInfinity(neighbour.X) && !float.IsInfinity(neighbour.Y)) { shallowestNeighbourDepth = neighbour.Z; highestNeighbourIndex = neighbourIndex; } } if (highestNeighbourIndex == currentIndex || searchDepth == 0) { return(currentIndex); } searchDepth--; return(GetHighestConnectingPoint(highestNeighbourIndex, searchDepth)); }
public static void DrawPoint(Point point) { int x = point.X; int y = point.Y; int i; i = GlobUtils.GetIndex(x, y); if (GlobUtils.BoundaryCheck(i)) { GlobVar.GraphicsCanvas[i] = (byte)255; } i = GlobUtils.GetIndex(x + 1, y - 1); if (GlobUtils.BoundaryCheck(i)) { GlobVar.GraphicsCanvas[i] = (byte)255; } i = GlobUtils.GetIndex(x + 1, y); if (GlobUtils.BoundaryCheck(i)) { GlobVar.GraphicsCanvas[i] = (byte)255; } i = GlobUtils.GetIndex(x + 1, y + 1); if (GlobUtils.BoundaryCheck(i)) { GlobVar.GraphicsCanvas[i] = (byte)255; } i = GlobUtils.GetIndex(x - 1, y - 1); if (GlobUtils.BoundaryCheck(i)) { GlobVar.GraphicsCanvas[i] = (byte)255; } i = GlobUtils.GetIndex(x - 1, y); if (GlobUtils.BoundaryCheck(i)) { GlobVar.GraphicsCanvas[i] = (byte)255; } i = GlobUtils.GetIndex(x - 1, y + 1); if (GlobUtils.BoundaryCheck(i)) { GlobVar.GraphicsCanvas[i] = (byte)255; } i = GlobUtils.GetIndex(x, y + 1); if (GlobUtils.BoundaryCheck(i)) { GlobVar.GraphicsCanvas[i] = (byte)255; } i = GlobUtils.GetIndex(x, y - 1); if (GlobUtils.BoundaryCheck(i)) { GlobVar.GraphicsCanvas[i] = (byte)255; } }