diff --git a/build/pl_rubberband.o b/build/pl_rubberband.o index c0db8b4816f3ce79f0d279d2df15e3b25980fc4a..9b836956a47f40dfb831bd1722219ecad2f6ea9a 100644 Binary files a/build/pl_rubberband.o and b/build/pl_rubberband.o differ diff --git a/data/graph b/data/graph index 6a90d650a9fd08e30d934d264d76e016f3a266f2..2d56a4c02d2fbb37faf9389080732e5f12f8f38c 100644 --- a/data/graph +++ b/data/graph @@ -9,8 +9,8 @@ 1 2 0.0 2 0 0.0 -0 3 3.0 +0 3 1.0 1 3 1.0 1 4 1.0 -2 4 2.0 +2 4 1.0 3 4 1.0 \ No newline at end of file diff --git a/data/graph_2 b/data/graph_2 index 9c8ec7f2dcc10250610ef0034acb67f95136c325..37663d372000afcbded02e9b8fd38e0be28a9c70 100644 --- a/data/graph_2 +++ b/data/graph_2 @@ -1,10 +1,10 @@ 12 25 5 -0 0.0 1.0 -1 0.951 0.309 -2 0.587 -0.809 -3 -0.587 -0.809 -4 -0.951 0.309 +0 2.1067999697460698 -2.899761388407705 +1 -2.106799969746069 -2.899761388407706 +2 -3.4088739585463905 1.1076102911071575 +3 0 3.5843021946010944 +4 3.4088739585463905 1.1076102911071581 0 1 0.0 1 2 0.0 diff --git a/output/graph.eps b/output/graph.eps new file mode 100644 index 0000000000000000000000000000000000000000..d2568070d95bf87cb5f69de8270173f3ac5f6c5d --- /dev/null +++ b/output/graph.eps @@ -0,0 +1,89 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Creator: LEMON, graphToEps() +%%CreationDate: Sat Dec 14 16:35:21 2019 +%%BoundingBox: -13 -13 213 213 +%%EndComments +/lb { setlinewidth setrgbcolor newpath moveto + 4 2 roll 1 index 1 index curveto stroke } bind def +/l { setlinewidth setrgbcolor newpath moveto lineto stroke } bind def +/c { newpath dup 3 index add 2 index moveto 0 360 arc closepath } bind def +/sq { newpath 2 index 1 index add 2 index 2 index add moveto + 2 index 1 index sub 2 index 2 index add lineto + 2 index 1 index sub 2 index 2 index sub lineto + 2 index 1 index add 2 index 2 index sub lineto + closepath pop pop pop} bind def +/di { newpath 2 index 1 index add 2 index moveto + 2 index 2 index 2 index add lineto + 2 index 1 index sub 2 index lineto + 2 index 2 index 2 index sub lineto + closepath pop pop pop} bind def +/nc { 0 0 0 setrgbcolor 5 index 5 index 5 index c fill + setrgbcolor 1.1 div c fill + } bind def +/nsq { 0 0 0 setrgbcolor 5 index 5 index 5 index sq fill + setrgbcolor 1.1 div sq fill + } bind def +/ndi { 0 0 0 setrgbcolor 5 index 5 index 5 index di fill + setrgbcolor 1.1 div di fill + } bind def +/nfemale { 0 0 0 setrgbcolor 3 index 0.0909091 1.5 mul mul setlinewidth + newpath 5 index 5 index moveto 5 index 5 index 5 index 3.01 mul sub + lineto 5 index 4 index .7 mul sub 5 index 5 index 2.2 mul sub moveto + 5 index 4 index .7 mul add 5 index 5 index 2.2 mul sub lineto stroke + 5 index 5 index 5 index c fill + setrgbcolor 1.1 div c fill + } bind def +/nmale { + 0 0 0 setrgbcolor 3 index 0.0909091 1.5 mul mul setlinewidth + newpath 5 index 5 index moveto + 5 index 4 index 1 mul 1.5 mul add + 5 index 5 index 3 sqrt 1.5 mul mul add + 1 index 1 index lineto + 1 index 1 index 7 index sub moveto + 1 index 1 index lineto + exch 5 index 3 sqrt .5 mul mul sub exch 5 index .5 mul sub lineto + stroke + 5 index 5 index 5 index c fill + setrgbcolor 1.1 div c fill + } bind def +/arrl 1 def +/arrw 0.3 def +/lrl { 2 index mul exch 2 index mul exch rlineto pop} bind def +/arr { setrgbcolor /y1 exch def /x1 exch def /dy exch def /dx exch def + /w exch def /len exch def + newpath x1 dy w 2 div mul add y1 dx w 2 div mul sub moveto + len w sub arrl sub dx dy lrl + arrw dy dx neg lrl + dx arrl w add mul dy w 2 div arrw add mul sub + dy arrl w add mul dx w 2 div arrw add mul add rlineto + dx arrl w add mul neg dy w 2 div arrw add mul sub + dy arrl w add mul neg dx w 2 div arrw add mul add rlineto + arrw dy dx neg lrl + len w sub arrl sub neg dx dy lrl + closepath fill } bind def +/cshow { 2 index 2 index moveto dup stringwidth pop + neg 2 div fosi .35 mul neg rmoveto show pop pop} def + +gsave +100 dup scale +%Arcs: +gsave +0.789474 0.947368 1.21053 0.947368 0 0 0 0.00848528 l +2 0 1.21053 0.947368 0 0 0 0.00848528 l +1 2 1.21053 0.947368 0 0 0 0.00848528 l +1 2 0.789474 0.947368 0 0 0 0.00848528 l +1 2 2 0 0 0 0 0.00848528 l +0 0 0.789474 0.947368 0 0 0 0.00848528 l +0 0 2 0 0 0 0 0.00848528 l +0 0 1 2 0 0 0 0.00848528 l +grestore +%Nodes: +gsave +1.21053 0.947368 0.0282843 1 1 1 nc +0.789474 0.947368 0.0282843 1 1 1 nc +2 0 0.0282843 1 1 1 nc +1 2 0.0282843 1 1 1 nc +0 0 0.0282843 1 1 1 nc +grestore +grestore +showpage diff --git a/output/graph_2.eps b/output/graph_2.eps index d1d42f3b8b76a028290b4ab9843cac4dcd090b11..3850a09cdbd834eda8103140a5344b522e88f8ce 100644 --- a/output/graph_2.eps +++ b/output/graph_2.eps @@ -1,7 +1,7 @@ %!PS-Adobe-2.0 EPSF-2.0 %%Creator: LEMON, graphToEps() -%%CreationDate: Thu Dec 5 16:13:00 2019 -%%BoundingBox: -108 -94 108 113 +%%CreationDate: Sat Dec 14 17:38:42 2019 +%%BoundingBox: -361 -310 361 378 %%EndComments /lb { setlinewidth setrgbcolor newpath moveto 4 2 roll 1 index 1 index curveto stroke } bind def @@ -68,46 +68,46 @@ gsave 100 dup scale %Arcs: gsave --0.280883 -0.323493 -0.42839 -0.018524 0 0 0 0.00787469 l -0.173856 -0.141598 -0.280883 -0.323493 0 0 0 0.00787469 l -0.369568 0.240292 0.173856 -0.141598 0 0 0 0.00787469 l -0.33518 0.46834 0.369568 0.240292 0 0 0 0.00787469 l -0.018099 0.325358 -0.42839 -0.018524 0 0 0 0.00787469 l -0.018099 0.325358 0.173856 -0.141598 0 0 0 0.00787469 l -0.018099 0.325358 0.369568 0.240292 0 0 0 0.00787469 l -0.018099 0.325358 0.33518 0.46834 0 0 0 0.00787469 l --0.33981 0.404089 -0.42839 -0.018524 0 0 0 0.00787469 l --0.33981 0.404089 0.018099 0.325358 0 0 0 0.00787469 l --0.951 0.309 -0.42839 -0.018524 0 0 0 0.00787469 l --0.951 0.309 -0.33981 0.404089 0 0 0 0.00787469 l --0.587 -0.809 -0.42839 -0.018524 0 0 0 0.00787469 l --0.587 -0.809 -0.280883 -0.323493 0 0 0 0.00787469 l --0.587 -0.809 -0.951 0.309 0 0 0 0.00787469 l -0.587 -0.809 0.173856 -0.141598 0 0 0 0.00787469 l -0.587 -0.809 -0.587 -0.809 0 0 0 0.00787469 l -0.951 0.309 0.369568 0.240292 0 0 0 0.00787469 l -0.951 0.309 0.33518 0.46834 0 0 0 0.00787469 l -0.951 0.309 0.587 -0.809 0 0 0 0.00787469 l -0 1 0.33518 0.46834 0 0 0 0.00787469 l -0 1 0.018099 0.325358 0 0 0 0.00787469 l -0 1 -0.33981 0.404089 0 0 0 0.00787469 l -0 1 -0.951 0.309 0 0 0 0.00787469 l -0 1 0.951 0.309 0 0 0 0.00787469 l +0 1.38145 1.2232 0.769845 0 0 0 0.0282263 l +-0.611601 0.158244 0 1.38145 0 0 0 0.0282263 l +-0.611601 -1.67656 -0.611601 0.158244 0 0 0 0.0282263 l +0 -2.28816 -0.611601 -1.67656 0 0 0 0.0282263 l +0.611601 -1.06496 1.2232 0.769845 0 0 0 0.0282263 l +0.611601 -1.06496 -0.611601 0.158244 0 0 0 0.0282263 l +0.611601 -1.06496 -0.611601 -1.67656 0 0 0 0.0282263 l +0.611601 -1.06496 0 -2.28816 0 0 0 0.0282263 l +1.8348 -0.453357 1.2232 0.769845 0 0 0 0.0282263 l +1.8348 -0.453357 0.611601 -1.06496 0 0 0 0.0282263 l +3.40887 1.10761 1.2232 0.769845 0 0 0 0.0282263 l +3.40887 1.10761 1.8348 -0.453357 0 0 0 0.0282263 l +0 3.5843 1.2232 0.769845 0 0 0 0.0282263 l +0 3.5843 0 1.38145 0 0 0 0.0282263 l +0 3.5843 3.40887 1.10761 0 0 0 0.0282263 l +-3.40887 1.10761 -0.611601 0.158244 0 0 0 0.0282263 l +-3.40887 1.10761 0 3.5843 0 0 0 0.0282263 l +-2.1068 -2.89976 -0.611601 -1.67656 0 0 0 0.0282263 l +-2.1068 -2.89976 0 -2.28816 0 0 0 0.0282263 l +-2.1068 -2.89976 -3.40887 1.10761 0 0 0 0.0282263 l +2.1068 -2.89976 0 -2.28816 0 0 0 0.0282263 l +2.1068 -2.89976 0.611601 -1.06496 0 0 0 0.0282263 l +2.1068 -2.89976 1.8348 -0.453357 0 0 0 0.0282263 l +2.1068 -2.89976 3.40887 1.10761 0 0 0 0.0282263 l +2.1068 -2.89976 -2.1068 -2.89976 0 0 0 0.0282263 l grestore %Nodes: gsave --0.42839 -0.018524 0.026249 1 1 1 nc --0.280883 -0.323493 0.026249 1 1 1 nc -0.173856 -0.141598 0.026249 1 1 1 nc -0.369568 0.240292 0.026249 1 1 1 nc -0.33518 0.46834 0.026249 1 1 1 nc -0.018099 0.325358 0.026249 1 1 1 nc --0.33981 0.404089 0.026249 1 1 1 nc --0.951 0.309 0.026249 1 1 1 nc --0.587 -0.809 0.026249 1 1 1 nc -0.587 -0.809 0.026249 1 1 1 nc -0.951 0.309 0.026249 1 1 1 nc -0 1 0.026249 1 1 1 nc +1.2232 0.769845 0.0940876 1 1 1 nc +0 1.38145 0.0940876 1 1 1 nc +-0.611601 0.158244 0.0940876 1 1 1 nc +-0.611601 -1.67656 0.0940876 1 1 1 nc +0 -2.28816 0.0940876 1 1 1 nc +0.611601 -1.06496 0.0940876 1 1 1 nc +1.8348 -0.453357 0.0940876 1 1 1 nc +3.40887 1.10761 0.0940876 1 1 1 nc +0 3.5843 0.0940876 1 1 1 nc +-3.40887 1.10761 0.0940876 1 1 1 nc +-2.1068 -2.89976 0.0940876 1 1 1 nc +2.1068 -2.89976 0.0940876 1 1 1 nc grestore grestore showpage diff --git a/pl_rubberband.out b/pl_rubberband.out index a19bd6fbcd7fbbe073d07440378c2a9706c3e34f..c4ef0303a0f5b33b5d23587a9deaeb3264b136c3 100755 Binary files a/pl_rubberband.out and b/pl_rubberband.out differ diff --git a/src/pl_rubberband.cpp b/src/pl_rubberband.cpp index 0408bf906434d12037cdb02ba2e09b62c04fa6a6..b9c13b187fe821b2ff6f898eead97bbbf4882349 100644 --- a/src/pl_rubberband.cpp +++ b/src/pl_rubberband.cpp @@ -200,20 +200,13 @@ int main (int argc, const char *argv[]) { // python output std::cout << "["; - Graph_t::NodeIt u(graph); - Point_t & p = coordsMap[u]; - std::cout << "(" << p.x << ", " << p.y << ")"; - for(++u; u != lemon::INVALID; ++u) { - p = coordsMap[u]; - std::cout << ", (" << p.x << ", " << p.y << ")"; + Point_t & p = coordsMap[graph.nodeFromId(0)]; + std::cout << "[" << p.x << ", " << p.y << ", 0]"; + for(int i=1; i<n; i++) { + p = coordsMap[graph.nodeFromId(i)]; + std::cout << ",[" << p.x << ", " << p.y << ", 0]"; } std::cout << "]" << std::endl << "["; - Graph_t::EdgeIt e(graph); - std::cout << "(" << graph.id(graph.u(e)) << ", " << graph.id(graph.v(e)) << ")"; - for(++e; e != lemon::INVALID; ++e) { - std::cout << ", (" << graph.id(graph.u(e)) << ", " << graph.id(graph.v(e)) << ")"; - } - std::cout << "]" << std::endl; delete solver; delete solver_builder; diff --git a/tmp.py b/tmp.py index 2a8674fef19e0b0dbc6e1950623f858d473df71a..0e0495b5a3f45b3abcc7eef0db6ac43106bc43cc 100644 --- a/tmp.py +++ b/tmp.py @@ -8,5 +8,4 @@ angle = 2 * math.pi / nb_vertices for i in range(nb_vertices): x = center_x + radius * math.sin(i * angle) - y = center_y + radius * math.cos(i * angle) - print(x, y) \ No newline at end of file + y = center_y + radius * math.cos(i * angle) \ No newline at end of file