[vtkusers] Create a curvilinear curve

Cory Quammen cquammen at cs.unc.edu
Fri Oct 23 16:13:25 EDT 2009


By curvilinear line, I am guessing you mean a curve interpolated from
a set of points, such as a spline. Here's example code on how to use
the vtkParametricSpline to do this for you:


vtkPoints* points = vtkPoints::New();
points->InsertPointer(0, 20,20,20);
...
vtkParametricSpline* spline = vtkParametricSpline::New();
spline->SetPoints(points);

vtkParametricFunctionSource* source = vtkParametricFunctionSource::New();
source->SetParametricFunction(spline);
source->SetUResolution(100); // Set this to how many line segments you
would like in your poly line. More produces a smoother curve.

// The output of source is a vtkPolyData, so you can use it like:
vtkTubeFilter* tuber = vtkTubeFilter::New();
tubers->SetInputConnection(source->GetOutputPort());


Hope that helps,
Cory

On Fri, Oct 23, 2009 at 11:22 AM, toulgen <toulgen at gmail.com> wrote:
> Hi,
>
>
>
> I have n points:
>
>
>
> -----------------------------------------------------------------------------------------------
>
> vtkPoints* temp_pts = vtkPoints::New(); // XYZ coords
>
>             temp_pts->InsertPoint(0, 20,20,20);
>
>             temp_pts->InsertPoint(1, 20,512,20);
>
>             temp_pts->InsertPoint(2, 512,512,20);
>
>             temp_pts->InsertPoint(3, 512,20,20);
>
>             temp_pts->InsertPoint(4, 20,20,20);
>
>             temp_pts->InsertPoint(0, 20,20,300);
>
>             temp_pts->InsertPoint(1, 20,512,300);
>
>             temp_pts->InsertPoint(2, 512,512,300);
>
>             temp_pts->InsertPoint(3, 512,20,300);
>
> -----------------------------------------------------------------------------------------------
>
>
>
> With the following code I create a polyline:
>
> -----------------------------------------------------------------------------------------------
>
>             // Create the polyline.
>
>             vtkCellArray *lines = vtkCellArray::New();
>
>             int numPoints = temp_pts->GetNumberOfPoints();
>
>             lines->InsertNextCell(numPoints);
>
>             for (int j = 0; j < numPoints; j++)
>
>                         lines->InsertCellPoint(j);
>
>
>
>             vtkPolyData *profileData = vtkPolyData::New();
>
>             profileData->SetPoints((vtkPoints *)(temp_pts));
>
> profileData->SetLines(lines);
>
>
>
>             //profileData->GetPointData()->SetScalars(scalars);
>
>             profileData->BuildLinks();
>
> -----------------------------------------------------------------------------------------------
>
>
>
> I want to create a curvilinear curve with my n points.
>
> It is possible?
>
>
>
> Thx.
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



-- 
Cory Quammen
Center for Computer Integrated Systems for Microscopy and Manipulation (CISMM)
Department of Computer Science
University of North Carolina at Chapel Hill
http://www.cs.unc.edu/~cquammen



More information about the vtkusers mailing list