00001 package commandline.Encoder.Iterators;
00002
00003 import java.util.LinkedList;
00004
00005 import junit.framework.Assert;
00006
00007 import commandline.Program;
00008 import commandline.CodingUtils.DataStructure;
00009 import commandline.Encoder.EncoderMesh;
00010 import commandline.ImageStuff.GeometricObjects.GeometricObject;
00011 import commandline.ImageStuff.GeometricObjects.factories.EdgeConstructorTriangleMakerFactory;
00012 import commandline.ImageStuff.Topology.ConnectieCriterium;
00013 import commandline.NormalMeshAlgorithm.Configuration;
00014 import commandline.NormalMeshAlgorithm.SnijPixelStrategy;
00015
00016 public class RecursiveUntillLevel extends RecursiveIteratorUntilNTriangles {
00017
00018 public RecursiveUntillLevel(Program program, EncoderMesh m,
00019 DataStructure dataStructure, SnijPixelStrategy snijPixelStrategy,
00020 ConnectieCriterium connectieCriterium, Configuration configuration,EdgeConstructorTriangleMakerFactory edgeConstructorTriangleMakerFactory) {
00021 super(program, m, dataStructure, snijPixelStrategy, connectieCriterium,
00022 configuration,edgeConstructorTriangleMakerFactory);
00023 }
00024
00025
00026 LinkedList<GeometricObject> children=new LinkedList<GeometricObject>();
00027 LinkedList<GeometricObject> all_sorted_list=new LinkedList<GeometricObject>();
00028 int max_level=(int)configuration.getStopValue();
00029 int level=0;
00030
00031 public void perform(){
00032 all_sorted_list.addAll(sortedGeomQueue);
00033 while(level!=max_level){
00034 super.perform();
00035 Assert.assertTrue(sortedGeomQueue.isEmpty());
00036
00037 all_sorted_list.addAll(children);
00038 if(level!=max_level-1){
00039 sortedGeomQueue=children;
00040 }
00041
00042 children=new LinkedList<GeometricObject>();
00043 reset();
00044 }
00045 sortedGeomQueue=all_sorted_list;
00046 }
00047
00048
00049
00050 protected void reset(){
00051 System.out.println("reset");
00052 level++;
00053 }
00054
00055 protected boolean stop(float dummy){
00056 return false;
00057 }
00058
00059 protected void tesselateCommitAndAddToQueue(GeometricObject nextGeomObj){
00060
00061
00062 LinkedList<GeometricObject> temp=(LinkedList<GeometricObject>)sortedGeomQueue;
00063 sortedGeomQueue=children;
00064 super.tesselateCommitAndAddToQueue(nextGeomObj);
00065
00066 sortedGeomQueue=temp;
00067
00068
00069 }
00070
00071 }