[vtkusers] Access data information from actor

Nicolas Rannou nicolas_rannou at hms.harvard.edu
Tue Mar 29 16:14:51 EDT 2011


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110329/670ff5d0/attachment.htm>


More information about the vtkusers mailing list