mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-08 17:42:31 +02:00
Add strip-antialising to export mesh
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="0.10.9" />
|
||||
<PackageReference Include="Avalonia" Version="0.10.10" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public Enumerations.FlipDirection Flip { get; init; } = Enumerations.FlipDirection.None;
|
||||
|
||||
/// <summary>
|
||||
/// Gets if striping anti-aliasing is enabled, cache will be threshold'ed
|
||||
/// </summary>
|
||||
public bool StripAntiAliasing { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the cache direction, false to go backwards, true to go forward
|
||||
/// </summary>
|
||||
@@ -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]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<RepositoryUrl>https://github.com/sn4k3/UVtools</RepositoryUrl>
|
||||
<PackageProjectUrl>https://github.com/sn4k3/UVtools</PackageProjectUrl>
|
||||
<Description>MSLA/DLP, file analysis, calibration, repair, conversion and manipulation</Description>
|
||||
<Version>2.23.7</Version>
|
||||
<Version>2.24.0</Version>
|
||||
<Copyright>Copyright © 2020 PTRTECH</Copyright>
|
||||
<PackageIcon>UVtools.png</PackageIcon>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AnimatedGif" Version="1.0.5" />
|
||||
<PackageReference Include="BinarySerializer" Version="8.6.1" />
|
||||
<PackageReference Include="BinarySerializer" Version="8.6.1.1" />
|
||||
<PackageReference Include="Emgu.CV" Version="4.5.3.4721" />
|
||||
<PackageReference Include="KdTree" Version="1.4.1" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.0.0-6.final" />
|
||||
|
||||
@@ -48,5 +48,9 @@
|
||||
Items="{Binding Operation.FlipDirection, Converter={StaticResource EnumToCollectionConverter}, Mode=OneTime}"
|
||||
SelectedItem="{Binding Operation.FlipDirection, Converter={StaticResource FromValueDescriptionToEnumConverter}}"/>
|
||||
</Grid>
|
||||
|
||||
<CheckBox
|
||||
Content="Strip anti-aliasing"
|
||||
IsChecked="{Binding Operation.StripAntiAliasing}"/>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<RepositoryUrl>https://github.com/sn4k3/UVtools</RepositoryUrl>
|
||||
<RepositoryType>Git</RepositoryType>
|
||||
<Version>2.23.7</Version>
|
||||
<Version>2.24.0</Version>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -34,11 +34,11 @@
|
||||
<NoWarn>1701;1702;</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="0.10.9" />
|
||||
<PackageReference Include="Avalonia" Version="0.10.10" />
|
||||
<PackageReference Include="Avalonia.Angle.Windows.Natives" Version="2.1.0.2020091801" />
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="0.10.9" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="0.10.9" />
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.9" />
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="0.10.10" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="0.10.10" />
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.10" />
|
||||
<PackageReference Include="Emgu.CV.runtime.windows" Version="4.5.3.4721" />
|
||||
<PackageReference Include="MessageBox.Avalonia" Version="1.5.5" />
|
||||
<PackageReference Include="ThemeEditor.Controls.ColorPicker" Version="0.10.8" />
|
||||
|
||||
Reference in New Issue
Block a user