Skip to content

Commit 5f34747

Browse files
committed
C# refactored Path64, Paths64, PathD & PathsD to derived List classes
Updated framework to .NET5.0
1 parent a616cb5 commit 5f34747

23 files changed

+99
-131
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
RandomPolygons.txt
1+
.*

CSharp/Clipper2Lib.Benchmark/Benchmarks.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@
66

77
namespace Clipper2Lib.Benchmark
88
{
9-
using Path64 = List<Point64>;
10-
using Paths64 = List<List<Point64>>;
11-
129
public class FastConfig : ManualConfig
1310
{
1411
public FastConfig()
1512
{
1613
Add(DefaultConfig.Instance);
1714
AddJob(Job.Default
1815
.WithLaunchCount(1)
19-
.WithWarmupCount(1)
16+
.WithWarmupCount(1)
2017
.WithIterationCount(1)
2118
);
2219
}

CSharp/Clipper2Lib.Benchmark/Clipper2Lib.Benchmark.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp3.1</TargetFramework>
3+
<TargetFramework>net5.0</TargetFramework>
44
<OutputType>Exe</OutputType>
55
</PropertyGroup>
66
<PropertyGroup>

CSharp/Clipper2Lib.Examples/ConsoleDemo/ConsoleDemo.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<TargetFramework>net5.0</TargetFramework>
66
<EnableNETAnalyzers>false</EnableNETAnalyzers>
77
<ApplicationIcon>Clipper2.ico</ApplicationIcon>
88
</PropertyGroup>

CSharp/Clipper2Lib.Examples/ConsoleDemo/Main.cs

-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*******************************************************************************
2-
* *
32
* Author : Angus Johnson *
43
* Date : 17 July 2022 *
54
* Website : http://www.angusj.com *
@@ -14,10 +13,6 @@
1413

1514
namespace ClipperDemo1
1615
{
17-
18-
using Path64 = List<Point64>;
19-
using Paths64 = List<List<Point64>>;
20-
2116
public class Application
2217
{
2318

@@ -71,7 +66,6 @@ public static void ClipTestPolys()
7166
ClipperFileIO.OpenFileWithDefaultApp("..\\..\\..\\clipperD.svg");
7267
}
7368

74-
7569
public static Paths64 LoadPathsFromResource(string resourceName)
7670
{
7771
using Stream stream = Assembly.GetExecutingAssembly().

CSharp/Clipper2Lib.Examples/InflateDemo/InflateDemo.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<TargetFramework>net5.0</TargetFramework>
66
<EnableNETAnalyzers>false</EnableNETAnalyzers>
77
<ApplicationIcon>Clipper2.ico</ApplicationIcon>
88
</PropertyGroup>

CSharp/Clipper2Lib.Examples/InflateDemo/Main.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*******************************************************************************
2-
* *
32
* Author : Angus Johnson *
4-
* Date : 16 May 2022 *
3+
* Date : 16 September 2022 *
54
* Website : http://www.angusj.com *
65
* Copyright : Angus Johnson 2010-2022 *
76
* License : http://www.boost.org/LICENSE_1_0.txt *
@@ -15,10 +14,6 @@
1514
namespace ClipperDemo1
1615
{
1716

18-
using Paths64 = List<List<Point64>>;
19-
using PathD = List<PointD>;
20-
using PathsD = List<List<PointD>>;
21-
2217
public class Application
2318
{
2419

CSharp/Clipper2Lib.Tests/Tests1/Tests/TestLines.cs

-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
2-
using System;
3-
using System.Collections.Generic;
42

53
namespace Clipper2Lib.UnitTests
64
{
7-
using Paths64 = List<List<Point64>>;
85

96
[TestClass]
107
public class TestLines

CSharp/Clipper2Lib.Tests/Tests1/Tests/TestPolygons.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
2-
using System;
3-
using System.Collections.Generic;
42

53
namespace Clipper2Lib.UnitTests
64
{
7-
using Paths64 = List<List<Point64>>;
85

96
[TestClass]
107
public class TestPolygons
@@ -43,9 +40,9 @@ public void TestClosedPaths()
4340
}
4441

4542
if (count > 0 && Math.Abs(solution.Count - count) > 2 &&
46-
(double)Math.Abs(solution.Count - count)/count > 0.02)
43+
(double)Math.Abs(solution.Count - count)/count > 0.03)
4744
{
48-
Assert.IsTrue(Math.Abs(solution.Count - count) < 4,
45+
Assert.IsTrue(Math.Abs(solution.Count - count) <= 4,
4946
string.Format("Incorrect count in test {0}", i));
5047
}
5148

CSharp/Clipper2Lib.Tests/Tests1/Tests/TestPolytree.cs

-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
2-
using System;
3-
using System.Collections.Generic;
42

53
namespace Clipper2Lib.UnitTests
64
{
7-
using Path64 = List<Point64>;
8-
using Paths64 = List<List<Point64>>;
95

106
[TestClass]
117
public class TestPolytree

CSharp/Clipper2Lib.Tests/Tests2/Tests/TestZCallback1.cs

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.IO;
52

63
// USINGZ compiler directive should have been set in project properties
74

85
namespace Clipper2Lib.UnitTests
96
{
10-
using Paths64 = List<List<Point64>>;
11-
using PathsD = List<List<PointD>>;
127

138
[TestClass]
149
public class TestingZ_1
@@ -141,12 +136,12 @@ public void TestSubjClipUnionD()
141136
public void TestMysteryD()
142137
{
143138
ClipperD c = new ClipperD(5);
144-
var bitePoly = new List<PointD>()
139+
var bitePoly = new PathD()
145140
{
146141
new PointD(5, 5, 5), new PointD(10, 5, 5), new PointD(10, 10, 5), new PointD(5, 10, 5)
147142
};
148143

149-
var surfacePoly = new List<PointD>()
144+
var surfacePoly = new PathD()
150145
{
151146
new PointD(0, 0, 5), new PointD(15, 0, 5), new PointD(15, 15, 5), new PointD(0, 15, 5)
152147
};

CSharp/Clipper2Lib/Clipper.Core.cs

+28-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
* Author : Angus Johnson *
3-
* Version : Clipper2 - ver.1.0.3 *
4-
* Date : 23 August 2022 *
3+
* Version : Clipper2 - ver.1.0.4 *
4+
* Date : 16 September 2022 *
55
* Website : http://www.angusj.com *
66
* Copyright : Angus Johnson 2010-2022 *
77
* Purpose : Core structures and functions for the Clipper Library *
@@ -340,9 +340,9 @@ public bool Contains(Rect64 rec)
340340
rec.top >= top && rec.bottom <= bottom;
341341
}
342342

343-
public List<Point64> AsPath()
343+
public Path64 AsPath()
344344
{
345-
List < Point64 > result = new List<Point64>(4);
345+
Path64 result = new Path64(4);
346346
result.Add(new Point64(left, top));
347347
result.Add(new Point64(right, top));
348348
result.Add(new Point64(right, bottom));
@@ -405,6 +405,30 @@ public bool PtIsInside(PointD pt)
405405

406406
}
407407

408+
public class Path64 : List<Point64>
409+
{
410+
public Path64(int reserve = 0) : base(reserve) { }
411+
public Path64(Path64 path) : base(path) { }
412+
}
413+
public class Paths64 : List<Path64>
414+
{
415+
public Paths64(int reserve = 0) : base(reserve) { }
416+
public Paths64(Paths64 paths) : base(paths) { }
417+
}
418+
419+
public class PathD : List<PointD>
420+
{
421+
public PathD(int reserve = 0) : base(reserve) { }
422+
public PathD(PathD path) : base(path) { }
423+
}
424+
425+
public class PathsD : List<PathD>
426+
{
427+
public PathsD(int reserve = 0) : base(reserve) { }
428+
public PathsD(PathsD paths) : base(paths) { }
429+
}
430+
431+
408432
// Note: all clipping operations except for Difference are commutative.
409433
public enum ClipType
410434
{

0 commit comments

Comments
 (0)