Hi!
I'm using Clipper version 6.1.5 of 28 March 2014 in c++. Trying to join polygons using Z values I found the following:
/* +----------+ +----------+ | | | | | b | | | +-----------+---+ | +-----------+ | | | | | Union | | | +---+------+ ------> | +------+ | | | | | a | | expected | | | | | | | | | +---------------+ +---------------+ */ Path a, b; a << IntPoint(0,0,0) << IntPoint(10,0,0) << IntPoint(10,10,0) << IntPoint(0,10,0); b << IntPoint(8,8,0) << IntPoint(14,8,0) << IntPoint(14,14,0) << IntPoint(8,14,0); Clipper c; c.AddPath(a, ptSubject, true); c.AddPath(b, ptClip, true); Paths solution; c.Execute(ctUnion, solution, pftNonZero, pftNonZero); cout << endl; for (IntPoint ip : solution[0]) cout << ip.X << ", " << ip.Y << ", " << ip.Z << endl;
The above code produces a correct result:
10, 8, 0 14, 8, 0 14, 14, 0 8, 14, 0 8, 10, 0 0, 10, 0 0, 0, 0 10, 0, 0
But then I try to do the same using 10 for all Z values:
Path a10, b10; a10 << IntPoint(0,0,10) << IntPoint(10,0,10) << IntPoint(10,10,10) << IntPoint(0,10,10); b10 << IntPoint(8,8,10) << IntPoint(14,8,10) << IntPoint(14,14,10) << IntPoint(8,14,10); Clipper c10; c10.AddPath(a10, ptSubject, true); c10.AddPath(b10, ptClip, true); Paths solution10; c10.Execute(ctUnion, solution10, pftNonZero, pftNonZero); cout << endl; for (IntPoint ip : solution10[0]) cout << ip.X << ", " << ip.Y << ", " << ip.Z << endl;
And the result is:
10, 8, 0 14, 8, 10 14, 14, 10 8, 14, 10 8, 10, 0 0, 10, 10 0, 0, 10 10, 0, 10
Where the first and fifth Z values should be 10.
Is there anything I'm doing wrong? JL
Some additional information:
The union of two adjacent rectangles works when Z values are 0:
Path a1, b1; a1 << IntPoint( 0,0,0) << IntPoint(10,0,0) << IntPoint(10,10,0) << IntPoint( 0,10,0); b1 << IntPoint(10,0,0) << IntPoint(15,0,0) << IntPoint(15,10,0) << IntPoint(10,10,0); Clipper c1; c1.AddPath(a1, ptSubject, true); c1.AddPath(b1, ptClip, true); Paths solution1; c1.Execute(ctUnion, solution1, pftNonZero, pftNonZero); cout << endl; for (IntPoint ip : solution1[0]) cout << ip.X << ", " << ip.Y << ", " << ip.Z << endl;
Produces a correct result:
0, 0, 0 15, 0, 0 15, 10, 0 0, 10, 0
But when the Y dimension is interchanged with the Z dimension:
Path a2, b2, e2; a2 << IntPoint( 0,0,0) << IntPoint(10,0,0) << IntPoint(10,0,10) << IntPoint( 0,0,10); b2 << IntPoint(10,0,0) << IntPoint(15,0,0) << IntPoint(15,0,10) << IntPoint(10,0,10); Clipper c2; c2.AddPath(a2, ptSubject, true); c2.AddPath(b2, ptClip, true); Paths solution2; c2.Execute(ctUnion, solution2, pftNonZero, pftNonZero); cout << endl; for (IntPoint ip : solution2[0]) cout << ip.X << ", " << ip.Y << ", " << ip.Z << endl;
In this case the solution is empty.
Should I avoid using 3d values and project evey polygon onto a 2d surface instead?
José Luis Esteban: You may have misunderstood the meaning of Z. It is not Z dimension like in 3D. Z is used to maintain relation between input and output vertices. More information about Z member: http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Classes/Clipper/Properties/ZFillFunction.htm
It should be eg. R (relation) instead of Z, which is confusing because Z is used as dimension in 3D programs.
You are right. I read http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/PreProcessor/Defines.htm and I understood polygons in 3d could be used.
Thank you!
Yes, I can see that Z is confusing and I'm considering changing it to U (user defined).
Hi!
I'm using Clipper version 6.1.5 of 28 March 2014 in c++.
Trying to join polygons using Z values I found the following:
The above code produces a correct result:
But then I try to do the same using 10 for all Z values:
And the result is:
Where the first and fifth Z values should be 10.
Is there anything I'm doing wrong?
JL
Some additional information:
The union of two adjacent rectangles works when Z values are 0:
Produces a correct result:
But when the Y dimension is interchanged with the Z dimension:
In this case the solution is empty.
Should I avoid using 3d values and project evey polygon onto a 2d surface instead?
José Luis Esteban: You may have misunderstood the meaning of Z. It is not Z dimension like in 3D. Z is used to maintain relation between input and output vertices. More information about Z member:
http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Classes/Clipper/Properties/ZFillFunction.htm
It should be eg. R (relation) instead of Z, which is confusing because Z is used as dimension in 3D programs.
Last edit: Timo Kähkönen 2014-05-20
You are right. I read http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/PreProcessor/Defines.htm and I understood polygons in 3d could be used.
Thank you!
Yes, I can see that Z is confusing and I'm considering changing it to U (user defined).