<div dir="ltr"><b>Thank you Ken. That fixed it. I changed the following function calls to make it work:</b><div><br></div><div>textureCoordinates->SetNumberOfComponents(2);<br></div><div><br></div><div><b>and</b></div><div><b><br></b></div><div>textureCoordinates->InsertNextTuple2(x, y);<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 3, 2017 at 10:32 AM, Ken Martin <span dir="ltr"><<a href="mailto:ken.martin@kitware.com" target="_blank">ken.martin@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">You can fix the issue by using 2D texture coordinates with a 2D texture map (better memory and performance as well). Apparently the old version accepted 3D tcoords even when the texturemap was 2D. <div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Wed, Aug 2, 2017 at 3:43 PM, Donny Zimmerman <span dir="ltr"><<a href="mailto:zmanvortex@gmail.com" target="_blank">zmanvortex@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><b>The following code works in VTK 7.1 but does not work in VTK 8.0 using the same PC and compiled with Visual Studio 2015. I have attached the XML .vti image file and also the .txt file used for the lookup table.</b><div><br></div><div><div>#include "stdafx.h"</div><div><br></div><div>#include "vtkAutoInit.h"</div><div>#define vtkRenderingCore_AUTOINIT 3(vtkInteractionStyle,vtkRende<wbr>ringFreeType,vtkRenderingOpenG<wbr>L2)</div><div>#define vtkRenderingVolume_AUTOINIT 1(vtkRenderingVolumeOpenGL2)</div><div><br></div><div>#include "vtkXMLImageDataReader.h"</div><div>#include "vtkImageData.h"</div><div>#include "vtkImageViewer2.h"</div><div>#include "vtkLookupTable.h"</div><div>#include "vtkRenderer.h"</div><div>#include "vtkRenderWindowInteractor.h"</div><div>#include "vtkRenderWindow.h"</div><div>#include "vtkImageResize.h"</div><div>#include "vtkImageMapToWindowLevelColor<wbr>s.h"</div><div>#include "vtkTransformPolyDataFilter.h"</div><div>#include "vtkFloatArray.h"</div><div>#include "vtkMath.h"</div><div>#include "vtkTriangle.h"</div><div>#include "vtkPointData.h"</div><div>#include "vtkTexture.h"</div><div>#include "vtkTransform.h"</div><div>#include "vtkPolyDataMapper.h"</div><div>#include "vtkProperty.h"</div><div><br></div><div>#include <iostream> // std::cout</div><div>#include <sstream> // std::istringstream</div><div>#include <string> // std::string</div><div>#include <math.h></div><div><br></div><div>int main()</div><div>{</div><div><span style="white-space:pre-wrap"> </span>double imgfact = 2.0;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkLookupTable<wbr>> lookuptable = vtkSmartPointer<vtkLookupTable<wbr>>::New();</div><div><span style="white-space:pre-wrap"> </span>lookuptable->GetTable()->Reset<wbr>();</div><div><span style="white-space:pre-wrap"> </span>lookuptable->SetNumberOfColors<wbr>(256);</div><div><span style="white-space:pre-wrap"> </span>lookuptable->SetRange(0, 255.0);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>std::ifstream infile;</div><div><span style="white-space:pre-wrap"> </span>std::string line;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>int ind = 0;</div><div><span style="white-space:pre-wrap"> </span>double r = 0, g = 0, b = 0, a = 0;</div><div><span style="white-space:pre-wrap"> </span>std::string sind, sr, sg, sb, sa;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>infile.open("lutable.txt", ifstream::in);</div><div><span style="white-space:pre-wrap"> </span>if (infile.is_open())</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>while (infile.good() && ind < 255)</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>std::getline(infile, line);</div><div><span style="white-space:pre-wrap"> </span>std::istringstream is(line);</div><div><span style="white-space:pre-wrap"> </span>std::getline(is, sind, ',');</div><div><span style="white-space:pre-wrap"> </span>std::getline(is, sr, ',');</div><div><span style="white-space:pre-wrap"> </span>std::getline(is, sg, ',');</div><div><span style="white-space:pre-wrap"> </span>std::getline(is, sb, ',');</div><div><span style="white-space:pre-wrap"> </span>std::getline(is, sa);</div><div><span style="white-space:pre-wrap"> </span>ind = std::stoi(sind);</div><div><span style="white-space:pre-wrap"> </span>r = std::stod(sr);</div><div><span style="white-space:pre-wrap"> </span>g = std::stod(sg);</div><div><span style="white-space:pre-wrap"> </span>b = std::stod(sb);</div><div><span style="white-space:pre-wrap"> </span>a = std::stod(sa);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>lookuptable->SetTableValue(ind<wbr>, r, g, b, a);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>infile.close();</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>else</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>cout << "Error opening file";</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>lookuptable->Build();</div><div><span style="white-space:pre-wrap"> </span></div><div><br></div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkXMLImageDat<wbr>aReader> imgdat = vtkSmartPointer<vtkXMLImageDat<wbr>aReader>::New();</div><div><span style="white-space:pre-wrap"> </span>imgdat->SetFileName("testimage<wbr>.vti");</div><div><span style="white-space:pre-wrap"> </span>imgdat->ReleaseDataFlagOn();</div><div><span style="white-space:pre-wrap"> </span>imgdat->Update();</div><div><br></div><div><span style="white-space:pre-wrap"> </span>int dims[3];</div><div><span style="white-space:pre-wrap"> </span>imgdat->GetOutput()->GetDimens<wbr>ions(dims);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>int img_res_x = dims[0];</div><div><span style="white-space:pre-wrap"> </span>int img_res_y = dims[1];</div><div><span style="white-space:pre-wrap"> </span> </div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkImageResize<wbr>> resize1 = vtkSmartPointer<vtkImageResize<wbr>>::New();</div><div><span style="white-space:pre-wrap"> </span>resize1->SetInputConnection(im<wbr>gdat->GetOutputPort());</div><div><span style="white-space:pre-wrap"> </span>resize1->SetOutputDimensions(i<wbr>mg_res_x / imgfact, img_res_y / imgfact, 1);</div><div><span style="white-space:pre-wrap"> </span>resize1->SetResizeMethodToOutp<wbr>utDimensions();</div><div><span style="white-space:pre-wrap"> </span>resize1->ReleaseDataFlagOn();</div><div><br></div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkImageResize<wbr>> resize2 = vtkSmartPointer<vtkImageResize<wbr>>::New();</div><div><span style="white-space:pre-wrap"> </span>resize2->SetInputConnection(re<wbr>size1->GetOutputPort());</div><div><span style="white-space:pre-wrap"> </span>resize2->SetOutputDimensions(i<wbr>mg_res_x, img_res_y, 1);</div><div><span style="white-space:pre-wrap"> </span>resize2->SetResizeMethodToOutp<wbr>utDimensions();</div><div><span style="white-space:pre-wrap"> </span>resize2->ReleaseDataFlagOn();</div><div><br></div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::Ne<wbr>w();</div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkCellArray> triangles = vtkSmartPointer<vtkCellArray>:<wbr>:New();</div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkFloatArray> textureCoordinates = vtkSmartPointer<vtkFloatArray><wbr>::New();</div><div><span style="white-space:pre-wrap"> </span>textureCoordinates->SetNumberO<wbr>fComponents(3);</div><div><span style="white-space:pre-wrap"> </span>textureCoordinates->SetName("T<wbr>extureCoordinates");</div><div><br></div><div><span style="white-space:pre-wrap"> </span>float xval, yval, x, y, z;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>double sinang = sin(vtkMath::RadiansFromDegree<wbr>s(19.0));</div><div><span style="white-space:pre-wrap"> </span>z = sinang * 1000.0;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>int ptIdIndex = 0;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>for (int rrad = 0; rrad < 360; rrad++)</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::<wbr>New();</div><div><span style="white-space:pre-wrap"> </span>triangle->GetPointIds()->SetNu<wbr>mberOfIds(3);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>// Point 1</div><div><span style="white-space:pre-wrap"> </span>points->InsertNextPoint(1000.0<wbr>, 1000.0, 0.0);</div><div><span style="white-space:pre-wrap"> </span>textureCoordinates->InsertNext<wbr>Tuple3(.5, .5, 0);</div><div><span style="white-space:pre-wrap"> </span>triangle->GetPointIds()->SetId<wbr>(0, ptIdIndex++);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>// Point 2</div><div><span style="white-space:pre-wrap"> </span>xval = (float)(sin(((float)rrad * vtkMath::Pi()) / 180.0));</div><div><span style="white-space:pre-wrap"> </span>yval = (float)(cos(((float)rrad * vtkMath::Pi()) / 180.0));</div><div><span style="white-space:pre-wrap"> </span>x = 1000.0 + (1000.0 * xval);</div><div><span style="white-space:pre-wrap"> </span>y = 1000.0 + (1000.0 * yval);</div><div><span style="white-space:pre-wrap"> </span>points->InsertNextPoint(x, y, z);</div><div><span style="white-space:pre-wrap"> </span>textureCoordinates->InsertNext<wbr>Tuple3(x / 2000.0, y / 2000.0, 0);</div><div><span style="white-space:pre-wrap"> </span>triangle->GetPointIds()->SetId<wbr>(1, ptIdIndex++);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>// Point 3</div><div><span style="white-space:pre-wrap"> </span>xval = (float)(sin(((float)(rrad + 1) * vtkMath::Pi()) / 180.0));</div><div><span style="white-space:pre-wrap"> </span>yval = (float)(cos(((float)(rrad + 1) * vtkMath::Pi()) / 180.0));</div><div><span style="white-space:pre-wrap"> </span>x = 1000.0 + (1000.0 * xval);</div><div><span style="white-space:pre-wrap"> </span>y = 1000.0 + (1000.0 * yval);</div><div><span style="white-space:pre-wrap"> </span>points->InsertNextPoint(x, y, z);</div><div><span style="white-space:pre-wrap"> </span>textureCoordinates->InsertNext<wbr>Tuple3(x / 2000.0, y / 2000.0, 0);</div><div><span style="white-space:pre-wrap"> </span>triangle->GetPointIds()->SetId<wbr>(2, ptIdIndex++);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>triangles->InsertNextCell(tria<wbr>ngle);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::<wbr>New();</div><div><span style="white-space:pre-wrap"> </span>polyData->SetPoints(points);</div><div><span style="white-space:pre-wrap"> </span>polyData->SetPolys(triangles);</div><div><span style="white-space:pre-wrap"> </span>polyData->GetPointData()->SetT<wbr>Coords(textureCoordinates);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkTexture> texture = vtkSmartPointer<vtkTexture>::N<wbr>ew();</div><div><span style="white-space:pre-wrap"> </span>texture->MapColorScalarsThroug<wbr>hLookupTableOn();</div><div><span style="white-space:pre-wrap"> </span>texture->SetLookupTable(lookup<wbr>table);</div><div><span style="white-space:pre-wrap"> </span>texture->InterpolateOff();</div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>texture->SetInputConnection(re<wbr>size2->GetOutputPort());</div><div><br></div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkTransformPo<wbr>lyDataFilter> tf = vtkSmartPointer<vtkTransformPo<wbr>lyDataFilter>::New();</div><div><span style="white-space:pre-wrap"> </span>tf->SetInputData(polyData);</div><div><span style="white-space:pre-wrap"> </span>double xfmscale = 250.0;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkTransform> pdxfm = vtkSmartPointer<vtkTransform>:<wbr>:New();</div><div><span style="white-space:pre-wrap"> </span>pdxfm->Scale(xfmscale, xfmscale, xfmscale);</div><div><span style="white-space:pre-wrap"> </span>pdxfm->Translate(-img_res_x / 2, -img_res_y / 2, 0);</div><div><span style="white-space:pre-wrap"> </span>tf->SetTransform(pdxfm);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkPolyDataMap<wbr>per> mapper = vtkSmartPointer<vtkPolyDataMap<wbr>per>::New();</div><div><span style="white-space:pre-wrap"> </span>mapper->SetInputConnection(tf-<wbr>>GetOutputPort());</div><div><span style="white-space:pre-wrap"> </span>mapper->ScalarVisibilityOff();</div><div><br></div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkActor> radarActor = vtkSmartPointer<vtkActor>::New<wbr>();</div><div><span style="white-space:pre-wrap"> </span>radarActor->SetMapper(mapper);</div><div><span style="white-space:pre-wrap"> </span>radarActor->SetTexture(texture<wbr>);</div><div><span style="white-space:pre-wrap"> </span>radarActor->GetProperty()->Lig<wbr>htingOff();</div><div><span style="white-space:pre-wrap"> </span>radarActor->GetProperty()->Sha<wbr>dingOff();</div><div><br></div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkRenderer> renderer =<span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkRenderer>::<wbr>New();</div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkRenderWindo<wbr>w> renderWindow =<span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkRenderWindo<wbr>w>::New();</div><div><span style="white-space:pre-wrap"> </span>renderWindow->AddRenderer(rend<wbr>erer);</div><div><span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkRenderWindo<wbr>wInteractor> renderWindowInteractor =<span style="white-space:pre-wrap"> </span>vtkSmartPointer<vtkRenderWindo<wbr>wInteractor>::New();</div><div><span style="white-space:pre-wrap"> </span>renderWindowInteractor->SetRen<wbr>derWindow(renderWindow);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>renderer->AddActor(radarActor)<wbr>;</div><div><br></div><div><span style="white-space:pre-wrap"> </span>renderWindow->Render();</div><div><span style="white-space:pre-wrap"> </span>renderWindowInteractor->Start(<wbr>);</div><div><br></div><div><span style="white-space:pre-wrap"> </span>return 0;</div><div>}</div></div><div><br></div><div><b>In 7.1 I see the texture rendered on the polydata correctly, but in 8.0 I only see the white shaded polydata. Any idea what may have changed in 8.0 that would prevent this from working.</b></div><div><b><br></b></div><div><b>Thanks.</b></div><div><br></div></div>
<br></div></div>______________________________<wbr>_________________<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/opensou<wbr>rce/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_FA<wbr>Q</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=<wbr>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/mail<wbr>man/listinfo/vtkusers</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_-1119480815868809723gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Ken Martin PhD<div>Distinguished Engineer<br><span style="font-size:12.8px">Kitware Inc.</span><br></div><div>28 Corporate Drive<br>Clifton Park NY 12065<br><div><br></div><div><span style="font-size:10pt;font-family:Tahoma,sans-serif">This communication,
including all attachments, contains confidential and legally privileged
information, and it is intended only for the use of the addressee. Access to this email by anyone else is
unauthorized. If you are not the intended recipient, any disclosure, copying,
distribution or any action taken in reliance on it is prohibited and may be
unlawful. If you received this communication in error please notify us
immediately and destroy the original message.
Thank you.</span></div></div></div></div></div>
</font></span></div>
</blockquote></div><br></div>