Skip to content

Commit

Permalink
Merge branch 'release/1.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
tluijken committed Sep 21, 2023
2 parents 37c2b2c + 4b92d63 commit 0802c89
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 51 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/BUILD_TEST_DSTV_NET.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@ name: Build and Unit Test Dstv reader

on:
push:
paths:
- 'DSTV.Net/**'
- 'DSTV.Net.Tests/**'
- '.github/workflows/BUILD_TEST_DSTV_NET.yml'
branches: [ develop, main ]
pull_request:
paths:
- 'DSTV.Net/**'
- 'DSTV.Net.Tests/**'
- '.github/workflows/BUILD_TEST_DSTV_NET.yml'
branches: [ develop, main ]

jobs:
Expand All @@ -28,4 +20,4 @@ jobs:
- name: Build
run: dotnet build DSTV.Net.sln --no-restore
- name: Test
run: dotnet test DSTV.Net.sln --no-build --verbosity normal
run: dotnet test DSTV.Net.sln --no-build --verbosity normal
9 changes: 8 additions & 1 deletion .img/dstv.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions .img/dstv2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion DSTV.Net.Test/Data/product2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion DSTV.Net.Test/Data/product3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion DSTV.Net/DSTV.Net.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>Added support for netstandard 2.0</releaseNotes>
<releaseNotes>Added better support for curves</releaseNotes>
<copyright>Copyright 2023</copyright>
<tags>DSTV, Tekla, NC, NC1, SVG, Steel, Plates</tags>
</metadata>
Expand Down
75 changes: 41 additions & 34 deletions DSTV.Net/Data/Contour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,52 +72,59 @@ public override string ToSvg()
{
var sb = new StringBuilder();
var sbLine = new StringBuilder();
var isFirst = true;
var previous = new DstvContourPoint("x", 0, 0, 0);
foreach (var point in _pointList)
{
if (isFirst)
if (_pointList.IndexOf(point) == 0)
{
sb.Append('M').Append(point.XCoord).Append(',').Append(point.YCoord);
sb.Append("M ").Append(point.XCoord).Append(' ').Append(point.YCoord);
previous = point;
continue;
}
else
sb.Append(' ');
var radius = previous.Radius;
switch (radius)
{
sb.Append(' ');
var radius = previous.Radius;
if (radius > 0)
{
if (previous.YCoord > point.YCoord && point.XCoord > previous.XCoord) // left-top corner
sb.Append('Q').Append(previous.XCoord).Append(',').Append(point.YCoord)
.Append(',').Append(point.XCoord).Append(',').Append(point.YCoord);
else if (previous.YCoord < point.YCoord && point.XCoord > previous.XCoord) // top-right corner
sb.Append('Q').Append(point.XCoord).Append(',').Append(previous.YCoord)
.Append(',').Append(point.XCoord).Append(',').Append(point.YCoord);
else if (previous.YCoord < point.YCoord && point.XCoord < previous.XCoord) // right-bottom corner
sb.Append('Q').Append(previous.XCoord).Append(',').Append(point.YCoord)
.Append(',').Append(point.XCoord).Append(',').Append(point.YCoord);
else if (previous.YCoord > point.YCoord && point.XCoord < previous.XCoord) // bottom-left corner
sb.Append('Q').Append(point.XCoord).Append(',').Append(previous.YCoord)
.Append(',').Append(point.XCoord).Append(',').Append(point.YCoord);
}
else
{
// top-right corner Quadratic Bézier curve
case > 0 when previous.YCoord < point.YCoord && point.XCoord > previous.XCoord:
sb.Append("Q ").Append(point.XCoord).Append(' ').Append(previous.YCoord)
.Append(' ').Append(point.XCoord).Append(' ').Append(point.YCoord);
break;
// right-bottom corner Quadratic Bézier curve
case > 0 when previous.YCoord < point.YCoord && point.XCoord < previous.XCoord:
sb.Append("Q ").Append(previous.XCoord).Append(' ').Append(point.YCoord)
.Append(' ').Append(point.XCoord).Append(' ').Append(point.YCoord);
break;
// bottom-left corner Quadratic Bézier curve
case > 0 when previous.YCoord > point.YCoord && point.XCoord < previous.XCoord:
sb.Append("Q ").Append(point.XCoord).Append(' ').Append(previous.YCoord)
.Append(' ').Append(point.XCoord).Append(' ').Append(point.YCoord);
break;
// in all other cases we use arc if the radius is not 0
case > 0:
case < 0:
sb.Append("A ").Append(-radius).Append(' ').Append(-radius).Append(" 0 0 0 ").Append(point.XCoord)
.Append(' ').Append(point.YCoord);
break;
// straight Line
default:
sb.Append('L').Append(point.XCoord).Append(',').Append(point.YCoord);
}

if (previous is DstvSkewedPoint screwingPoint)
{
sbLine.Append("<line x1=\"").Append(screwingPoint.XCoord).Append("\" y1=\"")
.Append(screwingPoint.YCoord).Append("\" x2=\"").Append(point.XCoord).Append("\" y2=\"")
.Append(point.YCoord).Append("\" stroke=\"red\" stroke-width=\"4\" />");
}
break;
}

isFirst = false;
// if previous point is screwing point, we draw a line from it to current point to show a bezel line
if (previous is DstvSkewedPoint screwingPoint)
{
sbLine.Append("<line x1=\"").Append(screwingPoint.XCoord).Append("\" y1=\"")
.Append(screwingPoint.YCoord).Append("\" x2=\"").Append(point.XCoord).Append("\" y2=\"")
.Append(point.YCoord).Append("\" stroke=\"red\" stroke-width=\"4\" />");
}

previous = point;
}

var points = sb.ToString();
//var points = string.Join(" ", _pointList.Select(d => _pointList.IndexOf(d) == 0 ? "M" : d is DstvContourPoint cp && cp.Radius >0 ? "Q" : "L").Zip(_pointList, (a, b) => $"{a}{b.XCoord},{b.YCoord}"));
return $"<path d=\"{points}\" fill=\"gray\" stroke=\"black\" stroke-width=\"0.5\" />{sbLine}";
var color = _type == ContourType.AK ? "grey" : "white";
return $"<path d=\"{points}\" fill=\"{color}\" stroke=\"black\" stroke-width=\"0.5\" />{sbLine}";
}
}
8 changes: 4 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project>
<Project>
<PropertyGroup>
<Copyright>Copyright (c) Baseflow. All rights reserved</Copyright>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
Expand All @@ -16,7 +16,7 @@
<RepositoryUrl>https://github.com/Baseflow/DSTV.Net</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Product>$(AssemblyName) ($(TargetFramework))</Product>

<Version>1.2.1</Version>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
Expand Down Expand Up @@ -58,7 +58,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Meziantou.Polyfill" Version="1.0.26">
<PackageReference Include="Meziantou.Polyfill" Version="1.0.27">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand All @@ -82,7 +82,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.82">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.85">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ The CodeProfile contains the following values:
In addition to parsing, DSTV.Net also facilitates the visualization of the geometry of steel plates as defined in DSTV files. It achieves this by converting the geometric data into an SVG (Scalable Vector Graphics) format. This immediate visual representation aids better understanding and verification of the data extracted.

![image](./.img/dstv.svg)
![image](./.img/dstv2.svg)


We support this by providing a SVG generator that can be used to generate SVG files from the parsed DSTV data.

Expand Down

0 comments on commit 0802c89

Please sign in to comment.