Commit 9eef9052 authored by a001188's avatar a001188
Browse files

Firts Front check in

parent cf5e3e0b
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
*/ */
package isospline; package isospline;
import java.awt.Dimension;
/** /**
* *
* @author a001188 * @author a001188
...@@ -20,6 +18,13 @@ public class IsoSplineContainer { ...@@ -20,6 +18,13 @@ public class IsoSplineContainer {
private final Directions directions; private final Directions directions;
public int currentIsoSplineElementIndex = 0; public int currentIsoSplineElementIndex = 0;
public double isoLevel = 0; public double isoLevel = 0;
double min02;
double max13;
double min13;
double max02;
double min;
double max;
public IsoSplineContainer(IsoSplineContainers iscs, Coordinate coord0, Coordinate coord1, Coordinate coord2, Coordinate coord3){ public IsoSplineContainer(IsoSplineContainers iscs, Coordinate coord0, Coordinate coord1, Coordinate coord2, Coordinate coord3){
this.iscs=iscs; this.iscs=iscs;
coords.add(coord0); coords.add(coord0);
...@@ -28,6 +33,12 @@ public class IsoSplineContainer { ...@@ -28,6 +33,12 @@ public class IsoSplineContainer {
coords.add(coord3); coords.add(coord3);
this.ref=coord0; this.ref=coord0;
directions = new Directions(ref); directions = new Directions(ref);
this.min02 = Math.min(coords.get(0).value,coords.get(2).value);
this.max13 = Math.max(coords.get(1).value,coords.get(3).value);
this.min13 = Math.min(coords.get(1).value,coords.get(3).value);
this.max02 = Math.max(coords.get(0).value,coords.get(2).value);
this.min = Math.min(min02, min13);
this.max = Math.max(max02, max13);
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -65,12 +76,7 @@ public class IsoSplineContainer { ...@@ -65,12 +76,7 @@ public class IsoSplineContainer {
public boolean canCreateIsoSplineElement(IsoLevel isoLevel){ public boolean canCreateIsoSplineElement(IsoLevel isoLevel){
this.isoLevel=isoLevel.isoLevel; this.isoLevel=isoLevel.isoLevel;
double min02 = Math.min(coords.get(0).value,coords.get(2).value);
double max13 = Math.max(coords.get(1).value,coords.get(3).value);
double min13 = Math.min(coords.get(1).value,coords.get(3).value);
double max02 = Math.max(coords.get(0).value,coords.get(2).value);
double min = Math.min(min02, min13);
double max = Math.max(max02, max13);
// Iso out of range // Iso out of range
if(isoLevel.isoLevel < min || max < isoLevel.isoLevel) if(isoLevel.isoLevel < min || max < isoLevel.isoLevel)
...@@ -261,6 +267,27 @@ public class IsoSplineContainer { ...@@ -261,6 +267,27 @@ public class IsoSplineContainer {
} }
public IsoSplineElement getMaxDeriviateSplineElement(){
Coordinate c0=coords.get(0);
Coordinate c1=coords.get(0);
double d = 0;
for (int i = 0; i < coords.size();i++)
for (int j = i+1; i < coords.size();j++)
if(d < Math.abs(getDeriviate(coords.get(i), coords.get(j)))){
c0 = coords.get(i);
c1 = coords.get(i);
}
return new IsoSplineElement(c0,c1);
}
private double getDeriviate(Coordinate coord1, Coordinate coord2){
double v1 = coord1.value-coord2.value;
double v2 = Math.pow(Math.pow((coord1.lon-coord2.lon),2) + Math.pow((coord1.lat-coord2.lat),2), 0.5);
return v1/v2;
}
@Override @Override
public String toString(){ public String toString(){
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
......
...@@ -13,10 +13,12 @@ import java.awt.Dimension; ...@@ -13,10 +13,12 @@ import java.awt.Dimension;
*/ */
public class IsoSplineElement extends Coordinates implements Comparable<IsoSplineElement> { public class IsoSplineElement extends Coordinates implements Comparable<IsoSplineElement> {
public int sortIndex; public int sortIndex;
public double deriviate;
public IsoSplineElement(Coordinate coord1, Coordinate coors2){ public IsoSplineElement(Coordinate coord1, Coordinate coord2){
add(coord1); add(coord1);
add(coors2); add(coord2);
this.deriviate = coord1.value - coord2.value;
} }
public void fitToFrame(Dimension dimension, MatrixCorners gridCorners, String type){ public void fitToFrame(Dimension dimension, MatrixCorners gridCorners, String type){
......
...@@ -51,6 +51,21 @@ public class IsoSplineFactory { ...@@ -51,6 +51,21 @@ public class IsoSplineFactory {
} }
public Polygons createDerivativeSplineElement(IsoApi matrix, String polygonsName){
Polygons polygons = new Polygons();
for(int r=0; r<matrix.getRows()-1; r++){
for(int c=0; c<matrix.getCols()-1; c++){
Polygon polygon = new Polygon(null);
IsoSplineElement ise = iscs.getIsoSplineContainer(r,c).getMaxDeriviateSplineElement();
polygon.add(ise.get(0));
polygon.add(ise.get(1));
polygons.add(polygon);
}
}
return polygons;
}
private Polygons _sortIsoPolygons(IsoLevel isoLevel){ private Polygons _sortIsoPolygons(IsoLevel isoLevel){
Polygons polygons = new Polygons(); Polygons polygons = new Polygons();
for(int r=0;r<iscs.rows;r++){ for(int r=0;r<iscs.rows;r++){
......
...@@ -20,7 +20,7 @@ public class Main { ...@@ -20,7 +20,7 @@ public class Main {
public static final boolean CLOSE_AROUND_THE_BORDER = true; public static final boolean CLOSE_AROUND_THE_BORDER = true;
public static final int ISO_LEVELS = 3; public static final int ISO_LEVELS = 3;
public static final boolean TEST = false; public static final boolean TEST = false;
public static final int MIN_POLYGON_SIZE = 500; public static final int MIN_POLYGON_SIZE = 1000;
public static final boolean FILTERED_VALUES = false; public static final boolean FILTERED_VALUES = false;
public static final boolean ORIGINAL_VALUES = true; public static final boolean ORIGINAL_VALUES = true;
public static final int FILTER_WIDTH = 2; public static final int FILTER_WIDTH = 2;
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
package isospline; package isospline;
import java.awt.Dimension; import java.awt.Dimension;
import java.util.ArrayList;
import java.awt.Color; import java.awt.Color;
/** /**
...@@ -34,6 +33,7 @@ public class Polygon extends Coordinates{ ...@@ -34,6 +33,7 @@ public class Polygon extends Coordinates{
return Math.pow(Math.pow(get(0).r-get(size()-1).r, 2) + Math.pow(get(0).c-get(size()-1).c, 2), 0.5); return Math.pow(Math.pow(get(0).r-get(size()-1).r, 2) + Math.pow(get(0).c-get(size()-1).c, 2), 0.5);
} }
@Override @Override
public String toString(){ public String toString(){
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
...@@ -72,5 +72,11 @@ public class Polygon extends Coordinates{ ...@@ -72,5 +72,11 @@ public class Polygon extends Coordinates{
return sb.toString(); return sb.toString();
} }
public int compareTo(Polygon p2) {
if(get(0).value > get(1).value)
return 1;
return -1;
}
} }
...@@ -6,12 +6,25 @@ ...@@ -6,12 +6,25 @@
package isospline; package isospline;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
/** /**
* *
* @author a001188 * @author a001188
*/ */
public class Polygons extends ArrayList<Polygon>{ public class Polygons extends ArrayList<Polygon>{
public void sort(){
Collections.sort(this, new Comparator<Polygon>() {
@Override
public int compare(Polygon p1, Polygon p2){
return p1.compareTo(p2);
}
});
}
@Override @Override
public String toString(){ public String toString(){
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
......
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