Giter VIP home page Giter VIP logo

3d_viewer's Introduction

3d_viewer's People

Contributors

acardona avatar axtimwalde avatar bene51 avatar ctrueden avatar dscho avatar hinerm avatar iarganda avatar mdoube avatar mhl avatar nickp avatar tinevez avatar tischi avatar tpietzsch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

3d_viewer's Issues

Added images aren't synchronised with the first image

Operating system: Mac 10.11.1
Java 1.8.0_65 (64-bit)
ImageJ 1.50e

I opened two animated gif images in Fiji and used 3D Viewer to display the first image. Then I added the second image to the first image using "add". The second image was added, but when I tried to move the combined image, the second and first image didn't not move together.

Java 3D ERROR : OpenGL 1.2 or better is required (GL_VERSION=1.1)

Several people have now reported the following error:

org.scijava.java3d.IllegalRenderingStateException: Java 3D ERROR : OpenGL 1.2 or better is required (GL_VERSION=1.1)
    at org.scijava.java3d.JoglPipeline.setupCanvasProperties(JoglPipeline.java:8083)
    at org.scijava.java3d.JoglPipeline.createNewContext(JoglPipeline.java:6440)
    at org.scijava.java3d.Canvas3D.createNewContext(Canvas3D.java:4602)
    at org.scijava.java3d.Canvas3D.createNewContext(Canvas3D.java:2376)
    at org.scijava.java3d.Renderer.doWork(Renderer.java:881)
    at org.scijava.java3d.J3dThread.run(J3dThread.java:271)

These reports indicate new systems with new high-quality graphics cards, so it seems unlikely that the version of OpenGL is actually that old. Need to investigate...

False deprecation warning for Image3DUniverse.addContentaddContent(ImagePlus image, Color3f color, String name, int thresh, boolean[] channels, int resf, int type)

The developer is falsely warned by the compiler about deprecation of the addContent() method. That's because the method right above it in the source is the one being deprecated, but also commented out (i.e. createAndAddOctree()), so the @deprecated annotation tag is being transferred onto addContent() at line 865 of the Image3DUniverse class.

Proposed solution: Comment out any such loose tags.

3D Viewer hangs Fiji when rendering an empty stack

From @mhl:

You can reproduce this with the following steps:

  • Go to File -> New and create an 8-bit stack, 200x200x10, filled with black
  • Run Plugins -> 3D Viewer, and leave the options at their defaults

Then I see about 6 CPUs maxing out for about 20 seconds, then just a single CPU is at 100% and Fiji becomes unresponsive, and I have to kill it with SIGKILL. Adding a single blob of non-zero pixels in the image stops this from happening.

It's useful to be able to test with empty images sometimes - for example, people often send me .traces files for SNT without the images, so it's easiest to construct an empty image of the right size to work with.

Migrated-From: http://fiji.sc/bugzilla/show_bug.cgi?id=314

reset universe option not available

Current user guide does not match anymore the plugin. Reset universe coordinate is not available in settings or anywhere in the menu anymore. Overall, quite promising but also unusable as of now.

3D [dev] 1.6.0-scijava-2-pre11-daily-experimental daily Error message

Hi @ctrueden

Received the following error while trying to run 3D Viewer on a new AIO Desktop:

3D [dev] 1.6.0-scijava-2-pre11-daily-experimental daily

Error

I have read the previous Github entries concerning this from past years however at the time it did not seem to prevent 3D from running.

Latest version of Fij/ImageJ being used. All updates installed.

3D Viewer and related plugins work fine on my two other computers (both with dedicated nvidia GPUs). New desktop is running a i7-9700 with Intel integrated graphics (Uhd 630 driver).

Do you have any information or fixes concerning this error message?

Many Thanks,

Richard

Segfault on Ubuntu 17.10

As soon as the plugin attempts to create a 3D viewer window, the JVM crashes with

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
3D [dev] 1.6.0-scijava-2-pre11-daily-experimental daily

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fcd8a239f88, pid=25237, tid=140519520167680
#
# JRE version: Java(TM) SE Runtime Environment (8.0_66-b17) (build 1.8.0_66-b17)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.66-b17 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libawt_xawt.so+0x41f88]  ReadRegionsInList+0x3b8
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/saalfeld/hs_err_pid25237.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Aborted (core dumped)

Spurious first slice in 360 degree rotation

From Gabriel Landini:

The 360 degree rotation (which is a superb function to create rotating anaglyphs) creates 180 slices at incremental angles. The first and second slices seem to be the same except the first one has the shadow of where the menu was when launched the command, so this slice (number 1) should perhaps be deleted.

Migrated-From: http://fiji.sc/bugzilla/show_bug.cgi?id=143

Remove System.out.println calls

I am using this in a command line app and its spitting out System.out.println which are quite distracting and not part of my application logging.

I will submit a PR to remove.

3D Viewer overhaul

<edit: We have moved beyond most of these issues. Look at SciView for updated information>

3D_Viewer is problematic these days, but sometimes still does the job and is a dependency for a number of plugins.

  • ClearVolume is great, but doesn't provide all of the features of 3D_Viewer.
  • Scenery does provide pretty much all of the features necessary for 3D_Viewer.
  • ui-behavior provides input handling.

The idea is to replace the Java3D backend of 3D_Viewer with Scenery to help transition to a more modern 3D rendering system. In doing so, a number of features that have been built directly into 3D_Viewer can be made into core code:

Dealing with 3D data structures:

  • Make a core mesh data structure based on imglib2-roi
  • Move mesh data structures to imagej-common (inherit from imglib2-roi mesh)
  • Move STL & Obj reading/writing to... imagej-common

Rendering and UI for 3D:

  • Fonts/text rendering
  • 3D object picking
  • Context menus for objects
  • Adding primitive objects to scene (landmarks/annotation)
  • Adjusting object rendering properties (transparency/coloring/etc.)
  • Bounding box/coordinate system indicator

Where the action is:

Relevant Peoples:
@Dietz @tpietzsch @skalarproduktraum @ctrueden @rimadoma

Java 1.6.0 pop up

Hi @ctrueden,

I have two questions:

  1. Is it possible to suppress the Console popping up with the message: 3D [dev] 1.6.0-scijava-2-pre11-daily-experimental daily. It is a bit disturbing for some applications...
  2. Could you point me to the place in the code where the Java 1.6 is launched? I am just very curious...are you launching a second JVM or how does that work?

Resizing 3D Viewer window can throw an exception

When using the Java-8 update site, resizing the 3D Viewer window leads to:

com.jogamp.opengl.GLException: detachAllImpl failed: FBO implementation fault, FBO[name r/w 1/1, init true, bound true, size 814x830, samples 0/8, modified true/true, depth RenderAttachment[type DEPTH, format 0x81a5, samples 0, 814x830, name 0xffffffff, obj 0x631efb05], stencil null, colorbuffer attachments: 1/8, with 1 textures: [TextureAttachment[type COLOR_TEXTURE, target GL_TEXTURE_2D, level 0, format 0x8051, 814x830, border 0, dataFormat 0x1907, dataType 0x1401; min/mag 0x2600/0x2600, wrap S/T 0x812f/0x812f; name 0xffffffff, obj 0xd24d2a0], null, null, null, null, null, null, null], msaa[null, hasSink false, dirty true], state FBO implementation fault, obj 0x48049414]
    at com.jogamp.opengl.FBObject.detachAllImpl(FBObject.java:2198)
    at com.jogamp.opengl.FBObject.reset(FBObject.java:1139)
    at org.scijava.java3d.JoglPipeline.resizeOffscreenLayer(JoglPipeline.java:6290)
    at org.scijava.java3d.Canvas3D.setViewport(Canvas3D.java:4864)
    at org.scijava.java3d.Renderer.doWork(Renderer.java:993)
    at org.scijava.java3d.J3dThread.run(J3dThread.java:271)

At least, I am able to reproduce consistently on my system using the T1 Head sample:

OS X 10.11.1 El Capitan
Model Name: MacBook Pro
Model Identifier: MacBookPro11,5
Processor Name: Intel Core i7
Processor Speed: 2.5 GHz

Both Java versions 1.7.0_80 and 1.8.0_66 exhibit the issue. So it is probably a bug in Java 3D 1.6 and/or JOGL.

I tried to create an MCVE based on the "Test Java3D" plugin from VIB, but was unable to reproduce the issue with a simple scene.

See also this thread on the ImageJ mailing list.

Licensing Unclear

Hi, I am interested in using a portion of this project, specifically the STLLoader class, but am not sure what license is it under? I tried searching for 3D_Viewer project on this page but couldn't find it:

https://github.com/fiji/fiji/blob/master/LICENSES

If possible could a license file be added to this project to make it clear?
Thanks

Empty canvas and GLException with Java 8 on Windows

On Windows 7, running an up-to-date Fiji with Java 1.8.0_66 and the Java8 update site enabled, I get an empty gray canvas in the 3D viewer (when trying to display e.g. the Bat Cochlea Volume sample image), and the following stack trace is displayed in the console window:

3D [dev] 1.6.0-scijava-2-pre11-daily-experimental daily

com.jogamp.opengl.GLException: J3D-Renderer-1: createImpl ctx !ARB but ARB is used, profile > GL2 requested (OpenGL >= 3.1). Requested: GLProfile[GL4bc/GL4bc.hw], current: 1.1 (Compat profile, compat[], hardware) - 1.1.0
    at jogamp.opengl.windows.wgl.WindowsWGLContext.createImpl(WindowsWGLContext.java:404)
    at jogamp.opengl.GLContextImpl.makeCurrentWithinLock(GLContextImpl.java:765)
    at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:648)
    at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:586)
    at org.scijava.java3d.JoglPipeline.createNewContext(JoglPipeline.java:6412)
    at org.scijava.java3d.Canvas3D.createNewContext(Canvas3D.java:4602)
    at org.scijava.java3d.Canvas3D.createNewContext(Canvas3D.java:2376)
    at org.scijava.java3d.Renderer.doWork(Renderer.java:881)
    at org.scijava.java3d.J3dThread.run(J3dThread.java:271)
Exception occurred in RenderingErrorListener:
java.lang.RuntimeException
    at ij3d.ImageWindow3D$ErrorListener.errorOccurred(ImageWindow3D.java:330)
    at org.scijava.java3d.VirtualUniverse.notifyRenderingErrorListeners(VirtualUniverse.java:1198)
    at org.scijava.java3d.NotificationThread.processNotifications(NotificationThread.java:86)
    at org.scijava.java3d.NotificationThread.run(NotificationThread.java:104)

This might be related to the graphics card, as I'm not seeing this problem on a different machine with different hardware. The 3D viewer used to work on that machine when running Java6, so it would be great to know if this can be sorted on Java8.

Polygon mesh transparency requires backface cull

Note: This issue is a placeholder for notes about the transparency support within the 3D Viewer. It was started after a discussion between @aherbert and @ctrueden

When rendering a customnode.CustomMesh the default appearance set in org.scijava.java3d.PolygonAttributes are setBackFaceNormalFlip(true) and setCullFace(PolygonAttributes.CULL_NONE). This is a change from the java3d default which will disable backface normal flip and use PolygonAttributes.CULL_BACK. This means that transparent mesh polygons appear wrong.

In addition transparent objects only appear transparent to objects that have already been rendered. This is a java3d default for speed optimisation. It can be corrected in two ways which will be described below.

This java plugin demo demonstrates this:

import java.util.List;

import org.scijava.java3d.PolygonAttributes;
import org.scijava.vecmath.Color3f;
import org.scijava.vecmath.Point3f;

import customnode.CustomMesh;
import customnode.CustomTriangleMesh;
import customnode.MeshMaker;
import ij.gui.GUI;
import ij.plugin.PlugIn;
import ij3d.DefaultUniverse;
import ij3d.Image3DUniverse;
import ij3d.ImageWindow3D;

public class Transparency_Demo implements PlugIn
{
	@Override
	public void run(String arg)
	{
		createUniverse("Transparency_Demo Backface Normal Flip (Default)", false, false);
		createUniverse("Transparency_Demo No Backface Normal Flip", true, false);
		createUniverse("Transparency_Demo No Backface Normal Flip + Backface Cull", true, true);
	}

	private void createUniverse(String title, boolean disableBackfaceNormalFlip, boolean backfaceCull)
	{
		Image3DUniverse univ = new Image3DUniverse();
		univ.showAttribute(DefaultUniverse.ATTRIBUTE_SCALEBAR, false);
		univ.show();
		ImageWindow3D w = univ.getWindow();
		GUI.center(w);
		w.setTitle(title);

		addPoint(univ, disableBackfaceNormalFlip, backfaceCull, -1.5f, 0, 0, new Color3f(1, 0, 0));
		addPoint(univ, disableBackfaceNormalFlip, backfaceCull, 1.5f, 0, 0, new Color3f(0, 1, 0));
		addPoint(univ, disableBackfaceNormalFlip, backfaceCull, -1.8f, -0.3f, -1.5f, new Color3f(0, 0, 1));
		univ.sync(true);
	}

	private void addPoint(Image3DUniverse univ, boolean disableBackfaceNormalFlip, boolean backfaceCull, float x,
			float y, float z, Color3f c)
	{
		List<Point3f> points = MeshMaker.createIcosahedron(0, 1f);
		for (Point3f p : points)
		{
			p.x += x;
			p.y += y;
			p.z += z;
		}
		CustomMesh mesh = new CustomTriangleMesh(points, c, 0.5f);
		mesh.getAppearance().getPolygonAttributes().setBackFaceNormalFlip(!disableBackfaceNormalFlip);
		if (backfaceCull)
			mesh.getAppearance().getPolygonAttributes().setCullFace(PolygonAttributes.CULL_BACK);
		univ.addCustomMesh(mesh, "Point " + x);
	}
}

The default mode is shown below:

default

Backface normal flip is disabled:

no backface normal flip

Here the rendering improves as the icosahedron has been constructed with triangle facets that have normals that all face outwards from the center. Note that due to the lighting model under some orientations it is still possible to see through a polygon to the backface. This is best viewed by running the demo.

Backface normal flip is disabled and the culling is set to back face then the rendering is correct:

no backface normal flip backface cull

Order Dependent Transparency

However note that objects have been added to the scene as Red, Green then Blue. It is possible to view through the Blue object to both Red and Green; through the Green object to Red but not Blue; and impossible to view through the Red object.

There are two solutions to this transparency issue:

  1. Sort all the objects before placing them on the scene from the viewpoint position. If the viewpoint changes then the sort must be redone and the objects reordered.
  2. Use the java3d support for sorting transparent objects.

Option 1

Sorting the objects can be done using their depth to the current view point. This can be obtained as:

Transform3D ipToVWorld = new Transform3D();
univ.getCanvas().getImagePlateToVworld(ipToVWorld);

Point3d eyePtInVWorld = new Point3d();
univ.getCanvas().getCenterEyeInImagePlate(eyePtInVWorld);
ipToVWorld.transform(eyePtInVWorld);

All objects (e.g. using the object centre) can compute their distance to the eye point. Note: This can only be done if each object has no additional transformations applied beyond the virtual world, for example in the ImageJ3DViewer it is possible to rotate a CustomContent relative to the universe if the content transformation is not locked. If this is the case then the local transformation of objects must also be considered.

Once the distance to the eye point is known the rendering order can be updated. For any CustomMesh constructed using multiple objects this would involve reordering the coordinates of the mesh. For several CustomMesh objects added to the same scene then there is no simple solution as each mesh is added as separate content and the rendering order cannot be changed.

Option 2

Enabling the java3d support requires the view is configured:

View view = univ.getViewer().getView();
view.setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY);

Java3d will then sort individual geometries of each Shape3D within the scene graph.

By default this sorts objects using the centre-of-mass of their vertices, which is computed and cached. Optionally the runtime parameter -Dj3d.sortShape3DBounds=true allows "the bounds of the Shape3D node [to] be used in place of the computed GeometryArray bounds for transparency sorting for those Shape3D nodes whose boundsAutoCompute attribute is set to false" (see org.scijava.java3d.MasterControl.sortShape3DBounds). This allows better performance when the bounds of a shape can be computed at construction.

The documentation states that "Note that this policy will not split geometry into smaller pieces, so intersecting or intertwined objects may not be sorted correctly." Thus this option is only useful for objects that are roughly spherical if overlapping.

Having tried to use this solution within the ImageJ3DViewer I found it did not work. This is because the sorting is only applied to shapes that are not part of an ordered group (which has a prescribed rendering order), or any part of the graph below the ordered group. The default ij3d.ContentInstant that is added to the scene for all content uses an org.scijava.java3d.OrderedGroup to list the content node; the bounding box of the content; the coordinate system; and point list. Thus the order is fixed for content below this in the scene graph preventing dynamic sorting.

This has been fixed by using a CustomContentInstant that uses a org.scijava.java3d.Group to list the contents. The content node can then be constructed as a collection of org.scijava.java3d.Shape3D objects added to a org.scijava.java3d.Group. This can be placed onto the scene graph and sorted dynamically by the java3d framework.

Application

This is used to display super-resolution microscopy images within the 3D viewer. The super-resolution image is a results list of XYZ points. Each XYZ point must be drawn using a shape to show an image. Additional information about the points may be known, for example the precision of the XYZ locations. This data can be used to change the properties of the shape (e.g. size, colour, transparency).

The example below shows a dynamically rendered image of microtubules:

microtubules3d

The localisations have been rendered using per localisation size dependent on the XY precision and the transparency set at 30%. Additionally per-item transparency is set using the localisation precision, hence larger objects that are more transparent have poorer precision. Due to the use of transparency the regions that are dense with localisations appear more saturated. Thus the microtubules can be seen to run parallel to each other. Note: These microtubules are on top of each other in the Z-axis and the z-resolution is poor.

A close up with high resolution spheres demonstrates the value of transparency:

microtubules3d_hr

The same microtubules can be rendered as a 2D image using circles:

microtubules2d

Again the localisations have been rendered using per localisation size dependent on the XY precision and the transparency set at 80%. Additionally per-item transparency is set using the localisation precision, hence larger objects that are more transparent have poorer precision. A random dither is applied to the z-component so that overlapping objects combine via transparency to be more opaque. In this case the two microtubules can be seen to be parallel and approximately on-top of each other. Low precision results (large circles) are far away from the microtubules.

The dynamic sort performed by java3d is computationally expensive. The framework maintains a list of all transparent content within the scene, and caches the object centre. If the eye point is moved then the centre of each object is transformed back from the relative transformation within the scene graph (virtual world coordinates) to the image plate world coordinates. These are then compared to the eye point to get a distance. This requires a transformation per object but allows support for objects that are positioned using transformations.

Note that this is different to the suggested implementation above for option 1 which is to transform the eye point to the virtual world, requiring only one transformation for all objects. This is only applicable if all the objects have the same relative transformation within the scene graph, i.e. the actual coordinates of each object are different (and not controlled by transformations).

The ordered list of transparent objects is then updated using the new distances before rendering. This happens for each render frame.

Performance

I have found that the impact on rendering performance is noticeable when approximately 20,000 transparent objects are within the scene. Below this is is possible to move the view without any appreciable effect, allowing full transparency support to be used to view small super-resolution datasets.

3D viewer under Matlab 2013b & 2014a

From @tinevez:

It is not possible to run the 3D viewer from MATLAB anymore.

The demo posted on the MATLAB FEX (see link) hooks forever when trying to instantiate the 3D universe. This most likely originates from MATLAB itself rather than from a Fiji component.

I copy below the very detailed report from Eric Siggia (thanks to him) that thoroughly investigated the issue.

I am on a Mac 10.9.2, using MATLAB 2013b, I downloaded Fiji yesterday, and checked no further updates needed.
I worked though the file Matlab3DViewerIntroduction and everything looks fine including…

InstallJava3D
Testing if Java3D is already installed...
Java3D is already installed.
Installed version is 1.5.
This is good enough, you have nothing to do.
Exiting.

I can run the demo at http://fiji.sc/Miji eg

MIJ.run('Embryos (42K)’);

etc

and all looks OK. I can open the 3D viewer directly via Fiji or ImageJ and it rotates normally.

However the demo Matlab3DViewerDemo_1.m hangs MATLAB at the command (with ‘busy’ on command window)…

universe = ij3d.Image3DUniverse();

and I have to force quit MATLAB to exit.

This error was encountered before by Ran Shadmi and your fix was an update of Fiji, but I am updated…(and have opened and closed all apps numerous times)

scripts> pwd
/Applications/FIJI.app/scripts
scripts> ls
InstallJava3D.m           Matlab3DViewerIntroduction.m
IsJava3DInstalled.m       Miji.m
Matlab3DViewerDemo_1.m        Miji_Test.m
Matlab3DViewerDemo_2.m        bfopen.m
Matlab3DViewerDemo_3.m        importTrackMateTracks.m

On the same MAC I have MATLAB 2010a installed and I get the error noted in Dec 2011 by S Mehta, which is a similar issue.

I also tried MATLAB 2014a on the same Mac and also run into problems on the same command (a query you posted 09 april 2014)

universe = ij3d.Image3DUniverse();

What I do not understand are the following responses…

ij3d
Undefined function or variable 'ij3d'. 
ij3d.setup()
Undefined variable "ij3d" or class "ij3d.setup". 
universe = ij3d.Image3DUniverse();  %%%%%

and then it hangs, but it did not recognize the ij3d class before and I assume this last line is a method in this class

On a different Mac running OS 10.6.8 and MATLAB 2012a everything runs fine!

I need some time to investigate the problem, and will come back to it later.

Migrated-From: http://fiji.sc/bugzilla/show_bug.cgi?id=735

3D Viewer fails when rotating/zooming on a multimesh that has a mesh with a list of zero triangles

From @acardona:

The error happens consistently when one of the meshes added to the MultiMesh is made of a list of empty triangles. Such mesh should either be refused from being added to the MultiMesh, or internally whatever computations go for estimating its bounding box etc. take the fact that it's empty into account.

At the moment, such empty triangle list is, I suspect, resulting into an inappropriate 3D affine transform for the MultiMesh object.

The exception below happens for example when trying to rotate such MultiMesh. And it's very consistent! Happens always.

I have observed these as of 2010-02-08; never before. I must comment here that I think I had never tried yet a CustomMultiMesh with an empty list of triangles inside.

For further proof, I git bisected to the last known version—and that version also failed. Then I realized that it was the CustomMultiMesh that I had crafted the one making the 3D Viewer fail.

Exception occurred during Behavior execution:
javax.media.j3d.BadTransformException: TransformGroup: non-affine transform
    at javax.media.j3d.TransformGroup.setTransform(TransformGroup.java:137)
    at ij3d.behaviors.ViewPlatformTransformer.rotateXY(ViewPlatformTransformer.java:312)
    at ij3d.behaviors.InteractiveViewPlatformTransformer.rotate(InteractiveViewPlatformTransformer.java:61)
    at ij3d.behaviors.InteractiveBehavior.doProcess(InteractiveBehavior.java:281)
    at ij3d.behaviors.InteractiveBehavior.processStimulus(InteractiveBehavior.java:104)
    at javax.media.j3d.BehaviorScheduler.doWork(BehaviorScheduler.java:192)
    at javax.media.j3d.J3dThread.run(J3dThread.java:275)
Information about your version of Java - this information is useful for the Fiji developers:
  os.arch => amd64
  os.name => Linux
  os.version => 2.6.31-19-generic
  java.version => 1.6.0_17
  java.vendor => Sun Microsystems Inc.
  java.runtime.name => Java(TM) SE Runtime Environment
  java.runtime.version => 1.6.0_17-b04
  java.vm.name => Java HotSpot(TM) 64-Bit Server VM
  java.vm.version => 14.3-b01
  java.vm.vendor => Sun Microsystems Inc.
  java.vm.info => mixed mode
  java.awt.graphicsenv => sun.awt.X11GraphicsEnvironment
  java.specification.name => Java Platform API Specification
  java.specification.version => 1.6
  sun.cpu.endian => little
  sun.desktop => gnome
  file.separator => /

Migrated-From: http://fiji.sc/bugzilla/show_bug.cgi?id=138

NegativeArraySizeException for planar meshes

Adding a mesh representing a plane that is aligned to the x, y or z axis can cause NegativeArraySizeException. For example:

Image3DUniverse universe = new Image3DUniverse();

// Mesh of a plane perpendicular to the z axis
float length = 1000;
float zpos = -100;
ArrayList<Point3f> triangles = new ArrayList<>();
triangles.add(new Point3f(-length/2, length/2, zpos));
triangles.add(new Point3f(length/2, length/2, zpos));
triangles.add(new Point3f(-length/2, -length/2, zpos));
triangles.add(new Point3f(length/2, length/2, zpos));
triangles.add(new Point3f(-length/2, -length/2, zpos));
triangles.add(new Point3f(length/2, -length/2, zpos));

CustomTriangleMesh mesh = new CustomTriangleMesh( triangles );
universe.addCustomMesh( mesh, "test-plane" );

universe.show();

results in:

Exception in thread "main" java.lang.NegativeArraySizeException
	at ij3d.shapes.BoundingBox.makeLine(BoundingBox.java:209)
	at ij3d.shapes.BoundingBox.<init>(BoundingBox.java:122)
	at ij3d.shapes.BoundingBox.<init>(BoundingBox.java:54)
	at ij3d.shapes.BoundingBox.<init>(BoundingBox.java:50)
	at ij3d.ContentInstant.display(ContentInstant.java:236)
	at ij3d.ContentCreator.createContent(ContentCreator.java:132)
	at ij3d.ContentCreator.createContent(ContentCreator.java:119)
	at ij3d.Image3DUniverse.createContent(Image3DUniverse.java:1175)
	at ij3d.Image3DUniverse.addCustomMesh(Image3DUniverse.java:1143)
	at develop.MinimalPlaneError.main(MinimalPlaneError.java:27)

This is an issue with drawing the BoundingBox, where it tries to draw lines that have a length of zero. This can result in n inside makeLine becoming negative.

I'd be happy to submit a PR with small changes to BoundingBox to account for this edge case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.