Ticket #12608: test.cpp

File test.cpp, 22.6 KB (added by shroman@…, 6 years ago)

Reproduction code

Line 
1#include <vector>
2#include <iostream>
3#include <boost/polygon/polygon.hpp>
4#include <boost/polygon/segment_concept.hpp>
5#include <boost/foreach.hpp>
6
7using namespace std;
8using namespace boost;
9using namespace boost::polygon;
10using namespace boost::polygon::operators;
11
12
13typedef point_data<long double> BPoint;
14typedef polygon_data<long double> BPolygon;
15typedef polygon_with_holes_data<long double> BPolygonWithHoles;
16typedef polygon_set_data<long double> BPolygonSet;
17
18
19
20
21int main(int argc, char *argv[])
22{
23 cout << "Start main" << endl;
24 BPolygonSet hole_set;
25 BPolygonSet rect_set;
26 vector<BPoint> hole_points;
27 vector<BPoint> rec_points;
28
29 long double rect_data[] = {
30 234192743,152532547,
31 234178199,152561636,
32 233483178,154160183,
33 233603877,155705125,
34 233260158,157423720,
35 231628565,159028565,
36 230128565,160553565,
37 228544284,162111875,
38 228397404,162185315,
39 218301395,165831785,
40 216409102,167750000,
41 216150000,167750000,
42 213820027,167750000,
43 207360263,169595647,
44 205528561,171403561,
45 203628561,173328561,
46 201799044,175134318,
47 195425000,199539218,
48 195425000,199941616,
49 194787046,200539697,
50 194531139,200625000,
51 194332166,200625000,
52 192115266,200466650,
53 191903820,200360927,
54 189964073,198421180,
55 189843548,198180131,
56 189975000,195761423,
57 189975000,193488431,
58 189838748,190954145,
59 190019795,190773099,
60 191209455,189560992,
61 191324464,187099786,
62 191194559,184267848,
63 191320134,184016698,
64 193379529,182163243,
65 195271439,180246439,
66 197196439,178346439,
67 199093680,176424234,
68 208601713,166740126,
69 208844329,166618819,
70 211258693,166744567,
71 214588435,165299400,
72 217843400,165299400,
73 218270800,164871900,
74 218271300,164871900,
75 221793300,161349900,
76 221793300,161349400,
77 221982300,161160500,
78 221982300,161116835,
79 223864356,161225000,
80 225797136,161225000,
81 232190313,153870442,
82 232251883,153131604,
83 232493443,150474451,
84 232646447,150321447,
85 232871447,150096447,
86 233042893,149925000,
87 234343034,149925000,
88 234571180,150039073,
89 234753553,150221447,
90 234925000,150392893,
91 234925000,151203637
92 };
93
94
95 for (size_t i = 0; i < sizeof(rect_data) / sizeof(*rect_data); i += 2) {
96 rec_points.push_back(BPoint(rect_data[i], rect_data[i + 1]));
97 }
98
99 rect_set |= BPolygon(rec_points.begin(), rec_points.end());
100
101
102
103
104
105
106
107 long double hole_1_data[] = {
108 191209300,199179000,
109 191176200,199301900,
110 191106800,199408500,
111 191091900,199430200,
112 191081900,199460400,
113 191081800,199492200,
114 191091500,199522400,
115 191110100,199548200,
116 191165349,199622456,
117 190464784,198921891,
118 190502800,198863500,
119 190601800,198783500,
120 190720700,198738000,
121 190847800,198731500,
122 190970700,198764600,
123 191077300,198834000,
124 191157300,198933000,
125 191202800,199051900,
126 191209300,199179000
127 };
128
129 hole_points.clear();
130 for (size_t i = 0; i < sizeof(hole_1_data) / sizeof(*hole_1_data); i += 2) {
131 hole_points.push_back(BPoint(hole_1_data[i], hole_1_data[i + 1]));
132 }
133 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
134
135 long double hole_2_data[] = {
136 192517800,197625700,
137 192505976,197723078,
138 192471192,197814796,
139 192415469,197895525,
140 192342046,197960572,
141 192255189,198006158,
142 192159946,198029633,
143 192061854,198029633,
144 191966611,198006158,
145 191879754,197960572,
146 191806331,197895525,
147 191750608,197814796,
148 191715824,197723078,
149 191704000,197625700,
150 191715824,197528322,
151 191750608,197436604,
152 191806331,197355875,
153 191879754,197290828,
154 191966611,197245242,
155 192061854,197221767,
156 192159946,197221767,
157 192255189,197245242,
158 192342046,197290828,
159 192415469,197355875,
160 192471192,197436604,
161 192505976,197528322,
162 192517800,197625700
163 };
164
165 hole_points.clear();
166 for (size_t i = 0; i < sizeof(hole_2_data) / sizeof(*hole_2_data); i += 2) {
167 hole_points.push_back(BPoint(hole_2_data[i], hole_2_data[i + 1]));
168 }
169 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
170
171 long double hole_3_data[] = {
172 193417500,200324300,
173 193415200,200451500,
174 193378752,200556899,
175 192632004,200503559,
176 192611700,200436900,
177 192614000,200309700,
178 192655600,200189400,
179 192732200,200087800,
180 192836500,200014800,
181 192958300,199977700,
182 193085500,199980000,
183 193205800,200021600,
184 193307400,200098200,
185 193380400,200202500,
186 193417500,200324300
187 };
188
189 hole_points.clear();
190 for (size_t i = 0; i < sizeof(hole_3_data) / sizeof(*hole_3_data); i += 2) {
191 hole_points.push_back(BPoint(hole_3_data[i], hole_3_data[i + 1]));
192 }
193 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
194
195 long double hole_4_data[] = {
196 193442300,198690000,
197 193424000,198703800,
198 193405800,198729900,
199 193399000,198743000,
200 193322400,198844600,
201 193218100,198917600,
202 193096300,198954700,
203 192969100,198952400,
204 192848800,198910800,
205 192747200,198834200,
206 192674200,198729900,
207 192637100,198608100,
208 192639400,198480900,
209 192681000,198360600,
210 192757600,198259000,
211 192861900,198186000,
212 192983700,198148900,
213 193110900,198151200,
214 193231200,198192800,
215 193332800,198269400,
216 193405800,198373700,
217 193407500,198377100,
218 193426700,198402500,
219 193442300,198413400,
220 193442300,198690000
221 };
222
223 hole_points.clear();
224 for (size_t i = 0; i < sizeof(hole_4_data) / sizeof(*hole_4_data); i += 2) {
225 hole_points.push_back(BPoint(hole_4_data[i], hole_4_data[i + 1]));
226 }
227 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
228
229 long double hole_5_data[] = {
230 193893400,195666300,
231 193862600,195789800,
232 193795100,195897800,
233 193697600,195979600,
234 193579600,196027300,
235 193452600,196036100,
236 193329100,196005300,
237 193221100,195937900,
238 193139300,195840400,
239 193091600,195722300,
240 193082700,195595300,
241 193113500,195471800,
242 193181000,195363800,
243 193191300,195349700,
244 193203200,195320200,
245 193205400,195288500,
246 193197800,195257700,
247 193181000,195230800,
248 193129100,195155400,
249 193087500,195035100,
250 193085000,194907800,
251 193122100,194786000,
252 193194900,194681600,
253 193203200,194670200,
254 193208400,194655100,
255 193208700,194639200,
256 193204100,194624000,
257 193194900,194611000,
258 193129100,194520400,
259 193087500,194400100,
260 193085100,194272800,
261 193122100,194151000,
262 193194900,194046600,
263 193203200,194035200,
264 193208400,194020100,
265 193208700,194004200,
266 193204100,193989000,
267 193194900,193976000,
268 193129100,193885400,
269 193087500,193765100,
270 193085100,193637800,
271 193122100,193516000,
272 193194900,193411600,
273 193296500,193334800,
274 193416800,193293200,
275 193544100,193290800,
276 193665900,193327800,
277 193770300,193400700,
278 193847000,193502200,
279 193888600,193622500,
280 193891100,193749800,
281 193854000,193871600,
282 193781200,193976000,
283 193772900,193987400,
284 193767700,194002500,
285 193767400,194018400,
286 193772100,194033600,
287 193781200,194046600,
288 193847000,194137200,
289 193888600,194257500,
290 193891100,194384800,
291 193854000,194506600,
292 193781200,194611000,
293 193772900,194622400,
294 193767700,194637500,
295 193767400,194653400,
296 193772100,194668600,
297 193781200,194681600,
298 193836800,194754200,
299 193884500,194872300,
300 193893400,194999300,
301 193862600,195122800,
302 193795100,195230800,
303 193784900,195244900,
304 193772900,195274400,
305 193770700,195306000,
306 193778300,195336900,
307 193795100,195363800,
308 193836800,195421200,
309 193884500,195539300,
310 193893400,195666300
311 };
312
313 hole_points.clear();
314 for (size_t i = 0; i < sizeof(hole_5_data) / sizeof(*hole_5_data); i += 2) {
315 hole_points.push_back(BPoint(hole_5_data[i], hole_5_data[i + 1]));
316 }
317 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
318
319 long double hole_6_data[] = {
320 194335900,200430000,
321 194316400,200555900,
322 194283250,200621506,
323 193547832,200568976,
324 193542400,200558400,
325 193522100,200432800,
326 193541600,200306900,
327 193599000,200193300,
328 193688700,200103000,
329 193802000,200044800,
330 193927600,200024500,
331 194053500,200044000,
332 194167100,200101400,
333 194257400,200191100,
334 194315600,200304400,
335 194335900,200430000
336 };
337
338 hole_points.clear();
339 for (size_t i = 0; i < sizeof(hole_6_data) / sizeof(*hole_6_data); i += 2) {
340 hole_points.push_back(BPoint(hole_6_data[i], hole_6_data[i + 1]));
341 }
342 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
343
344 long double hole_7_data[] = {
345 194357300,198495500,
346 194355000,198622700,
347 194313400,198743000,
348 194236800,198844600,
349 194132500,198917600,
350 194129100,198919300,
351 194103700,198938500,
352 194085500,198964500,
353 194076200,198995000,
354 194076800,199026800,
355 194087200,199056800,
356 194106400,199082200,
357 194132500,199100400,
358 194153100,199111300,
359 194253200,199190000,
360 194324000,199295800,
361 194325700,199299300,
362 194344300,199325000,
363 194348100,199327800,
364 194348100,199616700,
365 194335300,199626000,
366 194316600,199651600,
367 194313500,199657500,
368 194236800,199759100,
369 194132500,199832000,
370 194010700,199869100,
371 193883500,199866800,
372 193763100,199825300,
373 193661500,199748600,
374 193588600,199644300,
375 193551500,199522500,
376 193553800,199395300,
377 193595300,199274900,
378 193672000,199173300,
379 193776300,199100400,
380 193779700,199098700,
381 193805100,199079500,
382 193823300,199053400,
383 193832600,199023000,
384 193832000,198991200,
385 193821600,198961200,
386 193802400,198935800,
387 193776300,198917600,
388 193763200,198910800,
389 193661600,198834200,
390 193588600,198729900,
391 193586900,198726500,
392 193569300,198703200,
393 193569300,198400600,
394 193570400,198399800,
395 193588600,198373700,
396 193595400,198360600,
397 193672000,198259000,
398 193776300,198186000,
399 193898100,198148900,
400 194025300,198151200,
401 194145600,198192800,
402 194247200,198269400,
403 194320200,198373700,
404 194357300,198495500
405 };
406
407 hole_points.clear();
408 for (size_t i = 0; i < sizeof(hole_7_data) / sizeof(*hole_7_data); i += 2) {
409 hole_points.push_back(BPoint(hole_7_data[i], hole_7_data[i + 1]));
410 }
411 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
412
413 long double hole_8_data[] = {
414 195200631,200151961,
415 194787046,200539697,
416 194546002,200620045,
417 194510500,200573400,
418 194468400,200453200,
419 194465600,200325900,
420 194502200,200204000,
421 194574700,200099400,
422 194676000,200022200,
423 194697300,200006700,
424 195026000,200006700,
425 195036000,200002500,
426 195036300,200002900,
427 195061600,200022200,
428 195142100,200079200,
429 195200631,200151961
430 };
431
432 hole_points.clear();
433 for (size_t i = 0; i < sizeof(hole_8_data) / sizeof(*hole_8_data); i += 2) {
434 hole_points.push_back(BPoint(hole_8_data[i], hole_8_data[i + 1]));
435 }
436 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
437
438 long double hole_9_data[] = {
439 195325200,198584300,
440 195295300,198708000,
441 195228600,198816500,
442 195131700,198899000,
443 195014000,198947600,
444 194887100,198957400,
445 194763400,198927500,
446 194654900,198860800,
447 194572400,198763900,
448 194523800,198646200,
449 194514000,198519300,
450 194543900,198395600,
451 194610600,198287100,
452 194707500,198204600,
453 194729300,198186600,
454 194747000,198160200,
455 194755600,198129600,
456 194754300,198097800,
457 194743300,198068000,
458 194723600,198043100,
459 194697100,198025500,
460 194603100,197965200,
461 194520600,197868300,
462 194472000,197750600,
463 194462200,197623700,
464 194492100,197500000,
465 194558800,197391500,
466 194655700,197309000,
467 194773400,197260400,
468 194900300,197250600,
469 195024000,197280500,
470 195132500,197347200,
471 195215000,197444100,
472 195263500,197561800,
473 195273300,197688700,
474 195243500,197812400,
475 195176800,197920900,
476 195079900,198003400,
477 195058100,198021400,
478 195040400,198047800,
479 195031800,198078400,
480 195033100,198110200,
481 195044100,198140000,
482 195063800,198164900,
483 195090300,198182500,
484 195184300,198242800,
485 195266800,198339700,
486 195315400,198457400,
487 195325200,198584300
488 };
489
490 hole_points.clear();
491 for (size_t i = 0; i < sizeof(hole_9_data) / sizeof(*hole_9_data); i += 2) {
492 hole_points.push_back(BPoint(hole_9_data[i], hole_9_data[i + 1]));
493 }
494 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
495
496 long double hole_10_data[] = {
497 195536148,199113653,
498 195425000,199539218,
499 195425000,199725469,
500 195391500,199688400,
501 195382800,199677000,
502 195358300,199656700,
503 195328700,199644900,
504 195297000,199642900,
505 195266200,199650800,
506 195239300,199667800,
507 195219100,199692300,
508 195162900,199766300,
509 195061600,199843400,
510 195039700,199859300,
511 195024100,199879700,
512 194713000,199879700,
513 194701300,199862700,
514 194676000,199843400,
515 194670000,199840100,
516 194570000,199761300,
517 194499200,199655400,
518 194497500,199651900,
519 194478900,199626200,
520 194475100,199623400,
521 194475100,199334500,
522 194487900,199325200,
523 194506600,199299600,
524 194552100,199229500,
525 194646600,199144100,
526 194762800,199092100,
527 194889400,199078600,
528 195013900,199104800,
529 195124300,199168300,
530 195209700,199262700,
531 195218400,199274200,
532 195242900,199294500,
533 195272500,199306300,
534 195304200,199308300,
535 195335000,199300400,
536 195361900,199283400,
537 195382100,199258900,
538 195415700,199210700,
539 195510100,199125300,
540 195536148,199113653
541 };
542
543 hole_points.clear();
544 for (size_t i = 0; i < sizeof(hole_10_data) / sizeof(*hole_10_data); i += 2) {
545 hole_points.push_back(BPoint(hole_10_data[i], hole_10_data[i + 1]));
546 }
547 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
548
549 long double hole_11_data[] = {
550 195721300,195709900,
551 195687700,195832700,
552 195617800,195939200,
553 195518500,196018800,
554 195399400,196063800,
555 195272300,196069800,
556 195149500,196036200,
557 195043000,195966300,
558 194963400,195867000,
559 194918400,195747900,
560 194912400,195620700,
561 194946000,195497900,
562 195015900,195391500,
563 195029100,195373500,
564 195040300,195343700,
565 195041700,195311900,
566 195033300,195281300,
567 195015900,195254600,
568 194957900,195172400,
569 194916300,195052100,
570 194913800,194924800,
571 194950900,194803000,
572 195023700,194698600,
573 195032000,194687200,
574 195037200,194672200,
575 195037500,194656200,
576 195032900,194641000,
577 195023700,194628000,
578 194957900,194537400,
579 194916300,194417100,
580 194913900,194289800,
581 194950900,194168000,
582 195023700,194063600,
583 195032000,194052200,
584 195037200,194037200,
585 195037500,194021200,
586 195032900,194006000,
587 195023700,193993000,
588 194957900,193902400,
589 194916300,193782100,
590 194913900,193654800,
591 194950900,193533000,
592 195023700,193428600,
593 195032000,193417200,
594 195037200,193402200,
595 195037500,193386200,
596 195032900,193371000,
597 195023700,193358000,
598 194957900,193267400,
599 194916300,193147100,
600 194913900,193019800,
601 194950900,192898000,
602 195023700,192793600,
603 195125300,192716900,
604 195245600,192675200,
605 195372900,192672800,
606 195494700,192709800,
607 195599100,192782700,
608 195675800,192884200,
609 195717400,193004500,
610 195719900,193131800,
611 195682800,193253600,
612 195610000,193358000,
613 195601700,193369400,
614 195596500,193384500,
615 195596200,193400400,
616 195600900,193415600,
617 195610000,193428600,
618 195675800,193519200,
619 195717400,193639500,
620 195719900,193766800,
621 195682800,193888600,
622 195610000,193993000,
623 195601700,194004400,
624 195596500,194019500,
625 195596200,194035400,
626 195600900,194050600,
627 195610000,194063600,
628 195675800,194154200,
629 195717400,194274500,
630 195719900,194401800,
631 195682800,194523600,
632 195610000,194628000,
633 195601700,194639400,
634 195596500,194654500,
635 195596200,194670400,
636 195600900,194685600,
637 195610000,194698600,
638 195670300,194779200,
639 195715300,194898300,
640 195721300,195025400,
641 195687700,195148200,
642 195617800,195254600,
643 195604700,195272800,
644 195593500,195302500,
645 195592000,195334300,
646 195600300,195365000,
647 195617800,195391500,
648 195670300,195463700,
649 195715300,195582800,
650 195721300,195709900
651 };
652
653 hole_points.clear();
654 for (size_t i = 0; i < sizeof(hole_11_data) / sizeof(*hole_11_data); i += 2) {
655 hole_points.push_back(BPoint(hole_11_data[i], hole_11_data[i + 1]));
656 }
657 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
658
659 long double hole_12_data[] = {
660 231627700,156766300,
661 231615876,156863678,
662 231581092,156955396,
663 231525369,157036125,
664 231451946,157101172,
665 231365089,157146758,
666 231269846,157170233,
667 231171754,157170233,
668 231076511,157146758,
669 230989654,157101172,
670 230916231,157036125,
671 230860508,156955396,
672 230825724,156863678,
673 230813900,156766300,
674 230825724,156668922,
675 230860508,156577204,
676 230916231,156496475,
677 230989654,156431428,
678 231076511,156385842,
679 231171754,156362367,
680 231269846,156362367,
681 231365089,156385842,
682 231451946,156431428,
683 231525369,156496475,
684 231581092,156577204,
685 231615876,156668922,
686 231627700,156766300
687 };
688
689 hole_points.clear();
690 for (size_t i = 0; i < sizeof(hole_12_data) / sizeof(*hole_12_data); i += 2) {
691 hole_points.push_back(BPoint(hole_12_data[i], hole_12_data[i + 1]));
692 }
693 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
694
695 long double hole_13_data[] = {
696 232827755,150140138,
697 232801600,150305200,
698 232720400,150464700,
699 232593800,150591200,
700 232477433,150650551,
701 232493443,150474451,
702 232646447,150321447,
703 232827755,150140138
704 };
705
706 hole_points.clear();
707 for (size_t i = 0; i < sizeof(hole_13_data) / sizeof(*hole_13_data); i += 2) {
708 hole_points.push_back(BPoint(hole_13_data[i], hole_13_data[i + 1]));
709 }
710 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
711
712 long double hole_14_data[] = {
713 233362303,156912990,
714 233297275,157238132,
715 233291600,157222600,
716 233287000,157095400,
717 233321900,156973000,
718 233362303,156912990
719 };
720
721 hole_points.clear();
722 for (size_t i = 0; i < sizeof(hole_14_data) / sizeof(*hole_14_data); i += 2) {
723 hole_points.push_back(BPoint(hole_14_data[i], hole_14_data[i + 1]));
724 }
725 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
726
727 long double hole_15_data[] = {
728 233528178,156083619,
729 233397669,156736164,
730 233393000,156729200,
731 233335300,156649800,
732 233291600,156530200,
733 233287000,156403000,
734 233321900,156280600,
735 233393000,156174900,
736 233493200,156096400,
737 233528178,156083619
738 };
739
740 hole_points.clear();
741 for (size_t i = 0; i < sizeof(hole_15_data) / sizeof(*hole_15_data); i += 2) {
742 hole_points.push_back(BPoint(hole_15_data[i], hole_15_data[i + 1]));
743 }
744 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
745
746 long double hole_16_data[] = {
747 234262700,152323800,
748 234247248,152433629,
749 234192743,152532547,
750 234178199,152561636,
751 234123012,152688565,
752 234042700,152774600,
753 234061053,152831071,
754 233483178,154160183,
755 233551326,155032483,
756 233514200,155026600,
757 233354900,154945400,
758 233228400,154818900,
759 233147200,154659500,
760 233119200,154482800,
761 233119200,153593500,
762 233136200,153455000,
763 233206200,153290300,
764 233323600,153155400,
765 233311500,153131500,
766 233276100,153009200,
767 233280300,152881900,
768 233323600,152762200,
769 233228400,152660100,
770 233147200,152500700,
771 233119200,152324100,
772 233119200,151612600,
773 233147200,151435900,
774 233228400,151276500,
775 233354900,151150000,
776 233514200,151068800,
777 233690900,151040800,
778 233867600,151068800,
779 234027000,151150000,
780 234153500,151276500,
781 234234700,151435900,
782 234262700,151612600,
783 234262700,152323800
784 };
785
786 hole_points.clear();
787 for (size_t i = 0; i < sizeof(hole_16_data) / sizeof(*hole_16_data); i += 2) {
788 hole_points.push_back(BPoint(hole_16_data[i], hole_16_data[i + 1]));
789 }
790 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
791
792 long double hole_17_data[] = {
793 234859075,150326969,
794 234773200,150389300,
795 234603100,150444600,
796 234424200,150444600,
797 234254000,150389300,
798 234109300,150284200,
799 233750100,149925000,
800 234343034,149925000,
801 234571180,150039073,
802 234753553,150221447,
803 234859075,150326969
804 };
805
806 hole_points.clear();
807 for (size_t i = 0; i < sizeof(hole_17_data) / sizeof(*hole_17_data); i += 2) {
808 hole_points.push_back(BPoint(hole_17_data[i], hole_17_data[i + 1]));
809 }
810 hole_set |= BPolygon(hole_points.begin(), hole_points.end());
811 cout << "Data is set" <<endl;
812
813 assign(rect_set, rect_set - hole_set);
814 cout << "Substruction is done" <<endl;
815
816 vector<BPolygonWithHoles> result;
817 //CRASH IS HERE ---------------
818 rect_set.get(result);
819 cout << "Polygons with holes data is set" <<endl;
820
821 cout<< "Finished succefully" << endl;
822 cout << "Number of relevant rectungles "<< result.size() <<endl;
823}