[Paraview] Find Data in Python
Christian Werner
christian.werner at rwth-aachen.de
Mon Apr 19 11:20:51 EDT 2010
Does that mean that I have to create a selection with explicitly
defining the points? Oh man... Then I can forget the whole thing anyway.
Everything is so nice about Paraview, but this selection thing is
driving me mad.
It's still all about making it as easy as possible for the user to
select objects out of Polydata and let a plugin analyze these objects.
As it seems now, the user has to:
1) Ctrl+Click matching objects one after another (already dangerours,
because you might forget to hold down Ctrl when selecting)
2) go to Filter->Recent->ExtractSelection
3) wait at least 3 seconds
4) call a plugin that writes the extracted points' coordinates and their
ID to a file
5) call the analyzing plugin that reads out the file (to get the
RegionID and coordinates) and does the analysing stuff (in ITK)
I have found a way to do that "wait 3 seconds" in Python using a
thread(!) which checks the time and joins after some seconds. Using
sleep(5) simply froze everything and postponed the segmentation fault
(which clearly comes from my writer that doesn't have input). Another
possibility would be to modify vtkExtractSelection to suite my needs,
but I won't do that, since I don't have time for that anymore. This
workaround has to do.
Anyway, Paraview, VTK and ITK are really nice, I am glad I found these
open-source tools.
Best regards,
Christian
Utkarsh Ayachit schrieb:
> Does your data have time? If not, you don't need to specify the
> time=10000 attribute at all. So SelectionWriter is the thing that's
> coming from your plugin? Does it support writing empty datasets? Can
> you attach a debugger and see where is crashes? Are you sure it's not
> crashing in the writer? I dont' see why UpdatePipeline() on extract
> selection would crash. Instead of using a macro, try manually typing
> the text in the python shell to see exactly what line causes the
> segfault.
>
> BTW, ExtractSelection needs two inputs: 'Input" and "Selection" where
> Selection is set to the SelectionQuerySource proxy.
>
> Utkarsh
>
> On Mon, Apr 19, 2010 at 10:34 AM, Christian Werner
> <christian.werner at rwth-aachen.de> wrote:
>
>> I am afraid UpdatePipeline doesn't help, even if I set the time to some high
>> value. Paraview crashes right in the moment where I start this macro:
>>
>> extract=ExtractSelection(Input=ConnectivityFilter)
>>
>> UpdatePipeline(time= 10000, proxy=extract)
>>
>> mFilename = destPath + str( time() )
>>
>> swriter=SelectionWriter(Input=extract)
>>
>> swriter.FileName=mFilename
>>
>> swriter.UpdatePipeline()
>>
>>
>> When I manually select Fiters->ExtractSelection and then do:
>>
>> mFilename = destPath + str( time() )
>>
>> swriter=SelectionWriter()
>>
>> swriter.FileName=mFilename
>>
>> swriter.UpdatePipeline()
>>
>>
>> everything works fine.
>>
>>
>>
>> Utkarsh Ayachit schrieb:
>>
>>> You can simply call UpdatePipeline() as follows:
>>>
>>> from paraview.simple import *
>>> ....
>>> UpdatePipeline(proxy=extractSelectionSource)
>>>
>>> This will update the extract selection filter explicitly. Look at
>>> help(UpdatePipeline) for details.
>>>
>>> Utkarsh
>>>
>>>
>>> On Sun, Apr 18, 2010 at 3:38 PM, Christian Werner
>>> <christian.werner at rwth-aachen.de> wrote:
>>>
>>>
>>>> Hi Utkarsh,
>>>>
>>>> these are great news. I tried the python trace but not in combination
>>>> with
>>>> the extraction (what I acutally do need anyway....)
>>>>
>>>> As you might remember I am working around the "lack" of possibilty to
>>>> select
>>>> whole objects (cells with same RegionID). With the given
>>>> SelectionQuerySource this workaround is complete.
>>>>
>>>> There remains one issue: At some point I call an ExtractSelection() in
>>>> Python that is followed by a call to a vtk-Plugin (which writes the point
>>>> data of the selected points to disk). The resulting file is empty,
>>>> because
>>>> the Extraction takes a few seconds and obviously the plugin has no valid
>>>> input when being executed. Paraview also crashes as a consequence. When I
>>>> am
>>>> doing this manually (trigger ExtractSelection, wait until it's done, call
>>>> the vtk Plugin to write the point data) everything works fine. I could
>>>> just
>>>> go ahead and do a dull time.sleep(3) between the extraction and the call
>>>> to
>>>> the plugin, but this certainly isn't good programming style.
>>>>
>>>> What can I do instead?
>>>>
>>>>
>>>> Best regards,
>>>> Christian
>>>>
>>>>
>>>> Utkarsh Ayachit wrote:
>>>>
>>>>
>>>>> Yes, you can use the "SelectionQuerySource" to construct your query as
>>>>> follows:
>>>>>
>>>>> selection_source_540 = SelectionQuerySource( InsideOut=0,
>>>>> ArrayName='', HierarchicalLevel=-1, ProcessID=-1, ContainingCells=0,
>>>>> DoubleValues=None, HierarchicalIndex=-1, FieldType='CELL',
>>>>> ArrayComponent=0, Operator='IS_ONE_OF', TermMode='ID',
>>>>> CompositeIndex=-1, IdTypeValues=0 )
>>>>>
>>>>> You can use the python trace recorder functionality to determine how
>>>>> to create the query. You will, however have to "Extract Selection"
>>>>> from the query (and hit apply) before the selection_source object will
>>>>> appear in the trace.
>>>>>
>>>>> Utkarsh
>>>>>
>>>>>
>>>>> On Sat, Apr 17, 2010 at 9:32 AM, Christian Werner
>>>>> <christian.werner at rwth-aachen.de> wrote:
>>>>>
>>>>>
>>>>>
>>>>>> Hello!
>>>>>>
>>>>>> Is there any chance that the new Edit->Find Data functionality is
>>>>>> available
>>>>>> in Python-Scripting?
>>>>>>
>>>>>>
>>>>>> Best regards,
>>>>>> Christian
>>>>>> _______________________________________________
>>>>>> Powered by www.kitware.com
>>>>>>
>>>>>> Visit other Kitware open-source projects at
>>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>>
>>>>>> Please keep messages on-topic and check the ParaView Wiki at:
>>>>>> http://paraview.org/Wiki/ParaView
>>>>>>
>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>> http://www.paraview.org/mailman/listinfo/paraview
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>>
More information about the ParaView
mailing list