[vtkusers] Re: Draw and Color Polygons

Janny Dong janny.dong at gmail.com
Sun Sep 30 18:10:30 EDT 2007


Hi Eugene,

Thanks for your reply. The data I am using are more than 1000 points
(latitudes and longitudes), 3 polygons. The polygons are ordered
counter-clockwise. I put them into a .vtk file and read it from my code. The
main part of my code to do this is as follows.

//Read the vtk data file.
vtkPolyDataReader *usa = vtkPolyDataReader::New();
usa->SetFileName("greatlakes.vtk");

//clean polydata
vtkCleanPolyData *cleaner = vtkCleanPolyData::New();
    cleaner->SetInputConnection(usa->GetOutputPort());
    cleaner->SetTolerance(0.005);

//apply triangle filter
    vtkTriangleFilter *triangle = vtkTriangleFilter::New();
    triangle->SetInputConnection(cleaner->GetOutputPort());

//map to polydata mapper
    vtkSmartPointer<vtkPolyDataMapper> polyMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
    polyMapper->SetInputConnection(triangle->GetOutputPort());

I am guessing the polygon is not convex. Is there anything I can do to draw
the polygons properly?

Janny



On 9/30/07, Eugene Dorfman <justadreamer2007 at gmail.com> wrote:
>
> Please attach some code dealing with your polygons - how are you trying to
> draw them.  Seems that the order of the points is either incorrect when
> specifying them to the vtkPolyData - or you are using the triangulation
> strip.   All you need to do is to load a polygon into a cellarray - and
> define it as a single cell - than pass it to vtkPolyData.  It also might be
> that the polygon shape is not convex - that is why.  Some code would be
> helpful.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070930/daaae734/attachment.htm>


More information about the vtkusers mailing list