Commit 48a0dedc authored by peter's avatar peter
Browse files

Not complete solution - buggy

parent 67f31c85
......@@ -41,11 +41,12 @@ public class IsoSpline {
public Polygons createIsoPolygons(IsoApi matrix, String name, Color color, double isoLevel){
for(int r=0; r<matrix.getRows()-1; r++)
for(int c=0; c<matrix.getCols()-1; c++){
if(iscs.getIsoSplineContainer(r,c).canCreateIsoSplineElement(isoLevel))
iscs.getIsoSplineContainer(r, c).createSplineElement(isoLevel);
}
iscs.getIsoSplineContainer(3, 1).createSplineElement(isoLevel);
// for(int r=0; r<matrix.getRows()-1; r++)
// for(int c=0; c<matrix.getCols()-1; c++){
// if(iscs.getIsoSplineContainer(r,c).canCreateIsoSplineElement(isoLevel))
// iscs.getIsoSplineContainer(r, c).createSplineElement(isoLevel);
// }
return sortIsoPolygons(isoLevel, color);
}
......
......@@ -19,6 +19,7 @@ public class IsoSplineContainer {
private final ArrayList<String> directions = new Directions();
//public String nextDirection = NO_DIRECTION;
public int currentIsoSplineElementIndex = 0;
private final int r;
public IsoSplineContainer(IsoSplineContainers iscs, Coordinate coord0, Coordinate coord1, Coordinate coord2, Coordinate coord3){
this.iscs=iscs;
......@@ -27,6 +28,7 @@ public class IsoSplineContainer {
coords.add(coord2);
coords.add(coord3);
this.ref=coord0;
r=coord0.r;
}
......@@ -110,7 +112,7 @@ public class IsoSplineContainer {
// return false;
// Iso out of range
if(isoLevel <= min || max <= isoLevel)
if(isoLevel < min || max < isoLevel)
return false;
// if(Math.abs(min - max) < Coordinate.MAX_DIFF)
......@@ -125,8 +127,8 @@ public class IsoSplineContainer {
public void createSplineElement(double isoLevel){
ArrayList<Coordinate> splineCoords = new ArrayList();
//System.out.println(ref);
int j=0;
for(int i = 0; i<coords.size(); i++){
int j;
for(int i = 0; i<coords.size(); i++){ // walk around
if(i==coords.size()-1)
j=0;
else
......@@ -134,12 +136,18 @@ public class IsoSplineContainer {
// Find out in whitch direction a spline point exist
Coordinate coord1 = coords.get(i);
Coordinate coord2 = coords.get(j);
double range;
if(Math.max(coord1.value, coord2.value)>=isoLevel)
if(Math.min(coord1.value, coord2.value)<=isoLevel){
double range = (isoLevel - coord1.value)/(coord2.value - coord1.value);
double lat = range * (coord2.lat-coord1.lat) + coord1.lat;
double lon = range * (coord2.lon-coord1.lon) + coord1.lon;
splineCoords.add(new Coordinate(lon, lat, coord1.r, coord1.c, isoLevel, directions.get(i)));
if(coord1.value!=coord2.value)
range = (isoLevel - coord1.value)/(coord2.value - coord1.value);
else
range = 0;
double lat = range * (coord2.lat-coord1.lat) + coord1.lat;
double lon = range * (coord2.lon-coord1.lon) + coord1.lon;
splineCoords.add(new Coordinate(lon, lat, coord1.r, coord1.c, isoLevel, directions.get(i)));
}
}
ises = new IsoSplineElements(ref);
......@@ -150,11 +158,16 @@ public class IsoSplineContainer {
ises.add(new IsoSplineElement(splineCoords.get(0),splineCoords.get(1)));
break;
case 3:
ises.add(new IsoSplineElement(splineCoords.get(0),splineCoords.get(1)));
if(!splineCoords.get(0).equals(splineCoords.get(1)))
ises.add(new IsoSplineElement(splineCoords.get(0),splineCoords.get(1)));
else if(!splineCoords.get(0).equals(splineCoords.get(2)))
ises.add(new IsoSplineElement(splineCoords.get(0),splineCoords.get(2)));
else if(!splineCoords.get(1).equals(splineCoords.get(2)))
ises.add(new IsoSplineElement(splineCoords.get(1),splineCoords.get(2)));
break;
case 4:
ises.add(new IsoSplineElement(splineCoords.get(0),splineCoords.get(2)));
ises.add(new IsoSplineElement(splineCoords.get(1),splineCoords.get(3)));
ises.add(new IsoSplineElement(splineCoords.get(1),splineCoords.get(2))); /// TODO
break;
default:
System.out.println("Wrong number of iso points: " + coords.toString());
......
......@@ -19,11 +19,11 @@ import org.json.JSONException;
* @author a001188
*/
public class Main {
public static final int ISO_LEVELS =3;
public static final int ISO_LEVELS =1;
public static final boolean test = true;
public static int minPolygonSize = 1;
public static boolean filtering = true;
public static boolean original = false;
public static boolean filtering = false;
public static boolean original = true;
public static int filterWidth = 2;
public static int filterIter = 3;
public static double filterRange = 1.0;
......
4) 10.0,10.0,12.0,12.0
3) 11.0,11.0,11.0,11.0
2) 10.0,10.0,10.0,10.0
1) 10.0,12.0,12.0,12.0
0) 10.0,10.0,10.0,10.0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment