[vtkusers] How to make 2D Glyphs

Isabella Murphy isabella.murphy at yale.edu
Mon Oct 6 14:16:55 EDT 2008


I am with you, vtk has so little documentation, very frustrated with it as a
newbie with vtk and image processing/analysis. Even understanding the example
is hard for me. It will be great if developers can explain the meaning of the
arguments. But I know they are busy, wish they can document more if they have
time.

Isabella Murphy
Quoting Elvis Dowson <elvis.dowson at mac.com>:

> Hi,
>         I figured out why it wasn't working. I didn't specify the  
> point data for drawing the glyphs at.
>
> You know, these things are not really described anywhere, neither in  
> the VTK Book nor in the documentation. If you look at some of the  
> tests or examples, you can see somethings, but you really have no  
> information documented on the minimum number of things that you need  
> to set-up, in order to get it (vtkGlyph2D) to work. Comments,  
> anyone? :-)
>
> Best regards,
>
> Elvis Dowson
>
>
> Working code fragment
>
> 	// Prototype: 2D Glyph Source
> 	// ----------------------------
> 	#ifdef PROTOTYPE_2D_GLYPH_SOURCE
> 	{
> 		// Declare object instance variables
> 		vtkPolyData*		glyphPolyData	= NULL;
> 		vtkPoints*			glyphPoints		= NULL;
> 		vtkGlyphSource2D*	glyphSource		= NULL;
> 		vtkGlyph2D*			glyphDiamond	= NULL;
> 		vtkActor2D*			glyphActor		= NULL;
>
> 		// Generate points for glyphs
> 		glyphPolyData	= vtkPolyData::New();
> 		glyphPoints	= vtkPoints::New();
> 		glyphPolyData->SetPoints(glyphPoints);
> 		glyphPoints->InsertNextPoint(50,50,0);
> 		glyphPoints->InsertNextPoint(100,100,0);
> 		glyphPoints->InsertNextPoint(200,100,0);
>
> 		// Generate 2D Glyph: Diamond
> 		glyphSource = vtkGlyphSource2D::New();
> 		glyphSource->SetGlyphTypeToDiamond();
> 		glyphSource->SetScale(20);
> 		glyphSource->SetCenter(0,0,0);
> 		glyphSource->FilledOff();
> 		glyphSource->CrossOn();
>
> 		glyphDiamond = vtkGlyph2D::New();
> 		glyphDiamond->SetInput(glyphPolyData);
> 		glyphDiamond->SetSource(glyphSource->GetOutput());
> 		glyphDiamond->ScalingOff();
> 		glyphDiamond->OrientOn();
> 		glyphDiamond->SetVectorModeToUseVector();
> 		glyphDiamond->SetColorModeToColorByVector();
>
> 		// Rendering objects.
> 		vtkPolyDataMapper2D* mapperGlyph = NULL;
> 		mapperGlyph = vtkPolyDataMapper2D::New();
> 		mapperGlyph->SetInputConnection(glyphDiamond->GetOutputPort());
> 		mapperGlyph->SetScalarRange(50, 180);
>
> 		// Add actor to renderer
> 		glyphActor = vtkActor2D::New();
> 		glyphActor->SetMapper(mapperGlyph);
>
> 		// Add Actor to renderer
> 		ren->AddActor2D(glyphActor);
> 	}
> 	#endif
>
>
>
>
> On Oct 4, 2008, at 11:22 AM, Elvis Dowson wrote:
>
>> Hi,
>>         I am trying to make a 2D Glyph, but nothing gets displayed  
>> in the following code:
>>
>> 	// Prototype: 2D Glyph Source
>> 	// ----------------------------
>> 	#ifdef PROTOTYPE_2D_GLYPH_SOURCE
>> 	{
>> 		// Declare object instance variables
>> 		vtkGlyphSource2D*	glyphSource	= NULL;
>> 		vtkGlyph2D*		glyphDiamond	= NULL;
>> 		vtkActor2D*		glyphActor	= NULL;
>>
>> 		// Generate 2D Glyph: Diamond
>> 		glyphSource = vtkGlyphSource2D::New();
>> 		glyphSource->SetGlyphTypeToDiamond();
>> 		glyphSource->SetScale(0.2);
>> 		glyphSource->FilledOff();
>>
>> 		glyphDiamond = vtkGlyph2D::New();
>> 		glyphDiamond->SetSource(glyphSource->GetOutput());
>> 		glyphDiamond->ScalingOff();
>> 		glyphDiamond->OrientOn();
>> 		glyphDiamond->SetVectorModeToUseVector();
>> 		glyphDiamond->SetColorModeToColorByVector();
>>
>> 		// Rendering objects.
>> 		vtkPolyDataMapper2D* mapperGlyph = NULL;
>> 		mapperGlyph = vtkPolyDataMapper2D::New();
>> 		mapperGlyph->SetInputConnection(glyphDiamond->GetOutputPort());
>> 		mapperGlyph->SetScalarRange(50, 180);
>>
>> 		// Add actor to renderer
>> 		glyphActor = vtkActor2D::New();
>> 		glyphActor->SetMapper(mapperGlyph);
>>
>> 		// Add Actor to renderer
>> 		ren->AddActor2D(glyphActor);
>> 	}
>> 	#endif
>>
>> Best regards,
>>
>> Elvis Dowson
>
>



-- 
Isabella Y. Murphy
Programming Assistant
Yale University School of Medicine,
New Haven, CT 06520-8042 USA
isabella.murphy at yale.edu
(Cell) 203-906-5359



More information about the vtkusers mailing list