#ifndef PAPERVISGRID_H
#define PAPERVISGRID_H

#include <Indoor/grid/Grid.h>
#include <Indoor/grid/factory/GridFactory.h>
#include <Indoor/grid/factory/GridImportance.h>

#include <Indoor/floorplan/FloorplanFactorySVG.h>

#include <Indoor/grid/walk/GridWalkLightAtTheEndOfTheTunnel.h>



#include <Indoor/nav/dijkstra/Dijkstra.h>
#include <Indoor/nav/dijkstra/DijkstraPath.h>

#include "PaperPlot.h"
#include "PaperPlot2D.h"

#include "../MyGridNode.h"
#include "../Settings.h"

#include "../Helper.h"

class PaperVisGrid {

public:


	static void show() {

		// the grid
		Grid<MyGridNode> grid(40);

		// floors
		Helper::FHWSFloors floors = Helper::getFloors(grid);
		Helper::buildTheGrid(grid, floors);

		PaperPlot plot("/tmp/grid.eps", PaperPlot::Size(4,3));

		// stairwell low left
		{BBox3 bbox;
		bbox.add(Point3(1300, 650,160));
		bbox.add(Point3(2000,1300,floors.h2.cm()));
		plot.debugGrid(grid, bbox, true, true, true);}
		plot.addFloor(floors.f1, floors.h1);
		plot.addFloor(floors.f2, floors.h2);

		plot.gp << "set view 64, 300\n";
		plot.gp << "unset cbrange\n";
		plot.gp << "unset colorbox\n";
		plot.gp << "unset xtics\n";
		plot.gp << "unset ytics\n";
		plot.gp << "unset ztics\n";
		plot.gp << "unset border\n";
		plot.gp << "set xrange[1250:2050]\n";
		plot.gp << "set yrange[600:1350]\n";
		plot.gp << "set hidden3d front\n";

		plot.show();

	}

	static void showStairs() {

		// the grid
		Grid<MyGridNode> grid(20);

		// floors
		Helper::FHWSFloors floors = Helper::getFloors(grid);
		Helper::buildTheGrid(grid, floors);

//		// load the floorplan
//		FloorplanFactorySVG fpFac(MiscSettings::floorplan, 2.822222);
//		Floor f0 = fpFac.getFloor("floor_0");
//		Floor f0 = fpFac.getFloor("floor_1");
//		const LengthF h0 = LengthF::cm(0);
//		const LengthF h1 = LengthF::cm(400);
//		const LengthF h2 = LengthF::cm(400+340);
//		const LengthF h3 = LengthF::cm(400+340+340);

		// add the floorplan to the grid

//		GridFactory<MyGridNode> gridFac(grid);

//		gridFac.addFloor(f0, h0.cm());
//		gridFac.addFloor(f1, h1.cm());
//		gridFac.addFloor(f2, h2.cm());
//		gridFac.addFloor(f3, h3.cm());

		// remove all isolated nodes not attached to 300,300,floor0
//		gridFac.removeIsolated( (MyGridNode&)grid.getNodeFor( GridPoint(300,300,h0.cm()) ) );

		PaperPlot plot;



		// stairwell low left
		{BBox3 bbox;
		bbox.add(Point3(1300, 650,000));
		bbox.add(Point3(2000,1300,1400));
		plot.debugGrid(grid, bbox, true, true);}

		// stairwell upper left
		{BBox3 bbox;
		bbox.add(Point3(1200,4758,000));
		bbox.add(Point3(1800,5158,1400));
		plot.debugGrid(grid, bbox, true, true);}

		// stairwell upper right
		{BBox3 bbox;
		bbox.add(Point3(6240,4718,000));
		bbox.add(Point3(6830,5158,1400));
		plot.debugGrid(grid, bbox, true, true);}

		// stair left
		{BBox3 bbox;
		bbox.add(Point3(1200,3200,000));
		bbox.add(Point3(1440,4078,1400));
		plot.debugGrid(grid, bbox, true, true);}

		// stair center
		{BBox3 bbox;
		bbox.add(Point3(4200,4118,100));
		bbox.add(Point3(6120,4438,1400));
		plot.debugGrid(grid, bbox, true, true);}

		//stair lower right
		{BBox3 bbox;
		bbox.add(Point3(7360,3358,000));
		bbox.add(Point3(7880,4300,500));
		plot.debugGrid(grid, bbox, true, true);}


		plot.show();

		sleep(1000);

	}



};

#endif // PAPERVISGRID_H
