Skip to content

Commit

Permalink
v4.0.5
Browse files Browse the repository at this point in the history
- (Add) Tool - Phased Exposure: Replace "Double Exposure" with "Phased Exposure" tool, same effect but allow to define more steps (#778)
- (Fix) Infill: Honeycomb Infill does not completely infill model (#789)
- (Improvement) File -> Open recent: Disable all inexistent files (Can no longer be clicked)
- (Upgrade) .NET from 6.0.24 to 6.0.25
- (Upgrade) AvaloniaUI from 11.0.5 to 11.0.6
  • Loading branch information
sn4k3 committed Dec 12, 2023
1 parent 2caaba8 commit 9374705
Show file tree
Hide file tree
Showing 23 changed files with 995 additions and 91 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 12/12/2023 - v4.0.5

- (Add) Tool - Phased Exposure: Replace "Double Exposure" with "Phased Exposure" tool, same effect but allow to define more steps (#778)
- (Fix) Infill: Honeycomb Infill does not completely infill model (#789)
- (Improvement) File -> Open recent: Disable all inexistent files (Can no longer be clicked)
- (Upgrade) .NET from 6.0.24 to 6.0.25
- (Upgrade) AvaloniaUI from 11.0.5 to 11.0.6
-
## 09/11/2023 - v4.0.4

- **FileFormat Anycubic:**
Expand Down
4 changes: 3 additions & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,6 @@
- Robert Redden
- Nick Spirov
- Sylvain Chartrand
- Michael Pullen
- Michael Pullen
- Albeck Károly
- Mark Johnston
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,13 @@ The following commands are the old way and commands under the UI executable, the
- Click on: Turn Windows features on or off
- Check the "Media Extensions" and click Ok
<!-- 1. [.NET 6.0](https://dotnet.microsoft.com/download/dotnet/6.0) installed (Comes pre-installed on Windows 10 with last updates)!-->
1. 4GB RAM or higher
1. 8GB RAM or higher + 512MB per CPU core
2. 64 bit System
3. 1920 x 1080 @ 100% scale as minimum resolution
## Linux
1. 4GB RAM or higher
1. 8GB RAM or higher + 512MB per CPU core
2. 64 bit System
3. 1920 x 1080 @ 100% scale as minimum resolution
Expand Down Expand Up @@ -290,7 +290,7 @@ If you downloaded the **.AppImage** package variant you must set run permissions
## Mac
1. macOS 10.15 Catalina or higher
1. 4GB RAM or higher
1. 8GB RAM or higher + 512MB per CPU core
3. **For Mac M1/M2 (ARM):**
1. Install via the [auto installer](https://github.com/sn4k3/UVtools#to-auto-install-on-macos-homebrew)
Expand Down
18 changes: 6 additions & 12 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
- **FileFormat Anycubic:**
- (Fix) Preview marker size and `PropertyFields` for given file version
- (Fix) Do not cache and reuse layer images if equal on file write, as that is causing "file damage" message (#782, #787)
- **Tools:**
- **Mask:**
- (Improvement) Apply the mask with Multiply instead of BitwiseAnd (#747)
- **Layer and pixel arithmetic**:
- (Improvement) Use the byte scale value (1/255) for multiply operations
- **Infill:**
- (Add) Floor/Ceil thickness (#785)
- (Fix) Remove the debug blocking window when selecting the honeycomb pattern
- (Upgrade) .NET from 6.0.23 to 6.0.24
- (Add) Tool - Phased Exposure: Replace "Double Exposure" with "Phased Exposure" tool, same effect but allow to define more steps (#778)
- (Fix) Infill: Honeycomb Infill does not completely infill model (#789)
- (Improvement) File -> Open recent: Disable all inexistent files (Can no longer be clicked)
- (Upgrade) .NET from 6.0.24 to 6.0.25
- (Upgrade) AvaloniaUI from 11.0.5 to 11.0.6
-

2 changes: 1 addition & 1 deletion UVtools.AvaloniaControls/UVtools.AvaloniaControls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.5" />
<PackageReference Include="Avalonia" Version="11.0.6" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion UVtools.Cmd/Symbols/PrintMachines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal static Command CreateCommand()
if (xmlFormat)
{
Console.WriteLine(XmlExtensions.SerializeObject(Machine.Machines, XmlExtensions.SettingsIndent));
Console.WriteLine(XmlExtensions.SerializeToString(Machine.Machines, XmlExtensions.SettingsIndent));
return;
}
Expand Down
4 changes: 4 additions & 0 deletions UVtools.Core/EmguCV/MatRoi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public MatRoi(Mat sourceMat, Rectangle roi)

#endregion

public MatRoi Clone()
{
return new MatRoi(SourceMat.Clone(), Roi);
}

public void Dispose()
{
Expand Down
45 changes: 40 additions & 5 deletions UVtools.Core/Extensions/ClassExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,56 @@
* of this license document, but changing it is not allowed.
*/

using System.IO;
using System.Text;
using System.Text.Json;
using System.Xml;
using System.Xml.Serialization;

namespace UVtools.Core.Extensions;

public static class ClassExtensions
{
public static T? CloneByJsonSerialization<T>(this T classToClone) where T : class
private static readonly JsonSerializerOptions JsonCloneSerializeSettings = new()
{
var clone = JsonSerializer.SerializeToUtf8Bytes(classToClone);
return JsonSerializer.Deserialize<T>(clone);
//DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull,
WriteIndented = false,
Converters =
{
new System.Text.Json.Serialization.JsonStringEnumConverter()
},
IncludeFields = true,
};

private static readonly XmlWriterSettings XmlCloneSerializeSettings = new()
{
// If set to true XmlWriter would close MemoryStream automatically and using would then do double dispose
// Code analysis does not understand that. That's why there is a suppress message.
CloseOutput = false,
Encoding = Encoding.UTF8,
OmitXmlDeclaration = false,
Indent = false,
};

public static T CloneByJsonSerialization<T>(this T classToClone) where T : class
{
var clone = JsonSerializer.SerializeToUtf8Bytes(classToClone, JsonCloneSerializeSettings);
return JsonSerializer.Deserialize<T>(clone, JsonCloneSerializeSettings)!;
}

public static T CloneByXmlSerialization<T>(this T classToClone) where T : class
{
var clone = XmlExtensions.SerializeObject(classToClone);
return XmlExtensions.DeserializeFromText<T>(clone);
//var clone = XmlExtensions.SerializeObject(classToClone, Encoding.UTF8, false);
//return XmlExtensions.DeserializeFromText<T>(clone);

using var stream = new MemoryStream();
using var xmlWriter = XmlWriter.Create(stream, XmlCloneSerializeSettings);
xmlWriter.WriteStartDocument(false); // that bool parameter is called "standalone"
var xmlSerializer = new XmlSerializer(classToClone.GetType());
//XmlSerializerNamespaces? ns = true ? new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty }) : null;
xmlSerializer.Serialize(xmlWriter, classToClone);

stream.Seek(0, SeekOrigin.Begin);
return (T)xmlSerializer.Deserialize(stream)!;
}
}
20 changes: 20 additions & 0 deletions UVtools.Core/Extensions/ListExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
using System.Collections.Generic;
using System;
using System.Linq;

namespace UVtools.Core.Extensions;

public static class ListExtensions
{
public static List<T> Clone<T>(this List<T> listToClone) where T : class, ICloneable
{
return listToClone.Select(item => (T)item.Clone()).ToList();
}
}
7 changes: 7 additions & 0 deletions UVtools.Core/Extensions/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,11 @@ public static IEnumerable<Type> GetTypesInNamespace(Assembly assembly, string na
return assembly.GetTypes()
.Where(t => string.Equals(t.Namespace, nameSpace, StringComparison.Ordinal));
}

public static bool IsPrimitive(this Type type)
{
if (type == typeof(string)
|| type == typeof(decimal)) return true;
return type is { IsValueType: true, IsPrimitive: true };
}
}
80 changes: 48 additions & 32 deletions UVtools.Core/Extensions/XmlExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ public static class XmlExtensions
public static void Serialize(object toSerialize, Stream stream, bool noNameSpace = false)
{
var xmlSerializer = new XmlSerializer(toSerialize.GetType());
XmlSerializerNamespaces? ns = null;
if (noNameSpace)
{
ns = new();
ns.Add("", "");
}
XmlSerializerNamespaces? ns = noNameSpace ? new XmlSerializerNamespaces(new []{XmlQualifiedName.Empty}) : null;
xmlSerializer.Serialize(stream, toSerialize, ns);
}

Expand All @@ -40,12 +35,7 @@ public static void Serialize(object toSerialize, Stream stream, XmlWriterSetting
xw.WriteStartDocument(standalone); // that bool parameter is called "standalone"

var s = new XmlSerializer(toSerialize.GetType());
XmlSerializerNamespaces? ns = null;
if (noNameSpace)
{
ns = new();
ns.Add("", "");
}
XmlSerializerNamespaces? ns = noNameSpace ? new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty }) : null;
s.Serialize(xw, toSerialize, ns);
}

Expand All @@ -63,6 +53,39 @@ public static void Serialize(object toSerialize, Stream stream, Encoding encodin
Serialize(toSerialize, stream, settings, noNameSpace, standalone);
}

public static void Serialize(object toSerialize, TextWriter stream, bool noNameSpace = false)
{
var xmlSerializer = new XmlSerializer(toSerialize.GetType());
XmlSerializerNamespaces? ns = noNameSpace ? new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty }) : null;
xmlSerializer.Serialize(stream, toSerialize, ns);
}

public static void Serialize(object toSerialize, TextWriter stream, XmlWriterSettings settings, bool noNameSpace = false, bool standalone = false)
{
settings.CloseOutput = false;

using var xw = XmlWriter.Create(stream, settings);
xw.WriteStartDocument(standalone); // that bool parameter is called "standalone"

var s = new XmlSerializer(toSerialize.GetType());
XmlSerializerNamespaces? ns = noNameSpace ? new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty }) : null;
s.Serialize(xw, toSerialize, ns);
}

public static void Serialize(object toSerialize, TextWriter stream, Encoding encoding, bool indent = true, bool omitXmlDeclaration = false, bool noNameSpace = false, bool standalone = false)
{
var settings = new XmlWriterSettings
{
// If set to true XmlWriter would close MemoryStream automatically and using would then do double dispose
// Code analysis does not understand that. That's why there is a suppress message.
CloseOutput = false,
Encoding = encoding,
OmitXmlDeclaration = omitXmlDeclaration,
Indent = indent,
};
Serialize(toSerialize, stream, settings, noNameSpace, standalone);
}

public static void SerializeToFile(object toSerialize, string path, bool noNameSpace = false)
{
using var stream = new FileStream(path, FileMode.Create);
Expand All @@ -81,32 +104,25 @@ public static void SerializeToFile(object toSerialize, string path, Encoding enc
Serialize(toSerialize, stream, encoding, indent, omitXmlDeclaration, noNameSpace, standalone);
}


public static string SerializeObject(object toSerialize, bool noNameSpace = false)
public static string SerializeToString(object toSerialize, bool noNameSpace = false)
{
using var stream = new MemoryStream();
Serialize(toSerialize, stream, noNameSpace);
stream.Seek(0, SeekOrigin.Begin);
using var reader = new StreamReader(stream);
return reader.ReadToEnd();
using var stringWriter = new StringWriter();
Serialize(toSerialize, stringWriter, noNameSpace);
return stringWriter.ToString();
}

public static string SerializeObject(object toSerialize, XmlWriterSettings settings, bool noNameSpace = false, bool standalone = false)
public static string SerializeToString(object toSerialize, XmlWriterSettings settings, bool noNameSpace = false, bool standalone = false)
{
using var stream = new MemoryStream();
Serialize(toSerialize, stream, settings, noNameSpace, standalone);
stream.Seek(0, SeekOrigin.Begin);
using var reader = new StreamReader(stream);
return reader.ReadToEnd();
using var stringWriter = new StringWriter();
Serialize(toSerialize, stringWriter, settings, noNameSpace, standalone);
return stringWriter.ToString();
}

public static string SerializeObject(object toSerialize, Encoding encoding, bool indent = true, bool omitXmlDeclaration = false, bool noNameSpace = false, bool standalone = false)
public static string SerializeToString(object toSerialize, Encoding encoding, bool indent = true, bool omitXmlDeclaration = false, bool noNameSpace = false, bool standalone = false)
{
using var stream = new MemoryStream();
Serialize(toSerialize, stream, encoding, indent, omitXmlDeclaration, noNameSpace, standalone);
stream.Seek(0, SeekOrigin.Begin);
using var reader = new StreamReader(stream);
return reader.ReadToEnd();
using var stringWriter = new StringWriter();
Serialize(toSerialize, stringWriter, encoding, indent, omitXmlDeclaration, noNameSpace, standalone);
return stringWriter.ToString();
}

public static T DeserializeFromStream<T>(Stream stream)
Expand All @@ -121,7 +137,7 @@ public static T DeserializeFromFile<T>(string filePath)
return DeserializeFromStream<T>(stream);
}

public static T DeserializeFromText<T>(string text)
public static T DeserializeFromString<T>(string text)
{
var serializer = new XmlSerializer(typeof(T));
using TextReader reader = new StringReader(text);
Expand Down
4 changes: 2 additions & 2 deletions UVtools.Core/FileFormats/FlashForgeSVGXFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public string SerializeToString()
NewLineChars = "\n"
};

var svg = XmlExtensions.SerializeObject(this, settings);
var svg = XmlExtensions.SerializeToString(this, settings);
return svg.Replace(" ", string.Empty)
.Replace("<g id=\"background\" area=\"0\" perimeter=\"0\" />", "<g id=\"background\">\n</g>")
+ '\n';
Expand Down Expand Up @@ -602,7 +602,7 @@ protected override void DecodeInternally(OperationProgress progress)

inputFile.Seek(HeaderSettings.SVGDocumentAddress, SeekOrigin.Begin);
string svgDocument = Encoding.UTF8.GetString(inputFile.ReadToEnd());
SVGDocument = XmlExtensions.DeserializeFromText<FlashForgeSVGXSvg>(svgDocument);
SVGDocument = XmlExtensions.DeserializeFromString<FlashForgeSVGXSvg>(svgDocument);

Debug.WriteLine(SVGDocument);

Expand Down
3 changes: 3 additions & 0 deletions UVtools.Core/Operations/OperationDoubleExposure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public class OperationDoubleExposure : Operation
"After this, do not apply any modification which reconstruct the z positions of the layers.\n" +
"Note: To eliminate the elephant foot effect, the use of wall dimming method is recommended.";

public override bool CanROI => false;
public override bool CanMask => false;

public override string ConfirmationText =>
$"double exposure model layers {LayerIndexStart} through {LayerIndexEnd}";

Expand Down
18 changes: 14 additions & 4 deletions UVtools.Core/Operations/OperationInfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,24 @@ protected override bool ExecuteInternally(OperationProgress progress)
if (_infillType == InfillAlgorithm.Honeycomb)
{
mask = GetHoneycombMask(GetRoiSizeOrVolumeSize());
//CvInvoke.Imshow("Honeycomb", mask);
//CvInvoke.WaitKey();

}
else if (_infillType == InfillAlgorithm.Concentric)
{
mask = GetConcentricMask(GetRoiSizeOrVolumeSize());
}

#if DEBUG
/*
if (mask is not null)
{
using var previewMat = new Mat();
CvInvoke.Resize(mask, previewMat, new Size(mask.Width / 4, mask.Height / 4));
CvInvoke.Imshow("Honeycomb", previewMat);
CvInvoke.WaitKey();
}*/
#endif

var clonedLayers = SlicerFile.CloneLayers();

Parallel.For(LayerIndexStart, LayerIndexEnd + 1, CoreSettings.GetParallelOptions(progress), layerIndex =>
Expand Down Expand Up @@ -549,10 +559,10 @@ public Mat GetHoneycombMask(Size targetSize)
var halfInfillSpacingD = _infillSpacing / 2.0;
var halfInfillSpacing = (int)Math.Round(halfInfillSpacingD);
var halfThickenss = _infillThickness / 2;
int width = (int)Math.Round(4 * (halfInfillSpacing / Math.Sqrt(3)));
int width = (int)Math.Round(4 * (halfInfillSpacingD / Math.Sqrt(3)));
var infillColor = new MCvScalar(_infillBrightness);

int cols = (int)Math.Ceiling((float)targetSize.Width / _infillSpacing) + 2;
int cols = (int)Math.Ceiling(targetSize.Width / (width * 0.75f));
int rows = (int)Math.Ceiling((float)targetSize.Height / _infillSpacing);

for (int col = 0; col <= cols; col++)
Expand Down
Loading

0 comments on commit 9374705

Please sign in to comment.