Skip to content

Instantly share code, notes, and snippets.

@afabri
Created February 1, 2023 15:58
Show Gist options
  • Save afabri/6b3577b1c7f39ceede963b0ae739c699 to your computer and use it in GitHub Desktop.
Save afabri/6b3577b1c7f39ceede963b0ae739c699 to your computer and use it in GitHub Desktop.
Issue 7325
// Created by Dominik Krupke on 14.11.22.
//
#include <vector>
#include <iterator>
#include <iostream>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Boolean_set_operations_2.h>
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <CGAL/draw_polygon_2.h>
#include <CGAL/Arr_tracing_traits_2.h>
int main(int argc, char **argv) {
using Kernel = CGAL::Epeck;
using Traits = CGAL::Gps_segment_traits_2<Kernel>;
using FT = Kernel::FT;
using Pt = CGAL::Point_2<Kernel>;
using Polygon2 = CGAL::Polygon_2<Kernel>;
using Polygon_with_holes_2 = CGAL::Polygon_with_holes_2<Kernel>;
std::vector<std::vector<Pt>> solution =
{
{Pt(FT(1415),FT(1253)),Pt(FT(1416),FT(1250)),Pt(FT(1422),FT(1239)),Pt(FT(1426),FT(1235)),Pt(FT(2955)/FT(2),FT(1235)),Pt(FT(1492),FT(1236)),Pt(FT(1520),FT(1240)),Pt(FT(1549),FT(1268)),Pt(FT(1545),FT(1288)),Pt(FT(103109)/FT(67),FT(86557)/FT(67)),Pt(FT(367699)/FT(257),FT(325697)/FT(257)),Pt(FT(1428),FT(1265))},
{Pt(FT(1415),FT(1253)),Pt(FT(1416),FT(1250)),Pt(FT(1491),FT(1281)),Pt(FT(1511),FT(1291)),Pt(FT(1514),FT(1298)),Pt(FT(1490),FT(1298)),Pt(FT(1447),FT(1281)),Pt(FT(1428),FT(1265))},
{Pt(FT(1417),FT(1095)),Pt(FT(1420),FT(1053)),Pt(FT(1114793)/FT(780),FT(129697)/FT(130)),Pt(FT(1344021)/FT(916),FT(472663)/FT(458)),Pt(FT(1442),FT(1097)),Pt(FT(1431),FT(1112))},
{Pt(FT(1202758)/FT(859),FT(2299113)/FT(1718)),Pt(FT(1492),FT(1236)),Pt(FT(1514),FT(1213)),Pt(FT(1524),FT(1221)),Pt(FT(1520),FT(1240)),Pt(FT(1442),FT(1335)),Pt(FT(1422),FT(1358)),Pt(FT(1417),FT(1356))},
{Pt(FT(1418),FT(1366)),Pt(FT(1422),FT(1358)),Pt(FT(1442),FT(1337)),Pt(FT(1465),FT(1356)),Pt(FT(1471),FT(1388)),Pt(FT(1469),FT(1393)),Pt(FT(1461),FT(1394)),Pt(FT(1437),FT(1382))},
{Pt(FT(2105885)/FT(1491),FT(488294)/FT(497)),Pt(FT(1516),FT(1076)),Pt(FT(201940)/FT(133),FT(1082)),Pt(FT(1463),FT(1082)),Pt(FT(1449),FT(1079)),Pt(FT(1421),FT(1047))},
{Pt(FT(1421),FT(1221)),Pt(FT(1434),FT(1182)),Pt(FT(1445),FT(1178)),Pt(FT(1463),FT(1234)),Pt(FT(1484),FT(1319)),Pt(FT(1487),FT(1339)),Pt(FT(1477),FT(1347)),Pt(FT(1447),FT(1281)),Pt(FT(1427),FT(1235))},
{Pt(FT(1421),FT(1221)),Pt(FT(1445),FT(1178)),Pt(FT(1471),FT(1164)),Pt(FT(1473),FT(1164)),Pt(FT(1468),FT(1207)),Pt(FT(1463),FT(1234)),Pt(FT(1447),FT(1281)),Pt(FT(122957)/FT(85),FT(108853)/FT(85))},
{Pt(FT(1212998)/FT(857),FT(1348403)/FT(857)),Pt(FT(1425),FT(1535)),Pt(FT(1445),FT(1533)),Pt(FT(4969321)/FT(3433),FT(5400965)/FT(3433))},
{Pt(FT(1425),FT(1535)),Pt(FT(1426),FT(1517)),Pt(FT(1440),FT(1466)),Pt(FT(1450),FT(1450)),Pt(FT(1463),FT(1450)),Pt(FT(1510),FT(1479)),Pt(FT(1511),FT(1501)),Pt(FT(1496),FT(1525)),Pt(FT(1471),FT(1529)),Pt(FT(1445),FT(1533))},
{Pt(FT(1429),FT(1115)),Pt(FT(1431),FT(1112)),Pt(FT(1443),FT(1101)),Pt(FT(279411)/FT(191),FT(622855)/FT(573)),Pt(FT(1471),FT(1110)),Pt(FT(1470),FT(1138)),Pt(FT(1452),FT(1138))},
{Pt(FT(255757)/FT(181),FT(251537)/FT(181)),Pt(FT(1437),FT(1382)),Pt(FT(1471),FT(1388)),Pt(FT(1475),FT(1389)),Pt(FT(1486),FT(1394))},
{Pt(FT(1442),FT(1335)),Pt(FT(1448),FT(1285)),Pt(FT(1463),FT(1234)),Pt(FT(1492),FT(1236)),Pt(FT(1491),FT(1281)),Pt(FT(1490),FT(1298)),Pt(FT(1484),FT(1319)),Pt(FT(1468),FT(1336))},
{Pt(FT(1447),FT(1281)),Pt(FT(1520),FT(1240)),Pt(FT(433483)/FT(277),FT(340775)/FT(277)),Pt(FT(1569),FT(1249)),Pt(FT(1569),FT(36642)/FT(29)),Pt(FT(1491),FT(1281)),Pt(FT(1448),FT(1285))},
{Pt(FT(1452),FT(1549)),Pt(FT(1453),FT(1534)),Pt(FT(1469),FT(1544)),Pt(FT(186758)/FT(127),FT(197258)/FT(127))},
{Pt(FT(1452),FT(1549)),Pt(FT(1453),FT(1534)),Pt(FT(1470),FT(1550)),Pt(FT(1474),FT(1554))},
{Pt(FT(1458),FT(1144)),Pt(FT(81024)/FT(53),FT(58757)/FT(53)),Pt(FT(1594124)/FT(1035),FT(1177766)/FT(1035)),Pt(FT(1477),FT(1156))},
// {Pt(FT(29351)/FT(20),FT(1339)),Pt(FT(1468),FT(1336)),Pt(FT(1484),FT(1319)),Pt(FT(1569),FT(1319)),Pt(FT(1569),FT(1339))},
{Pt(FT(1470),FT(1138)),Pt(FT(1471),FT(1110)),Pt(FT(324697)/FT(215),FT(230218)/FT(215)),Pt(FT(1516),FT(1076)),Pt(FT(291188)/FT(187),FT(220896)/FT(187)),Pt(FT(1519),FT(1166))},
// {Pt(FT(1483),FT(1207)),Pt(FT(1519),FT(1187)),Pt(FT(1530),FT(1186)),Pt(FT(1530),FT(1205)),Pt(FT(1523),FT(1212)),Pt(FT(8915) / FT(6),FT(65671) / FT(54))},
{Pt(FT(16370)/FT(11),FT(12021)/FT(11)),Pt(FT(1489),FT(1092)),Pt(FT(1516),FT(1076)),Pt(FT(296192)/FT(193),FT(2819517)/FT(2509)),Pt(FT(1492),FT(1173))},
// {Pt(FT(1934050)/FT(1281),FT(1663411)/FT(1281)),Pt(FT(122482)/FT(81),FT(105157)/FT(81)),Pt(FT(1532),FT(1497)),Pt(FT(1529),FT(1477))},
{Pt(FT(1519),FT(1187)),Pt(FT(845924)/FT(551),FT(32632)/FT(29)),Pt(FT(1281052)/FT(823),FT(970934)/FT(823)),Pt(FT(1530),FT(1186))},
// {Pt(FT(1543),FT(1207)),Pt(FT(1548),FT(1202)),Pt(FT(1564),FT(1226)),Pt(FT(1569),FT(1249)),Pt(FT(1569),FT(1308)),Pt(FT(1549),FT(1268)),Pt(FT(1543),FT(1235))}
};
std::vector<Polygon2> polys;
for(auto boundary: solution){
//Polygon2 pp(boundary.begin(), boundary.end());
//assert(pp.is_simple());
polys.push_back(Polygon2(boundary.begin(),boundary.end()));
}
std::cout << polys.size() << std::endl;
std::vector<Polygon_with_holes_2> coverage;
typename CGAL::Gps_default_traits<Polygon_with_holes_2>::Traits traits;
CGAL::join(polys.begin(),polys.end(), std::back_inserter(coverage));
std::cout << coverage.size() << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment