<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content=text/html;charset=iso-8859-1>
<META content="MSHTML 6.00.6000.16640" name=GENERATOR></HEAD>
<BODY id=MailContainerBody 
style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-TOP: 15px; WORD-WRAP: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space" 
bgColor=#ffffff leftMargin=0 topMargin=0 CanvasTabStop="true" 
name="Compose message area">
<DIV><FONT face=Arial size=2>Thanks Michael. That worked</FONT></DIV>
<DIV style="FONT: 10pt Tahoma">
<DIV><BR></DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=marice@knology.net 
href="mailto:marice@knology.net">Michael Rice</A> </DIV>
<DIV><B>Sent:</B> Wednesday, May 07, 2008 3:35 PM</DIV>
<DIV><B>To:</B> <A 
href="mailto:polys_poly@hotmail.compolys_poly@hotmail.com">polys_poly@hotmail.compolys_poly@hotmail.com</A></DIV>
<DIV><B>Subject:</B> Re: [vtkusers] Calculating the area of a 
polygon</DIV></DIV></DIV>
<DIV><BR></DIV>Did you call polygonProperties-&gt;Update() before trying to use 
the polygonProperties-&gt;SurfaceArea? 
<DIV><BR></DIV>
<DIV>Michael<BR>
<DIV><BR>
<DIV>On May 6, 2008, at 8:00 AM, &lt;<A 
href="mailto:polys_poly@hotmail.com">polys_poly@hotmail.com</A>&gt; &lt;<A 
href="mailto:polys_poly@hotmail.com">polys_poly@hotmail.com</A>&gt; wrote:<BR 
class=Apple-interchange-newline>
<BLOCKQUOTE type="cite">
  <DIV id=MailContainerBody 
  style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-TOP: 15px" 
  name="Compose message area" bgcolor="#ffffff" leftmargin="0" topmargin="0" 
  canvastabstop="true">
  <DIV><FONT face=Arial>Hello,</FONT></DIV>
  <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial>I am using the following code to create a polygon in 
  3D.</FONT></DIV>
  <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial>vtkPolygon* polygon1 = 
  vtkPolygon::New();&nbsp;<BR>vtkPoints* polygonPoints1&nbsp; = 
  vtkPoints::New();<BR>vtkPolyData* polyData1 = 
  vtkPolyData::New();<BR>vtkPolyDataMapper* polygonMapper1 = 
  vtkPolyDataMapper::New();&nbsp;<BR>vtkTriangleFilter* tri1= 
  vtkTriangleFilter::New();</FONT></DIV>
  <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
  <DIV><FONT 
  face=Arial>polygonPoints1-&gt;SetNumberOfPoints(4);<BR>polygon1-&gt;GetPointIds()-&gt;SetNumberOfIds(4);</FONT></DIV>
  <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial>polygonPoints1-&gt;InsertPoint(0, x1, y1, 
  z1);</FONT></DIV>
  <DIV><FONT face=Arial>polygon1-&gt;GetPointIds()-&gt;SetId(0, 0);</FONT></DIV>
  <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial>polygonPoints1-&gt;InsertPoint(1, x2, y2, 
  z2);</FONT></DIV>
  <DIV><FONT face=Arial>polygon1-&gt;GetPointIds()-&gt;SetId(1, 
  1);</FONT></DIV><FONT face=Arial>
  <DIV><BR>polygonPoints1-&gt;InsertPoint(2, x3, y3, z3);</DIV>
  <DIV>polygon1-&gt;GetPointIds()-&gt;SetId(2, 2);</DIV>
  <DIV><BR>polygonPoints1-&gt;InsertPoint(3, x4, y4, z4);</DIV></FONT>
  <DIV><FONT face=Arial>polygon1-&gt;GetPointIds()-&gt;SetId(3, 
  3);<BR></FONT></DIV>
  <DIV><FONT 
  face=Arial>polyData1-&gt;Allocate();<BR>polyData1-&gt;InsertNextCell(polygon1-&gt;GetCellType(),polygon1-&gt;GetPointIds());<BR>polyData1-&gt;SetPoints(polygonPoints1);</FONT></DIV>
  <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
  <DIV><FONT 
  face=Arial>tri1-&gt;SetInput(polyData1);<BR>polygonMapper1-&gt;SetInput(tri1-&gt;GetOutput());</FONT></DIV>
  <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial>What i am trying to do is get the area of the 
  polygon.</FONT></DIV>
  <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial>I&nbsp;am using the following code but i get 0 for the 
  area</FONT></DIV>
  <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial>vtkMassProperties* polygonProperties = 
  vtkMassProperties::New();&nbsp;<BR>polygonProperties-&gt;SetInputConnection(tri1-&gt;GetOutputPort());</FONT></DIV>
  <DIV><FONT face=Arial>double area = 
  polygonProperties-&gt;SurfaceArea;</FONT></DIV>
  <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial>Can someone tell me what i am doing wrong or is there 
  any other way to compute the area of a polygon.</FONT></DIV>
  <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial>Maybe there is a way to find the number of pixels that a 
  polygon has on the screen and multiply that number with the pixel 
  size?</FONT></DIV>
  <DIV><FONT face=Arial></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial>Thanks in advance,</FONT></DIV>
  <DIV><FONT face=Arial>Polys</FONT></DIV>
  <DIV><FONT 
  face=Arial></FONT>&nbsp;</DIV></DIV>_______________________________________________<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></BLOCKQUOTE></DIV><BR></DIV></DIV></BODY></HTML>