|
@@ -26,13 +26,17 @@ public class Split {
|
|
|
//输入垛位的初始实际形状,形成网格
|
|
|
public void cal(ArrayList<Point> pointsList){
|
|
|
|
|
|
- double minX = 0.;
|
|
|
+ pointsList.add(pointsList.get(0));
|
|
|
|
|
|
- double minY = 0.;
|
|
|
+ Point point0 = pointsList.get(0);
|
|
|
|
|
|
- double maxX = 0.;
|
|
|
+ double minX = point0.getColX();
|
|
|
|
|
|
- double maxY = 0.;
|
|
|
+ double minY = point0.getColY();
|
|
|
+
|
|
|
+ double maxX = point0.getColX();
|
|
|
+
|
|
|
+ double maxY = point0.getColY();
|
|
|
|
|
|
for (int i = 0 ; i < pointsList.size();i++){
|
|
|
|
|
@@ -74,11 +78,16 @@ public class Split {
|
|
|
Point pointC = new Point();
|
|
|
Point pointD = new Point();
|
|
|
|
|
|
+ System.out.println("maxX " + maxX);
|
|
|
+ System.out.println("minX " + minX);
|
|
|
+ System.out.println("maxY " + maxY);
|
|
|
+ System.out.println("minY " + minY);
|
|
|
+
|
|
|
pointA.setColX(minX);
|
|
|
pointA.setColY(minY);
|
|
|
|
|
|
pointB.setColX(minX);
|
|
|
- pointB.setColX(maxY);
|
|
|
+ pointB.setColY(maxY);
|
|
|
|
|
|
pointC.setColX(maxX);
|
|
|
pointC.setColY(maxY);
|
|
@@ -96,9 +105,12 @@ public class Split {
|
|
|
decideIndex(rectanglePoints);
|
|
|
getLines(pointsList);
|
|
|
|
|
|
+// System.out.println(wholeIndexOccupy.getOccupyPerXArrayList());
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //横向纵向划分网格
|
|
|
public void decideIndex(ArrayList<Point> fourPointsList){
|
|
|
|
|
|
Point pointA = fourPointsList.get(0);
|
|
@@ -128,6 +140,11 @@ public class Split {
|
|
|
minY = minY + yGap;
|
|
|
}
|
|
|
|
|
|
+// System.out.println(xIndexCorList);
|
|
|
+//
|
|
|
+// System.out.println(" ");
|
|
|
+// System.out.println(yIndexCorList);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public double calculateDistance(Point point1,Point point2){
|
|
@@ -149,6 +166,7 @@ public class Split {
|
|
|
|
|
|
for (int i = 0 ; i< pointsList.size() - 1;i++){
|
|
|
|
|
|
+ //两个点形成直线
|
|
|
Point pointI = pointsList.get(i);
|
|
|
Point pointJ = pointsList.get(i + 1);
|
|
|
|
|
@@ -164,9 +182,9 @@ public class Split {
|
|
|
// Double pointJx = pointJ.getColX();
|
|
|
// Double pointJy = pointJ.getColY();
|
|
|
|
|
|
-// //该直线起始点的网格位置
|
|
|
-// Index indexI = identifyIndex(pointI);
|
|
|
-// Index indexJ = identifyIndex(pointJ);
|
|
|
+ //该直线起始点的网格位置
|
|
|
+ Index indexI = identifyIndex(pointI);
|
|
|
+ Index indexJ = identifyIndex(pointJ);
|
|
|
lineOccupy(pointI,pointJ,lineParamList);
|
|
|
|
|
|
|
|
@@ -190,57 +208,107 @@ public class Split {
|
|
|
|
|
|
//
|
|
|
Integer xIndexBegin = indexI.getxIndex();//网格横向起始编号
|
|
|
- Integer yIndexBegin = indexI.getxIndex();//网格纵向起始编号
|
|
|
+ Integer yIndexBegin = indexI.getyIndex();//网格纵向起始编号
|
|
|
|
|
|
Integer xIndexEnd = indexJ.getxIndex();//网格横向终止编号
|
|
|
- Integer yIndexEnd = indexJ.getxIndex();//网格纵向终止编号
|
|
|
+ Integer yIndexEnd = indexJ.getyIndex();//网格纵向终止编号
|
|
|
|
|
|
+ Integer lineYIndexMax = Math.max(yIndexBegin,yIndexEnd);
|
|
|
+ Integer lineYIndexMin = Math.min(yIndexBegin,yIndexEnd);
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ //对该格点跨越的所有横向网格序号作循环
|
|
|
for (int i = xIndexBegin;i < xIndexEnd + 1; i++){
|
|
|
|
|
|
+ //计算该直线(线段)在当前横向的网格内,在纵向的占据情况
|
|
|
+
|
|
|
Integer minYIndex;
|
|
|
Integer maxYIndex;
|
|
|
|
|
|
- Double xInputBegin;
|
|
|
- Double xInputEnd;
|
|
|
+ Double xInputBegin;//网格的起始的横坐标
|
|
|
+ Double xInputEnd;//
|
|
|
+
|
|
|
+ Double yOutBegin;//
|
|
|
+ Double yOutEnd;//
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- Double yOutBegin;
|
|
|
- Double yOutEnd;
|
|
|
|
|
|
|
|
|
xInputBegin = xMin + xGap * i;//当前网格的起始横坐标
|
|
|
xInputEnd = xInputBegin + xGap;//当前网格的终止横坐标
|
|
|
+ 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);
|
|
|
|
|
|
- yOutBegin = tool.getLineYValue(xInputBegin,lineParamList);//当前网格的起始纵坐标
|
|
|
- yOutEnd = tool.getLineYValue(xInputEnd,lineParamList);//当前网格的终止纵坐标
|
|
|
+ Integer yBeginIndex = identifyYIndex(yOutBegin);
|
|
|
+ Integer yEndIndex = identifyYIndex(yOutEnd);
|
|
|
|
|
|
-// Double yBeginIndexTemp = (yOutBegin - yMin)/yGap;
|
|
|
-// Integer yBeginIndex = yBeginIndexTemp.intValue();
|
|
|
+// if (yBeginIndex > lineYIndexMax){
|
|
|
+//
|
|
|
+// yBeginIndex = lineYIndexMax;
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (yBeginIndex < lineYIndexMin){
|
|
|
+//
|
|
|
+// yBeginIndex = ;
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
+ yBeginIndex = Math.min(yBeginIndex,lineYIndexMax);
|
|
|
+ yBeginIndex = Math.max(yBeginIndex,lineYIndexMin);
|
|
|
+ yEndIndex = Math.min(yEndIndex,lineYIndexMax);
|
|
|
+ yEndIndex = Math.max(yEndIndex,lineYIndexMin);
|
|
|
|
|
|
- Integer yBeginIndex = identifyYIndex(yOutBegin);
|
|
|
- Integer yEndIndex = identifyYIndex(yOutEnd);
|
|
|
- Integer yIndexMax;
|
|
|
- Integer yIndexMin;
|
|
|
|
|
|
+ Integer yIndexMax;
|
|
|
+ Integer yIndexMin;
|
|
|
|
|
|
- if (yBeginIndex > yEndIndex){
|
|
|
+ if (yBeginIndex > yEndIndex){
|
|
|
|
|
|
- yIndexMin = yEndIndex;
|
|
|
- yIndexMax = yBeginIndex;
|
|
|
+ yIndexMin = yEndIndex;
|
|
|
+ yIndexMax = yBeginIndex;
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+
|
|
|
+ yIndexMax = yEndIndex;
|
|
|
+ yIndexMin = yBeginIndex;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ occupyPerX.setMaxYIndex(yIndexMax);
|
|
|
+ occupyPerX.setMinYIndex(yIndexMin);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
else {
|
|
|
|
|
|
- yIndexMax = yEndIndex;
|
|
|
- yIndexMin = yBeginIndex;
|
|
|
+ occupyPerX.setMaxYIndex(Math.max(yIndexBegin,yIndexEnd));
|
|
|
+ occupyPerX.setMinYIndex(Math.min(yIndexBegin,yIndexEnd));
|
|
|
|
|
|
}
|
|
|
- OccupyPerX occupyPerX = new OccupyPerX();
|
|
|
- occupyPerX.setMaxYIndex(yIndexMax);
|
|
|
- occupyPerX.setMinYIndex(yIndexMin);
|
|
|
+
|
|
|
+
|
|
|
wholeIndexOccupy.setOccupyPerXArrayList(occupyPerX,i);
|
|
|
}
|
|
|
}
|
|
@@ -266,10 +334,33 @@ public class Split {
|
|
|
Double xIndexTemp = (pointX - minX) / xGap;
|
|
|
Double yIndexTemp = (pointY - minY) / yGap;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
Integer xIndex = xIndexTemp.intValue();
|
|
|
Integer yIndex = yIndexTemp.intValue();
|
|
|
|
|
|
+ if (xIndex == 100){
|
|
|
+
|
|
|
+ System.out.println(1111111 + " " + pointX + " " + xIndexTemp);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
Index index = new Index();
|
|
|
+
|
|
|
+ if (xIndex == 100){
|
|
|
+
|
|
|
+ xIndex = xIndex -1;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (yIndex == 100){
|
|
|
+
|
|
|
+ yIndex = yIndex -1;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
index.setxIndex(xIndex);
|
|
|
index.setyIndex(yIndex);
|
|
|
|