David,<div><br></div><div>Thanks for the clarification and the suggestion regarding vtkProgrammableSource.  I&#39;ll look into that option.</div><div><br></div><div>-Ryan</div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sun, Dec 9, 2012 at 1:25 PM, David Gobbi <span dir="ltr">&lt;<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Ryan,<br>
<br>
This won&#39;t work, because your EvaluateFunction() and EvalutateGradient()<br>
methods will never get called.  Overriding virtual methods through python<br>
doesn&#39;t work in the VTK wrappers.  Maybe it will work at some point in<br>
the future.<br>
<br>
For sources and filters, people use vtkProgrammableSource and<br>
vtkProgrammableFilter to do what you are trying to do.  You could use<br>
these as an example and write a vtkProgrammableImplicitFunction<br>
(in C++) that you could then use as a &quot;hook&quot; to write implicit functions<br>
in python.<br>
<span class="HOEnZb"><font color="#888888"><br>
 - David<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Sun, Dec 9, 2012 at 12:05 PM, Ryan Irvin &lt;<a href="mailto:ryan.irvin@gmail.com">ryan.irvin@gmail.com</a>&gt; wrote:<br>
&gt; I&#39;m trying to create a custom implicit surface function to represent a conic<br>
&gt; asphere and my approach was to try and subclass vtkSphere.  I had previously<br>
&gt; tried to subclass vtkImplicitFunction without success and saw some posts<br>
&gt; about not being able to subclass abstract classes in Python (I don&#39;t know if<br>
&gt; this is still true).<br>
&gt;<br>
&gt; The subclass I&#39;ve put together is shown below, where the attribute surf_obj<br>
&gt; is a python class representing the conic asphere and contains methods for<br>
&gt; evaluating the surface function and gradient.<br>
&gt;<br>
&gt; When I run my full script, the result is that the default vtkSphere is<br>
&gt; always rendered.  It&#39;s pretty apparent that I&#39;m not understanding the proper<br>
&gt; approach to this problem and/or am not properly subclassing vtkSphere.<br>
&gt;<br>
&gt; I will be happy to provide the full *.py file which contains all of the code<br>
&gt; but wasn&#39;t sure of the protocol and have not provided it with this post.<br>
&gt;<br>
&gt; If anyone has any suggestions about the correct way to approach this problem<br>
&gt; or can provide some advice for properly subclassing, I would very much<br>
&gt; appreciate it.<br>
&gt;<br>
&gt; -Ryan<br>
&gt;<br>
&gt;<br>
&gt; class VtkImplicitConic( vtk.vtkSphere ):<br>
&gt;<br>
&gt;     def __init__( self, con_surf ):<br>
&gt;         self.surf_obj = con_surf<br>
&gt;         self.SetRadius( self.surf_obj.GetRadius() )<br>
&gt;<br>
&gt;<br>
&gt;     def EvaluateFunction( self, x, y, z ):<br>
&gt;         return self.surf_obj.EvaluateFunction( x, y, z )<br>
&gt;<br>
&gt;<br>
&gt;     def EvaluateGradient( self, x, n ):<br>
&gt;         n[0],n[1],n[2] = self.surf_obj.EvaluateGradient( x[0], x[1], x[2] )<br>
&gt;<br>
&gt;<br>
&gt;     def GetRadius( self ):<br>
&gt;         return self.surf_obj.GetRadius()<br>
&gt;<br>
&gt;<br>
&gt;     def SetRadius( self, radius ):<br>
&gt;         self.surf_obj.SetRadius( radius )<br>
</div></div></blockquote></div><br></div>