[vtkusers] Showing a Line
Luca Pallozzi Lavorante
lplavorante at gmail.com
Tue May 23 17:36:38 EDT 2006
Bob, you must link the line´s mapper to its Actor:
vtkActor *lineASourceActor = vtkActor::New();
lineASourceActor->SetMapper(lineAMapper); // ADD THIS LINE
lineASourceActor->GetProperty()->SetColor(0.0, 0.0, 1.0);
Greetings
Luca
On 5/23/06, Bob Palank <bob at stlcc.org> wrote:
>
> Given the code below, I see the cylinder, but not the line.
> Any idea why ? Shouldn't a line be a visible object like a cylinder?
> If not, then does one display a line object using a cylinder with a small
> diameter ?
> Hopefully there is a simple coding error!
> TIA
> Bob
>
> Code follows:
> #include "vtkCylinderSource.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkActor.h"
> #include "vtkRenderer.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkProperty.h"
> #include "vtkCamera.h"
> #include "vtkLineSource.h"
>
> int main(int argc, char *argv[])
> {
> vtkCylinderSource *cylinder = vtkCylinderSource::New();
> cylinder->SetResolution(18); // eight circumferential facets.
>
>
> vtkPolyDataMapper *cylinderMapper = vtkPolyDataMapper::New();
> cylinderMapper->SetInput(cylinder->GetOutput());
>
>
> vtkActor *cylinderActor = vtkActor::New();
> cylinderActor->SetMapper(cylinderMapper);
> cylinderActor->GetProperty()->SetColor(1.0000, 0.3882, 0.2784);
> cylinderActor->RotateX(30.0);
> cylinderActor->RotateY(-45.0);
>
> // =================================================================
> vtkLineSource *lineASource = vtkLineSource::New();
> lineASource->SetPoint1(-12.0,2.0,2.0);
> lineASource->SetPoint2(12.0,4.0,5.0);
>
> vtkPolyDataMapper *lineAMapper = vtkPolyDataMapper::New();
> lineAMapper->SetInput(lineASource->GetOutput());
>
> vtkActor *lineASourceActor = vtkActor::New();
> lineASourceActor->GetProperty()->SetColor(0.0, 0.0, 1.0);
>
>
>
>
> vtkRenderer *ren1 = vtkRenderer::New();
> vtkRenderWindow *renWin = vtkRenderWindow::New();
> renWin->AddRenderer(ren1);
> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
> iren->SetRenderWindow(renWin);
>
>
> ren1->AddActor(cylinderActor);
> ren1->AddActor(lineASourceActor);
> ren1->SetBackground(0.1, 0.2, 0.4);
> renWin->SetSize(300, 300);
>
> // We'll zoom in a little by accessing the camera and invoking a "Zoom"
> // method on it.
> // ren1->GetActiveCamera()->Zoom(1.5);
> renWin->Render();
>
> // This starts the event loop and as a side effect causes an initial
> render.
> iren->Start();
>
> // Exiting from here, we have to delete all the instances that
> // have been created.
> cylinder->Delete();
> cylinderMapper->Delete();
> cylinderActor->Delete();
> lineASourceActor->Delete();
> lineAMapper->Delete();
> ren1->Delete();
> renWin->Delete();
> iren->Delete();
>
> return 0;
> }
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060523/538d0f2d/attachment.htm>
More information about the vtkusers
mailing list