diff --git a/Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/polygon-splitter-test/test_1_polygon_b.off b/Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/data/test_1_polygon_b.off similarity index 100% rename from Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/polygon-splitter-test/test_1_polygon_b.off rename to Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/data/test_1_polygon_b.off diff --git a/Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/polygon-splitter-test/test_2_polygons_ad.off b/Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/data/test_2_polygons_ad.off similarity index 100% rename from Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/polygon-splitter-test/test_2_polygons_ad.off rename to Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/data/test_2_polygons_ad.off diff --git a/Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/kinetic_precomputed_shapes_example.cpp b/Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/kinetic_precomputed_shapes_example.cpp index c893d582d82..c31d7f1e279 100644 --- a/Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/kinetic_precomputed_shapes_example.cpp +++ b/Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/kinetic_precomputed_shapes_example.cpp @@ -10,7 +10,7 @@ using SCD = CGAL::Simple_cartesian; using EPICK = CGAL::Exact_predicates_inexact_constructions_kernel; using EPECK = CGAL::Exact_predicates_exact_constructions_kernel; -using Kernel = EPECK; +using Kernel = EPICK; using Point_3 = typename Kernel::Point_3; using Segment_3 = typename Kernel::Segment_3; diff --git a/Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/real-data-test/building_b_34polygons_24planes.off b/Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/real-data-test/building_b_34polygons_24planes.off deleted file mode 100644 index 22aa505817d..00000000000 --- a/Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/real-data-test/building_b_34polygons_24planes.off +++ /dev/null @@ -1,536 +0,0 @@ -OFF -499 34 0 -60.454697561 -22.406230585 -35.713620691 -60.444088158 -22.375118569 -35.713954661 -54.728962982 -14.834420123 -35.87702005 -54.365969037 -14.579381719 -35.886968089 -52.385639963 -13.693685261 -35.940316357 -52.300435351 -13.696232884 -35.942537429 -52.258447876 -13.777136094 -35.943486451 -52.208331788 -15.139956451 -35.942306211 -51.922783751 -23.595597585 -35.934319944 -51.886976904 -24.805600283 -35.933045059 -51.89804897 -24.910613729 -35.932564011 -51.926431206 -24.954643815 -35.93174218 -51.975614743 -24.957757746 -35.930451713 -52.149760615 -24.963898747 -35.925891434 -53.155356816 -24.998432895 -35.899560033 -53.967593879 -25.025865329 -35.878292559 -59.251655529 -25.203874609 -35.739936434 -59.450429719 -25.171945101 -35.734802352 -59.634939305 -25.141844744 -35.73003755 -57.825105152 -22.252527016 -35.79166312 -57.375450613 -22.263070404 -35.538891432 -56.35877332 -22.304282418 -34.303938743 -56.276205503 -22.317425321 -33.829566608 -56.234687959 -22.327663152 -33.452450332 -56.08198177 -22.429211477 -29.625513687 -56.015797865 -22.479322675 -27.733973122 -56.129462004 -22.527034181 -25.874134681 -56.179252681 -22.528616449 -25.797119712 -56.386473869 -22.527208451 -25.781829872 -56.899714292 -22.52134536 -25.834684856 -57.115654253 -22.518868535 -25.857304758 -57.802383601 -22.510420266 -25.951064259 -57.924848826 -22.508062492 -26.000288716 -58.087501317 -22.503573791 -26.117494319 -58.263909411 -22.369612997 -31.174267354 -58.291913809 -22.27292339 -34.857221331 -58.184424828 -22.252494867 -35.673146482 -58.960779603 -21.701544946 -35.209666932 -58.112207076 -21.720498999 -34.768657705 -58.070322852 -21.93568982 -26.565122729 -58.229617503 -21.941312807 -26.297312297 -59.278235994 -21.937272173 -26.102156785 -59.644199352 -21.933164541 -26.13705659 -59.767237745 -21.930588652 -26.194419196 -60.04414029 -21.921089786 -26.464873842 -60.054263358 -21.917267003 -26.607480931 -60.257312668 -21.756052314 -32.696120312 -59.817510441 -21.709641492 -34.614975985 -54.480009038 -22.039972305 -31.277264765 -54.512926541 -21.834766388 -35.049236957 -54.515478536 -21.772171021 -35.341666676 -54.518306632 -21.572002411 -35.66573437 -54.519593649 -20.98950386 -35.813211914 -54.520551145 -18.132938385 -35.922930076 -54.520445585 -17.647500992 -35.910834155 -54.520443255 -17.640550613 -35.910567101 -54.519081496 -16.599811554 -35.75452505 -54.514703086 -15.733804703 -35.252808871 -54.503828294 -14.22180748 -34.006681179 -54.502484244 -14.102972031 -33.852668278 -54.494000393 -13.948583603 -32.880515266 -54.49291924 -13.946754456 -32.756627348 -54.49183175 -13.950035095 -32.632013438 -54.475864708 -14.117275238 -30.802371638 -54.460414655 -14.408224106 -29.031970839 -54.45994414 -14.422153473 -28.978055228 -54.436195503 -19.821184158 -26.256730957 -54.435687116 -20.087966919 -26.198475609 -54.435990138 -21.663282394 -26.233198419 -54.436390053 -21.944828033 -26.279024136 -54.437738303 -21.956230164 -26.433518328 -54.446804989 -22.013917923 -27.472457644 -56.147462113 -21.722001892 -35.366023766 -56.055723199 -21.723551033 -35.337438955 -55.786791377 -21.728512462 -35.237599175 -54.569281667 -21.756375817 -34.579319796 -54.43957171 -21.76897216 -34.141529403 -54.452297415 -21.79475504 -33.152717537 -54.678403848 -21.824913475 -31.925706597 -55.530053201 -21.834090836 -31.291436022 -55.976103346 -21.831778285 -31.231097879 -56.073289107 -21.826324487 -31.406974663 -56.081865941 -21.824834664 -31.461008266 -56.208022706 -21.790064031 -32.746752519 -56.265516139 -21.750765248 -34.228295467 -60.046952954 -22.062335968 -30.02271189 -60.051676911 -22.048606873 -30.564023703 -60.064699193 -21.309143066 -32.056229457 -60.068926857 -21.008811951 -32.540671731 -60.072773356 -20.361278534 -32.981436823 -60.07108987 -18.828260422 -32.7885285 -60.067435871 -18.056667328 -32.369821651 -60.06640436 -17.856010437 -32.251622264 -60.06328752 -17.463571548 -31.894467688 -60.051907985 -16.37260437 -30.590502174 -60.049899015 -16.296138763 -30.360297058 -60.04747833 -16.432258606 -30.082913994 -60.045156684 -16.579769135 -29.816879708 -60.016223234 -18.807035446 -26.501434716 -60.013274086 -19.056043625 -26.163495791 -60.01264803 -19.783550262 -26.091756882 -60.012176171 -21.175636292 -26.037687188 -60.012920003 -21.34740448 -26.122921929 -60.013554495 -21.442697525 -26.195627486 -60.017070115 -21.703496933 -26.598477667 -60.02124958 -21.7825737 -27.077396977 -55.453719239 -21.820707754 -31.827934351 -54.743071626 -21.830018638 -31.70920499 -54.724789275 -21.830668994 -31.690462472 -54.597430049 -21.835942617 -31.53152147 -54.544516136 -21.838416547 -31.454683203 -54.390641076 -21.848840658 -31.107896927 -54.38092537 -21.871179098 -30.258096611 -54.36517689 -21.912192337 -28.697172032 -54.37407811 -21.938675819 -27.68288083 -54.406319166 -21.968393132 -26.537321197 -54.579690148 -21.970705987 -26.391223834 -54.725715641 -21.97234282 -26.280054655 -55.23800485 -21.968750454 -26.246514436 -55.493875098 -21.96555366 -26.283320942 -55.920173657 -21.94928307 -26.762580782 -55.99270262 -21.931563519 -27.415066881 -56.071035256 -21.910486399 -28.193834375 -56.074905065 -21.909051463 -28.247340672 -56.083752893 -21.905638042 -28.374740434 -56.23770361 -21.83467331 -31.033366475 -56.247912369 -21.82457434 -31.415613796 -60.076240378 -21.144021988 -33.378718204 -60.080737378 -21.085184097 -33.894023345 -60.081485103 -21.029071808 -33.979704235 -60.08243079 -20.486625671 -34.088069238 -60.082613924 -20.259462357 -34.109054325 -60.081281726 -17.664897919 -33.956399493 -60.080319927 -17.590946198 -33.84618824 -60.074529297 -18.330116272 -33.182647732 -60.074050488 -18.651071548 -33.127781705 -60.072354823 -20.782798767 -32.933477759 -60.07541576 -21.115564346 -33.28422638 -60.075723735 -21.127456665 -33.319516819 -56.100655711 -22.480733871 -26.881004284 -56.135854546 -22.438484192 -30.914391238 -56.137826148 -22.345741272 -31.140314463 -56.137951926 -22.240142822 -31.154727259 -56.135327136 -21.845119476 -30.853956107 -56.131527838 -21.731235504 -30.418599672 -56.095547271 -21.416696548 -26.295635012 -56.094703569 -21.415468216 -26.198956409 -56.092394215 -21.56934166 -25.934330607 -56.091619704 -21.767311096 -25.845580467 -56.091976652 -22.005907059 -25.886482593 -56.092618728 -22.361257553 -25.960057249 -56.092934186 -22.433383942 -25.996205189 -56.093167789 -22.455976486 -26.022973401 -58.07476049 -22.528278351 -27.051837371 -58.077348505 -22.515953064 -27.348394431 -58.094877667 -22.355657578 -29.35703747 -58.098007704 -22.309080124 -29.715704155 -58.09975263 -22.282642365 -29.915652961 -58.09991173 -22.261245728 -29.933883977 -58.094658709 -21.794113159 -29.331947423 -58.068766255 -21.598890305 -26.364965999 -58.068407648 -21.599843979 -26.323873767 -58.06686319 -21.72930336 -26.146896335 -58.064548175 -22.085435867 -25.881621959 -58.064419291 -22.185422897 -25.866853351 -58.067437419 -22.496423721 -26.212696502 -60.055290143 -18.167594789 -26.173662031 -60.026659769 -17.636580781 -26.175379888 -59.950946384 -17.179164226 -26.178193217 -59.831545388 -17.109710092 -26.181439093 -59.382451864 -17.096265492 -26.193194933 -58.108362357 -17.096040861 -26.22647728 -58.058979836 -17.12461092 -26.22771507 -54.419351934 -19.642022118 -26.31819152 -54.396218234 -19.685730822 -26.318715981 -54.280679703 -20.256327982 -26.32069182 -54.238200688 -21.688833784 -26.319184794 -54.266117846 -21.802429898 -26.318248039 -54.297128732 -21.886015044 -26.317285289 -54.338098072 -21.919116458 -26.316154618 -56.144882443 -22.468270947 -26.267954448 -56.176055383 -22.474555341 -26.267128665 -56.533096782 -22.497717849 -26.257759672 -56.726171511 -22.505371993 -26.252702167 -57.395742947 -22.531763614 -26.235163324 -57.500042529 -22.535414271 -26.232432128 -57.947488314 -22.545359237 -26.220725724 -58.006647202 -22.529113841 -26.219210042 -59.894185494 -21.892185346 -26.171066951 -59.963737363 -21.833413335 -26.169357463 -60.016769326 -21.781666115 -26.168066679 -60.043684578 -21.746702957 -26.16742746 -60.053659131 -21.366329084 -26.167861708 -61.531134236 -12.411145423 -35.51156738 -61.522988391 -12.284708604 -35.512011121 -61.509616526 -12.266320889 -35.512394011 -61.27478757 -12.200260462 -35.518648913 -59.80824746 -12.224547492 -35.556913706 -59.700149406 -12.239507465 -35.559710132 -59.03413067 -13.143667626 -35.575456389 -58.899765967 -13.404023752 -35.578490706 -58.887173216 -13.462403548 -35.578713017 -60.219406044 -19.059793883 -35.533687849 -60.706851017 -18.918143163 -35.521213491 -61.252593792 -18.575465174 -35.507583473 -61.303244319 -18.425995996 -35.506533399 -61.315564523 -18.313551593 -35.506416964 -61.343157761 -17.890794624 -35.506468394 -61.384690775 -16.725029724 -35.507512893 -61.449373802 -14.836695931 -35.509272536 -60.067632743 -17.962985992 -32.392380972 -60.076349813 -17.869441986 -33.391258204 -60.077271406 -17.841083527 -33.496862323 -60.084250443 -17.148370743 -34.296580822 -60.091180893 -16.391429901 -35.090731673 -60.086606247 -16.200523376 -34.566529193 -60.078234637 -16.035030365 -33.607237658 -60.057084299 -16.579740524 -31.183649051 -60.055688677 -17.011846542 -31.023726541 -60.055282278 -17.222511292 -30.977157874 -60.059016322 -17.668647766 -31.405036877 -60.031662584 -18.884063721 -28.270609019 -60.034734765 -18.582611084 -28.622646054 -60.036282453 -18.205940247 -28.799993539 -60.035574638 -17.354724884 -28.718885971 -60.033541161 -16.734212875 -28.485872561 -60.032360077 -16.767669678 -28.350533734 -60.030183327 -16.837985992 -28.101102956 -60.029390432 -16.888834 -28.010246173 -60.020162349 -17.658342361 -26.952812579 -60.01968026 -18.167013168 -26.89757066 -60.027334926 -18.747760773 -27.774708487 -60.031122911 -18.879552841 -28.208768604 -60.683092393 -15.841480582 -30.123780575 -60.452162907 -14.573929507 -30.132128303 -59.596482496 -13.672301082 -30.156127449 -58.336765595 -13.599333929 -30.189167228 -57.903226324 -13.72203914 -30.200268061 -57.902488319 -13.894264862 -30.199972745 -58.340570704 -17.004076348 -30.1828486 -58.385318318 -17.024792375 -30.181641856 -59.055145918 -17.067882939 -30.164065819 -59.393111298 -17.022351013 -30.155320612 -59.422417097 -17.007043109 -30.154583044 -59.935066396 -16.734316188 -30.141689724 -60.160897499 -16.535924256 -30.136152923 -60.577309509 -16.082173651 -30.126104191 -60.592976174 -16.064288649 -30.125727614 -59.590757849 -19.810791548 -26.08088772 -57.739306084 -19.803170246 -26.093307311 -57.572393652 -19.834427917 -26.140905091 -57.53004938 -19.853728513 -26.169524217 -57.531474745 -19.961871589 -26.326849279 -57.595508425 -19.970295282 -26.338292314 -57.803227294 -19.981861507 -26.352483189 -59.01465579 -19.972654191 -26.323705236 -59.274527056 -19.964332024 -26.308297235 -59.483481836 -19.956526156 -26.294286921 -59.586079018 -19.926155969 -26.248797011 -59.749905303 -19.866815232 -26.160378859 -59.79053239 -19.825774224 -26.100150245 -56.514028751 -19.819676456 -26.132880658 -56.413292522 -19.819142839 -26.133383336 -54.931269792 -19.835134755 -26.175468353 -54.705986418 -19.839735587 -26.185022816 -54.614192438 -19.880573833 -26.245606096 -54.665243906 -19.912993715 -26.292127311 -54.855741927 -19.976669711 -26.382354143 -55.155752572 -20.003171684 -26.417103992 -55.359334019 -20.012061706 -26.427453651 -55.563319911 -20.010981124 -26.423291407 -56.594466557 -19.978563902 -26.36303319 -56.652158675 -19.862148505 -26.192921658 -56.607364282 -19.842916602 -26.165508893 -57.712326149 -17.099581216 -28.148351388 -57.624003603 -17.058796868 -28.15073306 -55.062632441 -17.219571199 -28.217347864 -54.750110879 -17.323456529 -28.225321833 -54.702612132 -17.426274162 -28.226374791 -54.80315461 -17.587242233 -28.223454377 -55.436842995 -17.982954928 -28.20617826 -56.54862871 -18.236576636 -28.17667277 -56.714547153 -18.184292377 -28.172434131 -56.814831369 -18.12194992 -28.16992837 -57.576363077 -17.521815137 -28.151131766 -57.662591235 -17.306495189 -28.149272614 -60.139164803 -16.662159577 -28.085756195 -60.063284296 -16.564582421 -28.087916593 -59.810767201 -16.367839967 -28.094872256 -59.21284987 -16.304754438 -28.110606367 -58.012318473 -16.305886218 -28.141964742 -57.552536122 -16.3424661 -28.15390842 -56.642653431 -16.70788727 -28.177009005 -56.560350525 -16.856021691 -28.178888345 -56.546407803 -16.959350608 -28.179063814 -56.543175138 -16.995461234 -28.179082297 -56.717682392 -17.424826839 -28.1737395 -56.737565128 -17.45921668 -28.173157303 -56.89148938 -17.471964291 -28.169113187 -59.673127583 -17.187045349 -28.096971305 -59.931389944 -16.910099327 -28.090730821 -55.362101907 -17.220643596 -30.180389318 -54.92233051 -17.229187284 -30.000686571 -54.456467727 -17.259154725 -29.011569887 -54.429596987 -17.296604981 -27.590411523 -54.444219219 -17.301302216 -27.40616526 -54.499114836 -17.303622416 -27.299269651 -54.590410692 -17.30385145 -27.260098922 -54.678959457 -17.30293564 -27.265561837 -55.766547264 -17.270604177 -28.137761722 -55.856708362 -17.267905857 -28.210756037 -55.964148631 -17.256188948 -28.622384921 -55.522005119 -17.223432642 -30.020595761 -55.454121432 -17.221344317 -30.122965081 -57.697277755 -14.15103651 -35.632283605 -56.869696655 -14.158424811 -35.625940366 -56.768315716 -14.160094222 -35.595976058 -56.73476986 -14.161069623 -35.569907676 -54.499978015 -14.308526823 -30.683709767 -54.354026225 -14.318889426 -30.336631867 -54.510087371 -14.347548546 -29.190218072 -54.716420362 -14.353086506 -28.90997889 -54.820956159 -14.353676236 -28.852621978 -55.940252439 -14.346496445 -28.753787938 -57.111212675 -14.335250789 -28.792999901 -57.470574996 -14.331499526 -28.816490867 -57.744618872 -14.326989766 -28.897379152 -57.806082852 -14.325302862 -28.941313922 -58.136150635 -14.293031789 -30.063653486 -58.36404245 -14.213116951 -33.039416207 -58.265745317 -14.155392455 -35.276499624 -58.120320765 -14.151833387 -35.460872961 -58.078474656 -16.189981206 -30.191182164 -57.945410137 -14.816097448 -30.197167681 -57.491825535 -14.278069254 -30.209999062 -57.294063548 -14.192184917 -30.215321906 -56.514329754 -14.185707472 -30.235702049 -54.853885125 -14.544117312 -30.278421721 -54.619326749 -14.644393213 -30.284365719 -54.439304281 -15.379243253 -30.287725985 -54.620538939 -16.791350158 -30.280412341 -54.895491748 -17.243714763 -30.272403681 -56.061983831 -17.180409586 -30.242048054 -57.827385718 -16.713155277 -30.196785494 -57.936035945 -16.575850476 -30.194198124 -56.52406818 -13.955457048 -30.235868244 -56.437480531 -13.847000288 -30.23832821 -56.104691963 -13.665003441 -30.2473538 -55.06892219 -13.665916093 -30.274408649 -54.705630274 -13.698832823 -30.283838482 -54.645759549 -13.744649717 -30.285318743 -54.63235684 -14.073508799 -30.285068144 -54.966061496 -14.284148815 -30.275966303 -56.32917369 -14.250562943 -30.240420253 -57.573522336 -17.137477286 -28.255245684 -57.477538008 -17.138484122 -28.248784694 -57.032918232 -17.144894501 -28.152162362 -56.993622475 -17.146004116 -28.122884934 -57.093808774 -17.147534424 -28.031059648 -58.622952098 -17.167001927 -26.778062507 -58.967034586 -17.169458744 -26.569577507 -59.761499704 -17.14751512 -27.142780951 -59.762541812 -17.147483595 -27.143637527 -60.037811654 -17.138997772 -27.375951214 -60.074018269 -17.128106714 -27.779782137 -60.070451027 -17.12666443 -27.836047434 -59.452356095 -17.124959566 -28.107133048 -59.010391053 -17.126385216 -28.199977906 -55.924069184 -13.881289338 -35.659823153 -55.282748774 -13.886973836 -35.656471103 -54.406072136 -13.896738548 -35.575741086 -54.327629761 -13.89869442 -35.527193323 -54.462697582 -13.992753339 -31.890353168 -54.581004364 -14.011773463 -31.124605499 -55.008328566 -14.0153523 -30.845533378 -55.988105861 -14.00776079 -30.808916738 -56.583299795 -14.001959947 -30.832083442 -56.334476353 -13.88179334 -35.503807427 -56.1366453 -13.88048704 -35.619618911 -56.088656821 -13.880529493 -35.633990059 -58.397883484 -16.707858381 -30.373812963 -57.026673609 -16.721516142 -30.309223681 -56.640485101 -16.725938028 -30.269063557 -56.579303623 -16.72677999 -30.257300448 -56.398882067 -16.730590481 -30.17191524 -56.342938094 -16.775651632 -28.469808331 -56.788764017 -16.780219159 -28.146815347 -57.002850151 -16.778609977 -28.136920342 -57.77215718 -16.771852752 -28.138584687 -57.842248202 -16.770122163 -28.18131267 -57.861563125 -16.769306442 -28.206025855 -58.322585809 -16.747962 -28.867469012 -58.729985118 -16.705438345 -30.355553024 -58.956334685 -13.991077186 -35.575940676 -58.944023738 -13.888620918 -35.576449415 -58.917090411 -13.686489014 -35.577522193 -58.904979173 -13.651360044 -35.577902732 -58.640112236 -13.208023176 -35.585631437 -57.518277933 -13.263637583 -35.614834556 -56.738913674 -13.334526681 -35.635063725 -56.547385905 -13.552925222 -35.639667904 -56.455738773 -13.801522287 -35.641607826 -56.482933167 -13.879836872 -35.640754398 -56.496359007 -13.912139035 -35.640344682 -56.551720249 -13.985202497 -35.638765068 -57.317768071 -14.423365073 -35.6179539 -58.924997377 -14.128792218 -35.576507718 -58.884683675 -16.256560303 -32.355433346 -58.861776291 -16.256772621 -32.354959491 -58.427774771 -16.266196443 -32.139724233 -58.359541008 -16.269689611 -32.029069709 -58.0833265 -16.297761524 -31.049136743 -58.274258091 -16.307495928 -30.613780495 -58.421000861 -16.311311335 -30.41917904 -58.981650466 -16.312435119 -30.189426975 -59.646544206 -16.307280657 -30.164682658 -59.823722361 -16.304544266 -30.210132069 -59.810849882 -16.271283451 -31.484552796 -59.720902776 -16.267157511 -31.672085239 -59.669562912 -16.265270236 -31.761263757 -59.010359307 -16.255726136 -32.345405907 -54.575412339 -17.702483944 -30.167473884 -54.492727432 -17.357740434 -30.195002868 -54.413159078 -17.271935039 -30.242094134 -54.296271622 -17.238832381 -30.319057227 -54.21183131 -17.257695112 -30.378238781 -54.118465718 -17.378746988 -30.452067994 -54.099394493 -17.529148214 -30.477674962 -54.061771575 -18.260421677 -30.564590093 -54.204402318 -18.429868753 -30.481486009 -54.411719817 -18.424157603 -30.339584347 -54.555909166 -18.261143141 -30.227570575 -55.479329298 -19.601692492 -28.742726419 -54.464436155 -19.618803096 -28.427539827 -54.424429199 -19.629277128 -28.040900341 -54.400715503 -19.642384144 -27.548285343 -54.484533018 -19.666918825 -26.583446888 -54.671956202 -19.67321081 -26.280715496 -54.9556516 -19.671793517 -26.240295359 -55.517446725 -19.668027945 -26.196871381 -56.475459892 -19.658738034 -26.23236458 -56.559302109 -19.655982116 -26.309664142 -56.592368734 -19.652595186 -26.427981318 -56.600795683 -19.63537236 -27.082861161 -56.297484867 -19.613668746 -28.012736415 -56.518015069 -19.704696655 -30.293496256 -56.518285113 -19.67358017 -30.324440254 -56.520219567 -19.298389435 -30.546106659 -56.517591746 -18.96197319 -30.244988231 -56.509959039 -18.101427078 -29.37036659 -56.509024125 -18.050617218 -29.263236084 -56.507715086 -17.982030869 -29.113235042 -56.502013083 -17.94310379 -28.459850308 -56.488766475 -18.318054199 -26.941939353 -56.482749402 -18.963567734 -26.252451097 -56.482288088 -19.035539627 -26.199589747 -56.482248473 -19.176277161 -26.195050281 -56.482431464 -19.292715073 -26.216018977 -56.483279476 -19.53852272 -26.313191487 -56.489699819 -19.586544037 -27.048890018 -56.492775095 -19.602781296 -27.401281656 -56.513401484 -19.698944092 -29.764831746 -58.079499633 -18.715843201 -27.594889303 -58.083164611 -18.660663605 -28.014854163 -58.084888105 -17.965370178 -28.212347052 -58.083601946 -17.582807541 -28.064967842 -58.081783056 -17.397571564 -27.85654367 -58.081489424 -17.373106003 -27.82289677 -58.078879413 -17.160417557 -27.523819138 -58.070478443 -17.251173019 -26.561163311 -58.069206765 -17.31955719 -26.41544348 -58.066788964 -17.713943481 -26.138390954 -58.066922456 -18.285982132 -26.15368755 -58.068006627 -18.34777832 -26.277921299 -57.40055932 -18.430580358 -28.199980158 -56.708034689 -18.450880606 -27.65556037 -56.39989724 -18.462124705 -27.328869605 -56.383767191 -18.463791192 -27.270606855 -56.494610343 -18.482108188 -26.534196834 -56.728113438 -18.489257429 -26.183373125 -56.982968735 -18.488044792 -26.1447488 -57.591606422 -18.483405472 -26.119080245 -57.685839804 -18.482074581 -26.138499449 -57.804616925 -18.478061082 -26.252180127 -57.814441263 -18.477027324 -26.288382273 -57.737409698 -18.4302707 -28.099548689 -59.252327083 -13.945342024 -32.104691138 -58.610971474 -13.957198247 -31.86567116 -58.342912494 -13.966766245 -31.589629412 -58.350932116 -13.967256829 -31.568222924 -59.327562535 -13.967808896 -31.22167617 -59.409263611 -13.967440392 -31.208521114 -59.505814093 -13.964434106 -31.29114642 -59.515491234 -13.964003676 -31.304358334 -59.494938981 -13.960123279 -31.45938817 -59.471416545 -13.95696692 -31.587758967 -59.453812894 -13.955063354 -31.666316938 -59.329642003 -13.947348801 -32.002292918 -59.277857314 -13.945854873 -32.076598974 -19 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 -18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 -11 37 38 39 40 41 42 43 44 45 46 47 -24 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 -13 72 73 74 75 76 77 78 79 80 81 82 83 84 -21 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 -21 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 -12 127 128 129 130 131 132 133 134 135 136 137 138 -14 139 140 141 142 143 144 145 146 147 148 149 150 151 152 -13 153 154 155 156 157 158 159 160 161 162 163 164 165 -27 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 -17 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 -11 210 211 212 213 214 215 216 217 218 219 220 -12 221 222 223 224 225 226 227 228 229 230 231 232 -15 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 -13 248 249 250 251 252 253 254 255 256 257 258 259 260 -13 261 262 263 264 265 266 267 268 269 270 271 272 273 -12 274 275 276 277 278 279 280 281 282 283 284 285 -15 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 -13 301 302 303 304 305 306 307 308 309 310 311 312 313 -18 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 -13 332 333 334 335 336 337 338 339 340 341 342 343 344 -9 345 346 347 348 349 350 351 352 353 -14 354 355 356 357 358 359 360 361 362 363 364 365 366 367 -12 368 369 370 371 372 373 374 375 376 377 378 379 -13 380 381 382 383 384 385 386 387 388 389 390 391 392 -14 393 394 395 396 397 398 399 400 401 402 403 404 405 406 -14 407 408 409 410 411 412 413 414 415 416 417 418 419 420 -11 421 422 423 424 425 426 427 428 429 430 431 -13 432 433 434 435 436 437 438 439 440 441 442 443 444 -17 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 -12 462 463 464 465 466 467 468 469 470 471 472 473 -12 474 475 476 477 478 479 480 481 482 483 484 485 -13 486 487 488 489 490 491 492 493 494 495 496 497 498 - diff --git a/Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/polygon-splitter-test/test-8-rnd-polygons-3-4.off b/Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/stress-test-1/test-8-rnd-polygons-3-4.off similarity index 100% rename from Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/polygon-splitter-test/test-8-rnd-polygons-3-4.off rename to Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/stress-test-1/test-8-rnd-polygons-3-4.off diff --git a/Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/polygon-splitter-test/test-5-rnd-polygons-1-3.off b/Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/stress-test-3/test-5-rnd-polygons-1-3.off similarity index 100% rename from Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/polygon-splitter-test/test-5-rnd-polygons-1-3.off rename to Kinetic_shape_reconstruction/examples/Kinetic_shape_reconstruction/stress-test-3/test-5-rnd-polygons-1-3.off diff --git a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Data_structure.h b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Data_structure.h index e92571bad7a..9cdfcb15416 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Data_structure.h +++ b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Data_structure.h @@ -167,6 +167,38 @@ public: m_current_time(FT(0)) { } + void clear() { + m_support_planes.clear(); + m_intersection_graph.clear(); + m_volumes.clear(); + m_current_time = FT(0); + } + + template + void convert(DS& ds) { + + ds.clear(); + ds.resize(number_of_support_planes()); + CGAL_assertion(ds.number_of_support_planes() == number_of_support_planes()); + + m_intersection_graph.convert(ds.igraph()); + for (KSR::size_t i = 0; i < number_of_support_planes(); ++i) { + m_support_planes[i].convert(m_intersection_graph, ds.support_planes()[i]); + } + } + + KSR::vector& support_planes() { + return m_support_planes; + } + + Intersection_graph& igraph() { + return m_intersection_graph; + } + + void resize(const KSR::size_t number_of_items) { + m_support_planes.resize(number_of_items); + } + // TODO: It looks like here we lose precision during the conversion because // KSR::size_t is usually smaller than std::size_t! void reserve(const std::size_t number_of_polygons) { @@ -199,13 +231,21 @@ public: return (support_plane_idx < 6); } - const bool is_mesh_valid(const KSR::size_t support_plane_idx) const { + const bool is_mesh_valid( + const bool check_simplicity, + const bool check_convexity, + const KSR::size_t support_plane_idx) const { const bool is_valid = mesh(support_plane_idx).is_valid(); if (!is_valid) { return false; } + // bbox faces may have multiple equal points after converting from exact to inexact! + if (support_plane_idx < 6) { + return true; + } + for (const auto pface : pfaces(support_plane_idx)) { std::function unary_f = [&](const PVertex& pvertex) -> Point_2 { @@ -217,18 +257,18 @@ public: boost::make_transform_iterator(pvertices_of_pface(pface).end(), unary_f)); // Use only with an exact kernel! - // if (!polygon.is_simple()) { - // const std::string msg = "ERROR: pface " + str(pface) + " is not simple!"; - // CGAL_assertion_msg(false, msg.c_str()); - // return false; - // } + if (check_simplicity && !polygon.is_simple()) { + const std::string msg = "ERROR: pface " + str(pface) + " is not simple!"; + CGAL_assertion_msg(false, msg.c_str()); + return false; + } // Use only with an exact kernel! - // if (!polygon.is_convex()) { - // const std::string msg = "ERROR: pface " + str(pface) + " is not convex!"; - // CGAL_assertion_msg(false, msg.c_str()); - // return false; - // } + if (check_convexity && !polygon.is_convex()) { + const std::string msg = "ERROR: pface " + str(pface) + " is not convex!"; + CGAL_assertion_msg(false, msg.c_str()); + return false; + } auto prev = null_pvertex(); for (const auto pvertex : pvertices_of_pface(pface)) { @@ -252,6 +292,44 @@ public: return true; } + void check_integrity( + const bool check_simplicity = false, + const bool check_convexity = false) const { + + for (KSR::size_t i = 0; i < number_of_support_planes(); ++i) { + if (!is_mesh_valid(check_simplicity, check_convexity, i)) { + const std::string msg = "ERROR: mesh " + std::to_string(i) + " is not valid!"; + CGAL_assertion_msg(false, msg.c_str()); + } + + for (const auto& iedge : this->iedges(i)) { + const auto& iplanes = this->intersected_planes(iedge); + if (iplanes.find(i) == iplanes.end()) { + + const std::string msg = "ERROR: support_plane " + std::to_string(i) + + " is intersected by " + str(iedge) + + " but it claims it does not intersect it!"; + CGAL_assertion_msg(false, msg.c_str()); + } + } + } + + for (const auto iedge : this->iedges()) { + const auto& iplanes = this->intersected_planes(iedge); + for (const auto support_plane_idx : iplanes) { + + const auto& sp_iedges = this->iedges(support_plane_idx); + if (sp_iedges.find(iedge) == sp_iedges.end()) { + + const std::string msg = "ERROR: iedge " + str(iedge) + + " intersects support plane " + std::to_string(support_plane_idx) + + " but it claims it is not intersected by it!"; + CGAL_assertion_msg(false, msg.c_str()); + } + } + } + } + template const KSR::size_t add_support_plane(const PointRange& polygon) { @@ -401,8 +479,13 @@ public: const KSR::size_t support_plane_idx = add_support_plane(polygon); std::vector points; points.reserve(polygon.size()); - for (const auto& point : polygon) - points.push_back(support_plane(support_plane_idx).to_2d(point)); + for (const auto& point : polygon) { + const Point_3 converted( + static_cast(point.x()), + static_cast(point.y()), + static_cast(point.z())); + points.push_back(support_plane(support_plane_idx).to_2d(converted)); + } // const auto centroid = CGAL::centroid(points.begin(), points.end()); @@ -2185,8 +2268,8 @@ public: check_bbox(); check_vertices(); check_edges(); - create_volumes(); - check_faces(); + // create_volumes(); + // check_faces(); } void create_volumes() { diff --git a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Initializer.h b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Initializer.h new file mode 100644 index 00000000000..4d2cf8d2b07 --- /dev/null +++ b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Initializer.h @@ -0,0 +1,403 @@ +// Copyright (c) 2019 GeometryFactory SARL (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0+ +// +// Author(s) : Simon Giraudot + +#ifndef CGAL_KSR_3_INITIALIZER_H +#define CGAL_KSR_3_INITIALIZER_H + +// #include + +// Internal includes. +#include +#include +#include +#include + +namespace CGAL { +namespace KSR_3 { + +template +class Initializer { + +public: + using Kernel = GeomTraits; + +private: + using FT = typename Kernel::FT; + using Point_2 = typename Kernel::Point_2; + using Point_3 = typename Kernel::Point_3; + using Segment_3 = typename Kernel::Segment_3; + using Transform_3 = typename Kernel::Aff_transformation_3; + + using Data_structure = KSR_3::Data_structure; + using Polygon_splitter = KSR_3::Polygon_splitter; + + using Bbox_3 = CGAL::Bbox_3; + using IVertex = typename Data_structure::IVertex; + +public: + Initializer(const bool verbose) : + m_verbose(verbose) + { } + + template< + typename InputRange, + typename PolygonMap> + const double initialize( + const InputRange& input_range, + const PolygonMap polygon_map, + const unsigned int k, + const double enlarge_bbox_ratio, + const bool reorient) { + + if (m_verbose) { + std::cout << std::endl << "--- INITIALIZING KSR:" << std::endl; + } + + FT time_step; + std::array bbox; + create_bounding_box( + input_range, polygon_map, + static_cast(enlarge_bbox_ratio), + reorient, bbox, time_step); + if (m_verbose) { + std::cout << "* precomputed time_step: " << time_step << std::endl; + } + + std::vector< std::vector > bbox_faces; + bounding_box_to_polygons(bbox, bbox_faces); + add_polygons(input_range, polygon_map, bbox_faces); + + if (m_verbose) { + std::cout << "* intersecting input polygons ..."; + KSR_3::dump(m_data, "init"); + // KSR_3::dump_segmented_edges(m_data, "init"); + } + + m_data.check_integrity(); + make_polygons_intersection_free(); + m_data.check_integrity(); + set_k_intersections(k); + + if (m_verbose) { + KSR_3::dump(m_data, "intersected"); + // KSR_3::dump_segmented_edges(m_data, "intersected"); + std::cout << " done" << std::endl; + } + + // for (KSR::size_t i = 6; i < m_data.number_of_support_planes(); ++i) { + // const auto& sp = m_data.support_plane(i); + // std::cout << "plane index: " << i << std::endl; + // std::cout << "plane: " << + // sp.plane().a() << ", " << + // sp.plane().b() << ", " << + // sp.plane().c() << ", " << + // sp.plane().d() << std::endl; + // } + + m_data.check_bbox(); + return CGAL::to_double(time_step); + } + + template + void convert(DS& ds) { + + ds.clear(); + m_data.convert(ds); + m_data.clear(); + + ds.check_integrity(); + ds.check_bbox(); + } + +private: + const bool m_verbose; + Data_structure m_data; + + template< + typename InputRange, + typename PolygonMap> + void create_bounding_box( + const InputRange& input_range, + const PolygonMap polygon_map, + const FT enlarge_bbox_ratio, + const bool reorient, + std::array& bbox, + FT& time_step) const { + + if (reorient) + initialize_optimal_box(input_range, polygon_map, bbox); + else + initialize_axis_aligned_box(input_range, polygon_map, bbox); + + CGAL_assertion(bbox.size() == 8); + time_step = KSR::distance(bbox.front(), bbox.back()); + time_step /= FT(50); + + enlarge_bounding_box(enlarge_bbox_ratio, bbox); + + const auto& minp = bbox.front(); + const auto& maxp = bbox.back(); + if (m_verbose) { + std::cout << "* bounding box minp: " << + minp.x() << "\t, " << minp.y() << "\t, " << minp.z() << std::endl; + } + if (m_verbose) { + std::cout << "* bounding box maxp: " << + maxp.x() << "\t, " << maxp.y() << "\t\t, " << maxp.z() << std::endl; + } + } + + template< + typename InputRange, + typename PolygonMap> + void initialize_optimal_box( + const InputRange& input_range, + const PolygonMap polygon_map, + std::array& bbox) const { + + CGAL_assertion_msg(false, "TODO: IMPLEMENT THE ORIENTED OPTIMAL BBOX!"); + } + + template< + typename InputRange, + typename PolygonMap> + void initialize_axis_aligned_box( + const InputRange& input_range, + const PolygonMap polygon_map, + std::array& bbox) const { + + Bbox_3 box; + for (const auto& item : input_range) { + const auto& polygon = get(polygon_map, item); + box += CGAL::bbox_3(polygon.begin(), polygon.end()); + } + + // The order of faces corresponds to the standard order from here: + // https://doc.cgal.org/latest/BGL/group__PkgBGLHelperFct.html#gad9df350e98780f0c213046d8a257358e + bbox = { + Point_3(box.xmin(), box.ymin(), box.zmin()), + Point_3(box.xmax(), box.ymin(), box.zmin()), + Point_3(box.xmax(), box.ymax(), box.zmin()), + Point_3(box.xmin(), box.ymax(), box.zmin()), + Point_3(box.xmin(), box.ymax(), box.zmax()), + Point_3(box.xmin(), box.ymin(), box.zmax()), + Point_3(box.xmax(), box.ymin(), box.zmax()), + Point_3(box.xmax(), box.ymax(), box.zmax()) }; + } + + void enlarge_bounding_box( + const FT enlarge_bbox_ratio, + std::array& bbox) const { + + CGAL_assertion_msg( + enlarge_bbox_ratio > FT(1), "TODO: HANDLE THE CASE ENLARGE_BBOX_RATIO = FT(1)"); + const auto a = CGAL::centroid(bbox.begin(), bbox.end()); + Transform_3 scale(CGAL::Scaling(), enlarge_bbox_ratio); + for (auto& point : bbox) + point = scale.transform(point); + + const auto b = CGAL::centroid(bbox.begin(), bbox.end()); + Transform_3 translate(CGAL::Translation(), a - b); + for (auto& point : bbox) + point = translate.transform(point); + } + + void bounding_box_to_polygons( + const std::array& bbox, + std::vector< std::vector >& bbox_faces) const { + + bbox_faces.clear(); + bbox_faces.reserve(6); + + bbox_faces.push_back({bbox[0], bbox[1], bbox[2], bbox[3]}); + bbox_faces.push_back({bbox[0], bbox[1], bbox[6], bbox[5]}); + bbox_faces.push_back({bbox[1], bbox[2], bbox[7], bbox[6]}); + bbox_faces.push_back({bbox[2], bbox[3], bbox[4], bbox[7]}); + bbox_faces.push_back({bbox[3], bbox[0], bbox[5], bbox[4]}); + bbox_faces.push_back({bbox[5], bbox[6], bbox[7], bbox[4]}); + CGAL_assertion(bbox_faces.size() == 6); + + // Simon's bbox. The faces are different. + // const FT xmin = bbox[0].x(); + // const FT ymin = bbox[0].y(); + // const FT zmin = bbox[0].z(); + // const FT xmax = bbox[7].x(); + // const FT ymax = bbox[7].y(); + // const FT zmax = bbox[7].z(); + // const std::vector sbbox = { + // Point_3(xmin, ymin, zmin), + // Point_3(xmin, ymin, zmax), + // Point_3(xmin, ymax, zmin), + // Point_3(xmin, ymax, zmax), + // Point_3(xmax, ymin, zmin), + // Point_3(xmax, ymin, zmax), + // Point_3(xmax, ymax, zmin), + // Point_3(xmax, ymax, zmax) }; + + // bbox_faces.push_back({sbbox[0], sbbox[1], sbbox[3], sbbox[2]}); + // bbox_faces.push_back({sbbox[4], sbbox[5], sbbox[7], sbbox[6]}); + // bbox_faces.push_back({sbbox[0], sbbox[1], sbbox[5], sbbox[4]}); + // bbox_faces.push_back({sbbox[2], sbbox[3], sbbox[7], sbbox[6]}); + // bbox_faces.push_back({sbbox[1], sbbox[5], sbbox[7], sbbox[3]}); + // bbox_faces.push_back({sbbox[0], sbbox[4], sbbox[6], sbbox[2]}); + // CGAL_assertion(bbox_faces.size() == 6); + } + + template< + typename InputRange, + typename PolygonMap> + void add_polygons( + const InputRange& input_range, + const PolygonMap polygon_map, + const std::vector< std::vector >& bbox_faces) { + + m_data.reserve(input_range.size()); + add_bbox_faces(bbox_faces); + add_input_polygons(input_range, polygon_map); + } + + void add_bbox_faces( + const std::vector< std::vector >& bbox_faces) { + + for (const auto& bbox_face : bbox_faces) + m_data.add_bbox_polygon(bbox_face); + + CGAL_assertion(m_data.number_of_support_planes() == 6); + CGAL_assertion(m_data.ivertices().size() == 8); + CGAL_assertion(m_data.iedges().size() == 12); + + if (m_verbose) { + std::cout << "* added bbox faces: " << bbox_faces.size() << std::endl; + } + } + + template< + typename InputRange, + typename PolygonMap> + void add_input_polygons( + const InputRange& input_range, + const PolygonMap polygon_map) { + + KSR::size_t input_index = 0; + for (const auto& item : input_range) { + const auto& polygon = get(polygon_map, item); + m_data.add_input_polygon(polygon, input_index); + ++input_index; + } + CGAL_assertion(m_data.number_of_support_planes() > 6); + if (m_verbose) { + std::cout << "* added input polygons: " << input_range.size() << std::endl; + } + } + + void make_polygons_intersection_free() { + + // First, create all transverse intersection lines. + using Map_p2vv = std::map >; + Map_p2vv map_p2vv; + + for (const auto ivertex : m_data.ivertices()) { + const auto key = m_data.intersected_planes(ivertex, false); + if (key.size() < 2) { + continue; + } + + const auto pair = map_p2vv.insert(std::make_pair( + key, std::make_pair(ivertex, IVertex()))); + const bool is_inserted = pair.second; + if (!is_inserted) { + pair.first->second.second = ivertex; + } + } + + // Then, intersect these lines to find internal intersection vertices. + using Pair_pv = std::pair< KSR::Idx_set, KSR::vector >; + KSR::vector todo; + for (auto it_a = map_p2vv.begin(); it_a != map_p2vv.end(); ++it_a) { + const auto& set_a = it_a->first; + + todo.push_back(std::make_pair(set_a, KSR::vector())); + auto& crossed_vertices = todo.back().second; + crossed_vertices.push_back(it_a->second.first); + + std::set done; + for (auto it_b = map_p2vv.begin(); it_b != map_p2vv.end(); ++it_b) { + const auto& set_b = it_b->first; + + KSR::size_t common_plane_idx = KSR::no_element(); + std::set_intersection( + set_a.begin(), set_a.end(), set_b.begin(), set_b.end(), + boost::make_function_output_iterator( + [&](const KSR::size_t idx) -> void { + common_plane_idx = idx; + } + ) + ); + + if (common_plane_idx != KSR::no_element()) { + auto union_set = set_a; + union_set.insert(set_b.begin(), set_b.end()); + if (!done.insert(union_set).second) { + continue; + } + + Point_2 inter; + if (!KSR::intersection( + m_data.to_2d(common_plane_idx, + Segment_3(m_data.point_3(it_a->second.first), m_data.point_3(it_a->second.second))), + m_data.to_2d(common_plane_idx, + Segment_3(m_data.point_3(it_b->second.first), m_data.point_3(it_b->second.second))), + inter)) { + + continue; + } + + crossed_vertices.push_back( + m_data.add_ivertex(m_data.to_3d(common_plane_idx, inter), union_set)); + } + } + crossed_vertices.push_back(it_a->second.second); + } + + for (auto& t : todo) { + m_data.add_iedge(t.first, t.second); + } + + // Refine polygons. + for (KSR::size_t i = 0; i < m_data.number_of_support_planes(); ++i) { + Polygon_splitter splitter(m_data); + splitter.split_support_plane(i); + } + } + + void set_k_intersections(const unsigned int k) { + + for (KSR::size_t i = 0; i < m_data.number_of_support_planes(); ++i) { + for (const auto pface : m_data.pfaces(i)) { + m_data.k(pface) = k; + } + } + } +}; + +} // namespace KSR_3 +} // namespace CGAL + +#endif // CGAL_KSR_3_INITIALIZER_H diff --git a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Intersection_graph.h b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Intersection_graph.h index 4ed7965d637..fe02bbd0662 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Intersection_graph.h +++ b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Intersection_graph.h @@ -26,6 +26,9 @@ // Boost includes. #include +// CGAL includes. +#include + // Internal includes. #include @@ -77,12 +80,75 @@ private: KSR::size_t m_nb_lines; std::map m_map_points; std::map m_map_vertices; + std::map m_vmap; + std::map m_emap; public: Intersection_graph() : m_nb_lines(0) { } + void clear() { + m_graph.clear(); + m_nb_lines = 0; + m_map_points.clear(); + m_map_vertices.clear(); + } + + template + void convert(IG& ig) { + + using Converter = CGAL::Cartesian_converter; + + Converter converter; + ig.set_nb_lines(m_nb_lines); + + const auto vpair = boost::vertices(m_graph); + const auto vertex_range = CGAL::make_range(vpair); + for (const auto vertex : vertex_range) { + const auto vd = boost::add_vertex(ig.graph()); + ig.graph()[vd].point = converter(m_graph[vertex].point); + ig.graph()[vd].active = m_graph[vertex].active; + CGAL_assertion(m_graph[vertex].active); + m_vmap[vertex] = vd; + } + CGAL_assertion(boost::num_vertices(ig.graph()) == boost::num_vertices(m_graph)); + + const auto epair = boost::edges(m_graph); + const auto edge_range = CGAL::make_range(epair); + for (const auto edge : edge_range) { + const auto ed = boost::add_edge( + boost::source(edge, m_graph), boost::target(edge, m_graph), ig.graph()).first; + + CGAL_assertion(m_graph[edge].line >= 0); + ig.graph()[ed].line = m_graph[edge].line; + + CGAL_assertion(m_graph[edge].planes.size() >= 2); + ig.graph()[ed].planes = m_graph[edge].planes; + + CGAL_assertion(m_graph[edge].active); + ig.graph()[ed].active = m_graph[edge].active; + + m_emap[edge] = ed; + } + CGAL_assertion(boost::num_edges(ig.graph()) == boost::num_edges(m_graph)); + + // for (const auto& mp : m_map_points) { + // ig.mapped_points()[converter(mp.first)] = m_vmap.at(mp.second); + // } + // for (const auto& mv : m_map_vertices) { + // ig.mapped_vertices()[mv.first] = m_vmap.at(mv.second); + // } + } + + const std::map& vmap() const { + return m_vmap; + } + + const std::map& emap() const { + return m_emap; + } + static Vertex_descriptor null_ivertex() { return boost::graph_traits::null_vertex(); } @@ -93,6 +159,8 @@ public: const KSR::size_t add_line() { return ( m_nb_lines++ ); } const KSR::size_t nb_lines() const { return m_nb_lines; } + void set_nb_lines(const KSR::size_t value) { m_nb_lines = value; } + Graph& graph() { return m_graph; } const std::pair add_vertex(const Point_3& point) { diff --git a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Polygon_splitter.h b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Polygon_splitter.h index cb0bb419d86..150f88d69ad 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Polygon_splitter.h +++ b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Polygon_splitter.h @@ -32,12 +32,11 @@ // Internal includes. #include -#include namespace CGAL { namespace KSR_3 { -template +template class Polygon_splitter { public: @@ -51,19 +50,18 @@ private: using Vector_2 = typename Kernel::Vector_2; using Triangle_2 = typename Kernel::Triangle_2; - using PVertex = typename Data::PVertex; - using PFace = typename Data::PFace; - using PEdge = typename Data::PEdge; + using PVertex = typename Data_structure::PVertex; + using PFace = typename Data_structure::PFace; - using IVertex = typename Data::IVertex; - using IEdge = typename Data::IEdge; + using IVertex = typename Data_structure::IVertex; + using IEdge = typename Data_structure::IEdge; struct Vertex_info { PVertex pvertex; IVertex ivertex; Vertex_info() : - pvertex(Data::null_pvertex()), - ivertex(Data::null_ivertex()) + pvertex(Data_structure::null_pvertex()), + ivertex(Data_structure::null_ivertex()) { } }; @@ -92,13 +90,13 @@ private: using Face_index = typename Mesh_3::Face_index; using Uchar_map = typename Mesh_3::template Property_map; - Data& m_data; + Data_structure& m_data; TRI m_cdt; std::set m_input; std::map m_map_intersections; public: - Polygon_splitter(Data& data) : + Polygon_splitter(Data_structure& data) : m_data(data) { } @@ -143,7 +141,7 @@ public: points.push_back(points.front()); const auto cid = m_cdt.insert_constraint(points.begin(), points.end()); - m_map_intersections.insert(std::make_pair(cid, Data::null_iedge())); + m_map_intersections.insert(std::make_pair(cid, Data_structure::null_iedge())); } // Then, add intersection vertices + constraints. @@ -244,7 +242,7 @@ public: const auto source = face->vertex(m_cdt.ccw(idx)); const auto target = face->vertex(m_cdt.cw(idx)); - if (source->info().pvertex == Data::null_pvertex()) { + if (source->info().pvertex == Data_structure::null_pvertex()) { source->info().pvertex = m_data.add_pvertex( support_plane_idx, source->point()); } @@ -278,15 +276,15 @@ public: // Set intersection adjacencies. for (auto vit = m_cdt.finite_vertices_begin(); vit != m_cdt.finite_vertices_end(); ++vit) { - if (vit->info().pvertex != Data::null_pvertex() && - vit->info().ivertex != Data::null_ivertex()) { + if (vit->info().pvertex != Data_structure::null_pvertex() && + vit->info().ivertex != Data_structure::null_ivertex()) { m_data.connect(vit->info().pvertex, vit->info().ivertex); } } for (const auto& m : m_map_intersections) { - if (m.second == Data::null_iedge()) { + if (m.second == Data_structure::null_iedge()) { continue; } @@ -302,7 +300,9 @@ public: const auto b = *next; vit = next; - if (a->info().pvertex == Data::null_pvertex() || b->info().pvertex == Data::null_pvertex()) { + if ( + a->info().pvertex == Data_structure::null_pvertex() || + b->info().pvertex == Data_structure::null_pvertex()) { continue; } m_data.connect(a->info().pvertex, b->info().pvertex, m.second); @@ -311,12 +311,12 @@ public: for (const auto pvertex : m_data.pvertices(support_plane_idx)) { bool frozen = false; - auto iedge = Data::null_iedge(); - std::pair neighbors(Data::null_pvertex(), Data::null_pvertex()); + auto iedge = Data_structure::null_iedge(); + std::pair neighbors(Data_structure::null_pvertex(), Data_structure::null_pvertex()); for (const auto pedge : m_data.pedges_around_pvertex(pvertex)) { if (m_data.has_iedge(pedge)) { - if (iedge == Data::null_iedge()) { + if (iedge == Data_structure::null_iedge()) { iedge = m_data.iedge(pedge); } else { frozen = true; @@ -324,10 +324,10 @@ public: } } else { const auto opposite = m_data.opposite(pedge, pvertex); - if (neighbors.first == Data::null_pvertex()) { + if (neighbors.first == Data_structure::null_pvertex()) { neighbors.first = opposite; } else { - CGAL_assertion(neighbors.second == Data::null_pvertex()); + CGAL_assertion(neighbors.second == Data_structure::null_pvertex()); neighbors.second = opposite; } } @@ -340,11 +340,13 @@ public: } // No intersection incident = keep initial direction. - if (iedge == Data::null_iedge()) { + if (iedge == Data_structure::null_iedge()) { continue; } m_data.connect(pvertex, iedge); - CGAL_assertion(neighbors.first != Data::null_pvertex() && neighbors.second != Data::null_pvertex()); + CGAL_assertion( + neighbors.first != Data_structure::null_pvertex() && + neighbors.second != Data_structure::null_pvertex()); bool first_okay = (m_input.find(neighbors.first) != m_input.end()); auto latest = pvertex; @@ -414,7 +416,7 @@ private: if (iter == m_map_intersections.end()) { continue; } - if (iter->second == Data::null_iedge()) { + if (iter->second == Data_structure::null_iedge()) { return true; } } diff --git a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Support_plane.h b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Support_plane.h index a3b56b5ebc3..7e0aeb74079 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Support_plane.h +++ b/Kinetic_shape_reconstruction/include/CGAL/KSR_3/Support_plane.h @@ -90,15 +90,54 @@ private: std::shared_ptr m_data; public: - Support_plane() { } + Support_plane() : + m_data(std::make_shared()) { + + m_data->direction = m_data->mesh.template add_property_map( + "v:direction", CGAL::NULL_VECTOR).first; + + m_data->v_ivertex_map = m_data->mesh.template add_property_map( + "v:ivertex", Intersection_graph::null_ivertex()).first; + + m_data->v_iedge_map = m_data->mesh.template add_property_map( + "v:iedge", Intersection_graph::null_iedge()).first; + + m_data->v_active_map = m_data->mesh.template add_property_map( + "v:active", true).first; + + m_data->e_iedge_map = m_data->mesh.template add_property_map( + "e:iedge", Intersection_graph::null_iedge()).first; + + m_data->input_map = m_data->mesh.template add_property_map( + "f:input", KSR::no_element()).first; + + m_data->k_map = m_data->mesh.template add_property_map( + "f:k", 0).first; + + m_data->v_original_map = m_data->mesh.template add_property_map( + "v:original", false).first; + + m_data->v_time_map = m_data->mesh.template add_property_map( + "v:time", FT(0)).first; + } template - Support_plane(const PointRange& points) : + Support_plane(const PointRange& polygon) : m_data(std::make_shared()) { + std::vector points; + points.reserve(polygon.size()); + for (const auto& point : polygon) { + points.push_back(Point_3( + static_cast(point.x()), + static_cast(point.y()), + static_cast(point.z()))); + } + const std::size_t n = points.size(); + CGAL_assertion(n == polygon.size()); + // Newell's method. Vector_3 normal = CGAL::NULL_VECTOR; - const std::size_t n = points.size(); for (std::size_t i = 0; i < n; ++i) { const auto& pa = points[i]; const auto& pb = points[(i + 1) % n]; @@ -110,26 +149,161 @@ public: CGAL_assertion_msg(normal != CGAL::NULL_VECTOR, "ERROR: polygon is flat!"); m_data->plane = Plane_3(points[0], KSR::normalize(normal)); - m_data->direction = m_data->mesh.template add_property_map( + + m_data->direction = m_data->mesh.template add_property_map( "v:direction", CGAL::NULL_VECTOR).first; - m_data->v_ivertex_map = m_data->mesh.template add_property_map( + + m_data->v_ivertex_map = m_data->mesh.template add_property_map( "v:ivertex", Intersection_graph::null_ivertex()).first; - m_data->v_iedge_map = m_data->mesh.template add_property_map( + + m_data->v_iedge_map = m_data->mesh.template add_property_map( "v:iedge", Intersection_graph::null_iedge()).first; - m_data->v_active_map = m_data->mesh.template add_property_map( + + m_data->v_active_map = m_data->mesh.template add_property_map( "v:active", true).first; - m_data->e_iedge_map = m_data->mesh.template add_property_map( + + m_data->e_iedge_map = m_data->mesh.template add_property_map( "e:iedge", Intersection_graph::null_iedge()).first; - m_data->input_map = m_data->mesh.template add_property_map( + + m_data->input_map = m_data->mesh.template add_property_map( "f:input", KSR::no_element()).first; - m_data->k_map = m_data->mesh.template add_property_map( + + m_data->k_map = m_data->mesh.template add_property_map( "f:k", 0).first; + m_data->v_original_map = m_data->mesh.template add_property_map( "v:original", false).first; - m_data->v_time_map = m_data->mesh.template add_property_map( + + m_data->v_time_map = m_data->mesh.template add_property_map( "v:time", FT(0)).first; } + template + void convert(const IG& ig, SP& sp) { + + using CPoint_2 = typename SP::Kernel::Point_2; + using Converter = CGAL::Cartesian_converter; + Converter converter; + + const auto& vmap = ig.vmap(); + const auto& emap = ig.emap(); + + std::set pts; + std::map map_vi; + sp.data().plane = converter(m_data->plane); + for (const auto& vertex : m_data->mesh.vertices()) { + const auto converted = converter(m_data->mesh.point(vertex)); + const bool is_inserted = pts.insert(converted).second; + const auto vi = sp.data().mesh.add_vertex(); + map_vi[vertex] = vi; + + if (is_inserted) { + sp.data().mesh.point(vi) = converted; + } else { + sp.data().mesh.point(vi) = converted; + + // using CFT = typename SP::Kernel::FT; + // const CFT b1 = CFT(9) / CFT(10); + // const CFT b2 = CFT(1) / CFT(10); + + // const auto pi = this->prev(vertex); + // const auto pc = converter(m_data->mesh.point(pi)); + // const auto ni = this->next(vertex); + // const auto nc = converter(m_data->mesh.point(ni)); + + // if (nc != converted) { + // const auto x = b1 * converted.x() + b2 * nc.x(); + // const auto y = b1 * converted.y() + b2 * nc.y(); + // const CPoint_2 new_point(x, y); + // sp.data().mesh.point(vi) = new_point; + // // std::cout << "or: " << to_3d(Point_2(converted.x(), converted.y())) << std::endl; + // // std::cout << "nc: " << to_3d(Point_2(new_point.x(), new_point.y())) << std::endl; + // } else if (pc != converted) { + // const auto x = b1 * converted.x() + b2 * pc.x(); + // const auto y = b1 * converted.y() + b2 * pc.y(); + // const CPoint_2 new_point(x, y); + // sp.data().mesh.point(vi) = new_point; + // // std::cout << "or: " << to_3d(Point_2(converted.x(), converted.y())) << std::endl; + // // std::cout << "pc: " << to_3d(Point_2(new_point.x(), new_point.y())) << std::endl; + // } else { + // CGAL_assertion_msg(false, "ERROR: WE HAVE THREE EQUAL POINTS!"); + // } + } + } + CGAL_assertion(sp.data().mesh.number_of_vertices() == m_data->mesh.number_of_vertices()); + + std::map map_fi; + std::vector mapped_vertices; + for (const auto& face : m_data->mesh.faces()) { + const auto vertices = CGAL::vertices_around_face( + m_data->mesh.halfedge(face), m_data->mesh); + + mapped_vertices.clear(); + mapped_vertices.reserve(vertices.size()); + for (const auto vertex : vertices) { + mapped_vertices.push_back(map_vi.at(vertex)); + } + CGAL_assertion(mapped_vertices.size() == vertices.size()); + const auto fi = sp.data().mesh.add_face(mapped_vertices); + map_fi[face] = fi; + } + CGAL_assertion(sp.data().mesh.number_of_faces() == m_data->mesh.number_of_faces()); + + for (const auto& vertex : m_data->mesh.vertices()) { + const auto vi = map_vi.at(vertex); + sp.data().direction[vi] = converter(m_data->direction[vertex]); + + const auto ivertex = m_data->v_ivertex_map[vertex]; + if (ivertex != IG::null_ivertex()) { + sp.data().v_ivertex_map[vi] = vmap.at(ivertex); + } else { + sp.data().v_ivertex_map[vi] = ivertex; + } + + const auto iedge = m_data->v_iedge_map[vertex]; + if (iedge != IG::null_iedge()) { + sp.data().v_iedge_map[vi] = emap.at(iedge); + } else { + sp.data().v_iedge_map[vi] = iedge; + } + + sp.data().v_active_map[vi] = m_data->v_active_map[vertex]; + sp.data().v_original_map[vi] = m_data->v_original_map[vertex]; + sp.data().v_time_map[vi] = converter(m_data->v_time_map[vertex]); + } + + for (const auto& edge : m_data->mesh.edges()) { + const auto source = m_data->mesh.source(m_data->mesh.halfedge(edge)); + const auto target = m_data->mesh.target(m_data->mesh.halfedge(edge)); + + const auto s = map_vi[source]; + const auto t = map_vi[target]; + const auto he = sp.data().mesh.halfedge(s, t); + const auto ei = sp.data().mesh.edge(he); + + const auto iedge = m_data->e_iedge_map[edge]; + if (iedge != IG::null_iedge()) { + sp.data().e_iedge_map[ei] = emap.at(iedge); + } else { + sp.data().e_iedge_map[ei] = iedge; + } + } + + for (const auto& face : m_data->mesh.faces()) { + const auto fi = map_fi.at(face); + sp.data().input_map[fi] = m_data->input_map[face]; + sp.data().k_map[fi] = m_data->k_map[face]; + } + + sp.data().iedges.clear(); + for (const auto& iedge : m_data->iedges) { + CGAL_assertion(iedge != IG::null_iedge()); + sp.data().iedges.insert(emap.at(iedge)); + } + } + + Data& data() { return *m_data; } + const std::array add_bbox_polygon( const std::array& points, diff --git a/Kinetic_shape_reconstruction/include/CGAL/Kinetic_shape_reconstruction_3.h b/Kinetic_shape_reconstruction/include/CGAL/Kinetic_shape_reconstruction_3.h index 1dfea5c22fd..2e0535800cd 100644 --- a/Kinetic_shape_reconstruction/include/CGAL/Kinetic_shape_reconstruction_3.h +++ b/Kinetic_shape_reconstruction/include/CGAL/Kinetic_shape_reconstruction_3.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace CGAL { @@ -43,43 +43,39 @@ public: using Kernel = GeomTraits; private: - using FT = typename Kernel::FT; - using Point_2 = typename Kernel::Point_2; - using Point_3 = typename Kernel::Point_3; - using Segment_2 = typename Kernel::Segment_2; - using Segment_3 = typename Kernel::Segment_3; - using Vector_2 = typename Kernel::Vector_2; - using Transform_3 = typename Kernel::Aff_transformation_3; + using FT = typename Kernel::FT; + using Point_2 = typename Kernel::Point_2; + using Vector_2 = typename Kernel::Vector_2; + using Segment_2 = typename Kernel::Segment_2; - using Data = KSR_3::Data_structure; + using Data_structure = KSR_3::Data_structure; - using PVertex = typename Data::PVertex; - using PEdge = typename Data::PEdge; - using PFace = typename Data::PFace; + using PVertex = typename Data_structure::PVertex; + using PFace = typename Data_structure::PFace; - using IVertex = typename Data::IVertex; - using IEdge = typename Data::IEdge; + using IVertex = typename Data_structure::IVertex; + using IEdge = typename Data_structure::IEdge; - using Event = KSR_3::Event; - using Event_queue = KSR_3::Event_queue; + using Event = KSR_3::Event; + using Event_queue = KSR_3::Event_queue; - using Bbox_3 = CGAL::Bbox_3; - - // using EK = CGAL::Exact_predicates_exact_constructions_kernel; - using Polygon_splitter = KSR_3::Polygon_splitter; + using EK = CGAL::Exact_predicates_exact_constructions_kernel; + using Initializer = KSR_3::Initializer; private: - Data m_data; + Data_structure m_data; Event_queue m_queue; FT m_min_time; FT m_max_time; const bool m_verbose; + Initializer m_initializer; public: Kinetic_shape_reconstruction_3(const bool verbose = true) : m_min_time(-FT(1)), m_max_time(-FT(1)), - m_verbose(verbose) + m_verbose(verbose), + m_initializer(m_verbose) { } template< @@ -89,7 +85,7 @@ public: const InputRange& input_range, const PolygonMap polygon_map, const unsigned int k = 1, - const FT enlarge_bbox_ratio = FT(11) / FT(10), + const double enlarge_bbox_ratio = 1.1, const bool reorient = false) { if (m_verbose) std::cout.precision(20); @@ -105,59 +101,21 @@ public: return false; } - if (enlarge_bbox_ratio < FT(1)) { - CGAL_warning_msg(enlarge_bbox_ratio >= FT(1), - "WARNING: YOU SET ENLARGE_BBOX_RATIO < 1. THE VALID RANGE IS [1, +INF). RETURN WITH NO CHANGE!"); + if (enlarge_bbox_ratio < 1.0) { + CGAL_warning_msg(enlarge_bbox_ratio >= 1.0, + "WARNING: YOU SET ENLARGE_BBOX_RATIO < 1.0. THE VALID RANGE IS [1.0, +INF). RETURN WITH NO CHANGE!"); return false; } - if (m_verbose) { - std::cout << std::endl << "--- INITIALIZING KSR:" << std::endl; - } + const FT time_step = static_cast(m_initializer.initialize( + input_range, polygon_map, k, enlarge_bbox_ratio, reorient)); + m_initializer.convert(m_data); - FT time_step; - std::array bbox; - create_bounding_box( - input_range, polygon_map, enlarge_bbox_ratio, reorient, bbox, time_step); - if (m_verbose) { - std::cout << "* precomputed time_step: " << time_step << std::endl; - } - - std::vector< std::vector > bbox_faces; - bounding_box_to_polygons(bbox, bbox_faces); - add_polygons(input_range, polygon_map, bbox_faces); - - if (m_verbose) { - std::cout << "* intersecting input polygons ..."; - KSR_3::dump(m_data, "init"); - // KSR_3::dump_segmented_edges(m_data, "init"); - } - - check_integrity(); - make_polygons_intersection_free(); - check_integrity(); - set_k_intersections(k); - - if (m_verbose) { - KSR_3::dump(m_data, "intersected"); - // KSR_3::dump_segmented_edges(m_data, "intersected"); - std::cout << " done" << std::endl; - } - - // for (KSR::size_t i = 6; i < m_data.number_of_support_planes(); ++i) { - // const auto& sp = m_data.support_plane(i); - // std::cout << "plane index: " << i << std::endl; - // std::cout << "plane: " << - // sp.plane().a() << ", " << - // sp.plane().b() << ", " << - // sp.plane().c() << ", " << - // sp.plane().d() << std::endl; + // if (m_verbose) { + // std::cout << std::endl << "POLYGON SPLITTER SUCCESS!" << std::endl << std::endl; + // exit(EXIT_SUCCESS); // } - m_data.check_bbox(); - std::cout << std::endl << "POLYGON SPLITTER SUCCESS!" << std::endl << std::endl; - exit(EXIT_SUCCESS); - if (m_verbose) { std::cout << std::endl << "--- RUNNING THE QUEUE:" << std::endl; std::cout << "propagation started ..." << std::endl; @@ -171,7 +129,7 @@ public: run(k); m_min_time = m_max_time; m_max_time += time_step; - check_integrity(); + m_data.check_integrity(); ++num_iterations; // if (m_verbose) { @@ -193,13 +151,13 @@ public: std::cout << std::endl << "--- FINALIZING KSR:" << std::endl; std::cout << "* checking final mesh integrity ..."; } - check_integrity(); + m_data.check_integrity(); if (m_verbose) { dump(m_data, "iter_1000-final-result"); std::cout << " done" << std::endl; } - // m_data.create_polyhedrons(); + m_data.create_polyhedrons(); return true; } @@ -237,362 +195,50 @@ public: } private: - template< - typename InputRange, - typename PolygonMap> - void create_bounding_box( - const InputRange& input_range, - const PolygonMap polygon_map, - const FT enlarge_bbox_ratio, - const bool reorient, - std::array& bbox, - FT& time_step) const { - - if (reorient) - initialize_optimal_box(input_range, polygon_map, bbox); - else - initialize_axis_aligned_box(input_range, polygon_map, bbox); - - CGAL_assertion(bbox.size() == 8); - time_step = KSR::distance(bbox.front(), bbox.back()); - time_step /= FT(50); - - enlarge_bounding_box(enlarge_bbox_ratio, bbox); - - const auto& minp = bbox.front(); - const auto& maxp = bbox.back(); - if (m_verbose) { - std::cout << "* bounding box minp: " << - minp.x() << "\t, " << minp.y() << "\t, " << minp.z() << std::endl; - } - if (m_verbose) { - std::cout << "* bounding box maxp: " << - maxp.x() << "\t, " << maxp.y() << "\t\t, " << maxp.z() << std::endl; - } - } - - template< - typename InputRange, - typename PolygonMap> - void initialize_optimal_box( - const InputRange& input_range, - const PolygonMap polygon_map, - std::array& bbox) const { - - CGAL_assertion_msg(false, "TODO: IMPLEMENT THE ORIENTED OPTIMAL BBOX!"); - } - - template< - typename InputRange, - typename PolygonMap> - void initialize_axis_aligned_box( - const InputRange& input_range, - const PolygonMap polygon_map, - std::array& bbox) const { - - Bbox_3 box; - for (const auto& item : input_range) { - const auto& polygon = get(polygon_map, item); - box += CGAL::bbox_3(polygon.begin(), polygon.end()); - } - - // The order of faces corresponds to the standard order from here: - // https://doc.cgal.org/latest/BGL/group__PkgBGLHelperFct.html#gad9df350e98780f0c213046d8a257358e - bbox = { - Point_3(box.xmin(), box.ymin(), box.zmin()), - Point_3(box.xmax(), box.ymin(), box.zmin()), - Point_3(box.xmax(), box.ymax(), box.zmin()), - Point_3(box.xmin(), box.ymax(), box.zmin()), - Point_3(box.xmin(), box.ymax(), box.zmax()), - Point_3(box.xmin(), box.ymin(), box.zmax()), - Point_3(box.xmax(), box.ymin(), box.zmax()), - Point_3(box.xmax(), box.ymax(), box.zmax()) }; - } - - void enlarge_bounding_box( - const FT enlarge_bbox_ratio, - std::array& bbox) const { - - CGAL_assertion_msg( - enlarge_bbox_ratio > FT(1), "TODO: HANDLE THE CASE ENLARGE_BBOX_RATIO = FT(1)"); - const auto a = CGAL::centroid(bbox.begin(), bbox.end()); - Transform_3 scale(CGAL::Scaling(), enlarge_bbox_ratio); - for (auto& point : bbox) - point = scale.transform(point); - - const auto b = CGAL::centroid(bbox.begin(), bbox.end()); - Transform_3 translate(CGAL::Translation(), a - b); - for (auto& point : bbox) - point = translate.transform(point); - } - - void bounding_box_to_polygons( - const std::array& bbox, - std::vector< std::vector >& bbox_faces) const { - - bbox_faces.clear(); - bbox_faces.reserve(6); - - bbox_faces.push_back({bbox[0], bbox[1], bbox[2], bbox[3]}); - bbox_faces.push_back({bbox[0], bbox[1], bbox[6], bbox[5]}); - bbox_faces.push_back({bbox[1], bbox[2], bbox[7], bbox[6]}); - bbox_faces.push_back({bbox[2], bbox[3], bbox[4], bbox[7]}); - bbox_faces.push_back({bbox[3], bbox[0], bbox[5], bbox[4]}); - bbox_faces.push_back({bbox[5], bbox[6], bbox[7], bbox[4]}); - CGAL_assertion(bbox_faces.size() == 6); - - // Simon's bbox. The faces are different. - // const FT xmin = bbox[0].x(); - // const FT ymin = bbox[0].y(); - // const FT zmin = bbox[0].z(); - // const FT xmax = bbox[7].x(); - // const FT ymax = bbox[7].y(); - // const FT zmax = bbox[7].z(); - // const std::vector sbbox = { - // Point_3(xmin, ymin, zmin), - // Point_3(xmin, ymin, zmax), - // Point_3(xmin, ymax, zmin), - // Point_3(xmin, ymax, zmax), - // Point_3(xmax, ymin, zmin), - // Point_3(xmax, ymin, zmax), - // Point_3(xmax, ymax, zmin), - // Point_3(xmax, ymax, zmax) }; - - // bbox_faces.push_back({sbbox[0], sbbox[1], sbbox[3], sbbox[2]}); - // bbox_faces.push_back({sbbox[4], sbbox[5], sbbox[7], sbbox[6]}); - // bbox_faces.push_back({sbbox[0], sbbox[1], sbbox[5], sbbox[4]}); - // bbox_faces.push_back({sbbox[2], sbbox[3], sbbox[7], sbbox[6]}); - // bbox_faces.push_back({sbbox[1], sbbox[5], sbbox[7], sbbox[3]}); - // bbox_faces.push_back({sbbox[0], sbbox[4], sbbox[6], sbbox[2]}); - // CGAL_assertion(bbox_faces.size() == 6); - } - - template< - typename InputRange, - typename PolygonMap> - void add_polygons( - const InputRange& input_range, - const PolygonMap polygon_map, - const std::vector< std::vector >& bbox_faces) { - - m_data.reserve(input_range.size()); - add_bbox_faces(bbox_faces); - add_input_polygons(input_range, polygon_map); - } - - void add_bbox_faces( - const std::vector< std::vector >& bbox_faces) { - - for (const auto& bbox_face : bbox_faces) - m_data.add_bbox_polygon(bbox_face); - - CGAL_assertion(m_data.number_of_support_planes() == 6); - CGAL_assertion(m_data.ivertices().size() == 8); - CGAL_assertion(m_data.iedges().size() == 12); - - if (m_verbose) { - std::cout << "* added bbox faces: " << bbox_faces.size() << std::endl; - } - } - - template< - typename InputRange, - typename PolygonMap> - void add_input_polygons( - const InputRange& input_range, - const PolygonMap polygon_map) { - - KSR::size_t input_index = 0; - for (const auto& item : input_range) { - const auto& polygon = get(polygon_map, item); - m_data.add_input_polygon(polygon, input_index); - ++input_index; - } - CGAL_assertion(m_data.number_of_support_planes() > 6); - if (m_verbose) { - std::cout << "* added input polygons: " << input_range.size() << std::endl; - } - } - - const bool check_integrity() const { - - for (KSR::size_t i = 0; i < m_data.number_of_support_planes(); ++i) { - if (!m_data.is_mesh_valid(i)) { - if (m_verbose) { - const std::string msg = "ERROR: mesh " + std::to_string(i) + " is not valid!"; - CGAL_assertion_msg(false, msg.c_str()); - } - return false; - } - - for (const auto& iedge : m_data.iedges(i)) { - const auto& iplanes = m_data.intersected_planes(iedge); - if (iplanes.find(i) == iplanes.end()) { - if (m_verbose) { - const std::string msg = "ERROR: support_plane " + std::to_string(i) + - " is intersected by " + m_data.str(iedge) + - " but it claims it does not intersect it!"; - CGAL_assertion_msg(false, msg.c_str()); - } - return false; - } - } - } - - for (const auto iedge : m_data.iedges()) { - const auto& iplanes = m_data.intersected_planes(iedge); - for (const auto support_plane_idx : iplanes) { - - const auto& sp_iedges = m_data.iedges(support_plane_idx); - if (sp_iedges.find(iedge) == sp_iedges.end()) { - - if (m_verbose) { - const std::string msg = "ERROR: iedge " + m_data.str(iedge) + - " intersects support plane " + std::to_string(support_plane_idx) + - " but it claims it is not intersected by it!"; - CGAL_assertion_msg(false, msg.c_str()); - } - return false; - } - } - } - return true; - } - - void make_polygons_intersection_free() { - - // First, create all transverse intersection lines. - using Map_p2vv = std::map >; - Map_p2vv map_p2vv; - - for (const auto ivertex : m_data.ivertices()) { - const auto key = m_data.intersected_planes(ivertex, false); - if (key.size() < 2) { - continue; - } - - const auto pair = map_p2vv.insert(std::make_pair( - key, std::make_pair(ivertex, IVertex()))); - const bool is_inserted = pair.second; - if (!is_inserted) { - pair.first->second.second = ivertex; - } - } - - // Then, intersect these lines to find internal intersection vertices. - using Pair_pv = std::pair< KSR::Idx_set, KSR::vector >; - KSR::vector todo; - for (auto it_a = map_p2vv.begin(); it_a != map_p2vv.end(); ++it_a) { - const auto& set_a = it_a->first; - - todo.push_back(std::make_pair(set_a, KSR::vector())); - auto& crossed_vertices = todo.back().second; - crossed_vertices.push_back(it_a->second.first); - - std::set done; - for (auto it_b = map_p2vv.begin(); it_b != map_p2vv.end(); ++it_b) { - const auto& set_b = it_b->first; - - KSR::size_t common_plane_idx = KSR::no_element(); - std::set_intersection( - set_a.begin(), set_a.end(), set_b.begin(), set_b.end(), - boost::make_function_output_iterator( - [&](const KSR::size_t idx) -> void { - common_plane_idx = idx; - } - ) - ); - - if (common_plane_idx != KSR::no_element()) { - auto union_set = set_a; - union_set.insert(set_b.begin(), set_b.end()); - if (!done.insert(union_set).second) { - continue; - } - - Point_2 inter; - if (!KSR::intersection( - m_data.to_2d(common_plane_idx, - Segment_3(m_data.point_3(it_a->second.first), m_data.point_3(it_a->second.second))), - m_data.to_2d(common_plane_idx, - Segment_3(m_data.point_3(it_b->second.first), m_data.point_3(it_b->second.second))), - inter)) { - - continue; - } - - crossed_vertices.push_back( - m_data.add_ivertex(m_data.to_3d(common_plane_idx, inter), union_set)); - } - } - crossed_vertices.push_back(it_a->second.second); - } - - for (auto& t : todo) { - m_data.add_iedge(t.first, t.second); - } - - // Refine polygons. - for (KSR::size_t i = 0; i < m_data.number_of_support_planes(); ++i) { - Polygon_splitter splitter(m_data); - splitter.split_support_plane(i); - } - } - - void set_k_intersections(const unsigned int k) { - - for (KSR::size_t i = 0; i < m_data.number_of_support_planes(); ++i) { - for (const auto pface : m_data.pfaces(i)) { - m_data.k(pface) = k; - } - } - } - - bool initialize_queue() - { - std::cout << "Initializing queue for events in [" << m_min_time << ";" << m_max_time << "]" << std::endl; + const bool initialize_queue() { + std::cout << "Initializing queue for events in [" << + m_min_time << ";" << m_max_time << "]" << std::endl; m_data.update_positions(m_max_time); - bool still_running = false; - for (KSR::size_t i = 0; i < m_data.number_of_support_planes(); ++ i) - { - KSR::vector iedges; - KSR::vector segments_2; - KSR::vector segment_bboxes; - init_search_structures (i, iedges, segments_2, segment_bboxes); - - for (const PVertex pvertex : m_data.pvertices(i)) - if (compute_events_of_vertex (pvertex, iedges, segments_2, segment_bboxes)) + KSR::vector iedges; + KSR::vector segments_2; + KSR::vector segment_bboxes; + for (KSR::size_t i = 0; i < m_data.number_of_support_planes(); ++i) { + init_search_structures(i, iedges, segments_2, segment_bboxes); + for (const PVertex pvertex : m_data.pvertices(i)) { + if (compute_events_of_vertex(pvertex, iedges, segments_2, segment_bboxes)) { still_running = true; + } + } } - m_data.update_positions(m_min_time); - return still_running; } - void init_search_structures (KSR::size_t i, - KSR::vector& iedges, - KSR::vector& segments_2, - KSR::vector& segment_bboxes) - { + void init_search_structures( + const KSR::size_t i, + KSR::vector& iedges, + KSR::vector& segments_2, + KSR::vector& segment_bboxes) { + + iedges.clear(); + segments_2.clear(); + segment_bboxes.clear(); + // To get random access, copy in vector (suboptimal to do this // all the time, maybe this should be done once and for all and - // replace the set) - iedges.reserve (m_data.iedges(i).size()); - std::copy (m_data.iedges(i).begin(), - m_data.iedges(i).end(), - std::back_inserter(iedges)); + // replace the set). + iedges.reserve(m_data.iedges(i).size()); + std::copy(m_data.iedges(i).begin(), m_data.iedges(i).end(), std::back_inserter(iedges)); - // Precompute segments and bboxes - segments_2.reserve (iedges.size()); - segment_bboxes.reserve (iedges.size()); - for (const IEdge& iedge : iedges) - { - segments_2.push_back (m_data.segment_2 (i, iedge)); - segment_bboxes.push_back (segments_2.back().bbox()); + // Precompute segments and bboxes. + segments_2.reserve(iedges.size()); + segment_bboxes.reserve(iedges.size()); + for (const IEdge& iedge : iedges) { + segments_2.push_back(m_data.segment_2(i, iedge)); + segment_bboxes.push_back(segments_2.back().bbox()); } } @@ -623,7 +269,7 @@ private: for (const PVertex& pother : { prev, next }) { - if (pother == Data::null_pvertex() + if (pother == Data_structure::null_pvertex() || !m_data.is_active(pother) || m_data.has_iedge (pother)) continue; @@ -761,7 +407,7 @@ private: // } apply(k, ev); - check_integrity(); + m_data.check_integrity(); // m_data.update_positions (0.5 * (current_time + m_queue.next().time())); // dump (m_data, "after_" + std::to_string(iter - 1)); diff --git a/Kinetic_shape_reconstruction/todo.md b/Kinetic_shape_reconstruction/todo.md index 8ce77d4ca0c..97b4586cd40 100644 --- a/Kinetic_shape_reconstruction/todo.md +++ b/Kinetic_shape_reconstruction/todo.md @@ -1,8 +1,7 @@ -* There is a random behavior for the test_polygons_ac.off case. Sometimes it works and sometimes not. -* Polygon_splitter bugs for the case test_1_polygon_b.off and for the case test_2_polygons_ad.off. * When we create a new face, should we use the initial k for it, e.g. 2 or should we copy the last counted k, e.g. 2 or 1? * Should we decrease k in the polygon splitter when two polygons are intersected at the very beginning? * Should we count the number of intersections per polygon or per mesh face? * Should we keep facei-facej number of intersections? -* When we do a test e.g. 6 polygons intersect k = 6 times all intersections between polygons are already inserted for k = 5 and do not change for k = 6. For 3 input polygons, they are inserted only for k = 3. Is it correct behaviour? -* Use the exact tag in the Delaunay triangulation. \ No newline at end of file +* Use the exact tag in the Delaunay triangulation. +* After converting exact to inexact, we may have equal points in the bbox faces. We should fix that. +* Can we accelerate initializer when using exact kernel? \ No newline at end of file