Visualize Very large number of Lines, Points/Spheres with High Performance

Dear Experts,

In my situation, i need visualize very large number of Lines, Points/Spheres, with high performance,
Do you have any suggestions?

My current implementation is put group of lines into polyData, then put polyData into multiBlockData,
in the way i can change color for each group of polyData, but seems the performance is not good…

Any suggestions?

Hi,

have you already checked out vtkGlyph3D? I use it to visualize a large number of spheres and cylinders. You can still change the scale, color and orientation individually.

Thank you Michael for your reply!

Havent tried, but vtkGlyph3D is an arrow, how you make it as spheres an cylinders?

Spheres:

// Array for sphere positions
Points = vtkSmartPointer::New();

// Array for sphere radii
radii = vtkSmartPointer::New();
radii->Initialize();
radii->SetName(“radii”);

// Array for sphere colors
colors = vtkSmartPointer::New();
colors->Initialize();
colors->SetNumberOfComponents(4);
colors->SetName(“colors”);

// Set position, radius and color
for (int i = 0; i < NUMBER OF SPHERES; i++)
{
points->InsertNextPoint(X, Y, Z);
radii->InsertNextValue(RADIUS);
colors->InsertNextTypedTuple(R, G, B, ALPHA);
}

// Create an unstructured grid
grid = vtkSmartPointer::New();
grid->SetPoints(points);
grid->GetPointData()->AddArray(radii);
grid->GetPointData()->AddArray(colors);
grid->GetPointData()->SetActiveScalars(“radii”);

// The points should be visualized as spheres
sourceBall = vtkSmartPointer::New();
sourceBall->SetRadius(1);

// Use VTK’s Glyph3D filter to create a single VTK actor
// which includes multiple spheres at certain locations
source = vtkSmartPointer::New();
source->SetColorModeToColorByScalar();
source->SetSourceConnection(spSourceBall->GetOutputPort());
source->SetInputData(grid);
source->SetScaleModeToScaleByScalar();

// Create VTK actor / mapper
vtkSmartPointer mapper = vtkSmartPointer::New();
mapper->SetInputConnection(spSource->GetOutputPort());
mapper->SetScalarModeToUsePointFieldData();
mapper->SelectColorArray(“colors”);
mapper->SetScalarVisibility(true);
actor = vtkSmartPointer::New();
actor->SetMapper(mapper);

Cylinders:

Just replace the sphere source with a cylinder source.

In order to orient the cylinders, create an additional array like this:

normals = vtkSmartPointer::New();
normals->SetNumberOfComponents(3);

Add the normals to the unstructured grid:
grid->GetPointData()->SetNormals(normals);

Moreover, you call the following method for the cylinder source:
source->SetVectorModeToUseNormal();

I hope this helps.

1 Like

Thank you Michael very much for your sample code!!
I will have a study of this!

Best Regards!