[vtkusers] Question about using different point sizes

Jong Youl Choi jychoi at indiana.edu
Sun Mar 20 17:38:43 EDT 2011


Hi. I am in difficulty in displaying Glyph2D projected in a 2D space.
Basically I want to display 2D glyphs like an example using
LabeledDataMapper
(http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/LabeledDataMapper)
in which 2D glyphs is displayed in a projected 2D space so that as I
move poly data 2D glyphs will follow them in 2D like shadows.

The following is a snapshot of my codes:

	vtkSmartPointer<vtkPolyData> poly = vtkSmartPointer<vtkPolyData>::New();
        // setup poly
	vtkSmartPointer<vtkRegularPolygonSource> polygonSource =
	vtkSmartPointer<vtkRegularPolygonSource>::New(); //default is 6 sides
	
	vtkSmartPointer<vtkGlyph2D> glyph2D = vtkSmartPointer<vtkGlyph2D>::New();
	glyph2D->SetSource(polygonSource->GetOutput());
	glyph2D->SetInput(poly);
	glyph2D->Update();
	
	vtkSmartPointer<vtkCoordinate> coordinate =
vtkSmartPointer<vtkCoordinate>::New();
	coordinate->SetViewport(renderer);
	coordinate->SetCoordinateSystemToDisplay();
	
	vtkSmartPointer<vtkPolyDataMapper2D> mapper =
vtkSmartPointer<vtkPolyDataMapper2D>::New();
	mapper->SetInput(glyph2D->GetOutput());
	mapper->SetTransformCoordinate(coordinate);
	mapper->Update();
	
	vtkSmartPointer<vtkActor2D> actor = vtkSmartPointer<vtkActor2D>::New();
	actor->SetMapper(mapper);
	
	renderer->AddActor(actor);

The above code doesn't work as I expected. If you can give any advice
or help, I will greatly appreciate it.

Thanks,
Jong

-- 
Jong Youl Choi
Dept. of Computer Science
Indiana University at Bloomington
Homepage: http://www.cs.indiana.edu/~jychoi



More information about the vtkusers mailing list