Replies: 10 comments 6 replies
-
If there's a chorus of people suggesting that I change point x & y to X & Y, then I'll happily oblige. |
Beta Was this translation helpful? Give feedback.
-
Migration is an important issue. I'm still strugling. Regarding the .x VS .X I can't think of anything smarter than 'replace all .X'. |
Beta Was this translation helpful? Give feedback.
-
I tried to support both versions with macros that let you choose which version to use, but it is too complex. enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor }; VS enum class ClipType { None, Intersection, Union, Difference, Xor }; Next try I'll try to replace Clipper1 with 2 unconditionaly. See how that goes and update. |
Beta Was this translation helpful? Give feedback.
-
Clipper2 was never intended to be backward compatible. In Clipper1 I tried to keep naming close to my original Delphi naming as I thought that that would make support easier. But in practise, this wasn't the case and it just IMHO made the C++ and C# code look odd. So in Clipper2, I've been more flexible with naming. Function names are generally the same in each of the 3 languages. But constants, variables, enums etc will now have a more language specific style. Anyhow, for the majority of users the functions in |
Beta Was this translation helpful? Give feedback.
-
I'm writing down what I've done to migrate to Clipper2, work in progress.
more changes and things I've noticed:
By now I've compiled my library, but tests are failing. More to come. |
Beta Was this translation helpful? Give feedback.
-
More changes I needed to do
By now I finished migrating my library that wraps Clipper, and all 84 tests pass. This is the stress test. It creating a grid of circles and xoring them with eachother. Stopwatch watch("test clipper lib");
Polygons polys;
Micron radius = 1000;
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 20; j++) {
polys = polys ^ PolyUtils::CreateCircle({radius * i * 75 / 100, radius * j * 75 / 100}, radius);
}
cout << "round " << i << ", area = " << polys.area() << "\n";
}
SvgWriter svg(DOC_FILE_NAME);
svg.Add(polys);
polys += radius;
polys -= radius;
|
Beta Was this translation helpful? Give feedback.
-
Yes, I should better document this. Edit: I've now added this to the documentation:
|
Beta Was this translation helpful? Give feedback.
-
Huh??? Edit: Oops, the attachment was missing a crucial file. Fixed now. Anyhow, Clipper2 comfortable out performs Clipper1 in this test and the time differences become more dramatic if you increase the i & j loop counts to 30 or 40. |
Beta Was this translation helpful? Give feedback.
-
Take a look, this is my stress test based on your solution. void stressTest() {
int64_t radius = 1000;
{
Timer t("starting Clipper1 ...");
ClipperLib::Paths polys;
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 20; j++) {
ClipperLib::Path e = Ellipse(IntPoint(radius * i * 75 / 100, radius * j * 75 / 100), radius);
Clipper c;
c.AddPath(e, PolyType::ptSubject, true);
c.AddPaths(polys, PolyType::ptClip, true);
c.Execute(ClipperLib::ClipType::ctXor, polys, PolyFillType::pftEvenOdd);
}
}
}
{
Timer t("starting Clipper2 ...");
Paths64 polys64;
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 20; j++) {
Path64 e = Ellipse(Point64(radius * i * 75 / 100, radius * j * 75 / 100), radius);
Clipper64 c64;
c64.AddSubject({ e });
c64.AddClip(polys64);
c64.Execute(Clipper2Lib::ClipType::Xor, FillRule::EvenOdd, polys64);
}
}
}
}
int main()
{
std::cout.imbue(std::locale(""));
srand((unsigned)time(0));
stressTest();
return 0; BTW, I've noticed there is no |
Beta Was this translation helpful? Give feedback.
-
The following pseudocode explains what ISTM you're "stress test" is doing:
I really don't understand how this is "stress testing" anything (except the Clipper constructors and their AddPath methods). Edit: While some of your suggestions in this thread have merit, the way you are going about it I'm finding pretty annoying. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a wrapper library clipper. (It's called
amlib
, for additive manufacturing, hope to go opensource someday).I'm trying to migrate, but it's too hard.
For example, at Clipper1,
Point.X/Y
(uppercase), at Clipper2Point.x/y
(lowercase).please advice.
Beta Was this translation helpful? Give feedback.
All reactions