@@ -80,7 +80,7 @@ public enum PhotonRleFormat
80
80
PWS ,
81
81
PW0
82
82
}
83
-
83
+
84
84
public enum AnyCubicMachine : byte
85
85
{
86
86
PhotonS ,
@@ -152,7 +152,7 @@ public class FileMark
152
152
/// <summary>
153
153
/// Spotted on version 515 only
154
154
/// </summary>
155
- [ FieldOrder ( 6 ) ] public uint LayerImageColorTableAddress { get ; set ; }
155
+ [ FieldOrder ( 6 ) ] public uint LayerImageColorTableAddress { get ; set ; }
156
156
157
157
/// <summary>
158
158
/// Gets the layer definition start address
@@ -269,7 +269,7 @@ public override string ToString()
269
269
/// <param name="lengthOffset">Offset to length</param>
270
270
/// <exception cref="FileLoadException"></exception>
271
271
public void Validate ( bool validateName , int lengthOffset = 0 ) => ValidateExpecting ( ( int ) GetFinalTableLength ( ) + lengthOffset , validateName ) ;
272
-
272
+
273
273
public void Validate ( sbyte lengthOffset ) => Validate ( true , lengthOffset ) ;
274
274
public void Validate ( byte lengthOffset ) => Validate ( true , lengthOffset ) ;
275
275
public void Validate ( ushort lengthOffset ) => Validate ( true , lengthOffset ) ;
@@ -317,12 +317,12 @@ public sealed class Header : AnycubicNamedTable
317
317
318
318
[ FieldOrder ( 4 ) ] public float WaitTimeBeforeCure { get ; set ; } = 1 ;
319
319
320
- [ FieldOrder ( 5 ) ] public float BottomExposureTime { get ; set ; }
320
+ [ FieldOrder ( 5 ) ] public float BottomExposureTime { get ; set ; }
321
321
322
322
[ FieldOrder ( 6 ) ] public float BottomLayersCount { get ; set ; }
323
323
324
324
[ FieldOrder ( 7 ) ] public float LiftHeight { get ; set ; } = DefaultLiftHeight ;
325
-
325
+
326
326
/// <summary>
327
327
/// Gets the lift speed in mm/s
328
328
/// </summary>
@@ -784,7 +784,7 @@ private unsafe Mat DecodePWS(AnycubicFile slicerFile)
784
784
785
785
span [ i ] = ( byte ) newC ;
786
786
}
787
-
787
+
788
788
return image ;
789
789
}
790
790
@@ -1065,7 +1065,7 @@ public override string ToString()
1065
1065
new ( typeof ( AnycubicFile ) , "pwc" , "Anycubic Custom Machine (PWC)" ) ,
1066
1066
//new(typeof(PhotonWorkshopFile), "pwmb", "Photon M3 Plus (PWMB)"),
1067
1067
} ;
1068
-
1068
+
1069
1069
public override SpeedUnit FormatSpeedUnit => SpeedUnit . MillimetersPerSecond ;
1070
1070
1071
1071
public override PrintParameterModifier [ ] PrintParameterModifiers
@@ -1382,8 +1382,8 @@ public override float ExposureTime
1382
1382
1383
1383
public override float BottomLiftHeight
1384
1384
{
1385
- get => FileMarkSettings . Version >= VERSION_516
1386
- ? ExtraSettings . BottomLiftHeight1
1385
+ get => FileMarkSettings . Version >= VERSION_516
1386
+ ? ExtraSettings . BottomLiftHeight1
1387
1387
: base . BottomLiftHeight ;
1388
1388
set
1389
1389
{
@@ -1405,7 +1405,7 @@ public override float BottomLiftHeight
1405
1405
public override float BottomLiftSpeed
1406
1406
{
1407
1407
get => FileMarkSettings . Version >= VERSION_516
1408
- ? SpeedConverter . Convert ( ExtraSettings . BottomLiftSpeed1 , FormatSpeedUnit , CoreSpeedUnit )
1408
+ ? SpeedConverter . Convert ( ExtraSettings . BottomLiftSpeed1 , FormatSpeedUnit , CoreSpeedUnit )
1409
1409
: base . BottomLiftSpeed ;
1410
1410
set
1411
1411
{
@@ -1417,8 +1417,8 @@ public override float BottomLiftSpeed
1417
1417
1418
1418
public override float LiftHeight
1419
1419
{
1420
- get => FileMarkSettings . Version >= VERSION_516
1421
- ? ExtraSettings . LiftHeight1
1420
+ get => FileMarkSettings . Version >= VERSION_516
1421
+ ? ExtraSettings . LiftHeight1
1422
1422
: HeaderSettings . LiftHeight ;
1423
1423
set
1424
1424
{
@@ -1440,7 +1440,7 @@ public override float LiftHeight
1440
1440
public override float LiftSpeed
1441
1441
{
1442
1442
get => SpeedConverter . Convert ( FileMarkSettings . Version >= VERSION_516
1443
- ? ExtraSettings . LiftSpeed1
1443
+ ? ExtraSettings . LiftSpeed1
1444
1444
: HeaderSettings . LiftSpeed , FormatSpeedUnit , CoreSpeedUnit ) ;
1445
1445
set
1446
1446
{
@@ -1453,7 +1453,7 @@ public override float LiftSpeed
1453
1453
public override float BottomLiftHeight2
1454
1454
{
1455
1455
get => FileMarkSettings . Version >= VERSION_516
1456
- ? ExtraSettings . BottomLiftHeight2
1456
+ ? ExtraSettings . BottomLiftHeight2
1457
1457
: 0 ;
1458
1458
set
1459
1459
{
@@ -1470,7 +1470,7 @@ public override float BottomLiftHeight2
1470
1470
public override float BottomLiftSpeed2
1471
1471
{
1472
1472
get => FileMarkSettings . Version >= VERSION_516
1473
- ? SpeedConverter . Convert ( ExtraSettings . BottomLiftSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
1473
+ ? SpeedConverter . Convert ( ExtraSettings . BottomLiftSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
1474
1474
: 0 ;
1475
1475
set
1476
1476
{
@@ -1484,7 +1484,7 @@ public override float BottomLiftSpeed2
1484
1484
public override float LiftHeight2
1485
1485
{
1486
1486
get => FileMarkSettings . Version >= VERSION_516
1487
- ? ExtraSettings . LiftHeight2
1487
+ ? ExtraSettings . LiftHeight2
1488
1488
: 0 ;
1489
1489
set
1490
1490
{
@@ -1500,8 +1500,8 @@ public override float LiftHeight2
1500
1500
1501
1501
public override float LiftSpeed2
1502
1502
{
1503
- get => FileMarkSettings . Version >= VERSION_516
1504
- ? SpeedConverter . Convert ( ExtraSettings . LiftSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
1503
+ get => FileMarkSettings . Version >= VERSION_516
1504
+ ? SpeedConverter . Convert ( ExtraSettings . LiftSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
1505
1505
: 0 ;
1506
1506
set
1507
1507
{
@@ -1514,8 +1514,8 @@ public override float LiftSpeed2
1514
1514
1515
1515
public override float BottomRetractSpeed
1516
1516
{
1517
- get => FileMarkSettings . Version >= VERSION_516
1518
- ? SpeedConverter . Convert ( ExtraSettings . BottomRetractSpeed1 , FormatSpeedUnit , CoreSpeedUnit )
1517
+ get => FileMarkSettings . Version >= VERSION_516
1518
+ ? SpeedConverter . Convert ( ExtraSettings . BottomRetractSpeed1 , FormatSpeedUnit , CoreSpeedUnit )
1519
1519
: RetractSpeed ;
1520
1520
set
1521
1521
{
@@ -1528,8 +1528,8 @@ public override float BottomRetractSpeed
1528
1528
1529
1529
public override float RetractSpeed
1530
1530
{
1531
- get => SpeedConverter . Convert ( FileMarkSettings . Version >= VERSION_516
1532
- ? ExtraSettings . RetractSpeed1
1531
+ get => SpeedConverter . Convert ( FileMarkSettings . Version >= VERSION_516
1532
+ ? ExtraSettings . RetractSpeed1
1533
1533
: HeaderSettings . RetractSpeed , FormatSpeedUnit , CoreSpeedUnit ) ;
1534
1534
set
1535
1535
{
@@ -1542,7 +1542,7 @@ public override float RetractSpeed
1542
1542
public override float BottomRetractSpeed2
1543
1543
{
1544
1544
get => FileMarkSettings . Version >= VERSION_516
1545
- ? SpeedConverter . Convert ( ExtraSettings . BottomRetractSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
1545
+ ? SpeedConverter . Convert ( ExtraSettings . BottomRetractSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
1546
1546
: 0 ;
1547
1547
set
1548
1548
{
@@ -1556,7 +1556,7 @@ public override float BottomRetractSpeed2
1556
1556
public override float RetractSpeed2
1557
1557
{
1558
1558
get => FileMarkSettings . Version >= VERSION_516
1559
- ? SpeedConverter . Convert ( ExtraSettings . RetractSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
1559
+ ? SpeedConverter . Convert ( ExtraSettings . RetractSpeed2 , FormatSpeedUnit , CoreSpeedUnit )
1560
1560
: 0 ;
1561
1561
set
1562
1562
{
@@ -1633,7 +1633,7 @@ public override string MachineName
1633
1633
}
1634
1634
set => base . MachineName = MachineSettings . MachineName = value ;
1635
1635
}
1636
-
1636
+
1637
1637
public override object [ ] Configs
1638
1638
{
1639
1639
get
@@ -1651,7 +1651,7 @@ public override object[] Configs
1651
1651
return new object [ ]
1652
1652
{
1653
1653
FileMarkSettings , HeaderSettings , PreviewSettings , LayerImageColorSettings , LayersDefinition ,
1654
- ExtraSettings , MachineSettings
1654
+ ExtraSettings , MachineSettings
1655
1655
} ;
1656
1656
case VERSION_517 :
1657
1657
return new object [ ]
@@ -1792,7 +1792,7 @@ public AnyCubicMachine PrinterModel
1792
1792
1793
1793
return AnyCubicMachine . PhotonS ;
1794
1794
}
1795
- }
1795
+ }
1796
1796
#endregion
1797
1797
1798
1798
#region Constructors
@@ -1878,16 +1878,18 @@ protected override void EncodeInternally(OperationProgress progress)
1878
1878
if ( LayerImageColorSettings . GreyMaxCount < 16 || LayerImageColorSettings . Grey . Length < 16 )
1879
1879
{
1880
1880
LayerImageColorSettings . GreyMaxCount = 16 ;
1881
- LayerImageColorSettings . Grey = new byte [ 16 ] ;
1882
1881
}
1883
-
1882
+
1884
1883
// But if the AntiAliasing is higher than 16, we adjust the table (Experimental)
1885
1884
if ( HeaderSettings . AntiAliasing > LayerImageColorSettings . GreyMaxCount || HeaderSettings . AntiAliasing > LayerImageColorSettings . Grey . Length )
1886
1885
{
1887
1886
LayerImageColorSettings . GreyMaxCount = HeaderSettings . AntiAliasing ;
1888
- LayerImageColorSettings . Grey = new byte [ HeaderSettings . AntiAliasing ] ;
1889
1887
}
1890
1888
1889
+ // Ensure the table is the correct size
1890
+ if ( LayerImageColorSettings . Grey . Length != LayerImageColorSettings . GreyMaxCount )
1891
+ LayerImageColorSettings . Grey = new byte [ LayerImageColorSettings . GreyMaxCount ] ;
1892
+
1891
1893
// Map the grey values
1892
1894
for ( var i = 0 ; i < LayerImageColorSettings . GreyMaxCount ; i ++ )
1893
1895
{
@@ -1906,7 +1908,7 @@ protected override void EncodeInternally(OperationProgress progress)
1906
1908
FileMarkSettings . LayerImageAddress = FileMarkSettings . LayerDefinitionAddress + LayersDefinition . TableLength + AnycubicNamedTable . TableBaseLength ;
1907
1909
1908
1910
outputFile . Seek ( FileMarkSettings . LayerImageAddress , SeekOrigin . Begin ) ;
1909
-
1911
+
1910
1912
if ( Version >= VERSION_516 )
1911
1913
{
1912
1914
FileMarkSettings . ExtraAddress = FileMarkSettings . LayerImageAddress ;
@@ -1984,7 +1986,7 @@ protected override void EncodeInternally(OperationProgress progress)
1984
1986
1985
1987
1986
1988
//layersHash.Add(hash, layerDef);
1987
-
1989
+
1988
1990
outputFile . WriteBytes ( layerDef . EncodedRle ) ;
1989
1991
layerDef . EncodedRle = null ! ;
1990
1992
//}
@@ -2074,7 +2076,7 @@ protected override void DecodeInternally(OperationProgress progress)
2074
2076
ExtraSettings . BottomLiftSpeed2 = HeaderSettings . LiftSpeed ;
2075
2077
ExtraSettings . BottomRetractSpeed1 = HeaderSettings . RetractSpeed ;
2076
2078
ExtraSettings . BottomRetractSpeed2 = HeaderSettings . RetractSpeed ;
2077
-
2079
+
2078
2080
ExtraSettings . LiftHeight1 = HeaderSettings . LiftHeight ;
2079
2081
ExtraSettings . LiftSpeed1 = HeaderSettings . LiftSpeed ;
2080
2082
ExtraSettings . LiftHeight2 = 0 ;
@@ -2148,9 +2150,9 @@ protected override void DecodeInternally(OperationProgress progress)
2148
2150
Debug . Write ( "LayersDefinition -> " ) ;
2149
2151
Debug . WriteLine ( LayersDefinition ) ;
2150
2152
LayersDefinition . Validate ( ) ;
2151
-
2153
+
2152
2154
Init ( LayersDefinition . LayerCount , DecodeType == FileDecodeType . Partial ) ;
2153
-
2155
+
2154
2156
progress . Reset ( OperationProgress . StatusDecodeLayers , LayerCount ) ;
2155
2157
foreach ( var batch in BatchLayersIndexes ( ) )
2156
2158
{
0 commit comments