mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-27 21:08:29 +00:00
Fixed a couple of off by one errors on CubistImageProcessor
This commit is contained in:
parent
ff27687980
commit
79c7828817
@ -113,11 +113,11 @@ namespace OSCADSharp.Solids.Imported
|
|||||||
private void markVisited(ref bool[,] visited, Cube cube, Point start, Bitmap img)
|
private void markVisited(ref bool[,] visited, Cube cube, Point start, Bitmap img)
|
||||||
{
|
{
|
||||||
var bounds = cube.Bounds();
|
var bounds = cube.Bounds();
|
||||||
for (int column = start.X; column < start.X + bounds.Width; column++)
|
for (int x = start.X; x < start.X + bounds.Width && x < img.Width; x++)
|
||||||
{
|
{
|
||||||
for (int row = start.Y; row < start.Y + bounds.Length; row++)
|
for (int y = start.Y; y < start.Y + bounds.Length && y < img.Height; y++)
|
||||||
{
|
{
|
||||||
visited[column, row] = true;
|
visited[x, y] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,15 +136,11 @@ namespace OSCADSharp.Solids.Imported
|
|||||||
pixelCanBeTraversed(img, ref visited, new Point(start.X, start.Y + 1), color);
|
pixelCanBeTraversed(img, ref visited, new Point(start.X, start.Y + 1), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (canTraverse)
|
if (canTraverse)
|
||||||
{
|
{
|
||||||
if (cube == null)
|
if (cube == null)
|
||||||
{
|
{
|
||||||
cube = new Cube();
|
cube = new Cube();
|
||||||
cube.Size.X += 1;
|
|
||||||
cube.Size.Y += 1;
|
|
||||||
|
|
||||||
return traverseNext(img, start, ref visited, color, cube);
|
return traverseNext(img, start, ref visited, color, cube);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -172,17 +168,17 @@ namespace OSCADSharp.Solids.Imported
|
|||||||
private void canContinueTraversal(Bitmap img, ref Point start, ref bool[,] visited, Color color, Cube cube, ref bool canTraverse)
|
private void canContinueTraversal(Bitmap img, ref Point start, ref bool[,] visited, Color color, Cube cube, ref bool canTraverse)
|
||||||
{
|
{
|
||||||
var bounds = cube.Bounds();
|
var bounds = cube.Bounds();
|
||||||
for (int column = start.X; column < start.X + bounds.Width && canTraverse; column++)
|
for (int x = start.X; x < start.X + bounds.Width+1 && canTraverse; x++)
|
||||||
{
|
{
|
||||||
for (int row = start.Y; row < start.Y + bounds.Length && canTraverse; row++)
|
for (int y = start.Y; y < start.Y + bounds.Length+1 && canTraverse; y++)
|
||||||
{
|
{
|
||||||
if (start.X + column >= img.Width || start.Y + row >= img.Height)
|
if (x >= img.Width || y >= img.Height)
|
||||||
{
|
{
|
||||||
canTraverse = false;
|
canTraverse = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
canTraverse = canTraverse && pixelCanBeTraversed(img, ref visited, new Point(column, row), color);
|
canTraverse = canTraverse && pixelCanBeTraversed(img, ref visited, new Point(x, y), color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,9 +194,9 @@ namespace OSCADSharp.Solids.Imported
|
|||||||
private Point? getNextPoint(Bitmap img, ref bool[,] visited, int width, int height)
|
private Point? getNextPoint(Bitmap img, ref bool[,] visited, int width, int height)
|
||||||
{
|
{
|
||||||
int rowStart = this.scannedRows;
|
int rowStart = this.scannedRows;
|
||||||
for (int row = rowStart; row < height; row++)
|
for (int row = rowStart; row <= height; row++)
|
||||||
{
|
{
|
||||||
for (int column = 0; column < width; column++)
|
for (int column = 0; column <= width; column++)
|
||||||
{
|
{
|
||||||
if (visited[column, row] == false)
|
if (visited[column, row] == false)
|
||||||
{
|
{
|
||||||
@ -217,3 +213,4 @@ namespace OSCADSharp.Solids.Imported
|
|||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user