Skip to content

Commit 9959730

Browse files
Added a unittest for ILT with in-CLI marking parameters and fixed some bugs in ConvertILTStructure.
Tests are rudimentary: one CLI file has additional parameter change commands inserted manually. ILT test is the same file with the modified CLI inserted back. Binary CLI is not supported, netfabb seems to not write any parameter change commands when exporting to binary.
1 parent 30fb29e commit 9959730

9 files changed

Lines changed: 1967 additions & 159 deletions

File tree

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ private void ConvertILTStructure(IFileReaderWriterProgress progress = null)
282282
double sectionProgress = 0;
283283
int modelSectionID = 0;
284284

285-
var markingParamsMap = new MapField<int, MarkingParams>();
286285
foreach (IModelSection section in buildJob.ModelSections)
287286
{
288287
/*convert Modelsection to Part, ignore every "parts" in a Modelsection, since
@@ -291,6 +290,7 @@ they don't provide any information*/
291290
section.ID = modelSectionID++;
292291
job.PartsMap.Add(section.ID, part);
293292

293+
// initialize with marking param from ILT, but allow each CLI-file to override them
294294
var markingParamsManager = new MarkingParamsManager(TranslateBuildParams(section.Parameters));
295295
var addedVectorBlocks = new List<VectorBlock>();
296296
for (int i = 0; i < section.Geometry.Layers.Count; i++)
@@ -346,7 +346,7 @@ they don't provide any information*/
346346
+ ((i / (double)section.Geometry.Layers.Count) * 100.0 / buildJob.ModelSections.Count)));
347347
}
348348
}
349-
markingParamsMap.MergeFromWithRemap(markingParamsManager.MarkingParamsMap, out var keyMapping);
349+
job.MarkingParamsMap.MergeFromWithRemap(markingParamsManager.MarkingParamsMap, out var keyMapping);
350350
foreach (var vectorBlock in addedVectorBlocks) // update all vector block marking param keys after merge
351351
vectorBlock.MarkingParamsKey = keyMapping[vectorBlock.MarkingParamsKey];
352352
sectionProgress++;
@@ -395,8 +395,15 @@ private void ConvertCLIStructure(IFileReaderWriterProgress progress = null)
395395
foreach (int key in markingParamsManager.MarkingParamsMap.Keys)
396396
job.MarkingParamsMap[key] = markingParamsManager.MarkingParamsMap[key];
397397
job.NumWorkPlanes = job.WorkPlanes.Count;
398-
}
399-
398+
}
399+
400+
/// <summary>
401+
/// Accumulate sequential parameter change commands into a map of ovf MarkingParams.
402+
/// Each parameter set is assigned a unique key and added to the marking params map.
403+
/// Each call to Update() changes the current parameter set. InsertCurrentParams()
404+
/// records the current params (avoiding duplicate entries) and returns the key
405+
/// for retreiving that parameter set from the map.
406+
/// </summary>
400407
private class MarkingParamsManager
401408
{
402409
public MapField<int, MarkingParams> MarkingParamsMap { get; }
@@ -406,11 +413,6 @@ private class MarkingParamsManager
406413
private bool currentMPlocked = false;
407414
private int nextMPKey = 0;
408415

409-
/// <summary>
410-
/// Accumulate sequential parameter change commands into ovf MarkingParameters.
411-
/// Each parameter set is assigned a unique key and added to the marking params map.
412-
/// </summary>
413-
/// <param name="markingParamsMap"></param>
414416
public MarkingParamsManager(MarkingParams initialMarkingParams = null)
415417
{
416418
MarkingParamsMap = new MapField<int, MarkingParams>();
@@ -456,7 +458,6 @@ private void SetJobData(IBuildJob buildJob)
456458
int i = 0;
457459
foreach (IModelSection section in buildJob.ModelSections)
458460
{
459-
job.MarkingParamsMap.Add(i, TranslateBuildParams(section.Parameters));
460461
ModelsectionMap.Add(section, i);
461462
i++;
462463
}
@@ -484,9 +485,6 @@ private VectorBlock TranslateBlockData(IVectorBlock iltBlock, IModelSection mode
484485
//this information gets lost
485486
block.LpbfMetadata.Reexposure = false;
486487

487-
//SetJobData has to be called before using this
488-
//block.MarkingParamsKey = ModelsectionMap[modelSection];
489-
Debug.Assert(job.MarkingParamsMap.ContainsKey(block.MarkingParamsKey));
490488
/* vs=Volumen Schraffur, vk=Volumen Kontur, u steht fuer unten-> down,
491489
us=Downskin Schraffur, uk=Downskin Kontur, kv=Kontur Versatz, sx = single vector, support */
492490
switch (modelSection.SubType)

ReaderWriter/OVFDefinition/Utils.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ public static void MergeFromWithRemap(this MapField<int, MarkingParams> map, Map
4444
foreach (var parameterToInsert in other)
4545
{
4646
bool found = false;
47-
foreach (var mergedShellParam in map)
47+
foreach (var existingParameter in map)
4848
{
49-
if (mergedShellParam.Value.Equals(parameterToInsert.Value))
49+
if (existingParameter.Value.Equals(parameterToInsert.Value))
5050
{
5151
found = true;
52-
keyMapping.Add(parameterToInsert.Key, mergedShellParam.Key);
52+
keyMapping.Add(parameterToInsert.Key, existingParameter.Key);
5353
break;
5454
}
5555
}

0 commit comments

Comments
 (0)