コード例 #1
0
ファイル: ContainerTest.java プロジェクト: EricChang1/P_1.3
  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
    protected void showCenterPoint(Position cPos) {
      // Display the center point in red.
      PointPlacemarkAttributes selectedLocationAttributes;
      selectedLocationAttributes = new PointPlacemarkAttributes();
      selectedLocationAttributes.setLineMaterial(Material.RED);
      selectedLocationAttributes.setScale(8d);
      selectedLocationAttributes.setUsePointAsDefaultImage(true);

      PointPlacemark pm = new PointPlacemark(cPos);
      pm.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      pm.setAttributes(selectedLocationAttributes);
      pm.setValue(AVKey.DISPLAY_NAME, cPos.toString());
      pm.setLineEnabled(true);
      this.gridLayer.addRenderable(pm);
    }
コード例 #3
0
    protected void showIntersections(List<Position> intersections) {
      this.intersectionsLayer.removeAllRenderables();

      // Display the intersections as CYAN points.
      PointPlacemarkAttributes intersectionPointAttributes;
      intersectionPointAttributes = new PointPlacemarkAttributes();
      intersectionPointAttributes.setLineMaterial(Material.CYAN);
      intersectionPointAttributes.setScale(6d);
      intersectionPointAttributes.setUsePointAsDefaultImage(true);

      for (Position p : intersections) {
        PointPlacemark pm = new PointPlacemark(p);
        pm.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
        pm.setAttributes(intersectionPointAttributes);
        pm.setValue(AVKey.DISPLAY_NAME, p.toString());
        this.intersectionsLayer.addRenderable(pm);
      }
    }
コード例 #4
0
    protected void showGrid(List<Position> grid, Position cPos) {
      this.gridLayer.removeAllRenderables();

      // Display the grid points in yellow.
      PointPlacemarkAttributes gridPointAttributes;
      gridPointAttributes = new PointPlacemarkAttributes();
      gridPointAttributes.setLineMaterial(Material.YELLOW);
      gridPointAttributes.setScale(6d);
      gridPointAttributes.setUsePointAsDefaultImage(true);

      for (Position p : grid) {
        PointPlacemark pm = new PointPlacemark(p);
        pm.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
        pm.setAttributes(gridPointAttributes);
        pm.setLineEnabled(true);
        pm.setValue(AVKey.DISPLAY_NAME, p.toString());
        this.gridLayer.addRenderable(pm);
      }

      showCenterPoint(cPos);
    }