[vtkusers] points render

David E DeMarle dave.demarle at kitware.com
Thu Jun 14 15:43:36 EDT 2012


vtk renders cells not points.

Apply a glyph filter to create a cell for each point and render that.

David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909


On Thu, Jun 14, 2012 at 3:39 PM, Gonzalo Amadio <gonzaloamadio at gmail.com> wrote:
> What is wrong in this example? . I want to render the 2 points but I can't
> see them.
>
>
> #include <vtkVersion.h>
> #include <vtkPolyData.h>
> #include <vtkPointData.h>
> #include <vtkCubeSource.h>
> #include <vtkSmartPointer.h>
> #include <vtkSelectEnclosedPoints.h>
> #include <vtkIntArray.h>
> #include <vtkDataArray.h>
> #include <vtkProperty.h>
> #include <vtkPolyDataMapper.h>
> #include <vtkActor.h>
> #include <vtkRenderWindow.h>
> #include <vtkRenderer.h>
> #include <vtkRenderWindowInteractor.h>
>
>
>
> int main(int, char *argv[])
> {
>
>   double testInside[3] = {0.0, 0.0, 0.0};
>   double testOutside[3] = {0.5, 0.0, 0.0};
>   vtkSmartPointer<vtkPoints> points =
>     vtkSmartPointer<vtkPoints>::New();
>   points->InsertNextPoint(testInside);
>   points->InsertNextPoint(testOutside);
>
>   vtkSmartPointer<vtkPolyData> pointsPolydata =
>     vtkSmartPointer<vtkPolyData>::New();
>   pointsPolydata->SetPoints(points);
>
>  vtkSmartPointer<vtkPolyDataMapper> mapper =
>     vtkSmartPointer<vtkPolyDataMapper>::New();
> #if VTK_MAJOR_VERSION <= 5
>   mapper->SetInputConnection(pointsPolydata->GetProducerPort());
> #else
>   mapper->SetInputData(pointsPolydata);
> #endif
>   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);
>   renderer->AddViewProp(actor);
>   renderer->SetBackground(.1, .3,.2); // Background color dark green
>
>   // Render and interact
>   renderWindow->SetWindowName(argv[0]);
>   renderWindow->Render();
>   renderWindowInteractor->Start();
>
>   return EXIT_SUCCESS;
> }
>
> --
> --------
> Gonzalo Amadio
>
>
> _______________________________________________
> 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
>



More information about the vtkusers mailing list