Hi all.
I am using VTK 8.2 from a Java application.
I am trying to use JOGL as a mechanism to have VTK render within my Java application, in the effort of having a cross-platform rendering pipeline working also under MacOS (MacOS build will be my next effort ;-)), in addition to under Windows and maybe Linux.
However, as of now, I am testing on Windows. So, my current setup is:
- Windows 10 64-bit
- Java 8
- VTK 8.2, built from source with Java wrapping and JOGL
- JOGAMP v2.3.2
In my application’s code (medical domain), I have a vtkJoglCanvasComponent-derived panel which takes care of rendering some vtkImagePlaneWidgets which reslice a volume coming from a CT or MR scan.
I am successful in having the widgets showing on screen:
However, interaction with this panel seems to be very “slow”, or at least to have a very low refresh rate. In particular, if I drag with my left mouse button on the view, which shall move/rotate the camera, the view updates once every some seconds… Actually, it seems to update as soon as I stop moving the mouse cursor (while still keeping mouse button down). Is there some kind of “lazy repaint timer” or something similar which can be tweaked?
Or what else could cause this “lazy” update/repaint behavior?
There are also some events in my application which causes some “Render()” calls to be invoked on my vtkJoglCanvasComponent-derived panel, and even in this case the repaint is done in an extremely lazy / delayed way. Can you guess why? Any suggestions on what I could try?
A second (and even more “radical”) issue. If on my scene I add an orientation marker widget, then the whole application crashes as soon as I start interacting (i.e., left-dragging) with the scene. Here is the code I use to add my orientation marker widget on my vtkJoglCanvasComponent-derived panel:
protected void buildOrientationMarkerWidget()
{
// Orientation marker
orientMarkerWidget = new vtkOrientationMarkerWidget();orientMarkerCubeProp = new vtkAnnotatedCubeActor(); orientMarkerCubeProp.SetXMinusFaceText("R"); orientMarkerCubeProp.SetXPlusFaceText("L"); orientMarkerCubeProp.SetYMinusFaceText("A"); orientMarkerCubeProp.SetYPlusFaceText("P"); orientMarkerCubeProp.SetZMinusFaceText("I"); orientMarkerCubeProp.SetZPlusFaceText("S"); double[] darkGray = {0.2, 0.2, 0.2}; double[] almostWhite = {0.9, 0.9, 0.9}; orientMarkerCubeProp.GetCubeProperty().SetOpacity(0); // The "embedded" cube shall be transparente orientMarkerCubeProp.GetXPlusFaceProperty().SetColor(darkGray); orientMarkerCubeProp.GetXPlusFaceProperty().SetEdgeColor(darkGray); orientMarkerCubeProp.GetXMinusFaceProperty().SetColor(darkGray); orientMarkerCubeProp.GetXMinusFaceProperty().SetEdgeColor(darkGray); orientMarkerCubeProp.GetYPlusFaceProperty().SetColor(darkGray); orientMarkerCubeProp.GetYPlusFaceProperty().SetEdgeColor(darkGray); orientMarkerCubeProp.GetYMinusFaceProperty().SetColor(darkGray); orientMarkerCubeProp.GetYMinusFaceProperty().SetEdgeColor(darkGray); orientMarkerCubeProp.GetZPlusFaceProperty().SetColor(almostWhite); orientMarkerCubeProp.GetZPlusFaceProperty().SetEdgeColor(almostWhite); orientMarkerCubeProp.GetZPlusFaceProperty().SetEdgeVisibility(0); orientMarkerCubeProp.GetZMinusFaceProperty().SetColor(almostWhite); orientMarkerCubeProp.GetZMinusFaceProperty().SetEdgeColor(almostWhite); orientMarkerCubeProp.GetZMinusFaceProperty().SetEdgeVisibility(0); vtkCubeSource cubeSource = new vtkCubeSource(); cubeSource.Update(); double[] white = {255, 255, 255}; double[] grayCyan = {145, 205, 225}; double[] darkRed = {200, 2, 2}; vtkUnsignedCharArray faceColors = new vtkUnsignedCharArray(); faceColors.SetNumberOfComponents(3); faceColors.InsertNextTuple3(white[0], white[1], white[2]); faceColors.InsertNextTuple3(white[0], white[1], white[2]); faceColors.InsertNextTuple3(grayCyan[0], grayCyan[1], grayCyan[2]); faceColors.InsertNextTuple3(grayCyan[0], grayCyan[1], grayCyan[2]); faceColors.InsertNextTuple3(darkRed[0], darkRed[1], darkRed[2]); faceColors.InsertNextTuple3(darkRed[0], darkRed[1], darkRed[2]); cubeSource.GetOutput().GetCellData().SetScalars(faceColors); cubeSource.Update(); vtkPolyDataMapper cubeMapper = new vtkPolyDataMapper(); cubeMapper.SetInputData(cubeSource.GetOutput()); cubeMapper.Update(); vtkActor cubeActor = new vtkActor(); cubeActor.SetMapper(cubeMapper); vtkPropAssembly propAssembly = new vtkPropAssembly(); propAssembly.AddPart(orientMarkerCubeProp); propAssembly.AddPart(cubeActor); orientMarkerWidget.SetOutlineColor( darkGray[0], darkGray[1], darkGray[2]/*0.9300, 0.5700, 0.1300*/ ); orientMarkerWidget.SetOrientationMarker(propAssembly/*orientMarkerCubeProp*/); orientMarkerWidget.SetInteractor(getRenderWindowInteractor()); orientMarkerWidget.SetViewport(0, 0.4, 0.2, 0.6); orientMarkerWidget.SetEnabled(1); orientMarkerWidget.InteractiveOff();
}
In particular, the initial scene appears correctly. But then, as soon as I start left-dragging on the scene, I get this “debug assertion” (I have built VTK 8.2 in debug mode for now), and the application crashes:
Any idea on what could be causing this? Am I missing to setup something in my code?
An important remark: before switching to JOGL-based rendering, I had implemented exactly the same panel with “direct” rendering from VTK to my AWT panel (through the JAWT interface), and it is working perfectly under Windows. However, I would like to switch to JOGL due to the need to make it work also under MacOS (JAWT-based rendering from VTK won’t work with the current version of JRE / MacOS).
Any feedback will be appreciated.
Thanks and regards,
Marco Sambin