Skip to content

Commit d10ad59

Browse files
committed
InflatePaths function (C# only) - added missing arcTolerance parameter.
Updated clipper.export.h documention.
1 parent 4ab4da0 commit d10ad59

2 files changed

Lines changed: 36 additions & 30 deletions

File tree

CPP/Clipper2Lib/include/clipper2/clipper.export.h

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*******************************************************************************
22
* Author : Angus Johnson *
3-
* Date : 17 September 2024 *
3+
* Date : 24 January 2025 *
44
* Website : http://www.angusj.com *
5-
* Copyright : Angus Johnson 2010-2024 *
5+
* Copyright : Angus Johnson 2010-2025 *
66
* Purpose : This module exports the Clipper2 Library (ie DLL/so) *
77
* License : http://www.boost.org/LICENSE_1_0.txt *
88
*******************************************************************************/
@@ -19,38 +19,43 @@
1919
2020
The path structures used extensively in other parts of this library are all
2121
based on std::vector classes. Since C++ classes can't be accessed by other
22-
languages, these paths are converted here into very simple array data
23-
structures that can be parsed by just about any programming language.
22+
languages, these paths are exported here as very simple array structures
23+
(either of int64_t or double) that can be parsed by just about any
24+
programming language.
2425
2526
These 2D paths are defined by series of x and y coordinates together with an
2627
optional user-defined 'z' value (see Z-values below). Hence, a vertex refers
27-
to a single x and y coordinate (+/- a user-defined value). These values will
28-
be either type int64_t or type double. Data structures have names that
29-
indicate the array type by a suffixed '64' or a 'D'. For example, the data
30-
structure CPath64 contains an array of int64_t values, whereas the data
31-
structure CPathD contains an array of double. Where documentation omits
32-
the type suffix (eg CPath), it is simply agnostic to the array's data type.
28+
to a single x and y coordinate (+/- a user-defined value). Data structures
29+
have names with suffixes that indicate the array type (either int64_t or
30+
double). For example, the data structure CPath64 contains an array of int64_t
31+
values, whereas the data structure CPathD contains an array of double.
32+
Where documentation omits the type suffix (eg CPath), it is referring to an
33+
array whose data type could be either int64_t or double.
3334
3435
For conciseness, the following letters are used in the diagrams below:
3536
N: Number of vertices in a given path
36-
C: Count of structure's paths
37-
A: Array size (as distinct from the size in memory)
37+
C: Count (ie number) of paths (or PolyPaths) in the structure
38+
A: Number of elements in an array
3839
3940
4041
CPath64 and CPathD:
41-
These are arrays of consecutive vertices preceeded by a pair of values
42-
containing the number of vertices (N) in the path, and a 0 value.
42+
These are arrays of either int64_t or double values. Apart from
43+
the first two elements, these arrays are a series of vertices
44+
that together define a path. The very first element contains the
45+
number of vertices (N) in the path, while second element should
46+
contain a 0 value.
4347
_______________________________________________________________
4448
| counters | vertex1 | vertex2 | ... | vertexN |
4549
| N, 0 | x1, y1, (z1) | x2, y2, (z2) | ... | xN, yN, (zN) |
4650
---------------------------------------------------------------
4751
4852
4953
CPaths64 and CPathsD:
50-
These are also arrays containing any number of consecutive CPath
51-
structures. Preceeding these consecutive paths, there is a pair of
52-
values that contain the length of the array structure (A) and
53-
the count of following CPath structures (C).
54+
These are also arrays of either int64_t or double values that
55+
contain any number of consecutive CPath structures. However,
56+
preceeding the first path is a pair of values. The first value
57+
contains the length of the entire array structure (A), and the
58+
second contains the number (ie count) of contained paths (C).
5459
Memory allocation for CPaths64 = A * sizeof(int64_t)
5560
Memory allocation for CPathsD = A * sizeof(double)
5661
__________________________________________
@@ -60,12 +65,13 @@ __________________________________________
6065
6166
6267
CPolytree64 and CPolytreeD:
63-
These structures consist of two values followed by a series of CPolyPath
64-
structures. The first value indicates the total length of the array (A).
65-
The second value indicates the number of following CPolyPath structures
66-
that are the top level CPolyPath in the CPolytree (C). These CPolyPath
67-
may, in turn, contain their own nested CPolyPath children that
68-
collectively make a tree structure.
68+
The entire polytree structure is an array of int64_t or double. The
69+
first element in the array indicates the array's total length (A).
70+
The second element indicates the number (C) of CPolyPath structures
71+
that are the TOP LEVEL CPolyPath in the polytree, and these top
72+
level CPolyPath immediately follow these first two array elements.
73+
These top level CPolyPath structures may, in turn, contain nested
74+
CPolyPath children, and these collectively make a tree structure.
6975
_________________________________________________________
7076
| counters | CPolyPath1 | CPolyPath2 | ... | CPolyPathC |
7177
| A, C | | | ... | |

CSharp/Clipper2Lib/Clipper.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*******************************************************************************
22
* Author : Angus Johnson *
3-
* Date : 10 October 2024 *
3+
* Date : 22 January 2025 *
44
* Website : http://www.angusj.com *
5-
* Copyright : Angus Johnson 2010-2024 *
5+
* Copyright : Angus Johnson 2010-2025 *
66
* Purpose : This module contains simple functions that will likely cover *
77
* most polygon boolean and offsetting needs, while also avoiding *
88
* the inherent complexities of the other modules. *
@@ -138,22 +138,22 @@ public static void BooleanOp(ClipType clipType,
138138
}
139139

140140
public static Paths64 InflatePaths(Paths64 paths, double delta, JoinType joinType,
141-
EndType endType, double miterLimit = 2.0)
141+
EndType endType, double miterLimit = 2.0, double arcTolerance = 0.0)
142142
{
143-
ClipperOffset co = new ClipperOffset(miterLimit);
143+
ClipperOffset co = new ClipperOffset(miterLimit, arcTolerance);
144144
co.AddPaths(paths, joinType, endType);
145145
Paths64 solution = new Paths64();
146146
co.Execute(delta, solution);
147147
return solution;
148148
}
149149

150150
public static PathsD InflatePaths(PathsD paths, double delta, JoinType joinType,
151-
EndType endType, double miterLimit = 2.0, int precision = 2)
151+
EndType endType, double miterLimit = 2.0, int precision = 2, double arcTolerance = 0.0)
152152
{
153153
InternalClipper.CheckPrecision(precision);
154154
double scale = Math.Pow(10, precision);
155155
Paths64 tmp = ScalePaths64(paths, scale);
156-
ClipperOffset co = new ClipperOffset(miterLimit);
156+
ClipperOffset co = new ClipperOffset(miterLimit, arcTolerance);
157157
co.AddPaths(tmp, joinType, endType);
158158
co.Execute(delta * scale, tmp); // reuse 'tmp' to receive (scaled) solution
159159
return ScalePathsD(tmp, 1 / scale);

0 commit comments

Comments
 (0)