[Paraview] vtkCellLocator: Python

Bastil2001 at yahoo.de Bastil2001 at yahoo.de
Tue Jun 1 15:12:24 EDT 2010


 Thanks Eric, all,

but this does not seem to work at all. My loop looks something like this:

input = self.GetInputDataObject(0, 0)
output = self.GetOutputDataObject(0)
if input.IsA("vtkMultiBlockDataSet"):
    iter = input.NewIterator()
    iter.UnRegister(None)
    iter.InitTraversal()
    i=1
    while not iter.IsDoneWithTraversal():
        curInput = iter.GetCurrentDataObject()
        curInformation = curInput.GetInformation()
        print i
        print iter.GetCurrentMetaData()
        # This is where I want to query for the current name, line does
not work....
        print iter.GetCurrentMetaData().Get(iter.GetCurrentMetaData.NAME)
        i=i+1
        iter.GoToNextItem();

The output of print iter.GetCurrentMetaData() looks like this:

vtkInformation (0x3808f00)
Debug: Off
Modified Time: 269417
Reference Count: 2
Registered Events: (none)
DONT_PRUNE: 1
NAME: my_given_name

I want to work wit the "NAME" attribute ('my_given_name in this case)
but I don't know how...?

Bastil2001 at yahoo.de wrote:
>
>
> -------- Original-Nachricht --------
> Betreff: 	Re: [Paraview] vtkCellLocator: Python
> Datum: 	Mon, 31 May 2010 15:15:54 -0400
> Von: 	Eric E. Monson <emonson at cs.duke.edu>
> An: 	Bastil2001 at yahoo.de
> CC: 	Utkarsh Ayachit <utkarsh.ayachit at kitware.com>, "'ParaView'"
> <paraview at paraview.org>
>
>
>
> Hey Bastian,
>
> I think you should be able to just use the Get() method to pull out
> that information key. When I want to find current time step
> information on some pipeline data (with a programmable filter), which
> has information that looks like this:
>
> vtkInformation (0x11dd723d0)
> Debug: Off
> Modified Time: 70754
> Reference Count: 2
> Registered Events: (none)
> DATA_NUMBER_OF_GHOST_LEVELS: 0
> DATA_TIME_STEPS: 0
> DATA_PIECE_NUMBER: 0
> DATA_EXTENT_TYPE: 0
> DATA_NUMBER_OF_PIECES: 1
>
> I can do it with these commands:
>
> pdi = self.GetInputDataObject(0,0)
> current_time = pdi.GetInformation().Get(pdi.DATA_TIME_STEPS(),0)
>
> So you might be able to just put NAME() in where I put DATA_TIME_STEPS().
>
> Talk to you later,
> -Eric
>
> ------------------------------------------------------
> Eric E Monson
> Duke Visualization Technology Group
>
>
> On May 31, 2010, at 1:23 PM, Bastil2001 at yahoo.de
> <mailto:Bastil2001 at yahoo.de> wrote:
>
>> Thanks Utkarsh,
>>
>> the required information is in MetaData:
>>
>> print iter.GetCurrentMetaData()
>>
>> vtkInformation (0x3808f00)
>> Debug: Off
>> Modified Time: 269417
>> Reference Count: 2
>> Registered Events: (none)
>> DONT_PRUNE: 1
>> NAME: my_given_name
>>
>> Now I want to work with the NAME-Attribute (my_given_name) but I
>> don't know how to get this into a variable? I can't find a
>> GetName()-Method...
>>
>> print dir(iter.GetCurrentMetaData())
>>
>> ['AddObserver', 'Append', 'AppendUnique', 'BreakOnError', 'Clear',
>> 'Copy', 'CopyEntries', 'CopyEntry', 'DebugOff', 'DebugOn',
>> 'FastDelete', 'Get', 'GetAddressAsString', 'GetClassName',
>> 'GetDebug', 'GetGlobalWarningDisplay', 'GetKey', 'GetMTime',
>> 'GetNumberOfKeys', 'GetReferenceCount', 'GetRequest',
>> 'GlobalWarningDisplayOff', 'GlobalWarningDisplayOn', 'Has',
>> 'HasObserver', 'InvokeEvent', 'IsA', 'IsTypeOf', 'Length',
>> 'Modified', 'NewInstance', 'PrintRevisions', 'Register', 'Remove',
>> 'RemoveAllObservers', 'RemoveObserver', 'RemoveObservers',
>> 'SafeDownCast', 'Set', 'SetDebug', 'SetGlobalWarningDisplay',
>> 'SetReferenceCount', 'SetRequest', 'UnRegister']
>>
>> Thanks for help.
>>
>> Regards Bastian
>>
>> Am 30.05.2010 16:58, schrieb Utkarsh Ayachit:
>>> The following example shows how to create an iterator to iterate over
>>> all blocks in a composite dataset. The iterator
>>> (http://www.vtk.org/doc/nightly/html/classvtkCompositeDataIterator.html)
>>> has methods like HasCurrentMetaData(), GetCurrentMetaData() that you
>>> can use to get the meta-data for the current block. Note that by
>>> default the iterator skips over non-leaf nodes. If you want to access
>>> those, use VisitOnlyLeavesOff() on the iterator.
>>>
>>> http://www.itk.org/Wiki/Python_Programmable_Filter#Dealing_with_Composite_Datasets
>>>
>>> Utkarsh
>>>
>>> On Sat, May 29, 2010 at 1:15 PM, BastiL2001 <bastil2001 at yahoo.de> wrote:
>>>   
>>>> Thanks Andi,
>>>>
>>>> I don't know since the ensight reader does this for me. I want to work with
>>>> the input he produces.
>>>>
>>>> Is it in any way possible to link GetMetaData to the current block? Afaik I
>>>> can not query each blocks meta-Data, can I?
>>>>
>>>> Are you naming the block in the meta-data?  In vtkCompositeDataSet there is
>>>> a method called GetMetaData
>>>> (http://www.vtk.org/doc/nightly/html/classvtkCompositeDataSet.html#abcf79d23fc3a67138da3336e4cda2afe)
>>>> that may be what you're looking for.
>>>>
>>>> Andy
>>>>
>>>> On Fri, May 28, 2010 at 3:58 PM, BastiL2001 <bastil2001 at yahoo.de> wrote:
>>>>     
>>>>> Thanks Andi,
>>>>>
>>>>> I will do this. What I am planning to do is to create a scalr field with
>>>>> some distance information as an output.
>>>>>
>>>>> Another issue: I want to loop oder a multi-block dataset with an iterator
>>>>> in a programmable filter (works) and find out the name of the currently
>>>>> visited block. Is that possible? Thanks.
>>>>>
>>>>> Regards Bastian
>>>>>
>>>>> ________________________________
>>>>> Von: pat marion <pat.marion at kitware.com>
>>>>> An: Utkarsh Ayachit <utkarsh.ayachit at kitware.com>
>>>>> CC: Andy Bauer <andy.bauer at kitware.com>; "Bastil2001 at yahoo.de"
>>>>> <Bastil2001 at yahoo.de>; ParaView <paraview at paraview.org>
>>>>> Gesendet: Freitag, den 28. Mai 2010, 16:59:07 Uhr
>>>>> Betreff: Re: [Paraview] vtkCellLocator: Python
>>>>>
>>>>> Unfortunately some of the locator api is pass by reference and therefore
>>>>> not wrapped by python.  Bastian, let us know if you run into missing methods
>>>>> when trying to use the cell locator in python.
>>>>>
>>>>> Pat
>>>>>
>>>>> On Fri, May 28, 2010 at 10:31 AM, Utkarsh Ayachit
>>>>> <utkarsh.ayachit at kitware.com> wrote:
>>>>>       
>>>>>> Andy,
>>>>>>
>>>>>> Bastian wants to use the cell locator in a python programmable --
>>>>>> which won't involve any fetching.
>>>>>>
>>>>>> Bastian,
>>>>>> You can create a cell locator in your programmable filter simply by:
>>>>>>
>>>>>> locator = vtk.vtkCellLocator()
>>>>>>
>>>>>>
>>>>>> Utkarsh
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, May 28, 2010 at 10:22 AM, Andy Bauer <andy.bauer at kitware.com>
>>>>>> wrote:
>>>>>>         
>>>>>>> My guess is that you'll want to use a filter to get access to the cell
>>>>>>> locator.  What's the desired output for this?
>>>>>>>
>>>>>>> You could also fetch the data set to the client and then use the vtk
>>>>>>> wrapped
>>>>>>> classes in paraview.vtk to use the cell locator if the class has been
>>>>>>> wrapped but the fetch operation should be used with caution.
>>>>>>>
>>>>>>> Andy
>>>>>>>
>>>>>>> On Thu, May 27, 2010 at 5:55 PM, Bastil2001 at yahoo.de
>>>>>>> <Bastil2001 at yahoo.de>
>>>>>>> wrote:
>>>>>>>           
>>>>>>>> Dear all,
>>>>>>>>
>>>>>>>> can I use vtkCellLocator from within Pyhon oder the Python
>>>>>>>> programmable
>>>>>>>> filter? If yes, how? Or do I need to write my own filter in c++?
>>>>>>>> Thanks.
>>>>>>>>
>>>>>>>> Regards Bastian
>>>>>>>> _______________________________________________
>>>>>>>> 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
>>>>>>>>             
>>>>>>> _______________________________________________
>>>>>>> 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
>>>>>>>
>>>>>>>
>>>>>>>           
>>>>>> _______________________________________________
>>>>>> 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
>>>>>>         
>>>>>       
>>>> _______________________________________________
>>>> 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
>>>>
>>>>
>>>>     
>>> _______________________________________________
>>> 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
>>>
>>>   
>>
>> _______________________________________________
>> Powered by www.kitware.com <http://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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20100601/73f9ed5a/attachment-0001.htm>


More information about the ParaView mailing list