<div dir="ltr">Hi Chris, <div><br></div><div>I got carried away by new volume rendering code but now I am back to your issue. I will report back. </div><div><br></div><div>thanks</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 30, 2014 at 5:04 PM, Chris Hafey <span dir="ltr"><<a href="mailto:chafey@gmail.com" target="_blank">chafey@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 style="word-wrap:break-word"><div>Hi Aashish and vtkusers,</div>  Just checking in to see if anyone has been able to reproduce this issue or see anything I am doing wrong.  I would love to get this working on Mac OS X - thanks for any assistance!<span class="HOEnZb"><font color="#888888"><div><br></div><div>Chris</div></font></span><div><div class="h5"><div><br></div><div><div>On Sep 25, 2014, at 8:39 AM, Chris Hafey <<a href="mailto:chafey@gmail.com" target="_blank">chafey@gmail.com</a>> wrote:</div><br><blockquote type="cite"><div dir="ltr">The follow code will reproduce the problem - change the line commented out near the top to switch between GPU and RayCast rendering to see it working and not working.  Let me know if you need a CMakefile and DICOM files (I assume you have DICOM files and can plug this code into an existing project if needed )<div><br></div><div><p>#include <span><string></span></p><p>#include <span><fstream></span></p><p><span>#include </span><vtkSmartPointer.h><br></p><p><span>#include </span><vtkImageSlabReslice.h></p><p><span>#include </span><vtkRenderer.h></p><p><span>#include </span><vtkRenderWindow.h></p><p><span>#include </span><vtkPiecewiseFunction.h></p><p><span>#include </span><vtkColorTransferFunction.h></p><p><span>#include </span><vtkImageData.h></p><p><span>#include </span><vtkMatrix4x4.h></p><p><span>#include </span><vtkWindowToImageFilter.h></p><p><span>#include </span><vtkDICOMImageReader.h></p><p><span>#include </span><vtkSmartVolumeMapper.h></p><p><span>#include </span><vtkJPEGWriter.h></p><p><span>#include </span><vtkCamera.h></p><p><span>#include </span><vtkVolumeProperty.h></p><p><span>#include </span><vtkUnsignedCharArray.h></p><p><br></p><p><span>int</span> main(<span>int</span> argc, <span>char</span>** argv)<br></p><p>{</p><p><br></p><p><span>    </span>//int renderMode =vtkSmartVolumeMapper::RayCastRenderMode; // this works</p><p><span>    </span><span>int</span><span> renderMode =</span><span>vtkSmartVolumeMapper</span><span>::</span><span>GPURenderMode</span><span>; </span>// this generates black image</p><div>    <br></div><p><span>    </span>// Read the DICOM Data</p><p><span>    </span>vtkSmartPointer<span><</span>vtkDICOMImageReader<span>> reader = </span>vtkSmartPointer<span><</span>vtkDICOMImageReader<span>>::</span><span>New</span><span>();</span></p><p><span>    reader-></span><span>SetDirectoryName</span><span>(</span>"/Users/chafey/DICOM/Volume3"<span>);</span></p><p>    reader-><span>Update</span>();</p><p>    <span>vtkSmartPointer</span><<span>vtkImageData</span>> imageData(reader-><span>GetOutput</span>());</p><div>    <br></div><p><span>    </span>// Translate origin to center of volume</p><p>    <span>double</span> xSpacing, ySpacing, zSpacing;</p><p>    imageData-><span>GetSpacing</span>(xSpacing, ySpacing, zSpacing);</p><p>    <span>int</span>* dims = imageData-><span>GetDimensions</span>();</p><p>    <span>double</span> xCenter = dims[<span>0</span>] * xSpacing / <span>2.0</span>;</p><p>    <span>double</span> yCenter = dims[<span>1</span>] * ySpacing / <span>2.0</span>;</p><p>    <span>double</span> zCenter = dims[<span>2</span>] * zSpacing / <span>2.0</span>;</p><p>    imageData-><span>SetOrigin</span>(-xCenter, -yCenter, -zCenter);</p><p><br></p><p><span>     </span>// Setup the renderer for offscreen rendering</p><p><span>    </span>vtkSmartPointer<span><</span>vtkRenderer<span>>  renderer = </span>vtkSmartPointer<span><</span>vtkRenderer<span>>::</span><span>New</span><span>();</span></p><div>    <br></div><p><span>    </span>// Setup the render window</p><p><span>    </span>vtkSmartPointer<span><</span>vtkRenderWindow<span>> render_window = </span>vtkSmartPointer<span><</span>vtkRenderWindow<span>>::</span><span>New</span><span>();</span></p><p>    render_window-><span>SetOffScreenRendering</span>(<span>1</span>);</p><p>    render_window-><span>AddRenderer</span>(renderer);</p><p>    render_window-><span>SetSize</span>(<span>512</span>, <span>512</span>);</p><div>    <br></div><p><span>    </span>// Setup the volume mapper</p><p><span>    </span>vtkSmartPointer<span><</span>vtkSmartVolumeMapper<span>> volume_mapper = </span>vtkSmartPointer<span><</span>vtkSmartVolumeMapper<span>>::</span><span>New</span><span>();</span></p><p>    volume_mapper-><span>SetRequestedRenderMode</span>(renderMode);</p><p>    volume_mapper-><span>SetInputData</span>(imageData);</p><div>    <br></div><p><br></p><p><span>    </span>// Setup the volume</p><p><span>    </span>vtkSmartPointer<span><</span>vtkVolume<span>> volume = </span>vtkSmartPointer<span><</span>vtkVolume<span>>::</span><span>New</span><span>();</span></p><p>    volume-><span>SetMapper</span>(volume_mapper);</p><p>    renderer-><span>AddViewProp</span>(volume);</p><div>    <br></div><p><span>    </span>// Render the image</p><p>    render_window-><span>Render</span>();</p><p><span>    </span>vtkSmartPointer<span><</span>vtkWindowToImageFilter<span>> windowToImageFilter = </span>vtkSmartPointer<span><</span>vtkWindowToImageFilter<span>>::</span><span>New</span><span>();</span></p><p>    windowToImageFilter-><span>SetInput</span>(render_window);</p><p>    windowToImageFilter-><span>Update</span>();</p><div>    <br></div><p><span>    </span>// Create a JPEG in memory</p><p><span>    </span>vtkSmartPointer<span><</span>vtkJPEGWriter<span>> writer = </span>vtkSmartPointer<span><</span>vtkJPEGWriter<span>>::</span><span>New</span><span>();</span></p><p>    writer-><span>WriteToMemoryOn</span>();</p><p>    writer-><span>SetInputConnection</span>(windowToImageFilter-><span>GetOutputPort</span>());</p><p>    writer-><span>Write</span>();</p><p><span>    </span>vtkSmartPointer<span><</span>vtkUnsignedCharArray<span>> dataPtr = writer-></span><span>GetResult</span><span>();</span></p><p>    dataPtr-><span>Squeeze</span>();</p><div>    <br></div><p><span>    </span>// write the jpeg to disk</p><p>    <span>ofstream</span> myFile (<span>"image.jpg"</span>, <span>ios</span>::<span>out</span> | <span>ios</span>::<span>binary</span>);</p><p>    myFile.<span>write</span> ((<span>const</span> <span>char</span>*)dataPtr-><span>GetPointer</span>(<span>0</span>), dataPtr-><span>GetSize</span>());</p><div> <br></div><p>    <span>return</span> <span>0</span>;</p><p>}</p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 25, 2014 at 7:42 AM, Aashish Chaudhary <span dir="ltr"><<a href="mailto:aashish.chaudhary@kitware.com" target="_blank">aashish.chaudhary@kitware.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"><div class="gmail_extra"><div class="gmail_quote"><span>On Thu, Sep 25, 2014 at 8:38 AM, Chris Hafey <span dir="ltr"><<a href="mailto:chafey@gmail.com" target="_blank">chafey@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">No errors on the console.  I will work on a standalone example.  Can you please clarify whether or not I should be using mesa / osmesa for GPU rendering on Mac OS X?</div></blockquote><div><br></div></span><div>In theory your regular driver should work with the offscreen rendering setting. As per my understanding, that will just not open the window but will create a context in which the rendering is performed.  But if the image is black and if it is not if you don't set that flag then it means the context was not created properly. VTK should have given you a error but may be it is fooled by the system itself. </div><div><br></div><div>You can try osmesa, make sure that VTK detects it, and see if that works. </div><span><font color="#888888"><div><br></div><div>- Aashish  </div></font></span><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span><font color="#888888"><div><br></div><div>Chris</div></font></span></div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 25, 2014 at 7:37 AM, Aashish Chaudhary <span dir="ltr"><<a href="mailto:aashish.chaudhary@kitware.com" target="_blank">aashish.chaudhary@kitware.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">This is good to know. Do you get any errors on the console? A standalone example  will be nice. <span><font color="#888888"><div><br></div><div>- Aashish</div></font></span></div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 25, 2014 at 8:32 AM, Chris Hafey <span dir="ltr"><<a href="mailto:chafey@gmail.com" target="_blank">chafey@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">I am enabling off screen rendering by calling SetOffScreenRendering(1) on the vtkRenderWindow.  Should I be using osmesa?  I can create a standalone example to reproduce if needed.<span><font color="#888888"><div><br></div><div>Chris</div></font></span></div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 25, 2014 at 7:21 AM, Aashish Chaudhary <span dir="ltr"><<a href="mailto:aashish.chaudhary@kitware.com" target="_blank">aashish.chaudhary@kitware.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">No problem. How did you enable the offscreen?  Can you post your code somewhere? <div><br></div><div>Thanks,</div><div>Aashish</div></div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 25, 2014 at 8:05 AM, Chris Hafey <span dir="ltr"><<a href="mailto:chafey@gmail.com" target="_blank">chafey@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">Hi Aashish,<div>  Forgive my ignorance but I don't know much about osmesa or whether I am using it.  I am using VTK as built by homebrew and don't see any options related to osmesa.  I have not installed osmesa on the machine.  No errors or warnings are issued on the console.</div><span><font color="#888888"><div><br></div><div>Chris</div></font></span></div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 25, 2014 at 6:46 AM, Aashish Chaudhary <span dir="ltr"><<a href="mailto:aashish.chaudhary@kitware.com" target="_blank">aashish.chaudhary@kitware.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"><div>Hi Chris, </div><div><br></div>Are you using osmesa for the offscreen rendering? Are you getting any error on the console? <div><br></div><div>Thanks</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div>On Thu, Sep 25, 2014 at 7:32 AM, Chris Hafey <span dir="ltr"><<a href="mailto:chafey@gmail.com" target="_blank">chafey@gmail.com</a>></span> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">VTK 6.1.0</span><div style="font-family:arial,sans-serif;font-size:13px">Mac OS X Mavericks 10.9.5</div><div style="font-family:arial,sans-serif;font-size:13px">Macbook Pro 2012 Retina with nVidia GeForce GT 650M 1024 MB</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">My program uses VTK to do off screen volume rendering of medical images.  I suspect this is a bug in VTK and not my software because:</div><div style="font-family:arial,sans-serif;font-size:13px">1) GPURenderMode works fine on Windows (both in a VM running on same Mac and on two other Windows 7 boxes with an nVidia GPUs)</div><div style="font-family:arial,sans-serif;font-size:13px">2) RayCastRenderMode works fine on Mac OS X</div><div style="font-family:arial,sans-serif;font-size:13px">3) TextureRenderMode works fine on Mac OS X</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">I tried searching the mailing list and google and couldn't find anything.  The rendering code is about as basic as it can be - it simply sets the color, opacity, clip planes and matrix.  Any ideas on what I might be doing wrong or how I can debug?</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Thanks</div><span><font color="#888888"><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Chris Hafey</div><div style="font-family:arial,sans-serif;font-size:13px"></div></font></span></div>
<br></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>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 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> </font></span></div>
</blockquote></div><br></div>
</div></blockquote></div><br><br clear="all"><div><br></div>-- <br><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></blockquote></div><br></div>
</div></blockquote></div><br><br clear="all"><div><br></div>-- <br><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></blockquote></div><br></div>
</div></blockquote></div></div></div><div><div><br><br clear="all"><div><br></div>-- <br><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></div>
</blockquote></div><br></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><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>