package com.cringe_studios.christmastreescanning;

import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;

import com.cringe_studios.christmastreescanning.scanning.SideScanner;
import com.cringe_studios.christmastreescanning.scanning.SingleColoredSideScanner;

public class FourSidedScanner extends SingleColorScanner {
	private SideScanner frontSideScanner;
	private SideScanner rightSideScanner;
	private SideScanner behindSideScanner;
	private SideScanner leftSideScanner;
	
	BufferedImage frontSideImages[];
	BufferedImage rightSideImages[];
	BufferedImage behindSideImages[];
	BufferedImage leftSideImages[];
	
	public FourSidedScanner(BufferedImage frontSideImages[], BufferedImage rightSideImages[], BufferedImage behindSideImages[], BufferedImage leftSideImages[]) {
		this.frontSideImages  = frontSideImages;
		this.rightSideImages  = rightSideImages;
		this.behindSideImages = behindSideImages;
		this.leftSideImages   = leftSideImages;
		
		//TODO
		
	}
	
	@Override	
	public Homograph scan() {
		frontSideScanner =  new SingleColoredSideScanner(frontSideImages, this.gammaDelta);
		rightSideScanner =  new SingleColoredSideScanner(rightSideImages, this.gammaDelta);
		behindSideScanner = new SingleColoredSideScanner(behindSideImages, this.gammaDelta);
		leftSideScanner =   new SingleColoredSideScanner(leftSideImages, this.gammaDelta);
		
		frontSideScanner.scan();
		frontSideScanner.normalizePoints();
		Point2D[] frontPoints = frontSideScanner.getPoints();
		
		rightSideScanner.scan();
		rightSideScanner.normalizePoints();
		Point2D[] rightSidePoints = rightSideScanner.getPoints();
		
		behindSideScanner.scan();
		behindSideScanner.normalizePoints();
		Point2D[] behindSidePoints = behindSideScanner.getPoints();
		
		leftSideScanner.scan();
		leftSideScanner.normalizePoints();
		Point2D[] leftSidePoints = leftSideScanner.getPoints();
		
		return new Homograph4(frontPoints, rightSidePoints, behindSidePoints, leftSidePoints);
	}
}
