[vtkusers] vtkCutter question -- vtk and qt

Shwu Ping Vong svong at email.arc.nasa.gov
Thu Jun 20 19:29:00 EDT 2002


Hi  vtkusers,

I have a question of speed.  Right now I have a qt widget that displays
a cross-section that is the result of a vtkCutter cuts through some 3D
dataset.   The position of the cut plane can be controlled by some qt
sliders which are responsible for getting different values of normals
and origins for a vtkPlane serving as the vtkImplicitFunction for the
vtkCutter.  There is a slight delay between the adjusting of the slider
and the redrawing of the vtk object.  Is there a way to speed it up?  My
co-worker suggested it may have something to do with how the
interpolation scheme works.  So aside from needing suggestion to speed
this up, does anyone know what the interpolation scheme is for vtkCutter
and/or vtkPlane (linear, quadric, cubic, gaussian?)  Can I manually
change something?

Below is the main part of the code.


Thanks,
Shwuping Vong


=========================================================================

       .
       .
       .
        vtkStructuredPointsReader *reader =
vtkStructuredPointsReader::New();
        reader->SetFileName(FILENAME);

        vtkStructuredPoints *data = vtkStructuredPoints::New();
        data = reader->GetOutput();
        data->Update();

        float *bounds;
        bounds = data->GetBounds();
        float xmin = bounds[0];
        float xmax = bounds[1];
        float ymin = bounds[2];
        float ymax = bounds[3];
        float zmin = bounds[4];
        float zmax = bounds[5];

        vtkAxes *axes = vtkAxes::New();
        axes->SetOrigin(xmin, ymin, zmin);
        axes->SetScaleFactor( xmax - xmin );

        vtkTubeFilter *axesTube = vtkTubeFilter::New();
        axesTube->SetInput(axes->GetOutput());
        axesTube->SetRadius(1);
        axesTube->SetNumberOfSides(20);

        vtkPolyDataMapper *axesMapper = vtkPolyDataMapper::New();
        axesMapper ->SetInput (axesTube ->GetOutput());

        axesActor = vtkActor::New();
        axesActor-> SetMapper (axesMapper);

        origin = data->GetCenter();
        origin_x = origin[0];
        origin_y = origin[1];
        origin_z = origin[2];

 planeOrigin_x->valChange(origin_x, xmin, xmax);
 planeOrigin_y->valChange(origin_y, ymin, ymax);
 planeOrigin_z->valChange(origin_z, zmin, zmax);

        plane = vtkPlane::New();
        plane->SetOrigin(origin_x, origin_y, origin_z);

        normal_x = 1;
        normal_y = 0;
        normal_z = 0;
        plane->SetNormal(normal_x, normal_y, normal_z);

 planeNormal_x->valChange(normal_x);
 planeNormal_y->valChange(normal_y);
 planeNormal_z->valChange(normal_z);

        vtkCutter *planeCut = vtkCutter::New();
        planeCut->SetInput(data);
        planeCut->SetCutFunction(plane);

        vtkDataSetMapper *cutMapper = vtkDataSetMapper::New();
        cutMapper->SetInput(planeCut->GetOutput());

        cutActor = vtkActor::New();
        cutActor->SetMapper(cutMapper);

        m_interactor->GetRenderer()->SetBackground( 0.1, 0.2, 0.4);
        m_interactor->GetRenderer()->AddActor(cutActor);
        m_interactor->GetRenderer()->AddActor(axesActor);
        m_interactor->GetRenderer()->ResetCamera();

        connect( planeOrigin_x, SIGNAL(setChange(float) ),
                 this, SLOT(setPlaneOriginXVal(float)) );

        connect( planeOrigin_y, SIGNAL(setChange(float) ),
                 this, SLOT(setPlaneOriginYVal(float)) );

        connect( planeOrigin_z, SIGNAL(setChange(float) ),
                 this, SLOT(setPlaneOriginZVal(float)) );

        connect( planeNormal_x, SIGNAL(setChange(float) ),
                 this, SLOT(setPlaneNormalXVal(float)) );

        connect( planeNormal_y, SIGNAL(setChange(float) ),
                 this, SLOT(setPlaneNormalYVal(float)) );

        connect( planeNormal_z, SIGNAL(setChange(float) ),
                 this, SLOT(setPlaneNormalZVal(float)) );
        .
        .
        .





More information about the vtkusers mailing list