Skip to content

Commit

Permalink
v3.13.3
Browse files Browse the repository at this point in the history
- (Add) Support for AnyCubic Photon Mono 2 (pm3n)
- (Add) PrusaSlicer printer: AnyCubic Photon Mono 2
- (Improvement) Layer compression performance for Deflate and GZip methods
- (Improvement) OSLA: Adds NonZeroPixelCount for layers and end marker (;OSLATiCo)
  • Loading branch information
sn4k3 committed May 7, 2023
1 parent 4c88995 commit fec994e
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 45 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 07/05/2023 - v3.13.3

- (Add) Support for AnyCubic Photon Mono 2 (pm3n)
- (Add) PrusaSlicer printer: AnyCubic Photon Mono 2
- (Improvement) Layer compression performance for Deflate and GZip methods
- (Improvement) OSLA: Adds NonZeroPixelCount for layers and end marker (;OSLATiCo)

## 06/05/2023 - v3.13.2

- **UVJ:**
Expand Down
42 changes: 42 additions & 0 deletions PrusaSlicer/printer/AnyCubic Photon Mono 2.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# generated by PrusaSlicer 2.5.2+win64 on 2023-05-06 at 19:20:44 UTC
absolute_correction = 0
area_fill = 50
bed_custom_model =
bed_custom_texture =
bed_shape = 0x0,143.36x0,143.36x89.6,0x89.6
default_sla_material_profile = Prusa Orange Tough 0.05
default_sla_print_profile = 0.05 Normal
display_height = 89.6
display_mirror_x = 1
display_mirror_y = 0
display_orientation = landscape
display_pixels_x = 4096
display_pixels_y = 2560
display_width = 143.36
elefant_foot_compensation = 0.2
elefant_foot_min_width = 0.2
fast_tilt_time = 5
gamma_correction = 1
high_viscosity_tilt_time = 10
host_type = octoprint
inherits = Original Prusa SL1
max_exposure_time = 120
max_initial_exposure_time = 300
max_print_height = 165
min_exposure_time = 1
min_initial_exposure_time = 1
print_host =
printer_model = SL1
printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_SL1\nPRINTER_VENDOR_ANYCUBIC\nPRINTER_MODEL_PHOTON_MONO_2\nFILEFORMAT_PM3N\n\nSTART_CUSTOM_VALUES\nWaitTimeBeforeCure_2.5\nBottomLiftHeight_6\nLiftHeight_6\nBottomLiftSpeed_150\nLiftSpeed_150\nRetractSpeed_150\nBottomLightPWM_255\nLightPWM_255\nEND_CUSTOM_VALUES
printer_settings_id =
printer_technology = SLA
printer_variant = default
printer_vendor =
printhost_apikey =
printhost_cafile =
relative_correction = 1,1
relative_correction_x = 1
relative_correction_y = 1
relative_correction_z = 1
slow_tilt_time = 8
thumbnails = 224x168
13 changes: 4 additions & 9 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
- **UVJ:**
- (Add) Properties: BottomWaitTimeBeforeCure, WaitTimeBeforeCure, BottomWaitTimeAfterCure, WaitTimeAfterCure, BottomWaitTimeAfterLift, WaitTimeAfterLift
- (Add) Vendor key to the configuration to be able to save custom key-values from other softwares (#687)
- (Add) Layers properties: `CompletionTime`, `CompletionTimeStr`, `StartTime`, `StartTimeStr`, `EndTime`, `EndTimeStr` (#698)
- (Add) PrusaSlicer printer: Creality Halot Mage and Mage Pro
- (Add) Tool - Blur: Stack blur
- (Change) Tool - Timelapse: Increase wait time from 100s to 1000s maximum
- (Change) Settings: Allow to combine start maximized with restore windows position and size (#695)
- (Fix) File formats: Parse transition layer count from layers now only take into account decreasing times related to the previous layer
- (Add) Support for AnyCubic Photon Mono 2 (pm3n)
- (Add) PrusaSlicer printer: AnyCubic Photon Mono 2
- (Improvement) Layer compression performance for Deflate and GZip methods
- (Improvement) OSLA: Adds NonZeroPixelCount for layers and end marker (;OSLATiCo)

6 changes: 5 additions & 1 deletion Scripts/010 Editor/osla.bt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
LittleEndian();

struct FILE {
char Marker[8] <fgcolor=cBlack, bgcolor=cWhite>;
char Marker[8] <fgcolor=cBlack, bgcolor=cPurple>; // OSLATiCo
ushort Version <fgcolor=cBlack, bgcolor=cWhite>;

char CreatedDateTime[20] <fgcolor=cBlack, bgcolor=cWhite>;
Expand Down Expand Up @@ -84,6 +84,7 @@ struct LAYER_DEF {
float ExposureTime <fgcolor=cBlack, bgcolor=cPurple>;
float WaitTimeAfterCure <fgcolor=cBlack, bgcolor=cPurple>;
ubyte LightPWM <fgcolor=cBlack, bgcolor=cPurple>;
uint NonZeroPixelCount <fgcolor=cBlack, bgcolor=cPurple>;
uint BoundingRectangleX <fgcolor=cBlack, bgcolor=cPurple>;
uint BoundingRectangleY <fgcolor=cBlack, bgcolor=cPurple>;
uint BoundingRectangleWidth <fgcolor=cBlack, bgcolor=cPurple>;
Expand Down Expand Up @@ -137,3 +138,6 @@ if(header.GCodeAddress > 0)
GCODE gcode;
}


FSeek(FileSize() - 9);
char EndMarker[9] <fgcolor=cBlack, bgcolor=cPurple>; // ;OSLATiCo
12 changes: 12 additions & 0 deletions UVtools.Core/Extensions/CompressionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public static MemoryStream GZipCompress(Stream inputStream, CompressionLevel com
public static MemoryStream GZipCompress(byte[] inputStream, CompressionLevel compressionLevel) =>
GZipCompress(new ReadOnlyMemory<byte>(inputStream).AsStream(), compressionLevel);

public static byte[] GZipCompressToBytes(Stream inputStream, CompressionLevel compressionLevel)
{
using var ms = GZipCompress(inputStream, compressionLevel);
return ms.ToArray();
}

public static byte[] GZipCompressToBytes(byte[] inputStream, CompressionLevel compressionLevel)
{
using var ms = GZipCompress(new ReadOnlyMemory<byte>(inputStream).AsStream(), compressionLevel);
Expand Down Expand Up @@ -99,6 +105,12 @@ public static MemoryStream DeflateCompress(Stream inputStream, CompressionLevel
public static MemoryStream DeflateCompress(byte[] inputStream, CompressionLevel compressionLevel) =>
DeflateCompress(new ReadOnlyMemory<byte>(inputStream).AsStream(), compressionLevel);

public static byte[] DeflateCompressToBytes(Stream inputStream, CompressionLevel compressionLevel)
{
using var ms = DeflateCompress(inputStream, compressionLevel);
return ms.ToArray();
}

public static byte[] DeflateCompressToBytes(byte[] inputStream, CompressionLevel compressionLevel)
{
using var ms = DeflateCompress(new ReadOnlyMemory<byte>(inputStream).AsStream(), compressionLevel);
Expand Down
28 changes: 22 additions & 6 deletions UVtools.Core/FileFormats/OSLAFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

using BinarySerialization;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
Expand Down Expand Up @@ -96,14 +97,14 @@ public class Header
[FieldOrder(11)] public float LayerHeight { get; set; } = 0.05f;
[FieldOrder(12)] public ushort BottomLayersCount { get; set; } = 4;
[FieldOrder(13)] public uint LayerCount { get; set; }
[FieldOrder(14)] public uint LayerTableSize { get; set; } = 69;
[FieldOrder(14)] public uint LayerTableSize { get; set; } = (uint)Helpers.Serializer.SizeOf(new LayerDef()) + 4; // 73
[FieldOrder(15)] public uint LayerDefinitionsAddress { get; set; }
[FieldOrder(16)] public uint GCodeAddress { get; set; }
[FieldOrder(17)] public uint PrintTime { get; set; }
[FieldOrder(18)] public float MaterialMilliliters { get; set; }
[FieldOrder(19)] public float MaterialCost { get; set; }
[FieldOrder(20)] [FieldLength(50)] [SerializeAs(SerializedType.TerminatedString)] public string? MaterialName { get; set; } = string.Empty;
[FieldOrder(21)] [FieldLength(50)] [SerializeAs(SerializedType.TerminatedString)] public string MachineName { get; set; } = "Unknown";
[FieldOrder(21)] [FieldLength(50)] [SerializeAs(SerializedType.TerminatedString)] public string MachineName { get; set; } = DefaultMachineName;


public override string ToString()
Expand Down Expand Up @@ -175,10 +176,11 @@ public class LayerDef
[FieldOrder(11)] public float ExposureTime { get; set; }
[FieldOrder(12)] public float WaitTimeAfterCure { get; set; }
[FieldOrder(13)] public byte LightPWM { get; set; }
[FieldOrder(14)] public uint BoundingRectangleX { get; set; }
[FieldOrder(15)] public uint BoundingRectangleY { get; set; }
[FieldOrder(16)] public uint BoundingRectangleWidth { get; set; }
[FieldOrder(17)] public uint BoundingRectangleHeight { get; set; }
[FieldOrder(14)] public uint NonZeroPixelCount { get; set; }
[FieldOrder(15)] public uint BoundingRectangleX { get; set; }
[FieldOrder(16)] public uint BoundingRectangleY { get; set; }
[FieldOrder(17)] public uint BoundingRectangleWidth { get; set; }
[FieldOrder(18)] public uint BoundingRectangleHeight { get; set; }

//[Ignore] public byte[] ImageData { get; set; }

Expand All @@ -201,6 +203,7 @@ public LayerDef(Layer layer)
ExposureTime = layer.ExposureTime;
WaitTimeAfterCure = layer.WaitTimeAfterCure;
LightPWM = layer.LightPWM;
NonZeroPixelCount = layer.NonZeroPixelCount;
BoundingRectangleX = (uint)layer.BoundingRectangle.X;
BoundingRectangleY = (uint)layer.BoundingRectangle.Y;
BoundingRectangleWidth = (uint)layer.BoundingRectangle.Width;
Expand Down Expand Up @@ -565,6 +568,8 @@ protected override void EncodeInternally(OperationProgress progress)
gcodeSettings.GCodeSize = (uint)(gcodeSettings.GCodeText?.Length ?? 0);
outputFile.WriteSerialize(gcodeSettings);

outputFile.WriteString($";{MARKER}");

outputFile.Seek(fileDefSize, SeekOrigin.Begin);
outputFile.WriteSerialize(HeaderSettings);

Expand All @@ -577,11 +582,21 @@ protected override void EncodeInternally(OperationProgress progress)
protected override void DecodeInternally(OperationProgress progress)
{
using var inputFile = new FileStream(FileFullPath!, FileMode.Open, FileAccess.Read);

FileSettings = Helpers.Deserialize<FileDef>(inputFile);
Debug.Write("File -> ");
Debug.WriteLine(FileSettings);
FileSettings.Validate();

inputFile.SeekDoWorkAndRewind(-9, SeekOrigin.End, () =>
{
string result = System.Text.Encoding.ASCII.GetString(inputFile.ReadBytes(9));
if (!string.Equals(result, ";OSLATiCo", StringComparison.Ordinal))
{
throw new FileLoadException($"Invalid end marker: {result}, not a valid OSLA file or it's incomplete.");
}
});

HeaderSettings = Helpers.Deserialize<Header>(inputFile);
Debug.Write("Header -> ");
Debug.WriteLine(HeaderSettings);
Expand Down Expand Up @@ -712,6 +727,7 @@ protected override void PartialSaveInternally(OperationProgress progress)
var gcodeSettings = new GCodeDef { GCodeText = GCodeStr };
gcodeSettings.GCodeSize = (uint)(gcodeSettings.GCodeText?.Length ?? 0);
outputFile.WriteSerialize(gcodeSettings);
outputFile.WriteString($";{MARKER}");
}
}
#endregion
Expand Down
31 changes: 20 additions & 11 deletions UVtools.Core/FileFormats/PhotonWorkshopFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public enum AnyCubicMachine : byte
PhotonUltra,
PhotonD2,
PhotonMono,
PhotonMono2,
PhotonMonoSE,
PhotonMono4K,
PhotonMonoX,
Expand Down Expand Up @@ -1001,7 +1002,6 @@ public void Validate()
}
#endregion



#endregion

Expand Down Expand Up @@ -1037,6 +1037,7 @@ public void Validate()
new(typeof(PhotonWorkshopFile), "pmx2", "Photon Mono X2 (PMX2)"),
new(typeof(PhotonWorkshopFile), "pwmb", "Photon Mono X 6K / Photon M3 Plus (PWMB)"),
new(typeof(PhotonWorkshopFile), "pwmo", "Photon Mono (PWMO)"),
new(typeof(PhotonWorkshopFile), "pm3n", "Photon Mono 2 (PM3N)"),
new(typeof(PhotonWorkshopFile), "pwms", "Photon Mono SE (PWMS)"),
new(typeof(PhotonWorkshopFile), "pwma", "Photon Mono 4K (PWMA)"),
new(typeof(PhotonWorkshopFile), "pmsq", "Photon Mono SQ (PMSQ)"),
Expand All @@ -1046,7 +1047,7 @@ public void Validate()
new(typeof(PhotonWorkshopFile), "pwc", "Anycubic Custom Machine (PWC)"),
//new(typeof(PhotonWorkshopFile), "pwmb", "Photon M3 Plus (PWMB)"),
};

public override SpeedUnit FormatSpeedUnit => SpeedUnit.MillimetersPerSecond;

public override PrintParameterModifier[]? PrintParameterModifiers
Expand Down Expand Up @@ -1140,6 +1141,8 @@ public override uint[] GetAvailableVersionsForExtension(string? extension)
case "pmx2":
case "pm3r":
return new uint[] { VERSION_515, VERSION_516, VERSION_517 };
case "pm3n":
return new uint[] { VERSION_517 };
default:
return AvailableVersions;
}
Expand Down Expand Up @@ -1182,6 +1185,7 @@ public override float DisplayWidth
AnyCubicMachine.PhotonUltra => 102.40f,
AnyCubicMachine.PhotonD2 => 130.56f,
AnyCubicMachine.PhotonMono => 82.62f,
AnyCubicMachine.PhotonMono2 => 143.36f,
AnyCubicMachine.PhotonMonoSE => 82.62f,
AnyCubicMachine.PhotonMono4K => 134.40f,
AnyCubicMachine.PhotonMonoX => 192,
Expand Down Expand Up @@ -1209,6 +1213,7 @@ public override float DisplayHeight
AnyCubicMachine.PhotonUltra => 57.60f,
AnyCubicMachine.PhotonD2 => 73.44f,
AnyCubicMachine.PhotonMono => 130.56f,
AnyCubicMachine.PhotonMono2 => 89.60f,
AnyCubicMachine.PhotonMonoSE => 130.56f,
AnyCubicMachine.PhotonMono4K => 84,
AnyCubicMachine.PhotonMonoX => 120,
Expand Down Expand Up @@ -1237,6 +1242,7 @@ public override float MachineZ
AnyCubicMachine.PhotonUltra => 165,
AnyCubicMachine.PhotonD2 => 165,
AnyCubicMachine.PhotonMono => 165,
AnyCubicMachine.PhotonMono2 => 165,
AnyCubicMachine.PhotonMonoSE => 160,
AnyCubicMachine.PhotonMono4K => 165,
AnyCubicMachine.PhotonMonoX => 245,
Expand Down Expand Up @@ -1530,6 +1536,7 @@ public override string MachineName
AnyCubicMachine.PhotonUltra => "Photon Ultra",
AnyCubicMachine.PhotonD2 => "Photon D2",
AnyCubicMachine.PhotonMono => "Photon Mono",
AnyCubicMachine.PhotonMono2 => "Photon Mono 2",
AnyCubicMachine.PhotonMonoSE => "Photon Mono SE",
AnyCubicMachine.PhotonMono4K => "Photon Mono 4K",
AnyCubicMachine.PhotonMonoX => "Photon Mono X",
Expand Down Expand Up @@ -1587,6 +1594,11 @@ public AnyCubicMachine PrinterModel
return AnyCubicMachine.PhotonMono;
}

if (FileEndsWith(".pm3n"))
{
return AnyCubicMachine.PhotonMono2;
}

if (FileEndsWith(".pwms"))
{
return AnyCubicMachine.PhotonMonoSE;
Expand Down Expand Up @@ -1673,16 +1685,12 @@ protected override void EncodeInternally(OperationProgress progress)
FileMarkSettings.HeaderAddress = (uint) Helpers.Serializer.SizeOf(FileMarkSettings);
using var outputFile = new FileStream(TemporaryOutputFileFullPath, FileMode.Create, FileAccess.Write);


if (FileMarkSettings.Version >= VERSION_517)
{
HeaderSettings.Section.Length = 92;
}
else if (FileMarkSettings.Version >= VERSION_516)
HeaderSettings.Section.Length = FileMarkSettings.Version switch
{
HeaderSettings.Section.Length = 84;
}

>= VERSION_517 => 92,
>= VERSION_516 => 84,
_ => HeaderSettings.Section.Length
};

outputFile.Seek((int)FileMarkSettings.HeaderAddress, SeekOrigin.Begin);
outputFile.WriteSerialize(HeaderSettings);
Expand Down Expand Up @@ -2043,6 +2051,7 @@ protected override void OnBeforeEncode(bool isPartialEncode)
AnyCubicMachine.PhotonUltra => VERSION_515,
AnyCubicMachine.PhotonD2 => VERSION_516,
AnyCubicMachine.PhotonMono => VERSION_515,
AnyCubicMachine.PhotonMono2 => VERSION_517,
AnyCubicMachine.PhotonMonoSE => VERSION_515,
AnyCubicMachine.PhotonMono4K => VERSION_516,
AnyCubicMachine.PhotonMonoX => VERSION_516,
Expand Down
13 changes: 2 additions & 11 deletions UVtools.Core/Layers/Layer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1982,20 +1982,11 @@ public static byte[] CompressMat(Mat mat, LayerCompressionCodec codec)
}
case LayerCompressionCodec.GZip:
{
return CompressionExtensions.GZipCompressToBytes(mat.GetBytes(), CompressionLevel.Fastest);
/*using var compressedStream = new MemoryStream();
using var matStream = mat.GetUnmanagedMemoryStream(FileAccess.Read);
using var gzipStream = new GZipStream(compressedStream, CompressionLevel.Fastest);
matStream.CopyTo(gzipStream);
return compressedStream.ToArray();*/
return CompressionExtensions.GZipCompressToBytes(mat.GetUnmanagedMemoryStream(FileAccess.Read), CompressionLevel.Fastest);
}
case LayerCompressionCodec.Deflate:
{
return CompressionExtensions.DeflateCompressToBytes(mat.GetBytes(), CompressionLevel.Fastest);
/*using var compressedStream = new MemoryStream();
using var deflateStream = new DeflateStream(compressedStream, CompressionLevel.Fastest);
deflateStream.Write(mat.GetDataByteSpan());
return compressedStream.ToArray();*/
return CompressionExtensions.DeflateCompressToBytes(mat.GetUnmanagedMemoryStream(FileAccess.Read), CompressionLevel.Fastest);
}
/*case LayerCompressionMethod.None:
return mat.GetBytes();*/
Expand Down
1 change: 1 addition & 0 deletions UVtools.Core/Printer/Machine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ public Machine Clone()
new(PrinterBrand.AnyCubic, "AnyCubic Photon Mono X", "Photon Mono X", 3840, 2400, 192f, 120f, 245f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon Mono X2", "Photon Mono X2", 4096, 2560, 196.61f, 122.88f, 260f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon Mono", "Photon Mono", 1620, 2560, 82.62f, 130.56f, 165f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon Mono 2", "Photon Mono 2", 4096, 2560, 143.36f, 89.60f, 165f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon S", "Photon S", 1440, 2560, 68.04f, 120.96f, 165f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon Ultra", "Photon Ultra", 1280, 720, 102.4f, 57.6f, 165f, FlipDirection.Horizontally),
new(PrinterBrand.AnyCubic, "AnyCubic Photon D2", "Photon D2", 2560, 1440, 130.56f, 73.44f, 165f, FlipDirection.Horizontally),
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, calibration, repair, conversion and manipulation</Description>
<Version>3.13.2</Version>
<Version>3.13.3</Version>
<Copyright>Copyright © 2020 PTRTECH</Copyright>
<PackageIcon>UVtools.png</PackageIcon>
<Platforms>AnyCPU;x64</Platforms>
Expand Down
Loading

0 comments on commit fec994e

Please sign in to comment.