<!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>Hello vtkusers,<BR>
<BR>
I have been having a similar problem rendering a cube made up of four smaller cubes.<BR>
<BR>
I would like to be able to visualise the interior nodes but they disappear<BR>
depending on the degree of the vertex. I have included a sample screen shot.<BR>
<BR>
What I want to eventually do is extract the edges to a TubeFilter and color<BR>
the tubes depending on some scalar values, but I always only get 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>
-----Original Message-----<BR>
From: vtkusers-bounces@vtk.org on behalf of Marie-Gabrielle Vallet<BR>
Sent: Fri 5/30/2008 9:21 PM<BR>
To: briand@aracnet.com<BR>
Cc: vtkusers@vtk.org<BR>
Subject: Re: [vtkusers] best way to represent a (planar) irregular polygon ?<BR>
<BR>
Hi Brian,<BR>
I remember having some problem to render a non-convex polygon. I found an<BR>
example, I can't find again where it comes from, and I worked on it. Finally<BR>
the following python script does what you want.<BR>
<BR>
You should try to add two filters : a GeometryFilter and a TriangleFilter.<BR>
Marie-Gabrielle<BR>
<BR>
&nbsp;#!/usr/bin/env python<BR>
<BR>
&nbsp;# This example shows how to visualize polygons, convex or not.<BR>
<BR>
&nbsp;import vtk<BR>
<BR>
&nbsp;# Define a set of points - these are the ordered polygon vertices<BR>
&nbsp;polygonPoints = vtk.vtkPoints()<BR>
&nbsp;polygonPoints.SetNumberOfPoints(6)<BR>
&nbsp;polygonPoints.InsertPoint(0, 0, 0, 0)<BR>
&nbsp;polygonPoints.InsertPoint(1,.4,.4, 0)<BR>
&nbsp;polygonPoints.InsertPoint(2, 1, 0, 0)<BR>
&nbsp;polygonPoints.InsertPoint(3, 1, 1, 0)<BR>
&nbsp;polygonPoints.InsertPoint(4,.1,.7, 0)<BR>
&nbsp;polygonPoints.InsertPoint(5, 0, 1, 0)<BR>
<BR>
&nbsp;# Make a cell with these points<BR>
&nbsp;aPolygon = vtk.vtkPolygon()<BR>
&nbsp;aPolygon.GetPointIds().SetNumberOfIds(6)<BR>
&nbsp;aPolygon.GetPointIds().SetId(0, 0)<BR>
&nbsp;aPolygon.GetPointIds().SetId(1, 1)<BR>
&nbsp;aPolygon.GetPointIds().SetId(2, 2)<BR>
&nbsp;aPolygon.GetPointIds().SetId(3, 3)<BR>
&nbsp;aPolygon.GetPointIds().SetId(4, 4)<BR>
&nbsp;aPolygon.GetPointIds().SetId(5, 5)<BR>
<BR>
&nbsp;# The cell is put into a mesh (containing only one cell)<BR>
&nbsp;aPolygonGrid = vtk.vtkUnstructuredGrid()<BR>
&nbsp;aPolygonGrid.Allocate(1, 1)<BR>
&nbsp;aPolygonGrid.InsertNextCell(aPolygon.GetCellType(), aPolygon.GetPointIds())<BR>
&nbsp;aPolygonGrid.SetPoints(polygonPoints)<BR>
<BR>
&nbsp;# This part is needed for non-convex polygon rendering<BR>
&nbsp;aPolygonGeomFilter = vtk.vtkGeometryFilter()<BR>
&nbsp;aPolygonGeomFilter.SetInput(aPolygonGrid)<BR>
&nbsp;aPolygonTriangleFilter = vtk.vtkTriangleFilter()<BR>
&nbsp;aPolygonTriangleFilter.SetInput(aPolygonGeomFilter.GetOutput())<BR>
&nbsp;#<BR>
&nbsp;# This one is only to check the triangulation (when factor &lt; 1)<BR>
&nbsp;aPolygonShrinkFilter = vtk.vtkShrinkFilter()<BR>
&nbsp;aPolygonShrinkFilter.SetShrinkFactor( 0.9 )<BR>
&nbsp;#aPolygonShrinkFilter.SetShrinkFactor( 1.0 )<BR>
&nbsp;aPolygonShrinkFilter.SetInput( aPolygonGrid)<BR>
<BR>
&nbsp;# Make ready for rendering<BR>
&nbsp;aPolygonMapper = vtk.vtkDataSetMapper()<BR>
&nbsp;aPolygonMapper.SetInput(aPolygonShrinkFilter.GetOutput())<BR>
&nbsp;aPolygonActor = vtk.vtkActor()<BR>
&nbsp;aPolygonActor.SetMapper(aPolygonMapper)<BR>
&nbsp;aPolygonActor.GetProperty().SetDiffuseColor(1, .4, .5)<BR>
<BR>
&nbsp;# Create the usual rendering stuff.<BR>
&nbsp;ren = vtk.vtkRenderer()<BR>
&nbsp;renWin = vtk.vtkRenderWindow()<BR>
&nbsp;renWin.AddRenderer(ren)<BR>
&nbsp;renWin.SetSize(300, 150)<BR>
&nbsp;iren = vtk.vtkRenderWindowInteractor()<BR>
&nbsp;iren.SetRenderWindow(renWin)<BR>
<BR>
&nbsp;ren.SetBackground(.1, .2, .4)<BR>
&nbsp;ren.AddActor(aPolygonActor)<BR>
&nbsp;ren.ResetCamera()<BR>
<BR>
&nbsp;# Render the scene and start interaction.<BR>
&nbsp;iren.Initialize()<BR>
&nbsp;renWin.Render()<BR>
&nbsp;iren.Start()<BR>
<BR>
<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>