Skip to content

Commit

Permalink
v1.3.3
Browse files Browse the repository at this point in the history
* (Add) Improved island detection: Combines the island and overhang detections for a better more realistic detection and to discard false-positives. (Slower)
   If enabled, and when a island is found, it will check for overhangs on that same island, if no overhang found then the island will be discarded and considered safe, otherwise it will flag as an island issue.
   Note: Overhangs settings will be used to configure the detection. Enabling Overhangs is not required for this procedure to work.
   Enabled by default,
* (Add) More information on the About box: Operative system and architecture, framework, processor count and screens
* (Fix) Overhangs: Include islands when detecting overhangs were not skip when found a island
* (Fix) Decode CWS from Wanhao Workshop fails on number of slices (#102)
  • Loading branch information
sn4k3 committed Nov 25, 2020
1 parent a4bdf8f commit 0017958
Show file tree
Hide file tree
Showing 15 changed files with 1,787 additions and 148 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 25/11/2020 - v1.3.3

* (Add) Improved island detection: Combines the island and overhang detections for a better more realistic detection and to discard false-positives. (Slower)
If enabled, and when a island is found, it will check for overhangs on that same island, if no overhang found then the island will be discarded and considered safe, otherwise it will flag as an island issue.
Note: Overhangs settings will be used to configure the detection. Enabling Overhangs is not required for this procedure to work.
Enabled by default,
* (Add) More information on the About box: Operative system and architecture, framework, processor count and screens
* (Fix) Overhangs: Include islands when detecting overhangs were not skip when found a island
* (Fix) Decode CWS from Wanhao Workshop fails on number of slices (#102)

## 19/11/2020 - v1.3.2

* (Add) Tools: Warn where layer preview is critical for use the tool, must disable layer rotation first (#100)
Expand Down
2 changes: 2 additions & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@
* illest twitch
* Khalil Nurullah
* Nahin Mulla
* Jorge diego Robles Ayerbe
* Timothy Gray
1,474 changes: 1,474 additions & 0 deletions UVtools.CAD/UVtools_fb_cover.ai

Large diffs are not rendered by default.

Binary file added UVtools.CAD/UVtools_fb_cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 27 additions & 2 deletions UVtools.Core/FileFormats/CWSFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
Expand Down Expand Up @@ -662,6 +663,23 @@ public override void Decode(string fileFullPath, OperationProgress progress = nu
{
//DecodeXML(fileFullPath, inputFile, progress);
Printer = PrinterType.Wanhao;

try
{
var serializer = new XmlSerializer(typeof(CWSManifest));
using (var stream = entry.Open())
{
var manifest = (CWSManifest)serializer.Deserialize(stream);
OutputSettings.LayersNum = (uint) manifest.Slices.Length;
}
}
catch (Exception e)
{
Clear();
throw new FileLoadException($"Unable to deserialize '{entry.Name}'\n{e}", fileFullPath);
}


entry = inputFile.Entries.FirstOrDefault(e => e.Name.EndsWith(".slicing"));

if (!(entry is null))
Expand Down Expand Up @@ -746,14 +764,21 @@ public override void Decode(string fileFullPath, OperationProgress progress = nu
var displayNameAttribute = propertyInfo.GetCustomAttributes(false).OfType<DisplayNameAttribute>().FirstOrDefault();
if (ReferenceEquals(displayNameAttribute, null)) continue;
if (!splitLine[0].Trim(' ', ';', '(').Equals(displayNameAttribute.DisplayName)) continue;
Helpers.SetPropertyValue(propertyInfo, OutputSettings, splitLine[1].Trim(' ', ')', 'p', 'x', 'm', 'n', 's', '/'));
try
{
Helpers.SetPropertyValue(propertyInfo, OutputSettings, splitLine[1].Trim(' ', ')', 'p', 'x', 'm', 'n', 's', '/'));
}
catch
{
// ignored
}

//Debug.WriteLine(splitLine[1].Trim(' ', ')', 'm', 'n', '/'));
}
}
tr.Close();
}


LayerManager = new LayerManager(OutputSettings.LayersNum, this);

progress.ItemCount = OutputSettings.LayersNum;
Expand Down
23 changes: 15 additions & 8 deletions UVtools.Core/Layer/LayerIssue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ public sealed class IslandDetectionConfiguration
/// </summary>
public List<uint> WhiteListLayers { get; set; } = null;

/// <summary>
/// Combines the island and overhang detections for a better more realistic detection and to discard false-positives. (Slower)
/// If enabled, and when a island is found, it will check for overhangs on that same island, if no overhang found then the island will be discarded and considered safe, otherwise it will flag as an island issue.
/// Note: Overhangs settings will be used to configure the detection.Enabling Overhangs is not required for this procedure to work.
/// </summary>
public bool EnhancedDetection { get; set; } = true;

/// <summary>
/// Gets the setting for whether or not diagonal bonds are considered when evaluation islands.
/// If true, all 8 neighbors of a pixel (including diagonals) will be considered when finding
/// individual components on the layer, if false only 4 neighbors (right, left, above, below)
/// will be considered..
/// </summary>
public bool AllowDiagonalBonds { get; set; } = false;

/// <summary>
/// Gets or sets the binary threshold, all pixels below this value will turn in black, otherwise white
/// Set to 0 to disable this operation
Expand Down Expand Up @@ -78,14 +93,6 @@ public sealed class IslandDetectionConfiguration
/// </summary>
public byte RequiredPixelBrightnessToSupport { get; set; } = 150;

/// <summary>
/// Gets the setting for whether or not diagonal bonds are considered when evaluation islands.
/// If true, all 8 neighbors of a pixel (including diagonals) will be considered when finding
/// individual components on the layer, if false only 4 neighbors (right, left, above, below)
/// will be considered..
/// </summary>
public bool AllowDiagonalBonds { get; set; } = false;

public IslandDetectionConfiguration(bool enabled = true)
{
Enabled = enabled;
Expand Down
22 changes: 17 additions & 5 deletions UVtools.Core/Layer/LayerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,16 +1056,21 @@ bool AddIssue(LayerIssue issue)
pixelsSupportingIsland >= Math.Max(1, points.Count / 2))
isIsland = false; // Not a island, but maybe weak bounding...*/


LayerIssue island = null;
if (pixelsSupportingIsland < requiredSupportingPixels)
{
AddIssue(new LayerIssue(layer, LayerIssue.IssueType.Island,
island = new LayerIssue(layer, LayerIssue.IssueType.Island,
points.ToArray(),
rect);
/*AddIssue(new LayerIssue(layer, LayerIssue.IssueType.Island,
points.ToArray(),
rect));
rect));*/
}

// Check for overhangs
if (overhangConfig.Enabled && !overhangConfig.IndependentFromIslands)
if (overhangConfig.Enabled && !overhangConfig.IndependentFromIslands && island is null
|| !ReferenceEquals(island, null) && islandConfig.EnhancedDetection && pixelsSupportingIsland >= 10
)
{
points.Clear();
using (var imageRoi = new Mat(image, rect))
Expand Down Expand Up @@ -1095,14 +1100,21 @@ bool AddIssue(LayerIssue issue)
points.Add(new Point(labelX, labelY));
}

if (points.Count >= overhangConfig.RequiredPixelsToConsider)
if (points.Count >= overhangConfig.RequiredPixelsToConsider) // Overhang
{
AddIssue(new LayerIssue(
layer, LayerIssue.IssueType.Overhang, points.ToArray(), rect
));
}
else if(islandConfig.EnhancedDetection) // No overhang
{
island = null;
}
}
}

if(!ReferenceEquals(island, null))
AddIssue(island);
}


Expand Down
2 changes: 1 addition & 1 deletion UVtools.Core/UVtools.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<RepositoryUrl>https://github.com/sn4k3/UVtools</RepositoryUrl>
<PackageProjectUrl>https://github.com/sn4k3/UVtools</PackageProjectUrl>
<Description>MSLA/DLP, file analysis, repair, conversion and manipulation</Description>
<Version>1.3.2</Version>
<Version>1.3.3</Version>
<Copyright>Copyright © 2020 PTRTECH</Copyright>
<PackageIcon>UVtools.png</PackageIcon>
<Platforms>AnyCPU;x64</Platforms>
Expand Down
1 change: 1 addition & 0 deletions UVtools.WPF/MainWindow.Issues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ public IslandDetectionConfiguration GetIslandDetectionConfiguration()
return new IslandDetectionConfiguration
{
Enabled = Settings.Issues.ComputeIslands,
EnhancedDetection = Settings.Issues.IslandEnhancedDetection,
AllowDiagonalBonds = Settings.Issues.IslandAllowDiagonalBonds,
BinaryThreshold = Settings.Issues.IslandBinaryThreshold,
RequiredAreaToProcessCheck = Settings.Issues.IslandRequiredAreaToProcessCheck,
Expand Down
37 changes: 20 additions & 17 deletions UVtools.WPF/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@


<MenuItem Header="_Help">
<MenuItem
Header="_About"
InputGesture="F1" HotKey="F1"
Command="{Binding MenuHelpAboutClicked}">
<MenuItem.Icon>
<Image Source="\Assets\Icons\button-info-16x16.png"/>
</MenuItem.Icon>
</MenuItem>

<MenuItem
Header="_Website"
InputGesture="Ctrl + F1" HotKey="Ctrl + F1"
Expand All @@ -156,14 +165,7 @@
</MenuItem.Icon>
</MenuItem>

<MenuItem
Header="_About"
InputGesture="F1" HotKey="F1"
Command="{Binding MenuHelpAboutClicked}">
<MenuItem.Icon>
<Image Source="\Assets\Icons\button-info-16x16.png"/>
</MenuItem.Icon>
</MenuItem>
<Separator/>

<MenuItem
Header="_Benchmark"
Expand All @@ -173,14 +175,6 @@
</MenuItem.Icon>
</MenuItem>

<MenuItem
Header="_Open settings folder"
Command="{Binding MenuHelpOpenSettingsFolderClicked}">
<MenuItem.Icon>
<Image Source="\Assets\Icons\open-16x16.png"/>
</MenuItem.Icon>
</MenuItem>

<Separator/>

<MenuItem
Expand All @@ -189,7 +183,16 @@
<MenuItem.Icon>
<Image Source="\Assets\Icons\CNCMachine-16x16.png"/>
</MenuItem.Icon>
</MenuItem>
</MenuItem>

<MenuItem
Header="_Open settings folder"
Command="{Binding MenuHelpOpenSettingsFolderClicked}">
<MenuItem.Icon>
<Image Source="\Assets\Icons\open-16x16.png"/>
</MenuItem.Icon>
</MenuItem>

</MenuItem>

<MenuItem
Expand Down
2 changes: 1 addition & 1 deletion UVtools.WPF/UVtools.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<RepositoryUrl>https://github.com/sn4k3/UVtools</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<Version>1.3.2</Version>
<Version>1.3.3</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
Loading

0 comments on commit 0017958

Please sign in to comment.