test.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <sstream>
00003 
00004 #include "hex.h"
00005 #include "hexsvg.h"
00006 #include "hexmove.h"
00007 
00008 using namespace std;
00009 
00010 
00011 int main()
00012 {
00013   using namespace hex;
00014   hex::Grid g(10,10);
00015   hex::svg::Document d(g);
00016   std::ostringstream os;
00017   hex::Point margin(0.5,0.5);
00018   d.p0 -= margin;
00019   d.p1 += margin;
00020   os<<d.header();
00021 
00022   hex::Area a =hex::Path(g.hex(1,1),g.hex(7,4)).to_area();
00023 
00024   hex::Boundary b =a.boundary();
00025 
00026 
00027   Area r =hex::range(g.hex(5,5),2);
00028   r.style="fill:#ddf; stroke:#99f; stroke-width:0.04";
00029   os<<d.draw_complex_area(r,+0.5);
00030 
00031 //cerr<<r.str()<<endl;
00032 
00033   os<<"<g style=\"fill:none; stroke:green; stroke-width:0.04\">\n";
00034   float bias=0.04;
00035 //  os<<d.draw_complex_area( hex::Path(g.hex(1,3),g.hex(7,8)).to_area(),bias);
00036   a.style="stroke:red";
00037   os<<d.draw_complex_area( a, bias );
00038   os<<"</g>\n";
00039 
00040   Area ga =g.to_area();
00041   ga.style="fill:none; stroke:gray; stroke-width:0.01";
00042   os<<d.draw_skeleton( ga, true );
00043 /*
00044   hex::Path p =g.path("3_1:A");
00045   p.style="fill:none;stroke:#9f9; stroke-width:0.08; marker-end:url(#Triangle)";
00046   os<<d.draw_path( p );
00047   
00048   list<Edge*> le =p.to_area().boundary().edges();//.complement();
00049   le.pop_back();
00050   Boundary pb(le);
00051 //  pb =g.boundary( "4_2+DEFEFAFAFAFABABCBCDCDCDEFEDC" );
00052   pb.style="fill:none; stroke:#800; stroke-width:0.04; marker-end:url(#Triangle)";
00053   cerr<<pb.str()<<" "<<pb.is_closed()<<endl;
00054   os<<d.draw_boundary( pb, -0.3 );
00055 */
00056   hex::move::Topography move(1);
00057   move.increase_cost(r,2);
00058   move.increase_cost(a,100);
00059 cerr<<a.str()<<endl;
00060   hex::Path bp =move.best_path( g.hex(1,3),g.hex(8,5) );
00061   bp.style="fill:none;stroke:#33f; stroke-width:0.08; marker-end:url(#Triangle)";
00062   os<<d.draw_path(bp);
00063   hex::Area hz =move.horizon( g.hex(1,3), 3 );
00064   hz.style="fill:none;stroke:#33f; stroke-width:0.04; marker-end:url(#Triangle)";
00065   os<<d.draw_simple_area(hz);
00066 
00067   os<<d.footer();
00068 
00069   cout<<os.str()<<endl;
00070 
00071   return 0;
00072 }

Generated on Thu Feb 21 00:00:54 2008 for libhex by  doxygen 1.5.1