I'm trying to create a custom implicit surface function to represent a conic asphere and my approach was to try and subclass vtkSphere. I had previously tried to subclass vtkImplicitFunction without success and saw some posts about not being able to subclass abstract classes in Python (I don't know if this is still true).<div>
<br></div><div>The subclass I've put together is shown below, where the attribute surf_obj is a python class representing the conic asphere and contains methods for evaluating the surface function and gradient.</div><div>
<br></div><div>When I run my full script, the result is that the default vtkSphere is always rendered. It's pretty apparent that I'm not understanding the proper approach to this problem and/or am not properly subclassing vtkSphere.</div>
<div><br></div><div>I will be happy to provide the full *.py file which contains all of the code but wasn't sure of the protocol and have not provided it with this post.</div><div><div><br></div><div>If anyone has any suggestions about the correct way to approach this problem or can provide some advice for properly subclassing, I would very much appreciate it.</div>
<div><br></div><div>-Ryan</div><div><br></div><div><br></div><div>class VtkImplicitConic( vtk.vtkSphere ):</div><div> </div><div> def __init__( self, con_surf ):</div><div> self.surf_obj = con_surf</div><div>
self.SetRadius( self.surf_obj.GetRadius() )</div><div> </div><div><br></div><div> def EvaluateFunction( self, x, y, z ):</div><div> return self.surf_obj.EvaluateFunction( x, y, z )</div><div><br></div>
<div> </div><div> def EvaluateGradient( self, x, n ):</div><div> n[0],n[1],n[2] = self.surf_obj.EvaluateGradient( x[0], x[1], x[2] )</div><div> </div><div> </div><div> def GetRadius( self ):<br>
</div><div> return self.surf_obj.GetRadius()</div><div><br></div><div><br></div><div> def SetRadius( self, radius ):</div><div> self.surf_obj.SetRadius( radius )</div></div>