#include "Behaviors/StateMachine.h"

$nodeclass Vee : VisualRoutinesStateNode {


        $setupmachine {

        FindLines =C=> DoSketches =C=> SpeechNode("done");

        }

	$nodeclass FindLines : MapBuilderNode() : doStart {
		mapreq.addObjectColor(lineDataType,"red");
	}

        $nodeclass DoSketches : StateNode : doStart {

        NEW_SHAPEVEC(lines, LineData, select_type<LineData>(camShS));
	cout << "size of shapevec is " << lines.size() << endl;
	int i = 0;
	Shape<LineData> line1;
	Shape<LineData> line2;
	SHAPEVEC_ITERATE(lines, LineData, someLine)
	
	if(i == 0)
		line1 = someLine;
	if(i == 1)
		line2 = someLine;
	if(i ==2)
		break;
			
	i++;
	
	cout << "iteration" << endl;
	END_ITERATE;

	if(i < 1)
	{
		cout<< "not enough shapes" << endl;
		return;
	}

	NEW_SKETCH(red_line, bool, visops::topHalfPlane(line1));
	NEW_SKETCH(red_line2, bool, visops::topHalfPlane(line2));

	NEW_SKETCH(combined, bool, visops::min(red_line, red_line2));

	NEW_SKETCH(eggcolor, bool, visops::colormask(sketchFromSeg(), "blue"));	
	NEW_SKETCH(eggSketch, bool, visops::labelcc(eggcolor));

	NEW_SKETCH(final, bool , visops::min(eggSketch, combined));
	
	}		
}

REGISTER_BEHAVIOR(Vee);

