[vtkusers] need text attached to actors

Patric.Weis at Mycrona.de Patric.Weis at Mycrona.de
Thu Apr 26 03:07:30 EDT 2001


Hi Patrick,

In vtk you can attach user defined data to points and cells by
means of field data (vtkFieldData). You are able to attach strings
but they have to be of constant length and must be created
character by character (each character belongs to another field
data array).
 
What I do is attaching identifiers of type 'long' to each cell and
map those identifiers to string arrays and other data structures 
in my program.

The following are code snippets to set and get cell identifiers of
the data type long.

<<< snip...
// Give each cell an identifier:
vtkLongArray *pIds = vtkLongArray::New();
long lNumOfCells = pPolyData->GetNumberOfCells();
for (long lCellNum=0; lCellNum < lNumOfCells; lCellNum++)
{
  lId = ...
  pIds->InsertNextValue(lId);
}
// Create the field data:
vtkFieldData *pCellFieldData = vtkFieldData::New();
pCellFieldData->SetNumberOfArrays(1);
pCellFieldData->SetArray(0, pIds);
pCellFieldData->SetArrayName(0, "ID");
// Attach the field data:
pPolyData->GetCellData()->SetFieldData(pCellFieldData);
<<< snip...

<<< snip...
// Get the ID of the picked cell:
vtkCellPicker *pCellPicker = (vtkCellPicker *) pInteractor->GetPicker();
vtkPolyData * pPolyData = (vtkPolyData *) pCellPicker->GetDataSet();
vtkFieldData  *pFieldData = pPolyData->GetCellData()->GetFieldData();
vtkLongArray *plArray = (vtkLongArray *) pFieldData->GetArray("ID");
long lCellId = pCellPicker->GetCellId();
long lID = plArray->GetValue(lCellId);
<<< snip...


Hope this is what you are looking for!

Patric Weis
MYCRONA GmbH


Am 25.04.01 19:17:09, schrieb Patrick Neumann <neumann at medizin.fu-berlin.de>:

>Thanks,
>
>but this is not what I want :-(
>I mean just a simple string which can be written to the console. If I pick
>an actor in the renderer it would be great to know what I have picked.
>What I need is a method like vtkProp->SetName(const char*) or more general
>vtkObject->SetUserData(void *) and the corresponding get methods.
>
>Yves Starreveld schrieb:
>
>> Hi, Patrick,
>>
>> Have a look at graphics/examplesPython/textOrigin.py
>>
>> Yves
>> On Wednesday, April 25, 2001, at 09:42  AM, Patrick Neumann wrote:
>>
>> > Hi,
>> >
>> > is there a way to attach some text to an actor? I need this for giving
>> > my actors a name.
>> >
>> > Thanks for help
>> > --
>> > Patrick Neumann
>> >
>> >
>> >
>> >
>> > _______________________________________________
>> > This is the private VTK discussion list.
>> > Please keep messages on-topic. Check the FAQ at:
>> > <http://public.kitware.com/cgi-bin/vtkfaq>
>> > Follow this link to subscribe/unsubscribe:
>> > http://public.kitware.com/mailman/listinfo/vtkusers
>> >
>
>--
>Patrick Neumann
>Universitaetsklinikum Benjamin Franklin
>WE 10, FU Berlin, Hindenburgdamm 30, D 12200 Berlin
>Tel: +49 30 8445 4503 / Fax: 4510 / Email: neumann at medizin.fu-berlin.de
>
>
>
>
>_______________________________________________
>This is the private VTK discussion list. 
>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers
>







More information about the vtkusers mailing list