<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,vtkRenderingFreeType,vtkRenderingOpenGL2)</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 "vtkImageMapToWindowLevelColors.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">  </span>double imgfact = 2.0;</div><div><br></div><div><span style="white-space:pre">        </span>vtkSmartPointer<vtkLookupTable> lookuptable = vtkSmartPointer<vtkLookupTable>::New();</div><div><span style="white-space:pre">     </span>lookuptable->GetTable()->Reset();</div><div><span style="white-space:pre">       </span>lookuptable->SetNumberOfColors(256);</div><div><span style="white-space:pre">       </span>lookuptable->SetRange(0, 255.0);</div><div><br></div><div><span style="white-space:pre">  </span>std::ifstream infile;</div><div><span style="white-space:pre"> </span>std::string line;</div><div><br></div><div><span style="white-space:pre">    </span>int ind = 0;</div><div><span style="white-space:pre">  </span>double r = 0, g = 0, b = 0, a = 0;</div><div><span style="white-space:pre">    </span>std::string sind, sr, sg, sb, sa;</div><div><br></div><div><span style="white-space:pre">    </span>infile.open("lutable.txt", ifstream::in);</div><div><span style="white-space:pre">   </span>if (infile.is_open())</div><div><span style="white-space:pre"> </span>{</div><div><span style="white-space:pre">             </span>while (infile.good() && ind < 255)</div><div><span style="white-space:pre">         </span>{</div><div><span style="white-space:pre">                     </span>std::getline(infile, line);</div><div><span style="white-space:pre">                   </span>std::istringstream is(line);</div><div><span style="white-space:pre">                  </span>std::getline(is, sind, ',');</div><div><span style="white-space:pre">                  </span>std::getline(is, sr, ',');</div><div><span style="white-space:pre">                    </span>std::getline(is, sg, ',');</div><div><span style="white-space:pre">                    </span>std::getline(is, sb, ',');</div><div><span style="white-space:pre">                    </span>std::getline(is, sa);</div><div><span style="white-space:pre">                 </span>ind = std::stoi(sind);</div><div><span style="white-space:pre">                        </span>r = std::stod(sr);</div><div><span style="white-space:pre">                    </span>g = std::stod(sg);</div><div><span style="white-space:pre">                    </span>b = std::stod(sb);</div><div><span style="white-space:pre">                    </span>a = std::stod(sa);</div><div><br></div><div><span style="white-space:pre">                   </span>lookuptable->SetTableValue(ind, r, g, b, a);</div><div><br></div><div><span style="white-space:pre">              </span>}</div><div><span style="white-space:pre">             </span>infile.close();</div><div><span style="white-space:pre">       </span>}</div><div><span style="white-space:pre">     </span>else</div><div><span style="white-space:pre">  </span>{</div><div><span style="white-space:pre">             </span>cout << "Error opening file";</div><div><span style="white-space:pre"> </span>}</div><div><br></div><div><span style="white-space:pre">    </span></div><div><span style="white-space:pre">      </span>lookuptable->Build();</div><div><span style="white-space:pre">      </span></div><div><br></div><div><span style="white-space:pre">     </span>vtkSmartPointer<vtkXMLImageDataReader> imgdat = vtkSmartPointer<vtkXMLImageDataReader>::New();</div><div><span style="white-space:pre">    </span>imgdat->SetFileName("testimage.vti");</div><div><span style="white-space:pre">    </span>imgdat->ReleaseDataFlagOn();</div><div><span style="white-space:pre">       </span>imgdat->Update();</div><div><br></div><div><span style="white-space:pre"> </span>int dims[3];</div><div><span style="white-space:pre">  </span>imgdat->GetOutput()->GetDimensions(dims);</div><div><br></div><div><span style="white-space:pre">      </span>int img_res_x = dims[0];</div><div><span style="white-space:pre">      </span>int img_res_y = dims[1];</div><div><span style="white-space:pre">      </span> </div><div><span style="white-space:pre">    </span>vtkSmartPointer<vtkImageResize> resize1 = vtkSmartPointer<vtkImageResize>::New();</div><div><span style="white-space:pre"> </span>resize1->SetInputConnection(imgdat->GetOutputPort());</div><div><span style="white-space:pre">   </span>resize1->SetOutputDimensions(img_res_x / imgfact, img_res_y / imgfact, 1);</div><div><span style="white-space:pre"> </span>resize1->SetResizeMethodToOutputDimensions();</div><div><span style="white-space:pre">      </span>resize1->ReleaseDataFlagOn();</div><div><br></div><div><span style="white-space:pre">     </span>vtkSmartPointer<vtkImageResize> resize2 = vtkSmartPointer<vtkImageResize>::New();</div><div><span style="white-space:pre"> </span>resize2->SetInputConnection(resize1->GetOutputPort());</div><div><span style="white-space:pre">  </span>resize2->SetOutputDimensions(img_res_x, img_res_y, 1);</div><div><span style="white-space:pre">     </span>resize2->SetResizeMethodToOutputDimensions();</div><div><span style="white-space:pre">      </span>resize2->ReleaseDataFlagOn();</div><div><br></div><div><span style="white-space:pre">     </span>vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();</div><div><span style="white-space:pre">    </span>vtkSmartPointer<vtkCellArray> triangles = vtkSmartPointer<vtkCellArray>::New();</div><div><span style="white-space:pre">   </span>vtkSmartPointer<vtkFloatArray> textureCoordinates = vtkSmartPointer<vtkFloatArray>::New();</div><div><span style="white-space:pre">        </span>textureCoordinates->SetNumberOfComponents(3);</div><div><span style="white-space:pre">      </span>textureCoordinates->SetName("TextureCoordinates");</div><div><br></div><div><span style="white-space:pre">      </span>float xval, yval, x, y, z;</div><div><br></div><div><span style="white-space:pre">   </span>double sinang = sin(vtkMath::RadiansFromDegrees(19.0));</div><div><span style="white-space:pre">       </span>z = sinang * 1000.0;</div><div><br></div><div><span style="white-space:pre"> </span>int ptIdIndex = 0;</div><div><br></div><div><span style="white-space:pre">   </span>for (int rrad = 0; rrad < 360; rrad++)</div><div><span style="white-space:pre">     </span>{</div><div><span style="white-space:pre">             </span>vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::New();</div><div><span style="white-space:pre">              </span>triangle->GetPointIds()->SetNumberOfIds(3);</div><div><br></div><div><span style="white-space:pre">            </span>// Point 1</div><div><span style="white-space:pre">            </span>points->InsertNextPoint(1000.0, 1000.0, 0.0);</div><div><span style="white-space:pre">              </span>textureCoordinates->InsertNextTuple3(.5, .5, 0);</div><div><span style="white-space:pre">           </span>triangle->GetPointIds()->SetId(0, ptIdIndex++);</div><div><br></div><div><span style="white-space:pre">                </span>// Point 2</div><div><span style="white-space:pre">            </span>xval = (float)(sin(((float)rrad * vtkMath::Pi()) / 180.0));</div><div><span style="white-space:pre">           </span>yval = (float)(cos(((float)rrad * vtkMath::Pi()) / 180.0));</div><div><span style="white-space:pre">           </span>x = 1000.0 + (1000.0 * xval);</div><div><span style="white-space:pre">         </span>y = 1000.0 + (1000.0 * yval);</div><div><span style="white-space:pre">         </span>points->InsertNextPoint(x, y, z);</div><div><span style="white-space:pre">          </span>textureCoordinates->InsertNextTuple3(x / 2000.0, y / 2000.0, 0);</div><div><span style="white-space:pre">           </span>triangle->GetPointIds()->SetId(1, ptIdIndex++);</div><div><br></div><div><span style="white-space:pre">                </span>// Point 3</div><div><span style="white-space:pre">            </span>xval = (float)(sin(((float)(rrad + 1) * vtkMath::Pi()) / 180.0));</div><div><span style="white-space:pre">             </span>yval = (float)(cos(((float)(rrad + 1) * vtkMath::Pi()) / 180.0));</div><div><span style="white-space:pre">             </span>x = 1000.0 + (1000.0 * xval);</div><div><span style="white-space:pre">         </span>y = 1000.0 + (1000.0 * yval);</div><div><span style="white-space:pre">         </span>points->InsertNextPoint(x, y, z);</div><div><span style="white-space:pre">          </span>textureCoordinates->InsertNextTuple3(x / 2000.0, y / 2000.0, 0);</div><div><span style="white-space:pre">           </span>triangle->GetPointIds()->SetId(2, ptIdIndex++);</div><div><br></div><div><span style="white-space:pre">                </span>triangles->InsertNextCell(triangle);</div><div><br></div><div><span style="white-space:pre">      </span>}</div><div><br></div><div><span style="white-space:pre">    </span>vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();</div><div><span style="white-space:pre">      </span>polyData->SetPoints(points);</div><div><span style="white-space:pre">       </span>polyData->SetPolys(triangles);</div><div><span style="white-space:pre">     </span>polyData->GetPointData()->SetTCoords(textureCoordinates);</div><div><br></div><div><span style="white-space:pre">      </span>vtkSmartPointer<vtkTexture> texture = vtkSmartPointer<vtkTexture>::New();</div><div><span style="white-space:pre"> </span>texture->MapColorScalarsThroughLookupTableOn();</div><div><span style="white-space:pre">    </span>texture->SetLookupTable(lookuptable);</div><div><span style="white-space:pre">      </span>texture->InterpolateOff();</div><div><span style="white-space:pre"> </span></div><div><span style="white-space:pre">      </span>texture->SetInputConnection(resize2->GetOutputPort());</div><div><br></div><div><span style="white-space:pre"> </span>vtkSmartPointer<vtkTransformPolyDataFilter> tf = vtkSmartPointer<vtkTransformPolyDataFilter>::New();</div><div><span style="white-space:pre">      </span>tf->SetInputData(polyData);</div><div><span style="white-space:pre">        </span>double xfmscale = 250.0;</div><div><br></div><div><span style="white-space:pre">     </span>vtkSmartPointer<vtkTransform> pdxfm = vtkSmartPointer<vtkTransform>::New();</div><div><span style="white-space:pre">       </span>pdxfm->Scale(xfmscale, xfmscale, xfmscale);</div><div><span style="white-space:pre">        </span>pdxfm->Translate(-img_res_x / 2, -img_res_y / 2, 0);</div><div><span style="white-space:pre">       </span>tf->SetTransform(pdxfm);</div><div><br></div><div><span style="white-space:pre">  </span>vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();</div><div><span style="white-space:pre">    </span>mapper->SetInputConnection(tf->GetOutputPort());</div><div><span style="white-space:pre">        </span>mapper->ScalarVisibilityOff();</div><div><br></div><div><span style="white-space:pre">    </span>vtkSmartPointer<vtkActor> radarActor = vtkSmartPointer<vtkActor>::New();</div><div><span style="white-space:pre">  </span>radarActor->SetMapper(mapper);</div><div><span style="white-space:pre">     </span>radarActor->SetTexture(texture);</div><div><span style="white-space:pre">   </span>radarActor->GetProperty()->LightingOff();</div><div><span style="white-space:pre">       </span>radarActor->GetProperty()->ShadingOff();</div><div><br></div><div><span style="white-space:pre">       </span>vtkSmartPointer<vtkRenderer> renderer =<span style="white-space:pre">        </span>vtkSmartPointer<vtkRenderer>::New();</div><div><span style="white-space:pre">    </span>vtkSmartPointer<vtkRenderWindow> renderWindow =<span style="white-space:pre">        </span>vtkSmartPointer<vtkRenderWindow>::New();</div><div><span style="white-space:pre">        </span>renderWindow->AddRenderer(renderer);</div><div><span style="white-space:pre">       </span>vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =<span style="white-space:pre">    </span>vtkSmartPointer<vtkRenderWindowInteractor>::New();</div><div><span style="white-space:pre">      </span>renderWindowInteractor->SetRenderWindow(renderWindow);</div><div><br></div><div><span style="white-space:pre">    </span>renderer->AddActor(radarActor);</div><div><br></div><div><span style="white-space:pre">   </span>renderWindow->Render();</div><div><span style="white-space:pre">    </span>renderWindowInteractor->Start();</div><div><br></div><div><span style="white-space:pre">  </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>