|
@@ -26,8 +26,22 @@ public class Split {
|
|
|
//输入垛位的初始实际形状,形成网格
|
|
|
public void cal(ArrayList<Point> pointsList){
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
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());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("print initial points end--------------");
|
|
|
+
|
|
|
+
|
|
|
Point point0 = pointsList.get(0);
|
|
|
|
|
|
double minX = point0.getColX();
|
|
@@ -113,6 +127,16 @@ 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");
|
|
|
+
|
|
|
Point pointA = fourPointsList.get(0);
|
|
|
Point pointB = fourPointsList.get(1);
|
|
|
Point pointC = fourPointsList.get(2);
|
|
@@ -164,11 +188,29 @@ public class Split {
|
|
|
|
|
|
|
|
|
|
|
|
- for (int i = 0 ; i< pointsList.size() - 1;i++){
|
|
|
+ for (int i = 0 ; i < (pointsList.size() - 1);i++){
|
|
|
|
|
|
//两个点形成直线
|
|
|
Point pointI = pointsList.get(i);
|
|
|
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;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//直线一般式相关的参数,A,B,C
|
|
|
ArrayList<Double> lineParamList = tool.calLineabc(pointI,pointJ);
|
|
@@ -183,9 +225,9 @@ public class Split {
|
|
|
// Double pointJy = pointJ.getColY();
|
|
|
|
|
|
//该直线起始点的网格位置
|
|
|
- Index indexI = identifyIndex(pointI);
|
|
|
- Index indexJ = identifyIndex(pointJ);
|
|
|
- lineOccupy(pointI,pointJ,lineParamList);
|
|
|
+// Index indexI = identifyIndex(pointI);
|
|
|
+// Index indexJ = identifyIndex(pointJ);
|
|
|
+ lineOccupy(pointI,pointJ,lineParamList,isTest);
|
|
|
|
|
|
|
|
|
|
|
@@ -196,12 +238,19 @@ public class Split {
|
|
|
}
|
|
|
|
|
|
//计算直线在各个网格内的占据情况
|
|
|
- public void lineOccupy(Point pointI,Point pointJ,ArrayList<Double> lineParamList){
|
|
|
+ public void lineOccupy(Point pointI,Point pointJ,ArrayList<Double> lineParamList,Boolean isTest){
|
|
|
|
|
|
Double xMin = xIndexCorList.get(0);
|
|
|
Double yMin = yIndexCorList.get(0);
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ///
|
|
|
+
|
|
|
+
|
|
|
//该直线起始点的网格位置
|
|
|
Index indexI = identifyIndex(pointI);
|
|
|
Index indexJ = identifyIndex(pointJ);
|
|
@@ -217,11 +266,45 @@ public class Split {
|
|
|
Integer lineYIndexMin = Math.min(yIndexBegin,yIndexEnd);
|
|
|
|
|
|
|
|
|
+ Integer lineXIndexMax = Math.max(xIndexBegin,xIndexEnd);
|
|
|
+ Integer lineXIndexMin = Math.min(xIndexBegin,xIndexEnd);
|
|
|
+
|
|
|
+
|
|
|
+ //
|
|
|
+ if (xIndexBegin > xIndexEnd){
|
|
|
+
|
|
|
+ Integer temp;
|
|
|
+ temp = xIndexBegin;
|
|
|
+ xIndexBegin = xIndexEnd;
|
|
|
+ xIndexEnd = temp;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ 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++){
|
|
|
|
|
|
+
|
|
|
+
|
|
|
//计算该直线(线段)在当前横向的网格内,在纵向的占据情况
|
|
|
|
|
|
Integer minYIndex;
|
|
@@ -240,39 +323,32 @@ public class Split {
|
|
|
|
|
|
xInputBegin = xMin + xGap * i;//当前网格的起始横坐标
|
|
|
xInputEnd = xInputBegin + xGap;//当前网格的终止横坐标
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// if (isTest){
|
|
|
+//
|
|
|
+// System.out.println("当前网格的起始横坐标:" + xInputBegin);
|
|
|
+// System.out.println("当前网格的终止横坐标:" + xInputEnd);
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
OccupyPerX occupyPerX = new OccupyPerX();
|
|
|
|
|
|
// if ((Double.POSITIVE_INFINITY == lineParamList.get(0) || Double.NEGATIVE_INFINITY == lineParamList.get(0))){
|
|
|
//
|
|
|
// System.out.println(111111);
|
|
|
// }
|
|
|
+
|
|
|
if ((lineParamList.size()!=0) && !(Double.POSITIVE_INFINITY == lineParamList.get(0) || Double.NEGATIVE_INFINITY == lineParamList.get(0))){
|
|
|
|
|
|
yOutBegin = tool.getLineYValue(xInputBegin,lineParamList);//当前网格的起始纵坐标
|
|
|
-// if (yOutBegin > lineYIndexMax){
|
|
|
-//
|
|
|
-// yOutBegin = lineYIndexMax;
|
|
|
-// }
|
|
|
|
|
|
yOutEnd = tool.getLineYValue(xInputEnd,lineParamList);//当前网格的终止纵坐标
|
|
|
-// System.out.println(lineParamList);
|
|
|
-// System.out.println("begin x: " + xInputBegin + " y: " + yOutBegin);
|
|
|
-// System.out.println("end x: " + xInputEnd + " y: " + yOutEnd);
|
|
|
|
|
|
Integer yBeginIndex = identifyYIndex(yOutBegin);
|
|
|
Integer yEndIndex = identifyYIndex(yOutEnd);
|
|
|
|
|
|
-// if (yBeginIndex > lineYIndexMax){
|
|
|
-//
|
|
|
-// yBeginIndex = lineYIndexMax;
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (yBeginIndex < lineYIndexMin){
|
|
|
-//
|
|
|
-// yBeginIndex = ;
|
|
|
-//
|
|
|
-// }
|
|
|
|
|
|
yBeginIndex = Math.min(yBeginIndex,lineYIndexMax);
|
|
|
yBeginIndex = Math.max(yBeginIndex,lineYIndexMin);
|
|
@@ -299,6 +375,25 @@ public class Split {
|
|
|
occupyPerX.setMaxYIndex(yIndexMax);
|
|
|
occupyPerX.setMinYIndex(yIndexMin);
|
|
|
|
|
|
+
|
|
|
+ if (isTest){
|
|
|
+
|
|
|
+ System.out.println("当前横向网格序号" + i);
|
|
|
+// System.out.println("当前纵向网格序号" + );
|
|
|
+
|
|
|
+ System.out.println(xInputBegin + " " + yOutBegin);
|
|
|
+
|
|
|
+// System.out.println("当前网格的起始横坐标:" + xInputBegin);
|
|
|
+// System.out.println("当前网格的终止横坐标:" + xInputEnd);
|
|
|
+// System.out.println("当前网格的起始纵坐标:" + yOutBegin);
|
|
|
+// System.out.println("当前网格的终止纵坐标:" + yOutEnd);
|
|
|
+//
|
|
|
+//
|
|
|
+// System.out.println("直线在当前网格内的纵向最小网格号:" + yIndexMin);
|
|
|
+// System.out.println("直线在当前网格内的纵向最大网格号:" + yIndexMax);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
else {
|