00001 package commandline.Distributions; 00002 00003 import junit.framework.Assert; 00004 import junit.framework.AssertionFailedError; 00005 00006 import commandline.CodingUtils.State; 00007 import commandline.CodingUtils.StateVisitor; 00008 import commandline.ImageStuff.GeometricObjects.GenericEdge; 00009 import commandline.debuggingCode.Debug; 00010 00017 public class PMFVisitor implements StateVisitor{ 00018 private NormalIndicesDistribution normalIndicesDistribution_1A,normalIndicesDistribution_1B, 00019 normalIndicesDistribution_2A,normalIndicesDistribution_2B; 00020 private double[] PMF; 00021 //private VerticalDistribution_discr verticalDistribution_discr; 00022 public PMFVisitor(VerticalDistribution verticalDistribution){ 00023 PMF=null; 00024 normalIndicesDistribution_1A=verticalDistribution.getNormalIndicesDistribution_1A(); //new NormalIndicesDistribution_1A_discr(verticalDistribution_discr); 00025 normalIndicesDistribution_1B=verticalDistribution.getNormalIndicesDistribution_1B(); //new NormalIndicesDistribution_1B_discr(); 00026 normalIndicesDistribution_2A=verticalDistribution.getNormalIndicesDistribution_2A(); //new NormalIndicesDistribution_2A_discr(verticalDistribution_discr); 00027 normalIndicesDistribution_2B=verticalDistribution.getNormalIndicesDistribution_2B(); //new NormalIndicesDistribution_2B_discr(); 00028 //this.verticalDistribution_discr=verticalDistribution_discr; 00029 } 00030 00031 00032 public void VisitStateA(State state){ 00033 Assert.assertTrue(state.getGenericEdge().isFlat()); 00034 this.PMF=new double[]{0.5,0.5}; // er is maar één mogelijkheid voor de normale offset 00035 // @ TODO normaal is er maar één mogelijkheid maar dan moeten alle edges van lengte 2 altijd een n.o.=0 krijgen 00036 // --> aanpassing kan nog gebeuren 00037 try{ 00038 Assert.assertTrue(state.getGenericEdge().getNormalOffset()==state.getGenericEdge().getMiddenIndex()); 00039 }catch(AssertionFailedError exception){ 00040 Debug.print("normal offset for flat edge is not zero!"); 00041 } 00042 } 00043 public void VisitStateB(State state){ 00044 GenericEdge edge=state.getGenericEdge(); 00045 float H=edge.getHoogte(); 00046 float length=edge.getEuclidischeLengte(); 00047 // double lambda=verticalDistribution.getLambda_streep(); 00048 if(H<length){ 00049 //this.PMF=normalIndicesDistribution_1A.getPMF(H,length,L,lambda,n_0,n_1); 00050 this.PMF=normalIndicesDistribution_1A.getPMF_disc(edge); 00051 }else{ 00052 //this.PMF=normalIndicesDistribution_1B.getPMF(H,length,L,lambda,n_0,n_1); 00053 this.PMF=normalIndicesDistribution_1B.getPMF_disc(edge); 00054 } 00055 00056 } 00057 00058 public void VisitStateC(State state){ 00059 GenericEdge edge=state.getGenericEdge(); 00060 float H=edge.getHoogte(); 00061 float length=edge.getEuclidischeLengte(); 00062 // double lambda=verticalDistribution.getLambda_streep(); 00063 if(H<length){ 00064 // this.PMF=normalIndicesDistribution_2A.getPMF(H,length,L,lambda,n_0,n_1); 00065 this.PMF=normalIndicesDistribution_2A.getPMF_disc(edge); 00066 }else{ 00067 // this.PMF=normalIndicesDistribution_2B.getPMF(H,length,L,lambda,n_0,n_1); 00068 this.PMF=normalIndicesDistribution_2B.getPMF_disc(edge); 00069 } 00070 } 00071 00072 public double[] getPMF() { 00073 return PMF; 00074 } 00075 00076 00077 00078 00079 }
1.5.5