[vtkusers] more local control for thin plate transform

Tim Hutton T.Hutton at eastman.ucl.ac.uk
Mon Mar 1 07:24:39 EST 2004


Hi Dmitry,

TPS warps are global by their nature. Perhaps with a different kernel you 
can obtain a more local warp.

Otherwise, consider using vtkGridTransform or similar?

tim

At 18:15 01/03/2004 +0700, mail.ru wrote:
>Hi All!
>
>There is shape (initially - sphere).
>Then I add a point and I need to deform initial shape in such way, that
>new shape interpolates new point.
>I try to use vtkThinPlateSplineTransform class, passing shape as input
>data and some points on shape surface as source landmark and the
>_same_ points plus a new point as target landmark -
>-----------code-----------
>/* auto_vtk - si simple wrapper like std::auto_ptr */
>
>/* initial shape - sphere */
>auto_vtk<vtkPolyData> sphere_out = create_sphere(point_type(0., 0., 0.), .5);
>_ASSERTE(sphere_out);
>
>/* cut function */
>auto_vtk<vtkPlane> plane = vtkPlane::New();
>plane->SetOrigin(.0, .0, .0);
>/* noraml - vector from center to the new point */
>plane->SetNormal(normal);
>
>/* find intersection sphere and plane (or other implicite function) -
>get points on sphere surface */
>auto_vtk<vtkPolyData> int_data = get_intersection(sphere_out, plane);
>_ASSERTE(int_data);
>
>/* mask unnecessary points to reduce landmark count */
>auto_vtk<vtkMaskPoints> mask_points = vtkMaskPoints::New();
>mask_points->SetInput(int_data);
>mask_points->GenerateVerticesOn();
>mask_points->SetOnRatio(3);
>mask_points->Update();
>vtkPolyData* masked_out = mask_points->GetOutput();
>_ASSERTE(masked_out);
>
>vtkPoints* mp = masked_out->GetPoints();
>
>const vtkIdType count = mp->GetNumberOfPoints() + 1;
>
>/* source landmarks */
>auto_vtk<vtkPoints> spoints = vtkPoints::New();
>spoints->SetNumberOfPoints(count);
>for (vtkIdType i = 0; i < count; ++i)
>         spoints->SetPoint(i, mp->GetPoint(i));
>
>/* int_point - point of intersection of shape and line from center of sphere
>and new point */
>spoints->SetPoint(count - 1, int_point);
>
>/* target landmarks */
>auto_vtk<vtkPoints> tpoints = vtkPoints::New();
>tpoints->SetNumberOfPoints(count);
>for (vtkIdType i = 0; i < count; ++i)
>         tpoints->SetPoint(i, mp->GetPoint(i));  //same point as source
>
>/* new_point - a point to "add" to shape */
>tpoints->SetPoint(count - 1, new_point);
>
>auto_vtk<vtkThinPlateSplineTransform> thin_plate = 
>vtkThinPlateSplineTransform::New();
>thin_plate->SetSourceLandmarks(spoints);
>thin_plate->SetTargetLandmarks(tpoints);
>thin_plate->SetBasisToR();
>//thin_plate->SetBasisToR2LogR();
>-----------end of code-----------
>
>than I apply transform to initial shape and get a new, deformed shape.
>(than new shape pass as initial and so on...)
>Problem - result shape is deformed as a whole, but I have to deform
>only part of shape, in such a way that the part "beyond" cutter plane stay
>unchanged! Is there way to do this?
>Maybe I need to pass as source and target landmark additional points
>on surface to prevent deformation of shape at its other part?
>
>[vtk 4.4.0, MSVC 7.1, WinXp SP1]
>
>--
>Best regards,
>Dmitry Guruelv                        mailto: patalog at mail.ru
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: 
><http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers





More information about the vtkusers mailing list