[vtkusers] vtkAssignAttribute for Java

Jeff Lee jeff at cdnorthamerica.com
Thu Jan 20 15:29:38 EST 2005


Ed Stewart wrote:

> 
>Greetings,
>
>I'm having a bit of trouble getting vtkAssignAttribute working in Java.
>I have a vtkPolyData object that I'd like to shade with a set of scalar
>values. I've created a vtkDoubleArray to hold those values and then I'm
>doing the following:
>
>//sc is the vtkDoubleArray that has been filled up with scalar values
>sc.SetName("foo");
>vtkAssignAttribute aa = new vtkAssignAttribute();
>aa.SetInput(surfPolyData);	//surfPolyData is my vtkPolyData object
>to be shaded
>aa.Assign("foo",0,0);		//enums are used for SCALARS and
>  
>
I think you first need to add the sc array to your surfPolyData.
  surfPolyData.GetPointData().AddArray(sc);

after that, I don't think you need assignAttribute at all.  just point
the mapper at that array
surfMapper.SetScalarModeToUseCellFieldData();
surfMapper.SelectColorArray("foo");

if you need to use assignAttribute, you still need to add the data array
to the dataset before assignAttribute will do anything.  All
assignAttribute is supposed to do is make an already existing array in a
dataset an attribute.
Regards,
Jeff

>POINTDATA
>aa.Update();			//I don't think this is needed
>  
>
>//I then create a vtkLookupTable lut to hold the shading colors
>
>vtkPolyDataNormals surfNormas = new vtkPolyDataNormals();
>surfNormals.setInput(aa.GetPolyDataOutput());
>vtkPolyDataMapper surfMapper = new vtkPolyDataMapper();
>surfMapper.SetColorModeToMapScalars();
>surfMapper.ScalarVisibilityOn();
>surfMapper.SetInput(surfNormals.GetOutput());
>surfMapper.SetScalarRange(0.0, 255.0);
>surfMapper.SetLookupTable(lut);
>vtkActor surfActor = new vtkActor();
>surfActor.SetMapper(surfMapper);
>
>The problem of course is that this doesn't change the surface at all. I
>suspect the aa.Assign("foo",0,0) line is to blame as I don't see how it
>can make the connection back to the vtkDataArray object that I've named
>"foo".
>
>Can anyone confirm that I am coding this correctly?
>
>Thank you,
>-ed
>_______________________________________________
>This is the private VTK discussion list. 
>Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>  
>




More information about the vtkusers mailing list