Пример #1
0
  /** Test of splitMidX method, of class IDBoundingBox. */
  @Test
  public void testSplitMidX() {
    for (int i = 0; i < 100; i++) {
      ID2BoundingBox box = build(i, i, i + 1, i + 1);
      ID2BoundingBox[] splitted = box.splitMidX();
      assertEquals(i, splitted[0].getLower().getX(), 0);
      assertEquals(i, splitted[0].getLower().getY(), 0);
      assertEquals(i + 0.5, splitted[0].getUpper().getX(), 0);
      assertEquals(i + 1, splitted[0].getUpper().getY(), 0);

      assertEquals(i + 0.5, splitted[1].getLower().getX(), 0);
      assertEquals(i, splitted[1].getLower().getY(), 0);
      assertEquals(i + 1, splitted[1].getUpper().getX(), 0);
      assertEquals(i + 1, splitted[1].getUpper().getY(), 0);
    }
  }
Пример #2
0
  /** Test of merge method, of class IDBoundingBox. */
  @Test
  public void testMerge() {
    for (int i = 0; i < 100; i++) {
      ArrayList<ID2BoundingBox> boxes = new ArrayList<>();

      ID2BoundingBox box = build(0, 0, i, i);
      ID2BoundingBox[] vals = box.splitMidX();
      boxes.addAll(
          Arrays.stream(vals)
              .flatMap((a) -> Arrays.stream(a.splitMidY()))
              .collect(Collectors.toList()));

      ID2BoundingBox two = build(0, 0, 0, 0);
      for (ID2BoundingBox boxt : boxes) {
        two = two.merge(boxt);
      }

      assertTrue(box.same(two));
    }
  }