Commit fb034ce4 authored by Casey Goodlett's avatar Casey Goodlett

Fix names of texture and normal arrays in the OBJ reader

Because the arrays were not named, they did not appear in ParaView.

Change-Id: I76500c1fb037c443ca3bcf2b71e2907061304d7c
parent 0ed01862
......@@ -23,6 +23,7 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
UnstructuredGridFastGradients.cxx
UnstructuredGridGradients.cxx
TestOBJReaderRelative.cxx,NO_VALID
TestOBJReaderNormalsTCoords.cxx,NO_VALID
TestOpenFOAMReader.cxx
TestProStarReader.cxx
TestTecplotReader.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestTecPlotReader.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME Test of vtkTecplotReader
// .SECTION Description
//
#include "vtkOBJReader.h"
#include "vtkDebugLeaks.h"
#include "vtkCellArray.h"
#include "vtkPointData.h"
#include "vtkSmartPointer.h"
#include "vtkTestUtilities.h"
int TestOBJReaderNormalsTCoords( int argc, char *argv[] )
{
int retVal = 0;
// Create the reader.
char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/obj_with_normals_and_tcoords.obj");
vtkSmartPointer<vtkOBJReader> reader =
vtkSmartPointer<vtkOBJReader>::New();
reader->SetFileName(fname);
reader->Update();
delete [] fname;
vtkPolyData *data = reader->GetOutput();
if(!data)
{
std::cerr << "Could not read data" << std::endl;
return 1;
}
if(data->GetNumberOfPoints() != 4)
{
std::cerr << "Invalid number of points" << std::endl;
return 1;
}
if(data->GetPointData()->GetNumberOfArrays() != 2)
{
std::cerr << "Invalid number of arrays" << std::endl;
return 1;
}
if(!data->GetPointData()->HasArray("TCoords"))
{
std::cerr << "Could not find TCoords array" << std::endl;
return 1;
}
if(!data->GetPointData()->HasArray("Normals"))
{
std::cerr << "Could not find TCoords array" << std::endl;
return 1;
}
return retVal;
}
......@@ -130,8 +130,10 @@ int vtkOBJReader::RequestData(
vtkPoints *points = vtkPoints::New();
vtkFloatArray *tcoords = vtkFloatArray::New();
tcoords->SetNumberOfComponents(2);
tcoords->SetName("TCoords");
vtkFloatArray *normals = vtkFloatArray::New();
normals->SetNumberOfComponents(3);
normals->SetName("Normals");
vtkCellArray *polys = vtkCellArray::New();
vtkCellArray *tcoord_polys = vtkCellArray::New();
......@@ -541,7 +543,9 @@ int vtkOBJReader::RequestData(
// if there is an exact correspondence between tcoords and vertices then can simply
// assign the tcoords points as point data
if (hasTCoords && tcoords_same_as_verts)
{
output->GetPointData()->SetTCoords(tcoords);
}
// if there is an exact correspondence between normals and vertices then can simply
// assign the normals as point data
......@@ -558,9 +562,11 @@ int vtkOBJReader::RequestData(
vtkPoints *new_points = vtkPoints::New();
vtkFloatArray *new_tcoords = vtkFloatArray::New();
new_tcoords->SetName("TCoords");
new_tcoords->SetNumberOfComponents(2);
vtkFloatArray *new_normals = vtkFloatArray::New();
new_normals->SetNumberOfComponents(3);
new_normals->SetName("Normals");
vtkCellArray *new_polys = vtkCellArray::New();
// for each poly, copy its vertices into new_points (and point at them)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment