[vtkusers] Is VTK really no inefficient?
Hui Zhou
meilizhuti at gmail.com
Fri Aug 3 01:41:42 EDT 2012
I am researching an efficient 3D visualization system. VTK is the first
one I picked up. It is really a pleasure to read the documentation and
example. It is also straightforward to write a quick benchmark example
thanks to its Python binding.
However, I quickly encountered an obvious bug in VTK. In order to get
around, I then find VTK intolerably inefficient... All seem to be due to
serious design and implementation faults. Well, I am just a beginner who
just picked up VTK which has been there for more than a decade. It seems I
am the obviously stupid one to laugh at, but really? Anyway, I would like
to challenge the experienced VTK users and developers in the mailing list:
Is VTK really so inefficient for such a simple task? If so, why
would anyone like to spend time on it?
Here is my story. I read in a structured grid which has about 500k cells.
VTK renders it quite fast and everything looks so well. Well done!
Then, my nightmare begins. I need to delete a set of cells which have zero
values in the scalars. The VTK manual explicitly states that the BlankCell
/ BlankPoint does exactly that for structured grid. However, this is an
unbelievable bug in VTK! BlankCell/BlankPoint does not at all. If you
google "VTK blankpoint", you may find many posts that reported this did not
work from as early as 2004. A quite good description is here:
http://vtk.1045678.n5.nabble.com/Blanking-a-point-in-a-vtkStructuredGrid-td5474001.html
I got some kind help from a developer and was hinted to use vtkThreshold to
hide those cells that I don't want. This really sounds like a plausible
solution, but it turned out to destroy my last faith in VTK. I used the
vtkThreshold and it worked. However, the new problem is that now the
rendering becomes very very slow! It takes about 5 seconds to update when
I rotate it. That is not acceptable at all. The problem is that when
vtkThreshold is applied, the output of the filter becomes unstructured
grid. It seems VTK is not so competent in visualizing the unstructured
grid, and everything is slowed down badly. Again, it is sad to see other
people reported this issue long time ago (
http://vtk.1045678.n5.nabble.com/Efficient-thresholding-td1240897.html#a1240898)
-- without any reply, again.
I feel it is incredible that VTK is so incompetent in doing such a simple
task. Actually I would feel sorry for the experienced users and
developers if that is really the case. Ok, please give me a lesson if you
think I am wrong. Although the code is in Python, I don't think a C++
implementation could speed things up much.
Here is the part I did the visualization. (self.grid is just an ordinary
vtkStructuredGrid with a scalar array set up.)
geometry = vtk.vtkGeometryFilter()
# key part: if to_cut_cells is true, it is terribly slow because
of the thresholding, otherwise very fast
if to_cut_cells :
active = vtk.vtkThreshold()
active.SetInput(self.grid)
active.ThresholdByUpper(0.1)
active.SetInputArrayToProcess(0, 0, 0,
vtk.vtkDataObject.FIELD_ASSOCIATION_CELLS, vtk.vtkDataSetAttributes.SCALARS)
active.Update()
geometry.SetInputConnection(active.GetOutputPort())
else:
geometry.SetInput(self.grid)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(geometry.GetOutputPort())
lut = vtk.vtkLookupTable()
lut.SetHueRange(0, 0.667)
mapper.SetLookupTable(lut)
mapper.SetScalarModeToUseCellData()
mapper.SetScalarRange(self.grid.GetScalarRange())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.SetScale(1, 1, 10)
....
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120803/0661579d/attachment.htm>
More information about the vtkusers
mailing list