mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-22 18:58:28 +00:00
Optimized out a bottleneck in CubistImageProcessor.cs
This commit is contained in:
parent
4f962ca257
commit
5574dfa2c6
@ -14,6 +14,7 @@ namespace OSCADSharp.Solids.Imported
|
|||||||
internal class CubistImageProcessor : IImageProcessor
|
internal class CubistImageProcessor : IImageProcessor
|
||||||
{
|
{
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
private int scannedRows = 0;
|
||||||
private string imagePath;
|
private string imagePath;
|
||||||
List<OSCADObject> cubes = new List<OSCADObject>();
|
List<OSCADObject> cubes = new List<OSCADObject>();
|
||||||
#endregion
|
#endregion
|
||||||
@ -34,17 +35,10 @@ namespace OSCADSharp.Solids.Imported
|
|||||||
return obj.Scale(1, -1, 1).Translate(0, ImageBounds.Width, 0);
|
return obj.Scale(1, -1, 1).Translate(0, ImageBounds.Width, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#region Private Methods
|
#region Private Methods
|
||||||
private List<OSCADObject> processImage()
|
private List<OSCADObject> processImage()
|
||||||
{
|
{
|
||||||
Bitmap img = new Bitmap(Image.FromFile(this.imagePath));
|
Bitmap img = new Bitmap(Image.FromFile(this.imagePath));
|
||||||
|
|
||||||
if (img.Width > 200 || img.Height > 200)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Cannot process images larger greater than 200x200 pixels");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.ImageBounds = new Bounds(new Vector3(), new Vector3(img.Width, img.Height, 1));
|
this.ImageBounds = new Bounds(new Vector3(), new Vector3(img.Width, img.Height, 1));
|
||||||
|
|
||||||
List<OSCADObject> cubes = new List<OSCADObject>();
|
List<OSCADObject> cubes = new List<OSCADObject>();
|
||||||
@ -157,17 +151,21 @@ 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)
|
||||||
{
|
{
|
||||||
for (int column = 0; column < width; column++)
|
int rowStart = this.scannedRows;
|
||||||
|
for (int row = rowStart; row < height; row++)
|
||||||
{
|
{
|
||||||
for (int row = 0; row < height; row++)
|
for (int column = 0; column < width; column++)
|
||||||
{
|
{
|
||||||
if (visited[column, row] == false)
|
if (visited[column, row] == false)
|
||||||
{
|
{
|
||||||
return new Point(column, row);
|
return new Point(column, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.scannedRows++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user