Search in sources :

Example 1 with OrderedItemGeometryGroup

use of uk.ac.sussex.gdsc.smlm.ij.ij3d.OrderedItemGeometryGroup in project GDSC-SMLM by aherbert.

the class ImageJ3DResultsViewer method createItemGroup.

private static ItemGeometryGroup createItemGroup(final ImageJ3DResultsViewerSettings.Builder settings, final Point3f[] sphereSize, final LocalList<Point3f> points, float[] alpha, float transparency, Color3f[] colors) {
    final Rendering rendering = Rendering.forNumber(settings.getRendering());
    // All objects have colour using the appearance not per vertex colours.
    // The exception is points which do not support colour from appearance.
    final int colorDepth = (rendering == Rendering.POINT) ? 4 : 0;
    final Shape3D shape = Shape3DHelper.createShape(rendering, colorDepth);
    // Use max so that points get a value of 1
    final int triangles = Math.max(Shape3DHelper.getNumberOfTriangles(rendering), 1);
    final GeometryArray ga = (GeometryArray) shape.getGeometry();
    final long size = (long) points.size() * triangles;
    if (size > 10000000L) {
        final String name = (rendering == Rendering.POINT) ? "points" : "triangles";
        final ExtendedGenericDialog egd = new ExtendedGenericDialog(TITLE);
        egd.addMessage("The results will generate a large dataset of " + size + " " + name + ".\nThis may take a long time to render and may run out of memory.");
        egd.setOKLabel("Continue");
        egd.showDialog();
        if (egd.wasCanceled()) {
            return null;
        }
    }
    final Appearance appearance = shape.getAppearance();
    final TransparencyAttributes ta = new TransparencyAttributes();
    ta.setTransparency(transparency);
    ta.setTransparencyMode((transparency == 0) ? TransparencyAttributes.NONE : TransparencyAttributes.FASTEST);
    appearance.setTransparencyAttributes(ta);
    if (rendering == Rendering.POINT) {
        appearance.getPointAttributes().setPointSize(sphereSize[0].x);
    }
    if (settings.getSupportDynamicTransparency()) {
        return new ItemGeometryGroup(points.toArray(new Point3f[0]), ga, appearance, sphereSize, colors, alpha);
    }
    return new OrderedItemGeometryGroup(points.toArray(new Point3f[0]), ga, appearance, sphereSize, colors, alpha);
}
Also used : ItemGeometryGroup(uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemGeometryGroup) OrderedItemGeometryGroup(uk.ac.sussex.gdsc.smlm.ij.ij3d.OrderedItemGeometryGroup) Point3f(org.scijava.vecmath.Point3f) Rendering(uk.ac.sussex.gdsc.smlm.ij.ij3d.Shape3DHelper.Rendering) OrderedItemGeometryGroup(uk.ac.sussex.gdsc.smlm.ij.ij3d.OrderedItemGeometryGroup) IndexedGeometryArray(org.scijava.java3d.IndexedGeometryArray) GeometryArray(org.scijava.java3d.GeometryArray) Shape3D(org.scijava.java3d.Shape3D) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) TransparencyAttributes(org.scijava.java3d.TransparencyAttributes) Appearance(org.scijava.java3d.Appearance)

Aggregations

Appearance (org.scijava.java3d.Appearance)1 GeometryArray (org.scijava.java3d.GeometryArray)1 IndexedGeometryArray (org.scijava.java3d.IndexedGeometryArray)1 Shape3D (org.scijava.java3d.Shape3D)1 TransparencyAttributes (org.scijava.java3d.TransparencyAttributes)1 Point3f (org.scijava.vecmath.Point3f)1 ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)1 ItemGeometryGroup (uk.ac.sussex.gdsc.smlm.ij.ij3d.ItemGeometryGroup)1 OrderedItemGeometryGroup (uk.ac.sussex.gdsc.smlm.ij.ij3d.OrderedItemGeometryGroup)1 Rendering (uk.ac.sussex.gdsc.smlm.ij.ij3d.Shape3DHelper.Rendering)1