<!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> </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> </DIV>
<DIV><FONT face=Arial size=2><A
title="http://img164.imageshack.us/img164/8985/polygon1ge2.jpg 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> </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> </DIV>
<DIV><FONT face=Arial size=2><A
title="http://img91.imageshack.us/img91/7253/polygon2yn4.jpg 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> </DIV>
<DIV><FONT face=Arial size=2>I don't know why this happens and I was hoping
if you could help me. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Here is my code for the function that creates and
renders the polygon </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 << </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 ->SetNumberOfPoints(numLines-1);</P>
<P>polygon->GetPointIds()->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 << </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 <=
numLines-1) { </P>
<P>inFile2.getline(buffer, 14);</P>
<P>x = strtod (buffer, &pEnd);</P>
<P>y = strtod (pEnd,NULL); </P>
<P>polygonPoints ->InsertPoint(countId, x, y, 0); </P>
<P>polygon->GetPointIds()->SetId(countId, countId);</P>
<P>countId++;</P>
<P>countLines++;</P>
<P>} </P>
<P>polygonGrid->Allocate(1,1);</P>
<P>polygonGrid->InsertNextCell(polygon->GetCellType(),
polygon->GetPointIds());</P>
<P>polygonGrid->SetPoints(polygonPoints);</P>
<P>polygonMapper->SetInput(polygonGrid);</P>
<P></P>
<P>polygonActor->SetMapper(polygonMapper);</P>
<P>polygonActor->GetProperty()->SetDiffuseColor(1,1,1);</FONT><FONT
color=#008000 size=2></P></FONT><FONT size=2>
<P>ren->SetBackground(0,0,0);</P>
<P>renWin->AddRenderer(ren);</P>
<P>iren->SetRenderWindow(renWin);</P>
<P>iren->SetInteractorStyle(interactorStyle3D);</P>
<P></P>
<P>ren->AddActor(polygonActor);</P>
<P>ren->ResetCamera(); </P>
<P>ren->ResetCameraClippingRange();</P>
<P></P>
<P>renWin->Render();</P>
<P>iren->Initialize();</P>
<P>iren->Start();</P>
<P>}</P>
<P><FONT face=Arial>Thanx, </FONT><FONT
face=Arial>Polys</FONT></P></FONT></DIV></BODY></HTML>