[vtkusers] Visualize vtkPoints?
Ambar C
ambarc at gmail.com
Sat Nov 27 14:08:27 EST 2010
Perfect, thanks David!
On Sat, Nov 27, 2010 at 5:07 AM, David Doria <daviddoria at gmail.com> wrote:
> On Sat, Nov 27, 2010 at 4:05 AM, Ambar C <ambarc at gmail.com> wrote:
>> Hello, I'm trying to visualize a set of points in a vtkPoints object
>> with the following code:
>>
>>
>> vtkPolyData *poly1 = vtkPolyData::New();
>> vtkPolyData *poly2 = vtkPolyData::New();
>> vtkPolyData *poly3 = vtkPolyData::New();
>> vtkPolyData *poly4 = vtkPolyData::New();
>>
>> vtkPoints *points1 = vtkPoints::New();
>>
>>
>> //Inserting points.
>>
>> points1->InsertNextPoint(1, 4, 5);
>> points1->InsertNextPoint(-1, 3, 2);
>> points1->InsertNextPoint(-4, -4, -4);
>>
>> poly1->SetPoints(points1);
>>
>> //Starting the visualization
>> vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
>> mapper->SetInput(poly1);
>>
>> vtkActor *actor = vtkActor::New();
>> actor->SetMapper(mapper);
>> actor->GetProperty()->SetColor(255,0,0);
>>
>> vtkRenderer *ren = vtkRenderer::New();
>> ren->SetBackground( 0.1, 0.2, 0.4 );
>> ren->AddActor(actor);
>>
>> vtkRenderWindow *renWin = vtkRenderWindow::New();
>> renWin->AddRenderer(ren);
>>
>> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>> iren->SetRenderWindow(renWin);
>>
>>
>> However, I just get a blank window. I'm not sure where I'm going
>> wrong. Any suggestions?
>>
>> Cheers.
>
> Take a look at this:
>
> http://www.vtk.org/Wiki/VTK/Tutorials/GeometryTopology
>
> The short story is that your PolyData has no topology. You can use
> VertexGlyphFilter to add a 0D cell (a vertex) to your points.
>
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Filters/vtkVertexGlyphFilter
>
> David
>
More information about the vtkusers
mailing list