[vtkusers] Re: Draw and Color Polygons

Mike Jackson imikejackson at gmail.com
Sun Sep 30 18:23:23 EDT 2007


You need to triangulate your polygon. Your data is just a bunch of  
points ordered counter-clockwise. You can try the vtkDelauney2D  
filter to try and triangulate the 3 polygons. If that doesn't work  
(and don't be surprised if it does not) there you may have to do  
looking elsewhere for triangulation routines. There is a decent one  
from the "Quake" project from CMU. I have used this successfully many  
times but the code is really old and takes some adaptation to get  
working with VTK. Report back on you progress.
    Can you send your data set to the list? or me directly. I may be  
able to triangulate it for you if that is all you need.


-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


On Sep 30, 2007, at 6:10 PM, Janny Dong wrote:

> 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.
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/ 
> Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070930/45fea5ab/attachment.htm>


More information about the vtkusers mailing list