<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content=text/html;charset=iso-8859-7>
<META content="MSHTML 6.00.6000.16587" name=GENERATOR></HEAD>
<BODY id=MailContainerBody 
style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-TOP: 15px" 
bgColor=#ffffff leftMargin=0 topMargin=0 CanvasTabStop="true" 
name="Compose message area">
<DIV><FONT face=Arial size=2>Hello.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I create a polygon in 3D space by reading the 2D 
coordinates from a file and when I render it </FONT></DIV>
<DIV><FONT face=Arial size=2>i get the following image which is correct. 
</FONT><FONT face=Arial size=2>The z coordinate is always 0</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><A 
title="http://img164.imageshack.us/img164/8985/polygon1ge2.jpg&#10;CTRL + Click to follow link" 
href="http://img164.imageshack.us/img164/8985/polygon1ge2.jpg">http://img164.imageshack.us/img164/8985/polygon1ge2.jpg</A></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>But when i try to rotate the image it becomes a bit 
messy</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2><A 
title="http://img91.imageshack.us/img91/7253/polygon2yn4.jpg&#10;CTRL + Click to follow link" 
href="http://img91.imageshack.us/img91/7253/polygon2yn4.jpg">http://img91.imageshack.us/img91/7253/polygon2yn4.jpg</A></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I don't know why this happens and&nbsp;I was hoping 
if&nbsp;you could help me. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Here is my code for the function that creates and 
renders the polygon&nbsp; </FONT><FONT face=Arial size=2>(at the beginning 
</FONT></DIV>
<DIV><FONT face=Arial size=2>it's the code that reads the file and gets the 
coordinates line by line)</FONT></DIV>
<DIV><FONT color=#0000ff size=2>
<P>void</FONT><FONT size=2> CreateVtkPolygon::Polygon() {</FONT></P>
<P><FONT size=2>ifstream inFile;</P>
<P>ifstream inFile2;</P>
<P></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> numLines = 0;</P>
<P></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> countId = 0;</P>
<P></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> countLines = 1;</P>
<P></FONT><FONT color=#0000ff size=2>char</FONT><FONT size=2> buffer[14];</P>
<P></FONT><FONT color=#0000ff size=2>char</FONT><FONT size=2> * pEnd;</P>
<P></FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> x;</P>
<P></FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> y;</P>
<P></P>
<P>inFile.open(</FONT><FONT color=#800000 size=2>"IM_00104_1.out"</FONT><FONT 
size=2>);</P>
<P></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2> (!inFile) {</P>
<P>cout &lt;&lt; </FONT><FONT color=#800000 size=2>"Unable to open 
file"</FONT><FONT size=2>;</P>
<P>exit(1); </FONT><FONT color=#008000 size=2>// terminate with 
error</P></FONT><FONT size=2>
<P>}</P>
<P></FONT><FONT color=#0000ff size=2>while</FONT><FONT size=2> 
(inFile.getline(buffer, 14)) {</P>
<P>numLines++;</P>
<P>}</P>
<P></P>
<P>polygonPoints -&gt;SetNumberOfPoints(numLines-1);</P>
<P>polygon-&gt;GetPointIds()-&gt;SetNumberOfIds(numLines-1);</P>
<P></P>
<P>inFile.close();</P>
<P>inFile2.open(</FONT><FONT color=#800000 size=2>"IM_00104_1.out"</FONT><FONT 
size=2>);</P>
<P></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2> (!inFile2) {</P>
<P>cout &lt;&lt; </FONT><FONT color=#800000 size=2>"Unable to open 
file"</FONT><FONT size=2>;</P>
<P>exit(1); </FONT><FONT color=#008000 size=2>// terminate with 
error</P></FONT><FONT size=2>
<P>} </P>
<P></P>
<P></FONT><FONT color=#0000ff size=2>while</FONT><FONT size=2>(countLines &lt;= 
numLines-1) { </P>
<P>inFile2.getline(buffer, 14);</P>
<P>x = strtod (buffer, &amp;pEnd);</P>
<P>y = strtod (pEnd,NULL); </P>
<P>polygonPoints -&gt;InsertPoint(countId, x, y, 0); </P>
<P>polygon-&gt;GetPointIds()-&gt;SetId(countId, countId);</P>
<P>countId++;</P>
<P>countLines++;</P>
<P>} </P>
<P>polygonGrid-&gt;Allocate(1,1);</P>
<P>polygonGrid-&gt;InsertNextCell(polygon-&gt;GetCellType(), 
polygon-&gt;GetPointIds());</P>
<P>polygonGrid-&gt;SetPoints(polygonPoints);</P>
<P>polygonMapper-&gt;SetInput(polygonGrid);</P>
<P></P>
<P>polygonActor-&gt;SetMapper(polygonMapper);</P>
<P>polygonActor-&gt;GetProperty()-&gt;SetDiffuseColor(1,1,1);</FONT><FONT 
color=#008000 size=2></P></FONT><FONT size=2>
<P>ren-&gt;SetBackground(0,0,0);</P>
<P>renWin-&gt;AddRenderer(ren);</P>
<P>iren-&gt;SetRenderWindow(renWin);</P>
<P>iren-&gt;SetInteractorStyle(interactorStyle3D);</P>
<P></P>
<P>ren-&gt;AddActor(polygonActor);</P>
<P>ren-&gt;ResetCamera(); </P>
<P>ren-&gt;ResetCameraClippingRange();</P>
<P></P>
<P>renWin-&gt;Render();</P>
<P>iren-&gt;Initialize();</P>
<P>iren-&gt;Start();</P>
<P>}</P>
<P><FONT face=Arial>Thanx, </FONT><FONT 
face=Arial>Polys</FONT></P></FONT></DIV></BODY></HTML>