[vtkusers] creating a vtkSpline to transform within a pipeline
David Gobbi
david.gobbi at gmail.com
Fri Sep 14 08:37:08 EDT 2012
Hi Anant,
If you recompute the spline coefficients within the transform's
Update() method, then it should provide the sort of pipeline behavior
that you are looking for. The following paper describes the VTK
transform update mechanism:
http://www.ncbi.nlm.nih.gov/pubmed/12631510
I added a vtkBSplineTransform to VTK 5.10. It might satisfy your
needs, and if not, you might be able to re-use parts of it:
http://hdl.handle.net/10380/3252
- David
On Fri, Sep 14, 2012 at 4:02 AM, Anant Vemuri <ajar108 at gmail.com> wrote:
> 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.
More information about the vtkusers
mailing list