[vtkusers] Artifacts when displaying non convex polygons

John Biddiscombe jbiddiscombe at skippingmouse.co.uk
Thu Jul 12 18:23:51 EDT 2001


No no. There has never been concave polygon support AFAIK. You need to use 
a vtktrianglefilter if in doubt. (For rendering, polygons can be as 
degenerate or faulty in any way when simply defining them)

JB


At 19:56 12/07/2001, Randy Heiland wrote:
>Yes indeed - there seems to be something screwy here.  A bit more debugging
>reveals that down in vtkOpenGLPolyDataMapper, it simply attempts to draw this
>polygon using  glBegin(GL_POLYGON), and according to the OpenGL Pgming Guide,
>this polygon must be convex.
>
>So it would seem that either the VTK doc for vtkPolygon is incorrect, or there
>is some missing triangulation step, or your/my version of VTK is out-of-date
>and this problem has been fixed.
>
>--Randy
>
>On Jul 12, 10:03am, Jose Paulo Moitinho de Almeida wrote:
> > Subject: [vtkusers] Artifacts when displaying non convex polygons
> >
> > 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()
> >
> > _______________________________________________
> > This is the private VTK discussion list.
> > Please keep messages on-topic. Check the FAQ at:
><http://public.kitware.com/cgi-bin/vtkfaq>
> > Follow this link to subscribe/unsubscribe:
> > http://public.kitware.com/mailman/listinfo/vtkusers
> >-- End of excerpt from Jose Paulo Moitinho de Almeida
>
>
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: 
><http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers





More information about the vtkusers mailing list