Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sn4k3/UVtools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Conceição <Tiago_caza@hotmail.com>2021-06-16 01:29:45 +0300
committerTiago Conceição <Tiago_caza@hotmail.com>2021-06-16 01:29:45 +0300
commit3888f187bb27ad13dce9ad2912710b17839a04b5 (patch)
tree5b9706b3a7e3f35df2923b3ed9048bf1d38284cf /UVtools.Core
parent5217f9ff22f4d9a11cc00e95f00ebdf2cd4d451c (diff)
Create UVtools.AvaloniaControls
Diffstat (limited to 'UVtools.Core')
-rw-r--r--UVtools.Core/Extensions/PointExtensions.cs3
-rw-r--r--UVtools.Core/FileFormats/LGSFile.cs7
-rw-r--r--UVtools.Core/Slicer/LinAlgUtils.cs7
-rw-r--r--UVtools.Core/Slicer/Slice.cs14
-rw-r--r--UVtools.Core/Slicer/Slicer.cs25
-rw-r--r--UVtools.Core/UVtools.Core.csproj3
6 files changed, 48 insertions, 11 deletions
diff --git a/UVtools.Core/Extensions/PointExtensions.cs b/UVtools.Core/Extensions/PointExtensions.cs
index 01bcc96..2b59054 100644
--- a/UVtools.Core/Extensions/PointExtensions.cs
+++ b/UVtools.Core/Extensions/PointExtensions.cs
@@ -65,6 +65,9 @@ namespace UVtools.Core.Extensions
public static Point Half(this Point point) => new(point.X / 2, point.Y / 2);
public static PointF Half(this PointF point) => new(point.X / 2, point.Y / 2);
+ public static Point ToPoint(this PointF point) => new((int) Math.Round(point.X), (int) Math.Round(point.Y));
+
+
public static Size ToSize(this Point point) => new(point.X, point.Y);
diff --git a/UVtools.Core/FileFormats/LGSFile.cs b/UVtools.Core/FileFormats/LGSFile.cs
index 97f7cbc..9e88da8 100644
--- a/UVtools.Core/FileFormats/LGSFile.cs
+++ b/UVtools.Core/FileFormats/LGSFile.cs
@@ -6,9 +6,6 @@
* 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.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
@@ -34,7 +31,7 @@ namespace UVtools.Core.FileFormats
//[FieldOrder(0)] public uint Offset1 { get; set; }
/// <summary>
- /// Gets the file tag = MKSDLP
+ /// Gets the model name
/// </summary>
[FieldOrder(0)] [FieldLength(8)] public string Name { get; set; } = NameValue; // 0x00:
[FieldOrder(1)] public uint Uint_08 { get; set; } = 4278190081; // 0x08: 0xff000001 ?
@@ -72,7 +69,7 @@ namespace UVtools.Core.FileFormats
[FieldOrder(33)] public float Float_88 { get; set; } = 6; // 0x88: 6?
[FieldOrder(34)] public float Float_8c { get; set; } = 150; // 0x8c: 150 ?
[FieldOrder(35)] public float Float_90 { get; set; } = 1001; // 0x90: 1001 ?
- [FieldOrder(36)] public float Float_94 { get; set; } = 140;// 0x94: 140 for Longer 10, 170 for Longer 30?
+ [FieldOrder(36)] public float Float_94 { get; set; } = 140;// 0x94: 140 for lgs10, 170 for lgs30, 190 for lgs4k
[FieldOrder(37)] public uint Uint_98 { get; set; } // 0x98: 0 ?
[FieldOrder(38)] public uint Uint_9c { get; set; } // 0x9c: 0 ?
[FieldOrder(39)] public uint Uint_a0 { get; set; } // 0xa0: 0 ?
diff --git a/UVtools.Core/Slicer/LinAlgUtils.cs b/UVtools.Core/Slicer/LinAlgUtils.cs
index c6efbcf..8ec92a3 100644
--- a/UVtools.Core/Slicer/LinAlgUtils.cs
+++ b/UVtools.Core/Slicer/LinAlgUtils.cs
@@ -85,17 +85,18 @@ namespace UVtools.Core.Slicer
};
}
- public static float CalculateDimensionalValueAtIndex(PointF p1, PointF p2, float z, string precision = "0000")
+ public static float CalculateDimensionalValueAtIndex(PointF p1, PointF p2, float z, byte precision = 4)
{
var slope = (p1.Y - p2.Y) / (p1.X - p2.X);
var intercept = p1.Y - (slope * p1.X);
var rawVal = slope * z + intercept;
+ return (float)Math.Round(rawVal, precision);
// using floats we end up with some infinitesimal rounding errors,
// so we need to set the precision to something reasonable. Default is 1/100th of a micron
// I'm sure there's a better way than converting it to a string and then back to a float,
// but that's what I've got right now, so that's what I'm doing.
- var strVal = rawVal.ToString($"0.{precision}");
- return float.Parse(strVal, CultureInfo.InvariantCulture.NumberFormat);
+ //var strVal = rawVal.ToString($"0.{precision}");
+ //return float.Parse(strVal, CultureInfo.InvariantCulture.NumberFormat);
}
}
}
diff --git a/UVtools.Core/Slicer/Slice.cs b/UVtools.Core/Slicer/Slice.cs
index de26bdc..50ee130 100644
--- a/UVtools.Core/Slicer/Slice.cs
+++ b/UVtools.Core/Slicer/Slice.cs
@@ -6,7 +6,9 @@
* of this license document, but changing it is not allowed.
*/
using System.Collections.Generic;
+using System.Drawing;
using System.Linq;
+using UVtools.Core.Extensions;
namespace UVtools.Core.Slicer
{
@@ -38,5 +40,17 @@ namespace UVtools.Core.Slicer
return true;
}
+
+ public Point[] ToContour()
+ {
+ var points = new Point[Count*2];
+ for (var i = 0; i < Count; i++)
+ {
+ points[i] = this[i][0].ToPoint();
+ points[i+1] = this[i][1].ToPoint();
+ }
+
+ return points;
+ }
}
}
diff --git a/UVtools.Core/Slicer/Slicer.cs b/UVtools.Core/Slicer/Slicer.cs
index a570948..9f30e86 100644
--- a/UVtools.Core/Slicer/Slicer.cs
+++ b/UVtools.Core/Slicer/Slicer.cs
@@ -11,6 +11,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
+using Org.BouncyCastle.Asn1.X509;
using QuantumConcepts.Formats.StereoLithography;
namespace UVtools.Core.Slicer
@@ -152,8 +153,25 @@ namespace UVtools.Core.Slicer
public Dictionary<float, Slice> SliceModel(float layerHeight)
{
+ /*float volume = 0;
+ _stl.Facets.ForEach(facet =>
+ {
+ var v1 = facet.Vertices[0];
+ var v2 = facet.Vertices[1];
+ var v3 = facet.Vertices[2];
+
+ volume += (
+ -(v3.X * v2.Y * v1.Z)
+ + (v2.X * v3.Y * v1.Z)
+ + (v3.X * v1.Y * v2.Z)
+ - (v1.X * v3.Y * v2.Z)
+ - (v2.X * v1.Y * v3.Z)
+ + (v1.X * v2.Y * v3.Z)
+ ) / 6;
+ });*/
var newDict = new Dictionary<float, Slice>();
- for (var z = RangeUtils.CalculateLowZ(_stl); z <= RangeUtils.CalculateHighZ(_stl); z += layerHeight)
+
+ for (var z = Layer.RoundHeight(LowZ); z <= HighZ; z = Layer.RoundHeight(z+layerHeight))
{
if (_slices.Keys.Contains(z))
newDict[z] = _slices[z];
@@ -165,6 +183,11 @@ namespace UVtools.Core.Slicer
}
return newDict;
}
+
+ public void SliceModel2()
+ {
+
+ }
#endregion
public decimal MillimetersFromPixelsX(uint pixels) => (decimal) Math.Round(pixels / Ppmm.Width, 2);
diff --git a/UVtools.Core/UVtools.Core.csproj b/UVtools.Core/UVtools.Core.csproj
index 00fcf9e..e687d90 100644
--- a/UVtools.Core/UVtools.Core.csproj
+++ b/UVtools.Core/UVtools.Core.csproj
@@ -51,7 +51,7 @@
<PackageReference Include="AnimatedGif" Version="1.0.5" />
<PackageReference Include="BinarySerializer" Version="8.6.0" />
<PackageReference Include="Emgu.CV" Version="4.5.1.4349" />
- <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="3.10.0-3.final" />
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="3.11.0-1.final" />
<PackageReference Include="morelinq" Version="3.3.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.10" />
@@ -59,5 +59,4 @@
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.7.0" />
</ItemGroup>
-
</Project>