[vtkusers] Strange problem with vtkExtractEdges (Python)

Marcus Stojek stojek at part-gmbh.de
Thu Feb 6 04:54:27 EST 2003


Hi,

I am using vtk and wxPython for viewing unstructured grids. First I wrote my
data into a vtk ascii file and then read them using the vtkreader.
Everything ok.
Then I switched to the version listed below.(Thanks to this list). Still
everything
works perfectly. Then I added the vtkGeometryFilter in order to draw the
edges of
the cells. The geometry itself is still ok but only a portion of edges are
showing up.
Connectivity of feature angle are not the point. It seems like only the
first third or
so edges are drawn. If I add more cells to my geometry, more edges are
drawn.
The array I use with SetVoidArray are contiguous.

If I use the vtkreader instead of creating the data itself, all edges are
showing up.

Any idea or hints?
Thanks marcus

Python 2.2 vtk4.0 WinNT


    def VTKViewer(self):
        nl=[]
        for n in self.nodes:
            nl.extend(n)
        narray=Numeric.array(nl,'f')
        el=[]
        el2=[]
        loc=0
        cloc=[]
        for e in range(self.elcount):
            et=EType[self.etypelist[e]]
            el.append(et.vtknnum)
            el.extend(map(lambda x:self.elements[e][x-1],et.ecknodes))
            el2.append(et.vtkid)
            cloc.append(loc)
            loc+=et.vtknnum +1
        earray=Numeric.array(el)
        ctarray=Numeric.array(el2,'c')
        locarray=Numeric.array(cloc)
#idtypes
        IdTArray=vtkIdTypeArray()
        IdTArray.SetVoidArray(earray,self.elcount,1)

#celltypes
        cidTArray=vtkUnsignedCharArray()
        cidTArray.SetVoidArray(ctarray,self.elcount,1)
#cell array
        vtkCArray=vtkCellArray()
        vtkCArray.SetCells(self.elcount,IdTArray)
#cell location
        vtkLocArray=vtkIntArray()
        vtkLocArray.SetVoidArray(locarray,self.elcount,1)
#grid
        grid=vtkUnstructuredGrid()
        grid.SetCells(cidTArray,vtkLocArray,vtkCArray)

        vpoints=vtkFloatArray()
        vpoints.SetNumberOfComponents(3)
        vpoints.SetVoidArray(narray,3*self.ncount,1)

        pointe = vtkPoints()
        pointe.SetData(vpoints)

        grid.SetPoints(pointe)

#---added feature that doesn't work
        gfilter=vtkGeometryFilter()
        gfilter.SetInput(grid)
        edges=vtkExtractEdges()
        edges.SetInput(gfilter.GetOutput())

        edgemap = vtkPolyDataMapper()
        edgemap.SetInput(edges.GetOutput())
        edgeActor = vtkActor()
        edgeActor.SetMapper(edgemap)
#----
        MapperSurf=vtkDataSetMapper()
        MapperSurf.SetInput(grid)
        MapperSurf.ScalarVisibilityOff()
        MapperSurf.SetResolveCoincidentTopologyToPolygonOffset()

        ActorSurf=vtkActor()
        ActorSurf.SetMapper(MapperSurf)
        PropSurf=vtkProperty()
        PropSurf.SetDiffuseColor(0.2,1.0,0.3)
        PropSurf.SetRepresentationToSurface()
        PropSurf.BackfaceCullingOff()
        PropSurf.FrontfaceCullingOff()
        ActorSurf.SetProperty(PropSurf)

        ren = vtkRenderer()

        win = wxMDIChildFrame(self.renwin, -1, 'test')
        widget = wxVTKRenderWindow.wxVTKRenderWindow(win, -1)

        widget.GetRenderWindow().AddRenderer(ren)
        ren.AddActor(edgeActor)
        ren.AddActor(ActorSurf)

        widget.Render()
        widget.Show(true)
#-----------------------------------------------------------------------




More information about the vtkusers mailing list