<div dir="ltr">The clipping planes are automatically set when you call ResetCameraClippingRange based on the sum total of the bounds of the visible actors in the scene.<div><br></div><div>If you need different clipping planes, you'll have to add an actor with the appropriate bounds, or figure out how to intercept and override VTK's setting of the clipping planes.</div><div><br></div><div>If you are calling code within VTK, there are many built-in callers to ResetCameraClippingRange, so I would recommend having all of your actors participate in the bounds computation by reporting their correct bounds in VTK world coordinates.</div><div><br></div><div><br></div><div>HTH,</div><div>David C.</div><div><br></div><div><br><br>On Friday, April 10, 2015, Sergio Vera <<a href="mailto:sergio.vera@alma3d.com" target="_blank">sergio.vera@alma3d.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Dear Sankhesh and Aashish<br><br></div>many thanks for your heping advices.<br><br></div>I've finally made it work (more or less)<br></div>I did it by giving the opengl mapper a faked input as you suggested. <br></div>My opengl stuff is being actually drawn to the screen although it seems to be heavily clipped and/or dissapearing depending on the polydata that I provide as a "fake" input to my rawGLMapper.I guess is some part of the vtk pipeline confused about having an actor with bogus bounds (the bounds of a completely different polydata). Or perhaps something related to the depth / color buffers or frustum clipping planes perhaps (i have to dig a little more at it)<br><br><br><div>Many thanks<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 2, 2015 at 6:48 PM, Sankhesh Jhaveri <span dir="ltr"><<a>sankhesh.jhaveri@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(11,83,148)">Hello Sergio,<br><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(11,83,148)">A couple of things:<br><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(11,83,148)">1. If you look at the vtkPolyDataMapper::Render() method, it calls RenderPiece only if there is input information set on the mapper. I guess your code does not provide an input to the mapper, and hence, RenderPiece (and Draw) is not called.<br><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(11,83,148)">2. The vtkRenderer::Render() method clears the color and depth buffers by default. You'll have to work around that to make sure the GL objects are preserved.<br><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(11,83,148)">Hope that helps.<br><br></div></div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr"><div><div dir="ltr"><div><span style="color:rgb(11,83,148)"><br></span></div><div><span style="color:rgb(11,83,148)"><span style="font-family:verdana,sans-serif">Best Regards,<br><br></span></span></div><span style="color:rgb(11,83,148)"><span style="font-family:verdana,sans-serif">Sankhesh Jhaveri<br>Research & Development Engineer</span></span><div><span style="color:rgb(11,83,148)"><span style="font-family:verdana,sans-serif">Kitware, Inc.<br><b>Phone</b>: <a href="tel:%28518%29%20881%204417" value="+15188814417" target="_blank">(518) 881 4417</a><br><b>Fax</b>: <a href="tel:%28518%29%20371%204573" value="+15183714573" target="_blank">(518) 371 4573</a></span></span><br><b></b><br> </div></div></div></div></div></div><div><div>
<br><div class="gmail_quote">On Wed, Apr 1, 2015 at 11:01 AM, Sergio Vera <span dir="ltr"><<a>sergio.vera@alma3d.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Dear Aashish,<br><br></div>thanks for your time. At the moment it is kinda difficult to switch to OpenGL2 backend, manily because the VTK (5.10) we use is pulled by the CTK superbuild. I could try to switch to the experimental branch of CTK with support for vtk 6 and try to modifly the superbuild so VTK uses the OpenGL2 backend.<br><br></div>Currently I'm testing stuff using this toy example (based on a VTK example)<br><br><font face="monospace,monospace">#include <iostream><br>#include <vtkProp3D.h><br>#include <vtkVersion.h><br>#include <vtkSmartPointer.h><br>#include <vtkCellArray.h><br>#include <vtkCellData.h><br>#include <vtkDoubleArray.h><br>#include <vtkPoints.h><br>#include <vtkLine.h><br>#include <vtkPolyData.h><br>#include <vtkPolyDataMapper.h><br>#include <vtkActor.h><br>#include <vtkRenderWindow.h><br>#include <vtkRenderer.h><br>#include <vtkRenderWindowInteractor.h><br>#include <vtkOpenGL.h> // For export macro<br>#include <vtkObjectFactory.h><br>#include <vtkMapper.h><br>#include <vtkOpenGLPolyDataMapper.h><br>#include <vtkgl.h><br>#include <vtkViewport.h><br><br>#include <GL/gl.h><br><br>class myMapper : public vtkOpenGLPolyDataMapper<br>{<br>public:<br> static myMapper *New();<br> vtkTypeMacro(myMapper, vtkOpenGLPolyDataMapper);<br><br> virtual void RenderPiece(vtkRenderer *aren, vtkActor *act);<br> virtual int Draw(vtkRenderer *aren, vtkActor *act);<br><br>protected:<br><br>private:<br><br>};<br><br>vtkStandardNewMacro(myMapper);<br><br>void<br>myMapper::RenderPiece(vtkRenderer* a_ren, vtkActor* a_act)<br>{<br> std::cout << "RenderPiece" << std::endl;<br> glDisable( GL_LIGHTING);<br> glBegin(GL_LINES);<br> glVertex3f(0, 1, 0);<br> glVertex3f(1, 1., 0.);<br> glEnd();<br>}<br><br>int<br>myMapper::Draw(vtkRenderer* a_ren, vtkActor* a_act)<br>{<br> std::cout << "Draw" << std::endl;<br><br> glDisable( GL_LIGHTING);<br> glBegin(GL_LINES);<br> glVertex3f(0, 1, 0);<br> glVertex3f(1, 1., 0.);<br> glEnd();}<br><br><br>int main(int, char *[])<br>{<br> std::cout << "Main" << std::endl;<br> // Create three points. Join (Origin and P0) with a red line and<br> // (Origin and P1) with a green line<br> double origin[3] = {0.0, 0.0, 0.0};<br> double p0[3] = {1.0, 0.0, 0.0};<br> double p1[3] = {0.0, 1.0, 0.0};<br><br> // Create a vtkPoints object and store the points in it<br> vtkSmartPointer<vtkPoints> pts =<br> vtkSmartPointer<vtkPoints>::New();<br> pts->InsertNextPoint(origin);<br> pts->InsertNextPoint(p0);<br> pts->InsertNextPoint(p1);<br><br> // Setup two colors - one for each line<br> unsigned char red[3] = {255, 0, 0};<br> unsigned char green[3] = {0, 255, 0};<br><br> // Setup the colors array<br> vtkSmartPointer<vtkUnsignedCharArray> colors =<br> vtkSmartPointer<vtkUnsignedCharArray>::New();<br> colors->SetNumberOfComponents(3);<br> colors->SetName("Colors");<br><br> // Add the colors we created to the colors array<br> colors->InsertNextTupleValue(red);<br> colors->InsertNextTupleValue(green);<br><br> // Create the first line (between Origin and P0)<br> vtkSmartPointer<vtkLine> line0 =<br> vtkSmartPointer<vtkLine>::New();<br> line0->GetPointIds()->SetId(0,0); //the second 0 is the index of the Origin in the vtkPoints<br> line0->GetPointIds()->SetId(1,1); //the second 1 is the index of P0 in the vtkPoints<br><br> // Create the second line (between Origin and P1)<br> vtkSmartPointer<vtkLine> line1 =<br> vtkSmartPointer<vtkLine>::New();<br> line1->GetPointIds()->SetId(0,0); //the second 0 is the index of the Origin in the vtkPoints<br> line1->GetPointIds()->SetId(1,2); //2 is the index of P1 in the vtkPoints<br><br> // Create a cell array to store the lines in and add the lines to it<br> vtkSmartPointer<vtkCellArray> lines =<br> vtkSmartPointer<vtkCellArray>::New();<br> lines->InsertNextCell(line0);<br> lines->InsertNextCell(line1);<br><br> // Create a polydata to store everything in<br> vtkSmartPointer<vtkPolyData> linesPolyData =<br> vtkSmartPointer<vtkPolyData>::New();<br><br> // Add the points to the dataset<br> linesPolyData->SetPoints(pts);<br><br> // Add the lines to the dataset<br> linesPolyData->SetLines(lines);<br><br> // Color the lines - associate the first component (red) of the<br> // colors array with the first component of the cell array (line 0)<br> // and the second component (green) of the colors array with the<br> // second component of the cell array (line 1)<br> linesPolyData->GetCellData()->SetScalars(colors);<br><br> // Visualize<br> vtkSmartPointer<vtkPolyDataMapper> mapper =<br> vtkSmartPointer<vtkPolyDataMapper>::New();<br>#if VTK_MAJOR_VERSION <= 5<br> mapper->SetInput(linesPolyData);<br>#else<br> mapper->SetInputData(linesPolyData);<br>#endif<br><br> vtkSmartPointer<vtkActor> actor =<br> vtkSmartPointer<vtkActor>::New();<br> actor->SetMapper(mapper);<br><br> vtkSmartPointer<myMapper> mapperGL =<br> vtkSmartPointer<myMapper>::New();<br><br><br> vtkSmartPointer<vtkActor> actorGL =<br> vtkSmartPointer<vtkActor>::New();<br> actorGL->SetMapper(mapperGL);<br><br> vtkSmartPointer<vtkRenderer> renderer =<br> vtkSmartPointer<vtkRenderer>::New();<br> vtkSmartPointer<vtkRenderWindow> renderWindow =<br> vtkSmartPointer<vtkRenderWindow>::New();<br> renderWindow->AddRenderer(renderer);<br> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<br> vtkSmartPointer<vtkRenderWindowInteractor>::New();<br> renderWindowInteractor->SetRenderWindow(renderWindow);<br> renderer->AddActor(actor);<br> renderer->AddActor(actorGL);<br><br> renderWindow->Render();<br> renderWindowInteractor->Start();<br><br> return EXIT_SUCCESS;<br>}<br></font><br><br><br></div>when I run the above code, I see the vtk lines but the OpenGL lines are missing and no output is printed in the console signaling that the code is being called.<br><br><br></div>thanks for your time<br><div><br><br><div><br></div></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 1, 2015 at 3:23 PM, Aashish Chaudhary <span dir="ltr"><<a>aashish.chaudhary@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">It's much harder In OpenGL backend because of the architecture. If you can provide more detail on exactly what you did, we could probably help. I would suggest switching to OpenGL2 backend. <span><font color="#888888"><div><br></div><div>- Aashish</div></font></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 1, 2015 at 4:33 AM, Sergio Vera <span dir="ltr"><<a>sergio.vera@alma3d.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br>I'm using the OpenGL backend since I'm using vtk5.10 (CTK compatibility)<br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 31, 2015 at 6:38 PM, Aashish Chaudhary <span dir="ltr"><<a>aashish.chaudhary@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Are using OpenGL2 or OpenGL backend? </div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 31, 2015 at 12:13 PM, Sergio Vera <span dir="ltr"><<a>sergio.vera@alma3d.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div>Thanks,<br>I've derived from vtkOpenGLPolyDataMapper, attached the mapper to an ordinary actor and added the actor to the renderer.<br></div>It seems that neigher Draw() nor RenderPiece() methods of the mapper are being called and my simple gl code snipped is not being rendered.<br><br></div>Any additional hints?<br><br></div>Thanks in advance<br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 31, 2015 at 4:15 PM, Aashish Chaudhary <span dir="ltr"><<a>aashish.chaudhary@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">there is no easy way. You will have to write your own <div>mapper. </div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Tue, Mar 31, 2015 at 7:17 AM, Sergio Vera <span dir="ltr"><<a>sergio.vera@alma3d.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div dir="ltr"><div><div><div><div><br clear="all"></div>Hello vtk Users<br><br></div>I'm trying to insert opengl calls inside vtk. So far I have seen examples of the opposite, insert vtk into opengl.<br><br></div><div>There is the suggestion somewhere on the list of using the render methods of vtkMapper or vtkprops but no definite example<br><br></div>Where is the best way to do it?<br><br></div>thanks in advance<span><font color="#888888"><br><div><div><div><div>-- <br><div>Sergio Vera<br><br> Alma IT Systems<br> C/ Vilana, 4B, 4º 1ª<br> 08022 Barcelona<br> T. <a href="tel:%28%2B34%29%20932%20380%20592" value="+34932380592" target="_blank">(+34) 932 380 592</a><br> <a href="http://www.alma3d.com" target="_blank">www.alma3d.com</a></div>
</div></div></div></div></font></span></div>
<br></div></div>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" 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" 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" 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" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><font face="trebuchet ms, sans-serif"><i>| Aashish Chaudhary <br>| Technical Leader <br>| Kitware Inc. <br></i></font><div><i><font face="trebuchet ms, sans-serif">| </font><a href="http://www.kitware.com/company/team/chaudhary.html" target="_blank">http://www.kitware.com/company/team/chaudhary.html</a></i></div></div></div>
</font></span></div>
</blockquote></div><br><br clear="all"><br>-- <br><div>Sergio Vera<br><br> Alma IT Systems<br> C/ Vilana, 4B, 4º 1ª<br> 08022 Barcelona<br> T. <a href="tel:%28%2B34%29%20932%20380%20592" value="+34932380592" target="_blank">(+34) 932 380 592</a><br> <a href="http://www.alma3d.com" target="_blank">www.alma3d.com</a></div>
</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><font face="trebuchet ms, sans-serif"><i>| Aashish Chaudhary <br>| Technical Leader <br>| Kitware Inc. <br></i></font><div><i><font face="trebuchet ms, sans-serif">| </font><a href="http://www.kitware.com/company/team/chaudhary.html" target="_blank">http://www.kitware.com/company/team/chaudhary.html</a></i></div></div></div>
</div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div>Sergio Vera<br><br> Alma IT Systems<br> C/ Vilana, 4B, 4º 1ª<br> 08022 Barcelona<br> T. <a href="tel:%28%2B34%29%20932%20380%20592" value="+34932380592" target="_blank">(+34) 932 380 592</a><br> <a href="http://www.alma3d.com" target="_blank">www.alma3d.com</a></div>
</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><font face="trebuchet ms, sans-serif"><i>| Aashish Chaudhary <br>| Technical Leader <br>| Kitware Inc. <br></i></font><div><i><font face="trebuchet ms, sans-serif">| </font><a href="http://www.kitware.com/company/team/chaudhary.html" target="_blank">http://www.kitware.com/company/team/chaudhary.html</a></i></div></div></div>
</div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div>Sergio Vera<br><br> Alma IT Systems<br> C/ Vilana, 4B, 4º 1ª<br> 08022 Barcelona<br> T. <a href="tel:%28%2B34%29%20932%20380%20592" value="+34932380592" target="_blank">(+34) 932 380 592</a><br> <a href="http://www.alma3d.com" target="_blank">www.alma3d.com</a></div>
</div>
</div></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" 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" 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" 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" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div></div></div>
</blockquote></div><br><br clear="all"><br>-- <br><div>Sergio Vera<br><br> Alma IT Systems<br> C/ Vilana, 4B, 4º 1ª<br> 08022 Barcelona<br> T. <a href="tel:%28%2B34%29%20932%20380%20592" value="+34932380592" target="_blank">(+34) 932 380 592</a><br> <a href="http://www.alma3d.com" target="_blank">www.alma3d.com</a></div>
</div>
</blockquote>
</div></div>