Skip to content
Permalink
Browse files
GEOMETRY-109: renaming BoundarySourceXX.from() to BoundarySourceXX.of()
  • Loading branch information
darkma773r committed Dec 26, 2020
1 parent 1410a0e commit 2c84bf3b0e458ed98248b91c60c8d27705488e7c
Showing 16 changed files with 66 additions and 66 deletions.
@@ -104,16 +104,16 @@ default Bounds3D getBounds() {
* @param boundaries boundaries to include in the boundary source
* @return a boundary source containing the given boundaries
*/
static BoundarySource3D from(final PlaneConvexSubset... boundaries) {
return from(Arrays.asList(boundaries));
static BoundarySource3D of(final PlaneConvexSubset... boundaries) {
return of(Arrays.asList(boundaries));
}

/** Return a {@link BoundarySource3D} instance containing the given boundaries. The given
* collection is used directly as the source of the boundaries; no copy is made.
* @param boundaries boundaries to include in the boundary source
* @return a boundary source containing the given boundaries
*/
static BoundarySource3D from(final Collection<PlaneConvexSubset> boundaries) {
static BoundarySource3D of(final Collection<PlaneConvexSubset> boundaries) {
return boundaries::stream;
}
}
@@ -77,16 +77,16 @@ default Bounds2D getBounds() {
* @param boundaries line subsets to include in the boundary source
* @return a boundary source containing the given boundaries
*/
static BoundarySource2D from(final LineConvexSubset... boundaries) {
return from(Arrays.asList(boundaries));
static BoundarySource2D of(final LineConvexSubset... boundaries) {
return of(Arrays.asList(boundaries));
}

/** Return a {@link BoundarySource2D} instance containing the given boundaries. The given
* collection is used directly as the source of the line subsets; no copy is made.
* @param boundaries line subsets to include in the boundary source
* @return a boundary source containing the given boundaries
*/
static BoundarySource2D from(final Collection<LineConvexSubset> boundaries) {
static BoundarySource2D of(final Collection<LineConvexSubset> boundaries) {
return boundaries::stream;
}
}
@@ -36,7 +36,7 @@ public class BoundarySource3DTest {
@Test
public void testToList() {
// act
final BoundarySource3D src = BoundarySource3D.from(
final BoundarySource3D src = BoundarySource3D.of(
Planes.convexPolygonFromVertices(
Arrays.asList(Vector3D.ZERO, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y), TEST_PRECISION)
);
@@ -51,7 +51,7 @@ public void testToList() {
@Test
public void testToList_noBoundaries() {
// act
final BoundarySource3D src = BoundarySource3D.from();
final BoundarySource3D src = BoundarySource3D.of();

// act
final BoundaryList3D list = src.toList();
@@ -68,7 +68,7 @@ public void testToTree() {
final PlaneConvexSubset b = Planes.convexPolygonFromVertices(
Arrays.asList(Vector3D.ZERO, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_Z), TEST_PRECISION);

final BoundarySource3D src = BoundarySource3D.from(a, b);
final BoundarySource3D src = BoundarySource3D.of(a, b);

// act
final RegionBSPTree3D tree = src.toTree();
@@ -82,7 +82,7 @@ public void testToTree() {
@Test
public void testToTree_noBoundaries() {
// act
final BoundarySource3D src = BoundarySource3D.from();
final BoundarySource3D src = BoundarySource3D.of();

// act
final RegionBSPTree3D tree = src.toTree();
@@ -94,24 +94,24 @@ public void testToTree_noBoundaries() {
}

@Test
public void testFrom_varargs_empty() {
public void testOf_varargs_empty() {
// act
final BoundarySource3D src = BoundarySource3D.from();
final BoundarySource3D src = BoundarySource3D.of();

// assert
final List<PlaneConvexSubset> segments = src.boundaryStream().collect(Collectors.toList());
Assertions.assertEquals(0, segments.size());
}

@Test
public void testFrom_varargs() {
public void testOf_varargs() {
// act
final PlaneConvexSubset a = Planes.convexPolygonFromVertices(
Arrays.asList(Vector3D.ZERO, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y), TEST_PRECISION);
final PlaneConvexSubset b = Planes.convexPolygonFromVertices(
Arrays.asList(Vector3D.ZERO, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_Z), TEST_PRECISION);

final BoundarySource3D src = BoundarySource3D.from(a, b);
final BoundarySource3D src = BoundarySource3D.of(a, b);

// assert
final List<PlaneConvexSubset> boundaries = src.boundaryStream().collect(Collectors.toList());
@@ -122,20 +122,20 @@ public void testFrom_varargs() {
}

@Test
public void testFrom_list_empty() {
public void testOf_list_empty() {
// arrange
final List<PlaneConvexSubset> input = new ArrayList<>();

// act
final BoundarySource3D src = BoundarySource3D.from(input);
final BoundarySource3D src = BoundarySource3D.of(input);

// assert
final List<PlaneConvexSubset> segments = src.boundaryStream().collect(Collectors.toList());
Assertions.assertEquals(0, segments.size());
}

@Test
public void testFrom_list() {
public void testOf_list() {
// act
final PlaneConvexSubset a = Planes.convexPolygonFromVertices(
Arrays.asList(Vector3D.ZERO, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y), TEST_PRECISION);
@@ -146,7 +146,7 @@ public void testFrom_list() {
input.add(a);
input.add(b);

final BoundarySource3D src = BoundarySource3D.from(input);
final BoundarySource3D src = BoundarySource3D.of(input);

// assert
final List<PlaneConvexSubset> segments = src.boundaryStream().collect(Collectors.toList());
@@ -35,7 +35,7 @@ public class BoundarySourceBoundsBuilder3DTest {
@Test
public void testGetBounds_noBoundaries() {
// arrange
final BoundarySource3D src = BoundarySource3D.from(new ArrayList<>());
final BoundarySource3D src = BoundarySource3D.of(new ArrayList<>());
final BoundarySourceBoundsBuilder3D builder = new BoundarySourceBoundsBuilder3D();

// act
@@ -53,7 +53,7 @@ public void testGetBounds_singleFiniteBoundary() {
Vector3D.of(1, 0, 2),
Vector3D.of(3, 4, 5)), TEST_PRECISION);

final BoundarySource3D src = BoundarySource3D.from(poly);
final BoundarySource3D src = BoundarySource3D.of(poly);
final BoundarySourceBoundsBuilder3D builder = new BoundarySourceBoundsBuilder3D();

// act
@@ -84,7 +84,7 @@ public void testGetBounds_multipleFiniteBoundaries() {
Vector3D.of(1, 7, 2),
Vector3D.of(5, 4, 10)), TEST_PRECISION);

final BoundarySource3D src = BoundarySource3D.from(poly1, poly2, poly3);
final BoundarySource3D src = BoundarySource3D.of(poly1, poly2, poly3);
final BoundarySourceBoundsBuilder3D builder = new BoundarySourceBoundsBuilder3D();

// act
@@ -105,7 +105,7 @@ public void testGetBounds_singleInfiniteBoundary() {
// arrange
final PlaneConvexSubset boundary = Planes.fromPointAndNormal(Vector3D.ZERO, Vector3D.Unit.PLUS_Z, TEST_PRECISION)
.span();
final BoundarySource3D src = BoundarySource3D.from(boundary);
final BoundarySource3D src = BoundarySource3D.of(boundary);
final BoundarySourceBoundsBuilder3D builder = new BoundarySourceBoundsBuilder3D();

// act
@@ -138,7 +138,7 @@ public void testGetBounds_mixedFiniteAndInfiniteBoundaries() {
Vector3D.of(1, 7, 2),
Vector3D.of(5, 4, 10)), TEST_PRECISION);

final BoundarySource3D src = BoundarySource3D.from(poly1, poly2, inf, poly3);
final BoundarySource3D src = BoundarySource3D.of(poly1, poly2, inf, poly3);
final BoundarySourceBoundsBuilder3D builder = new BoundarySourceBoundsBuilder3D();

// act
@@ -101,7 +101,7 @@ public void testLinecast_line_corners() {
@Test
public void testLinecast_line_removesDuplicatePoints() {
// arrange
final BoundarySource3D src = BoundarySource3D.from(
final BoundarySource3D src = BoundarySource3D.of(
Planes.convexPolygonFromVertices(Arrays.asList(Vector3D.ZERO, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y), TEST_PRECISION),
Planes.convexPolygonFromVertices(Arrays.asList(Vector3D.ZERO, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X), TEST_PRECISION)
);
@@ -234,7 +234,7 @@ public void testLinecast_segment_corners() {
@Test
public void testLinecast_segment_removesDuplicatePoints() {
// arrange
final BoundarySource3D src = BoundarySource3D.from(
final BoundarySource3D src = BoundarySource3D.of(
Planes.convexPolygonFromVertices(Arrays.asList(Vector3D.ZERO, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y), TEST_PRECISION),
Planes.convexPolygonFromVertices(Arrays.asList(Vector3D.ZERO, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X), TEST_PRECISION)
);
@@ -173,7 +173,7 @@ public void testFrom_boundarySource() {
@Test
public void testFrom_boundarySource_empty() {
// act
final SimpleTriangleMesh mesh = SimpleTriangleMesh.from(BoundarySource3D.from(Collections.emptyList()),
final SimpleTriangleMesh mesh = SimpleTriangleMesh.from(BoundarySource3D.of(Collections.emptyList()),
TEST_PRECISION);

// assert
@@ -431,7 +431,7 @@ public void testToString() {
// arrange
final Triangle3D tri = Planes.triangleFromVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0),
TEST_PRECISION);
final SimpleTriangleMesh mesh = SimpleTriangleMesh.from(BoundarySource3D.from(tri), TEST_PRECISION);
final SimpleTriangleMesh mesh = SimpleTriangleMesh.from(BoundarySource3D.of(tri), TEST_PRECISION);

// act
final String str = mesh.toString();
@@ -445,7 +445,7 @@ public void testFaceToString() {
// arrange
final Triangle3D tri = Planes.triangleFromVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0),
TEST_PRECISION);
final SimpleTriangleMesh mesh = SimpleTriangleMesh.from(BoundarySource3D.from(tri), TEST_PRECISION);
final SimpleTriangleMesh mesh = SimpleTriangleMesh.from(BoundarySource3D.of(tri), TEST_PRECISION);

// act
final String str = mesh.getFace(0).toString();
@@ -35,7 +35,7 @@ public class BoundarySource2DTest {
@Test
public void testToList() {
// act
final BoundarySource2D src = BoundarySource2D.from(
final BoundarySource2D src = BoundarySource2D.of(
Lines.segmentFromPoints(Vector2D.ZERO, Vector2D.of(1, 0), TEST_PRECISION),
Lines.segmentFromPoints(Vector2D.of(1, 0), Vector2D.of(1, 1), TEST_PRECISION)
);
@@ -50,7 +50,7 @@ public void testToList() {
@Test
public void testToList_noBoundaries() {
// act
final BoundarySource2D src = BoundarySource2D.from();
final BoundarySource2D src = BoundarySource2D.of();

// act
final BoundaryList2D list = src.toList();
@@ -62,7 +62,7 @@ public void testToList_noBoundaries() {
@Test
public void testToTree() {
// act
final BoundarySource2D src = BoundarySource2D.from(
final BoundarySource2D src = BoundarySource2D.of(
Lines.segmentFromPoints(Vector2D.ZERO, Vector2D.of(1, 0), TEST_PRECISION),
Lines.segmentFromPoints(Vector2D.of(1, 0), Vector2D.of(1, 1), TEST_PRECISION)
);
@@ -79,7 +79,7 @@ public void testToTree() {
@Test
public void testToTree_noBoundaries() {
// act
final BoundarySource2D src = BoundarySource2D.from();
final BoundarySource2D src = BoundarySource2D.of();

// act
final RegionBSPTree2D tree = src.toTree();
@@ -91,22 +91,22 @@ public void testToTree_noBoundaries() {
}

@Test
public void testFrom_varargs_empty() {
public void testOf_varargs_empty() {
// act
final BoundarySource2D src = BoundarySource2D.from();
final BoundarySource2D src = BoundarySource2D.of();

// assert
final List<LineConvexSubset> segments = src.boundaryStream().collect(Collectors.toList());
Assertions.assertEquals(0, segments.size());
}

@Test
public void testFrom_varargs() {
public void testOf_varargs() {
// act
final Segment a = Lines.segmentFromPoints(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
final Segment b = Lines.segmentFromPoints(Vector2D.Unit.PLUS_X, Vector2D.of(1, 1), TEST_PRECISION);

final BoundarySource2D src = BoundarySource2D.from(a, b);
final BoundarySource2D src = BoundarySource2D.of(a, b);

// assert
final List<LineConvexSubset> segments = src.boundaryStream().collect(Collectors.toList());
@@ -117,20 +117,20 @@ public void testFrom_varargs() {
}

@Test
public void testFrom_list_empty() {
public void testOf_list_empty() {
// arrange
final List<LineConvexSubset> input = new ArrayList<>();

// act
final BoundarySource2D src = BoundarySource2D.from(input);
final BoundarySource2D src = BoundarySource2D.of(input);

// assert
final List<LineConvexSubset> segments = src.boundaryStream().collect(Collectors.toList());
Assertions.assertEquals(0, segments.size());
}

@Test
public void testFrom_list() {
public void testOf_list() {
// act
final Segment a = Lines.segmentFromPoints(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
final Segment b = Lines.segmentFromPoints(Vector2D.Unit.PLUS_X, Vector2D.of(1, 1), TEST_PRECISION);
@@ -139,7 +139,7 @@ public void testFrom_list() {
input.add(a);
input.add(b);

final BoundarySource2D src = BoundarySource2D.from(input);
final BoundarySource2D src = BoundarySource2D.of(input);

// assert
final List<LineConvexSubset> segments = src.boundaryStream().collect(Collectors.toList());
@@ -34,7 +34,7 @@ public class BoundarySourceBoundsBuilder2DTest {
@Test
public void testGetBounds_noBoundaries() {
// arrange
final BoundarySource2D src = BoundarySource2D.from(new ArrayList<>());
final BoundarySource2D src = BoundarySource2D.of(new ArrayList<>());
final BoundarySourceBoundsBuilder2D builder = new BoundarySourceBoundsBuilder2D();

// act
@@ -49,7 +49,7 @@ public void testGetBounds_singleFiniteBoundary() {
// arrange
final Segment seg = Lines.segmentFromPoints(Vector2D.of(1, -2), Vector2D.of(-3, 4), TEST_PRECISION);

final BoundarySource2D src = BoundarySource2D.from(seg);
final BoundarySource2D src = BoundarySource2D.of(seg);
final BoundarySourceBoundsBuilder2D builder = new BoundarySourceBoundsBuilder2D();

// act
@@ -68,7 +68,7 @@ public void testGetBounds_multipleFiniteBoundaries() {
final Segment seg2 = Lines.segmentFromPoints(Vector2D.of(0, 1), Vector2D.of(7, 0), TEST_PRECISION);
final Segment seg3 = Lines.segmentFromPoints(Vector2D.of(4, 6), Vector2D.of(-3, 9), TEST_PRECISION);

final BoundarySource2D src = BoundarySource2D.from(seg1, seg2, seg3);
final BoundarySource2D src = BoundarySource2D.of(seg1, seg2, seg3);
final BoundarySourceBoundsBuilder2D builder = new BoundarySourceBoundsBuilder2D();

// act
@@ -88,7 +88,7 @@ public void testGetBounds_singleInfiniteBoundary() {
// arrange
final LineConvexSubset boundary = Lines.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION)
.span();
final BoundarySource2D src = BoundarySource2D.from(boundary);
final BoundarySource2D src = BoundarySource2D.of(boundary);
final BoundarySourceBoundsBuilder2D builder = new BoundarySourceBoundsBuilder2D();

// act
@@ -110,7 +110,7 @@ public void testGetBounds_mixedFiniteAndInfiniteBoundaries() {
final Segment seg2 = Lines.segmentFromPoints(Vector2D.of(0, 1), Vector2D.of(7, 0), TEST_PRECISION);
final Segment seg3 = Lines.segmentFromPoints(Vector2D.of(4, 6), Vector2D.of(-3, 9), TEST_PRECISION);

final BoundarySource2D src = BoundarySource2D.from(seg1, seg2, inf, seg3);
final BoundarySource2D src = BoundarySource2D.of(seg1, seg2, inf, seg3);
final BoundarySourceBoundsBuilder2D builder = new BoundarySourceBoundsBuilder2D();

// act
@@ -92,7 +92,7 @@ public void testLinecast_line_corners() {
@Test
public void testLinecast_line_removesDuplicatePoints() {
// arrange
final BoundarySource2D src = BoundarySource2D.from(
final BoundarySource2D src = BoundarySource2D.of(
Lines.segmentFromPoints(Vector2D.of(-1, -1), Vector2D.ZERO, TEST_PRECISION),
Lines.segmentFromPoints(Vector2D.ZERO, Vector2D.of(1, 1), TEST_PRECISION)
);
@@ -220,7 +220,7 @@ public void testLinecast_segment_corners() {
@Test
public void testLinecast_segment_removesDuplicatePoints() {
// arrange
final BoundarySource2D src = BoundarySource2D.from(
final BoundarySource2D src = BoundarySource2D.of(
Lines.segmentFromPoints(Vector2D.of(-1, -1), Vector2D.ZERO, TEST_PRECISION),
Lines.segmentFromPoints(Vector2D.ZERO, Vector2D.of(1, 1), TEST_PRECISION)
);
@@ -64,7 +64,7 @@ public void testReadWrite_supportedTypes() {

private void checkWriteRead(final String type) {
// arrange
final BoundarySource3D model = BoundarySource3D.from(
final BoundarySource3D model = BoundarySource3D.of(
Planes.triangleFromVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0), TEST_PRECISION)
);

0 comments on commit 2c84bf3

Please sign in to comment.