diff --git a/DSTV.Net.Test/Data/notch.nc1 b/DSTV.Net.Test/Data/notch.nc1
new file mode 100644
index 0000000..3896733
--- /dev/null
+++ b/DSTV.Net.Test/Data/notch.nc1
@@ -0,0 +1,46 @@
+ST
+**NC-DSTV-Schnittstelle
+ DSTV
+ 1
+ 3
+ 3
+ RST37-2
+ 1
+ HEB400
+ I
+ 2000.00
+ 400.00
+ 300.00
+ 24.00
+ 13.50
+ 27.00
+ 155.000
+ 1.930
+ 0.000
+ 0.000
+ 0.000
+ 0.000
+ TRAEGER
+
+
+
+AK
+ v 200.00u 0.00 0.00
+ v 1952.00 0.00w 10.00
+ v 200.00 100.00 -10.00
+ 200.00 110.00t -10.00
+ 200.00 90.00 0.00
+ v 200.00 0.00 0.00
+AK
+ u 200.00 0.00 0.00
+ u 1900.00 0.00 0.00
+ u 2000.00 300.00 0.00
+ u 200.00 300.00 0.00
+ u 200.00 0.00 0.00
+AK
+ o 159.50s 0.00 0.00
+ o 159.50s 300.00 0.00
+ o 1650.00s 300.00 0.00
+ o 1750.00s 200.00 0.00
+ o 1750.00s 0.00 0.00
+ o 159.50s 0.00 0.00
\ No newline at end of file
diff --git a/DSTV.Net.Test/Tests.cs b/DSTV.Net.Test/Tests.cs
index 3c50b59..d57f0c5 100644
--- a/DSTV.Net.Test/Tests.cs
+++ b/DSTV.Net.Test/Tests.cs
@@ -275,6 +275,36 @@ public async Task TestTupleParseException()
exception.Message);
}
+ ///
+ /// Example with notch points
+ /// Expect valid IsNotch flag for points
+ ///
+ [Fact]
+ public async Task TestIsNotchPoint()
+ {
+ using var streamReader = new StreamReader($"{DataPath}/Data/notch.nc1");
+ var dstvReader = new DstvReader();
+
+ var result = await dstvReader.ParseAsync(streamReader).ConfigureAwait(false);
+ var dstvElement = result.Elements.First();
+
+ Assert.IsType(dstvElement);
+ var contour = (Contour)dstvElement;
+
+ Assert.Equal(ContourType.AK, contour.Type);
+ var actualPoints = contour.Points.ToArray();
+
+ Assert.Equal(6, actualPoints.Length);
+ // First notch "w" point with flange code
+ Assert.True(actualPoints[1].IsNotch);
+ // First not notch point with flange code
+ Assert.False(actualPoints[2].IsNotch);
+ // Second notch "t" point without flange code
+ Assert.True(actualPoints[3].IsNotch);
+ // Second not notch point without flange code
+ Assert.False(actualPoints[4].IsNotch);
+ }
+
// ///
// /// Example of an invalid end in the DSTV file
// /// Expect a
diff --git a/DSTV.Net.sln.DotSettings b/DSTV.Net.sln.DotSettings
index e4bf72d..e5a6507 100644
--- a/DSTV.Net.sln.DotSettings
+++ b/DSTV.Net.sln.DotSettings
@@ -1,2 +1,3 @@
+ True
True
\ No newline at end of file
diff --git a/DSTV.Net/DSTV.Net.csproj b/DSTV.Net/DSTV.Net.csproj
index db0b8b2..6a8ebb3 100644
--- a/DSTV.Net/DSTV.Net.csproj
+++ b/DSTV.Net/DSTV.Net.csproj
@@ -1,10 +1,10 @@
-
+
DSTV.Net is an open-source library tailored for .NET platforms, providing a powerful utility for interacting with DSTV (also known as NC1 or Tekla) files. These files serve as a key industry standard in the steel industry, defining geometry and project information for steel plates.
https://github.com/Baseflow/DSTV.Net
net6.0;net7.0;netstandard2.0
- 1.2.1
+ 1.3.0
diff --git a/DSTV.Net/Data/Contour.cs b/DSTV.Net/Data/Contour.cs
index 93e2f9f..6c324d1 100644
--- a/DSTV.Net/Data/Contour.cs
+++ b/DSTV.Net/Data/Contour.cs
@@ -11,12 +11,14 @@ public record Contour : DstvElement
private readonly List _pointList;
// ReSharper disable once NotAccessedField.Local
- private readonly ContourType _type;
+ public ContourType Type { get; }
+
+ public IEnumerable Points => _pointList.AsEnumerable();
private Contour(List pointList, ContourType type)
{
_pointList = pointList;
- _type = type;
+ Type = type;
}
[SuppressMessage("Design", "CA1002:Do not expose generic lists", Justification = "This is a record")]
@@ -72,7 +74,7 @@ public override string ToSvg()
{
var sb = new StringBuilder();
var sbLine = new StringBuilder();
- var previous = new DstvContourPoint("x", 0, 0, 0);
+ var previous = new DstvContourPoint("x", 0, 0, false, 0);
foreach (var point in _pointList)
{
if (_pointList.IndexOf(point) == 0)
@@ -124,7 +126,7 @@ public override string ToSvg()
}
var points = sb.ToString();
- var color = _type == ContourType.AK ? "grey" : "white";
+ var color = Type == ContourType.AK ? "grey" : "white";
return $"{sbLine}";
}
}
\ No newline at end of file
diff --git a/DSTV.Net/Data/DstvContourPoint.cs b/DSTV.Net/Data/DstvContourPoint.cs
index 74aee22..6a26ed8 100644
--- a/DSTV.Net/Data/DstvContourPoint.cs
+++ b/DSTV.Net/Data/DstvContourPoint.cs
@@ -1,32 +1,33 @@
using DSTV.Net.Exceptions;
using DSTV.Net.Implementations;
using System.Diagnostics.CodeAnalysis;
+using System.Text.RegularExpressions;
namespace DSTV.Net.Data;
[SuppressMessage("Designer", "CA1051:Do not declare visible instance fields", Justification = "This is a DTO")]
-public record DstvContourPoint : LocatedElement
+public record DstvContourPoint(string FlCode, double XCoord, double YCoord, bool IsNotch, double Radius) : LocatedElement(FlCode, XCoord, YCoord)
{
- protected readonly double _radius;
-
- public DstvContourPoint(string flCode, double xCoord, double yCoord, double radius) :
- base(flCode, xCoord, yCoord) => _radius = radius;
-
- public double Radius => _radius;
-
public static DstvContourPoint CreatePoint(string dstvElement)
{
var separated = GetDataVector(dstvElement, FineSplitter.Instance);
// temporary flange-code in case of missing a signature in line
var flCode = "x";
separated[0] = separated[0].Trim();
- if (ValidateFlange(separated[0])) flCode = separated[0];
+ var yCoordIndex = 1;
+ if (ValidateFlange(separated[0]))
+ {
+ flCode = separated[0];
+ ++yCoordIndex;
+ }
+
+ var isNotchPoint = IsNotchPoint(separated[yCoordIndex]);
separated = CorrectSplits(separated);
var xCoord = double.Parse(separated[0], Constants.ParserCultureInfo);
var yCoord = double.Parse(separated[1], Constants.ParserCultureInfo);
var rad = double.Parse(separated[2], Constants.ParserCultureInfo);
- if (separated.Length <= 4) return new DstvContourPoint(flCode, xCoord, yCoord, rad);
+ if (separated.Length <= 4) return new DstvContourPoint(flCode, xCoord, yCoord, isNotchPoint, rad);
double ang1;
double blunting1;
@@ -34,9 +35,9 @@ public static DstvContourPoint CreatePoint(string dstvElement)
{
ang1 = double.Parse(separated[3], Constants.ParserCultureInfo);
blunting1 = double.Parse(separated[4], Constants.ParserCultureInfo);
- if (ang1 == 0 && blunting1 == 0) return new DstvContourPoint(flCode, xCoord, yCoord, rad);
+ if (ang1 == 0 && blunting1 == 0) return new DstvContourPoint(flCode, xCoord, yCoord, isNotchPoint, rad);
- return new DstvSkewedPoint(flCode, xCoord, yCoord, rad, ang1, blunting1, 0, 0);
+ return new DstvSkewedPoint(flCode, xCoord, yCoord, isNotchPoint, rad, ang1, blunting1, 0, 0);
}
if (separated.Length == 7)
@@ -44,9 +45,9 @@ public static DstvContourPoint CreatePoint(string dstvElement)
ang1 = double.Parse(separated[4], Constants.ParserCultureInfo);
var ang2 = double.Parse(separated[6], Constants.ParserCultureInfo);
blunting1 = double.Parse(separated[5], Constants.ParserCultureInfo);
- if (ang1 == 0 && blunting1 == 0) return new DstvContourPoint(flCode, xCoord, yCoord, rad);
+ if (ang1 == 0 && blunting1 == 0) return new DstvContourPoint(flCode, xCoord, yCoord, isNotchPoint, rad);
- return new DstvSkewedPoint(flCode, xCoord, yCoord, rad, ang1, blunting1, ang2, 0);
+ return new DstvSkewedPoint(flCode, xCoord, yCoord, isNotchPoint, rad, ang1, blunting1, ang2, 0);
}
if (separated.Length == 8)
@@ -60,15 +61,22 @@ public static DstvContourPoint CreatePoint(string dstvElement)
&& ang2 == 0
&& blunting2 == 0)
{
- return new DstvContourPoint(flCode, xCoord, yCoord, rad);
+ return new DstvContourPoint(flCode, xCoord, yCoord, isNotchPoint, rad);
}
- return new DstvSkewedPoint(flCode, xCoord, yCoord, rad, ang1, blunting1, ang2, blunting2);
+ return new DstvSkewedPoint(flCode, xCoord, yCoord, isNotchPoint, rad, ang1, blunting1, ang2, blunting2);
}
throw new DstvParseException("Illegal data vector format (AK/IK)");
}
+ private static bool IsNotchPoint(string yCoordValue)
+ {
+ var numberRegexString = "[.\\d-]+";
+ var regexString = $"{numberRegexString}[wt]";
+ return Regex.IsMatch(yCoordValue, regexString, RegexOptions.None, TimeSpan.FromSeconds(1));
+ }
+
public override string ToString() =>
- $"DStVContourPoint : radius={_radius}, flCode=\'{FlCode}\', xCoord={XCoord}, yCoord={YCoord}";
+ $"DStVContourPoint : radius={Radius}, flCode=\'{FlCode}\', xCoord={XCoord}, yCoord={YCoord}";
}
\ No newline at end of file
diff --git a/DSTV.Net/Data/DstvHole.cs b/DSTV.Net/Data/DstvHole.cs
index 4bb0ab6..2c5f14f 100644
--- a/DSTV.Net/Data/DstvHole.cs
+++ b/DSTV.Net/Data/DstvHole.cs
@@ -7,15 +7,16 @@ namespace DSTV.Net.Data;
[SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "This is a DTO")]
public record DstvHole : LocatedElement
{
- //0 if through
- private readonly double _depth;
- protected readonly double Diam;
+ // 0 if through
+ public double Depth { get; }
- protected DstvHole(string flCode, double xCoord, double yCoord, double diam, double depth) : base(flCode, xCoord,
- yCoord)
+ public double Diameter { get; }
+
+ protected DstvHole(string flCode, double xCoord, double yCoord, double diam, double depth)
+ : base(flCode, xCoord, yCoord)
{
- Diam = diam;
- _depth = depth;
+ Diameter = diam;
+ Depth = depth;
}
@@ -51,8 +52,8 @@ public static DstvElement CreateHole(string holeNote)
}
public override string ToString() =>
- $"DStVHole : flCode='{FlCode}', xCoord={XCoord}, yCoord={YCoord}, diam={Diam}, depth={_depth}";
+ $"DStVHole : flCode='{FlCode}', xCoord={XCoord}, yCoord={YCoord}, diam={Diameter}, depth={Depth}";
public override string ToSvg() =>
- $"";
+ $"";
}
\ No newline at end of file
diff --git a/DSTV.Net/Data/DstvSkewedPoint.cs b/DSTV.Net/Data/DstvSkewedPoint.cs
index f43f84e..4696e35 100644
--- a/DSTV.Net/Data/DstvSkewedPoint.cs
+++ b/DSTV.Net/Data/DstvSkewedPoint.cs
@@ -1,25 +1,17 @@
namespace DSTV.Net.Data;
-public record DstvSkewedPoint : DstvContourPoint
+public record DstvSkewedPoint(
+ string FlCode,
+ double XCoord,
+ double YCoord,
+ bool IsNotch,
+ double Radius,
+ double FirstAngle,
+ double FirstBlunting,
+ double SecondAngle,
+ double SecondBlunting)
+ : DstvContourPoint(FlCode, XCoord, YCoord, IsNotch, Radius)
{
- private readonly double _ang1;
-
- private readonly double _ang2;
-
- private readonly double _blunting1;
-
- private readonly double _blunting2;
-
- public DstvSkewedPoint(string flCode, double xCoord, double yCoord, double radius, double ang1, double blunting1,
- double ang2, double blunting2) : base(flCode, xCoord, yCoord, radius)
- {
- _ang1 = ang1;
- _blunting1 = blunting1;
- _ang2 = ang2;
- _blunting2 = blunting2;
- }
-
-
public override string ToString() =>
- $"DStVSkewedPoint{{ang1={_ang1}, blunting1={_blunting1}, ang2={_ang2}, blunting2={_blunting2}, radius={_radius}, flCode='{FlCode}', xCoord={XCoord}, yCoord={YCoord}}}";
+ $"DStVSkewedPoint{{ang1={FirstAngle}, blunting1={FirstBlunting}, ang2={SecondAngle}, blunting2={SecondBlunting}, radius={Radius}, flCode='{FlCode}', xCoord={XCoord}, yCoord={YCoord}}}";
}
\ No newline at end of file
diff --git a/DSTV.Net/Data/DstvSlot.cs b/DSTV.Net/Data/DstvSlot.cs
index 4059660..cc116d8 100644
--- a/DSTV.Net/Data/DstvSlot.cs
+++ b/DSTV.Net/Data/DstvSlot.cs
@@ -2,21 +2,30 @@ namespace DSTV.Net.Data;
public record DstvSlot : DstvHole
{
- private readonly double _slotAng;
+ public double SlotAngle { get; }
//optional, for slots only
- private readonly double _slotLen;
- private readonly double _slotWidth;
+ public double SlotLength { get; }
- public DstvSlot(string flCode, double xCoord, double yCoord, double diam, double depth, double slotLen,
- double slotWidth, double slotAng) : base(flCode, xCoord, yCoord, diam, depth)
+ public double SlotWidth { get; }
+
+ public DstvSlot(
+ string flCode,
+ double xCoord,
+ double yCoord,
+ double diam,
+ double depth,
+ double slotLen,
+ double slotWidth,
+ double slotAng)
+ : base(flCode, xCoord, yCoord, diam, depth)
{
- _slotLen = slotLen;
- _slotWidth = slotWidth;
- _slotAng = slotAng;
+ SlotLength = slotLen;
+ SlotWidth = slotWidth;
+ SlotAngle = slotAng;
}
- public override string ToString() => $"{base.ToString()}, SlotLength : {_slotLen}, SlothWidth : {_slotWidth}, SlotAngle : {_slotAng}";
+ public override string ToString() => $"{base.ToString()}, SlotLength : {SlotLength}, SlothWidth : {SlotWidth}, SlotAngle : {SlotAngle}";
- public override string ToSvg() => $"";
+ public override string ToSvg() => $"";
}
\ No newline at end of file
diff --git a/DSTV.Net/Implementations/DotSplitter.cs b/DSTV.Net/Implementations/DotSplitter.cs
index 28b7336..2d3e9d1 100644
--- a/DSTV.Net/Implementations/DotSplitter.cs
+++ b/DSTV.Net/Implementations/DotSplitter.cs
@@ -16,7 +16,7 @@ public string[] Split(string input)
{
var prevPos = 0;
if (i > 0) prevPos = dotPoss[i - 1];
- dotPoss[i] = input.IndexOf(".", prevPos + 1, StringComparison.Ordinal);
+ dotPoss[i] = input.IndexOf('.', prevPos + 1);
}
var outArr = new string[n];
diff --git a/DSTV.Net/Implementations/FineSplitter.cs b/DSTV.Net/Implementations/FineSplitter.cs
index 4ac41f4..12e28e7 100644
--- a/DSTV.Net/Implementations/FineSplitter.cs
+++ b/DSTV.Net/Implementations/FineSplitter.cs
@@ -5,9 +5,10 @@ namespace DSTV.Net.Implementations;
internal class FineSplitter : ISplitter
{
internal static readonly ISplitter Instance = new Lazy(() => new FineSplitter()).Value;
+ internal static readonly string[] Separator = {" "};
///
/// Splitter for full carefully splitting - saving all lexemes
///
- public string[] Split(string input) => input.Split(new [] {" "}, StringSplitOptions.RemoveEmptyEntries);
+ public string[] Split(string input) => input.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
}
\ No newline at end of file
diff --git a/Directory.Build.props b/Directory.Build.props
index 3afb440..07a6d88 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -19,7 +19,7 @@
enable
enable
latest
- $(NoWarn);1591;1701;1702;1705;VSX1000;NU1603;CA1014;NU5125
+ $(NoWarn);1591;1701;1702;1705;VSX1000;NU1603;CA1014;NU5125;CA1510
true
AnyCPU