#include "Behaviors/StateMachine.h"

using namespace DualCoding;

$nodeclass Lab5Q4 : VisualRoutinesStateNode{
	$nodeclass GetBoundary : VisualRoutinesStateNode: doStart{
		int const threshold = 1000;
		NEW_SKETCH(depthFrame, usint, sketchFromDepth() );
		//NEW_SKETCH(empty, bool, visops::zeros(camSkS));
		//can be extende to 8-way
		camSkS.requireIdx4way();
		

		NEW_SKETCH(idxS, usint, depthFrame[*camSkS.idxS]);	
		NEW_SKETCH(south, bool, depthFrame - depthFrame[*camSkS.idxS] > threshold);
		NEW_SKETCH(north, bool, depthFrame - depthFrame[*camSkS.idxN] > threshold);
		NEW_SKETCH(east, bool, depthFrame - depthFrame[*camSkS.idxE] > threshold);
		NEW_SKETCH(west, bool, depthFrame - depthFrame[*camSkS.idxW] > threshold);
		NEW_SKETCH(result, bool, south | north | east | west);
	}

	$setupmachine {
		GetBoundary
	}

}

REGISTER_BEHAVIOR(Lab5Q4);
