00001 package commandline.baseMeshGeneration.pointInsertor;
00002
00003 import java.util.ArrayList;
00004
00005 import commandline.CodingUtils.MyRandom;
00006 import commandline.baseMeshGeneration.delaunaypackage.Edge;
00007 import commandline.baseMeshGeneration.delaunaypackage.QuadraticAlgorithm;
00008 import commandline.baseMeshGeneration.delaunaypackage.RealPoint;
00009 import commandline.baseMeshGeneration.delaunaypackage.Triangulation;
00010 import commandline.debuggingCode.Debug;
00011
00012
00013
00014
00015
00016 public class MoreSofisticatedPointInsertor extends PointInsertor {
00017
00018 public MoreSofisticatedPointInsertor(Triangulation t) {
00019 super(t);
00020 }
00021
00022 @Override
00023 protected Triangulation insertPoints(Triangulation t) {
00024 ArrayList<RealPoint> points=new ArrayList<RealPoint>();
00025 RealPoint begin,eind;
00026 for(int i =0;i!=t.getNEdges();i++){
00027 Edge e=t.getEdge(i);
00028 begin=t.getPoint(e.getBeginPunt());
00029 eind=t.getPoint(e.getEindPunt());
00030 float xrand=(float)(MyRandom.random()*0.9);
00031 float yrand=(float)(MyRandom.random()*0.9);
00032 if(begin.distance(eind)>15){
00033 points.add(new RealPoint((float)(Math.floor(begin.x())+Math.floor(eind.x())+xrand)/2, (float)( Math.floor(begin.y())+Math.floor(eind.y())+yrand)/2));
00034 }
00035 else{ Debug.print("points where to close to each other");}
00036 }
00037
00038 RealPoint[] alle_punten_tot_nu_toe=new RealPoint[t.getPoints().length+points.size()];
00039 for(int i=0;i!=t.getPoints().length;i++){
00040 alle_punten_tot_nu_toe[i]=t.getPoint(i);
00041 }
00042 for(int i=t.getPoints().length;i!=alle_punten_tot_nu_toe.length;i++){
00043 alle_punten_tot_nu_toe[i]=points.get(i-t.getPoints().length);
00044 }
00045
00046 Triangulation trian=new Triangulation(alle_punten_tot_nu_toe);
00047 QuadraticAlgorithm quadraticAlgorithm=new QuadraticAlgorithm();
00048 quadraticAlgorithm.triangulate(trian);
00049
00050
00051 return trian;
00052 }
00053
00054 }