[vtkusers] 3 speed questions

Jonathan Morra jonmorra at gmail.com
Mon Nov 1 21:01:52 EDT 2010


I have three questions regarding speed in VTK with Java
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.

    double[] center = imageViewer.GetImageActor().GetCenter();
    vtkPolyData organData =
ENV.getInstance().getDataManager().getOrganMesh(organ);
    if (organData == null)
        continue;

    vtkPlane cutPlane = new vtkPlane();
    cutPlane.SetOrigin(center);
    switch (orientation) {
        case ORIENTATION_XY:
            cutPlane.SetNormal(0, 0, 1);
            break;
        case ORIENTATION_XZ:
            cutPlane.SetNormal(0, 1, 0);
            break;
        case ORIENTATION_YZ:
            cutPlane.SetNormal(1, 0, 0);
            break;
    }

    vtkCutter cutter = new vtkCutter();
    cutter.SetCutFunction(cutPlane);
    cutter.SetInput(organData);

    vtkPolyDataMapper mapper = new vtkPolyDataMapper();
    mapper.SetInputConnection(cutter.GetOutputPort());
    mapper.ScalarVisibilityOff();
    mapper.Update();

    vtkActor actor = new vtkActor();
    actor.SetMapper(mapper);

 actor.GetProperty().SetColor(ENV.getInstance().getDataManager().getLineColor(organ));
    actor.GetProperty().SetRepresentationToWireframe();

    imageViewer.GetRenderer().AddActor(actor);

>From my analysis, the slowdown does not occur here, but rather in the line
imageViewer.SetSlice(value);
After some more digging, it turns out that the Render method is actually the
method taking the most time to execute.

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.

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

    // For now, we're just initializing the data with
    // the point that was clicked

    vtkPoints points = new vtkPoints();

    // The initial data MUST be at least a "line"
    // by giving the same point twice we are effictively creating a zero
    // length line
    points.InsertNextPoint(lastContourControlPoint);
    points.InsertNextPoint(lastContourControlPoint);
    vtkPolyData initialData = new vtkPolyData();
    initialData.SetPoints(points);
    contourWidget.Initialize(initialData, 0);
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.

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?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101101/916dd276/attachment.htm>


More information about the vtkusers mailing list