Skip to content

Commit

Permalink
v0.6.3.2
Browse files Browse the repository at this point in the history
* (Add) Tool: Layer Re-Height - Allow change layer height
* (Add) Setting: Gap closing default iterations
* (Add) Setting: Noise removal default iterations
* (Add) Setting: Repair layers and islands by default
* (Add) Setting: Remove empty layers by default
* (Add) Setting: Repair resin traps by default
* (Change) Setting: "Reset to Defaults" changed to "Reset All Settings"
* (Fix) CWS: Lack of ';' on GCode was preventing printer from printing
  • Loading branch information
sn4k3 committed Jul 24, 2020
1 parent 07652d6 commit bf0feb8
Show file tree
Hide file tree
Showing 30 changed files with 521 additions and 101 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 24/07/2020 - v0.6.3.2

* (Add) Tool: Layer Re-Height - Allow change layer height
* (Add) Setting: Gap closing default iterations
* (Add) Setting: Noise removal default iterations
* (Add) Setting: Repair layers and islands by default
* (Add) Setting: Remove empty layers by default
* (Add) Setting: Repair resin traps by default
* (Change) Setting: "Reset to Defaults" changed to "Reset All Settings"
* (Fix) CWS: Lack of ';' on GCode was preventing printer from printing

## 20/07/2020 - v0.6.3.1

* (Add) Preview: Allow import images from disk and replace preview image
Expand Down
9 changes: 7 additions & 2 deletions UVtools.Core/FileFormats/CWSFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,19 @@ public class Slice
public override uint ResolutionY => SliceSettings.Yres;
public override byte AntiAliasing => (byte) OutputSettings.AntiAliasingValue;

public override float LayerHeight => SliceSettings.Thickness;
public override float LayerHeight
{
get => SliceSettings.Thickness;
set => OutputSettings.LayerThickness = SliceSettings.Thickness = value;
}

public override uint LayerCount
{
set
{
OutputSettings.LayersNum = LayerCount;
SliceSettings.LayersNum = LayerCount;
UpdateGCode();
}
}

Expand Down Expand Up @@ -581,7 +586,7 @@ private void UpdateGCode()
string arch = Environment.Is64BitOperatingSystem ? "64-bits" : "32-bits";
GCode = new StringBuilder();
GCode.AppendLine($"; {About.Website} {About.Software} {Assembly.GetExecutingAssembly().GetName().Version} {arch} {DateTime.Now}");
GCode.AppendLine("(****Build and Slicing Parameters * ***)");
GCode.AppendLine(";(****Build and Slicing Parameters ****)");

foreach (var propertyInfo in OutputSettings.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
{
Expand Down
6 changes: 5 additions & 1 deletion UVtools.Core/FileFormats/ChituboxFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,11 @@ public byte[] Read(byte[] input)
public override uint ResolutionY => HeaderSettings.ResolutionY;
public override byte AntiAliasing => (byte) (IsCbtFile ? SlicerInfoSettings.AntiAliasLevel : HeaderSettings.AntiAliasLevel);

public override float LayerHeight => HeaderSettings.LayerHeightMilimeter;
public override float LayerHeight
{
get => HeaderSettings.LayerHeightMilimeter;
set => HeaderSettings.LayerHeightMilimeter = value;
}

public override uint LayerCount
{
Expand Down
7 changes: 6 additions & 1 deletion UVtools.Core/FileFormats/ChituboxZipFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,18 @@ public class Header
public override uint ResolutionY => HeaderSettings.ResolutionY;
public override byte AntiAliasing => HeaderSettings.AntiAliasing;

public override float LayerHeight => HeaderSettings.LayerHeight;
public override float LayerHeight
{
get => HeaderSettings.LayerHeight;
set => HeaderSettings.LayerHeight = value;
}

public override uint LayerCount
{
set
{
HeaderSettings.LayerCount = LayerCount;
UpdateGCode();
}
}

Expand Down
2 changes: 1 addition & 1 deletion UVtools.Core/FileFormats/FileFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public bool RequireFullEncode
public bool HaveAntiAliasing => AntiAliasing > 1;
public abstract byte AntiAliasing { get; }

public abstract float LayerHeight { get; }
public abstract float LayerHeight { get; set; }

public float TotalHeight => LayerCount == 0 ? 0 : this[LayerCount - 1].PositionZ; //(float)Math.Round(LayerCount * LayerHeight, 2);

Expand Down
2 changes: 1 addition & 1 deletion UVtools.Core/FileFormats/IFileFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public interface IFileFormat
/// <summary>
/// Gets Layer Height in mm
/// </summary>
float LayerHeight { get; }
float LayerHeight { get; set; }

/// <summary>
/// Gets Total Height in mm
Expand Down
2 changes: 1 addition & 1 deletion UVtools.Core/FileFormats/ImageFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ImageFile : FileFormat
public override uint ResolutionX => (uint)ImageMat.Width;
public override uint ResolutionY => (uint)ImageMat.Height;
public override byte AntiAliasing { get; } = 1;
public override float LayerHeight { get; } = 0;
public override float LayerHeight { get; set; } = 0;
public override ushort InitialLayerCount { get; } = 1;
public override float InitialExposureTime { get; } = 0;
public override float LayerExposureTime { get; } = 0;
Expand Down
6 changes: 5 additions & 1 deletion UVtools.Core/FileFormats/PHZFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,11 @@ public byte[] Read(byte[] input)
public override uint ResolutionY => HeaderSettings.ResolutionY;
public override byte AntiAliasing => (byte) HeaderSettings.AntiAliasLevelInfo;

public override float LayerHeight => HeaderSettings.LayerHeightMilimeter;
public override float LayerHeight
{
get => HeaderSettings.LayerHeightMilimeter;
set => HeaderSettings.LayerHeightMilimeter = value;
}

public override uint LayerCount
{
Expand Down
6 changes: 5 additions & 1 deletion UVtools.Core/FileFormats/PWSFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,11 @@ public void Validate()
public override uint ResolutionY => HeaderSettings.ResolutionY;
public override byte AntiAliasing => (byte) HeaderSettings.AntiAliasing;

public override float LayerHeight => HeaderSettings.LayerHeight;
public override float LayerHeight
{
get => HeaderSettings.LayerHeight;
set => HeaderSettings.LayerHeight = value;
}

public override uint LayerCount
{
Expand Down
6 changes: 5 additions & 1 deletion UVtools.Core/FileFormats/SL1File.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ public override string ToString()
public override uint ResolutionY => PrinterSettings.DisplayPixelsY;
public override byte AntiAliasing => (byte) (PrinterSettings.GammaCorrection > 0 ? LookupCustomValue(Keyword_AntiAliasing, 4) : 1);

public override float LayerHeight => OutputConfigSettings.LayerHeight;
public override float LayerHeight
{
get => OutputConfigSettings.LayerHeight;
set => OutputConfigSettings.LayerHeight = value;
}

public override uint LayerCount
{
Expand Down
6 changes: 5 additions & 1 deletion UVtools.Core/FileFormats/UVJFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ public override string ToString()
public override uint ResolutionY => JsonSettings.Properties.Size.Y;
public override byte AntiAliasing => JsonSettings.Properties.AntiAliasLevel;

public override float LayerHeight => JsonSettings.Properties.Size.LayerHeight;
public override float LayerHeight
{
get => JsonSettings.Properties.Size.LayerHeight;
set => JsonSettings.Properties.Size.LayerHeight = value;
}

public override uint LayerCount
{
Expand Down
7 changes: 6 additions & 1 deletion UVtools.Core/FileFormats/ZCodexFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,19 @@ public class LayerData
public override uint ResolutionY => 2560;
public override byte AntiAliasing => UserSettings.AntiAliasing;

public override float LayerHeight => ResinMetadataSettings.LayerThickness;
public override float LayerHeight
{
get => ResinMetadataSettings.LayerThickness;
set => ResinMetadataSettings.LayerThickness = value;
}

public override uint LayerCount
{
set
{
UserSettings.MaxLayer = LayerCount - 1;
ResinMetadataSettings.TotalLayersCount = LayerCount;
UpdateGCode();
}
}

Expand Down
10 changes: 8 additions & 2 deletions UVtools.Core/Layer/Layer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class Layer : IEquatable<Layer>, IEquatable<uint>
/// <summary>
/// Gets the bounding rectangle for the image area
/// </summary>
public Rectangle BoundingRectangle { get; private protected set; } = Rectangle.Empty;
public Rectangle BoundingRectangle { get; internal set; } = Rectangle.Empty;

/// <summary>
/// Gets the layer index
Expand Down Expand Up @@ -781,7 +781,13 @@ public void ToolPattern(OperationPattern settings)

public Layer Clone()
{
return new Layer(Index, CompressedBytes, Filename, ParentLayerManager);
return new Layer(Index, CompressedBytes, Filename, ParentLayerManager)
{
PositionZ = PositionZ,
ExposureTime = ExposureTime,
BoundingRectangle = BoundingRectangle,
NonZeroPixelCount = NonZeroPixelCount,
};
}

#endregion
Expand Down
59 changes: 59 additions & 0 deletions UVtools.Core/Layer/LayerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1437,5 +1437,64 @@ public void RemoveLayer(List<uint> layersRemove)
BoundingRectangle = Rectangle.Empty;
SlicerFile.RequireFullEncode = true;
}

public void ReHeight(OperationLayerReHeight operation, OperationProgress progress = null)
{
if (ReferenceEquals(progress, null)) progress = new OperationProgress();
progress.Reset("Re-Height", operation.LayerCount);

var oldLayers = Layers;

Layers = new Layer[operation.LayerCount];

uint newLayerIndex = 0;
for (uint layerIndex = 0; layerIndex < oldLayers.Length; layerIndex++)
{
var oldLayer = oldLayers[layerIndex];
if (operation.IsDivision)
{
for (byte i = 0; i < operation.Modifier; i++)
{
Layers[newLayerIndex] =
new Layer(newLayerIndex, oldLayer.CompressedBytes, null, this)
{
PositionZ = (float) (operation.LayerHeight * (newLayerIndex + 1)),
ExposureTime = oldLayer.ExposureTime,
BoundingRectangle = oldLayer.BoundingRectangle,
};
newLayerIndex++;
progress++;
}
}
else
{
using (var mat = oldLayers[layerIndex++].LayerMat)
{
for (byte i = 1; i < operation.Modifier; i++)
{
using (var nextMat = oldLayers[layerIndex++].LayerMat)
{
CvInvoke.Add(mat, nextMat, mat);
}
}

Layers[newLayerIndex] = new Layer(newLayerIndex, mat, null, this)
{
PositionZ = (float)(operation.LayerHeight * (newLayerIndex + 1)),
ExposureTime = oldLayer.ExposureTime
};
newLayerIndex++;
layerIndex--;
progress++;
}
}
}


SlicerFile.LayerHeight = (float) operation.LayerHeight;
SlicerFile.LayerCount = Count;
BoundingRectangle = Rectangle.Empty;
SlicerFile.RequireFullEncode = true;
}
}
}
25 changes: 25 additions & 0 deletions UVtools.Core/Operations/OperationLayerReHeight.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

namespace UVtools.Core.Operations
{
public sealed class OperationLayerReHeight
{
public bool IsMultiply { get; }
public bool IsDivision => !IsMultiply;
public byte Modifier { get; }
public decimal LayerHeight { get; }
public uint LayerCount { get; }

public OperationLayerReHeight(bool isMultiply, byte modifier, decimal layerHeight, uint layerCount)
{
IsMultiply = isMultiply;
Modifier = modifier;
LayerHeight = layerHeight;
LayerCount = layerCount;
}

public override string ToString()
{
return (IsMultiply ? 'x' : '÷') +$" {Modifier}{LayerCount} layers at {LayerHeight}mm";
}
}
}
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>0.6.3.1</Version>
<Version>0.6.3.2</Version>
<Copyright>Copyright © 2020 PTRTECH</Copyright>
<PackageIcon>UVtools.png</PackageIcon>
<Platforms>AnyCPU;x64</Platforms>
Expand Down
15 changes: 15 additions & 0 deletions UVtools.GUI/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,21 @@
<setting name="AutoZoomIssues" serializeAs="String">
<value>True</value>
</setting>
<setting name="LayerRepairDefaultClosingIterations" serializeAs="String">
<value>2</value>
</setting>
<setting name="LayerRepairDefaultOpeningIterations" serializeAs="String">
<value>1</value>
</setting>
<setting name="LayerRepairLayersIslands" serializeAs="String">
<value>True</value>
</setting>
<setting name="LayerRepairResinTraps" serializeAs="String">
<value>True</value>
</setting>
<setting name="LayerRepairRemoveEmptyLayers" serializeAs="String">
<value>True</value>
</setting>
</UVtools.GUI.Properties.Settings>
</userSettings>
</configuration>
1 change: 1 addition & 0 deletions UVtools.GUI/Forms/FrmInputBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

using System;
using System.Diagnostics;
using System.Globalization;
using System.Windows.Forms;
using UVtools.Core;
Expand Down
9 changes: 6 additions & 3 deletions UVtools.GUI/Forms/FrmRepairLayers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,17 @@ public bool RepairResinTraps
#endregion

#region Constructors
public FrmRepairLayers(uint defaultClosingIterations = 1, uint defaultOpeningIterations = 1)
public FrmRepairLayers()
{
InitializeComponent();
DialogResult = DialogResult.Cancel;


ClosingIterations = defaultClosingIterations;
OpeningIterations = defaultOpeningIterations;
ClosingIterations = Properties.Settings.Default.LayerRepairDefaultClosingIterations;
OpeningIterations = Properties.Settings.Default.LayerRepairDefaultOpeningIterations;
RepairIslands = Properties.Settings.Default.LayerRepairLayersIslands;
RemoveEmptyLayers = Properties.Settings.Default.LayerRepairRemoveEmptyLayers;
RepairResinTraps = Properties.Settings.Default.LayerRepairResinTraps;
numClosingIterations.Select();

nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount-1;
Expand Down
Loading

0 comments on commit bf0feb8

Please sign in to comment.