Skip to content

Commit

Permalink
feat: add setter for settings
Browse files Browse the repository at this point in the history
  • Loading branch information
andywiecko committed Sep 26, 2024
1 parent 0d8153c commit 619bb0b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Runtime/Triangulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public readonly struct Handle
/// <seealso cref="Triangulator{T2}"/>
public class Triangulator : IDisposable
{
public TriangulationSettings Settings => impl.Settings;
public TriangulationSettings Settings { get => impl.Settings; set => impl.Settings = value; }
public InputData<double2> Input { get => impl.Input; set => impl.Input = value; }
public OutputData<double2> Output => impl.Output;
private readonly Triangulator<double2> impl;
Expand Down Expand Up @@ -418,7 +418,7 @@ public class Triangulator : IDisposable

public class Triangulator<T2> : IDisposable where T2 : unmanaged
{
public TriangulationSettings Settings { get; } = new();
public TriangulationSettings Settings { get; set; } = new();
public InputData<T2> Input { get; set; } = new();
public OutputData<T2> Output { get; }

Expand Down
11 changes: 10 additions & 1 deletion Tests/TriangulatorEditorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void TriangulatorWrapperTest((bool autoHoles, bool constrainMesh, bool re
using var impl = new Triangulator<double2>(Allocator.Persistent)
{
Input = triangulator.Input,
Settings = { AutoHolesAndBoundary = input.autoHoles, RefineMesh = input.refineMesh, RestoreBoundary = input.restoreBoundary, Preprocessor = input.preprocessor }
Settings = triangulator.Settings,
};

triangulator.Run();
Expand All @@ -75,6 +75,15 @@ public void TriangulatorWrapperTest((bool autoHoles, bool constrainMesh, bool re
if (constraints.IsCreated) { constraints.Dispose(); }
}

[Test]
public void TriangulatorWrapperSettingsTest()
{
var settings = new TriangulationSettings { SloanMaxIters = 42 };
using var t = new Triangulator(Allocator.Persistent) { Settings = settings };
Assert.That(t.Settings, Is.EqualTo(settings));
Assert.That(t.Settings.SloanMaxIters, Is.EqualTo(42));
}

[Test]
public void AsNativeArrayTest()
{
Expand Down
13 changes: 1 addition & 12 deletions Tests/TriangulatorGenericsEditorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,7 @@ public void ValidateArgsTest(TriangulationSettings settings, Status expectedStat
using var triangulator = new Triangulator<T>(Allocator.Persistent)
{
Input = { Positions = positions, ConstraintEdges = constraints },
Settings =
{
AutoHolesAndBoundary = settings.AutoHolesAndBoundary,
ConcentricShellsParameter = settings.ConcentricShellsParameter,
Preprocessor = settings.Preprocessor,
RefinementThresholds = { Angle = settings.RefinementThresholds.Angle, Area = settings.RefinementThresholds.Area},
RefineMesh = settings.RefineMesh,
RestoreBoundary = settings.RestoreBoundary,
SloanMaxIters = settings.SloanMaxIters,
ValidateInput = true,
Verbose = settings.Verbose
}
Settings = settings,
};

LogAssert.Expect(expectedStatus == Status.OK ? LogType.Warning : LogType.Error, new Regex(".*"));
Expand Down

0 comments on commit 619bb0b

Please sign in to comment.