You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2020/12/10 02:58:54 UTC
[commons-geometry] branch master updated: GEOMETRY-106 - Refine
Module
This is an automated email from the ASF dual-hosted git repository.
mattjuntunen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
The following commit(s) were added to refs/heads/master by this push:
new 4573154 GEOMETRY-106 - Refine Module
4573154 is described below
commit 4573154a284c0e64b1a76d527b3c546696cfc5d0
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Tue Dec 8 09:09:09 2020 +0100
GEOMETRY-106 - Refine Module
---
.../commons/geometry/euclidean/threed/Planes.java | 2 +-
.../euclidean/threed/mesh/SimpleTriangleMesh.java | 2 +-
.../examples/io/threed/AbstractModelIOHandler.java | 10 +--
.../threed/DefaultModelIOHandlerRegistryTest.java | 14 ++--
.../io/threed/ModelIOHandlerRegistryTest.java | 78 +++++++++++-----------
.../geometry/examples/io/threed/ModelIOTest.java | 18 ++---
.../io/threed/obj/OBJModelIOHandlerTest.java | 44 ++++++------
.../examples/io/threed/obj/OBJReaderTest.java | 56 ++++++++--------
.../examples/io/threed/obj/OBJWriterTest.java | 62 ++++++++---------
.../jmh/euclidean/RegionBSPTree2DPerformance.java | 2 +-
.../jmh/euclidean/RegionBSPTree3DPerformance.java | 2 +-
.../examples/jmh/euclidean/VectorPerformance.java | 2 +-
.../examples/tutorials/bsp/BSPTreeSVGWriter.java | 32 ++++-----
.../examples/tutorials/bsp/BSPTreeUnion.java | 14 ++--
.../examples/tutorials/bsp/BSPTreeXor.java | 12 ++--
.../tutorials/bsp/BottomUpBSPTreeConstruction.java | 36 +++++-----
.../tutorials/bsp/HexagonPartitionedRegion.java | 12 ++--
.../tutorials/bsp/HexagonStructuralCut.java | 12 ++--
.../examples/tutorials/bsp/HexagonUnbalanced.java | 12 ++--
.../tutorials/bsp/TopDownBSPTreeConstruction.java | 38 +++++------
.../geometry/spherical/oned/RegionBSPTree1S.java | 2 +-
21 files changed, 231 insertions(+), 231 deletions(-)
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Planes.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Planes.java
index 73ce61e..ae76fe0 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Planes.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Planes.java
@@ -808,7 +808,7 @@ public final class Planes {
this.basePlane = basePlane;
// Extruded plane; this forms the end of the 3D region opposite the base plane.
- EmbeddingPlane extrudedPlane = basePlane.translate(extrusionVector);
+ final EmbeddingPlane extrudedPlane = basePlane.translate(extrusionVector);
if (basePlane.contains(extrudedPlane)) {
throw new IllegalArgumentException(
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/mesh/SimpleTriangleMesh.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/mesh/SimpleTriangleMesh.java
index 1c56b5b..ca10e99 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/mesh/SimpleTriangleMesh.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/mesh/SimpleTriangleMesh.java
@@ -678,7 +678,7 @@ public final class SimpleTriangleMesh implements TriangleMesh {
final Integer actualIdx = map.putIfAbsent(vertex, targetIdx);
return actualIdx != null ?
- actualIdx.intValue() :
+ actualIdx :
targetIdx;
}
diff --git a/commons-geometry-examples/examples-io/src/main/java/org/apache/commons/geometry/examples/io/threed/AbstractModelIOHandler.java b/commons-geometry-examples/examples-io/src/main/java/org/apache/commons/geometry/examples/io/threed/AbstractModelIOHandler.java
index 06cfe3c..826a113 100644
--- a/commons-geometry-examples/examples-io/src/main/java/org/apache/commons/geometry/examples/io/threed/AbstractModelIOHandler.java
+++ b/commons-geometry-examples/examples-io/src/main/java/org/apache/commons/geometry/examples/io/threed/AbstractModelIOHandler.java
@@ -38,7 +38,7 @@ public abstract class AbstractModelIOHandler implements ModelIOHandler {
try (InputStream is = Files.newInputStream(in.toPath())) {
return readInternal(type, is, precision);
}
- } catch (IOException exc) {
+ } catch (final IOException exc) {
throw createUnchecked(exc);
}
}
@@ -49,7 +49,7 @@ public abstract class AbstractModelIOHandler implements ModelIOHandler {
ensureTypeSupported(type);
try {
return readInternal(type, in, precision);
- } catch (IOException exc) {
+ } catch (final IOException exc) {
throw createUnchecked(exc);
}
}
@@ -62,18 +62,18 @@ public abstract class AbstractModelIOHandler implements ModelIOHandler {
try (OutputStream os = Files.newOutputStream(out.toPath())) {
writeInternal(model, type, os);
}
- } catch (IOException exc) {
+ } catch (final IOException exc) {
throw createUnchecked(exc);
}
}
/** {@inheritDoc} */
@Override
- public void write(final BoundarySource3D model, final String type, OutputStream out) {
+ public void write(final BoundarySource3D model, final String type, final OutputStream out) {
ensureTypeSupported(type);
try {
writeInternal(model, type, out);
- } catch (IOException exc) {
+ } catch (final IOException exc) {
throw createUnchecked(exc);
}
}
diff --git a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/DefaultModelIOHandlerRegistryTest.java b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/DefaultModelIOHandlerRegistryTest.java
index ec1edfd..3073132 100644
--- a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/DefaultModelIOHandlerRegistryTest.java
+++ b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/DefaultModelIOHandlerRegistryTest.java
@@ -43,7 +43,7 @@ public class DefaultModelIOHandlerRegistryTest {
@Test
public void testDefaultHandlers() {
// act
- List<ModelIOHandler> handlers = registry.getHandlers();
+ final List<ModelIOHandler> handlers = registry.getHandlers();
// assert
Assertions.assertEquals(1, handlers.size());
@@ -62,23 +62,23 @@ public class DefaultModelIOHandlerRegistryTest {
checkWriteRead("obj");
}
- private void checkWriteRead(String type) {
+ private void checkWriteRead(final String type) {
// arrange
- BoundarySource3D model = BoundarySource3D.from(
+ final BoundarySource3D model = BoundarySource3D.from(
Planes.triangleFromVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0), TEST_PRECISION)
);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
// act
registry.write(model, type, out);
- BoundarySource3D result = registry.read(type, new ByteArrayInputStream(out.toByteArray()), TEST_PRECISION);
+ final BoundarySource3D result = registry.read(type, new ByteArrayInputStream(out.toByteArray()), TEST_PRECISION);
// assert
- List<Triangle3D> tris = result.triangleStream().collect(Collectors.toList());
+ final List<Triangle3D> tris = result.triangleStream().collect(Collectors.toList());
Assertions.assertEquals(1, tris.size());
- Triangle3D tri = tris.get(0);
+ final Triangle3D tri = tris.get(0);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, tri.getPoint1(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 0, 0), tri.getPoint2(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0, 1, 0), tri.getPoint3(), TEST_EPS);
diff --git a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOHandlerRegistryTest.java b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOHandlerRegistryTest.java
index e097176..d687868 100644
--- a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOHandlerRegistryTest.java
+++ b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOHandlerRegistryTest.java
@@ -47,16 +47,16 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testGetSetHandlers() {
// arrange
- StubHandler handlerA = new StubHandler("a", SRC_A);
- StubHandler handlerB = new StubHandler("b", SRC_B);
+ final StubHandler handlerA = new StubHandler("a", SRC_A);
+ final StubHandler handlerB = new StubHandler("b", SRC_B);
- List<ModelIOHandler> handlers = Arrays.asList(handlerA, handlerB);
+ final List<ModelIOHandler> handlers = Arrays.asList(handlerA, handlerB);
// act
registry.setHandlers(handlers);
// assert
- List<ModelIOHandler> resultHandlers = registry.getHandlers();
+ final List<ModelIOHandler> resultHandlers = registry.getHandlers();
Assertions.assertNotSame(handlers, resultHandlers);
Assertions.assertEquals(2, resultHandlers.size());
@@ -67,8 +67,8 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testSetHandlers_null() {
// arrange
- StubHandler handlerA = new StubHandler("a", SRC_A);
- StubHandler handlerB = new StubHandler("b", SRC_B);
+ final StubHandler handlerA = new StubHandler("a", SRC_A);
+ final StubHandler handlerB = new StubHandler("b", SRC_B);
registry.setHandlers(Arrays.asList(handlerA, handlerB));
@@ -82,8 +82,8 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testGetHandlerForType() {
// arrange
- StubHandler handlerA = new StubHandler("a", SRC_A);
- StubHandler handlerB = new StubHandler("b", SRC_B);
+ final StubHandler handlerA = new StubHandler("a", SRC_A);
+ final StubHandler handlerB = new StubHandler("b", SRC_B);
registry.setHandlers(Arrays.asList(handlerA, handlerB));
@@ -100,8 +100,8 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testHandlesType() {
// arrange
- StubHandler handlerA = new StubHandler("a", SRC_A);
- StubHandler handlerB = new StubHandler("b", SRC_B);
+ final StubHandler handlerA = new StubHandler("a", SRC_A);
+ final StubHandler handlerB = new StubHandler("b", SRC_B);
registry.setHandlers(Arrays.asList(handlerA, handlerB));
@@ -118,15 +118,15 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testRead_typeFromFileExtension() {
// arrange
- StubHandler handlerA = new StubHandler("a", SRC_A);
- StubHandler handlerB = new StubHandler("b", SRC_B);
+ final StubHandler handlerA = new StubHandler("a", SRC_A);
+ final StubHandler handlerB = new StubHandler("b", SRC_B);
registry.setHandlers(Arrays.asList(handlerA, handlerB));
- File file = new File("file.B");
+ final File file = new File("file.B");
// act
- BoundarySource3D src = registry.read(file, TEST_PRECISION);
+ final BoundarySource3D src = registry.read(file, TEST_PRECISION);
// assert
Assertions.assertSame(SRC_B, src);
@@ -135,7 +135,7 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testRead_typeFromFileExtension_unknownType() {
// arrange
- File file = new File("file.B");
+ final File file = new File("file.B");
// act/assert
GeometryTestUtils.assertThrows(() -> {
@@ -146,7 +146,7 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testRead_typeFromFileExtension_noFileExtension() {
// arrange
- File file = new File("file");
+ final File file = new File("file");
// act/assert
GeometryTestUtils.assertThrows(() -> {
@@ -158,13 +158,13 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testRead_typeAndFile() {
// arrange
- StubHandler handlerA = new StubHandler("a", SRC_A);
- StubHandler handlerB = new StubHandler("b", SRC_B);
+ final StubHandler handlerA = new StubHandler("a", SRC_A);
+ final StubHandler handlerB = new StubHandler("b", SRC_B);
registry.setHandlers(Arrays.asList(handlerA, handlerB));
// act
- BoundarySource3D src = registry.read("a", new File("file"), TEST_PRECISION);
+ final BoundarySource3D src = registry.read("a", new File("file"), TEST_PRECISION);
// assert
Assertions.assertSame(SRC_A, src);
@@ -173,7 +173,7 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testRead_typeAndFile_unknownType() {
// arrange
- File file = new File("file");
+ final File file = new File("file");
// act/assert
GeometryTestUtils.assertThrows(() -> {
@@ -184,13 +184,13 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testRead_typeAndInputStream() {
// arrange
- StubHandler handlerA = new StubHandler("a", SRC_A);
- StubHandler handlerB = new StubHandler("b", SRC_B);
+ final StubHandler handlerA = new StubHandler("a", SRC_A);
+ final StubHandler handlerB = new StubHandler("b", SRC_B);
registry.setHandlers(Arrays.asList(handlerA, handlerB));
// act
- BoundarySource3D src = registry.read("a", new ByteArrayInputStream(new byte[0]), TEST_PRECISION);
+ final BoundarySource3D src = registry.read("a", new ByteArrayInputStream(new byte[0]), TEST_PRECISION);
// assert
Assertions.assertSame(SRC_A, src);
@@ -207,12 +207,12 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testWrite_typeFromFileExtension() {
// arrange
- StubHandler handlerA = new StubHandler("a", SRC_A);
- StubHandler handlerB = new StubHandler("b", SRC_B);
+ final StubHandler handlerA = new StubHandler("a", SRC_A);
+ final StubHandler handlerB = new StubHandler("b", SRC_B);
registry.setHandlers(Arrays.asList(handlerA, handlerB));
- File file = new File("file.B");
+ final File file = new File("file.B");
// act
registry.write(SRC_B, file);
@@ -225,7 +225,7 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testWrite_typeFromFileExtension_unknownType() {
// arrange
- File file = new File("file.B");
+ final File file = new File("file.B");
// act/assert
GeometryTestUtils.assertThrows(() -> {
@@ -236,7 +236,7 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testWrite_typeFromFileExtension_noFileExtension() {
// arrange
- File file = new File("file");
+ final File file = new File("file");
// act/assert
GeometryTestUtils.assertThrows(() -> {
@@ -248,12 +248,12 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testWrite_typeAndFile() {
// arrange
- StubHandler handlerA = new StubHandler("a", SRC_A);
- StubHandler handlerB = new StubHandler("b", SRC_B);
+ final StubHandler handlerA = new StubHandler("a", SRC_A);
+ final StubHandler handlerB = new StubHandler("b", SRC_B);
registry.setHandlers(Arrays.asList(handlerA, handlerB));
- File file = new File("file.B");
+ final File file = new File("file.B");
// act
registry.write(SRC_B, "a", file);
@@ -266,7 +266,7 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testWrite_typeAndFile_unknownType() {
// arrange
- File file = new File("file");
+ final File file = new File("file");
// act/assert
GeometryTestUtils.assertThrows(() -> {
@@ -277,8 +277,8 @@ public class ModelIOHandlerRegistryTest {
@Test
public void testWrite_typeAndOutputStream() {
// arrange
- StubHandler handlerA = new StubHandler("a", SRC_A);
- StubHandler handlerB = new StubHandler("b", SRC_B);
+ final StubHandler handlerA = new StubHandler("a", SRC_A);
+ final StubHandler handlerB = new StubHandler("b", SRC_B);
registry.setHandlers(Arrays.asList(handlerA, handlerB));
@@ -312,27 +312,27 @@ public class ModelIOHandlerRegistryTest {
}
@Override
- public boolean handlesType(String type) {
+ public boolean handlesType(final String type) {
return this.handlerType.equals(type);
}
@Override
- public BoundarySource3D read(String type, File in, DoublePrecisionContext precision) {
+ public BoundarySource3D read(final String type, final File in, final DoublePrecisionContext precision) {
return boundarySrc;
}
@Override
- public BoundarySource3D read(String type, InputStream in, DoublePrecisionContext precision) {
+ public BoundarySource3D read(final String type, final InputStream in, final DoublePrecisionContext precision) {
return boundarySrc;
}
@Override
- public void write(BoundarySource3D model, String type, File out) {
+ public void write(final BoundarySource3D model, final String type, final File out) {
outputBoundarySrc = model;
}
@Override
- public void write(BoundarySource3D model, String type, OutputStream out) {
+ public void write(final BoundarySource3D model, final String type, final OutputStream out) {
outputBoundarySrc = model;
}
}
diff --git a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOTest.java b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOTest.java
index 5cc0ffc..8480681 100644
--- a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOTest.java
+++ b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/ModelIOTest.java
@@ -48,7 +48,7 @@ public class ModelIOTest {
@Test
public void testGetHandler() {
// act
- ModelIOHandlerRegistry registry = ModelIO.getModelIOHandlerRegistry();
+ final ModelIOHandlerRegistry registry = ModelIO.getModelIOHandlerRegistry();
// assert
Assertions.assertTrue(registry instanceof DefaultModelIOHandlerRegistry);
@@ -60,7 +60,7 @@ public class ModelIOTest {
// act/assert
checkWriteRead(model -> {
//File file = new File(tempFolder.getRoot(), "model.obj");
- File file = new File(anotherTempDir, "model.obj");
+ final File file = new File(anotherTempDir, "model.obj");
ModelIO.write(model, file);
return ModelIO.read(file, TEST_PRECISION);
});
@@ -71,7 +71,7 @@ public class ModelIOTest {
// act/assert
checkWriteRead(model -> {
//File file = new File(tempFolder.getRoot(), "objmodel");
- File file = new File(anotherTempDir, "objmodel");
+ final File file = new File(anotherTempDir, "objmodel");
ModelIO.write(model, "OBJ", file);
return ModelIO.read("obj", file, TEST_PRECISION);
});
@@ -82,7 +82,7 @@ public class ModelIOTest {
// act/assert
checkWriteRead(model -> {
//File file = new File(tempFolder.getRoot(), "objmodel");
- File file = new File(anotherTempDir, "objmodel");
+ final File file = new File(anotherTempDir, "objmodel");
try (OutputStream out = Files.newOutputStream(file.toPath())) {
ModelIO.write(model, "OBJ", out);
}
@@ -98,20 +98,20 @@ public class ModelIOTest {
BoundarySource3D apply(BoundarySource3D model) throws IOException;
}
- private void checkWriteRead(ModelIOFunction fn) throws IOException {
+ private void checkWriteRead(final ModelIOFunction fn) throws IOException {
// arrange
- BoundarySource3D model = BoundarySource3D.from(
+ final BoundarySource3D model = BoundarySource3D.from(
Planes.triangleFromVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0), TEST_PRECISION)
);
// act
- BoundarySource3D result = fn.apply(model);
+ final BoundarySource3D result = fn.apply(model);
// assert
- List<Triangle3D> tris = result.triangleStream().collect(Collectors.toList());
+ final List<Triangle3D> tris = result.triangleStream().collect(Collectors.toList());
Assertions.assertEquals(1, tris.size());
- Triangle3D tri = tris.get(0);
+ final Triangle3D tri = tris.get(0);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, tri.getPoint1(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 0, 0), tri.getPoint2(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0, 1, 0), tri.getPoint3(), TEST_EPS);
diff --git a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJModelIOHandlerTest.java b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJModelIOHandlerTest.java
index 5c83f04..40020b1 100644
--- a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJModelIOHandlerTest.java
+++ b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJModelIOHandlerTest.java
@@ -72,10 +72,10 @@ public class OBJModelIOHandlerTest {
@Test
public void testRead_fromFile() throws Exception {
// act
- BoundarySource3D src = handler.read("obj", cubeMinusSphereFile(), TEST_PRECISION);
+ final BoundarySource3D src = handler.read("obj", cubeMinusSphereFile(), TEST_PRECISION);
// assert
- TriangleMesh mesh = (TriangleMesh) src;
+ final TriangleMesh mesh = (TriangleMesh) src;
Assertions.assertEquals(CUBE_MINUS_SPHERE_VERTICES, mesh.getVertexCount());
Assertions.assertEquals(CUBE_MINUS_SPHERE_FACES, mesh.getFaceCount());
}
@@ -83,7 +83,7 @@ public class OBJModelIOHandlerTest {
@Test
public void testRead_fromFile_unsupportedType() throws Exception {
// arrange
- File file = cubeMinusSphereFile();
+ final File file = cubeMinusSphereFile();
// act/assert
GeometryTestUtils.assertThrows(() -> {
@@ -94,7 +94,7 @@ public class OBJModelIOHandlerTest {
@Test
public void testRead_fromFile_ioException() throws Exception {
// arrange
- File file = new File("doesnotexist.obj");
+ final File file = new File("doesnotexist.obj");
// act/assert
GeometryTestUtils.assertThrows(() -> {
@@ -105,13 +105,13 @@ public class OBJModelIOHandlerTest {
@Test
public void testRead_fromStream() throws Exception {
// act
- BoundarySource3D src;
+ final BoundarySource3D src;
try (InputStream in = Files.newInputStream(cubeMinusSphereFile().toPath())) {
src = handler.read("obj", cubeMinusSphereFile(), TEST_PRECISION);
}
// assert
- TriangleMesh mesh = (TriangleMesh) src;
+ final TriangleMesh mesh = (TriangleMesh) src;
Assertions.assertEquals(CUBE_MINUS_SPHERE_VERTICES, mesh.getVertexCount());
Assertions.assertEquals(CUBE_MINUS_SPHERE_FACES, mesh.getFaceCount());
}
@@ -119,7 +119,7 @@ public class OBJModelIOHandlerTest {
@Test
public void testRead_fromStream_unsupportedType() throws Exception {
// arrange
- File file = cubeMinusSphereFile();
+ final File file = cubeMinusSphereFile();
// act/assert
try (InputStream in = Files.newInputStream(file.toPath())) {
@@ -140,9 +140,9 @@ public class OBJModelIOHandlerTest {
@Test
public void testWrite_toFile() throws Exception {
// arrange
- File out = new File(anotherTempDir, "out.obj");
+ final File out = new File(anotherTempDir, "out.obj");
- BoundarySource3D src = BoundarySource3D.from(
+ final BoundarySource3D src = BoundarySource3D.from(
Planes.triangleFromVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0), TEST_PRECISION)
);
@@ -150,7 +150,7 @@ public class OBJModelIOHandlerTest {
handler.write(src, "OBJ", out);
// assert
- TriangleMesh mesh = (TriangleMesh) handler.read("obj", out, TEST_PRECISION);
+ final TriangleMesh mesh = (TriangleMesh) handler.read("obj", out, TEST_PRECISION);
Assertions.assertEquals(3, mesh.getVertexCount());
Assertions.assertEquals(1, mesh.getFaceCount());
}
@@ -158,8 +158,8 @@ public class OBJModelIOHandlerTest {
@Test
public void testWrite_toFile_unsupportedFormat() throws Exception {
// arrange
- File out = new File(anotherTempDir, "out.obj");
- BoundarySource3D src = BoundarySource3D.from(
+ final File out = new File(anotherTempDir, "out.obj");
+ final BoundarySource3D src = BoundarySource3D.from(
Planes.triangleFromVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0), TEST_PRECISION)
);
@@ -172,8 +172,8 @@ public class OBJModelIOHandlerTest {
@Test
public void testWrite_toFile_ioException() throws Exception {
// arrange
- File out = new File(anotherTempDir, "notafolder/notafile");
- BoundarySource3D src = BoundarySource3D.from(
+ final File out = new File(anotherTempDir, "notafolder/notafile");
+ final BoundarySource3D src = BoundarySource3D.from(
Planes.triangleFromVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0), TEST_PRECISION)
);
@@ -186,9 +186,9 @@ public class OBJModelIOHandlerTest {
@Test
public void testWrite_toStream() throws Exception {
// arrange
- ByteArrayOutputStream out = new ByteArrayOutputStream();
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
- BoundarySource3D src = BoundarySource3D.from(
+ final BoundarySource3D src = BoundarySource3D.from(
Planes.triangleFromVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0), TEST_PRECISION)
);
@@ -196,7 +196,7 @@ public class OBJModelIOHandlerTest {
handler.write(src, "OBJ", out);
// assert
- TriangleMesh mesh = (TriangleMesh) handler.read("obj", new ByteArrayInputStream(out.toByteArray()),
+ final TriangleMesh mesh = (TriangleMesh) handler.read("obj", new ByteArrayInputStream(out.toByteArray()),
TEST_PRECISION);
Assertions.assertEquals(3, mesh.getVertexCount());
Assertions.assertEquals(1, mesh.getFaceCount());
@@ -205,8 +205,8 @@ public class OBJModelIOHandlerTest {
@Test
public void testWrite_toStream_unsupportedFormat() throws Exception {
// arrange
- File file = new File(anotherTempDir, "out.obj");
- BoundarySource3D src = BoundarySource3D.from(
+ final File file = new File(anotherTempDir, "out.obj");
+ final BoundarySource3D src = BoundarySource3D.from(
Planes.triangleFromVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0), TEST_PRECISION)
);
@@ -221,7 +221,7 @@ public class OBJModelIOHandlerTest {
@Test
public void testWrite_toStream_ioException() throws Exception {
// arrange
- BoundarySource3D src = BoundarySource3D.from(
+ final BoundarySource3D src = BoundarySource3D.from(
Planes.triangleFromVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0), TEST_PRECISION)
);
@@ -232,7 +232,7 @@ public class OBJModelIOHandlerTest {
}
private static File cubeMinusSphereFile() throws Exception {
- URL url = OBJModelIOHandlerTest.class.getResource(CUBE_MINUS_SPHERE_MODEL);
+ final URL url = OBJModelIOHandlerTest.class.getResource(CUBE_MINUS_SPHERE_MODEL);
return new File(url.toURI());
}
@@ -247,7 +247,7 @@ public class OBJModelIOHandlerTest {
private static final class FailingOutputStream extends OutputStream {
@Override
- public void write(int b) throws IOException {
+ public void write(final int b) throws IOException {
throw new IOException("test");
}
}
diff --git a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJReaderTest.java b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJReaderTest.java
index 5e5101e..195d0ee 100644
--- a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJReaderTest.java
+++ b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJReaderTest.java
@@ -51,7 +51,7 @@ public class OBJReaderTest {
@Test
public void testReadMesh_emptyInput() throws Exception {
// act
- TriangleMesh mesh = reader.readTriangleMesh(new StringReader(""), TEST_PRECISION);
+ final TriangleMesh mesh = reader.readTriangleMesh(new StringReader(""), TEST_PRECISION);
// assert
Assertions.assertEquals(0, mesh.getVertexCount());
@@ -61,7 +61,7 @@ public class OBJReaderTest {
@Test
public void testReadMesh_mixedVertexIndexTypesAndWhitespace() throws Exception {
// arrange
- String input =
+ final String input =
"#some comments \n\r\n \n" +
" # some other comments\n" +
"v 0.0 0.0 0.0\n" +
@@ -72,18 +72,18 @@ public class OBJReaderTest {
" f -1 -2\t-3";
// act
- TriangleMesh mesh = reader.readTriangleMesh(new StringReader(input), TEST_PRECISION);
+ final TriangleMesh mesh = reader.readTriangleMesh(new StringReader(input), TEST_PRECISION);
// assert
Assertions.assertEquals(4, mesh.getVertexCount());
Assertions.assertEquals(2, mesh.getFaceCount());
- Triangle3D t0 = mesh.getFace(0).getPolygon();
+ final Triangle3D t0 = mesh.getFace(0).getPolygon();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, t0.getPoint1(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.1, 0, 0), t0.getPoint2(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0, 1, 0), t0.getPoint3(), TEST_EPS);
- Triangle3D t1 = mesh.getFace(1).getPolygon();
+ final Triangle3D t1 = mesh.getFace(1).getPolygon();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0, 0, 1), t1.getPoint1(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0, 1, 0), t1.getPoint2(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.1, 0, 0), t1.getPoint3(), TEST_EPS);
@@ -92,7 +92,7 @@ public class OBJReaderTest {
@Test
public void testReadMesh_multipleFaceIndices_usesTriangleFan() throws Exception {
// arrange
- String input =
+ final String input =
"v 0 0 0\n" +
"v 1 0 0\n" +
"v 1 1 0\n" +
@@ -101,23 +101,23 @@ public class OBJReaderTest {
"f 1 2 3 -2 -1\n";
// act
- TriangleMesh mesh = reader.readTriangleMesh(new StringReader(input), TEST_PRECISION);
+ final TriangleMesh mesh = reader.readTriangleMesh(new StringReader(input), TEST_PRECISION);
// assert
Assertions.assertEquals(5, mesh.getVertexCount());
Assertions.assertEquals(3, mesh.getFaceCount());
- Triangle3D t0 = mesh.getFace(0).getPolygon();
+ final Triangle3D t0 = mesh.getFace(0).getPolygon();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, t0.getPoint1(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 0, 0), t0.getPoint2(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 1, 0), t0.getPoint3(), TEST_EPS);
- Triangle3D t1 = mesh.getFace(1).getPolygon();
+ final Triangle3D t1 = mesh.getFace(1).getPolygon();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, t1.getPoint1(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 1, 0), t1.getPoint2(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 1.5, 0), t1.getPoint3(), TEST_EPS);
- Triangle3D t2 = mesh.getFace(2).getPolygon();
+ final Triangle3D t2 = mesh.getFace(2).getPolygon();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, t2.getPoint1(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 1.5, 0), t2.getPoint2(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0, 1, 0), t2.getPoint3(), TEST_EPS);
@@ -126,7 +126,7 @@ public class OBJReaderTest {
@Test
public void testReadMesh_ignoresUnsupportedContent() throws Exception {
// arrange
- String input =
+ final String input =
"mtllib abc.mtl\n" +
"nope\n" +
"v 0 0 0\n" +
@@ -135,13 +135,13 @@ public class OBJReaderTest {
"f 1/10/20 2//40 3//\n";
// act
- TriangleMesh mesh = reader.readTriangleMesh(new StringReader(input), TEST_PRECISION);
+ final TriangleMesh mesh = reader.readTriangleMesh(new StringReader(input), TEST_PRECISION);
// assert
Assertions.assertEquals(3, mesh.getVertexCount());
Assertions.assertEquals(1, mesh.getFaceCount());
- Triangle3D t0 = mesh.getFace(0).getPolygon();
+ final Triangle3D t0 = mesh.getFace(0).getPolygon();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, t0.getPoint1(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 0, 0), t0.getPoint2(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0, 1, 0), t0.getPoint3(), TEST_EPS);
@@ -150,13 +150,13 @@ public class OBJReaderTest {
@Test
public void testReadMesh_invalidVertexDefinition() throws Exception {
// arrange
- String badNumber =
+ final String badNumber =
"v abc 0 0\n" +
"v 1 0 0\n" +
"v 0 1 0\n" +
"f 1 2 3\n";
- String notEnoughVertices =
+ final String notEnoughVertices =
"v 0 0\n" +
"v 1 0 0\n" +
"v 0 1 0\n" +
@@ -166,7 +166,7 @@ public class OBJReaderTest {
GeometryTestUtils.assertThrows(() -> {
try {
reader.readTriangleMesh(new StringReader(badNumber), TEST_PRECISION);
- } catch (IOException exc) {
+ } catch (final IOException exc) {
throw new UncheckedIOException(exc);
}
}, NumberFormatException.class);
@@ -174,7 +174,7 @@ public class OBJReaderTest {
GeometryTestUtils.assertThrows(() -> {
try {
reader.readTriangleMesh(new StringReader(notEnoughVertices), TEST_PRECISION);
- } catch (IOException exc) {
+ } catch (final IOException exc) {
throw new UncheckedIOException(exc);
}
}, IllegalArgumentException.class, "Invalid vertex definition: at least 3 fields required but found only 2");
@@ -183,13 +183,13 @@ public class OBJReaderTest {
@Test
public void testReadMesh_invalidFaceDefinition() throws Exception {
// arrange
- String badNumber =
+ final String badNumber =
"v 0 0 0\n" +
"v 1 0 0\n" +
"v 0 1 0\n" +
"f 1 abc 3\n";
- String notEnoughIndices =
+ final String notEnoughIndices =
"v 0 0 0\n" +
"v 1 0 0\n" +
"v 0 1 0\n" +
@@ -199,7 +199,7 @@ public class OBJReaderTest {
GeometryTestUtils.assertThrows(() -> {
try {
reader.readTriangleMesh(new StringReader(badNumber), TEST_PRECISION);
- } catch (IOException exc) {
+ } catch (final IOException exc) {
throw new UncheckedIOException(exc);
}
}, NumberFormatException.class);
@@ -207,7 +207,7 @@ public class OBJReaderTest {
GeometryTestUtils.assertThrows(() -> {
try {
reader.readTriangleMesh(new StringReader(notEnoughIndices), TEST_PRECISION);
- } catch (IOException exc) {
+ } catch (final IOException exc) {
throw new UncheckedIOException(exc);
}
}, IllegalArgumentException.class, "Invalid face definition: at least 3 fields required but found only 2");
@@ -216,22 +216,22 @@ public class OBJReaderTest {
@Test
public void testReadMesh_cubeMinusSphereFile() throws Exception {
// arrange
- URL url = getClass().getResource(CUBE_MINUS_SPHERE_MODEL);
- File file = new File(url.toURI());
+ final URL url = getClass().getResource(CUBE_MINUS_SPHERE_MODEL);
+ final File file = new File(url.toURI());
// act
- TriangleMesh mesh = reader.readTriangleMesh(file, TEST_PRECISION);
+ final TriangleMesh mesh = reader.readTriangleMesh(file, TEST_PRECISION);
// assert
Assertions.assertEquals(CUBE_MINUS_SPHERE_VERTICES, mesh.getVertexCount());
Assertions.assertEquals(CUBE_MINUS_SPHERE_FACES, mesh.getFaceCount());
- RegionBSPTree3D tree = RegionBSPTree3D.partitionedRegionBuilder()
+ final RegionBSPTree3D tree = RegionBSPTree3D.partitionedRegionBuilder()
.insertAxisAlignedGrid(mesh.getBounds(), 1, TEST_PRECISION)
.insertBoundaries(mesh)
.build();
- double eps = 1e-5;
+ final double eps = 1e-5;
Assertions.assertEquals(0.11509505362599505, tree.getSize(), eps);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, tree.getCentroid(), TEST_EPS);
}
@@ -239,10 +239,10 @@ public class OBJReaderTest {
@Test
public void testReadMesh_cubeMinusSphereUrl() throws IOException {
// arrange
- URL url = getClass().getResource(CUBE_MINUS_SPHERE_MODEL);
+ final URL url = getClass().getResource(CUBE_MINUS_SPHERE_MODEL);
// act
- TriangleMesh mesh = reader.readTriangleMesh(url, TEST_PRECISION);
+ final TriangleMesh mesh = reader.readTriangleMesh(url, TEST_PRECISION);
// assert
Assertions.assertEquals(CUBE_MINUS_SPHERE_VERTICES, mesh.getVertexCount());
diff --git a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJWriterTest.java b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJWriterTest.java
index 4983164..6c440c1 100644
--- a/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJWriterTest.java
+++ b/commons-geometry-examples/examples-io/src/test/java/org/apache/commons/geometry/examples/io/threed/obj/OBJWriterTest.java
@@ -48,7 +48,7 @@ public class OBJWriterTest {
@Test
public void testDefaults() throws IOException {
// arrange
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
// act/assert
try (OBJWriter meshWriter = new OBJWriter(writer)) {
@@ -60,7 +60,7 @@ public class OBJWriterTest {
@Test
public void testClose_calledMultipleTimes() throws IOException {
// arrange
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
// act/assert
try (OBJWriter meshWriter = new OBJWriter(writer)) {
@@ -72,7 +72,7 @@ public class OBJWriterTest {
@Test
public void testSetLineSeparator() throws IOException {
// arrange
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
// act
try (OBJWriter meshWriter = new OBJWriter(writer)) {
@@ -93,7 +93,7 @@ public class OBJWriterTest {
@Test
public void testSetDecimalFormat() throws IOException {
// arrange
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
// act
try (OBJWriter meshWriter = new OBJWriter(writer)) {
@@ -109,7 +109,7 @@ public class OBJWriterTest {
@Test
public void testWriteComment() throws IOException {
// arrange
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
// act
try (OBJWriter meshWriter = new OBJWriter(writer)) {
@@ -128,7 +128,7 @@ public class OBJWriterTest {
@Test
public void testWriteObjectName() throws IOException {
// arrange
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
// act
try (OBJWriter meshWriter = new OBJWriter(writer)) {
@@ -142,7 +142,7 @@ public class OBJWriterTest {
@Test
public void testWriteGroupName() throws IOException {
// arrange
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
// act
try (OBJWriter meshWriter = new OBJWriter(writer)) {
@@ -156,11 +156,11 @@ public class OBJWriterTest {
@Test
public void testWriteVertex() throws IOException {
// arrange
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
// act
- int index1;
- int index2;
+ final int index1;
+ final int index2;
try (OBJWriter meshWriter = new OBJWriter(writer)) {
meshWriter.getDecimalFormat().setMaximumFractionDigits(1);
@@ -179,7 +179,7 @@ public class OBJWriterTest {
@Test
public void testWriteFace() throws IOException {
// arrange
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
// act
try (OBJWriter meshWriter = new OBJWriter(writer)) {
@@ -205,13 +205,13 @@ public class OBJWriterTest {
@Test
public void testWriteFace_invalidVertexNumber() throws IOException {
// arrange
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
// act
GeometryTestUtils.assertThrows(() -> {
try (OBJWriter meshWriter = new OBJWriter(writer)) {
meshWriter.writeFace(1, 2);
- } catch (IOException exc) {
+ } catch (final IOException exc) {
throw new UncheckedIOException(exc);
}
}, IllegalArgumentException.class, "Face must have more than 3 vertices; found 2");
@@ -220,12 +220,12 @@ public class OBJWriterTest {
@Test
public void testWriteMesh() throws IOException {
// arrange
- SimpleTriangleMesh mesh = SimpleTriangleMesh.builder(TEST_PRECISION)
+ final SimpleTriangleMesh mesh = SimpleTriangleMesh.builder(TEST_PRECISION)
.addFaceUsingVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0))
.addFaceUsingVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 0, 1))
.build();
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
// act
try (OBJWriter meshWriter = new OBJWriter(writer)) {
@@ -245,12 +245,12 @@ public class OBJWriterTest {
@Test
public void testWriteBoundaries_meshArgument() throws IOException {
// arrange
- SimpleTriangleMesh mesh = SimpleTriangleMesh.builder(TEST_PRECISION)
+ final SimpleTriangleMesh mesh = SimpleTriangleMesh.builder(TEST_PRECISION)
.addFaceUsingVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0))
.addFaceUsingVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 0, 1))
.build();
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
// act
try (OBJWriter meshWriter = new OBJWriter(writer)) {
@@ -270,12 +270,12 @@ public class OBJWriterTest {
@Test
public void testWriteBoundaries_nonMeshArgument() throws IOException {
// arrange
- BoundarySource3D src = BoundarySource3D.from(
+ final BoundarySource3D src = BoundarySource3D.from(
Planes.triangleFromVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0), TEST_PRECISION),
Planes.triangleFromVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 0, 1), TEST_PRECISION)
);
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
// act
try (OBJWriter meshWriter = new OBJWriter(writer)) {
@@ -297,18 +297,18 @@ public class OBJWriterTest {
@Test
public void testWriteBoundaries_infiniteBoundary() throws IOException {
// arrange
- BoundarySource3D src = BoundarySource3D.from(
+ final BoundarySource3D src = BoundarySource3D.from(
Planes.triangleFromVertices(Vector3D.ZERO, Vector3D.of(1, 0, 0), Vector3D.of(0, 1, 0), TEST_PRECISION),
Planes.fromPointAndNormal(Vector3D.ZERO, Vector3D.Unit.PLUS_Z, TEST_PRECISION).span()
);
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
// act/assert
GeometryTestUtils.assertThrows(() -> {
try (OBJWriter meshWriter = new OBJWriter(writer)) {
meshWriter.writeBoundaries(src);
- } catch (IOException exc) {
+ } catch (final IOException exc) {
throw new UncheckedIOException(exc);
}
}, IllegalArgumentException.class, Pattern.compile("^OBJ input geometry cannot be infinite: .*"));
@@ -317,17 +317,17 @@ public class OBJWriterTest {
@Test
public void testWriteToFile_boundaries() throws IOException {
// arrange
- RegionBSPTree3D box = Parallelepiped.unitCube(TEST_PRECISION).toTree();
- RegionBSPTree3D sphere = Sphere.from(Vector3D.ZERO, 0.6, TEST_PRECISION)
+ final RegionBSPTree3D box = Parallelepiped.unitCube(TEST_PRECISION).toTree();
+ final RegionBSPTree3D sphere = Sphere.from(Vector3D.ZERO, 0.6, TEST_PRECISION)
.toTree(3);
- RegionBSPTree3D result = RegionBSPTree3D.empty();
+ final RegionBSPTree3D result = RegionBSPTree3D.empty();
result.difference(box, sphere);
- TriangleMesh mesh = result.toTriangleMesh(TEST_PRECISION);
+ final TriangleMesh mesh = result.toTriangleMesh(TEST_PRECISION);
// act
- Path out = Files.createTempFile("objTest", ".obj");
+ final Path out = Files.createTempFile("objTest", ".obj");
try (OBJWriter writer = new OBJWriter(out.toFile())) {
writer.writeComment("A test obj file\nWritten by " + OBJReaderTest.class.getName());
@@ -340,15 +340,15 @@ public class OBJWriterTest {
@Test
public void testWriteToFile_mesh() throws IOException {
// arrange
- RegionBSPTree3D box = Parallelepiped.unitCube(TEST_PRECISION).toTree();
- RegionBSPTree3D sphere = Sphere.from(Vector3D.ZERO, 0.6, TEST_PRECISION)
+ final RegionBSPTree3D box = Parallelepiped.unitCube(TEST_PRECISION).toTree();
+ final RegionBSPTree3D sphere = Sphere.from(Vector3D.ZERO, 0.6, TEST_PRECISION)
.toTree(3);
- RegionBSPTree3D result = RegionBSPTree3D.empty();
+ final RegionBSPTree3D result = RegionBSPTree3D.empty();
result.difference(box, sphere);
// act
- Path out = Files.createTempFile("objTest", ".obj");
+ final Path out = Files.createTempFile("objTest", ".obj");
try (OBJWriter writer = new OBJWriter(out.toFile())) {
writer.writeComment("A test obj file\nWritten by " + OBJReaderTest.class.getName());
diff --git a/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/RegionBSPTree2DPerformance.java b/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/RegionBSPTree2DPerformance.java
index 84fef01..14568b4 100644
--- a/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/RegionBSPTree2DPerformance.java
+++ b/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/RegionBSPTree2DPerformance.java
@@ -120,7 +120,7 @@ public class RegionBSPTree2DPerformance {
public RegionBSPTree2D insertConvexWorstCase(final CircularBoundaryInput input) {
final RegionBSPTree2D tree = RegionBSPTree2D.empty();
- for (LineConvexSubset boundary : input.getBoundaries()) {
+ for (final LineConvexSubset boundary : input.getBoundaries()) {
tree.insert(boundary);
}
diff --git a/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/RegionBSPTree3DPerformance.java b/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/RegionBSPTree3DPerformance.java
index c0ddafa..2b0a1fc 100644
--- a/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/RegionBSPTree3DPerformance.java
+++ b/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/RegionBSPTree3DPerformance.java
@@ -122,7 +122,7 @@ public class RegionBSPTree3DPerformance {
public RegionBSPTree3D insertConvexWorstCase(final SphericalBoundaryInput input) {
final RegionBSPTree3D tree = RegionBSPTree3D.empty();
- for (PlaneConvexSubset boundary : input.getBoundaries()) {
+ for (final PlaneConvexSubset boundary : input.getBoundaries()) {
tree.insert(boundary);
}
diff --git a/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/VectorPerformance.java b/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/VectorPerformance.java
index 07a0abb..85df71e 100644
--- a/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/VectorPerformance.java
+++ b/commons-geometry-examples/examples-jmh/src/main/java/org/apache/commons/geometry/examples/jmh/euclidean/VectorPerformance.java
@@ -148,7 +148,7 @@ public class VectorPerformance {
case NORMALIZABLE:
final ZigguratNormalizedGaussianSampler sampler = ZigguratNormalizedGaussianSampler.of(rng);
return () -> {
- double n = sampler.sample();
+ final double n = sampler.sample();
return n == 0 ? 0.1 : n; // do not return exactly zero
};
case EDGE:
diff --git a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BSPTreeSVGWriter.java b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BSPTreeSVGWriter.java
index 26e38b2..50e8743 100644
--- a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BSPTreeSVGWriter.java
+++ b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BSPTreeSVGWriter.java
@@ -118,31 +118,31 @@ public class BSPTreeSVGWriter {
private final Bounds2D bounds;
/** The width of the SVG. */
- private int width = 750;
+ private final int width = 750;
/** The height of the SVG. */
- private int height = 375;
+ private final int height = 375;
/** The margin used in the SVG. */
- private int margin = 5;
+ private final int margin = 5;
/** Amount of the overall width of the SVG to use for the geometry area. */
- private double geometryAreaWidthFactor = 0.5;
+ private final double geometryAreaWidthFactor = 0.5;
/** Amount of the overall width of the SVG to use for the tree structure area. */
- private double treeAreaWidthFactor = 1.0 - geometryAreaWidthFactor;
+ private final double treeAreaWidthFactor = 1.0 - geometryAreaWidthFactor;
/** Angle that arrow heads on lines make with the direction of the line. */
- private double arrowAngle = 0.8 * Math.PI;
+ private final double arrowAngle = 0.8 * Math.PI;
/** Length of arrow head lines. */
- private double arrowLength = 8;
+ private final double arrowLength = 8;
/** Distance between levels of the tree in the tree structure display. */
- private double treeVerticalSpacing = 45;
+ private final double treeVerticalSpacing = 45;
/** Line end margin used in the lines between nodes in the tree structure display. */
- private double treeLineMargin = 10;
+ private final double treeLineMargin = 10;
/** Factor determining how much of the available horizontal width for a node should be used to
* offset it from its parent.
@@ -153,7 +153,7 @@ public class BSPTreeSVGWriter {
private double treeParentXOffsetMin = 0;
/** Precision context used for floating point comparisons. */
- private DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
+ private final DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
/** Construct a new instance that will render regions within the given bounds.
* @param bounds bounds used to determine what output
@@ -247,7 +247,7 @@ public class BSPTreeSVGWriter {
transformer.transform(source, target);
- } catch (ParserConfigurationException | TransformerException e) {
+ } catch (final ParserConfigurationException | TransformerException e) {
// throw as a runtime exception for convenience
throw new RuntimeException("Failed to create SVG", e);
}
@@ -475,7 +475,7 @@ public class BSPTreeSVGWriter {
* @param svgEnd end point
* @return path element
*/
- protected Element createPathElement(final String className, final Vector2D svgStart, Vector2D svgEnd) {
+ protected Element createPathElement(final String className, final Vector2D svgStart, final Vector2D svgEnd) {
final Element path = createElement(PATH_ELEMENT);
path.setAttribute(CLASS_ATTR, className);
@@ -570,12 +570,12 @@ public class BSPTreeSVGWriter {
labelGroup.appendChild(createNodeNameElement(name, svgCentroid));
if (node.isInside()) {
- for (LinePath linePath : tree.getBoundaryPaths()) {
+ for (final LinePath linePath : tree.getBoundaryPaths()) {
final Element path = createElement(PATH_ELEMENT);
pathGroup.appendChild(path);
path.setAttribute(CLASS_ATTR, "inside");
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
for (final Vector2D pt : linePath.getVertexSequence()) {
if (sb.length() < 1) {
@@ -696,7 +696,7 @@ public class BSPTreeSVGWriter {
private final double svgWidth;
/** Map of nodes to their rendered locations in the content area. */
- private final Map<RegionNode2D, Vector2D> nodeLocations = new HashMap<>();;
+ private final Map<RegionNode2D, Vector2D> nodeLocations = new HashMap<>();
/** Construct a new instance for rendering a representation of the structure of a BSP tree.
* @param treeNodeHeight the height of the BSP tree
@@ -742,7 +742,7 @@ public class BSPTreeSVGWriter {
*/
private String getNodeClassNames(final String name, final RegionNode2D node) {
final StringBuilder sb = new StringBuilder();
- sb.append("node-" + name);
+ sb.append("node-").append(name);
if (node.isLeaf()) {
sb.append(SPACE)
diff --git a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BSPTreeUnion.java b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BSPTreeUnion.java
index 5cec817..5b6c5e4 100644
--- a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BSPTreeUnion.java
+++ b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BSPTreeUnion.java
@@ -37,25 +37,25 @@ public final class BSPTreeUnion {
* @param args command arguments; if given, the first argument is used as the location of
* output folder
*/
- public static void main(String[] args) {
- File outputFolder = new File(args.length > 0 ? args[0] : ".");
- BSPTreeSVGWriter svgWriter = new BSPTreeSVGWriter(Bounds2D.from(Vector2D.of(-8, -8), Vector2D.of(8, 8)));
+ public static void main(final String[] args) {
+ final File outputFolder = new File(args.length > 0 ? args[0] : ".");
+ final BSPTreeSVGWriter svgWriter = new BSPTreeSVGWriter(Bounds2D.from(Vector2D.of(-8, -8), Vector2D.of(8, 8)));
- DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
+ final DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
- RegionBSPTree2D a = LinePath.fromVertexLoop(Arrays.asList(
+ final RegionBSPTree2D a = LinePath.fromVertexLoop(Arrays.asList(
Vector2D.of(2, 0),
Vector2D.of(-4, 3),
Vector2D.of(-4, -3)
), precision).toTree();
- RegionBSPTree2D b = LinePath.fromVertexLoop(Arrays.asList(
+ final RegionBSPTree2D b = LinePath.fromVertexLoop(Arrays.asList(
Vector2D.of(-2, 0),
Vector2D.of(4, -3),
Vector2D.of(4, 3)
), precision).toTree();
- RegionBSPTree2D result = RegionBSPTree2D.empty();
+ final RegionBSPTree2D result = RegionBSPTree2D.empty();
result.union(a, b);
diff --git a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BSPTreeXor.java b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BSPTreeXor.java
index f4d4993..9168db9 100644
--- a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BSPTreeXor.java
+++ b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BSPTreeXor.java
@@ -37,19 +37,19 @@ public final class BSPTreeXor {
* @param args command arguments; if given, the first argument is used as the location of
* output folder
*/
- public static void main(String[] args) {
- File outputFolder = new File(args.length > 0 ? args[0] : ".");
- BSPTreeSVGWriter svgWriter = new BSPTreeSVGWriter(Bounds2D.from(Vector2D.of(-8, -8), Vector2D.of(8, 8)));
+ public static void main(final String[] args) {
+ final File outputFolder = new File(args.length > 0 ? args[0] : ".");
+ final BSPTreeSVGWriter svgWriter = new BSPTreeSVGWriter(Bounds2D.from(Vector2D.of(-8, -8), Vector2D.of(8, 8)));
- DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
+ final DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
- RegionBSPTree2D result = LinePath.fromVertexLoop(Arrays.asList(
+ final RegionBSPTree2D result = LinePath.fromVertexLoop(Arrays.asList(
Vector2D.of(2, 0),
Vector2D.of(-4, 3),
Vector2D.of(-4, -3)
), precision).toTree();
- RegionBSPTree2D other = LinePath.fromVertexLoop(Arrays.asList(
+ final RegionBSPTree2D other = LinePath.fromVertexLoop(Arrays.asList(
Vector2D.of(-2, 0),
Vector2D.of(4, -3),
Vector2D.of(4, 3)
diff --git a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BottomUpBSPTreeConstruction.java b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BottomUpBSPTreeConstruction.java
index e947968..b9d93be 100644
--- a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BottomUpBSPTreeConstruction.java
+++ b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/BottomUpBSPTreeConstruction.java
@@ -44,21 +44,21 @@ public final class BottomUpBSPTreeConstruction {
* @param args command arguments; if given, the first argument is used as the location of
* output folder
*/
- public static void main(String[] args) {
- File outputFolder = new File(args.length > 0 ? args[0] : ".");
- BSPTreeSVGWriter svgWriter = new BSPTreeSVGWriter(Bounds2D.from(Vector2D.of(-8, -8), Vector2D.of(8, 8)));
+ public static void main(final String[] args) {
+ final File outputFolder = new File(args.length > 0 ? args[0] : ".");
+ final BSPTreeSVGWriter svgWriter = new BSPTreeSVGWriter(Bounds2D.from(Vector2D.of(-8, -8), Vector2D.of(8, 8)));
- Map<RegionNode2D, String> nodeNames = new HashMap<>();
+ final Map<RegionNode2D, String> nodeNames = new HashMap<>();
int cutCount = -1;
// create a precision context for floating point comparisons
- DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
+ final DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
// construct an empty tree
- RegionBSPTree2D tree = RegionBSPTree2D.empty();
+ final RegionBSPTree2D tree = RegionBSPTree2D.empty();
- Line rootCut = Lines.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, precision);
- RegionNode2D a = tree.getRoot();
+ final Line rootCut = Lines.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, precision);
+ final RegionNode2D a = tree.getRoot();
nodeNames.put(a, "a");
svgWriter.write(tree, nodeNames, new File(outputFolder, String.format(OUTPUT_FILE_FORMAT, ++cutCount)));
@@ -66,8 +66,8 @@ public final class BottomUpBSPTreeConstruction {
// add a single cut
a.cut(rootCut);
- RegionNode2D b = a.getMinus();
- RegionNode2D c = a.getPlus();
+ final RegionNode2D b = a.getMinus();
+ final RegionNode2D c = a.getPlus();
nodeNames.put(b, "b");
nodeNames.put(c, "c");
@@ -76,8 +76,8 @@ public final class BottomUpBSPTreeConstruction {
// add another cut
b.insertCut(Lines.fromPoints(Vector2D.of(1, 0), Vector2D.of(-1, 1), precision));
- RegionNode2D d = b.getMinus();
- RegionNode2D e = b.getPlus();
+ final RegionNode2D d = b.getMinus();
+ final RegionNode2D e = b.getPlus();
nodeNames.put(d, "d");
nodeNames.put(e, "e");
@@ -85,8 +85,8 @@ public final class BottomUpBSPTreeConstruction {
d.insertCut(Lines.fromPointAndDirection(Vector2D.of(-5, 1), Vector2D.Unit.MINUS_Y, precision));
- RegionNode2D f = d.getMinus();
- RegionNode2D g = d.getPlus();
+ final RegionNode2D f = d.getMinus();
+ final RegionNode2D g = d.getPlus();
nodeNames.put(f, "f");
nodeNames.put(g, "g");
@@ -95,8 +95,8 @@ public final class BottomUpBSPTreeConstruction {
// other side
c.insertCut(Lines.fromPoints(Vector2D.of(-1, 0), Vector2D.of(1, -1), precision));
- RegionNode2D h = c.getMinus();
- RegionNode2D i = c.getPlus();
+ final RegionNode2D h = c.getMinus();
+ final RegionNode2D i = c.getPlus();
nodeNames.put(h, "h");
nodeNames.put(i, "i");
@@ -104,8 +104,8 @@ public final class BottomUpBSPTreeConstruction {
h.insertCut(Lines.fromPointAndDirection(Vector2D.of(5, -1), Vector2D.Unit.PLUS_Y, precision));
- RegionNode2D j = h.getMinus();
- RegionNode2D k = h.getPlus();
+ final RegionNode2D j = h.getMinus();
+ final RegionNode2D k = h.getPlus();
nodeNames.put(j, "j");
nodeNames.put(k, "k");
diff --git a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/HexagonPartitionedRegion.java b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/HexagonPartitionedRegion.java
index 9b19ef3..93ddc38 100644
--- a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/HexagonPartitionedRegion.java
+++ b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/HexagonPartitionedRegion.java
@@ -38,13 +38,13 @@ public final class HexagonPartitionedRegion {
* @param args command arguments; if given, the first argument is used as the location of
* output folder
*/
- public static void main(String[] args) {
- File outputFolder = new File(args.length > 0 ? args[0] : ".");
- BSPTreeSVGWriter svgWriter = new BSPTreeSVGWriter(Bounds2D.from(Vector2D.of(-8, -8), Vector2D.of(8, 8)));
+ public static void main(final String[] args) {
+ final File outputFolder = new File(args.length > 0 ? args[0] : ".");
+ final BSPTreeSVGWriter svgWriter = new BSPTreeSVGWriter(Bounds2D.from(Vector2D.of(-8, -8), Vector2D.of(8, 8)));
- DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
+ final DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
- LinePath path = LinePath.fromVertexLoop(Arrays.asList(
+ final LinePath path = LinePath.fromVertexLoop(Arrays.asList(
Vector2D.of(-4, 0),
Vector2D.of(-2, -3),
Vector2D.of(2, -3),
@@ -53,7 +53,7 @@ public final class HexagonPartitionedRegion {
Vector2D.of(-2, 3)
), precision);
- RegionBSPTree2D tree = RegionBSPTree2D.partitionedRegionBuilder()
+ final RegionBSPTree2D tree = RegionBSPTree2D.partitionedRegionBuilder()
.insertAxisAlignedGrid(path.getBounds(), 1, precision)
.insertBoundaries(path)
.build();
diff --git a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/HexagonStructuralCut.java b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/HexagonStructuralCut.java
index bbd789b..073626f 100644
--- a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/HexagonStructuralCut.java
+++ b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/HexagonStructuralCut.java
@@ -40,20 +40,20 @@ public final class HexagonStructuralCut {
* @param args command arguments; if given, the first argument is used as the location of
* output folder
*/
- public static void main(String[] args) {
- File outputFolder = new File(args.length > 0 ? args[0] : ".");
- BSPTreeSVGWriter svgWriter = new BSPTreeSVGWriter(Bounds2D.from(Vector2D.of(-8, -8), Vector2D.of(8, 8)));
+ public static void main(final String[] args) {
+ final File outputFolder = new File(args.length > 0 ? args[0] : ".");
+ final BSPTreeSVGWriter svgWriter = new BSPTreeSVGWriter(Bounds2D.from(Vector2D.of(-8, -8), Vector2D.of(8, 8)));
- DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
+ final DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
- RegionBSPTree2D tree = RegionBSPTree2D.empty();
+ final RegionBSPTree2D tree = RegionBSPTree2D.empty();
tree.insert(Lines.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, precision).span(),
RegionCutRule.INHERIT);
svgWriter.write(tree, new File(outputFolder, "hex-struct-0.svg"));
- LinePath path = LinePath.fromVertexLoop(Arrays.asList(
+ final LinePath path = LinePath.fromVertexLoop(Arrays.asList(
Vector2D.of(-4, 0),
Vector2D.of(-2, -3),
Vector2D.of(2, -3),
diff --git a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/HexagonUnbalanced.java b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/HexagonUnbalanced.java
index 7737474..a56306f 100644
--- a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/HexagonUnbalanced.java
+++ b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/HexagonUnbalanced.java
@@ -37,17 +37,17 @@ public final class HexagonUnbalanced {
* @param args command arguments; if given, the first argument is used as the location of
* output folder
*/
- public static void main(String[] args) {
- File outputFolder = new File(args.length > 0 ? args[0] : ".");
- BSPTreeSVGWriter svgWriter = new BSPTreeSVGWriter(Bounds2D.from(Vector2D.of(-8, -8), Vector2D.of(8, 8)));
+ public static void main(final String[] args) {
+ final File outputFolder = new File(args.length > 0 ? args[0] : ".");
+ final BSPTreeSVGWriter svgWriter = new BSPTreeSVGWriter(Bounds2D.from(Vector2D.of(-8, -8), Vector2D.of(8, 8)));
svgWriter.setTreeParentOffsetFactor(0);
svgWriter.setTreeParentXOffsetMin(20);
- DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
+ final DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
- RegionBSPTree2D tree = RegionBSPTree2D.empty();
+ final RegionBSPTree2D tree = RegionBSPTree2D.empty();
- LinePath path = LinePath.fromVertexLoop(Arrays.asList(
+ final LinePath path = LinePath.fromVertexLoop(Arrays.asList(
Vector2D.of(-4, 0),
Vector2D.of(-2, -3),
Vector2D.of(2, -3),
diff --git a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/TopDownBSPTreeConstruction.java b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/TopDownBSPTreeConstruction.java
index 8a84c5d..3f293de 100644
--- a/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/TopDownBSPTreeConstruction.java
+++ b/commons-geometry-examples/examples-tutorials/src/main/java/org/apache/commons/geometry/examples/tutorials/bsp/TopDownBSPTreeConstruction.java
@@ -46,25 +46,25 @@ public final class TopDownBSPTreeConstruction {
* @param args command arguments; if given, the first argument is used as the location of
* output folder
*/
- public static void main(String[] args) {
- File outputFolder = new File(args.length > 0 ? args[0] : ".");
- BSPTreeSVGWriter svgWriter = new BSPTreeSVGWriter(Bounds2D.from(Vector2D.of(-8, -8), Vector2D.of(8, 8)));
+ public static void main(final String[] args) {
+ final File outputFolder = new File(args.length > 0 ? args[0] : ".");
+ final BSPTreeSVGWriter svgWriter = new BSPTreeSVGWriter(Bounds2D.from(Vector2D.of(-8, -8), Vector2D.of(8, 8)));
- Map<RegionNode2D, String> nodeNames = new HashMap<>();
+ final Map<RegionNode2D, String> nodeNames = new HashMap<>();
int cutCount = 0;
// create a precision context for floating point comparisons
- DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
+ final DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
// construct an empty tree
- RegionBSPTree2D tree = RegionBSPTree2D.empty();
+ final RegionBSPTree2D tree = RegionBSPTree2D.empty();
- Segment firstBoundary = Lines.segmentFromPoints(Vector2D.of(-5, 0), Vector2D.of(-1, 0), precision);
+ final Segment firstBoundary = Lines.segmentFromPoints(Vector2D.of(-5, 0), Vector2D.of(-1, 0), precision);
tree.insert(firstBoundary);
- RegionNode2D a = tree.getRoot();
- RegionNode2D b = a.getMinus();
- RegionNode2D c = a.getPlus();
+ final RegionNode2D a = tree.getRoot();
+ final RegionNode2D b = a.getMinus();
+ final RegionNode2D c = a.getPlus();
nodeNames.put(a, "a");
nodeNames.put(b, "b");
@@ -74,10 +74,10 @@ public final class TopDownBSPTreeConstruction {
tree.insert(Lines.segmentFromPoints(Vector2D.of(1, 0), Vector2D.of(-5, 3), precision));
tree.insert(Lines.segmentFromPoints(Vector2D.of(-5, 3), Vector2D.of(-5, 0), precision));
- RegionNode2D d = b.getMinus();
- RegionNode2D e = b.getPlus();
- RegionNode2D f = d.getMinus();
- RegionNode2D g = d.getPlus();
+ final RegionNode2D d = b.getMinus();
+ final RegionNode2D e = b.getPlus();
+ final RegionNode2D f = d.getMinus();
+ final RegionNode2D g = d.getPlus();
nodeNames.put(d, "d");
nodeNames.put(e, "e");
@@ -85,17 +85,17 @@ public final class TopDownBSPTreeConstruction {
nodeNames.put(g, "g");
svgWriter.write(tree, nodeNames, new File(outputFolder, String.format(OUTPUT_FILE_FORMAT, ++cutCount)));
- LinePath path = LinePath.fromVertices(Arrays.asList(
+ final LinePath path = LinePath.fromVertices(Arrays.asList(
Vector2D.of(-1, 0),
Vector2D.of(5, -3),
Vector2D.of(5, 0),
Vector2D.of(1, 0)), precision);
tree.insert(path);
- RegionNode2D h = c.getMinus();
- RegionNode2D i = c.getPlus();
- RegionNode2D j = h.getMinus();
- RegionNode2D k = h.getPlus();
+ final RegionNode2D h = c.getMinus();
+ final RegionNode2D i = c.getPlus();
+ final RegionNode2D j = h.getMinus();
+ final RegionNode2D k = h.getPlus();
nodeNames.put(h, "h");
nodeNames.put(i, "i");
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java
index f63a29f..f1313b5 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java
@@ -215,7 +215,7 @@ public class RegionBSPTree1S extends AbstractRegionBSPTree<Point1S, RegionBSPTre
final int boundaryPairCount = insideBoundaryPairs.size();
// Get the start point for merging intervals together.
- int startOffset = getIntervalStartIndex(insideBoundaryPairs);
+ final int startOffset = getIntervalStartIndex(insideBoundaryPairs);
// Go through the pairs starting at the start offset and create intervals
// for each set of adjacent pairs.