File size: 1,393 Bytes
b6a0fc3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
ο»ΏFastPrint/
β
βββ Geometry/
β βββ BsplineMitchellNetravali.cs
β
βββ Slicing/
β βββ SliceAccelerator.cs
β
βββ Printer/
β βββ MarlinConnector.cs
β
βββ Model/
β βββ STLModel.cs
β
βββ UI/
β βββ MainWindow.xaml
β βββ MainWindow.xaml.cs
β
βββ README.md
using System.Collections.Generic;
using System.IO;
using System.Globalization;
namespace FastPrint.Model
{
public class STLModel
{
public List<float[]> Triangles { get; } = new List<float[]>();
public void LoadAscii(string path)
{
using var reader = new StreamReader(path);
string line;
var currentTriangle = new List<float>();
while ((line = reader.ReadLine()) != null)
{
if (line.Trim().StartsWith("vertex"))
{
var parts = line.Trim().Split(' ');
for (int i = 1; i < 4; i++)
currentTriangle.Add(float.Parse(parts[i], CultureInfo.InvariantCulture));
}
if (currentTriangle.Count == 9)
{
Triangles.Add(currentTriangle.ToArray());
currentTriangle.Clear();
}
}
}
}
} |