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