[vtkusers] How to draw a line (in display)
Erkang Cheng
ekyaya at gmail.com
Wed Apr 14 21:37:39 EDT 2010
Hi all:
I have a question about drawing a line.
Actually, I want to draw a line in display window. But when I change these
two points, the line doesn't looks correct.
I follow the example :
//create two points, P0 and P1
double p0[3] = {1.0, 0.0, 0.0};
double p1[3] = {0.0, 1.0, 0.0};
vtkSmartPointer<vtkLineSource> lineSource =
vtkSmartPointer<vtkLineSource>::New();
lineSource->SetPoint1(p0);
lineSource->SetPoint2(p1);
lineSource->Update();
//Create a mapper and actor
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(lineSource->GetOutputPort());
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
//Create a renderer, render window, and interactor
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
//Add the actor to the scene
renderer->AddActor(actor);
//Render and interact
renderWindow->Render();
renderWindowInteractor->Start();
*But, when I change these two points as*
double p0[3] = {10.0, 0.0, 0.0};
double p1[3] = {0.0, 10.0, 0.0};
The line doesn't change.
Could Anyone tell me what's the problem?
I want to draw a line in display coordinate.
Thanks
Best
Erkang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100414/c36b727f/attachment.htm>
More information about the vtkusers
mailing list