|
@@ -5,6 +5,7 @@ import test.entity.OccupyPerX;
|
|
|
import test.entity.Point;
|
|
|
import test.entity.WholeIndexOccupy;
|
|
|
|
|
|
+import java.io.FileNotFoundException;
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
public class Split {
|
|
@@ -24,22 +25,22 @@ public class Split {
|
|
|
|
|
|
|
|
|
//输入垛位的初始实际形状,形成网格
|
|
|
- public void cal(ArrayList<Point> pointsList){
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ public void cal(ArrayList<Point> pointsList) throws FileNotFoundException {
|
|
|
|
|
|
pointsList.add(pointsList.get(0));
|
|
|
|
|
|
- System.out.println("print initial points-----------------");
|
|
|
- for (int i = 0 ; i < pointsList.size(); i++){
|
|
|
-
|
|
|
- Point point = pointsList.get(i);
|
|
|
- System.out.println(point.getColX() + " " + point.getColY());
|
|
|
-
|
|
|
- }
|
|
|
+ OperateFile operateFile = new OperateFile();
|
|
|
+ operateFile.printPoint("Y:\\initial.txt",pointsList);
|
|
|
|
|
|
- System.out.println("print initial points end--------------");
|
|
|
+// System.out.println("print initial points-----------------");
|
|
|
+// for (int i = 0 ; i < pointsList.size(); i++){
|
|
|
+//
|
|
|
+// Point point = pointsList.get(i);
|
|
|
+// System.out.println(point.getColX() + " " + point.getColY());
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// System.out.println("print initial points end--------------");
|
|
|
|
|
|
|
|
|
Point point0 = pointsList.get(0);
|
|
@@ -128,14 +129,14 @@ public class Split {
|
|
|
public void decideIndex(ArrayList<Point> fourPointsList){
|
|
|
|
|
|
|
|
|
- System.out.println("test");
|
|
|
- for (int i = 0 ; i < fourPointsList.size(); i++){
|
|
|
-
|
|
|
- Point pointTemp = fourPointsList.get(i);
|
|
|
- System.out.println(pointTemp.getColX() + " " + pointTemp.getColY());
|
|
|
-
|
|
|
- }
|
|
|
- System.out.println("test");
|
|
|
+// System.out.println("test");
|
|
|
+// for (int i = 0 ; i < fourPointsList.size(); i++){
|
|
|
+//
|
|
|
+// Point pointTemp = fourPointsList.get(i);
|
|
|
+// System.out.println(pointTemp.getColX() + " " + pointTemp.getColY());
|
|
|
+//
|
|
|
+// }
|
|
|
+// System.out.println("test");
|
|
|
|
|
|
Point pointA = fourPointsList.get(0);
|
|
|
Point pointB = fourPointsList.get(1);
|
|
@@ -150,8 +151,10 @@ public class Split {
|
|
|
double maxX = pointC.getColX();
|
|
|
double maxY = pointC.getColY();
|
|
|
|
|
|
- xGap = distanceAB / numOfGaps;
|
|
|
- yGap = distanceBC / numOfGaps;
|
|
|
+ xGap = (maxX - minX) / numOfGaps;
|
|
|
+ System.out.println("xGap is : " + xGap);
|
|
|
+ yGap = (maxY - minY) / numOfGaps;
|
|
|
+ System.out.println("yGap is : " + yGap);
|
|
|
|
|
|
// ArrayList<Double> xIndexCorList = new ArrayList<>();//格点横坐标List
|
|
|
// ArrayList<Double> yIndexCorList = new ArrayList<>();//格点纵坐标List
|
|
@@ -177,6 +180,14 @@ public class Split {
|
|
|
double corY1 = point1.getColY();
|
|
|
double corX2 = point2.getColX();
|
|
|
double corY2 = point2.getColY();
|
|
|
+ System.out.println("计算距离:");
|
|
|
+ System.out.println("corx1:" + corX1);
|
|
|
+ System.out.println("cory1:" + corY1);
|
|
|
+ System.out.println("corx2:" + corX2);
|
|
|
+ System.out.println("cory2:" + corY2);
|
|
|
+ System.out.println("distance");
|
|
|
+
|
|
|
+
|
|
|
double distance = Math.sqrt(Math.pow((corX1 - corX2),2) + Math.pow((corY1 - corY2),2));
|
|
|
return distance;
|
|
|
|
|
@@ -195,20 +206,20 @@ public class Split {
|
|
|
Point pointJ = pointsList.get(i + 1);
|
|
|
boolean isTest = false;
|
|
|
|
|
|
- if (i == (pointsList.size() - 2)){
|
|
|
-
|
|
|
- System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
|
|
|
- System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
|
|
|
- System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
|
|
|
- System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
|
|
|
-
|
|
|
-
|
|
|
- System.out.println(pointI.getColX() + " " + pointI.getColY());
|
|
|
- System.out.println(pointJ.getColX() + " " + pointJ.getColY());
|
|
|
-
|
|
|
- isTest = true;
|
|
|
-
|
|
|
- }
|
|
|
+// if (i == (pointsList.size() - 2)){
|
|
|
+//
|
|
|
+// System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
|
|
|
+// System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
|
|
|
+// System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
|
|
|
+// System.out.println("这是最后那条直线pppppppppppppppppppppppppppp");
|
|
|
+//
|
|
|
+//
|
|
|
+// System.out.println(pointI.getColX() + " " + pointI.getColY());
|
|
|
+// System.out.println(pointJ.getColX() + " " + pointJ.getColY());
|
|
|
+//
|
|
|
+// isTest = true;
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
|
|
|
|
|
@@ -245,9 +256,6 @@ public class Split {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
///
|
|
|
|
|
|
|
|
@@ -280,29 +288,35 @@ public class Split {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if (isTest){
|
|
|
-
|
|
|
- System.out.println("ISTEST起始横向网格" + xIndexBegin);
|
|
|
- System.out.println("ISTEST终止横向网格" + xIndexEnd);
|
|
|
- System.out.println("ISTEST起始纵向网格" + lineYIndexMin);
|
|
|
- System.out.println("ISTEST终止纵向网格" + lineYIndexMax);
|
|
|
- System.out.println("直线参数为:" + lineParamList);
|
|
|
-
|
|
|
- ///测试直线
|
|
|
- Double xTest = pointI.getColX();
|
|
|
- Double yTest = pointI.getColY();
|
|
|
- Double yTestResult = tool.getLineYValue(xTest,lineParamList);
|
|
|
- System.out.println("xtest:" + xTest);
|
|
|
- System.out.println("ytest:" + yTest);
|
|
|
- System.out.println("ytestresult:" + yTestResult);
|
|
|
-
|
|
|
- }
|
|
|
+// if (isTest){
|
|
|
+//
|
|
|
+// System.out.println("ISTEST起始横向网格" + xIndexBegin);
|
|
|
+// System.out.println("ISTEST终止横向网格" + xIndexEnd);
|
|
|
+// System.out.println("ISTEST起始纵向网格" + lineYIndexMin);
|
|
|
+// System.out.println("ISTEST终止纵向网格" + lineYIndexMax);
|
|
|
+// System.out.println("直线参数为:" + lineParamList);
|
|
|
+//
|
|
|
+// ///测试直线
|
|
|
+// Double xTest = pointI.getColX();
|
|
|
+// Double yTest = pointI.getColY();
|
|
|
+// Double yTestResult = tool.getLineYValue(xTest,lineParamList);
|
|
|
+// System.out.println("xtest:" + xTest);
|
|
|
+// System.out.println("ytest:" + yTest);
|
|
|
+// System.out.println("ytestresult:" + yTestResult);
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
|
|
|
|
|
|
//对该格点跨越的所有横向网格序号作循环
|
|
|
for (int i = xIndexBegin;i < xIndexEnd + 1; i++){
|
|
|
|
|
|
+ if (i == 100){
|
|
|
+ System.out.println(xIndexBegin);
|
|
|
+ System.out.println(xIndexEnd);
|
|
|
+ System.out.println(pointJ.getColX());
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
//计算该直线(线段)在当前横向的网格内,在纵向的占据情况
|
|
@@ -376,12 +390,12 @@ public class Split {
|
|
|
occupyPerX.setMinYIndex(yIndexMin);
|
|
|
|
|
|
|
|
|
- if (isTest){
|
|
|
+// if (isTest){
|
|
|
|
|
|
- System.out.println("当前横向网格序号" + i);
|
|
|
+// System.out.println("当前横向网格序号" + i);
|
|
|
// System.out.println("当前纵向网格序号" + );
|
|
|
|
|
|
- System.out.println(xInputBegin + " " + yOutBegin);
|
|
|
+// System.out.println(xInputBegin + " " + yOutBegin);
|
|
|
|
|
|
// System.out.println("当前网格的起始横坐标:" + xInputBegin);
|
|
|
// System.out.println("当前网格的终止横坐标:" + xInputEnd);
|
|
@@ -392,7 +406,7 @@ public class Split {
|
|
|
// System.out.println("直线在当前网格内的纵向最小网格号:" + yIndexMin);
|
|
|
// System.out.println("直线在当前网格内的纵向最大网格号:" + yIndexMax);
|
|
|
|
|
|
- }
|
|
|
+// }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -420,6 +434,7 @@ public class Split {
|
|
|
//网格的起始x
|
|
|
Double minX = xIndexCorList.get(0);
|
|
|
|
|
|
+
|
|
|
// //网格的终止x
|
|
|
// Double maxX = xIndexCorList.get(xIndexCorList.size());
|
|
|
|
|
@@ -429,16 +444,29 @@ public class Split {
|
|
|
Double xIndexTemp = (pointX - minX) / xGap;
|
|
|
Double yIndexTemp = (pointY - minY) / yGap;
|
|
|
|
|
|
+ if (xIndexTemp > 100){
|
|
|
|
|
|
+ System.out.println(1111111111);
|
|
|
+ System.out.println("x is :" + pointX);
|
|
|
+ System.out.println("minx is : " + minX);
|
|
|
+ System.out.println("xgap is :" + xGap);
|
|
|
+ System.out.println("x - minx = " + (pointX - minX));
|
|
|
+ System.out.println("result is " + (pointX - minX) / xGap);
|
|
|
|
|
|
- Integer xIndex = xIndexTemp.intValue();
|
|
|
- Integer yIndex = yIndexTemp.intValue();
|
|
|
+ }
|
|
|
|
|
|
- if (xIndex == 100){
|
|
|
+// System.out.println("pointx: " + pointX +" - " +"minx: " + minX + " = " + (pointX - minX));
|
|
|
+// System.out.println("(pointX - minX) / xGap: " + xIndexTemp);
|
|
|
|
|
|
- System.out.println(1111111 + " " + pointX + " " + xIndexTemp);
|
|
|
|
|
|
- }
|
|
|
+ Integer xIndex = xIndexTemp.intValue();
|
|
|
+ Integer yIndex = yIndexTemp.intValue();
|
|
|
+
|
|
|
+// if (xIndex == 100){
|
|
|
+//
|
|
|
+// System.out.println(1111111 + " " + pointX + " " + xIndexTemp);
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
Index index = new Index();
|
|
|
|
|
@@ -482,6 +510,13 @@ public class Split {
|
|
|
Double xMin = xIndexCorList.get(0);
|
|
|
Double xIndexTemp = (xCor - xMin)/xGap;
|
|
|
Integer xIndex = xIndexTemp.intValue();
|
|
|
+
|
|
|
+ if (xIndex >= 100){
|
|
|
+
|
|
|
+ xIndex = 99;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
return xIndex;
|
|
|
|
|
|
|