Skip to content

Commit

Permalink
v3.9.3
Browse files Browse the repository at this point in the history
- **Issues:**
  - (Fix) Resin traps and suction cups area sum, was losing precision due uint cast (#621)
  - (Fix) Overhang area was incorrectly showing bounding rectangle area instead it real area
- (Fix) OSF: Unable to open certain files when using anti-aliasing
- (Upgrade) .NET from 6.0.11 to 6.0.12
  • Loading branch information
sn4k3 committed Dec 14, 2022
1 parent 439e0d1 commit 925808e
Show file tree
Hide file tree
Showing 14 changed files with 512 additions and 49 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/2022 - v3.9.3

- **Issues:**
- (Fix) Resin traps and suction cups area sum, was losing precision due uint cast (#621)
- (Fix) Overhang area was incorrectly showing bounding rectangle area instead it real area
- (Fix) OSF: Unable to open certain files when using anti-aliasing
- (Upgrade) .NET from 6.0.11 to 6.0.12

## 11/12/2022 - v3.9.2

- **Dynamic lifts:**
Expand Down
3 changes: 2 additions & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@
- Ajilus
- James F Hammond
- Steven Woodward
- Piotr Czerkasow
- Piotr Czerkasow
- Kevin Bullmann
10 changes: 5 additions & 5 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- **Dynamic lifts:**
- (Improvement) Remove the 'light-off delay' set logic as it is now better integrated on 'Wait time before cure' suggestion and should run/applied there if intended
- (Fix) Prevent set NaN values to lift height and/or speed
- (Fix) Lift height and speed for the current layer must be calculated from previous layer (#618)
- (Improvement) Windows auto-updater will install the update without dialogs, just displaying installation progress
- **Issues:**
- (Fix) Resin traps and suction cups area sum, was losing precision due uint cast (#621)
- (Fix) Overhang area was incorrectly showing bounding rectangle area instead it real area
- (Fix) OSF: Unable to open certain files when using anti-aliasing
- (Upgrade) .NET from 6.0.11 to 6.0.12

48 changes: 41 additions & 7 deletions Scripts/010 Editor/osf.bt
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,51 @@ struct LAYER_DEF {
local long currentPos = FTell();
local long rleSize = 0;

while(!FEof())
if (NumberOfPixels > 0)
{
if(ReadByte() == 0x0D && (ReadByte(FTell()+1) == 0x0A || ReadByte(FTell()+1) == 0x0B))
local byte buffer;
local byte slen;
while(!FEof())
{
break;
buffer = ReadByte();
if ((buffer & 0x01) == 0x01) // It's a run
{
FSkip(1);
slen = ReadByte();
if (buffer == 0x0D && (slen == 0x0A || slen == 0x0B))
{
break;
}

FSkip(1);
rleSize += 2;

if ((slen & 0x80) == 0) {}
else if ((slen & 0xc0) == 0x80)
{
rleSize++;
FSkip(1);
}
else if ((slen & 0xe0) == 0xc0)
{
rleSize += 2;
FSkip(2);
}
else if ((slen & 0xf0) == 0xe0)
{
rleSize += 3;
FSkip(3);
}
}
else
{
rleSize++;
FSkip(1);
}
}
rleSize++;
FSkip(1);
FSeek(currentPos);
ubyte RLE[rleSize] <fgcolor=cBlack, bgcolor=cWhite>;
}
FSeek(currentPos);
ubyte RLE[rleSize] <fgcolor=cBlack, bgcolor=cWhite>;
};


Expand Down
13 changes: 13 additions & 0 deletions UVtools.Core/FileFormats/FileFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5189,6 +5189,19 @@ public uint MillimetersToPixels(float millimeters, uint fallbackToPixels = 0)
return (uint)(ppmm * millimeters);
}

/// <summary>
/// Converts millimeters to pixels given the current resolution and display size
/// </summary>
/// <param name="millimeters">Millimeters to convert</param>
/// <param name="fallbackToPixels">Fallback to this value in pixels if no ratio is available to make the convertion</param>
/// <returns>Pixels</returns>
public float MillimetersToPixelsF(float millimeters, uint fallbackToPixels = 0)
{
var ppmm = PpmmMax;
if (ppmm <= 0) return fallbackToPixels;
return ppmm * millimeters;
}

/// <summary>
/// From a pixel position get the equivalent position on the display
/// </summary>
Expand Down
62 changes: 38 additions & 24 deletions UVtools.Core/FileFormats/OSFFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
*/

using BinarySerialization;
using Emgu.CV;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Threading.Tasks;
using Emgu.CV;
using UVtools.Core.Extensions;
using UVtools.Core.Layers;
using UVtools.Core.Objects;
Expand Down Expand Up @@ -250,6 +250,7 @@ void AddRep()
internal Mat DecodeImage(OSFFile parent)
{
var mat = parent.CreateMat();
if (NumberOfPixels == 0) return mat;

int pixel = (int)(StartY * parent.ResolutionX);
for (var n = 0; n < EncodedRle.Length; n++)
Expand All @@ -260,9 +261,7 @@ internal Mat DecodeImage(OSFFile parent)
if ((code & 0x01) == 0x01) // It's a run
{
code &= 0xfe; // Get the grey value
n++;

var slen = EncodedRle[n];
var slen = EncodedRle[++n];

if ((slen & 0x80) == 0)
{
Expand Down Expand Up @@ -785,9 +784,9 @@ protected override void DecodeInternally(OperationProgress progress)
{
inputFile.Seek(Header.HeaderLength, SeekOrigin.Begin);
var layerDef = new OSFLayerDef[LayerCount];
int buffer;
var rle = new List<byte>();
progress.Reset(OperationProgress.StatusDecodeLayers, LayerCount);

foreach (var batch in BatchLayersIndexes())
{
foreach (var layerIndex in batch)
Expand All @@ -796,33 +795,48 @@ protected override void DecodeInternally(OperationProgress progress)

//Debug.WriteLine($"{layerIndex}: {inputFile.Position}");
layerDef[layerIndex] = Helpers.Deserialize<OSFLayerDef>(inputFile);
if (layerDef[layerIndex].NumberOfPixels == 0) continue;

int buffer;
int slen;
while ((buffer = inputFile.ReadByte()) > -1)
{
if (buffer != 0x0D) // Not what we want, add and continue
if ((buffer & 0x01) == 0x01) // It's a run
{
slen = inputFile.ReadByte();
if (buffer == 0x0D && slen is 0x0A or 0x0B)
{
inputFile.Seek(-2, SeekOrigin.Current);
break;
}

rle.Add((byte)buffer);
continue;
}

// Check next byte for 0x0A or 0x0B
buffer = inputFile.ReadByte();
if (buffer is 0x0A or 0x0B)
{
inputFile.Seek(-2, SeekOrigin.Current);
break;
rle.Add((byte)slen);

if ((slen & 0x80) == 0)
{
}
else if ((slen & 0xc0) == 0x80)
{
rle.Add((byte)inputFile.ReadByte());
}
else if ((slen & 0xe0) == 0xc0)
{
rle.AddRange(inputFile.ReadBytes(2));
}
else if ((slen & 0xf0) == 0xe0)
{
rle.AddRange(inputFile.ReadBytes(3));
}
else
{
throw new FileLoadException("Corrupted RLE data");
}
}

rle.Add(0x0D); // Add previous byte

if (buffer == -1) break; // End of file
if (buffer == 0x0D) // 0x0D pair, rewind 1 and recheck
else
{
inputFile.Seek(-1, SeekOrigin.Current);
continue;
rle.Add((byte)buffer);
}

rle.Add((byte)buffer);
}

layerDef[layerIndex].EncodedRle = rle.ToArray();
Expand Down
11 changes: 8 additions & 3 deletions UVtools.Core/Layers/MainIssue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,20 @@ public MainIssue(IssueType type, Issue issue) : this(type, issue.BoundingRectang
Childs = new[] { issue };
issue.Parent = this;
PixelCount = issue.PixelsCount;
if (issue is IssueOfPoints) Area = issue.PixelsCount;
Area = issue switch
{
IssueOfPoints => issue.PixelsCount,
IssueOfContours => issue.Area,
_ => issue.Area
};
}

public MainIssue(IssueType type, IEnumerable<Issue> issues) : this(type)
{
foreach (var issue in issues)
{
issue.Parent = this;
var layerHeightInPixels = issue.Layer.SlicerFile.MillimetersToPixels(issue.Layer.LayerHeight, 20);
var layerHeightInPixels = issue.Layer.SlicerFile.MillimetersToPixelsF(issue.Layer.LayerHeight, 20);
Area += issue.Area * layerHeightInPixels;
PixelCount += issue.PixelsCount;
if (issue.BoundingRectangle.IsEmpty) continue;
Expand All @@ -154,7 +159,7 @@ public MainIssue(IssueType type, IEnumerable<Issue> issues) : this(type)
Childs = issues.OrderBy(issue => issue.LayerIndex).ToArray();
}

Area = Math.Floor(Area);
Area = Math.Round(Area, 3);
}

private void Sort()
Expand Down
4 changes: 2 additions & 2 deletions 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.9.2</Version>
<Version>3.9.3</Version>
<Copyright>Copyright © 2020 PTRTECH</Copyright>
<PackageIcon>UVtools.png</PackageIcon>
<Platforms>AnyCPU;x64</Platforms>
Expand Down Expand Up @@ -84,7 +84,7 @@
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.7.0" />
<PackageReference Include="System.Text.Json" Version="7.0.0" />
<PackageReference Include="System.Text.Json" Version="7.0.1" />
</ItemGroup>

<Target Name="PreparePackageReleaseNotesFromFile" BeforeTargets="GenerateNuspec">
Expand Down
6 changes: 3 additions & 3 deletions UVtools.Installer/Code/HeatGeneratedFileList.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@
<Component Id="cmpE35DDB3C925C83E74C7DAAE6FEA6C156" Guid="*">
<File Id="filEAEAE1CB9E8AC1FF00B05453ABEE2ADF" KeyPath="yes" Source="$(var.HarvestPath)\mscordaccore.dll" />
</Component>
<Component Id="cmp7FE735164884E23E3A78C7D52A84A02E" Guid="*">
<File Id="filF23EC789015B97CDD2EEC3398CD076F0" KeyPath="yes" Source="$(var.HarvestPath)\mscordaccore_amd64_amd64_6.0.1122.52304.dll" />
<Component Id="cmpA66BC8DD06BB1F7AEF2D6D0D9EB2A8B9" Guid="*">
<File Id="fil051ED3A46FEDD778FE2907C8B9387712" KeyPath="yes" Source="$(var.HarvestPath)\mscordaccore_amd64_amd64_6.0.1222.56807.dll" />
</Component>
<Component Id="cmpA5ABEAD31F33B1E5825EC6F159ABFB0F" Guid="*">
<File Id="fil1A6B0EBD5A5BF8DD0582A2665D3492F1" KeyPath="yes" Source="$(var.HarvestPath)\mscordbi.dll" />
Expand Down Expand Up @@ -1687,7 +1687,7 @@
<ComponentRef Id="cmp3E4F3E4686A9B425B5812E5171CCDEEF" />
<ComponentRef Id="cmp16861E24C897764CA922EC062BA74EC9" />
<ComponentRef Id="cmpE35DDB3C925C83E74C7DAAE6FEA6C156" />
<ComponentRef Id="cmp7FE735164884E23E3A78C7D52A84A02E" />
<ComponentRef Id="cmpA66BC8DD06BB1F7AEF2D6D0D9EB2A8B9" />
<ComponentRef Id="cmpA5ABEAD31F33B1E5825EC6F159ABFB0F" />
<ComponentRef Id="cmp5D6845991403E371A015DF7EBDF71F13" />
<ComponentRef Id="cmp57B8361D25AD503DC733F4039E5A38B0" />
Expand Down
Loading

0 comments on commit 925808e

Please sign in to comment.