[vtkusers] Displaying multiple vector data with vtkGlyph3D

Leguay Romain romain.leguay at etu.u-bordeaux1.fr
Mon Sep 26 03:04:00 EDT 2011


Hello everyone!
I try to display some vector data with vtkGlyph3D.
When I display only one vector data, it works just fine. But when I try to display two or more vector datas, I have just the final vector data displayed and the glyph's colors is the color of the first vector glyph.

Here the code (in java) when I create my vtkActor:

                vtkDataSet vDataSet = zone.getVtkDataSet();
		String varName = variable.getName();
                 
                 // Test if the variable data is CELL_DATA or POINT_DATA
		switch (variable.getCurrentAttributeType()) {
		case CELL_DATA:
			vtkCellData vCellData = vDataSet.GetCellData();
			vCellData.SetActiveVectors(varName);
				//vCellData.SetVectors(variable.getVtkDataArray());
			
			break;

		case POINT_DATA:
			vtkPointData vPointData = vDataSet.GetPointData();
			vPointData.SetActiveVectors(varName);
			//vPointData.SetVectors(variable.getVtkDataArray());
			
			break;

		case FIELD_DATA:
			break;

		default:
			break;
		}
		
		vtkArrowSource arrow = new vtkArrowSource();
		
		vtkTransform transform = new vtkTransform();
		transform.Translate(stride, 0, 0);
		vtkTransformPolyDataFilter transformF = new vtkTransformPolyDataFilter();
		transformF.SetInputConnection(arrow.GetOutputPort());
		transformF.SetTransform(transform);

		vtkGlyph3D glyph = new vtkGlyph3D();
		glyph.SetInput(vDataSet);
		glyph.SetSourceConnection(transformF.GetOutputPort());
		glyph.SetVectorModeToUseVector();
		glyph.SetScaleModeToScaleByVector();
		glyph.SetScaleFactor(scale);
		glyph.Update();

		// On choisit quel type de coloration.
		VtkMapper mapper = new VtkMapper(zone);
		vtkMapper vMapper = mapper.getVtkMapper();

		vMapper.SetInputConnection(glyph.GetOutputPort());
		vMapper.ScalarVisibilityOff();
		vtkActor actor = new vtkActor();
		actor.SetMapper(vMapper);
		actor.GetProperty().SetColor(colorVectors.getR(), colorVectors.getG(), colorVectors.getB());
		
		setVtkProp3D(actor);
		setVtkMapper(mapper);


For each new variable, I create a new vtkActor.
I don't understand why this code doesn't work.

If anyone found some mistake(s)...

Thanks.

Romain.




More information about the vtkusers mailing list