Hello,

I've created GEOMETRY-115 and an associated PR [1] containing new modules for 
IO functionality. The new modules are

  *   commons-geometry-core-io - Common space-independent interfaces and classes
  *   commons-geometry-euclidean-io - Euclidean IO classes; currently contains 
support for the 3D formats TXT, CSV, and OBJ

The API is based on a core BoundaryIOManager class that delegates to 
BoundaryReadHandler and BoundaryWriteHandler implementations based on the 
requested data format. For Euclidean 3D space, a convenience IO3D class is 
provided with static methods that delegate to a default manager instance. In 
addition to reading and writing the core geometric types for the library 
(ConvexPolygon3D, Triangle3D), the Euclidean module also supports reading and 
writing a FacetDefinition interface, which exposes simple, unvalidated 
geometric data. This is intended for accessing raw (possibly invalid) geometric 
data from files and writing data contained in external data structures (for 
example, a custom facet class). The example below is from the IO3D class 
documentation and demonstrates a read, transform, write operation using streams.

        final Path origFile = tempDir.resolve("orig.obj");
        final Path scaledFile = tempDir.resolve("scaled.csv");

        final DoublePrecisionContext precision = new 
EpsilonDoublePrecisionContext(1e-10);
        final BoundarySource3D src = Parallelepiped.unitCube(precision);

        IO3D.write(src, origFile);

        final AffineTransformMatrix3D transform = 
AffineTransformMatrix3D.createScale(2);

        try (Stream<Triangle3D> stream = IO3D.triangles(origFile, precision)) {
            IO3D.write(stream.map(t -> t.transform(transform)), scaledFile);
        }

Feedback is welcome.

Regards,
Matt J

[1] https://github.com/apache/commons-geometry/pull/130

Reply via email to