Re: [Paraview] [EXT] Re: vtkPointDataToCellData but only for selected PointData

2018-05-02 Thread Dennis Conklin
David,

Thanks very much for that – that works and works well.   My filter now runs ~15 
times faster than it did before I incorporated this.

I’m always impressed by the helpfulness of this board.

Dennis


From: David E DeMarle [mailto:dave.dema...@kitware.com]
Sent: Monday, April 30, 2018 3:50 PM
To: Dennis Conklin <dennis_conk...@goodyear.com>
Cc: Paraview (parav...@paraview.org) <parav...@paraview.org>
Subject: Re: [EXT] Re: [Paraview] vtkPointDataToCellData but only for selected 
PointData

This does what you are looking for:

import vtk



# copy entire structure across

self.GetOutputDataObject(0).ShallowCopy(self.GetInputDataObject(0,0))



# use pass arrays to extract a copy with one array of interest

myArrays=vtk.vtkPassArrays()

myArrays.SetInputDataObject(self.GetInputDataObject(0,0))

myArrays.ClearArrays()

myArrays.AddPointDataArray('DISPL')

myArrays.AddCellDataArray('')

myArrays.AddFieldDataArray('')



# use point2cell to operate on the one array we care about

p2c = vtk.vtkPointDataToCellData()

p2c.SetInputConnection(myArrays.GetOutputPort())

p2c.Update()



# iterate over blocks and copy in the result

iter=dsa.MultiCompositeDataIterator([p2c.GetOutputDataObject(0), output])

for  in_block,  output_block in iter:

 
output_block.GetCellData().AddArray(in_block.VTKObject.GetCellData().GetArray('DISPL'))




David E DeMarle
Kitware, Inc.
Principal Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909

On Mon, Apr 30, 2018 at 8:52 AM, Dennis Conklin 
<dennis_conk...@goodyear.com<mailto:dennis_conk...@goodyear.com>> wrote:
David,

I have not called filters within the Programmable Filter before and I am not 
getting things hooked up correctly. My attempt is attached.   Clearly, I do 
not understand how to hook the output of 1 filter to the input of the next 
because I’m getting to the end and getting something with no blocks and no 
cells.

Any hints?

Dennis





From: David E DeMarle 
[mailto:dave.dema...@kitware.com<mailto:dave.dema...@kitware.com>]
Sent: Tuesday, April 10, 2018 10:14 AM
To: Dennis Conklin 
<dennis_conk...@goodyear.com<mailto:dennis_conk...@goodyear.com>>
Cc: Paraview (parav...@paraview.org<mailto:parav...@paraview.org>) 
<parav...@paraview.org<mailto:parav...@paraview.org>>
Subject: [EXT] Re: [Paraview] vtkPointDataToCellData but only for selected 
PointData

 WARNING - External email; exercise caution.



The pass arrays filter comes to mind.

If creating withing your python programmable filter it will be called 
vtk.vtkPassArrays then follow that with a vtk.vtkPointDataToCellData.



David E DeMarle
Kitware, Inc.
Principal Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909

On Tue, Apr 10, 2018 at 10:07 AM, Dennis Conklin 
<dennis_conk...@goodyear.com<mailto:dennis_conk...@goodyear.com>> wrote:
All,

Well, this list solved my problem so easily (and made me feel slightly less 
than the sharpest pencil in the box) yesterday, so I thought I’d try again.

I am doing some Python calcs inside a programmable filter and some of the 
results I want to average from the Points onto the Cells.   But,  I don’t want 
all my PointData moved over to CellData – I want to transfer some of them over 
within my Filter.

Right now I’m looping thru all the elements and finding all their nodes, then 
averaging them and assigning to the cells.  It is dog slow and is choking off 
the usefulness of this filter.

Is there anything like vtkPointDataToCellData that lets me specify which 
quantities to convert – could I do something tricky like store original list of 
PointData, make up a new list, then run PointDataToCellData, then restore the 
list of PointData ??

I realize this may have all sorts of unexpected side effects, so I’m just 
asking!

Thanks again, this group is great!

Dennis

___
Powered by 
www.kitware.com<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com=01%7C01%7Cdennis_conklin%40goodyear.com%7Ccdd327b7b83443c9224908d59eed5011%7C939e896692854a9a9f040887efe8aae0%7C0=bFpbI9%2F4eHwIrhf5Sd9f2ynzY%2FvWHiDIlONgpO13J0A%3D=0>

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com%2Fopensource%2Fopensource.html=01%7C01%7Cdennis_conklin%40goodyear.com%7Ccdd327b7b83443c9224908d59eed5011%7C939e896692854a9a9f040887efe8aae0%7C0=mMExlGeMQKwAob7IUdPyH60WLz420BhmCRMs%2Fp8aLf4%3D=0>

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fparaview.org%2FWiki%2FParaView=01%7C01%7Cdennis_conklin%40goodyear.com%7Ccdd327b7b83443c9224908d59eed5011%7C939e896692854a9a9f040887efe8aae0%7C0=Myi6SWCBnXGSlGEpOScpW0tc83nT6ue%2FjmtzC9G%2FafE%3

Re: [Paraview] [EXT] Re: vtkPointDataToCellData but only for selected PointData

2018-04-30 Thread David E DeMarle
This does what you are looking for:

import vtk


# copy entire structure across

self.GetOutputDataObject(0).ShallowCopy(self.GetInputDataObject(0,0))


# use pass arrays to extract a copy with one array of interest

myArrays=vtk.vtkPassArrays()

myArrays.SetInputDataObject(self.GetInputDataObject(0,0))

myArrays.ClearArrays()

myArrays.AddPointDataArray('DISPL')

myArrays.AddCellDataArray('')

myArrays.AddFieldDataArray('')


# use point2cell to operate on the one array we care about

p2c = vtk.vtkPointDataToCellData()

p2c.SetInputConnection(myArrays.GetOutputPort())

p2c.Update()


# iterate over blocks and copy in the result

iter=dsa.MultiCompositeDataIterator([p2c.GetOutputDataObject(0), output])

for  in_block,  output_block in iter:

 
output_block.GetCellData().AddArray(in_block.VTKObject.GetCellData().GetArray('DISPL'))




David E DeMarle
Kitware, Inc.
Principal Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909

On Mon, Apr 30, 2018 at 8:52 AM, Dennis Conklin <dennis_conk...@goodyear.com
> wrote:

> David,
>
>
>
> I have not called filters within the Programmable Filter before and I am
> not getting things hooked up correctly. My attempt is attached.
> Clearly, I do not understand how to hook the output of 1 filter to the
> input of the next because I’m getting to the end and getting something with
> no blocks and no cells.
>
>
>
> Any hints?
>
>
>
> Dennis
>
>
>
>
>
>
>
>
>
>
>
> *From:* David E DeMarle [mailto:dave.dema...@kitware.com]
> *Sent:* Tuesday, April 10, 2018 10:14 AM
> *To:* Dennis Conklin <dennis_conk...@goodyear.com>
> *Cc:* Paraview (parav...@paraview.org) <parav...@paraview.org>
> *Subject:* [EXT] Re: [Paraview] vtkPointDataToCellData but only for
> selected PointData
>
>
>
>  *WARNING - External email; exercise caution.*
>
>
>
> The pass arrays filter comes to mind.
>
>
>
> If creating withing your python programmable filter it will be called
> vtk.vtkPassArrays then follow that with a vtk.vtkPointDataToCellData.
>
>
>
>
>
>
> David E DeMarle
> Kitware, Inc.
> Principal Engineer
> 21 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-881-4909
>
>
>
> On Tue, Apr 10, 2018 at 10:07 AM, Dennis Conklin <
> dennis_conk...@goodyear.com> wrote:
>
> All,
>
>
>
> Well, this list solved my problem so easily (and made me feel slightly
> less than the sharpest pencil in the box) yesterday, so I thought I’d try
> again.
>
>
>
> I am doing some Python calcs inside a programmable filter and some of the
> results I want to average from the Points onto the Cells.   But,  I don’t
> want all my PointData moved over to CellData – I want to transfer some of
> them over within my Filter.
>
>
>
> Right now I’m looping thru all the elements and finding all their nodes,
> then averaging them and assigning to the cells.  It is dog slow and is
> choking off the usefulness of this filter.
>
>
>
> Is there anything like vtkPointDataToCellData that lets me specify which
> quantities to convert – could I do something tricky like store original
> list of PointData, make up a new list, then run PointDataToCellData, then
> restore the list of PointData ??
>
>
>
> I realize this may have all sorts of unexpected side effects, so I’m just
> asking!
>
>
>
> Thanks again, this group is great!
>
>
>
> Dennis
>
>
> ___
> Powered by www.kitware.com
> <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com=01%7C01%7Cdennis_conklin%40goodyear.com%7Ccdd327b7b83443c9224908d59eed5011%7C939e896692854a9a9f040887efe8aae0%7C0=bFpbI9%2F4eHwIrhf5Sd9f2ynzY%2FvWHiDIlONgpO13J0A%3D=0>
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
> <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.kitware.com%2Fopensource%2Fopensource.html=01%7C01%7Cdennis_conklin%40goodyear.com%7Ccdd327b7b83443c9224908d59eed5011%7C939e896692854a9a9f040887efe8aae0%7C0=mMExlGeMQKwAob7IUdPyH60WLz420BhmCRMs%2Fp8aLf4%3D=0>
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
> <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fparaview.org%2FWiki%2FParaView=01%7C01%7Cdennis_conklin%40goodyear.com%7Ccdd327b7b83443c9224908d59eed5011%7C939e896692854a9a9f040887efe8aae0%7C0=Myi6SWCBnXGSlGEpOScpW0tc83nT6ue%2FjmtzC9G%2FafE%3D=0>
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
> <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmarkmail.org%2Fsearch%2F%3Fq%3DParaView=01%7C01%7Cdennis