package ipp.imse.fusionOptics.apps.mse;

import ipp.imse.fusionOptics.mse.AugFaroNov2013;
import ipp.imse.fusionOptics.mse.AugMSESystem;
import ipp.imse.fusionOptics.mse.AugMseFaroData;
import fusionOptics.MinervaOpticsSettings;
import fusionOptics.Util;
import fusionOptics.drawing.VRMLDrawer;
import fusionOptics.interfaces.NullInterface;
import fusionOptics.optics.Box;
import fusionOptics.surfaces.Cylinder;
import fusionOptics.surfaces.Disc;
import fusionOptics.surfaces.Triangle;
import fusionOptics.types.Intersection;
import fusionOptics.types.RaySegment;
import otherSupport.ColorMaps;
import oneLiners.OneLiners;
import algorithmrepository.Algorithms;

public class MakeFARONov2013VRML {
	public static void main(String[] args) {
		AugFaroNov2013 faro = new AugFaroNov2013();
		
		String names[] = faro.getNames();
		
		VRMLDrawer vrmlOut = new VRMLDrawer("/work/ipp/augddd-models/faroNov2013.vrml", 0.005);
		vrmlOut.addVRML(AugMSESystem.vrmlScaleToAUGDDD);
		vrmlOut.setDrawPolarisationFrames(false);
		double w = 0.010;
		double uVecLen = 0.050;
		
		for(String name : names){
			double pos[] = faro.getPos(name);
			
			Box box = new Box(name, pos, w, w, w, null, NullInterface.ideal());
			vrmlOut.drawOptic(box);
			
			double uVec[] = faro.getUVec(name);
			if(uVec != null){
				RaySegment ray = new RaySegment();	
				ray.startPos = pos;
				ray.dir = uVec.clone();
				ray.length = uVecLen;
				ray.wavelength = 1;
				ray.endHit = new Intersection();
				ray.endHit.pos = Util.plus(pos, Util.mul(uVec, uVecLen));					
				ray.E0 = new double[][]{ { 1,0,0,0 } };
				ray.E1 = new double[][]{ { 1,0,0,0 } };
				ray.up = Util.createPerp(ray.dir);

				vrmlOut.drawRay(ray);	
			}
						
			double diam = faro.getDiameter(name);
			if(!Double.isNaN(diam) && uVec != null){				
				Disc disc = new Disc(name, pos, uVec, diam/2, NullInterface.ideal());
				vrmlOut.drawSurface(disc);
			}
		}
		
		
				
		vrmlOut.addVRML("}");
		vrmlOut.destroy();
	}
}
