Menu

#148 How to let the Clipper operate without deleting important points in original polygons?

*
open
nobody
None
1
2015-12-30
2015-12-27
Anonymous
No

Dear all,

I have two polygons:
first A:
16
-1535495880 -1541273642
-1535495880 795188567
-1535495880 1413663857
-1535495880 211073015
-1535495880 829548305
-1535495880 1654413275
-1535495880 -1713303583
-1535495880 176713276
918406642 176713276
918406642 2135218363
918406642 1516743073
918406642 -1575633381
918406642 2100858625
918406642 1275993655
918406642 348743217
918406642 -1541273642

second B:
7
-370321410 -649651205
555026919 1339863428
-1535495880 1413663857
-1535495880 211073015
-866995776 1765760360
1110339441 852756938
1223528831 145771704

then I make operation
A - B

the result is
11
918406642 176713276
918406642 -1541273642
-1535495880 -1541273642
-1535495880 1413663857
555026919 1339863428
-370321410 -649651205
1223528831 145771704
1110339441 852756938
-866995776 1765760360
-1535495880 211073015
-1535495880 176713276

The result is correct but it deleted all middle points that are on a line. However, these points are important points for me. How to let the Clipper work without deleting important points?

Thanks,
Tang Laoya

Discussion

  • Anonymous

    Anonymous - 2015-12-28

    You can instantiate the Clipper object with the flag ioPreserveCollinear as first argument to Clipper(), this should keep the middle points.

    And if you happen to get the same problem with offsetting, too, try adding significant but invisible differences to the points, since ClipperOffset seems to have no ioPreserveCollinear option, afaik. I'm not sure about that.

     
  • Anonymous

    Anonymous - 2015-12-28

    That's great! Thank you very much!

     
  • Anonymous

    Anonymous - 2015-12-30

    I set the flag ioPreserveCollinear to Clipper() and tested the following two polygons, the result is wrong. Could anyone help me to take a look at it?

    Thanks,
    Tang Laoya

    polygon 1 (A):
    10
    -1541273642 -1831285569
    795188567 -1831285569
    1413663857 -1831285569
    211073015 -1831285569
    829548305 -1831285569
    1654413275 -1831285569
    -1713303583 -1831285569
    176713276 -1831285569
    176713276 2120603822
    -1541273642 2120603822

    polygon 2 (B):
    7
    211073015 -1831285569
    -598305483 1401500626
    -1879913943 -853325489
    408883151 -921073854
    1492674740 -490667425
    -327926577 141107247
    1413663857 -1831285569

    then I make operation
    A - B

    the results are two polygons with
    10
    176713276 2120603822
    -1541273642 2120603822
    -1541273642 -1831285569
    795188567 -1831285569
    1413663857 -1831285569
    211073015 -1831285569
    829548305 -1831285569
    1654413275 -1831285569
    -1713303583 -1831285569
    176713276 -1831285569
    and
    7
    1413663857 -1831285569
    -327926577 141107247
    1492674740 -490667425
    408883151 -921073854
    -1879913943 -853325489
    -598305483 1401500626
    211073015 -1831285569

     

Anonymous
Anonymous

Add attachments
Cancel