|
@@ -13,6 +13,8 @@ public class Cal {
|
|
|
|
|
|
ArrayList<OccupyPerX> occupyPerXArrayList = new ArrayList<>();//占用情况
|
|
|
|
|
|
+ Integer numOfGaps = 100;
|
|
|
+
|
|
|
public ArrayList<Point> calShape() throws SQLException, FileNotFoundException {
|
|
|
|
|
|
GetPoints getPoints = new GetPoints();
|
|
@@ -32,6 +34,9 @@ public class Cal {
|
|
|
ArrayList<Double> xIndexCorList = split.xIndexCorList;//格点横坐标List
|
|
|
ArrayList<Double> yIndexCorList = split.yIndexCorList;//格点纵坐标List
|
|
|
WholeIndexOccupy wholeIndexOccupy = split.wholeIndexOccupy;//初始垛位的占用情况
|
|
|
+// ArrayList<Point> occupyShapeList = wholeIndexOccupy.getOccupyPointsArrayList();//坐标形式的初始形状
|
|
|
+
|
|
|
+ System.out.println(occupyPerXArrayList);
|
|
|
|
|
|
// wholeIndexOccupy.printOccupy();
|
|
|
|
|
@@ -44,6 +49,7 @@ public class Cal {
|
|
|
Double maxY = yIndexCorList.get(yIndexCorList.size() - 1);
|
|
|
|
|
|
wholeIndexOccupy.printOccupy(minX,minY,xGap,yGap);
|
|
|
+ ArrayList<Point> occupyShapeList = wholeIndexOccupy.getOccupyPointsArrayList();//坐标形式的初始形状
|
|
|
|
|
|
|
|
|
ArrayList<Point> pointAfterExclude = new ArrayList<>();//过滤后的所有点的坐标
|
|
@@ -93,7 +99,7 @@ public class Cal {
|
|
|
Integer xIndex = split.identifyXIndex(x);
|
|
|
Integer yIndex = split.identifyYIndex(y);
|
|
|
|
|
|
- if (yIndex < 100 && yIndex >=0){
|
|
|
+ if (yIndex < numOfGaps && yIndex >=0){
|
|
|
|
|
|
ArrayList<Integer> arrayList = occupyList.get(xIndex);
|
|
|
arrayList.set(yIndex,0);
|
|
@@ -170,30 +176,68 @@ public class Cal {
|
|
|
ArrayList<Point> shape = new ArrayList<>();
|
|
|
for (int i = 0 ; i < occupyPerXArrayList.size();i++){
|
|
|
|
|
|
+// OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
|
|
|
+// Double xCor = minX + i * xGap + 0.5 * xGap;
|
|
|
+// Integer yIndex = occupyPerX.maxYIndex;
|
|
|
+// Double yCor = minY + yIndex * yGap + 0.5 * yGap;
|
|
|
+// Point point = new Point();
|
|
|
+// point.setColX(xCor);
|
|
|
+// point.setColY(yCor);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
|
|
|
- Double xCor = minX + i * xGap + 0.5 * xGap;
|
|
|
+ Double xCor1 = minX + i * xGap;
|
|
|
+ Double xCor2 = minX + i * xGap + xGap;
|
|
|
Integer yIndex = occupyPerX.maxYIndex;
|
|
|
Double yCor = minY + yIndex * yGap + 0.5 * yGap;
|
|
|
- Point point = new Point();
|
|
|
- point.setColX(xCor);
|
|
|
- point.setColY(yCor);
|
|
|
- shape.add(point);
|
|
|
+
|
|
|
+ Point point1 = new Point();
|
|
|
+ point1.setColX(xCor1);
|
|
|
+ point1.setColY(yCor);
|
|
|
+
|
|
|
+ Point point2 = new Point();
|
|
|
+ point2.setColX(xCor2);
|
|
|
+ point2.setColY(yCor);
|
|
|
+
|
|
|
+
|
|
|
+ shape.add(point1);
|
|
|
+ shape.add(point2);
|
|
|
}
|
|
|
|
|
|
for (int i = (occupyPerXArrayList.size() -1) ; i >=0;i--){
|
|
|
|
|
|
+// OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
|
|
|
+// Double xCor = minX + i * xGap + 0.5 * xGap;
|
|
|
+// Integer yIndex = occupyPerX.minYIndex;
|
|
|
+// Double yCor = minY + yIndex * yGap + 0.5 * yGap;
|
|
|
+// Point point = new Point();
|
|
|
+// point.setColX(xCor);
|
|
|
+// point.setColY(yCor);
|
|
|
+//
|
|
|
+// shape.add(point);
|
|
|
+
|
|
|
OccupyPerX occupyPerX = occupyPerXArrayList.get(i);
|
|
|
- Double xCor = minX + i * xGap + 0.5 * xGap;
|
|
|
+ Double xCor1 = minX + i * xGap;
|
|
|
+ Double xCor2 = minX + i * xGap + xGap;
|
|
|
Integer yIndex = occupyPerX.minYIndex;
|
|
|
Double yCor = minY + yIndex * yGap + 0.5 * yGap;
|
|
|
- Point point = new Point();
|
|
|
- point.setColX(xCor);
|
|
|
- point.setColY(yCor);
|
|
|
|
|
|
- shape.add(point);
|
|
|
+ Point point1 = new Point();
|
|
|
+ point1.setColX(xCor1);
|
|
|
+ point1.setColY(yCor);
|
|
|
+
|
|
|
+ Point point2 = new Point();
|
|
|
+ point2.setColX(xCor2);
|
|
|
+ point2.setColY(yCor);
|
|
|
+
|
|
|
+ shape.add(point2);
|
|
|
+ shape.add(point1);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
shape.add(shape.get(0));
|
|
|
+ System.out.println(shape.size() + ")))))))))))))))000");
|
|
|
|
|
|
|
|
|
// System.out.println(shape.size());
|
|
@@ -205,6 +249,10 @@ public class Cal {
|
|
|
// }
|
|
|
|
|
|
operateFile.printPoint("Y:\\changed.txt",shape);
|
|
|
+
|
|
|
+ ArrayList<Point> afterAdjustPointsList = adjustShape(occupyShapeList,shape,5);
|
|
|
+
|
|
|
+ operateFile.printPoint("Y:\\adjustchanged.txt",afterAdjustPointsList);
|
|
|
return shape;
|
|
|
|
|
|
|
|
@@ -272,4 +320,54 @@ public class Cal {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public ArrayList<Point> adjustShape(ArrayList<Point> initialShapeList,ArrayList<Point> changedShapeList,Integer adjustSize){
|
|
|
+
|
|
|
+
|
|
|
+ Integer size = initialShapeList.size() - 1;
|
|
|
+
|
|
|
+ System.out.println(size + "size");
|
|
|
+
|
|
|
+ ArrayList<Point> afterAdjustPointsList = new ArrayList<>();
|
|
|
+
|
|
|
+ Integer round = size / adjustSize;
|
|
|
+
|
|
|
+ System.out.println(round + "round");
|
|
|
+
|
|
|
+ for (int i = 0; i < round ;i++){
|
|
|
+
|
|
|
+ Integer indexBegin = i * adjustSize;
|
|
|
+ Integer indexEnd = indexBegin + adjustSize;
|
|
|
+
|
|
|
+ Double avgDec = 0.0;
|
|
|
+ for (int j = indexBegin;j < indexEnd; j++){
|
|
|
+ Point iniPoint = initialShapeList.get(j);
|
|
|
+ Point chaPoint = changedShapeList.get(j);
|
|
|
+ avgDec = avgDec + chaPoint.getColY() - iniPoint.getColY();
|
|
|
+ }
|
|
|
+ avgDec = avgDec / adjustSize;
|
|
|
+ System.out.println(avgDec + " avgdec");
|
|
|
+
|
|
|
+ for (int j = indexBegin ; j < indexEnd;j++){
|
|
|
+
|
|
|
+// Point chaPoint = changedShapeList.get(j);
|
|
|
+ Point intPoint = initialShapeList.get(j);
|
|
|
+ Point adjustPoint = new Point();
|
|
|
+ adjustPoint.setColX(intPoint.getColX());
|
|
|
+ adjustPoint.setColY(intPoint.getColY() + avgDec);
|
|
|
+
|
|
|
+ afterAdjustPointsList.add(adjustPoint);
|
|
|
+ }
|
|
|
+ //后面扩充不整除的情况
|
|
|
+ }
|
|
|
+
|
|
|
+ afterAdjustPointsList.add(afterAdjustPointsList.get(0));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return afterAdjustPointsList;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|