[vtkusers] Problems with vtkClipPolyData and vtkImplicitBoolean
normanius
juch at zhaw.ch
Wed Dec 30 20:35:13 EST 2015
Hi
I have an issue with vtkClipPolyData, using an implicit function created
with vtkImplicitBoolean. Although it is really convenient to create a
complex-shaped function, it does not behave as expected in regions where two
implicit functions coincide.
Here is what I do: cut out a cylinder from an arbitrary surface. The code is
found at the end of this post.
1) Define a bounded implicit cylinder by combining (intersecting) one
vtkCylinder with two vtkPlanes: vtkImplicitBoolean.
2) Clip the surface using vtkClipPolyData (at function value 0).
While the clipping works good in general, the clipping is inaccurate in
regions where two implicit functions intersect. Look at the image below
(ignore the red sphere). In white the surface that has to be cut. The green
transparent surface indicates the implicit cylinder function. The cells that
are clipped away by vtkClipPolyData are marked blue. You can see easily that
close to where vtkCylinder and vtkPlane intersect the clipping looks faulty.
<http://vtk.1045678.n5.nabble.com/file/n5735713/imperfect_cut_for_small_angle_of_attack.png>
I found two issues with vtk related to this:
1) The vtkCylinder function measures the *squared* radial distance from the
surface, while the vtkPlane evaluates the normal distance. This is
inconsistent with the linear interpolation performed when clipping the cells
(e.g. vtkTriangle::Clip()).
2) If two points of a surface triangle are "constrained" by different
implicit functions, the interpolation used when clipping a (triangular) cell
is inaccurate. (This problem occurs only for functions using
vtkImplicitBoolean.)
1) is not actually a bug or issue but the choice of function accentuates the
problem in my case. That's why I would suggest the following change of code
int vtkCylinder.cxx.
I guess you are pretty reluctant to apply this change because of backward
compatibility. Nevertheless, the result looks considerably better with the
new choice and is more consistent with the linear interpolation when
clipping.
<http://vtk.1045678.n5.nabble.com/file/n5735713/imperfect-cut-after-fix.png>
But the real issue is 2). When the corners of a triangle "hit" different
implicit functions, the linear interpolation (e.g. in vtkTriangle::Clip())
between the function values is not valid, or at best inaccurate. I've looked
how vtkClipPolyData::RequestData() operates and how it invokes
vtkGenericCell::Clip(...) (or vtkTriangle::Clip() in my case) and I suggest
that this is improved: either by passing a functor to Clip() that allows to
evaluate multiple candidates, or to discretize the edges of these triangles
beforehand. Obviously, this would make the code run slower. But the
precision could be specified, which is often more eligible.
So here's a question: how can I work around these inaccuracies along the
boundaries of a boolean implicit function?
And along this lines, I'm suggesting two changes in the code:
1) Make the distance function for the cylinder linear.
2) Don't use linear interpolation in those cells that are clipped.
Let me know what you're thinking.
--
View this message in context: http://vtk.1045678.n5.nabble.com/Problems-with-vtkClipPolyData-and-vtkImplicitBoolean-tp5735713.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list