예제 #1
0
    def _buildVtkBlocksActor(self, binfo):
        if binfo.multiblock_index is not None:
            eb = vtk.vtkExtractBlock()
            eb.SetInputConnection(self._reader.getVtkOutputPort())
            eb.AddIndex(binfo.multiblock_index)
            eb.Update()

            geometry = vtk.vtkCompositeDataGeometryFilter()
            geometry.SetInputConnection(0, eb.GetOutputPort(0))
            geometry.Update()

            mapper = vtk.vtkPolyDataMapper()
            mapper.SetInputConnection(geometry.GetOutputPort())
        else:
            mapper = vtk.vtkDataSetMapper()
            mapper.SetInputConnection(0, self._reader.getVtkOutputPort())
            mapper.ScalarVisibilityOff()

        mapper.InterpolateScalarsBeforeMappingOn()

        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
        actor.VisibilityOn()

        return actor
예제 #2
0
파일: MeshWindow.py 프로젝트: andrsd/otter
    def _addNodeSets(self):
        reader = self._load_thread.getReader()

        for index, ninfo in enumerate(reader.getNodeSets()):
            eb = vtk.vtkExtractBlock()
            eb.SetInputConnection(reader.getVtkOutputPort())
            eb.AddIndex(ninfo.multiblock_index)
            eb.Update()

            nodeset = NodeSetObject(eb)
            self._node_sets[ninfo.number] = nodeset
            self._vtk_renderer.AddViewProp(nodeset.actor)
            self._setNodeSetProperties(nodeset)
예제 #3
0
    def __init__(self, reader, **kwargs):
        super(ExodusSource, self).__init__(**kwargs)

        if not isinstance(reader, ExodusReader):
            raise mooseutils.MooseException('The supplied reader must be a '
                                            '"chigger.readers.ExodusReader", but a "{}" was '
                                            'provided.'.format(type(reader).__name__))

        self.__reader = reader
        self.__current_variable = None
        self._colormap = base.ColorMap()

        self.__extract_indices = []
        self.__vtkextractblock = vtk.vtkExtractBlock()
        self.__vtkextractblock.SetInputConnection(self.__reader.getVTKReader().GetOutputPort())

        self._required_filters = [filters.GeometryFilter()]
예제 #4
0
    def __init__(self, reader, **kwargs):
        super(ExodusSource, self).__init__(**kwargs)

        if not isinstance(reader, ExodusReader):
            raise mooseutils.MooseException('The supplied reader must be a '
                                            '"chigger.readers.ExodusReader", but a "{}" was '
                                            'provided.'.format(type(reader).__name__))

        self.__reader = reader
        self.__current_variable = None
        self._colormap = base.ColorMap()

        self.__extract_indices = []
        self.__vtkextractblock = vtk.vtkExtractBlock()
        self.__vtkextractblock.SetInputConnection(self.__reader.getVTKReader().GetOutputPort())

        self._required_filters = [filters.GeometryFilter()]
예제 #5
0
파일: MeshWindow.py 프로젝트: andrsd/otter
    def _addBlocks(self):
        camera = self._vtk_renderer.GetActiveCamera()
        reader = self._load_thread.getReader()

        for index, binfo in enumerate(reader.getBlocks()):
            eb = vtk.vtkExtractBlock()
            eb.SetInputConnection(reader.getVtkOutputPort())
            eb.AddIndex(binfo.multiblock_index)
            eb.Update()

            block = BlockObject(eb, camera)
            self._setBlockProperties(block)
            self._blocks[binfo.number] = block

            self._vtk_renderer.AddViewProp(block.actor)
            self._vtk_renderer.AddViewProp(block.silhouette_actor)
            # FIXME: make this work with multiple blocks
            self._geometry = block.geometry
예제 #6
0
def getStuctureActor(vtk_r, blockIndex, scalarField="p_rgh", scalarRange=None):
    """Return an actor with the ship structure
    """
    #--------------------------------- Structure
    structureOnly = vtk.vtkExtractBlock()
    structureOnly.SetInputConnection(vtk_r.GetOutputPort())
    structureOnly.AddIndex(blockIndex)

    structureDataFilter = vtk.vtkCompositeDataGeometryFilter()
    structureDataFilter.SetInputConnection(structureOnly.GetOutputPort())

    structureMapper = vtk.vtkDataSetMapper()
    structureMapper.SetInputConnection(structureDataFilter.GetOutputPort())
    colorMapper(structureMapper, scalarField, scalarRange)
    structureActor = vtk.vtkActor()
    structureActor.GetProperty().SetEdgeVisibility(0)
    structureActor.SetMapper(structureMapper)
    return structureActor
예제 #7
0
def getSymPlaneVtkActor(vtk_r,
                        blockIndex,
                        scalarField="alpha.water",
                        scalarRange=None):
    """return symmetry plane colored by field
    """
    #SymmetryPlane
    symPlane = vtk.vtkExtractBlock()
    symPlane.SetInputConnection(vtk_r.GetOutputPort())
    symPlane.AddIndex(blockIndex)
    symPlaneDataFilter = vtk.vtkCompositeDataGeometryFilter()
    symPlaneDataFilter.SetInputConnection(symPlane.GetOutputPort())
    symPlaneMapper = vtk.vtkDataSetMapper()
    symPlaneMapper.SetInputConnection(symPlaneDataFilter.GetOutputPort())
    colorMapper(symPlaneMapper, scalarField, scalarRange)

    symPlaneActor = vtk.vtkActor()
    symPlaneActor.GetProperty().SetEdgeVisibility(1)
    symPlaneActor.SetMapper(symPlaneMapper)
    return symPlaneActor
for i in range(0, N):
    name = reader.GetOutput().GetMetaData(i).Get(vtk.vtkCompositeDataSet.NAME())
    print(name)
    if (wall):
        if (name == "wall"):
            block_list_wall.append(i)
    if(surface):
        if (name == "wall" or name.split('_')[0] in ['outlet', 'inlet']):
            block_list.append(i)
    else:
        block_list.append(i)

print(block_list_wall)
if (wall):
    # extract a block
    wall_block = vtk.vtkExtractBlock()
    wall_block.SetInputConnection(reader.GetOutputPort())
    for b in block_list_wall:
        print(reader.GetOutput().GetMetaData(b).Get(vtk.vtkCompositeDataSet.NAME()))
        wall_block.AddIndex(b)
    wall_block.Update()
    print(wall_block.GetOutput().GetNumberOfBlocks(), " yo")
    print(wall_block.GetOutput().GetMetaData(0).Get(vtk.vtkCompositeDataSet.NAME()))
    append = vtk.vtkAppendFilter()
    append.MergePointsOn()
    for i in range(wall_block.GetOutput().GetNumberOfBlocks()):
        append.AddInputData(wall_block.GetOutput().GetBlock(i))
    append.Update()
    writer = vtk.vtkXMLUnstructuredGridWriter()
    writer.SetFileName(os.path.join(out_dir,'wall_outfile_node_test.vtu'))
    #writer.SetNumberOfTimeSteps(int(time_array.GetNumberOfTuples()))