Skip to content

Commit 71f6d6e

Browse files
Merge pull request #35 from Digital-Production-Aachen/fixOVFMergingBug
Bug fixes and stability improvements for ovf streaming merger
2 parents defe36a + e815160 commit 71f6d6e

19 files changed

Lines changed: 384 additions & 83 deletions

File tree

Benchmarks/Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
13+
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
1414
</ItemGroup>
1515

1616
<ItemGroup>

PlausibilityChecker/PlausibilityChecker/PlausibilityChecker.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</ItemGroup>
2626

2727
<ItemGroup>
28-
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
28+
<PackageReference Include="Google.Protobuf" Version="3.26.1" />
2929
</ItemGroup>
3030

3131
<ItemGroup>

PlausibilityChecker/PlausibilityCheckerUnitTests/PlausibilityCheckerUnitTests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
20-
<PackageReference Include="MSTest.TestAdapter" Version="3.0.4" />
21-
<PackageReference Include="MSTest.TestFramework" Version="3.0.4" />
22-
<PackageReference Include="coverlet.collector" Version="6.0.0">
19+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
20+
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
21+
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
22+
<PackageReference Include="coverlet.collector" Version="6.0.2">
2323
<PrivateAssets>all</PrivateAssets>
2424
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2525
</PackageReference>

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,14 +643,21 @@ private MarkingParams TranslateBuildParams(IModelSectionParams iltParams)
643643
private Job.Types.JobMetaData TranslateMetaData(ICLIFile section)
644644
{
645645
Job.Types.JobMetaData metaData = new Job.Types.JobMetaData();
646-
if (section.Header.Date != 0)
646+
if (section.Header.Date > 0)
647647
{
648648
//assuming that the date is after the year 2000, since there is no information about it
649649
int year = (section.Header.Date % 100) + 2000;
650650
int month = (section.Header.Date / 100) % 100;
651651
int day = section.Header.Date % 100;
652-
DateTime date = new DateTime(year, month, day);
653-
metaData.JobCreationTime = new DateTimeOffset(date).ToUnixTimeSeconds();
652+
try
653+
{
654+
DateTime date = new DateTime(year, month, day);
655+
metaData.JobCreationTime = new DateTimeOffset(date).ToUnixTimeSeconds();
656+
}
657+
catch (System.ArgumentOutOfRangeException ex)
658+
{
659+
// ignore invalid dates
660+
};
654661
}
655662
metaData.Version = (ulong)section.Header.Version;
656663
return metaData;

ReaderWriter/FileReaderWriterFactory/FileWriterFactory.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ You should have received a copy of the GNU Lesser General Public
2626

2727
using System;
2828
using System.Collections.Generic;
29+
using System.IO;
2930
using System.Linq;
31+
using System.Threading.Tasks;
3032
using OpenVectorFormat.AbstractReaderWriter;
3133

3234
namespace OpenVectorFormat.FileReaderWriterFactory
@@ -60,5 +62,25 @@ public static List<string> SupportedFileFormats
6062
return formats;
6163
}
6264
}
65+
66+
/// <summary>
67+
/// Utility for writing the contents of a file reader to disk.
68+
/// </summary>
69+
/// <param name="fileToWrite"></param>
70+
/// <param name="targetFile"></param>
71+
/// <returns></returns>
72+
public static async Task StreamToFile(FileReader fileToWrite, string targetFile)
73+
{
74+
var fileInfo = new FileInfo(targetFile);
75+
using (var writer = CreateNewWriter(fileInfo.Extension))
76+
{
77+
writer.StartWritePartial(fileToWrite.JobShell, targetFile, null);
78+
for (int i = 0; i < fileToWrite.JobShell.NumWorkPlanes; i++)
79+
{
80+
var wp = fileToWrite.GetWorkPlaneShell(i);
81+
await writer.AppendWorkPlaneAsync(wp);
82+
}
83+
}
84+
}
6385
}
6486
}

ReaderWriter/FileReaderWriterFactoryGRPCWrapper/FileReaderWriterFactoryGRPCWrapper.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Grpc.AspNetCore" Version="2.55.0" />
12+
<PackageReference Include="Grpc.AspNetCore" Version="2.62.0" />
1313

1414
<!-- Explicitly include our proto file by adding this line: -->
1515
<Protobuf Include="../../ReaderWriter/AbstractReaderWriter/grpc_reader_writer_interface.proto" GrpcServices="Both" Link="Protos/grpc_reader_writer_interface.proto" ProtoRoot="../../" />

ReaderWriter/OVFDefinition/OVFDefinition.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
</ItemGroup>
2424

2525
<ItemGroup>
26-
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
27-
<PackageReference Include="Grpc.Tools" Version="2.56.0">
26+
<PackageReference Include="Google.Protobuf" Version="3.26.1" />
27+
<PackageReference Include="Grpc.Tools" Version="2.62.0">
2828
<PrivateAssets>all</PrivateAssets>
2929
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3030
</PackageReference>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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) 2023 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 OVFDefinition
30+
{
31+
public class Utils
32+
{
33+
public static bool ApproxEquals(float value1, float value2, float tolerance = 1e-6f)
34+
{
35+
return Math.Abs(value1 - value2) <= tolerance;
36+
}
37+
}
38+
}

ReaderWriter/OVFDefinition/VectorBlockExtensions.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ You should have received a copy of the GNU Lesser General Public
2424

2525
using Google.Protobuf.Collections;
2626
using OpenVectorFormat.Utils;
27-
using OVFDefinition;
27+
using OVFDefinition;
2828
using System;
2929
using System.Collections.Generic;
30-
using System.Drawing;
30+
using System.Drawing;
3131
using System.Linq;
3232
using System.Numerics;
3333
using static OpenVectorFormat.SIMDVectorOperations;
@@ -340,14 +340,14 @@ public static void StoreVectorBlockBoundsInMetaData(this VectorBlock vectorBlock
340340
vectorBlock.MetaData.Bounds = vectorBlock.Bounds2D();
341341
}
342342

343-
public static void SetDisplayColor(this VectorBlock.Types.VectorBlockMetaData metaData, Color color)
344-
{
345-
metaData.DisplayColor = ColorConversions.ColorToInt(color);
343+
public static void SetDisplayColor(this VectorBlock.Types.VectorBlockMetaData metaData, Color color)
344+
{
345+
metaData.DisplayColor = ColorConversions.ColorToInt(color);
346346
}
347347

348-
public static Color GetDisplayColor(this VectorBlock.Types.VectorBlockMetaData metaData)
349-
{
350-
return ColorConversions.IntToColor(metaData.DisplayColor);
348+
public static Color GetDisplayColor(this VectorBlock.Types.VectorBlockMetaData metaData)
349+
{
350+
return ColorConversions.IntToColor(metaData.DisplayColor);
351351
}
352352

353353
/// <summary>

ReaderWriter/OVFReaderWriter/OVFReaderWriter.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
</ItemGroup>
3333

3434
<ItemGroup>
35-
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
36-
<PackageReference Include="Grpc.Tools" Version="2.56.0">
35+
<PackageReference Include="Google.Protobuf" Version="3.26.1" />
36+
<PackageReference Include="Grpc.Tools" Version="2.62.0">
3737
<PrivateAssets>all</PrivateAssets>
3838
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
3939
</PackageReference>

0 commit comments

Comments
 (0)