<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>RE: [vtkusers] best way to represent a (planar) irregular polygon ?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<BR>

<P><FONT SIZE=2>Thanks a lot Amy, I could of swore I tried that combination of filters<BR>
but nevermind.<BR>
<BR>
And sorry for misunderstanding the original post.<BR>
<BR>
Henrik<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: Amy Squillacote [<A HREF="mailto:ahs@cfdrc.com">mailto:ahs@cfdrc.com</A>]<BR>
Sent: Wed 6/4/2008 4:03 PM<BR>
To: Marie-Gabrielle Vallet<BR>
Cc: Henrik Westerberg; vtkusers@vtk.org<BR>
Subject: Re: [vtkusers] best way to represent a (planar) irregular polygon ?<BR>
<BR>
Henrik,<BR>
<BR>
If you want to extract the edges of your unstructured grid dataset, you<BR>
don't need a geometry filter or a triangle filter. (The geometry filter<BR>
is the reason you're not seeing interior points; for 3D cells, it<BR>
extracts the 2D faces used by only one 3D cells. This works out to be<BR>
the boundary faces. This is described in the online documentation for<BR>
this class:<BR>
<A HREF="http://www.vtk.org/doc/nightly/html/classvtkGeometryFilter.html">http://www.vtk.org/doc/nightly/html/classvtkGeometryFilter.html</A>.) To put<BR>
tubes around the edges in your dataset, set up a pipeline like the<BR>
following (shown in c++)<BR>
<BR>
vtkUnstructuredGridReader *reader = vtkUnstructuredGridReader::New();<BR>
... set up the rest of the reader's parameters ...<BR>
<BR>
vtkExtractEdges *edges = vtkExtractEdges::New();<BR>
edges-&gt;SetInputConnection(reader-&gt;GetOutputPort());<BR>
... set up the rest of this filter's parameters ...<BR>
<BR>
vtkTubeFilter *tubes = vtkTubeFilter::New();<BR>
tubes-&gt;SetInputConnection(tubes-&gt;GetOutputPort());<BR>
... set up the rest of this filter's parameters ...<BR>
<BR>
vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<BR>
mapper-&gt;SetInputConnection(tubes-&gt;GetOutputPort());<BR>
...<BR>
<BR>
vtkActor *actor = vtkActor::New();<BR>
actor-&gt;SetMapper(mapper);<BR>
...<BR>
<BR>
- Amy<BR>
<BR>
Marie-Gabrielle Vallet wrote:<BR>
&gt; Henrik,<BR>
&gt;<BR>
&gt; That's not a similar problem. A polygon is a surface, discretized with<BR>
&gt; triangles. For a non-convex polygon, the triangles have to be filtered<BR>
&gt; before rendering, to correct their orientation I guess.<BR>
&gt;<BR>
&gt; Your grid is volumetric. There is no triangle to filter. I don't know<BR>
&gt; how to visualise your grid inside. And I'm not sure you want to see<BR>
&gt; all these lines.<BR>
&gt;<BR>
&gt; A TubeFilter generates a surface around a line. There is nothing<BR>
&gt; inside. You can cap both ends. But you can only see the exterior<BR>
&gt; surface because their is no volume.<BR>
&gt;<BR>
&gt; Marie-Gabrielle Vallet<BR>
&gt;<BR>
&gt; 2008/6/4 Henrik Westerberg &lt;henrik.westerberg@crg.es<BR>
&gt; &lt;<A HREF="mailto:henrik.westerberg@crg.es">mailto:henrik.westerberg@crg.es</A>&gt;&gt;:<BR>
&gt;<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; Hello vtkusers,<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; I have been having a similar problem rendering a cube made up of<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; four smaller cubes.<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; I would like to be able to visualise the interior nodes but they<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; disappear<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; depending on the degree of the vertex. I have included a sample<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; screen shot.<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; What I want to eventually do is extract the edges to a TubeFilter<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; and color<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; the tubes depending on some scalar values, but I always only get<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; the exterior<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; lines.<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; Also I will eventually need to visualise tetrahedra within a surface.<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; My current pipeline looks like:<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; reader = vtkUnstructuredGridReader()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; reader.SetFileName(uginput)<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; geoFil = new vtkGeometryFilter()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; geoFil.SetInput(reader.GetOutput())<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; triFil = new vtkTriangleFilter()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; triFil.SetInput(geoFil.GetOutput())<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; gridMapper = vtkDataSetMapper()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; gridMapper.SetInput(triFil.GetOutput())<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; gridActor = vtkActor()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; gridActor.SetMapper(gridMapper)<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; thanks for your time,<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; Henrik<BR>
&gt;<BR>
&gt;<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; -----Original Message-----<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; From: vtkusers-bounces@vtk.org &lt;<A HREF="mailto:vtkusers-bounces@vtk.org">mailto:vtkusers-bounces@vtk.org</A>&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; on behalf of Marie-Gabrielle Vallet<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; Sent: Fri 5/30/2008 9:21 PM<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; To: briand@aracnet.com &lt;<A HREF="mailto:briand@aracnet.com">mailto:briand@aracnet.com</A>&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; Cc: vtkusers@vtk.org &lt;<A HREF="mailto:vtkusers@vtk.org">mailto:vtkusers@vtk.org</A>&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; Subject: Re: [vtkusers] best way to represent a (planar) irregular<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; polygon ?<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; Hi Brian,<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; I remember having some problem to render a non-convex polygon. I<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; found an<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; example, I can't find again where it comes from, and I worked on<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; it. Finally<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; the following python script does what you want.<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; You should try to add two filters : a GeometryFilter and a<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; TriangleFilter.<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; Marie-Gabrielle<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #!/usr/bin/env python<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # This example shows how to visualize polygons, convex or not.<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import vtk<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Define a set of points - these are the ordered polygon vertices<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; polygonPoints = vtk.vtkPoints()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; polygonPoints.SetNumberOfPoints(6)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; polygonPoints.InsertPoint(0, 0, 0, 0)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; polygonPoints.InsertPoint(1,.4,.4, 0)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; polygonPoints.InsertPoint(2, 1, 0, 0)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; polygonPoints.InsertPoint(3, 1, 1, 0)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; polygonPoints.InsertPoint(4,.1,.7, 0)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; polygonPoints.InsertPoint(5, 0, 1, 0)<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Make a cell with these points<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygon = vtk.vtkPolygon()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygon.GetPointIds().SetNumberOfIds(6)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygon.GetPointIds().SetId(0, 0)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygon.GetPointIds().SetId(1, 1)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygon.GetPointIds().SetId(2, 2)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygon.GetPointIds().SetId(3, 3)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygon.GetPointIds().SetId(4, 4)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygon.GetPointIds().SetId(5, 5)<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # The cell is put into a mesh (containing only one cell)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonGrid = vtk.vtkUnstructuredGrid()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonGrid.Allocate(1, 1)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonGrid.InsertNextCell(aPolygon.GetCellType(),<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; aPolygon.GetPointIds())<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonGrid.SetPoints(polygonPoints)<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # This part is needed for non-convex polygon rendering<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonGeomFilter = vtk.vtkGeometryFilter()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonGeomFilter.SetInput(aPolygonGrid)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonTriangleFilter = vtk.vtkTriangleFilter()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonTriangleFilter.SetInput(aPolygonGeomFilter.GetOutput())<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # This one is only to check the triangulation (when factor &lt; 1)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonShrinkFilter = vtk.vtkShrinkFilter()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonShrinkFilter.SetShrinkFactor( 0.9 )<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #aPolygonShrinkFilter.SetShrinkFactor( 1.0 )<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonShrinkFilter.SetInput( aPolygonGrid)<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Make ready for rendering<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonMapper = vtk.vtkDataSetMapper()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonMapper.SetInput(aPolygonShrinkFilter.GetOutput())<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonActor = vtk.vtkActor()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonActor.SetMapper(aPolygonMapper)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aPolygonActor.GetProperty().SetDiffuseColor(1, .4, .5)<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Create the usual rendering stuff.<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ren = vtk.vtkRenderer()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renWin = vtk.vtkRenderWindow()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renWin.AddRenderer(ren)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renWin.SetSize(300, 150)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iren = vtk.vtkRenderWindowInteractor()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iren.SetRenderWindow(renWin)<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ren.SetBackground(.1, .2, .4)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ren.AddActor(aPolygonActor)<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ren.ResetCamera()<BR>
&gt;<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Render the scene and start interaction.<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iren.Initialize()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renWin.Render()<BR>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iren.Start()<BR>
&gt;<BR>
&gt;<BR>
&gt;<BR>
&gt;<BR>
&gt; ------------------------------------------------------------------------<BR>
&gt;<BR>
&gt; _______________________________________________<BR>
&gt; This is the private VTK discussion list.<BR>
&gt; Please keep messages on-topic. Check the FAQ at: <A HREF="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</A><BR>
&gt; Follow this link to subscribe/unsubscribe:<BR>
&gt; <A HREF="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</A><BR>
&gt;&nbsp;&nbsp;<BR>
<BR>
--<BR>
Amy Squillacote&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Phone: (256) 726-4839<BR>
Computer Scientist&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fax: (256) 726-4806<BR>
CFD Research Corporation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Web: <A HREF="http://www.cfdrc.com">http://www.cfdrc.com</A><BR>
215 Wynn Drive, Suite 501<BR>
Huntsville, AL&nbsp; 35805<BR>
<BR>
<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>