[vtkusers] Artifacts when displaying non convex polygons

Jose Paulo Moitinho de Almeida moitinho at civil.ist.utl.pt
Mon Jul 16 05:59:38 EDT 2001


On Monday 16 July 2001 10:18, Jose Paulo Moitinho de Almeida wrote:
> On Friday 13 July 2001 18:26, John Biddiscombe wrote:
> > Yes, and No. I mean polygons can be non convex and all the geometric
> > operations will work fine, but rendering them is not supported (and
> > hasn't ever worked as far as I've found).
>
> OK. Thanks.
>
> It is clear for me now and I can use the vtktrianglefilter.
>
> Would it be possible to avoid this doubt in "future generations"?
>
> Regards
>

Sorry for posting incomplete answers....

The answer to my initial question regarding degenerate polygons seems to be a 
definite no it is not possible, as you can verify in the new version of my 
check code when you set offset to  zero.

Regards

------------------------------------------
#!/usr/bin/env python
import os

from libVTKCommonPython import *
from libVTKGraphicsPython import *
from libVTKImagingPython import *

ren = vtkRenderer()
renWin = vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetSize(400,400)

iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

offset = 0.01

points = vtkPoints()
points.SetNumberOfPoints(6)
points.InsertPoint(0,0,0,0)
points.InsertPoint(1,1,1,0)
points.InsertPoint(2,0+offset,1,0)
points.InsertPoint(3,0,2,0)
points.InsertPoint(4,-1,1,0)
points.InsertPoint(5,0-offset,1,0)

polygon = vtkPolygon()
polygon.GetPointIds().SetNumberOfIds(6)

polygon.GetPointIds().SetId(0,0)
polygon.GetPointIds().SetId(1,1)
polygon.GetPointIds().SetId(2,2)
polygon.GetPointIds().SetId(3,3)
polygon.GetPointIds().SetId(4,4)
polygon.GetPointIds().SetId(5,5)

polygonGrid = vtkUnstructuredGrid()
polygonGrid.Allocate(1,1)
polygonGrid.InsertNextCell(polygon.GetCellType(), polygon.GetPointIds())
polygonGrid.SetPoints(points)

geom = vtkGeometryFilter()
geom.SetInput(polygonGrid)

triangles = vtkTriangleFilter()
triangles.SetInput(geom.GetOutput())

polygonMapper = vtkDataSetMapper()
polygonMapper.SetInput(triangles.GetOutput())

polygonActor = vtkActor()
polygonActor.SetMapper(polygonMapper)

ren.AddActor(polygonActor)

ren.ResetCameraClippingRange()
renWin.Render()

iren.Initialize()

iren.Start()




More information about the vtkusers mailing list