<div dir="ltr">Thanks for the code Alister, I can't see anything obvious that could be causing the issue. I will try<div>to reproduce it here, in the mean time, could you try something for me? Exchange </div><div>vtkSmartVolumeMapper for vtkGPUVolumeRayCastMapper and see if that helps.<div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 17, 2017 at 1:37 PM, Alister O Maguire <span dir="ltr"><<a href="mailto:aom@uoregon.edu" target="_blank">aom@uoregon.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Alvaro,<br>
<br>
Thanks for the response. The original data set is a rectilinear grid (which should contain cell and point data), but I'm creating a vtkImageData object from the data within this grid, and this image data is what I'm passing to the volume mapper. VTK should be built with OpenGL2, so I don't believe that is an issue. Currently, I'm just using the default render mode for the mapper. I've attached the module that uses the mapper below.<br>
<br>
<br>
<br>
<br>
<br>
<br>
/*****************************<wbr>******************************<wbr>******************<br>
*<br>
* Copyright (c) 2000 - 2017, Lawrence Livermore National Security, LLC<br>
* Produced at the Lawrence Livermore National Laboratory<br>
* LLNL-CODE-442911<br>
* All rights reserved.<br>
*<br>
* This file is part of VisIt. For details, see <a href="https://visit.llnl.gov/" rel="noreferrer" target="_blank">https://visit.llnl.gov/</a>. The<br>
* full copyright notice is contained in the file COPYRIGHT located at the root<br>
* of the VisIt distribution or at <a href="http://www.llnl.gov/visit/copyright.html" rel="noreferrer" target="_blank">http://www.llnl.gov/visit/copy<wbr>right.html</a>.<br>
*<br>
* Redistribution and use in source and binary forms, with or without<br>
* modification, are permitted provided that the following conditions are met:<br>
*<br>
* - Redistributions of source code must retain the above copyright notice,<br>
* this list of conditions and the disclaimer below.<br>
* - Redistributions in binary form must reproduce the above copyright notice,<br>
* this list of conditions and the disclaimer (as noted below) in the<br>
* documentation and/or other materials provided with the distribution.<br>
* - Neither the name of the LLNS/LLNL nor the names of its contributors may<br>
* be used to endorse or promote products derived from this software without<br>
* specific prior written permission.<br>
*<br>
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"<br>
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,<br>
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY<br>
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL<br>
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR<br>
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER<br>
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT<br>
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY<br>
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH<br>
* DAMAGE.<br>
*<br>
******************************<wbr>******************************<wbr>*****************/<br>
<br>
// ******************************<wbr>******************************<wbr>************* //<br>
// avtDefaultRenderer.C //<br>
// ******************************<wbr>******************************<wbr>************* //<br>
<br>
#include <vtkAutoInit.h><br>
VTK_MODULE_INIT(vtkRenderingVo<wbr>lumeOpenGL2);<br>
<br>
#include "avtDefaultRenderer.h"<br>
#include <avtOpenGLExtensionManager.h><br>
<br>
#include <vtkRectilinearGrid.h><br>
#include <vtkUnstructuredGrid.h><br>
#include <vtkRenderer.h><br>
<br>
#include <VolumeAttributes.h><br>
#include <avtCallback.h><br>
#include <DebugStream.h><br>
<br>
#include <vtkColorTransferFunction.h><br>
#include <vtkVolumeProperty.h><br>
#include <vtkImageData.h><br>
#include <vtkPiecewiseFunction.h><br>
#include <LightList.h><br>
<br>
<br>
// ******************************<wbr>******************************<wbr>****************<br>
// Method: avtDefaultRenderer::avtDefault<wbr>Renderer<br>
//<br>
// Purpose:<br>
// Initialize the memebers associated with the default renderer.<br>
//<br>
// Programmer: Alister Maguire<br>
// Creation: April 3, 2017<br>
//<br>
// Modifications:<br>
//<br>
// ******************************<wbr>******************************<wbr>****************<br>
<br>
avtDefaultRenderer::avtDefault<wbr>Renderer()<br>
{<br>
VTKRen = NULL;<br>
lastVolume = NULL;<br>
gridToRender = NULL;<br>
resetColorMap = false;<br>
volumeProp = vtkSmartPointer<vtkVolumePrope<wbr>rty>::New();<br>
mapper = vtkSmartPointer<vtkSmartVolume<wbr>Mapper>::New();<br>
}<br>
<br>
<br>
// ******************************<wbr>******************************<wbr>****************<br>
// Method: avtDefaultRenderer::~avtDefaul<wbr>tRenderer<br>
//<br>
// Purpose:<br>
// Destructor.<br>
//<br>
// Programmer: Alister Maguire<br>
// Creation: April 3, 2017<br>
//<br>
// Modifications:<br>
//<br>
// ******************************<wbr>******************************<wbr>****************<br>
<br>
avtDefaultRenderer::~avtDefaul<wbr>tRenderer()<br>
{<br>
}<br>
<br>
<br>
// ******************************<wbr>******************************<wbr>****************<br>
// Method: avtDefaultRenderer::Render<br>
//<br>
// Purpose:<br>
// Render a volume using a vtkSmartVolumeMapper<br>
//<br>
// Arguments:<br>
// props : the rendering properties<br>
// volume : the volume to be rendered<br>
//<br>
// Programmer: Alister Maguire<br>
// Creation: April 3, 2017<br>
//<br>
// Modifications:<br>
//<br>
// ******************************<wbr>******************************<wbr>****************<br>
<br>
void<br>
avtDefaultRenderer::Render(<br>
const avtVolumeRendererImplementatio<wbr>n::RenderProperties &props,<br>
const avtVolumeRendererImplementatio<wbr>n::VolumeData &volume)<br>
{<br>
if (props.dataIs2D)<br>
return;<br>
<br>
bool needsReset = false;<br>
const char *mName = "avtDefaultRenderer::Render ";<br>
<br>
//Add volume data to mapper<br>
//Need to convert it from RectilinearGrid to ImageData<br>
if(gridToRender == NULL)<br>
{<br>
debug5 << mName << "Converting from rectilinear grid to image data" << endl;<br>
<br>
int dims[3], extent[6];<br>
((vtkRectilinearGrid *)volume.grid)->GetDimensions(<wbr>dims);<br>
((vtkRectilinearGrid *)volume.grid)->GetExtent(exte<wbr>nt);<br>
vtkDataArray *da = ((vtkRectilinearGrid *)volume.grid)->GetPointData()<wbr>->GetScalars();<br>
<br>
vtkRectilinearGrid *rgrid = (vtkRectilinearGrid *) volume.grid;<br>
double spacingX = rgrid->GetXCoordinates()->GetT<wbr>uple1(1)-<br>
rgrid->GetXCoordinates()->GetT<wbr>uple1(0);<br>
double spacingY = rgrid->GetYCoordinates()->GetT<wbr>uple1(1)-<br>
rgrid->GetYCoordinates()->GetT<wbr>uple1(0);<br>
double spacingZ = rgrid->GetZCoordinates()->GetT<wbr>uple1(1)-<br>
rgrid->GetZCoordinates()->GetT<wbr>uple1(0);<br>
<br>
gridToRender = vtkSmartPointer<vtkImageData>:<wbr>:New();<br>
gridToRender->SetDimensions(di<wbr>ms);<br>
gridToRender->SetExtent(extent<wbr>);<br>
gridToRender->SetSpacing(spaci<wbr>ngX, spacingY, spacingZ);<br>
gridToRender->AllocateScalars(<wbr>VTK_FLOAT, 1);<br>
int limit = dims[0] * dims[1] * dims[2];<br>
float *p = (float *)gridToRender->GetScalarPoint<wbr>er();<br>
<br>
//Set the origin to match the lower bounds of the grid<br>
double bounds[6];<br>
((vtkRectilinearGrid *)volume.grid)->GetBounds(boun<wbr>ds);<br>
gridToRender->SetOrigin(bounds<wbr>[0], bounds[2], bounds[4]);<br>
<br>
for (int i = 0 ; i < limit ; i++)<br>
{<br>
// z-axis is reversed somehow<br>
p[i] = da->GetTuple1(i);<br>
}<br>
<br>
<br>
debug5 << mName << "Adding data to the mapper" << endl;<br>
<br>
mapper->SetInputData(gridToRen<wbr>der);<br>
mapper->SetScalarModeToUsePoin<wbr>tData();<br>
mapper->SetBlendModeToComposit<wbr>e();<br>
resetColorMap = true;<br>
needsReset = true;<br>
}<br>
<br>
if(resetColorMap || oldAtts != props.atts)<br>
{<br>
<br>
debug5 << mName << "Resetting color" << endl;<br>
<br>
//getting color/alpha transfer function from VisIt<br>
unsigned char rgba[256*4];<br>
props.atts.GetTransferFunction<wbr>(rgba);<br>
float min = volume.data.min;<br>
float max = volume.data.max;<br>
float range = max - min;<br>
vtkColorTransferFunction *trans_func = vtkColorTransferFunction::New(<wbr>);<br>
vtkPiecewiseFunction *opacity = vtkPiecewiseFunction::New();<br>
for(int i = 0; i < 256; i++) {<br>
float pos = min + (i/255.f)*range;<br>
trans_func->AddRGBPoint(pos, rgba[4*i]/255.f, rgba[4*i+1]/255.f, rgba[4*i+2]/255.f);<br>
opacity->AddPoint(pos, rgba[i*4+3]/255.f);<br>
}<br>
<br>
volumeProp->SetColor(trans_fun<wbr>c);<br>
volumeProp->SetScalarOpacity(o<wbr>pacity);<br>
<br>
resetColorMap = false;<br>
needsReset = true;<br>
}<br>
<br>
debug5 << mName << "Rendering!" << endl;<br>
<br>
//Create the volume to be rendered and<br>
//set its mapper to our SmartVolumeMapper.<br>
if (lastVolume == NULL || needsReset)<br>
{<br>
if (lastVolume != NULL)<br>
lastVolume->Delete();<br>
lastVolume = vtkSmartPointer<vtkVolume>::Ne<wbr>w();<br>
lastVolume->SetMapper(mapper);<br>
lastVolume->SetProperty(volume<wbr>Prop);<br>
}<br>
<br>
mapper->Render(VTKRen, lastVolume);<span class="gmail-"><br>
}<br>
<br>
<br>
<br>
<br>
<br>
<br>
On 2017/05/17 09:14, Alvaro Sanchez wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">
Hi,<br>
I assume your dataset contains both cell and point data. Did you<br>
build VTK with OpenGL2?<br>
Are you using any particular configuration in vtkSmartVolumeMapper<br>
(GPURenderMode,<br>
VectorMode, etc.)?<br>
<br>
It would be nice If you could provide some sample code.<br>
<br>
On Sun, May 14, 2017 at 11:01 PM, Alister O Maguire <<a href="mailto:aom@uoregon.edu" target="_blank">aom@uoregon.edu</a>><br>
wrote:<br>
<br>
</span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">
Hello,<br>
<br>
I'm using the vtkSmartVolumeMapper for volume rendering, but it<br>
appears to only be rendering as cell-centered data (you can clearly<br>
see the cell boundaries). I'm calling SetScalarModeToUsePointData(),<br>
but this doesn't seem to be having any affect. It actually looks the<br>
same as when I call SetScalarModeToUseCellData(). Any ideas on how<br>
to get this mapper to use point centered data when rendering?<br>
<br>
Best,<br>
Alister<br>
______________________________<wbr>_________________<br></span>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a> [1]<span class="gmail-"><br>
<br>
Visit other Kitware open-source projects at<br>
</span><a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensou<wbr>rce/opensource.html</a> [2]<span class="gmail-"><br>
<br>
Please keep messages on-topic and check the VTK FAQ at:<br>
</span><a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FA<wbr>Q</a> [3]<span class="gmail-"><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br></span>
[4]<span class="gmail-"><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
</span><a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/vtkusers</a> [5]<br>
</blockquote><span class="gmail-">
<br>
--<br>
<br>
Alvaro Sanchez<br>
Kitware, Inc.<br>
Senior R&D Engineer<br>
21 Corporate Drive<br>
Clifton Park, NY 12065-8662<br>
Phone: <a href="tel:518-881-4901" value="+15188814901" target="_blank">518-881-4901</a><br>
<br></span>
Links:<br>
------<br>
[1] <a href="http://www.kitware.com" rel="noreferrer" target="_blank">http://www.kitware.com</a><br>
[2] <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
[3] <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FA<wbr>Q</a><br>
[4] <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
[5] <a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mail<wbr>man/listinfo/vtkusers</a><br>
</blockquote>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Alvaro Sanchez</div><div>Kitware, Inc.</div><div>Senior R&D Engineer</div><div>21 Corporate Drive</div><div>Clifton Park, NY 12065-8662</div><div>Phone: 518-881-4901</div></div></div></div></div></div></div>
</div></div></div></div>