[vtkusers] Access data information from actor
Gelas, Arnaud Joel Florent
Arnaud_Gelas at hms.harvard.edu
Tue Mar 29 20:06:22 EDT 2011
Hi Nicolas,
You may want to check field data instead:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/FieldData
HTH
Arnaud
________________________________________
From: vtkusers-bounces at vtk.org [vtkusers-bounces at vtk.org] On Behalf Of Nicolas Rannou [nicolas_rannou at hms.harvard.edu]
Sent: Tuesday, March 29, 2011 4:14 PM
To: vtkusers at vtk.org; vtk-developers at vtk.org
Subject: [vtkusers] Access data information from actor
Hello,
I would like to access information about an object from the actor.
It is working but it is very inefficient and I would like to improve it.
Let's say I have a polydata which represent the object #9.
When I click on the associated actor, I would like to know that it is object #9.
So far, I am storing the object ID in an array.
//----------------------------------------------------------
// FILL THE POLYDATA
vtkPolydata* myPolyData; // Object #9
vtkDataArray* array;
array->SetName("ID");
for(int i=0; i<myPolyData->GetNumberOfPoints(); ++i)
{
array->InsertNextValue(ObjectID);
}
myPolyData->GetPointData()->AddArray( array );
// APPLY FILTER
vtkCutter* myCutter;
cutter->SetInput(myPolyData);
cutter->SetCutFunction(myCutFunction);
//ADD TO VISU
vtkMapper* myMapper;
vtkActor* myActor;
mapper->SetInput( cutter->GetOutput() );
actor->setMapper(mapper);
//----------------------------------------------------------
I can then access it:
//----------------------------------------------------------
actor->GetMapper()->GetInput()->GetPointData()->GetArray("ID");
//----------------------------------------------------------
The problem is that filling such an array if you have thousands of polydatas (500 points each) is quite time consuming.
Would somebody have any recommendation? I guess the best practice would be to add the information directly in the actor but I couldn't figure out how to proceed.
Thanks,
Nicolas
More information about the vtkusers
mailing list