Henning,<br><br>As a work around, just scale the plane uwing SetNormal so that the range of the data is the same as the sphere (or other data). No need to implement your own.<br><br><div class="gmail_quote">On Fri, Oct 5, 2012 at 1:26 PM, Henning Meyer <span dir="ltr"><<a href="mailto:tutmann@gmail.com" target="_blank">tutmann@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p>Thank you all for helping me understanding the issue. For now I'll implement my own version of vtkSphere and vtkCylinder - I think the algorithm they use could be switched depending on a certain radius threshold (somewhere around 50). I'll try and produce some patches. </p>



<div class="gmail_quote">Am 05.10.2012 20:11 schrieb "David Gobbi" <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>>:<div><div><br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Several other implicit functions return squared distance instead<br>
of linear distance.  Of course there's the caveat that clipping is<br>
approximate for non-planar implicit surfaces, so people using<br>
these functions should only expect approximate results.<br>
<br>
vtkCylinder<br>
vtkQuadric<br>
vtkSuperquadric<br>
vtkImplicitHalo<br>
<br>
The last two classes, vtkSuperquadric and vtkImplicitHalo, aren't<br>
even complete, they don't compute the function gradient.  And<br>
vtkImplicitHalo has a math error in EvaluateFunction, and will only<br>
give correct results if Radius=1.0.  So it's a very good thing that<br>
these days we have gerrit to enforce code review.<br>
<br>
I'll see about posting a bug report to report my findings.  If anyone<br>
wants to send patches, I'll be glad to review them.<br>
<br>
 - David<br>
<br>
<br>
<br>
<br>
On Fri, Oct 5, 2012 at 10:42 AM, Bill Lorensen <<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>> wrote:<br>
> Will,<br>
><br>
> Sounds like a good solution.<br>
><br>
> Bill<br>
><br>
><br>
> On Fri, Oct 5, 2012 at 12:40 PM, Will Schroeder <<a href="mailto:will.schroeder@kitware.com" target="_blank">will.schroeder@kitware.com</a>><br>
> wrote:<br>
>><br>
>> One approach is to just add an option to the class which indicates whether<br>
>> the take the sqrt or not. Leave the default behavior alone or you'll be<br>
>> driving a lot of people nuts :-)<br>
>> W<br>
>><br>
>><br>
>> On Fri, Oct 5, 2012 at 12:09 PM, David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> I think the root of the problem is vtkSphere.  Here is the function<br>
>>> that it uses:<br>
>>><br>
>>>   return ( ((x[0] - this->Center[0]) * (x[0] - this->Center[0]) +<br>
>>>               (x[1] - this->Center[1]) * (x[1] - this->Center[1]) +<br>
>>>               (x[2] - this->Center[2]) * (x[2] - this->Center[2])) -<br>
>>>               this->Radius*this->Radius );<br>
>>><br>
>>> It is computing the squared distance from the surface of the sphere.<br>
>>> This is different from vtkPlane, which computes the linear distance<br>
>>> from the plane.  This is definitely going to cause scaling problems<br>
>>> when you combine these two functions with vtkImplicitBoolean.<br>
>>><br>
>>> VTK's clipping and contouring operations work by doing linearly<br>
>>> interpolating the scalar value along each edge or line segment that is<br>
>>> clipped.  In order for the clipping to be done accurately, the<br>
>>> implicit functions must return a signed linear distance from the<br>
>>> surface that the implicit function defines.  Because vtkSphere is<br>
>>> returning a squared distance, I have to declare that vtkSphere is<br>
>>> broken.<br>
>>><br>
>>> It should be using a formula like this:<br>
>>><br>
>>>   double d2 = (dx*dx + dy*dy + dz*dz - r*r);<br>
>>>   return (d2 < 0 ? -sqrt(-d2) : sqrt(d2));<br>
>>><br>
>>> This will make vtkSphere a bit slower, but it will make it give better<br>
>>> results.<br>
>>><br>
>>>  - David<br>
>>><br>
>>><br>
>>> On Thu, Oct 4, 2012 at 5:05 PM, Sebastien Jourdain<br>
>>> <<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>> wrote:<br>
>>> > Ok then, could you save the 2 output of the vtkSampleFunction to a<br>
>>> > binary vtk file format and upload them to the bug tracker, so I can<br>
>>> > try to clip the dataset inside ParaView.<br>
>>> ><br>
>>> > Thanks,<br>
>>> ><br>
>>> > Seb<br>
>>> ><br>
>>> > On Thu, Oct 4, 2012 at 6:51 PM, Henning Meyer <<a href="mailto:tutmann@gmail.com" target="_blank">tutmann@gmail.com</a>><br>
>>> > wrote:<br>
>>> >>> But I don't think the issue come from the contour filter. Did you<br>
>>> >>> tried to just render the SampleFunction ?<br>
>>> >> It looks almost the same in both cases - besides the 1000 * value<br>
>>> >> range in<br>
>>> >> the second example.<br>
>>> > _______________________________________________<br>
>>> > Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>>> ><br>
>>> > Visit other Kitware open-source projects at<br>
>>> > <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>>> ><br>
>>> > Follow this link to subscribe/unsubscribe:<br>
>>> > <a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
>>> ><br>
>>> _______________________________________________<br>
>>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>>><br>
>>> Visit other Kitware open-source projects at<br>
>>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>>><br>
>>> Follow this link to subscribe/unsubscribe:<br>
>>> <a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
>>><br>
>><br>
>><br>
>><br>
>> --<br>
>> William J. Schroeder, PhD<br>
>> Kitware, Inc.<br>
>> 28 Corporate Drive<br>
>> Clifton Park, NY 12065<br>
>> <a href="mailto:will.schroeder@kitware.com" target="_blank">will.schroeder@kitware.com</a><br>
>> <a href="http://www.kitware.com" target="_blank">http://www.kitware.com</a><br>
>> <a href="tel:%28518%29%20881-4902" value="+15188814902" target="_blank">(518) 881-4902</a><br>
>><br>
>> _______________________________________________<br>
>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>><br>
>> Visit other Kitware open-source projects at<br>
>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>><br>
>> Follow this link to subscribe/unsubscribe:<br>
>> <a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
>><br>
>><br>
><br>
><br>
><br>
> --<br>
> Unpaid intern in BillsBasement at noware dot com<br>
><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
<br>
</blockquote></div></div></div>
</blockquote></div><br><br clear="all"><br>-- <br>Unpaid intern in BillsBasement at noware dot com<br><br>