[vtkusers] Polydata filtering in real-time
Nil Goyette
nil.goyette at imeka.ca
Wed Jun 4 14:48:55 EDT 2014
HI all, I tried more things and I can finally call it a success.
Modifying the vtkPolyData when the cube moves is a bad idea for
real-time rendering. A simple polydata->Modified() takes 3-4 seconds to
render the next frame. There's too much fibers and not enough time in a
second.
I had some good results using another vtkPolyData, building it with the
small subset of fibers passing by the cube and displaying it with a
normal mapper. It was rendering in real-time most of the time, but not
in the part with the most fibers.
After a lot of trials and errors to make it fast, I discovered the
OpenGL list functions in vtkOpenGLPolyDataMapper.cxx: glGenLists,
glNewList, glEndList and glCallList. I understand why they were used in
the code (compiling a list of commands to make them fast *after*), but I
had to remove them to render in real-time. Now moving around in the
scene is slower, but rendering the filtered fibers is as fast as I
wanted it to be.
In summary, the solution is to modify the vtkPolyDataMapper, not the
vtkPolydata, in order to draw only the fibers you need in OpenGL.
Le 2014-05-23 13:58, Nil Goyette a écrit :
> While waiting for an answer, I tried coding the third solution I had:
> "Extend vtkPolyData to add the concept of visibility". I took
> vtkStructuredGrid as an example, noted where this->CellVisibility
> appears and extended vtkPolyData with the important methods:
> Initialize, GetCellType and GetCell_1-2, added Blank, UnBlank, etc.
>
> Of course, it didn't work and I'm not sure why. It seems GetCell and
> GetCellType are never called. I was sure that one method somewhere
> during the rendering process called them but it's not the case. What I
> don't understand then is, if all methods related to CellVisibility are
> not called, how can it works for vtkStructuredGrid? There's no example
> using vtkStructuredVisibilityConstraint. Do I need to pass the result
> of polydata->GetCellVisibilityArray() to another method?
>
> Le 2014-05-21 10:43, Nil Goyette a écrit :
>> Hi,
>>
>> I'm searching how to recreate the FiberNavigator [1] using vtk and
>> I'm stuck on one problem. As you can see in my screenshot [2], we use
>> a little teal cube to filter which fibers we want to see. The cube
>> will be a vtkBoxWidget and the fibers are a vtkPolyData. The problem
>> is that there's no concept of cell visibility in a vtkPolyData. I
>> found this feature in vtkStructuredGrid but I believe my data doesn't
>> fit the class' description. I found three ways to do what I want:
>>
>> 1. Use vtkExtractSelectedPolyDataIds to extract only the cells I
>> need. I think this would be super slow.
>> 2. Add/delete cells when the cube pass by. I think this would also
>> be slow.
>> 3. Extend vtkPolyData to add the concept of visibility
>> (vtkStructuredVisibilityConstraint). This looks like the best
>> option to me but I may be wrong.
>>
>> I wonder what's the best way to filter the fibers. Do you have any
>> suggestions for me? Thanks for your time.
>>
>> [1] https://github.com/scilus/fibernavigator
>> [2] http://imgur.com/1edZpWT
--
Logo Imeka <http://imeka.ca/> Nil Goyette, M.Sc.
Programmer
www.imeka.ca <http://imeka.ca/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140604/1860cd19/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Imeka.png
Type: image/png
Size: 6630 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140604/1860cd19/attachment.png>
More information about the vtkusers
mailing list