[vtkusers] creating a vtkSpline to transform within a pipeline

Anant Vemuri ajar108 at gmail.com
Fri Sep 14 06:02:03 EDT 2012


I am currently creating a spline using vtkSplineFilter. The points in the
spline are changing as new positions for points are generated. However, now
I want to put the position information into a vtkTransform and connect the
Spline being created within a pipeline so that, it gets updated when the
the transform changes.

currently I am doing this whenever I get new positions. Is it possible to
put this in a pipeline so that the points are updated using a vtktransform
when the transform changes. In vtkTransform there is a function called
"MultiplyPoint" and "TransformPoint", however both are not indicated to be
pipelined.

I am curious if anyone has tried to do this, or if anyone has suggestions
on this issue.

myspline is a class containing vtkPoints, vtkPolyLine, vtkPolyData etc.


    //   In the constructor for my spline class
    _points       = vtkSmartPointer< vtkPoints >::New();
    _polyLine     = vtkSmartPointer< vtkPolyLine >::New();
    _cells        = vtkSmartPointer< vtkCellArray >::New();
    _polyData     = vtkSmartPointer< vtkPolyData >::New();
    _splineFilter = vtkSmartPointer< vtkSplineFilter >::New();
    _tubeFilter   = vtkSmartPointer< vtkTubeFilter >::New();

    //   PIPELINE
    _cells->InsertNextCell(_polyLine);
    _polyData->SetPoints(_points);
    _polyData->SetLines(_cells);
    _splinefilter->SetInput( _polyData );
    _splinefilter->SetMaximumNumberOfSubdivisions( 48 );
    _tubeFilter->SetInputConnection( _splineFilter->GetOutputPort());
    _tubeFilter->SetNumberOfSides( 12 );
    _tubeFilter->SetRadius( 5.0 );
    _tubeFilter->SetCapping(true);
    _mapper->SetInputConnection( _tubeFilter->GetOutputPort() );
    _actor->SetMapper(_mapper);
    _actor->GetProperty()->SetLineWidth(4);

    //----------------------------------------------------------------
    // Updating for new vtkpoints

*    // I want to put this part into the pipeline if possible so that
    // i can apply a vtkTransform to lets say the _points and the spline
    // gets updated automatically. The updated _points that I get are*

    // absolute positions so I cannot appl
    splineObj->getPoints()->Reset();
    splineObj->getPolyLine()->GetPointIds()->Reset();
    vtkIdType k = 0;

    // __scanorder contains the order in which the points need to be
put into a spline
    // __positions contains the updated point locations
    for (int j = 0; j < __scanOrder.size(); j++)
    {
         unsigned int __idx = __scanOrder[i][j]-1;
         double &__coord = __positions[__idx]->getCoordinate();

         splineObj->getPoints()->InsertNextPoint(__coord[0],__coord[1],__coord[2]);
         splineObj->getPolyLine()->GetPointIds()->InsertNextId( k );
         k++;
    }
    splineObj->getCellArray()->Reset();
    splineObj->getCellArray()->InsertNextCell(splineObj->getPolyLine());
    splineObj->getPolyData()->Modified();


Thank you,

Anant.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120914/7e5be1cd/attachment.htm>


More information about the vtkusers mailing list