diff options
author | Julien Gouesse <[email protected]> | 2015-11-26 21:52:10 +0100 |
---|---|---|
committer | Julien Gouesse <[email protected]> | 2015-11-26 21:52:10 +0100 |
commit | 9f41bd6a2e753f3df1eb301498467e3e8177a97e (patch) | |
tree | 26140e37f3bdee4dbf77c7867e38a8d45e858753 | |
parent | e884748d57128ba11b4582b66ec6663e0fc0a6bd (diff) | |
parent | 6173452b10842e2f244eea1b44ee1466642b95ce (diff) |
Merge pull request #1 from scijava/geometry-service
Add GeometryService implementation
-rw-r--r-- | src/classes/share/META-INF/services/javax.media.j3d.GeometryService | 1 | ||||
-rw-r--r-- | src/classes/share/com/sun/j3d/utils/geometry/GeometryServiceImpl.java | 38 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/classes/share/META-INF/services/javax.media.j3d.GeometryService b/src/classes/share/META-INF/services/javax.media.j3d.GeometryService new file mode 100644 index 0000000..fc954bc --- /dev/null +++ b/src/classes/share/META-INF/services/javax.media.j3d.GeometryService @@ -0,0 +1 @@ +com.sun.j3d.utils.geometry.GeometryServiceImpl diff --git a/src/classes/share/com/sun/j3d/utils/geometry/GeometryServiceImpl.java b/src/classes/share/com/sun/j3d/utils/geometry/GeometryServiceImpl.java new file mode 100644 index 0000000..f3b0dff --- /dev/null +++ b/src/classes/share/com/sun/j3d/utils/geometry/GeometryServiceImpl.java @@ -0,0 +1,38 @@ + +package com.sun.j3d.utils.geometry; + +import java.util.ArrayList; + +import javax.media.j3d.GeometryArray; +import javax.media.j3d.GeometryService; +import javax.vecmath.Point3f; + +/** + * Default implementation of the {@link GeometryService} service interface. + */ +public class GeometryServiceImpl implements GeometryService { + + @Override + public int triangulateIslands(final int[][] islandCounts, + final Point3f[][] outVerts, final int[] contourCounts, + final ArrayList<GeometryArray> triangData) + { + int vertOffset = 0; + final NormalGenerator ng = new NormalGenerator(); + for (int i = 0; i < islandCounts.length; i++) { + contourCounts[0] = islandCounts[i].length; + final GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY); + gi.setCoordinates(outVerts[i]); + gi.setStripCounts(islandCounts[i]); + gi.setContourCounts(contourCounts); + ng.generateNormals(gi); + + final GeometryArray ga = gi.getGeometryArray(false, false, false); + vertOffset += ga.getVertexCount(); + + triangData.add(ga); + } + return vertOffset; + } + +} |