mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-12 11:32:33 +02:00
097bbb867d
* **PrusaSlicer:**
* **In this release is recommended to discard your printer and refresh it with uvtools updated printer or replace notes over**
* (Add) FILEFORMAT_XXX variable to auto-convert to that file format once open in UVtools
* (Update) Print profiles fields with new PrusaSlicer version
* (Remove) LayerOffDelay from printer notes and use only the LightOffDelay variable instead, both were being used, to avoid redundacy LayerOffDelay was dropped. Please update your printer accordingly!
* (Remove) FLIP_XY compability from printers
* (Remove) AntiAlias variable from printers
* **(Add) Settings - Automations:**
* Auto save the file after apply any automation(s)
* Auto convert SL1 files to the target format when possible and load it back
* Auto set the extra 'light-off delay' based on lift height and speed.
* (Add) Allow all and future formats to convert between them without knowing each other (Abstraction)
* (Add) XYResolution and XYResolutionUm property to file formats
* (Add) Calculator - Optimal model tilt: Calculates the optimal model tilt angle for printing and to minimize the visual layer effect
* (Add) Bottom layer count to the status bar
* **(Add) FileFormat propertiers:**
* MirrorDisplay: If images need to be mirrored on lcd to print on the correct orientation (If available)
* MaxPrintHeight: The maximum Z build volume of the printer (If available)
* (Add) ZCodex: Print paramenter light-off delay"
* (Add) SL1: Implement missing keys: host_type, physical_printer_settings_id and support_small_pillar_diameter_percent
* (Change) File formats: Round all setters floats to 2 decimals
* (Change) Island Repair: "Remove Islands Below Equal Pixels" limit from 255 to 65535 (#124)
* (Change) LightOffTime variables to LayerOffDelay
* (Fix) Files with upper case extensions doesn't load in
* **(Fix) SL1:**
* Prevent error when bottle volume is 0
* bool values were incorrectly parsed
* (Fix) **ZIP:**
* Material volume was set to grams
* Bed Y was not being set
247 lines
7.8 KiB
C#
247 lines
7.8 KiB
C#
/*
|
|
* 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.
|
|
*/
|
|
|
|
// https://github.com/cbiffle/catibo/blob/master/doc/cbddlp-ctb.adoc
|
|
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using BinarySerialization;
|
|
using UVtools.Core.Operations;
|
|
|
|
namespace UVtools.Core.FileFormats
|
|
{
|
|
public class MakerbaseFile : FileFormat
|
|
{
|
|
#region Constants
|
|
private const uint MAGIC_CBDDLP = 0x12FD0019;
|
|
private const uint MAGIC_CBT = 0x12FD0086;
|
|
private const ushort REPEATRGB15MASK = 0x20;
|
|
|
|
private const byte RLE8EncodingLimit = 0x7d; // 125;
|
|
private const ushort RLE16EncodingLimit = 0xFFF;
|
|
#endregion
|
|
|
|
#region Sub Classes
|
|
|
|
#region Header
|
|
public class Header
|
|
{
|
|
public const string TagValue = "MKSDLP";
|
|
//[FieldOrder(0)] public uint Offset1 { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets the file tag = MKSDLP
|
|
/// </summary>
|
|
[FieldOrder(0)] [FieldOffset(4)] [FieldLength(6)] public string Tag { get; set; } = TagValue;
|
|
[FieldOrder(1)] [FieldOffset(1)] public ushort MaxSize { get; set; }
|
|
[FieldOrder(2)] public ushort ResolutionX { get; set; }
|
|
[FieldOrder(3)] public ushort ResolutionY { get; set; }
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
public Header HeaderSettings { get; protected internal set; } = new Header();
|
|
private int temp = 0;
|
|
public override FileFormatType FileType => FileFormatType.Binary;
|
|
|
|
public override FileExtension[] FileExtensions { get; } = {
|
|
new FileExtension("mdlp", "Makerbase MDLP Files"),
|
|
new FileExtension("gr1", "GR1 Workshop GR1 Files"),
|
|
};
|
|
|
|
public override PrintParameterModifier[] PrintParameterModifiers { get; } =
|
|
{
|
|
PrintParameterModifier.BottomLayerCount,
|
|
PrintParameterModifier.BottomExposureSeconds,
|
|
PrintParameterModifier.ExposureSeconds,
|
|
|
|
PrintParameterModifier.BottomLightOffDelay,
|
|
PrintParameterModifier.LightOffDelay,
|
|
PrintParameterModifier.BottomLiftHeight,
|
|
PrintParameterModifier.BottomLiftSpeed,
|
|
PrintParameterModifier.LiftHeight,
|
|
PrintParameterModifier.LiftSpeed,
|
|
PrintParameterModifier.RetractSpeed,
|
|
|
|
PrintParameterModifier.BottomLightPWM,
|
|
PrintParameterModifier.LightPWM,
|
|
};
|
|
|
|
public override byte ThumbnailsCount { get; } = 0;
|
|
|
|
public override Size[] ThumbnailsOriginalSize { get; } = {new Size(400, 300), new Size(200, 125)};
|
|
|
|
public override uint ResolutionX
|
|
{
|
|
get => 0;
|
|
set => temp = 0;
|
|
}
|
|
|
|
public override uint ResolutionY
|
|
{
|
|
get => 0;
|
|
set => temp = 0;
|
|
}
|
|
|
|
public override float DisplayWidth { get; set; }
|
|
public override float DisplayHeight { get; set; }
|
|
public override bool MirrorDisplay { get; set; }
|
|
|
|
public override byte AntiAliasing
|
|
{
|
|
get => 1;
|
|
set { }
|
|
}
|
|
|
|
public override float LayerHeight
|
|
{
|
|
get => 0;
|
|
set => temp = 0;
|
|
}
|
|
|
|
public override uint LayerCount
|
|
{
|
|
set
|
|
{
|
|
temp = 0;
|
|
/*HeaderSettings.LayerCount = LayerCount;
|
|
HeaderSettings.OverallHeightMilimeter = TotalHeight;*/
|
|
}
|
|
}
|
|
|
|
public override ushort BottomLayerCount => 0;
|
|
|
|
public override float BottomExposureTime => 0;
|
|
|
|
public override float ExposureTime => 0;
|
|
public override float LiftHeight => 0;
|
|
public override float LiftSpeed => 0;
|
|
public override float RetractSpeed => 0;
|
|
|
|
public override float PrintTime => 0;
|
|
|
|
public override float MaterialMilliliters => 0;
|
|
|
|
public override float MaterialCost => 0;
|
|
|
|
public override string MaterialName => "Unknown";
|
|
public override string MachineName => null;
|
|
|
|
public override object[] Configs => new[] { (object)HeaderSettings };
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
public MakerbaseFile()
|
|
{
|
|
}
|
|
#endregion
|
|
|
|
#region Methods
|
|
public override void Encode(string fileFullPath, OperationProgress progress = null)
|
|
{
|
|
base.Encode(fileFullPath, progress);
|
|
|
|
uint currentOffset = (uint)Helpers.Serializer.SizeOf(HeaderSettings);
|
|
using (var outputFile = new FileStream(fileFullPath, FileMode.Create, FileAccess.Write))
|
|
{
|
|
|
|
outputFile.Seek((int) currentOffset, SeekOrigin.Begin);
|
|
|
|
|
|
|
|
}
|
|
|
|
AfterEncode();
|
|
|
|
Debug.WriteLine("Encode Results:");
|
|
Debug.WriteLine(HeaderSettings);
|
|
Debug.WriteLine("-End-");
|
|
}
|
|
|
|
|
|
|
|
public override void Decode(string fileFullPath, OperationProgress progress = null)
|
|
{
|
|
base.Decode(fileFullPath, progress);
|
|
|
|
using (var inputFile = new FileStream(fileFullPath, FileMode.Open, FileAccess.Read))
|
|
{
|
|
//HeaderSettings = Helpers.ByteToType<CbddlpFile.Header>(InputFile);
|
|
//HeaderSettings = Helpers.Serializer.Deserialize<Header>(InputFile.ReadBytes(Helpers.Serializer.SizeOf(typeof(Header))));
|
|
HeaderSettings = Helpers.Deserialize<Header>(inputFile);
|
|
if (HeaderSettings.Tag != Header.TagValue)
|
|
{
|
|
throw new FileLoadException("Not a valid Makerfile file!", fileFullPath);
|
|
}
|
|
|
|
|
|
FileFullPath = fileFullPath;
|
|
|
|
}
|
|
|
|
progress.Token.ThrowIfCancellationRequested();
|
|
}
|
|
|
|
public override void SaveAs(string filePath = null, OperationProgress progress = null)
|
|
{
|
|
if (RequireFullEncode)
|
|
{
|
|
if (!string.IsNullOrEmpty(filePath))
|
|
{
|
|
FileFullPath = filePath;
|
|
}
|
|
Encode(FileFullPath, progress);
|
|
return;
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(filePath))
|
|
{
|
|
File.Copy(FileFullPath, filePath, true);
|
|
FileFullPath = filePath;
|
|
}
|
|
|
|
/*using (var outputFile = new FileStream(FileFullPath, FileMode.Open, FileAccess.Write))
|
|
{
|
|
|
|
outputFile.Seek(0, SeekOrigin.Begin);
|
|
Helpers.SerializeWriteFileStream(outputFile, HeaderSettings);
|
|
|
|
if (HeaderSettings.Version >= 2 && HeaderSettings.PrintParametersOffsetAddress > 0)
|
|
{
|
|
outputFile.Seek(HeaderSettings.PrintParametersOffsetAddress, SeekOrigin.Begin);
|
|
Helpers.SerializeWriteFileStream(outputFile, PrintParametersSettings);
|
|
Helpers.SerializeWriteFileStream(outputFile, SlicerInfoSettings);
|
|
}
|
|
|
|
uint layerOffset = HeaderSettings.LayersDefinitionOffsetAddress;
|
|
for (byte aaIndex = 0; aaIndex < HeaderSettings.AntiAliasLevel; aaIndex++)
|
|
{
|
|
for (uint layerIndex = 0; layerIndex < HeaderSettings.LayerCount; layerIndex++)
|
|
{
|
|
outputFile.Seek(layerOffset, SeekOrigin.Begin);
|
|
layerOffset += Helpers.SerializeWriteFileStream(outputFile, LayersDefinitions[aaIndex, layerIndex]);
|
|
}
|
|
}
|
|
}*/
|
|
|
|
//Decode(FileFullPath, progress);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|