Skip to content

Commit b18cc56

Browse files
Merge pull request #41 from Digital-Production-Aachen/ilt_fallback_params
added Ilt fallback params and imroved ILT compatiblity with exports from Netfabb and 3dExpert. Fixes #40
2 parents 0c2034a + 9959730 commit b18cc56

26 files changed

Lines changed: 2611 additions & 267 deletions

ReaderWriter/3rdPartyFormatAdapters/CLI_ILT/ILTFileReaderAdapter/ILTFileReaderAdapter.cs

Lines changed: 142 additions & 76 deletions
Large diffs are not rendered by default.

ReaderWriter/3rdPartyFormatAdapters/CLI_ILT/ILTFileReaderInterfaces/ILayer.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,9 @@ You should have received a copy of the GNU Lesser General Public
3030
// Original author: Dirks
3131
///////////////////////////////////////////////////////////
3232

33-
using System;
34-
using System.Collections.Generic;
35-
using System.Text;
36-
using System.IO;
37-
3833

34+
using System.Collections.Generic;
3935

40-
using OpenVectorFormat.ILTFileReader;
4136
namespace OpenVectorFormat.ILTFileReader
4237
{
4338
/// <summary>
@@ -46,13 +41,13 @@ namespace OpenVectorFormat.ILTFileReader
4641
/// </summary>
4742
public interface ILayer {
4843

49-
float Height{
50-
get;
51-
}
44+
float Height { get; }
45+
46+
IList<ILayerCommand> LayerCommands { get; }
47+
48+
IList<IVectorBlock> VectorBlocks { get; }
5249

53-
IList<IVectorBlock> VectorBlocks{
54-
get;
55-
}
50+
void AddLayerCommand(ILayerCommand command);
5651
}//end ILayer
5752

5853
}//end namespace OpenVectorFormat.ILTFileReader
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
---- Copyright Start ----
3+
4+
This file is part of the OpenVectorFormatTools collection. This collection provides tools to facilitate the usage of the OpenVectorFormat.
5+
6+
Copyright (C) 2024 Digital-Production-Aachen
7+
8+
This library is free software; you can redistribute it and/or
9+
modify it under the terms of the GNU Lesser General Public
10+
License as published by the Free Software Foundation; either
11+
version 2.1 of the License, or (at your option) any later version.
12+
13+
This library is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
Lesser General Public License for more details.
17+
18+
You should have received a copy of the GNU Lesser General Public
19+
License along with this library; if not, write to the Free Software
20+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
22+
---- Copyright End ----
23+
*/
24+
25+
using System;
26+
using System.Collections.Generic;
27+
using System.Text;
28+
29+
namespace OpenVectorFormat.ILTFileReader
30+
{
31+
public interface ILayerCommand
32+
{
33+
}
34+
}

ReaderWriter/3rdPartyFormatAdapters/CLI_ILT/ILTFileReaderInterfaces/IModelSection.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ PartArea Type
6161
string ModelsectionName
6262
{
6363
get;
64-
}
64+
}
65+
int ID { get; set; }
6566
}//end IModelSection
6667

6768
}//end namespace OpenVectorFormat.ILTFileReader
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
---- Copyright Start ----
3+
4+
This file is part of the OpenVectorFormatTools collection. This collection provides tools to facilitate the usage of the OpenVectorFormat.
5+
6+
Copyright (C) 2024 Digital-Production-Aachen
7+
8+
This library is free software; you can redistribute it and/or
9+
modify it under the terms of the GNU Lesser General Public
10+
License as published by the Free Software Foundation; either
11+
version 2.1 of the License, or (at your option) any later version.
12+
13+
This library is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
Lesser General Public License for more details.
17+
18+
You should have received a copy of the GNU Lesser General Public
19+
License along with this library; if not, write to the Free Software
20+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
22+
---- Copyright End ----
23+
*/
24+
25+
26+
namespace OpenVectorFormat.ILTFileReader
27+
{
28+
29+
public enum CLILaserParameter { POWER, SPEED, FOCUS }
30+
31+
public interface IParameterChange : ILayerCommand
32+
{
33+
CLILaserParameter Parameter { get; }
34+
float Value { get; }
35+
}
36+
}

ReaderWriter/3rdPartyFormatAdapters/CLI_ILT/ILTFileReaderInterfaces/IVectorBlock.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,9 @@ You should have received a copy of the GNU Lesser General Public
3030
// Original author: Dirks
3131
///////////////////////////////////////////////////////////
3232

33-
using System;
34-
using System.Collections.Generic;
35-
using System.Text;
36-
using System.IO;
37-
38-
3933

4034
namespace OpenVectorFormat.ILTFileReader {
41-
public interface IVectorBlock {
35+
public interface IVectorBlock : ILayerCommand {
4236
/// <summary>
4337
/// Raw coordiantes of points.
4438
/// </summary>

ReaderWriter/3rdPartyFormatAdapters/CLI_ILT/iltFileReader/Controller/CliFileAccess.cs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ You should have received a copy of the GNU Lesser General Public
3232
using System.IO;
3333
using System.Text;
3434
using System.Text.RegularExpressions;
35+
using ILTFileReader.Model;
3536

3637
namespace OpenVectorFormat.ILTFileReader.Controller
3738
{
@@ -273,7 +274,7 @@ private IList<ILayer> ReadBinaryContent()
273274
ushort dir = this.bR.ReadUInt16();// readHelper.readUint16(this, ref index);
274275
ushort n = this.bR.ReadUInt16(); //readHelper.readUint16(this, ref index); //number of points
275276

276-
layers[layers.Count - 1].VectorBlocks.Add(new Polyline(this.bR.BaseStream.Position, id, (Direction)dir, n, false, this.bR)); //using the last layer in the list, since the format gives: Layer, it's Vectors, next Layer
277+
layers[layers.Count - 1].AddLayerCommand(new Polyline(this.bR.BaseStream.Position, id, (Direction)dir, n, false, this.bR)); //using the last layer in the list, since the format gives: Layer, it's Vectors, next Layer
277278
this.bR.BaseStream.Seek(this.bR.BaseStream.Position + n * 2 * 2, SeekOrigin.Begin);
278279
//For all non Layer Commands there is the second parameter, giving the number of VectorBlocks following
279280
//at least that value has to parsed to see how far we have to jump to get to the next Layer/CI
@@ -291,7 +292,7 @@ private IList<ILayer> ReadBinaryContent()
291292
*/
292293
int dir = this.bR.ReadInt32();//readHelper.readInt(this, ref index);
293294
int n = this.bR.ReadInt32(); //readHelper.readInt(this, ref index); //number of points
294-
layers[layers.Count - 1].VectorBlocks.Add(new Polyline(this.bR.BaseStream.Position, id, (Direction)dir, n, true, this.bR)); //using the last layer in the list, since the format gives: Layer, it's Vectors, next Layer
295+
layers[layers.Count - 1].AddLayerCommand(new Polyline(this.bR.BaseStream.Position, id, (Direction)dir, n, true, this.bR)); //using the last layer in the list, since the format gives: Layer, it's Vectors, next Layer
295296
this.bR.BaseStream.Seek(this.bR.BaseStream.Position + n * 2 * 4, SeekOrigin.Begin);
296297
//index += n * 2 * 4; //for each vector value jump four bytes ahead
297298
//For all non Layer Commands there is the second parameter, giving the number of VectorBlocks following
@@ -303,7 +304,7 @@ private IList<ILayer> ReadBinaryContent()
303304
//Hex: 83 start Hatch Short
304305
ushort id = this.bR.ReadUInt16();//readHelper.readUint16(this, ref index); //identifier to allow more than one model information in one file. id refers to the parameter id of command $$LABEL (HEADER-section).
305306
ushort n = this.bR.ReadUInt16();//readHelper.readUint16(this, ref index); //number of points
306-
layers[layers.Count - 1].VectorBlocks.Add(new Hatches(this.bR.BaseStream.Position, id, n, false, this.bR)); //using the last layer in the list, since the format gives: Layer, it's Vectors, next Layer
307+
layers[layers.Count - 1].AddLayerCommand(new Hatches(this.bR.BaseStream.Position, id, n, false, this.bR)); //using the last layer in the list, since the format gives: Layer, it's Vectors, next Layer
307308

308309
this.bR.BaseStream.Seek(this.bR.BaseStream.Position + n * 4 * 2, SeekOrigin.Begin);
309310
//index += n * 4 * 2;
@@ -314,7 +315,7 @@ private IList<ILayer> ReadBinaryContent()
314315
// Hex: 84 'start hatch long
315316
int id = this.bR.ReadInt32();//readHelper.readInt(this, ref index); //identifier to allow more than one model information in one file. id refers to the parameter id of command $$LABEL (HEADER-section).
316317
int n = this.bR.ReadInt32();//readHelper.readInt(this, ref index); //number of points
317-
layers[layers.Count - 1].VectorBlocks.Add(new Hatches(this.bR.BaseStream.Position, id, n, true, this.bR)); //using the last layer in the list, since the format gives: Layer, it's Vectors, next Layer
318+
layers[layers.Count - 1].AddLayerCommand(new Hatches(this.bR.BaseStream.Position, id, n, true, this.bR)); //using the last layer in the list, since the format gives: Layer, it's Vectors, next Layer
318319
this.bR.BaseStream.Seek(this.bR.BaseStream.Position + n * 4 * 4, SeekOrigin.Begin);
319320
break;
320321
}
@@ -350,7 +351,7 @@ private IList<ILayer> ReadASCIIContent()
350351
{
351352
coordinates[i] = float.Parse(numberStrings[i+2], NumberStyles.Any, CultureInfo.InvariantCulture);
352353
}
353-
currentLayer.VectorBlocks.Add(new Hatches(id, n, coordinates));
354+
currentLayer.AddLayerCommand(new Hatches(id, n, coordinates));
354355
}
355356
if (line.StartsWith(@"$$POLYLINE/"))
356357
{
@@ -367,14 +368,29 @@ private IList<ILayer> ReadASCIIContent()
367368
{
368369
coordinates[i] = float.Parse(numberStrings[i + 3], NumberStyles.Any, CultureInfo.InvariantCulture);
369370
}
370-
currentLayer.VectorBlocks.Add(new Polyline(id, dir, n, coordinates));
371+
currentLayer.AddLayerCommand(new Polyline(id, dir, n, coordinates));
371372
}
372373
if (line.StartsWith(@"$$LAYER/"))
373374
{
374375
float height = float.Parse(line.Substring(8), NumberStyles.Any, CultureInfo.InvariantCulture);
375376
currentLayer = new Layer(height);
376377
layers.Add(currentLayer);
377378
}
379+
if (line.StartsWith(@"$$POWER/"))
380+
{
381+
currentLayer.AddLayerCommand(new ParameterChange(
382+
CLILaserParameter.POWER, float.Parse(line.Substring(8), NumberStyles.Any, CultureInfo.InvariantCulture)));
383+
}
384+
if (line.StartsWith(@"$$SPEED/"))
385+
{
386+
currentLayer.AddLayerCommand(new ParameterChange(
387+
CLILaserParameter.SPEED, float.Parse(line.Substring(8), NumberStyles.Any, CultureInfo.InvariantCulture)));
388+
}
389+
if (line.StartsWith(@"$$FOCUS/"))
390+
{
391+
currentLayer.AddLayerCommand(new ParameterChange(
392+
CLILaserParameter.FOCUS, float.Parse(line.Substring(8), NumberStyles.Any, CultureInfo.InvariantCulture)));
393+
}
378394
}
379395
return layers;
380396
}

0 commit comments

Comments
 (0)