Hi,
I’m following this example https://lorensen.github.io/VTKExamples/site/Python/Picking/HighlightPickedActor/
which shows how to change color of the picked actor which is a vtkSphereSource. However, how is it possible to change the radius of the picked actor? there isn’t any SetRadius in the properties of the actors. How can I reach to the source from the actor? I’m thinking something like actor.GetMapper().GetSource().SetRadius() but there is no GetSource, I tried GetInputData too which doesn’t led me to the place I can SetRadius
I have found this example here which is written in C++, I’m interested in VTK Javascript or Python, There is not a getProducer for actor.getMapper().getInputData() as I saw.
//
// Now we retrieve the source object from vtkActor reversely,
// meaning we don't use the spheresource object we instantiated
// above directly,
// instead we retrieve a reference to the spheresource through the
// actor.
// An advantage of this concept might be that we don't need to
// maintain the source object anymore
// in a more complex application.
// To demonstrate that we can modify properties of the spheresource
// through this reference
// beside changing some properties of the actor (in this example we
// change actor's x-position),
// we change the radius of the spheresource as well.
//
// next two lines are the core lines for reverse access
//
vtkSmartPointer<vtkAlgorithm> algorithm =
sphereActor->GetMapper()->GetInputConnection(0, 0)->GetProducer();
vtkSmartPointer<vtkSphereSource> srcReference =
vtkSphereSource::SafeDownCast(algorithm);
float origRadius = srcReference->GetRadius();
for (int i = 0; i < 360; ++i)
{
// change radius of the spheresource
srcReference->SetRadius(origRadius * (1 + sin((float)i/180.0 * vtkMath::Pi())));
// change x-position of the actor
sphereActor->SetPosition(sin((float)i/45.0 * vtkMath::Pi())*0.5, 0, 0);
renWin->Render();
}
//
// Thanks to the usage of vtkSmartPointer there is no explicit need
// to free any objects at this point.
//
return EXIT_SUCCESS;