I have three questions regarding speed in VTK with Java<div>1. I have three vtkImageViewer2's showing three different cuts through a 3D volume. I wish to display cuts through a vtkPolyData over 2 of them and have those cuts update as the user moves through the data. When the vtkPolyData is a stack of 2D contours, the speed is totally fine. However, when I take that stack of 2D contours and create a 3D mesh out of it by using a LinearExtruder then ImageStencil then MarchingCubes then Decimation (I do this only once, not on every update). The render time is much slower. Here is a snippet of code showing how I go from a 3D mesh to the appropriate 2D cut for display.</div>
<div><br></div><div> double[] center = imageViewer.GetImageActor().GetCenter();</div><div> vtkPolyData organData = ENV.getInstance().getDataManager().getOrganMesh(organ);</div><div><div> if (organData == null)</div>
<div> continue;</div><div><br></div><div> vtkPlane cutPlane = new vtkPlane();</div><div> cutPlane.SetOrigin(center);</div><div> switch (orientation) {</div><div> case ORIENTATION_XY:</div><div> cutPlane.SetNormal(0, 0, 1);</div>
<div> break;</div><div> case ORIENTATION_XZ:</div><div> cutPlane.SetNormal(0, 1, 0);</div><div> break;</div><div> case ORIENTATION_YZ:</div><div> cutPlane.SetNormal(1, 0, 0);</div>
<div> break;</div><div> }</div><div><br></div><div> vtkCutter cutter = new vtkCutter();</div><div> cutter.SetCutFunction(cutPlane);</div><div> cutter.SetInput(organData);</div><div><br></div><div> vtkPolyDataMapper mapper = new vtkPolyDataMapper();</div>
<div> mapper.SetInputConnection(cutter.GetOutputPort());</div><div> mapper.ScalarVisibilityOff();</div><div> mapper.Update();</div><div><br></div><div> vtkActor actor = new vtkActor();</div><div> actor.SetMapper(mapper);</div>
<div> actor.GetProperty().SetColor(ENV.getInstance().getDataManager().getLineColor(organ));</div><div> actor.GetProperty().SetRepresentationToWireframe();</div><div><br></div><div> imageViewer.GetRenderer().AddActor(actor);</div>
</div><div><br></div><div>From my analysis, the slowdown does not occur here, but rather in the line </div><div>imageViewer.SetSlice(value);</div><div>After some more digging, it turns out that the Render method is actually the method taking the most time to execute.</div>
<div><br></div><div>2. I have 3 vtkImagePlaneWidget's with and I want to show a vtkPolyData with them in the same window. This question is similar to the first in that if I show a vtkPolyData that is a series of 2D contours then the speed is fine, however the render speed is extremely slow if I show a 3D surface. I noticed that the amount of decimation that I do to the surface with vtkDecimatePro does not seem to affect the render speed.</div>
<div><br></div><div>3. An unrelated question. I have a vtkContourWidget that I wish to use live wire with. I have followed the tutorial on vtkDijkstraImageContourLineInterpolator and am able to successfully create the contour widget with live wire interpolation. However, when I first initialize the contour with the following code it is very slow</div>
<div><br></div><div><div> // For now, we're just initializing the data with</div><div> // the point that was clicked</div><div><br></div><div> vtkPoints points = new vtkPoints();</div><div> </div><div>
// The initial data MUST be at least a "line"</div><div> // by giving the same point twice we are effictively creating a zero</div><div> // length line</div><div> points.InsertNextPoint(lastContourControlPoint);</div>
<div> points.InsertNextPoint(lastContourControlPoint);</div><div> vtkPolyData initialData = new vtkPolyData();</div><div> initialData.SetPoints(points);</div><div> contourWidget.Initialize(initialData, 0);</div>
</div><div>The line that is slow is the last line. The weird part is that if I do not use live wire, and just use the default Bezier curve interpolation the initialization is instant.</div><div><br></div><div>In summary, I've been working on these three issues for a few days and can't seem to make any progress in any of them. Does anyone have any suggestions on how to speed things up?</div>
<div><br></div><div>Thanks</div>