00001 package commandline.ImageStuff.Topology; 00002 00003 import java.util.ArrayList; 00004 import java.util.HashSet; 00005 00006 import commandline.CodingUtils.CommitDataStructure; 00007 import commandline.CodingUtils.DataStructure; 00008 import commandline.ImageStuff.Loc; 00009 import commandline.ImageStuff.GeometricObjects.GeometricObject; 00010 import commandline.ImageStuff.GeometricObjects.Impl.TriangleImplType; 00011 00012 import commandline.ImageStuff.GeometricObjects.factories.GenericEdgeConstructor; 00013 import commandline.ImageStuff.util.myVector; 00014 import commandline.NormalMeshAlgorithm.ChildMaker; 00015 import commandline.NormalMeshAlgorithm.Configuration; 00016 00017 00018 00019 public abstract class AbstractTesselation { 00020 00021 00022 /* 00023 * @ pre alle edges van t (parent driehoek) zijn minsten een of beide 00024 * driehoek toegewezen 00025 */ 00026 00027 00028 00029 protected ChildMaker childMaker; 00030 protected Configuration configuration; 00031 protected GenericEdgeConstructor edgeConstructor; 00032 protected TriangleImplType triangleImplType; 00033 public AbstractTesselation(ChildMaker childMaker,GenericEdgeConstructor edgeConstructor,TriangleImplType triangleImplType, Configuration configuration) { 00034 this.childMaker=childMaker; 00035 this.configuration=configuration; 00036 this.edgeConstructor=edgeConstructor; 00037 this.triangleImplType=triangleImplType; 00038 } 00039 00040 00041 protected abstract void makeTesselation(); 00042 00043 00044 protected abstract void builtChildren(); 00045 00046 public abstract void commit(DataStructure dataStructure); 00047 00048 public abstract void commitOnlyDecodingStuff(CommitDataStructure dataStructure) ; 00049 00050 // initialiseren van edges en driehoeken, outer en inneredges 00051 protected abstract void makeInnerEdgesAndTriangles(); 00052 00053 // public abstract GeometricObject getGeometricObject(final int nr); 00054 00055 public abstract ArrayList<GeometricObject> getParts(); 00056 00057 00058 00060 protected abstract void link(); 00061 00062 00063 public abstract String getTesselationCode(); 00064 00065 00066 00067 00068 00071 public abstract HashSet<Loc> getAllLocs(); 00072 00073 00074 public abstract int getNbrOfGeometricObjects(); 00075 00076 00077 public abstract float error(int WHICHNORM); 00078 00079 00081 private final int NULL=0; 00082 private final int POSITIVE_SIDE=1; 00083 private final int NEGATIVE_SIDE=2; 00084 public boolean isConvex(){ 00085 ArrayList<GeometricObject> geometricObjects=getParts(); // get all parts of the tesselation 00086 // each triangle defines a plane to which all points have to lie on the same side 00087 for(GeometricObject geomObj:geometricObjects){ 00088 if(geomObj.isATriangle()){ // triangle 00089 myVector A=new myVector(geomObj.getVertex(0),geomObj.getVertex(1)); // vectors parallel to plane 00090 myVector B=new myVector(geomObj.getVertex(0),geomObj.getVertex(2)); 00091 myVector N= A.vectorieelProduct(B); 00092 int SIDE=NULL; // no value yet assigned 00093 for(GeometricObject others:geometricObjects){ 00094 if(others!=geomObj){ // an object other then the triangle 00095 for(int k=0;k!=others.getAantalPunten();k++){ // for each point of that face or edge 00096 myVector C=new myVector(geomObj.getVertex(0),others.getVertex(k)); // vector from plane to point 00097 int TEMP_SIDE=(N.scalair(C)<0) ? NEGATIVE_SIDE : POSITIVE_SIDE; // tempside either positive or negative 00098 if(TEMP_SIDE!=SIDE && SIDE!=NULL) return false; // points located at other sides!!! 00099 if(SIDE==NULL) {SIDE= TEMP_SIDE;} // if SIDE has not been assigned a value then assign one 00100 } 00101 } 00102 } 00103 } 00104 } 00105 return true; 00106 } 00107 00108 00109 }
1.5.5