[vtkusers] vtkVertexGlyphFilter display issue

Alex Southern mrapsouthern at gmail.com
Thu Aug 5 08:35:13 EDT 2010


David,

Here is a CPP file followed by a corresponding CmakeLists.txt file. I 
think the problem is to do with the number of points, when L = 50 W = 30 
H = 40, the point are displayed fine. But in the code L W H are set to L 
= 500 W = 300 H = 400.

I would like to be able to visualize large amounts of points....

//--------- Start of vtkVertexGlyphDemo2.cpp --------------------------
#include <vtkActor.h>
#include <vtkVertexGlyphFilter.h>
#include <vtkPolyData.h>
#include <vtkPointData.h>
#include <vtkProperty.h>
#include <vtkSmartPointer.h>
#include <vtkSelectEnclosedPoints.h>
#include <vtkPolyDataMapper.h>
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"

int main(int , char *[])
{

     int L = 500;
     int W = 300;
     int H = 400;

     // Assign Points to vtkPoints list
     vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();

     for (int k = 0; k < H; k++)
     {
         for (int j = 0; j < W; j++)
         {
             for (int i = 0; i < L; i++)
             {
                 points->InsertNextPoint(i,j,k);
             }
         }
     }

     // Use the points to form poly data
     vtkSmartPointer<vtkPolyData> pointsPolydata = 
vtkSmartPointer<vtkPolyData>::New();
     pointsPolydata->SetPoints(points);

     // Add polydata to input of a vtkVertexGlyphFilter
     vtkSmartPointer<vtkVertexGlyphFilter> vertexGlyphFilter = 
vtkSmartPointer<vtkVertexGlyphFilter>::New();
     vertexGlyphFilter->AddInput(pointsPolydata);
     vertexGlyphFilter->Update();

     vtkPolyData* vertexPolyData = vertexGlyphFilter->GetOutput();

     vtkSmartPointer<vtkPolyDataMapper> meshMapper = 
vtkSmartPointer<vtkPolyDataMapper>::New();
     meshMapper->SetInputConnection(vertexGlyphFilter->GetOutputPort());

     // Add Filtered PolyData to Actor
     vtkSmartPointer<vtkActor> meshActor = vtkSmartPointer<vtkActor>::New();
     meshActor->SetMapper(meshMapper);
     meshActor->GetProperty()->SetPointSize(2);

     // Make Render Window, Renderer and Interactor
     vtkSmartPointer<vtkRenderer> ren1 = 
vtkSmartPointer<vtkRenderer>::New();
     vtkSmartPointer<vtkRenderWindow> renderWindow = 
vtkSmartPointer<vtkRenderWindow>::New();
     renderWindow->AddRenderer(ren1);
     vtkSmartPointer<vtkRenderWindowInteractor> iren = 
vtkSmartPointer<vtkRenderWindowInteractor>::New();
     iren->SetRenderWindow(renderWindow);

     ren1->AddActor(meshActor);

     renderWindow->Render();
     iren->Start();
}
//--------- End of vtkVertexGlyphDemo2.cpp --------------------------


cmake_minimum_required(VERSION 2.6)
PROJECT(VertexGlyphFilter2)

FIND_PACKAGE(VTK REQUIRED)
INCLUDE(${VTK_USE_FILE})

ADD_EXECUTABLE(VertexGlyphFilter2 vtkVertexGlyphDemo2.cpp)
TARGET_LINK_LIBRARIES(VertexGlyphFilter2 vtkHybrid)


On 5.8.2010 15:09, David Doria wrote:
> On Thu, Aug 5, 2010 at 8:03 AM, Alex Southern<mrapsouthern at gmail.com>  wrote:
>    
>> David,
>>
>> Yes this example works fine for me, but my own does not as yet...
>>
>> Thanks
>> Alex
>>
>> On 5.8.2010 14:44, David Doria wrote:
>>      
>>> On Thu, Aug 5, 2010 at 7:25 AM, Alex Southern<mrapsouthern at gmail.com>
>>>   wrote:
>>>
>>>        
>>>> Hi,
>>>>
>>>> Im trying to display a very large number of points, except for dome reson
>>>> the points are not visible, can somebody help me with this?
>>>>
>>>> double dx = some number;
>>>>
>>>> // Assign Points to vtkPoints list
>>>>     vtkSmartPointer<vtkPoints>    points =
>>>> vtkSmartPointer<vtkPoints>::New();
>>>>
>>>>     for (int k = 0; k<    H; k++)
>>>>     {
>>>>         for (int j = 0; j<    W; j++)
>>>>         {
>>>>             for (int i = 0; i<    L; i++)
>>>>             {
>>>>                 points->InsertNextPoint((i*dx),(j*dx),(k*dx));
>>>>             }
>>>>         }
>>>>     }
>>>>
>>>>     // Use the points to form poly data
>>>>     vtkSmartPointer<vtkPolyData>    pointsPolydata =
>>>> vtkSmartPointer<vtkPolyData>::New();
>>>>     pointsPolydata->SetPoints(points);
>>>>
>>>>     vtkSmartPointer<vtkVertexGlyphFilter>    vertexGlyphFilter =
>>>> vtkSmartPointer<vtkVertexGlyphFilter>::New();
>>>>     vertexGlyphFilter->AddInput(pointsPolydata);
>>>>     vertexGlyphFilter->Update();
>>>>
>>>>     vtkPolyData* vertexPolyData = vertexGlyphFilter->GetOutput();
>>>>
>>>>     vtkSmartPointer<vtkPolyDataMapper>    meshMapper =
>>>> vtkSmartPointer<vtkPolyDataMapper>::New();
>>>>     meshMapper->SetInput(vertexPolyData);
>>>>
>>>>     vtkSmartPointer<vtkActor>    meshActor =
>>>> vtkSmartPointer<vtkActor>::New();
>>>>     meshActor->SetMapper(meshMapper);
>>>>
>>>>      // The renderer and interactor have been setup correctly
>>>> elsewhere....
>>>>     ren1->AddActor(meshActor);
>>>>     iren->Render();
>>>>
>>>>          
>>> Just as another data point - does this example work properly for you?
>>>
>>> http://www.vtk.org/Wiki/VTK/Examples/Filters/vtkVertexGlyphFilter
>>>
>>> Thanks,
>>>
>>> David
>>>        
> Can you send us a brief but complete/compilable version of your code
> which does not work?
>
> Thanks,
>
> David
>    




More information about the vtkusers mailing list