Menu

#106 Can't union identical polygons where both PolyTypes as Subject

*
closed
nobody
None
1
2014-08-31
2014-08-29
No

When you try to union two identical polygons (rectangles in this example) setting both as Subject , the solution polygon is null.

using Polygon = List<IntPoint>;
using Polygons = List<List<IntPoint>>;

public void run() {
Polygons subj = new Polygons(2);
subj.Add(new Polygon(4));
subj[0].Add(new IntPoint(30, 30));
subj[0].Add(new IntPoint(30, 250));
subj[0].Add(new IntPoint(250, 250));
subj[0].Add(new IntPoint(250, 30));

        subj.Add(new Polygon(4));
        subj[1].Add(new IntPoint(30, 30));
        subj[1].Add(new IntPoint(30, 250));
        subj[1].Add(new IntPoint(250, 250));
        subj[1].Add(new IntPoint(250, 30));

        Polygons solution = new Polygons();

        Clipper c = new Clipper();
        c.AddPaths(subj, PolyType.ptSubject, true);
        c.Execute(ClipType.ctUnion, solution);

}

Related

Bugs: #106

Discussion

  • Angus Johnson

    Angus Johnson - 2014-08-29

    Hi Joseph. There is no bug. Since you haven't specified a polygon fill type in the Execute method, it defaults to PolyFillType.pftEvenOdd. Consequently the second fill correctly erases the first. If you set the fill type to PolyFillType.pftNonZero you'll get the result you're expecting.

     
    • Ignorant

      Ignorant - 2014-08-30

      Angus,
      does it mean that odd even filltype op s on the intersection of the
      subject contours/paths.?
      Mahesh naik

      On Sat, Aug 30, 2014 at 2:37 AM, Angus Johnson angusj@users.sf.net wrote:

      Hi Joseph. There is no bug. Since you haven't specified a polygon fill
      type in the Execute method, it defaults to PolyFillType.pftEvenOdd.
      Consequently the second fill correctly erases the first. If you set the
      fill type to PolyFillType.pftNonZero you'll get the result you're expecting.


      Status: open
      Group:
      Created: Fri Aug 29, 2014 07:56 PM UTC by Joseph Werick
      Last Updated: Fri Aug 29, 2014 07:56 PM UTC
      Owner:* nobody

      When you try to union two identical polygons (rectangles in this example)
      setting both as Subject , the solution polygon is null.

      using Polygon = List<IntPoint>;
      using Polygons = List<List<IntPoint>>;

      public void run() {
      Polygons subj = new Polygons(2);
      subj.Add(new Polygon(4));
      subj[0].Add(new IntPoint(30, 30));
      subj[0].Add(new IntPoint(30, 250));
      subj[0].Add(new IntPoint(250, 250));
      subj[0].Add(new IntPoint(250, 30));

          subj.Add(new Polygon(4));
          subj[1].Add(new IntPoint(30, 30));
          subj[1].Add(new IntPoint(30, 250));
          subj[1].Add(new IntPoint(250, 250));
          subj[1].Add(new IntPoint(250, 30));
      
          Polygons solution = new Polygons();
      
          Clipper c = new Clipper();
          c.AddPaths(subj, PolyType.ptSubject, true);
          c.Execute(ClipType.ctUnion, solution);
      

      }

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/polyclipping/bugs/106/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #106

  • Angus Johnson

    Angus Johnson - 2014-08-29
    • status: open --> closed
     
  • Joseph Werick

    Joseph Werick - 2014-08-30

    Thanks for your quick response, I understand now. Off to read more...

     

Anonymous
Anonymous

Add attachments
Cancel