diff --git a/.github/workflows/BUILD_TEST_DSTV_NET.yml b/.github/workflows/BUILD_TEST_DSTV_NET.yml
index a12419a..fb7b753 100644
--- a/.github/workflows/BUILD_TEST_DSTV_NET.yml
+++ b/.github/workflows/BUILD_TEST_DSTV_NET.yml
@@ -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:
@@ -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
\ No newline at end of file
+ run: dotnet test DSTV.Net.sln --no-build --verbosity normal
diff --git a/.img/dstv.svg b/.img/dstv.svg
index 81bb4e7..cd4adfd 100644
--- a/.img/dstv.svg
+++ b/.img/dstv.svg
@@ -1 +1,8 @@
-
\ No newline at end of file
+
diff --git a/.img/dstv2.svg b/.img/dstv2.svg
new file mode 100644
index 0000000..da49ca6
--- /dev/null
+++ b/.img/dstv2.svg
@@ -0,0 +1,12 @@
+
diff --git a/DSTV.Net.Test/Data/product2.svg b/DSTV.Net.Test/Data/product2.svg
index c3c1822..e44d14e 100644
--- a/DSTV.Net.Test/Data/product2.svg
+++ b/DSTV.Net.Test/Data/product2.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/DSTV.Net.Test/Data/product3.svg b/DSTV.Net.Test/Data/product3.svg
index 8fa4f73..7dca7ef 100644
--- a/DSTV.Net.Test/Data/product3.svg
+++ b/DSTV.Net.Test/Data/product3.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/DSTV.Net/DSTV.Net.nuspec b/DSTV.Net/DSTV.Net.nuspec
index 1757a7a..b2dec09 100644
--- a/DSTV.Net/DSTV.Net.nuspec
+++ b/DSTV.Net/DSTV.Net.nuspec
@@ -8,7 +8,7 @@
$author$
false
$description$
- Added support for netstandard 2.0
+ Added better support for curves
Copyright 2023
DSTV, Tekla, NC, NC1, SVG, Steel, Plates
diff --git a/DSTV.Net/Data/Contour.cs b/DSTV.Net/Data/Contour.cs
index e6da14c..93e2f9f 100644
--- a/DSTV.Net/Data/Contour.cs
+++ b/DSTV.Net/Data/Contour.cs
@@ -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("");
- }
+ 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("");
+ }
+
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 $"{sbLine}";
+ var color = _type == ContourType.AK ? "grey" : "white";
+ return $"{sbLine}";
}
}
\ No newline at end of file
diff --git a/Directory.Build.props b/Directory.Build.props
index 2d8225c..6832dd2 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,4 +1,4 @@
-
+
Copyright (c) Baseflow. All rights reserved
Apache-2.0
@@ -16,7 +16,7 @@
https://github.com/Baseflow/DSTV.Net
git
$(AssemblyName) ($(TargetFramework))
-
+ 1.2.1
enable
enable
latest
@@ -58,7 +58,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
@@ -82,7 +82,7 @@
all
runtime; build; native; contentfiles; analyzers
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/README.md b/README.md
index b51be5e..8d53dc5 100644
--- a/README.md
+++ b/README.md
@@ -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.