Что-то не так с моим кодом: «обрезать многоугольник (точки эллипса) с отрезками (предметом) с помощью библиотеки обрезки в c #» - PullRequest
3 голосов
/ 29 марта 2019

1. Я рисую эллипс и линии на PictureBox.
2. Я получаю счет объекта Paths как ноль после выполнения clipper.PolyTreeToPaths(polytree_solution); см. Содержание
3. PolyTree объект содержит это см. Содержимое .

Я знаю, что мой вопрос похож на эти ссылки, но я не смог найти решение проблемы, возможно, я не смог найти неправильный в коде. link1 link2 link3

//adding subject (lines)
Paths subj=new Paths(1);
subj.Add(new Path());
subj[0].Add(new IntPoint(0,0));
subj[0].Add(new IntPoint(440,280));
subj[0].Add(new IntPoint(440,0));
subj[0].Add(new IntPoint(0,280));
subj[0].Add(new IntPoint(440/2,280));
subj[0].Add(new IntPoint(440/2,0));

//for clip, GraphicsPath object is defined properly by ellipse points by help of mouse events
GraphicsPath path=new GraphicsPath();
path.AddEllipse(m_rectArena);

Paths clip=new Paths(1);
int scale=100;
path.Flatten();
Path clip2=new Path(path.PointCount);
foreach(PointF p in path.PathPoints)
{
  clip2.Add(new IntPoint((int)(p.X*scale),(int)(p.Y*scale)));
}
clip.Add(clip2);
Paths solution=new Paths();
PolyTree polytree_solution=new PolyTree();
Clipper c=new Clipper();
c.AddPath(subj[0],PolyTree.ptSubject,false);
c.AddPaths(clip,PolyType.ptClip,true);
c.Execute(ClipType.ctIntersection,polytree_solution,PolyFilllType.pftEvenOdd,PolyFillType.pftEvenOdd);
Paths openp=Clipper.PolyTreeToPaths(polytree_solution);


1.Я хочу ct.Intersection строк (предмет) и круга (клип), но этого не происходит рис. Нажмите здесь .
2. Актуальный рисунок на PictureBox нажмите здесь

...