Commit 81ff4519 authored by Ben Boeckel's avatar Ben Boeckel

IO/Geometry: add obj index tests

Change-Id: I72d7dcf6e94c692b243dbfbfc156b3ea093a1499
parent b11deb8a
......@@ -22,6 +22,7 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
UnstructuredGridCellGradients.cxx
UnstructuredGridFastGradients.cxx
UnstructuredGridGradients.cxx
TestOBJReaderRelative.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 TestOBJReaderRelative( int argc, char *argv[] )
{
int retVal = 0;
// Create the reader.
char* fname_rel = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/relative_indices.obj");
vtkSmartPointer<vtkOBJReader> reader_rel =
vtkSmartPointer<vtkOBJReader>::New();
reader_rel->SetFileName(fname_rel);
reader_rel->Update();
delete [] fname_rel;
// Create the reader.
char* fname_abs = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/absolute_indices.obj");
vtkSmartPointer<vtkOBJReader> reader_abs =
vtkSmartPointer<vtkOBJReader>::New();
reader_abs->SetFileName(fname_abs);
reader_abs->Update();
delete [] fname_abs;
vtkPolyData *data_rel = reader_rel->GetOutput();
vtkPolyData *data_abs = reader_abs->GetOutput();
#define CHECK(obj, method) \
if (obj##_rel->method != obj##_abs->method) \
{ \
cerr << "Error: different values for " #obj "->" #method << endl; \
retVal = 1; \
}
#define CHECK_ARRAY(obj, idx) \
if (obj##_rel[idx] != obj##_abs[idx]) \
{ \
cerr << "Error: different values for " #obj "[" << idx << "]" << endl; \
retVal = 1; \
}
#define CHECK_SCALAR(obj) \
if (obj##_rel != obj##_abs) \
{ \
cerr << "Error: different values for " #obj << endl; \
retVal = 1; \
}
CHECK(data, GetNumberOfVerts())
CHECK(data, GetNumberOfLines())
CHECK(data, GetNumberOfCells())
CHECK(data, GetNumberOfStrips())
vtkCellArray *polys_rel = data_rel->GetPolys();
vtkCellArray *polys_abs = data_abs->GetPolys();
CHECK(polys, GetNumberOfCells());
vtkIdType npts_rel;
vtkIdType npts_abs;
vtkIdType *pts_rel;
vtkIdType *pts_abs;
polys_rel->InitTraversal();
polys_abs->InitTraversal();
while (!polys_rel->GetNextCell(npts_rel, pts_rel) &&
!polys_abs->GetNextCell(npts_abs, pts_abs))
{
CHECK_SCALAR(npts)
for (vtkIdType i = 0; i < npts_rel && i < npts_abs; ++i)
{
CHECK_ARRAY(pts, i)
}
}
#undef CHECK_SCALAR
#undef CHECK_ARRAY
#undef CHECK
return retVal;
}
b16e3a09c21bcee11ef17ecbd0d2f967
1d99f3d4136d467f8dfd6b42bf7f7f03
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