[vtkusers] Help - Drawing multiple lines.
Amy Squillacote
ahs at cfdrc.com
Tue Jun 17 09:13:08 EDT 2008
Hi Prakash,
Is there any reason you cannot use two instances of vtkLineSource: one
going from (x0, y0) to (x1, y1) and another going from (x2, y2) to (x3,
y3)? vtkLineSource is intended to create a single straight line between
two points.
- Amy
prakash vtk wrote:
> Hi all,
>
> How do we draw multiple lines in vtk?
>
> I want to draw a two lines intersecting perpendicularly at the center
> in my MPR project- like
> x2,y2
> |
> x0,y0--------|--------x1,y1
> |
> x3,y4 Here , y0 and
> y1; x2 and x3 are equal;
>
> I am using vtklinesource in my program.
>
> code snippet:
>
> vtkLineSource *linea=vtkLineSource::New();
> vtkPolyDataMapper2D *mapper=vtkPolyDataMapper2D::New();
> vtkActor2D *actor=vtkActor2D::New();
> vtkRenderer *render=vtkRenderer::New();
> vtkRenderWindow *ventana=vtkRenderWindow::New();
> vtkRenderWindowInteractor *interac=vtkRenderWindowInteractor::New();
>
> vtkInteractorStyleImage *imageStyle = vtkInteractorStyleImage::New();
> linea->SetResolution(4);
> linea->Update();
> linea->GetOutput()->GetPoints()->SetNumberOfPoints(4);
> // Try.
> linea->GetOutput()->GetPoints()->SetPoint(0,150,0,0);
> linea->GetOutput()->GetPoints()->SetPoint(1,150,300,0);
> linea->GetOutput()->GetPoints()->SetPoint(2,0,150,0);
> linea->GetOutput()->GetPoints()->SetPoint(3,300,150,0);
> /* _p
> Dirty fix out put: q|_|_
> int x=1024,y=740; |
> //Line p & q are outside the rendering window.
> linea->GetOutput()->GetPoints()->SetPoint(0,x/2,0,0);
> linea->GetOutput()->GetPoints()->SetPoint(1,x/2,y,0);
> linea->GetOutput()->GetPoints()->SetPoint(2,0,y,0);
> linea->GetOutput()->GetPoints()->SetPoint(3,0,y/2,0);
> linea->GetOutput()->GetPoints()->SetPoint(4,x,y/2,0);*/
>
> mapper->SetInput(linea->GetOutput());
> actor->SetMapper(mapper);
> actor->GetProperty()->SetColor(1.0,0.0,0.0);
>
> render->AddActor2D(actor);
> render->SetBackground(0.1,0.2,0.4);
>
> ventana->AddRenderer(render);
> interac->SetInteractorStyle(imageStyle);
> interac->SetRenderWindow(ventana);
>
> ventana->Render();
>
> interac->Render();
> //cleanup codes..
>
> //Code ends here...
>
> But, using vtklinesource, I am getting continuous line as attached
> snapshot. I have fixed it. but its a dirty fix which I dont want to
> integrate in my project. ( you can see the code for dirty fix and its
> output in attachment).
>
> Is there any way using vtklinesource to get what I expected?
>
> vtklinesource draws a continuous line, I guess. I might be wrong here...
>
> Or Are there any other classes which help me to do this?
> Or how can I get this done in vtk?
>
> Please help me ...
>
> Regards
> Prakash,
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
--
Amy Squillacote Phone: (256) 726-4839
Computer Scientist Fax: (256) 726-4806
CFD Research Corporation Web: http://www.cfdrc.com
215 Wynn Drive, Suite 501
Huntsville, AL 35805
More information about the vtkusers
mailing list