00001 package commandline.ImageStuff.GeometricObjects;
00002
00003 import commandline.ImageStuff.Image;
00004 import commandline.ImageStuff.Loc;
00005 import commandline.ImageStuff.Pixel;
00006
00007 import junit.framework.Assert;
00008
00009 public class TwoValuedParametrizedPiercingVertex extends
00010 ParametrizedPiercingVertex {
00011
00012 private ParametrizedPiercingVertex nextToLoc;
00013
00014
00015
00016 private GenericEdge parentEdge;
00017 public TwoValuedParametrizedPiercingVertex(ParametrizedPiercingVertex onLoc,
00018 ParametrizedPiercingVertex nextoLoc,float A_I,GenericEdge e) {
00019 super(onLoc.getLoc(), onLoc.getZ(),onLoc.getVerticalOffset(), A_I,e);
00020 this.nextToLoc=nextoLoc;
00021 this.parentEdge=e;
00022 Assert.assertNotNull(parentEdge);
00023 printThisAndNextTo();
00024 }
00025
00029 public TwoValuedParametrizedPiercingVertex(Pixel p,float x_param,float y_param){
00030 super(p,x_param,y_param);
00031 this.nextToLoc=this;
00032 parentEdge=null;
00033 }
00034
00043 public TwoValuedParametrizedPiercingVertex(Loc l, float z,int verticalOffset,float A_I,GenericEdge e){
00044 super(l, z,verticalOffset,A_I,e);
00045 this.nextToLoc=this;
00046 this.parentEdge=e;
00047 Assert.assertNotNull(parentEdge);
00048 printThisAndNextTo();
00049 }
00050
00051 private void printThisAndNextTo(){
00052 System.out.println("this pixel");
00053 this.getLoc().print();
00054 float val=this.getZ()+this.getVerticalOffset();
00055 System.out.println(val);
00056 System.out.println("next to loc pixel");
00057 this.nextToLoc.getLoc().print();
00058 val=this.nextToLoc.getZ()+this.nextToLoc.getVerticalOffset();
00059 System.out.println(val);
00060
00061 }
00062
00068 public boolean isEdgeLocatedOnEdgeOfThisPiercingPoint(GenericEdge e){
00069 Assert.assertNotNull(e);
00070 if(parentEdge==null){
00071 System.out.println("parent edge=null");
00072 return true;}
00073 if(!parentEdge.isRegistered) {System.err.println("parent edge wasn't registered so, no children yet-> implement with locs");
00074 System.exit(-1);}
00075 if(parentEdge.getBeginChild()==e || parentEdge.getEindChild()==e){
00076 return true;
00077 }
00078 return false;
00079 }
00080
00087 public ParametrizedPiercingVertex getSuitablePiercingVertexForNormalAndInterpolating(GenericEdge e){
00088 if(!isEdgeLocatedOnEdgeOfThisPiercingPoint(e)){
00089 System.out.println(this.getClass().getName()+ " -> return location at this point (new Edge)");
00090
00091 return this;
00092 }
00093
00094 if(e.getMidLoc().distance(nextToLoc)<e.getMidLoc().distance(this)){
00095 System.out.println(this.getClass().getName()+ " -> return location closest to edge (hierarchical Egde)");
00096
00097 return nextToLoc;
00098 }
00099
00100 return this;
00101 }
00102
00103 private void check(ParametrizedPiercingVertex parametrizedPiercingVertex){
00104 float grayvalue=parametrizedPiercingVertex.getZ()+parametrizedPiercingVertex.getVerticalOffset();
00105 System.out.println("z:= "+parametrizedPiercingVertex.getZ());
00106 System.out.println("v:= "+ parametrizedPiercingVertex.getVerticalOffset());
00107 System.out.println("gray:= "+ grayvalue);
00108 float original =Image.getInstance().getPuntOpEnty(parametrizedPiercingVertex).getZ();
00109 System.out.println("original:=" + original);
00110 }
00111
00115 public ParametrizedPiercingVertex getNextToLoc() {
00116 return nextToLoc;
00117 }
00118
00119 }