//-*-c++-*-
#ifndef INCLUDED_FindArea_h_
#define INCLUDED_FindArea_h_

#include "Behaviors/Leapers.h"

#nodeclass FindArea: VisualRoutinesStateNode
	
    #shortnodeclass FindRedBalls : MapBuilderNode ($, MapBuilderRequest::localMap) : constructor
    	std::vector<Point> pts;
	pts.push_back(Point(9000,0,-2000));
	pts.push_back(Point(500,0,0));
	pts.push_back(Point(2000,4000,-2000));
	pts.push_back(Point(2000,-4000,-2000));
	pts.push_back(Point(2000,0,-4000));
	NEW_SHAPE(gazePoly, PolygonData, new PolygonData(localShS, Lookout::groundSearchPoints(), false));
	mapreq.searchArea = gazePoly;
	mapreq.motionSettleTime = 2000;
	mapreq.maxDist = 1e6;
	mapreq.clearShapes = true;
	mapreq.pursueShapes = true;
	mapreq.rawY = true;
	mapreq.addObjectColor (blobDataType, "red");

    #shortnodeclass GetLargestRedBall : VisualRoutinesStateNode : DoStart
	NEW_SHAPEVEC(blobs, BlobData, select_type<BlobData>(localShS));
	NEW_SHAPEVEC(colored, BlobData, subset(blobs, IsColor("red")));
	if(blobs.empty())
		postStateFailure();
	blobMarker = max_element(blobs, BlobData::AreaLessThan());
	cout<<"Are of biggest blob I saw is "<<blobMarker->getArea()<<endl;
	postStateCompletion();
		
	#shortnodemethod setup
		#statemachine
			startnode: FindRedBalls
			redball: GetLargestRedBall
			
			startnode =MAP=> redball
			
		#endstatemachine
		
#endnodeclass

#endif
