[vtkusers] How to extract poly data from an unstructured grid

Dominik Szczerba dominik at itis.ethz.ch
Thu Oct 9 07:40:05 EDT 2008


Probably you forgot to set input or call Update() somewhere, I am unable to 
see quickly in the long code (next time only post minimal required code 
please)

Dominik

On Thursday 09 October 2008 12:49:43 pm Elvis Dowson wrote:
> Hi Dominik,
>                           I'm getting the following error in the
> terminal window, when I run the code.
>
> elvis-dowsons-macbook-pro:~ elvis$ wish
> % ERROR: In /Users/elvis/Tool/vtk-5.x/src/VTK/Filtering/
> vtkAlgorithm.cxx, line 739
> vtkPainterPolyDataMapper (0x89aa00): Attempt to get output port index
> 0 for an algorithm with 0 output ports.
>
> ERROR: In /Users/elvis/Tool/vtk-5.x/src/VTK/Filtering/
> vtkDemandDrivenPipeline.cxx, line 722
> vtkStreamingDemandDrivenPipeline (0x6130f20): Input port 0 of
> algorithm vtkPolyDataNormals(0x61309c0) has 0 connections but is not
> optional.
>
> ERROR: In /Users/elvis/Tool/vtk-5.x/src/VTK/Filtering/
> vtkDemandDrivenPipeline.cxx, line 722
> vtkStreamingDemandDrivenPipeline (0x6130f20): Input port 0 of
> algorithm vtkPolyDataNormals(0x61309c0) has 0 connections but is not
> optional.
>
> ERROR: In /Users/elvis/Tool/vtk-5.x/src/VTK/Filtering/
> vtkDemandDrivenPipeline.cxx, line 722
> vtkStreamingDemandDrivenPipeline (0x6130f20): Input port 0 of
> algorithm vtkPolyDataNormals(0x61309c0) has 0 connections but is not
> optional.
>
> I have looked at the test example for vtkDataSetSurfaceFilter
> http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/IO/Testing/Tcl/Tes
>tXMLUnstructuredGridIO.tcl?root=VTK&content-type=text/plain
>
> What could be causing it?
>
> Best regards,
>
> Elvis Dowson
>
> Example TCL code
>
> # This example shows how to manually construct triangle cell using
> unstructured grids
> # and display its surface normal.
> #
>
> package require vtk
> package require vtkinteraction
>
> # Create an unstructured grids containing a triangle cell.
> vtkPoints trianglePoints
>    trianglePoints SetNumberOfPoints 3
>    trianglePoints InsertPoint 0 0 0 0
>    trianglePoints InsertPoint 1 1 0 0
>    trianglePoints InsertPoint 2 .5 .5 0
> vtkTriangle aTriangle
>    [aTriangle GetPointIds] SetId 0 0
>    [aTriangle GetPointIds] SetId 1 1
>    [aTriangle GetPointIds] SetId 2 2
> vtkUnstructuredGrid aTriangleGrid
>    aTriangleGrid Allocate 1 1
>    aTriangleGrid InsertNextCell [aTriangle GetCellType] [aTriangle
> GetPointIds]
>    aTriangleGrid SetPoints trianglePoints
> vtkDataSetMapper aTriangleMapper
>    aTriangleMapper SetInput aTriangleGrid
> vtkActor aTriangleActor
>    aTriangleActor SetMapper aTriangleMapper
>    aTriangleActor AddPosition 4 0 2
>    [aTriangleActor GetProperty] SetDiffuseColor .3 1 .5
>
> # Create an arrow glyph to represent the surface normal for the
> triangle cell.
>
> vtkDataSetSurfaceFilter triangleCellDataSetSurfaceFilter
>    triangleCellDataSetSurfaceFilter SetInput aTriangleGrid
>
> vtkPolyDataMapper trianglePolyData
>    trianglePolyData SetInputConnection
> [triangleCellDataSetSurfaceFilter GetOutputPort]
>
> vtkPolyDataNormals triangleCellNormals
>    # TODO: Fix this
>    triangleCellNormals SetInputConnection [trianglePolyData
> GetOutputPort]
>    triangleCellNormals ComputePointNormalsOff
>    triangleCellNormals ComputeCellNormalsOn
>
> # Specify the shape of the glyph
> vtkArrowSource arrowSource
>
> vtkGlyph3D arrowGlyph
>    arrowGlyph ScalingOn
>    arrowGlyph SetScaleFactor 0.7
>    arrowGlyph SetVectorModeToUseNormal
>    arrowGlyph SetScaleModeToScaleByVector
>    arrowGlyph OrientOn
>    arrowGlyph SetSourceConnection [arrowSource GetOutputPort]
>    arrowGlyph SetInputConnection [triangleCellNormals GetOutputPort]
>
> vtkDataSetMapper arrowGlyphMapper
>    arrowGlyphMapper SetInputConnection [arrowGlyph GetOutputPort]
>
> vtkActor glyphActor
>    glyphActor SetMapper arrowGlyphMapper
>
>
> # Create the usual rendering stuff.
> vtkRenderer ren1
> vtkRenderWindow renWin
>    renWin AddRenderer ren1
>    renWin SetSize 300 150
> vtkRenderWindowInteractor iren
>    iren SetRenderWindow renWin
>
> ren1 SetBackground .1 .2 .4
>
> ren1 AddActor aTriangleActor
> ren1 AddActor glyphActor
>
> ren1 ResetCamera
> ren1 ResetCameraClippingRange
>
> renWin Render
>
> # render the image
> #
> iren AddObserver UserEvent {wm deiconify .vtkInteract}
> iren Initialize
> wm withdraw .
>
> On Oct 9, 2008, at 12:43 PM, Dominik Szczerba wrote:
> > Sorry, ExtractSurface is Paraview name.
> > In vtk it is vtkDataSetSurfaceFilter.
> >
> > Dominik



-- 
Dominik Szczerba, Ph.D.
Computational Physics Group
Foundation for Research on Information Technologies in Society
http://www.itis.ethz.ch



More information about the vtkusers mailing list