[vtkusers] Artifacts when displaying non convex polygons

Jose Paulo Moitinho de Almeida moitinho at civil.ist.utl.pt
Thu Jul 12 05:03:32 EDT 2001


Hello 

When I was investigating some artifacts that I got when rendering polygons I 
reduced my doubt to the following questions:

1) The manual says "vtkPolygon is a concrete implementation of vtkCell to 
represent a 2D n-sided polygon. The polygons cannot have any internal holes, 
and cannot self-intersect." Thus I was expecting that the code attached would 
draw "approximatelly" two triangles like this (note that points 2 and 5 are 
close, but are not coincident):

 /|
 ---
  |/


Instead it draws:

 /|
  --
 \ /

Is this a problem (when rendering?) or am I doing something wrong?

2 ) If I merge points 2 and 5 is it a "legal" polygon? The sides touch, but 
do not cross, strictly that is intersecting, but....


Regards


Notes:

1) When I was looking for the source of the problem I did some intersections 
and the result of intersecting the "ilegal" polygon with a plane is correct. 
That is why I am trying to blame the renderer.

2) If I change the order of the points to 2,3,4,5,0,1 the triangles are 
correctly displayed, even when the points are merged.

--------------Cut here---------------------
#!/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)

points = vtkPoints()
points.SetNumberOfPoints(6)
points.InsertPoint(0,0,0,0)
points.InsertPoint(1,1,1,0)
points.InsertPoint(2,0.1,1,0)
points.InsertPoint(3,0,2,0)
points.InsertPoint(4,-1,1,0)
points.InsertPoint(5,-0.1,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)

polygonMapper = vtkDataSetMapper()
polygonMapper.SetInput(polygonGrid)

polygonActor = vtkActor()
polygonActor.SetMapper(polygonMapper)

ren.AddActor(polygonActor)

ren.ResetCameraClippingRange()
renWin.Render()

iren.Initialize()

iren.Start()




More information about the vtkusers mailing list