<div dir="ltr">Hi,<div><br></div><div>Thank you for providing the complete code example that shows the problem. I compiled and ran it and see the same problem you report. Thanks also for your suggestion about what to modify. I tried adding 0.5 to the coordinates returned by <span style="font-size:12.8000001907349px">this->TransformCoordinate-></span><span style="font-size:12.8000001907349px">GetComputedDoubleViewportValue(), but this just led to blank pixels on the bottom of the window.</span></div><div><br></div><div>I think this may indeed be a bug in the conversion from viewport coordinates to window coordinates. Right now, the transformation appears to be placing coordinates (1, 1) in the lower left corner of the upper right pixel, where I think it should be in the upper right corner of the pixel. When I modify vtkViewport::DisplayToNormalizedDisplay() to divide the u and v coordinates by size-1 instead of just size, the quad fills the window. This calculation should be putting the (1,1) coordinate in the upper right corner of the pixel.</div><div><br></div><div>Would you mind posting this but on the bug tracker [1]?</div><div><br></div><div>Thanks,</div><div>Cory</div><div><br></div><div>[1] <a href="http://www.vtk.org/Bug/view_all_bug_page.php">http://www.vtk.org/Bug/view_all_bug_page.php</a></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 1, 2015 at 4:55 AM, Xabi Riobe <span dir="ltr"><<a href="mailto:xabivtk@gmail.com" target="_blank">xabivtk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Here is an example and a screenshot to illustrate the issue.<div><br></div><div>I'm wondering if the coordinates returned in vtkOpenGLPolyDataMapper2D::RenderOverlay by the call to <br></div><div>this->TransformCoordinate->GetComputedDoubleViewportValue(viewport); should be then shifted with the extra 0.5 to be in the center of the pixel and not in the border.<br></div><div><br></div><div><br></div><div><div>#define vtkRenderingCore_AUTOINIT 4(vtkInteractionStyle, vtkRenderingOpenGL, vtkRenderingFreeType,vtkRenderingFreeTypeOpenGL)</div><div><br></div><div>#include <vtkActor2D.h></div><div>#include <vtkPolyDataMapper2D.h></div><div>#include <vtkRenderer.h></div><div>#include <vtkPlaneSource.h></div><div>#include <vtkRenderWindow.h></div><div>#include <vtkRenderWindowInteractor.h></div><div>#include <vtkSmartPointer.h></div><div>#include <vtkCoordinate.h></div><div>#include <vtkPointData.h></div><div><br></div><div>int main(int, char* [])</div><div>{</div><div>   vtkSmartPointer<vtkRenderer> ren1= vtkSmartPointer<vtkRenderer>::New();</div><div>   vtkSmartPointer<vtkRenderWindow> renWin= vtkSmartPointer<vtkRenderWindow>::New();</div><div>   renWin->SetSize( 1533, 792 );</div><div>   renWin->AddRenderer(ren1);</div><div><br></div><div>   vtkSmartPointer<vtkRenderWindowInteractor> iren= vtkSmartPointer<vtkRenderWindowInteractor>::New();</div><div>   iren->SetRenderWindow(renWin);</div><div><br></div><div>   vtkSmartPointer<vtkPlaneSource> source = vtkSmartPointer<vtkPlaneSource>::New();</div><div>   source->SetOrigin(0.0, 0.0, 0.0);</div><div>   source->SetPoint1(1.0, 0.0, 0.0);</div><div>   source->SetPoint2(0.0, 1.0, 0.0);</div><div>   source->Update();</div><div><br></div><div>   vtkSmartPointer<vtkUnsignedCharArray> scalars = vtkSmartPointer<vtkUnsignedCharArray>::New();</div><div>   double bottom[3] = {255.0, 0, 0};</div><div>   double top[3] = {0, 255.0, 0};</div><div>   scalars->Initialize();</div><div>   scalars->SetNumberOfComponents(3);</div><div>   scalars->SetNumberOfTuples(4);</div><div>   scalars->InsertTuple(0, bottom);</div><div>   scalars->InsertTuple(1, bottom);</div><div>   scalars->InsertTuple(2, top);</div><div>   scalars->InsertTuple(3, top);</div><div>   source->GetOutput()->GetPointData()->SetScalars(scalars);</div><div><br></div><div>   vtkSmartPointer<vtkCoordinate> coordinateSystem = vtkSmartPointer<vtkCoordinate>::New();</div><div>   coordinateSystem->SetCoordinateSystemToNormalizedViewport();</div><div><br></div><div>   vtkSmartPointer<vtkPolyDataMapper2D> mapper = vtkSmartPointer<vtkPolyDataMapper2D>::New();</div><div>   mapper->SetInputConnection(source->GetOutputPort());</div><div>   mapper->SetTransformCoordinate(coordinateSystem);</div><div>   mapper->TransformCoordinateUseDoubleOn();</div><div><br></div><div>   vtkSmartPointer<vtkActor2D> actor2d = vtkSmartPointer<vtkActor2D>::New();</div><div>   actor2d->SetMapper(mapper);</div><div><br></div><div>   ren1->AddActor(actor2d);</div><div><br></div><div>   ren1->ResetCamera();</div><div>   renWin->Render();</div><div>   iren->Start();</div></div><div>}</div><div><br></div><div><img src="cid:ii_14e48ce35d944ab8" alt="Images intégrées 1" width="253" height="182"><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2015-06-30 18:18 GMT+02:00 Xabi Riobe <span dir="ltr"><<a href="mailto:xabivtk@gmail.com" target="_blank">xabivtk@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I want to display a plane as a background.</div><div>For that i have in a vtkActor2D a vtkPolyDataMapper2D filled with a vtkPlaneSource going from 0,0,0 to 1,1,1</div><div>I add to the mapper a vtkCoordinate with SetCoordinateSystemToNormalizedViewport</div><div><br></div><div>with that, everything seems fine and i don't have to take care of it when my view is resized.</div><div><br></div><div>but if i put some color on it and look at it carefully i can see an extra line and column of black pixels</div><div><br></div><div>I looked at the code of vtkCoordinate and vtkViewport and the combination of the coordinates transformations leads to a final size of the polygon rendered 1 pixel short in both x and y directions.</div><div><br></div><div>Is this considered a normal behaviour due to the computation involved, or is it definitively a bug?</div><div><br></div><div>A quick workaround is to set my plane source a little bit larger, but for future features of my app, i would need the exact size...</div><div><br></div><div>Thanks for any comments/suggestions</div><div><br></div></div>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Cory Quammen<br>R&D Engineer<br>Kitware, Inc.</div>
</div>