[vtkusers] Contour Widget line as a tube

igorznt igorznt at gmail.com
Thu May 13 17:45:50 EDT 2010


   Thanks for help, it  works. The code is bellow. Now I have another
problem, how could i fill the tube?
        path = self.contourRep.GetContourRepresentationAsPolyData()
        lines = path .GetLines()
        
        points = vtk.vtkPoints()
        for cellIdx in range(lines.GetNumberOfCells()):
            
            npts = 0
            pts = vtk.vtkIdList()
            path.GetCellPoints(npts, pts)
            
            for i in range(pts.GetNumberOfIds()):
                pt0 = path.GetPoints().GetPoint(pts.GetId(i))
                points.InsertNextPoint(pt0)
                   
        ps = vtk.vtkParametricSpline()
        ps.SetPoints(points)
        
        pfs = vtk.vtkParametricFunctionSource()
        pfs.SetParametricFunction(ps)
        pfs.SetUResolution(100)
        
        tubeFilter = vtk.vtkTubeFilter()
        tubeFilter.SetNumberOfSides(500)
        tubeFilter.SetRadius(2)
        tubeFilter.SetInputConnection(pfs.GetOutputPort())
        
        tubeMapper = vtk.vtkPolyDataMapper()
        tubeMapper.SetInputConnection(tubeFilter.GetOutputPort())
        
        tubeActor = vtk.vtkActor()
        tubeActor.SetMapper(tubeMapper)
        
        renderer.AddActor(tubeActor)



David Doria-2 wrote:
> 
> On Thu, May 13, 2010 at 4:20 PM, igorznt <igorznt at gmail.com> wrote:
>>
>> Does anyone knows how to make the line of the contour widget a tube? By
>> default it is a strip, its totally clear when you increase the line
>> width. i
>> read lots of threads in this forum and the vtk doc but i didnt find a way
>> to
>> do it.
> 
> At a quick glance it looks like you'll want to display the output of
> the function:
> 
> tubeMapper->SetInput(vtkContourRepresentation::SafeDownCast(contourWidget->GetRepresentation())->GetContourRepresentationAsPolyData());
> 
> See if that helps you get started - let us know what you find out.
> 
> Thanks,
> 
> David
> _______________________________________________
> 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 VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 
> 

-- 
View this message in context: http://old.nabble.com/Contour-Widget-line-as-a-tube-tp28552139p28552956.html
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list