Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InflatePaths output and input polygons intersect #407

Closed
ccoustet opened this issue Feb 13, 2023 · 2 comments
Closed

InflatePaths output and input polygons intersect #407

ccoustet opened this issue Feb 13, 2023 · 2 comments

Comments

@ccoustet
Copy link

I offset (negative offset) complex polygons (building footprints from real data) to produce interior walls footprints from exterior wall footprints. Most building wall footprints are correct, but some are broken: interior and exterior polygons intersect.

wall

wall_intersection

In this example, the interior polygon ends with 116 vertices while the exterior one has 117.
Code and output follow.

Paths64 polyline, solution;
Point64 coords[117] = {
{1436297462, 1349601198},
{1436108718, 1347587932},
{1431841014, 1348133192},
{1432029757, 1349936742},
{1432218501, 1352904212},
{1434294682, 1382725714},
{1439862620, 1382128026},
{1441529856, 1398192210},
{1435521516, 1398852813},
{1436653978, 1414350766},
{1437031465, 1419551703},
{1437408952, 1424857498},
{1437786440, 1429733376},
{1443805266, 1429093745},
{1444371497, 1433120276},
{1442054144, 1433445335},
{1442893005, 1440774881},
{1443459236, 1445126472},
{1440953139, 1445441044},
{1441236255, 1447884227},
{1443773809, 1447674511},
{1443836723, 1448209285},
{1445965332, 1447884227},
{1446437192, 1452026102},
{1439296389, 1452560876},
{1440009421, 1461882716},
{1440428851, 1467314340},
{1440995082, 1475807805},
{1451470356, 1474308342},
{1455884861, 1473637253},
{1462868378, 1472588677},
{1462774006, 1470889984},
{1468824289, 1469988209},
{1475010888, 1469075948},
{1474916516, 1467912028},
{1478156616, 1467366769},
{1478261473, 1468541174},
{1481742746, 1468027372},
{1487709143, 1467146568},
{1487719629, 1467366769},
{1495028204, 1466286735},
{1495028204, 1466821509},
{1502724751, 1465835848},
{1507453829, 1465217188},
{1506143109, 1454280540},
{1494000599, 1456094577},
{1494566830, 1460131594},
{1487237284, 1461316485},
{1487048540, 1458349015},
{1474350285, 1459848479},
{1474350285, 1459408077},
{1471288443, 1459848479},
{1471382815, 1460802683},
{1462207775, 1461882716},
{1462113403, 1461033370},
{1449499034, 1462627205},
{1448660173, 1451910758},
{1452550390, 1451585700},
{1451239670, 1440019907},
{1454018396, 1439694848},
{1453357793, 1432910561},
{1450484695, 1433120276},
{1450023322, 1428454113},
{1453263421, 1428013711},
{1453074678, 1426220646},
{1455203287, 1425895588},
{1453347308, 1417832038},
{1465122816, 1416447918},
{1464472699, 1411351839},
{1462501376, 1395853885},
{1455475917, 1396629832},
{1453724795, 1380660019},
{1450621010, 1380974592},
{1448639201, 1358084178},
{1488694804, 1354529505},
{1489166664, 1359950643},
{1493706998, 1359510241},
{1495300833, 1376392315},
{1483787469, 1377619149},
{1484836045, 1386899046},
{1486020936, 1386752246},
{1486587167, 1393316332},
{1492574536, 1392634757},
{1493277082, 1398685041},
{1494493430, 1398580183},
{1495521034, 1407912509},
{1487646228, 1408772342},
{1488673833, 1424270295},
{1492113162, 1423892808},
{1492480164, 1427237765},
{1491934904, 1427332137},
{1492679393, 1434126909},
{1496758354, 1433812337},
{1497230213, 1437629153},
{1498257818, 1448240742},
{1506604483, 1447391396},
{1505943880, 1439956992},
{1503720899, 1440166707},
{1503437783, 1436874179},
{1503154668, 1433696993},
{1505293763, 1433487278},
{1504633160, 1426052874},
{1502955438, 1426168218},
{1502598922, 1422781317},
{1504811418, 1422550630},
{1504433930, 1416825405},
{1503962071, 1410450063},
{1503773327, 1406947820},
{1503112724, 1397930066},
{1502640865, 1391565210},
{1501183345, 1375805112},
{1506059223, 1375312282},
{1503689441, 1344117146},
{1502116577, 1344242975},
{1470638326, 1346853929},
{1465479332, 1347294331},
{1445105500, 1348972052} };
  polyline.push_back(Path64(std::begin(coords), std::end(coords)));
  // offset polyline
  solution = InflatePaths(polyline, -209715, JoinType::Miter, EndType::Polygon);

  //print polyline and inflated solution
  std::cout << polyline << "=====>\n" << solution;


1436297462,1349601198 , 1436108718,1347587932 , 1431841014,1348133192 , 1432029757,1349936742 , 1432218501,1352904212 , 1434294682,1382725714 , 1439862620,1382128026 , 1441529856,1398192210 , 1435521516,1398852813 , 1436653978,1414350766 , 1437031465,1419551703 , 1437408952,1424857498 , 1437786440,1429733376 , 1443805266,1429093745 , 1444371497,1433120276 , 1442054144,1433445335 , 1442893005,1440774881 , 1443459236,1445126472 , 1440953139,1445441044 , 1441236255,1447884227 , 1443773809,1447674511 , 1443836723,1448209285 , 1445965332,1447884227 , 1446437192,1452026102 , 1439296389,1452560876 , 1440009421,1461882716 , 1440428851,1467314340 , 1440995082,1475807805 , 1451470356,1474308342 , 1455884861,1473637253 , 1462868378,1472588677 , 1462774006,1470889984 , 1468824289,1469988209 , 1475010888,1469075948 , 1474916516,1467912028 , 1478156616,1467366769 , 1478261473,1468541174 , 1481742746,1468027372 , 1487709143,1467146568 , 1487719629,1467366769 , 1495028204,1466286735 , 1495028204,1466821509 , 1502724751,1465835848 , 1507453829,1465217188 , 1506143109,1454280540 , 1494000599,1456094577 , 1494566830,1460131594 , 1487237284,1461316485 , 1487048540,1458349015 , 1474350285,1459848479 , 1474350285,1459408077 , 1471288443,1459848479 , 1471382815,1460802683 , 1462207775,1461882716 , 1462113403,1461033370 , 1449499034,1462627205 , 1448660173,1451910758 , 1452550390,1451585700 , 1451239670,1440019907 , 1454018396,1439694848 , 1453357793,1432910561 , 1450484695,1433120276 , 1450023322,1428454113 , 1453263421,1428013711 , 1453074678,1426220646 , 1455203287,1425895588 , 1453347308,1417832038 , 1465122816,1416447918 , 1464472699,1411351839 , 1462501376,1395853885 , 1455475917,1396629832 , 1453724795,1380660019 , 1450621010,1380974592 , 1448639201,1358084178 , 1488694804,1354529505 , 1489166664,1359950643 , 1493706998,1359510241 , 1495300833,1376392315 , 1483787469,1377619149 , 1484836045,1386899046 , 1486020936,1386752246 , 1486587167,1393316332 , 1492574536,1392634757 , 1493277082,1398685041 , 1494493430,1398580183 , 1495521034,1407912509 , 1487646228,1408772342 , 1488673833,1424270295 , 1492113162,1423892808 , 1492480164,1427237765 , 1491934904,1427332137 , 1492679393,1434126909 , 1496758354,1433812337 , 1497230213,1437629153 , 1498257818,1448240742 , 1506604483,1447391396 , 1505943880,1439956992, 1503720899,1440166707 , 1503437783,1436874179 , 1503154668,1433696993 , 1505293763,1433487278 , 1504633160,1426052874 , 1502955438,1426168218 , 1502598922,1422781317 , 1504811418,1422550630 , 1504433930,1416825405 , 1503962071,1410450063 , 1503773327,1406947820 , 1503112724,1397930066 , 1502640865,1391565210 , 1501183345,1375805112 , 1506059223,1375312282 , 1503689441,1344117146 , 1502116577,1344242975 , 1470638326,1346853929 , 1465479332,1347294331 , 1445105500,1348972052 
=====>
1503496278,1344342983 , 1502133301,1344452022 , 1470655661,1347062926 , 1465497170,1347503286 , 1445122711,1349181060 , 1436107808,1349824994 , 1435920162,1347823442 , 1432070925,1348315237 , 1432238333,1349914914 , 1432427793,1352890900 , 1434488770,1382493959 , 1440049489,1381897047 , 1441759968,1398377888 , 1435745407,1399039175 , 1436863135,1414335483 , 1437240630,1419536522 , 1437618138,1424842615 , 1437978871,1429502029 , 1443984706,1428863780 , 1444608383,1433298816 , 1442285746,1433624616 , 1443101360,1440751035 , 1443694381,1445308317 , 1441185371,1445623254 , 1441421217,1447658511 , 1443958419,1447448824 , 1444019640,1447969205 , 1446149039,1447644027 , 1446670234,1452218952 , 1439521512,1452754318 , 1440218525,1461866722 , 1440637944,1467298194 , 1441189285,1475568153 , 1451440640,1474100743 , 1455853342,1473429920 , 1462648393,1472409642 , 1462554010,1470710742 , 1468793373,1469780785 , 1474785985,1468897128 , 1474691934,1467737158 , 1478345342,1467122346 , 1478450602,1468301273 , 1481712126,1467819904 , 1487907606,1466905282 , 1487918090,1467125448 , 1495237919,1466583224 , 1502698111,1465627832 , 1507220917,1465036155 , 1505960573,1454519852 , 1494237150,1456271279 , 1494803038,1460305846 , 1487042658,1461560386 , 1486853299,1458583241 , 1474140570,1460084415 , 1474140570,1459650114 , 1471516886,1460027494 , 1471611772,1460986894 , 1462022653,1462115670 , 1461928480,1461268117 , 1449307122,1462862836 , 1448434817,1451719142 , 1452317687,1451394698 , 1451007759,1439835891 , 1453789733,1439510451 , 1453168903,1433134621 , 1450296109,1433344314 , 1449794730,1428273540 , 1453033557,1427833311 , 1452845163,1426043549 , 1454948224,1425722391 , 1453090456,1417651070 , 1464887984,1416264361 , 1464264670,1411378378 , 1462319365,1396084977 , 1455290328,1396861320 , 1453539001,1380889638 , 1450430433,1381204697 , 1448412217,1357893782 , 1488885513,1354302042 , 1489357223,1359721460 , 1493896022,1359281207 , 1495529095,1376578894 , 1484019554,1377805320 , 1485020632,1386664858 , 1486211168,1386517359 , 1486777583,1393083586 , 1492758717,1392402721 , 1493461913,1398458614 , 1494679469,1398353652 , 1495752464,1408098201 , 1487868780,1408959003 , 1488868602,1424037943 , 1492298753,1423661464 , 1492710122,1427410797 , 1492164832,1427505174 , 1492865741,1433902200 , 1496941912,1433587843 , 1497438344,1437603423 , 1498446242,1448010769 , 1506377265,1447203718 , 1505753650,1440185584 , 1503530071,1440395356 , 1503228839,1436892146 , 1502927331,1433508560 , 1505066477,1433298840 , 1504442462,1426276194 , 1502768048,1426391311 , 1502368384,1422594502 , 1504588874,1422362981 , 1504224669,1416839202 , 1503752928,1410465542 , 1503563916,1406959106 , 1502903569,1397945388 , 1502431724,1391580715 , 1500955372,1375617371 , 1505834616,1375124200 
@AngusJohnson
Copy link
Owner

It looks OK in Delphi and C# so it seems this is a bug specific to C++. I'll investigate.

@AngusJohnson
Copy link
Owner

AngusJohnson commented Feb 15, 2023

The problem is here in clipper.engine.cpp at the bottom of ProcessIntersectList().

CheckJoinLeft(*node.edge2, node.pt, true); // make sure the third parameter = true

As I said this looks OK in the C# and Delphi code.

AngusJohnson added a commit that referenced this issue Feb 16, 2023
Fixed multiple bugs in RectClip and RectClipLines (#410)
Fixed null warnings in C# code (#414)
Fixed missing units in DelphiBenchmark example (#406)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants