[vtkusers] creating a vtkSpline to transform within a pipeline
David Gobbi
david.gobbi at gmail.com
Mon Sep 17 07:32:43 EDT 2012
You can also look at the vtkThinPlateSplineTransform to see if suits
your needs, it can be used with scattered data points but is much
slower than b-splines.
- David
On Mon, Sep 17, 2012 at 5:25 AM, Anant Vemuri <ajar108 at gmail.com> wrote:
> thank you for the prompt reply. I will check that.
>
>
>
> On Mon, Sep 17, 2012 at 12:57 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>
>> Hi Anant,
>>
>> The example program that you are trying to run was made for VTK 6. If
>> you have a copy of the VTK 5.10 source code, look for
>> Hybrid/Testing/Cxx/TestBSplineWarp.cxx and use that instead.
>>
>> The vtkBSplineTransform doesn't manage missing points. For that,
>> someone would need to add an algorithm to VTK like the one described
>> in this paper:
>>
>> Seungyong Lee, George Wolberg, and Sung Yong Shin,
>> Scattered Data Interpolation with Multilevel B-Splines
>> IEEE Transactions on Visualization and Computer Graphics,
>> Vol. 3, pp. 228-244, 1997
>>
>> - David
>>
>> On Mon, Sep 17, 2012 at 2:03 AM, Anant Vemuri <ajar108 at gmail.com> wrote:
>> > Hi David,
>> >
>> > Thanks... that is exactly what I want to do. I was wondering, how does
>> > it
>> > manage missing points.
>> >
>> > Another thing, I tried to compile the test program on vtk documentation
>> > website
>> >
>> >
>> > http://vtk.org/gitweb?p=VTK.git;a=blob_plain;f=Filters/Hybrid/Testing/Cxx/TestBSplineWarp.cxx
>> >
>> > and I get an error as,
>> >
>> > error: ‘class vtkBSplineTransform’ has no member named
>> > ‘SetCoefficientData’.
>> >
>> > Thanks,
>> > Anant.
>> >
>> >
>> > On Fri, Sep 14, 2012 at 2:37 PM, David Gobbi <david.gobbi at gmail.com>
>> > wrote:
>> >>
>> >> 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