Пример #1
0
  public void addTest() {
    ArrayList<IntegerMatrix> vecs = Container.computeInitDimVectors(2, 3, 3);
    IntegerMatrix adj = Container.computeInitAdjacencyMatrix(vecs);
    Block cuboid1 = new Block(vecs, adj, 2);
    System.out.println("cuboid 1");
    cuboid1.print(System.out);

    vecs = Container.computeInitDimVectors(2, 2, 4);
    adj = Container.computeInitAdjacencyMatrix(vecs);
    Block cuboid2 = new Block(vecs, adj, 5);
    System.out.println("cuboid 2");
    cuboid2.print(System.out);

    Position posZero = setVector(0, 0, 0);
    Position posOutsideConflict = setVector(11, 11, 11);

    System.out.println("demo 0|0|0");
    printPlaceTest(mContainer, cuboid1, posZero);
    System.out.println("demo 11|11|11");
    printPlaceTest(mContainer, cuboid2, posOutsideConflict);

    Position posInsideConflict_Bounds = setVector(9, 9, 9);
    System.out.println("demo 9|9|9");
    printPlaceTest(mContainer, cuboid1, posInsideConflict_Bounds);

    System.out.println("actually placing cuboid 1 at 0|0|0");
    mContainer.placeBlock(cuboid1, posZero);
    mContainer.print(System.out);

    Position posInsideConflict_Placed = setVector(2, 1, 3);
    System.out.println("demo 2|1|3");
    printPlaceTest(mContainer, cuboid2, posInsideConflict_Placed);

    System.out.println("demo 2|3|3: possible");
    Position vertex = setVector(2, 3, 3);
    ArrayList<Position> relatives =
        mContainer.getRelativePlacements(cuboid2, mContainer.getVertexIndex(vertex.toVector()));
    for (Position relat : relatives) {
      System.out.println(relat.toString());
      printPlaceTest(mContainer, cuboid2, relat);
      if (mContainer.checkPositionInside(relat)
          && mContainer.checkPositionOverlap(cuboid2, relat)) {
        System.out.println("success!");
        mContainer.placeBlock(cuboid2, relat);
        mContainer.print(System.out);
        break;
      }
    }
  }
Пример #2
0
 public void printPlaceTest(Container c, Block b, Glue g) {
   System.out.print("Placing " + c.checkPositionInside(g));
   System.out.println(" " + c.checkPositionOverlap(b, g));
 }