MantisBT - VTK
View Issue Details
0014143VTK(No Category)public2013-06-24 07:482014-01-03 08:51
David Doria 
Will Schroeder 
normalminorhave not tried
closedfixed 
 
 
TBD
incorrect functionality
0014143: vtkClipPolyData with implicit function produces NANs
In this example:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Broken/PolyData/ImplicitDataSetClipping [^]

I create a sphere (vtkPolyData) and clip it with an implicit cube
(vtkBox). The visual result of the clipping looks correct (the portion
of the sphere that is inside the box remains), but there are 68 cells
reported in the resulting clipped data (clipped->GetNumberOfCells()),
but I only count 20 (2 columns of 10 triangles).

The cells seem to be well formed, but there are tons of NAN points
that I guess the cells are referencing. At line 250ish in
vtkClipPolyData.cxx:

    // evaluate implicit cutting function
    for ( i=0; i < numberOfPoints; i++ )
      {
      s = clipScalars->GetComponent(cellIds->GetId(i),0);
      cellScalars->InsertTuple(i, &s);
      }

's' is getting set to -inf for many of the cells, which is my best
quick guess at what is causing the NANs.
No tags attached.
png ClipPolyData.png (24,079) 2014-01-03 08:50
https://www.vtk.org/Bug/file/9590/ClipPolyData.png
png

cxx ImplicitDataSetClipping.cxx (6,131) 2014-01-03 08:50
https://www.vtk.org/Bug/file/9591/ImplicitDataSetClipping.cxx
Issue History
2013-06-24 07:48David DoriaNew Issue
2014-01-03 07:02Will SchroederNote Added: 0032123
2014-01-03 07:02Will SchroederAssigned To => Will Schroeder
2014-01-03 07:02Will SchroederStatusbacklog => active development
2014-01-03 07:54Will SchroederNote Edited: 0032123bug_revision_view_page.php?bugnote_id=32123#r707
2014-01-03 08:48Will SchroederNote Edited: 0032123bug_revision_view_page.php?bugnote_id=32123#r708
2014-01-03 08:50Will SchroederFile Added: 0014143-ClipPolyData.png
2014-01-03 08:50Will SchroederFile Added: ImplicitDataSetClipping.cxx
2014-01-03 08:51Will SchroederNote Added: 0032124
2014-01-03 08:51Will SchroederStatusactive development => closed
2014-01-03 08:51Will SchroederResolutionopen => fixed

Notes
(0032123)
Will Schroeder   
2014-01-03 07:02   
(edited on: 2014-01-03 08:48)
Investigating now.
There is definitely a problem, lots of bad points and scalars. Diving in now.

Okay this is user error, a very bad example of using a box to clip a sphere. Here is the litany of errors:
1. Using vtkImplicitDataSet -> You really need to set the OutValue. By default it is a very large number which resulted in the NaNs.
2. Having said that, it is difficult in this case to choose any reasonable out value. Using large, negative numbers causes the clipped triangles on the edge to be "squashed" into little slivers. So although only 20 triangles were counted by eye, there were actually many more, most of which were squashed.
3. Using a cube source and then using Delaunay3D to create a 3D dataset which is then used as an implicit function is way overkill. It's better just to use the implicit function vtkBox.
4. Doing so fixes the problem. I have uploaded a final image and the working code.

(0032124)
Will Schroeder   
2014-01-03 08:51   
User error. Test program modified and fixed.