Need a noninvasive vtkActor::GetProperty()

vtkProperty* vtkActor::GetProperty( )
will automatically create a vtkProperty object if one has not yet been created.
I would like something like GetProperty() but it should return a Null pointer if the vtkProperty object has not yet been created.
My motivation: If someone else has already created a vtkProperty object for a particular vtkActor, then I will not change it. However, if the vtkProperty object has not yet been created, then I will create one and set the Interpolation to Flat. Currently we are having problems with uninitialized memory reads causing some vtkActors to have Gouraud shading.


If I understood it right, just test whether the returned vtkProperty’s setting is Gouraud shading and set it to flat.



Hello Paulo,
Thank you for your response.
Unfortunately if the vtkProperty objects are automatically created by vtkActor::GetProperty(), they contain uninitialized values (garbage values that are different each time I run the program), so they could have shading set to Flat or Gouraud randomly. So I need to know if a vtkProperty object for this vtkActor does not exist before I call vtkActor::GetProperty() or if someone else has already created a vtkProperty object for this vtkActor.

Like I said, just test the shading setting with an if() and set it correctly when it is initialized incorrectly. Now, if the question extends to other properties, not only shading option, just call vtkProperty::DeepCopy( my_standard_property ) on the returned vtkProperty objects.

I don’t understand how this might be happening. If I look at vtkActor::GetProperty(), I see it invokes vtkActor::MakeActor() which simply invokes the vtkProperty constructor. In that constructor, the Shading member variable is indeed initialized.

Thank you for the information. I studied the problem in more detail and determined that the uninitialized memory error was not in the VTK code. It was in some other convoluted code that deceptively made it look like the vtkProperty objects contained uninitialized values. My apologies.

No worries! Glad you got it resolved.