diff --git a/UVtools.AvaloniaControls/UVtools.AvaloniaControls.csproj b/UVtools.AvaloniaControls/UVtools.AvaloniaControls.csproj index 61d2ff2..3eabae2 100644 --- a/UVtools.AvaloniaControls/UVtools.AvaloniaControls.csproj +++ b/UVtools.AvaloniaControls/UVtools.AvaloniaControls.csproj @@ -34,7 +34,7 @@ - + diff --git a/UVtools.Core/Managers/MatCacheManager.cs b/UVtools.Core/Managers/MatCacheManager.cs index 44b49b0..adabcba 100644 --- a/UVtools.Core/Managers/MatCacheManager.cs +++ b/UVtools.Core/Managers/MatCacheManager.cs @@ -10,6 +10,7 @@ using System; using System.Diagnostics; using System.Threading.Tasks; using Emgu.CV; +using Emgu.CV.CvEnum; using UVtools.Core.FileFormats; using UVtools.Core.Operations; @@ -57,6 +58,11 @@ namespace UVtools.Core.Managers /// public Enumerations.FlipDirection Flip { get; init; } = Enumerations.FlipDirection.None; + /// + /// Gets if striping anti-aliasing is enabled, cache will be threshold'ed + /// + public bool StripAntiAliasing { get; init; } + /// /// Gets or sets the cache direction, false to go backwards, true to go forward /// @@ -172,6 +178,11 @@ namespace UVtools.Core.Managers CvInvoke.Rotate(MatCache[currentCacheIndex][0], MatCache[currentCacheIndex][0], Enumerations.ToOpenCVRotateFlags(Rotate)); } + if (StripAntiAliasing) + { + CvInvoke.Threshold(MatCache[currentCacheIndex][0], MatCache[currentCacheIndex][0], 127, byte.MaxValue, ThresholdType.Binary); + } + AfterCacheAction?.Invoke(MatCache[currentCacheIndex]); }); } diff --git a/UVtools.Core/Operations/OperationDynamicLayerHeight.cs b/UVtools.Core/Operations/OperationDynamicLayerHeight.cs index 715bf9e..1244a3d 100644 --- a/UVtools.Core/Operations/OperationDynamicLayerHeight.cs +++ b/UVtools.Core/Operations/OperationDynamicLayerHeight.cs @@ -565,7 +565,7 @@ namespace UVtools.Core.Operations var anchor = new Point(-1, -1); using var kernel = CvInvoke.GetStructuringElement(ElementShape.Rectangle, new Size(3, 3), anchor); - var matCache = new MatCacheManager(this, (ushort)CacheObjectCount, 2) + var matCache = new MatCacheManager(this, (ushort)CacheObjectCount, ObjectsPerCache) { AutoDispose = true, AutoDisposeKeepLast = 1, @@ -706,7 +706,10 @@ namespace UVtools.Core.Operations { //byte innerErodeCount = 0; bool meetRequirement = false; - using var erodeMatXor = matXorSum.Clone(); + //using var erodeMatXor = matXorSum.Clone(); + //Debug.WriteLine($"\n\n{layerIndex} - 0"); + //CvInvoke.Imshow("Render", erodeMatXor.Roi(SlicerFile.BoundingRectangle)); + //CvInvoke.WaitKey(); while (erodeCount < _maximumErodes) { //innerErodeCount++; @@ -721,9 +724,11 @@ namespace UVtools.Core.Operations { break; }*/ - - CvInvoke.Erode(erodeMatXor, erodeMatXor, kernel, anchor, 1, BorderType.Reflect101, default); - if (CvInvoke.CountNonZero(erodeMatXor) == 0) + //Debug.WriteLine($"{layerIndex} - {erodeCount}"); + CvInvoke.Erode(matXorSum, matXor, kernel, anchor, 1, BorderType.Reflect101, default); + //CvInvoke.Imshow("Render", erodeMatXor.Roi(SlicerFile.BoundingRectangle)); + //CvInvoke.WaitKey(); + if (CvInvoke.CountNonZero(matXor) == 0) //if (erodeMatXor.IsZeroed(0, startPos, endPos+1)) // Image pixels exhausted and got empty image, can pack and go next { meetRequirement = true; diff --git a/UVtools.Core/Operations/OperationLayerExportMesh.cs b/UVtools.Core/Operations/OperationLayerExportMesh.cs index e255b6c..4561868 100644 --- a/UVtools.Core/Operations/OperationLayerExportMesh.cs +++ b/UVtools.Core/Operations/OperationLayerExportMesh.cs @@ -48,6 +48,8 @@ namespace UVtools.Core.Operations private ExportMeshQuality _quality = ExportMeshQuality.Accurate; private Enumerations.RotateDirection _rotateDirection = Enumerations.RotateDirection.None; private Enumerations.FlipDirection _flipDirection = Enumerations.FlipDirection.None; + private bool _stripAntiAliasing = true; + #endregion #region Overrides @@ -115,6 +117,12 @@ namespace UVtools.Core.Operations set => RaiseAndSetIfChanged(ref _flipDirection, value); } + public bool StripAntiAliasing + { + get => _stripAntiAliasing; + set => RaiseAndSetIfChanged(ref _stripAntiAliasing, value); + } + #endregion #region Constructor @@ -163,8 +171,9 @@ namespace UVtools.Core.Operations { AutoDispose = true, AutoDisposeKeepLast = 1, - //Rotate = _rotateDirection, - //Flip = _flipDirection + Rotate = _rotateDirection, + Flip = _flipDirection, + StripAntiAliasing = _stripAntiAliasing }; /* For the 1st stage, we maintain up to 3 mats, the current layer, the one below us, and the one above us @@ -175,7 +184,7 @@ namespace UVtools.Core.Operations { var matRoi = mat.Roi(SlicerFile.BoundingRectangle); - if (_flipDirection != Enumerations.FlipDirection.None) + /*if (_flipDirection != Enumerations.FlipDirection.None) { CvInvoke.Flip(matRoi, matRoi, Enumerations.ToOpenCVFlipType(_flipDirection)); } @@ -183,7 +192,7 @@ namespace UVtools.Core.Operations if (_rotateDirection != Enumerations.RotateDirection.None) { CvInvoke.Rotate(matRoi, matRoi, Enumerations.ToOpenCVRotateFlags(_rotateDirection)); - } + }*/ if ((byte)_quality > 1) { @@ -231,7 +240,7 @@ namespace UVtools.Core.Operations using var mat = SlicerFile.LayerManager.GetMergedMatForSequentialPositionedLayers(distinctLayers[(int)layerIndex+1].Index, cacheManager); var matRoi = mat.Roi(SlicerFile.BoundingRectangle); - if (_flipDirection != Enumerations.FlipDirection.None) + /*if (_flipDirection != Enumerations.FlipDirection.None) { CvInvoke.Flip(matRoi, matRoi, Enumerations.ToOpenCVFlipType(_flipDirection)); } @@ -239,7 +248,7 @@ namespace UVtools.Core.Operations if (_rotateDirection != Enumerations.RotateDirection.None) { CvInvoke.Rotate(matRoi, matRoi, Enumerations.ToOpenCVRotateFlags(_rotateDirection)); - } + }*/ if ((byte)_quality > 1) { diff --git a/UVtools.Core/UVtools.Core.csproj b/UVtools.Core/UVtools.Core.csproj index 8034585..6394a39 100644 --- a/UVtools.Core/UVtools.Core.csproj +++ b/UVtools.Core/UVtools.Core.csproj @@ -10,7 +10,7 @@ https://github.com/sn4k3/UVtools https://github.com/sn4k3/UVtools MSLA/DLP, file analysis, calibration, repair, conversion and manipulation - 2.23.7 + 2.24.0 Copyright © 2020 PTRTECH UVtools.png AnyCPU;x64 @@ -49,7 +49,7 @@ - + diff --git a/UVtools.WPF/Controls/Tools/ToolLayerExportMeshControl.axaml b/UVtools.WPF/Controls/Tools/ToolLayerExportMeshControl.axaml index 642c35f..30ba23a 100644 --- a/UVtools.WPF/Controls/Tools/ToolLayerExportMeshControl.axaml +++ b/UVtools.WPF/Controls/Tools/ToolLayerExportMeshControl.axaml @@ -48,5 +48,9 @@ Items="{Binding Operation.FlipDirection, Converter={StaticResource EnumToCollectionConverter}, Mode=OneTime}" SelectedItem="{Binding Operation.FlipDirection, Converter={StaticResource FromValueDescriptionToEnumConverter}}"/> + + diff --git a/UVtools.WPF/UVtools.WPF.csproj b/UVtools.WPF/UVtools.WPF.csproj index f204db3..ffac566 100644 --- a/UVtools.WPF/UVtools.WPF.csproj +++ b/UVtools.WPF/UVtools.WPF.csproj @@ -12,7 +12,7 @@ LICENSE https://github.com/sn4k3/UVtools Git - 2.23.7 + 2.24.0 AnyCPU;x64 @@ -34,11 +34,11 @@ 1701;1702; - + - - - + + +