[vtkusers] vtkAssignAttribute for Java

Ed Stewart estewart at vni.com
Thu Jan 20 17:18:23 EST 2005


 
Thank you very much! I think I found an easy way to do this based on
your suggestion. I had been scouring the docs for some kind of
"SetScalars" method and sure enough vtkPointData has one! So I can use:
 sc.SetLookupTable(lut);
 surfPolyData.GetPointData().SetScalars(sc);

Now I don't need to use any names at all, nor do I need to set the color
table via the mapper (which didn't seem to be working either).

Thanks for getting me to look in the right place.

-ed

-----Original Message-----
From: Jeff Lee [mailto:jeff at cdnorthamerica.com] 
Sent: Thursday, January 20, 2005 3:25 PM
To: Ed Stewart
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] vtkAssignAttribute for Java

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