/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package colorsegmentation;

import baseclasses.Frame;
import baseclasses.ObjImport;
import baseclasses.ObjExport;
import baseclasses.Point;
import java.awt.Color;
import java.io.IOException;
import java.util.ArrayList;

/**
 *
 * @author Alex
 */
public class MeshSegmentation {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        
        int[] redRGB = {255, 0, 0};
//        int[] redRGB = {219, 108, 102};
//        int[] redRGB = {138, 95, 86};
        int[] greRGB = {0, 255, 0};
//        int[] greRGB = {145, 162, 179};
//        int[] greRGB = {115, 166, 151};
        int[] bluRGB = {0, 0, 255};
//        int[] bluRGB = {137, 141, 99};
//        int[] bluRGB = {145, 191, 221};
        int[][] colorSpecs = {redRGB, greRGB, bluRGB};
//        int[][] colorSpecs = {redRGB, greRGB};
        double[] tol = {0.5, 0.3, 0.3};
        double[] tolR = {0.1, 0.2, 0.2};
        double[] tolG = {0.1, 0.2, 0.25};
        double[] tolB = {0.1, 0.2, 0.25};
        double[][] dotTol = {tolR, tolG, tolB};
//        double[][] dotTol = {tol, tol};
        ScanColorDotRegistration test1;
        test1 = new ScanColorDotRegistration("Scan3_15_1_focused_test.obj", 
                "Scan3_15_2_focused_test.obj", colorSpecs, dotTol);
        Frame fTest1 = test1.findTransformation();
        System.out.println("Frame:");
        fTest1.print();
        
        System.out.println("Applying Transformation");
        System.out.println("=======================");
        
        ObjImport fileB = new ObjImport("Scan3_15_1_skull.obj");
        try {
            fileB.read();
        } catch (IOException e) {
            System.out.println("bad file");
        }
        Point[] fileBPts = fileB.getPoints();
        Point[] fileBPtsTrans = fTest1.transform(fileBPts);
        
        System.out.println("\nExporting");
        System.out.println("=======================");
        ObjExport ex = new ObjExport("Scan3_15_1to2_focused_test.obj", 
                fileBPtsTrans, fileB.getTriangles());
        try {
            ex.write();
        } catch (IOException e) {
            System.out.println("Error on Export");
        }
    }
}
