[Paraview] Filter cell type from PolyData VTK file

David E DeMarle dave.demarle at kitware.com
Wed Dec 16 20:29:34 EST 2015


Last time this came up to my knowledge was:
http://markmail.org/thread/pbghkrm2zbubkj54

od = self.GetOutput()
od.ShallowCopy(self.GetInput())
cta = vtk.vtkIntArray()
cta.SetName("cell types")
cta.SetNumberOfComponents(1)
cta.SetNumberOfTuples(od.GetNumberOfCells())
od.GetCellData().AddArray(cta)
for x in xrange(0,od.GetNumberOfCells()):
  cta.SetValue(x,od.GetCell(x).GetCellType())

Which does what you originally suggested. There are probably shorter
incantations now in the numpy based python calculator.



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

On Wed, Dec 16, 2015 at 2:56 AM, Viktor Sip <viktor.sip at centrum.cz> wrote:

> Thanks for the helpful tips.
> First approach has the disadvantage that I need to specify the underlying
> points in each of the separate files, which leads again to some redundancy.
> But good to know.
> EnSight format looks promising though, I didn't know about it before.
>
> Thanks again,
> Viktor
>
> ______________________________________________________________
> > Od: Samuel Key <samuelkey at bresnan.net>
> > Komu: <paraview at paraview.org>
> > Datum: 15.12.2015 23:47
> > Předmět: Re: [Paraview] Filter cell type from PolyData VTK file
> >
> >Victor,
> >
> >
> >
> >Off the top of my head, I can think of three different ways to do this:
> >
> >
> >
> >(1) Put each cell-type in a separate *.vtp file. You can then load each
> cell-type separately or you can load them with a *.pvd meta-file (sample
> attached) as "one object" and use the Extract Block filter to display any
> number and combination of cell-types.
> >
> >
> >
> >(2) You can use the EnSight format for your results. This format has a
> Part-construct that allows mixed-cell objects and that can be used to
> organize your cells any way you like, for example, by cell-type, by
> material, by sub-assemblies, ... Again, the Extract Block filter can be
> used to display any number and combination of 'Parts.'
> >
> >
> >
> >(3) When you write the *.vtp file assign each cell its vtk-cell-type
> number as data, and then use the Threshold filter applied to the cell's
> cell-type value.
> >
> >
> >
> >There are probably other ways as well.
> >
> >
> >
> >Hope this helps.
> >
> >
> >
> >Sam Key
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >On 12/15/2015 2:54 PM, Viktor Sip wrote:
> >
> >
> >
> >Dear all,
> >
> >
> >
> >is there a way to filter and show only a specific cell type?
> >
> >
> >
> >In my application I am exporting a PolyData VTK file containing some
> Polys and Lines. When imported into Paraview, both Polys and Lines are
> shown, and I did not find a simple way to show only Polys.
> >
> >What I can do is to export additional CellData array with a number
> specifying cell type and then apply Treshold in Paraview. However that
> seems redundant, as the type is already stored in the file somewhere.
> >
> >So my question is, is there a direct way?
> >
> >
> >
> >Simplified example of the exported VTK file is attached.
> >
> >
> >
> >Kind regards,
> >
> >Viktor
> >
> >
> >
> >
> >
> >
> >
> >_______________________________________________ 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
> Search the list archives at: http://markmail.org/search/?q=ParaView
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/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
> >
> >Search the list archives at: http://markmail.org/search/?q=ParaView
> >
> >Follow this link to subscribe/unsubscribe:
> >http://public.kitware.com/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
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20151216/35759245/attachment.html>


More information about the ParaView mailing list