Ejemplo n.º 1
0
  /** Test of splitMidY method, of class IDBoundingBox. */
  @Test
  public void testSplitMidY() {
    for (int i = 0; i < 100; i++) {
      ID2BoundingBox box = build(i, i, i + 1, i + 1);
      ID2BoundingBox[] splitted = box.splitMidY();
      assertEquals(i, splitted[0].getLower().getX(), 0);
      assertEquals(i, splitted[0].getLower().getY(), 0);
      assertEquals(i + 1, splitted[0].getUpper().getX(), 0);
      assertEquals(i + 0.5, splitted[0].getUpper().getY(), 0);

      assertEquals(i, splitted[1].getLower().getX(), 0);
      assertEquals(i + 0.5, splitted[1].getLower().getY(), 0);
      assertEquals(i + 1, splitted[1].getUpper().getX(), 0);
      assertEquals(i + 1, splitted[1].getUpper().getY(), 0);
    }
  }
Ejemplo n.º 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));
    }
  }
Ejemplo n.º 3
0
 /** Test of contains method, of class IDBoundingBox. */
 @Test
 public void testContains_IDPoint() {
   ID2BoundingBox box = build(0, 0, 100, 100);
   for (int i = 0; i < 100; i++) {
     assertTrue("Point: " + build(i + 0.5, i + 0.5), box.contains(build(i + 0.5, i + 0.5)));
     assertFalse(box.contains(build(100 + i + 0.5, i)));
     assertFalse(box.contains(build(0 - i - 0.5, i)));
     assertFalse(box.contains(build(i, 100 + i + 0.5)));
     assertFalse(box.contains(build(i, 0 - i - 0.5)));
   }
 }
Ejemplo n.º 4
0
 /** Test of getUpper method, of class IDBoundingBox. */
 @Test
 public void testGetUpper() {
   ID2BoundingBox box = build(3, 4, 7, 8);
   assertEquals(box.getUpper(), box.getUpper());
 }