[Paraview] Ensight Imort Multiblock Datasets

Berk Geveci berk.geveci at kitware.com
Tue Jun 23 11:55:25 EDT 2009


I had some fun doing this in Python. Here is a script that creates a
Python filter for each block and names it with the block name. To run
it, you need to select the Ensight reader and then run this script
using the Python Shell under the Tools menu. This requires cvs
ParaView unfortunately as I had to make some minor changes to make it
work.

Another hint: remember that you can turn on/off the visibility of
multiple object by selecting them (using shift+click or control+click)
in the pipeline browser and clicking on the visibility icon (the eye)
of one of them.

-berk


from paraview.simple import *

def extract_block(source, outputType, name, di, idx):
    if name:
        pf = ProgrammableFilter(source, registrationName=name)
    else:
        pf = ProgrammableFilter(source)
    pf.OutputDataSetType = outputType
    pf.Script = """
input = self.GetInputDataObject(0, 0)
self.GetOutputDataObject(0).ShallowCopy(input.GetBlock(%d))""" % idx
    if outputType == 'vtkImageData' or outputType ==
'vtkStructuredGrid' or outputType == 'vtkRectilinearGrid':
        pf.RequestInformationScript = """
from paraview import util
util.SetOutputWholeExtent(self, %r)""" % list(di.GetExtent())
    Show(pf)

source = GetActiveSource()
if not source:
    raise RuntimeError, "This macro needs an active pipeline object"
source.UpdatePipeline()
cdi = source.GetDataInformation().GetCompositeDataInformation()
blocks = cdi.GetNumberOfChildren()
for i in range(blocks):
    di = cdi.GetDataInformation(i)
    eb = extract_block(source, di.GetDataClassName(), cdi.GetName(i), di, i)
Hide(source)


On Sun, Jun 21, 2009 at 6:17 AM, BastiL2001<bastil2001 at yahoo.de> wrote:
>
> A nice sunday to everybody,
>
> first of all I have to thank all the Paraview developers who made the tool what it is today. After some correspondence on the mailing list I am able to use the tool with our models today the way I like :-).
>
> One thing I am not so happy with at the moment is how our Ensight-Multiblock-Data gets imported. An import generates one Multiblock-Dataset with every Ensight-Zone as a block. I have lots of zones and need to extract them all by hand. Maybe this could be scripted. Another problem is I use filter that do not work with multiblock-datasets quite often (resampleWithDataset, AppendAttributes,...). So in my eyes most effektive way of importing would be: Not generate ONE Multiblock-Dataset but generate an individuell unstructered Dataset for each Part of the ensight-File and name them after the Ensight Part names - this will give you e.g. 80 Parts in the Tree if you have 80 Ensight parts instead of one. I would not have to extract blocks afterwards. This duplicates the whole model. Furthermore, if I need unstructed Datasets, I need to run mergeBlocks additionally, producing even more Parts. All of this would not be essential if we had such an import filter.
>  However, I do not really know how to modify the filter. Maybe someone can comment on that.
>
> Regards BastiL
>
>
>
> _______________________________________________
> 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