Hi David and everyone,<br><br>I think the problem is solved. I got this conclusion based on my current result, but I'm not sure if it would come out again in my MFC app. Anyway, it is solve in my console app.<br><br>The way to do it is you have to resize the vtkRenderWindow instead of letting VTK create a window with default value. I put renderWindow->SetSize(500, 500) into my source code and suddenly the right values come out.<br>
<br>I'm not sure the earlier problem is caused by my terrible coding skills or the bug of VTK itself. I still would like to hear from you all if there is any solution under my earlier situation.<br><br>Thank you all.<br>
<br>Wenlong<br><br><div class="gmail_quote">2011/10/31 Wenlong Wang <span dir="ltr"><<a href="mailto:scc.wwl@gmail.com">scc.wwl@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi, David<br><br>Sorry the last mail missed somthing.<br><br>The current situdation is, I set the transform like (1, 1, 0), and a new polydata object was created and translated to another place. I catch the new polydata with a pointer. In this case, I think the out coming of my code should show that the display coordinates of points on the new sphere has the value like ( X_originnal + X_translate, Y_original+Y_Translate, 0), since I didn't translate it in Z direction.<br>
<br>But the result shows the X and Y coordinates were not changed at all, only the Z has slight difference. Why is this happened? It really strange.<br><br>Thank you so much.<br><font color="#888888"><br>Wenlong</font><div>
<div></div><div class="h5"><br><br><div class="gmail_quote">
2011/10/31 Wenlong Wang <span dir="ltr"><<a href="mailto:scc.wwl@gmail.com" target="_blank">scc.wwl@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi, David,<br><br>Thank you for your help.<br><br>Here is the code shows the problem I encountered.<br><br> <b style="color: rgb(255, 0, 0);">vtkSphereSource* s = vtkSphereSource::New();<br> s->Update();<br><br>
vtkTransform* trans = vtkTransform::New();<br>
trans->Translate(1, 1, 0);<br><br> vtkTransformPolyDataFilter* tf = vtkTransformPolyDataFilter::New();<br> tf->SetInputConnection(s->GetOutputPort());<br> tf->SetTransform(trans);<br> tf->Update();<br>
<br> vtkPolyDataMapper* originalMapper = vtkPolyDataMapper::New();<br> originalMapper->SetInputConnection(s->GetOutputPort());<br><br> vtkActor* originalActor = vtkActor::New();<br> originalActor->SetMapper(originalMapper);<br>
originalActor->GetProperty()->SetColor(1, 0, 0); <br><br> vtkPolyDataMapper* transformedMapper = vtkPolyDataMapper::New();<br> transformedMapper->SetInputConnection(tf->GetOutputPort());<br>
<br> vtkActor* transdformedActor = vtkActor::New();<br> transdformedActor->SetMapper(transformedMapper);<br> transdformedActor->GetProperty()->SetColor(0 ,1, 0); <br><br> vtkCamera* camera = vtkCamera::New();<br>
camera->SetPosition(0, 0, 5);<br> camera->SetViewUp(0, 1, 0);<br><br> vtkRenderer* ren = vtkRenderer::New();<br> ren->AddActor(originalActor);<br> ren->AddActor(transdformedActor);<br> ren->SetActiveCamera(camera);<br>
<br> vtkRenderWindow* renWin = vtkRenderWindow::New();<br> renWin->AddRenderer(ren);<br><br> vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();<br> iren->SetRenderWindow(renWin);<br><br>
//------------------Start to convert the world coordinates to display coordinates--------------<br> vtkPoints* points = vtkPoints::New();<br> vtkPolyData* polydata = vtkPolyData::New();<br><br> polydata = tf->GetOutput();<br>
points = polydata->GetPoints();<br><br> double p[3], r[3];<br> for (int i = 0; i< 50; i++)<br> {<br> points->GetPoint(i, p);<br> ren->SetWorldPoint(p);<br> ren->WorldToDisplay();<br>
ren->GetDisplayPoint(r);<br> }</b><b style="color: rgb(255, 0, 0);"><br> renWin->Render();<br> iren->Start();</b><br><br>On the screen, the sphere did translate to another place. However, when I check the display coordinates store in point <b>r</b>, I found the X and Y are not changed, only Z has slight difference.<br>
<br>Thank you again for your time.<br><font color="#888888"><br>Wenlong</font><div><div></div><div><br><br><div class="gmail_quote">2011/10/30 David Doria <span dir="ltr"><<a href="mailto:daviddoria@gmail.com" target="_blank">daviddoria@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="gmail_quote"><div>On Sat, Oct 29, 2011 at 1:47 PM, Wenlong Wang <span dir="ltr"><<a href="mailto:scc.wwl@gmail.com" target="_blank">scc.wwl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi David,<br><br>I tried the example about vtkTransformPolyDataFilter and applied it to my actor. But seems the coordinates didn't change in the way I discribed in my earlier mail.<br><br>So is that because I didn't use it right? Or I should use other methods to get access to the new dataset generated by vtkTransformPolyDataFilter?<br>
<br>Thank you very much.<br><br>Long</blockquote><div><br></div></div>I suggest you send the smallest possible compilable code that you can to demonstrate the problem. Something like simply display a vtkSphereSource. Describe the behavior the code produces, and the behavior that you are aiming for.<br>
<font color="#888888">
<br>David</font></div>
</blockquote></div><br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>