我想用clipper库剪辑平行线 [英] I want to clip parallel lines with clipper library
本文介绍了我想用clipper库剪辑平行线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用C ++的限幅器库。
I想要用多边形剪切平行线。
看下面的代码。
I use clipper library with C++.
I want to clip parallel lines with a polygon.
look below code.
Paths subj(2), clip(1), solution;
subj[0] <<IntPoint(0, 100) << IntPoint(100, 100);
subj[1] <<IntPoint(0, 50) << IntPoint(100, 50);
clip[0] <<IntPoint(30,0) << IntPoint(35,200) <<IntPoint(40,210) << IntPoint(45,40);
Clipper c;
c.AddPaths(subj, ptSubject, true);
c.AddPaths(clip, ptClip, true);
c.Execute(ctIntersection, solution, pftNonZero, pftNonZero);
但是解决方案的大小
是执行以下指令后为零
c.Execute(ctIntersection,solution,pftNonZero,pftNonZero)
。
为什么?问题在哪里?
but size of solution
is zero after execute below instruction
c.Execute(ctIntersection, solution, pftNonZero, pftNonZero)
.
for what? problem is where?
推荐答案
虽然你发布的链接不起作用,但我能在这里找到这个库: http://www.angusj.com/delphi/clipper.php [ ^ ]。在此页面上: http://www.angusj。 com / delphi / clipper / documentation / Docs / Units / ClipperLib / Classes / Clipper / Methods / Execute.htm [ ^ ]文档说明
Although the link you posted didn't work, I was able to find the library here: http://www.angusj.com/delphi/clipper.php[^]. On this page: http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Classes/Clipper/Methods/Execute.htm[^] the documentation states that
Quote:
当打开路径传递给Clipper对象时,用户必须使用PolyTree对象作为解决方案参数,否则将引发异常。
when open paths are passed to a Clipper object, the user must use a PolyTree object as the solution parameter, otherwise an exception will be raised.
因此,您必须将路径定义为封闭路径,或者您应将解决方案定义为 PolyTree
而不是使用路径
类型。
我的路径(平行线)是打开的,所以我不能用这个库做这个工作。看看这个链接。
我改了线条到三角形,然后我剪辑它们。
当我想绘制它们时,我画平行线。
My paths(parallel lines) are open, so I can't do this work with this library. look this link.
I changed lines to triangles and then I clip their.
when I want to draw their, just I draw parallel lines.
这篇关于我想用clipper库剪辑平行线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文